@memori.ai/memori-webcomponent 7.32.4 → 7.32.6
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 +1 -1
- package/package.json +2 -2
|
@@ -242,7 +242,7 @@ to {
|
|
|
242
242
|
* SPDX-License-Identifier: MIT
|
|
243
243
|
*/
|
|
244
244
|
const lf="144",cf={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},uf={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},df=0,hf=1,pf=2,mf=3,ff=0,gf=1,vf=2,yf=3,_f=0,Sf=1,bf=2,xf=0,Cf=1,wf=2,Af=3,Ef=4,If=5,Tf=100,Mf=101,Rf=102,Pf=103,Nf=104,Of=200,Df=201,Lf=202,kf=203,Bf=204,zf=205,Ff=206,Uf=207,jf=208,Gf=209,Hf=210,Vf=0,Wf=1,qf=2,Jf=3,Kf=4,Yf=5,Xf=6,Qf=7,$f=0,Zf=1,eg=2,tg=0,ng=1,rg=2,ig=3,og=4,sg=5,ag=300,lg=301,cg=302,ug=303,dg=304,hg=306,pg=1e3,mg=1001,fg=1002,gg=1003,vg=1004,yg=1004,_g=1005,Sg=1005,bg=1006,xg=1007,Cg=1007,wg=1008,Ag=1008,Eg=1009,Ig=1010,Tg=1011,Mg=1012,Rg=1013,Pg=1014,Ng=1015,Og=1016,Dg=1017,Lg=1018,kg=1020,Bg=1021,zg=1022,Fg=1023,Ug=1024,jg=1025,Gg=1026,Hg=1027,Vg=1028,Wg=1029,qg=1030,Jg=1031,Kg=1033,Yg=33776,Xg=33777,Qg=33778,$g=33779,Zg=35840,ev=35841,tv=35842,nv=35843,rv=36196,iv=37492,ov=37496,sv=37808,av=37809,lv=37810,cv=37811,uv=37812,dv=37813,hv=37814,pv=37815,mv=37816,fv=37817,gv=37818,vv=37819,yv=37820,_v=37821,Sv=36492,bv=2200,xv=2201,Cv=2202,wv=2300,Av=2301,Ev=2302,Iv=2400,Tv=2401,Mv=2402,Rv=2500,Pv=2501,Nv=0,Ov=1,Dv=2,Lv=3e3,kv=3001,Bv=3200,zv=3201,Fv=0,Uv=1,jv="",Gv="srgb",Hv="srgb-linear",Vv=0,Wv=7680,qv=7681,Jv=7682,Kv=7683,Yv=34055,Xv=34056,Qv=5386,$v=512,Zv=513,ey=514,ty=515,ny=516,ry=517,iy=518,oy=519,sy=35044,ay=35048,ly=35040,cy=35045,uy=35049,dy=35041,hy=35046,py=35050,my=35042,fy="100",gy="300 es",vy=1035;class yy{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 _y=["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 Sy=1234567;const by=Math.PI/180,xy=180/Math.PI;function Cy(){const e=4294967295*Math.random()|0,t=4294967295*Math.random()|0,n=4294967295*Math.random()|0,r=4294967295*Math.random()|0;return(_y[255&e]+_y[e>>8&255]+_y[e>>16&255]+_y[e>>24&255]+"-"+_y[255&t]+_y[t>>8&255]+"-"+_y[t>>16&15|64]+_y[t>>24&255]+"-"+_y[63&n|128]+_y[n>>8&255]+"-"+_y[n>>16&255]+_y[n>>24&255]+_y[255&r]+_y[r>>8&255]+_y[r>>16&255]+_y[r>>24&255]).toLowerCase()}function wy(e,t,n){return Math.max(t,Math.min(n,e))}function Ay(e,t){return(e%t+t)%t}function Ey(e,t,n){return(1-n)*e+n*t}function Iy(e){return 0==(e&e-1)&&0!==e}function Ty(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function My(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function Ry(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 Py(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 Ny=Object.freeze({__proto__:null,DEG2RAD:by,RAD2DEG:xy,generateUUID:Cy,clamp:wy,euclideanModulo:Ay,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:Ey,damp:function(e,t,n,r){return Ey(e,t,1-Math.exp(-n*r))},pingpong:function(e,t=1){return t-Math.abs(Ay(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&&(Sy=e);let t=Sy+=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*by},radToDeg:function(e){return e*xy},isPowerOfTwo:Iy,ceilPowerOfTwo:Ty,floorPowerOfTwo:My,setQuaternionFromProperEuler:function(e,t,n,r,i){const o=Math.cos,s=Math.sin,a=o(n/2),l=s(n/2),c=o((t+r)/2),u=s((t+r)/2),d=o((t-r)/2),h=s((t-r)/2),p=o((r-t)/2),m=s((r-t)/2);switch(i){case"XYX":e.set(a*u,l*d,l*h,a*c);break;case"YZY":e.set(l*h,a*u,l*d,a*c);break;case"ZXZ":e.set(l*d,l*h,a*u,a*c);break;case"XZX":e.set(a*u,l*m,l*p,a*c);break;case"YXY":e.set(l*p,a*u,l*m,a*c);break;case"ZYZ":e.set(l*m,l*p,a*u,a*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}},normalize:Py,denormalize:Ry});class Oy{constructor(e=0,t=0){Oy.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 Dy{constructor(){Dy.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1]}set(e,t,n,r,i,o,s,a,l){const c=this.elements;return c[0]=e,c[1]=r,c[2]=s,c[3]=t,c[4]=i,c[5]=a,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],s=n[3],a=n[6],l=n[1],c=n[4],u=n[7],d=n[2],h=n[5],p=n[8],m=r[0],f=r[3],g=r[6],v=r[1],y=r[4],_=r[7],S=r[2],b=r[5],x=r[8];return i[0]=o*m+s*v+a*S,i[3]=o*f+s*y+a*b,i[6]=o*g+s*_+a*x,i[1]=l*m+c*v+u*S,i[4]=l*f+c*y+u*b,i[7]=l*g+c*_+u*x,i[2]=d*m+h*v+p*S,i[5]=d*f+h*y+p*b,i[8]=d*g+h*_+p*x,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],s=e[5],a=e[6],l=e[7],c=e[8];return t*o*c-t*s*l-n*i*c+n*s*a+r*i*l-r*o*a}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],o=e[4],s=e[5],a=e[6],l=e[7],c=e[8],u=c*o-s*l,d=s*a-c*i,h=l*i-o*a,p=t*u+n*d+r*h;if(0===p)return this.set(0,0,0,0,0,0,0,0,0);const m=1/p;return e[0]=u*m,e[1]=(r*l-c*n)*m,e[2]=(s*n-r*o)*m,e[3]=d*m,e[4]=(c*t-r*a)*m,e[5]=(r*i-s*t)*m,e[6]=h*m,e[7]=(n*a-l*t)*m,e[8]=(o*t-n*i)*m,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,s){const a=Math.cos(i),l=Math.sin(i);return this.set(n*a,n*l,-n*(a*o+l*s)+o+e,-r*l,r*a,-r*(-l*o+a*s)+s+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],s=r[6],a=r[1],l=r[4],c=r[7];return r[0]=t*i+n*a,r[3]=t*o+n*l,r[6]=t*s+n*c,r[1]=-n*i+t*a,r[4]=-n*o+t*l,r[7]=-n*s+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 Ly(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}const ky={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:Uint8ClampedArray,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};function By(e,t){return new ky[e](t)}function zy(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function Fy(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}function Uy(e){return e<.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}const jy={[Gv]:{[Hv]:Fy},[Hv]:{[Gv]:Uy}},Gy={legacyMode:!0,get workingColorSpace(){return Hv},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(jy[t]&&void 0!==jy[t][n]){const r=jy[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)}},Hy={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},Vy={r:0,g:0,b:0},Wy={h:0,s:0,l:0},qy={h:0,s:0,l:0};function Jy(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 Ky(e,t){return t.r=e.r,t.g=e.g,t.b=e.b,t}class Yy{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=Gv){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,Gy.toWorkingColorSpace(this,t),this}setRGB(e,t,n,r=Hv){return this.r=e,this.g=t,this.b=n,Gy.toWorkingColorSpace(this,r),this}setHSL(e,t,n,r=Hv){if(e=Ay(e,1),t=wy(t,0,1),n=wy(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=Jy(i,r,e+1/3),this.g=Jy(i,r,e),this.b=Jy(i,r,e-1/3)}return Gy.toWorkingColorSpace(this,r),this}setStyle(e,t=Gv){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,Gy.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,Gy.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,Gy.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,Gy.toWorkingColorSpace(this,t),this}return e&&e.length>0?this.setColorName(e,t):this}setColorName(e,t=Gv){const n=Hy[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=Fy(e.r),this.g=Fy(e.g),this.b=Fy(e.b),this}copyLinearToSRGB(e){return this.r=Uy(e.r),this.g=Uy(e.g),this.b=Uy(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Gv){return Gy.fromWorkingColorSpace(Ky(this,Vy),e),wy(255*Vy.r,0,255)<<16^wy(255*Vy.g,0,255)<<8^wy(255*Vy.b,0,255)<<0}getHexString(e=Gv){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Hv){Gy.fromWorkingColorSpace(Ky(this,Vy),t);const n=Vy.r,r=Vy.g,i=Vy.b,o=Math.max(n,r,i),s=Math.min(n,r,i);let a,l;const c=(s+o)/2;if(s===o)a=0,l=0;else{const e=o-s;switch(l=c<=.5?e/(o+s):e/(2-o-s),o){case n:a=(r-i)/e+(r<i?6:0);break;case r:a=(i-n)/e+2;break;case i:a=(n-r)/e+4}a/=6}return e.h=a,e.s=l,e.l=c,e}getRGB(e,t=Hv){return Gy.fromWorkingColorSpace(Ky(this,Vy),t),e.r=Vy.r,e.g=Vy.g,e.b=Vy.b,e}getStyle(e=Gv){return Gy.fromWorkingColorSpace(Ky(this,Vy),e),e!==Gv?`color(${e} ${Vy.r} ${Vy.g} ${Vy.b})`:`rgb(${255*Vy.r|0},${255*Vy.g|0},${255*Vy.b|0})`}offsetHSL(e,t,n){return this.getHSL(Wy),Wy.h+=e,Wy.s+=t,Wy.l+=n,this.setHSL(Wy.h,Wy.s,Wy.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(Wy),e.getHSL(qy);const n=Ey(Wy.h,qy.h,t),r=Ey(Wy.s,qy.s,t),i=Ey(Wy.l,qy.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 Xy;Yy.NAMES=Hy;class Qy{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===Xy&&(Xy=zy("canvas")),Xy.width=e.width,Xy.height=e.height;const n=Xy.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=Xy}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=zy("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*Fy(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*Fy(t[e]/255)):t[e]=Fy(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 $y{constructor(e=null){this.isSource=!0,this.uuid=Cy(),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(Zy(r[t].image)):e.push(Zy(r[t]))}else e=Zy(r);n.url=e}return t||(e.images[this.uuid]=n),n}}function Zy(e){return"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap?Qy.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 e_=0;class t_ extends yy{constructor(e=t_.DEFAULT_IMAGE,t=t_.DEFAULT_MAPPING,n=mg,r=mg,i=bg,o=wg,s=Fg,a=Eg,l=1,c=Lv){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:e_++}),this.uuid=Cy(),this.name="",this.source=new $y(e),this.mipmaps=[],this.mapping=t,this.wrapS=n,this.wrapT=r,this.magFilter=i,this.minFilter=o,this.anisotropy=l,this.format=s,this.internalFormat=null,this.type=a,this.offset=new Oy(0,0),this.repeat=new Oy(1,1),this.center=new Oy(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Dy,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!==ag)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case pg:e.x=e.x-Math.floor(e.x);break;case mg:e.x=e.x<0?0:1;break;case fg: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 pg:e.y=e.y-Math.floor(e.y);break;case mg:e.y=e.y<0?0:1;break;case fg: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)}}t_.DEFAULT_IMAGE=null,t_.DEFAULT_MAPPING=ag;class n_{constructor(e=0,t=0,n=0,r=1){n_.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,s=.1,a=e.elements,l=a[0],c=a[4],u=a[8],d=a[1],h=a[5],p=a[9],m=a[2],f=a[6],g=a[10];if(Math.abs(c-d)<o&&Math.abs(u-m)<o&&Math.abs(p-f)<o){if(Math.abs(c+d)<s&&Math.abs(u+m)<s&&Math.abs(p+f)<s&&Math.abs(l+h+g-3)<s)return this.set(1,0,0,0),this;t=Math.PI;const e=(l+1)/2,a=(h+1)/2,v=(g+1)/2,y=(c+d)/4,_=(u+m)/4,S=(p+f)/4;return e>a&&e>v?e<o?(n=0,r=.707106781,i=.707106781):(n=Math.sqrt(e),r=y/n,i=_/n):a>v?a<o?(n=.707106781,r=0,i=.707106781):(r=Math.sqrt(a),n=y/r,i=S/r):v<o?(n=.707106781,r=.707106781,i=0):(i=Math.sqrt(v),n=_/i,r=S/i),this.set(n,r,i,t),this}let v=Math.sqrt((f-p)*(f-p)+(u-m)*(u-m)+(d-c)*(d-c));return Math.abs(v)<.001&&(v=1),this.x=(f-p)/v,this.y=(u-m)/v,this.z=(d-c)/v,this.w=Math.acos((l+h+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 r_ extends yy{constructor(e,t,n={}){super(),this.isWebGLRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new n_(0,0,e,t),this.scissorTest=!1,this.viewport=new n_(0,0,e,t);const r={width:e,height:t,depth:1};this.texture=new t_(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:bg,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 $y(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 i_ extends t_{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=gg,this.minFilter=gg,this.wrapR=mg,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class o_ extends r_{constructor(e,t,n){super(e,t),this.isWebGLArrayRenderTarget=!0,this.depth=n,this.texture=new i_(null,e,t,n),this.texture.isRenderTargetTexture=!0}}class s_ extends t_{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=gg,this.minFilter=gg,this.wrapR=mg,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class a_ extends r_{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 l_ extends r_{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 c_{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,s){let a=n[r+0],l=n[r+1],c=n[r+2],u=n[r+3];const d=i[o+0],h=i[o+1],p=i[o+2],m=i[o+3];if(0===s)return e[t+0]=a,e[t+1]=l,e[t+2]=c,void(e[t+3]=u);if(1===s)return e[t+0]=d,e[t+1]=h,e[t+2]=p,void(e[t+3]=m);if(u!==m||a!==d||l!==h||c!==p){let e=1-s;const t=a*d+l*h+c*p+u*m,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,s=Math.sin(s*o)/i}const i=s*n;if(a=a*e+d*i,l=l*e+h*i,c=c*e+p*i,u=u*e+m*i,e===1-s){const e=1/Math.sqrt(a*a+l*l+c*c+u*u);a*=e,l*=e,c*=e,u*=e}}e[t]=a,e[t+1]=l,e[t+2]=c,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,r,i,o){const s=n[r],a=n[r+1],l=n[r+2],c=n[r+3],u=i[o],d=i[o+1],h=i[o+2],p=i[o+3];return e[t]=s*p+c*u+a*h-l*d,e[t+1]=a*p+c*d+l*u-s*h,e[t+2]=l*p+c*h+s*d-a*u,e[t+3]=c*p-s*u-a*d-l*h,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,s=Math.cos,a=Math.sin,l=s(n/2),c=s(r/2),u=s(i/2),d=a(n/2),h=a(r/2),p=a(i/2);switch(o){case"XYZ":this._x=d*c*u+l*h*p,this._y=l*h*u-d*c*p,this._z=l*c*p+d*h*u,this._w=l*c*u-d*h*p;break;case"YXZ":this._x=d*c*u+l*h*p,this._y=l*h*u-d*c*p,this._z=l*c*p-d*h*u,this._w=l*c*u+d*h*p;break;case"ZXY":this._x=d*c*u-l*h*p,this._y=l*h*u+d*c*p,this._z=l*c*p+d*h*u,this._w=l*c*u-d*h*p;break;case"ZYX":this._x=d*c*u-l*h*p,this._y=l*h*u+d*c*p,this._z=l*c*p-d*h*u,this._w=l*c*u+d*h*p;break;case"YZX":this._x=d*c*u+l*h*p,this._y=l*h*u+d*c*p,this._z=l*c*p-d*h*u,this._w=l*c*u-d*h*p;break;case"XZY":this._x=d*c*u-l*h*p,this._y=l*h*u-d*c*p,this._z=l*c*p+d*h*u,this._w=l*c*u+d*h*p;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],s=t[5],a=t[9],l=t[2],c=t[6],u=t[10],d=n+s+u;if(d>0){const e=.5/Math.sqrt(d+1);this._w=.25/e,this._x=(c-a)*e,this._y=(i-l)*e,this._z=(o-r)*e}else if(n>s&&n>u){const e=2*Math.sqrt(1+n-s-u);this._w=(c-a)/e,this._x=.25*e,this._y=(r+o)/e,this._z=(i+l)/e}else if(s>u){const e=2*Math.sqrt(1+s-n-u);this._w=(i-l)/e,this._x=(r+o)/e,this._y=.25*e,this._z=(a+c)/e}else{const e=2*Math.sqrt(1+u-n-s);this._w=(o-r)/e,this._x=(i+l)/e,this._y=(a+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(wy(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,s=t._x,a=t._y,l=t._z,c=t._w;return this._x=n*c+o*s+r*l-i*a,this._y=r*c+o*a+i*s-n*l,this._z=i*c+o*l+n*a-r*s,this._w=o*c-n*s-r*a-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 s=o*e._w+n*e._x+r*e._y+i*e._z;if(s<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,s=-s):this.copy(e),s>=1)return this._w=o,this._x=n,this._y=r,this._z=i,this;const a=1-s*s;if(a<=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(a),c=Math.atan2(l,s),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 u_{constructor(e=0,t=0,n=0){u_.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,s=e.z,a=e.w,l=a*t+o*r-s*n,c=a*n+s*t-i*r,u=a*r+i*n-o*t,d=-i*t-o*n-s*r;return this.x=l*a+d*-i+c*-s-u*-o,this.y=c*a+d*-o+u*-i-l*-s,this.z=u*a+d*-s+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,s=t.y,a=t.z;return this.x=r*a-i*s,this.y=i*o-n*a,this.z=n*s-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 d_.copy(this).projectOnVector(e),this.sub(d_)}reflect(e){return this.sub(d_.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(wy(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 d_=new u_,h_=new c_;class p_{constructor(e=new u_(1/0,1/0,1/0),t=new u_(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){let t=1/0,n=1/0,r=1/0,i=-1/0,o=-1/0,s=-1/0;for(let a=0,l=e.length;a<l;a+=3){const l=e[a],c=e[a+1],u=e[a+2];l<t&&(t=l),c<n&&(n=c),u<r&&(r=u),l>i&&(i=l),c>o&&(o=c),u>s&&(s=u)}return this.min.set(t,n,r),this.max.set(i,o,s),this}setFromBufferAttribute(e){let t=1/0,n=1/0,r=1/0,i=-1/0,o=-1/0,s=-1/0;for(let a=0,l=e.count;a<l;a++){const l=e.getX(a),c=e.getY(a),u=e.getZ(a);l<t&&(t=l),c<n&&(n=c),u<r&&(r=u),l>i&&(i=l),c>o&&(o=c),u>s&&(s=u)}return this.min.set(t,n,r),this.max.set(i,o,s),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=f_.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++)f_.fromBufferAttribute(t,n).applyMatrix4(e.matrixWorld),this.expandByPoint(f_)}else null===n.boundingBox&&n.computeBoundingBox(),g_.copy(n.boundingBox),g_.applyMatrix4(e.matrixWorld),this.union(g_);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,f_),f_.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(C_),w_.subVectors(this.max,C_),v_.subVectors(e.a,C_),y_.subVectors(e.b,C_),__.subVectors(e.c,C_),S_.subVectors(y_,v_),b_.subVectors(__,y_),x_.subVectors(v_,__);let t=[0,-S_.z,S_.y,0,-b_.z,b_.y,0,-x_.z,x_.y,S_.z,0,-S_.x,b_.z,0,-b_.x,x_.z,0,-x_.x,-S_.y,S_.x,0,-b_.y,b_.x,0,-x_.y,x_.x,0];return!!I_(t,v_,y_,__,w_)&&(t=[1,0,0,0,1,0,0,0,1],!!I_(t,v_,y_,__,w_)&&(A_.crossVectors(S_,b_),t=[A_.x,A_.y,A_.z],I_(t,v_,y_,__,w_)))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return f_.copy(e).clamp(this.min,this.max).sub(e).length()}getBoundingSphere(e){return this.getCenter(e.center),e.radius=.5*this.getSize(f_).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 u_,new u_,new u_,new u_,new u_,new u_,new u_,new u_],f_=new u_,g_=new p_,v_=new u_,y_=new u_,__=new u_,S_=new u_,b_=new u_,x_=new u_,C_=new u_,w_=new u_,A_=new u_,E_=new u_;function I_(e,t,n,r,i){for(let o=0,s=e.length-3;o<=s;o+=3){E_.fromArray(e,o);const s=i.x*Math.abs(E_.x)+i.y*Math.abs(E_.y)+i.z*Math.abs(E_.z),a=t.dot(E_),l=n.dot(E_),c=r.dot(E_);if(Math.max(-Math.max(a,l,c),Math.min(a,l,c))>s)return!1}return!0}const T_=new p_,M_=new u_,R_=new u_,P_=new u_;class N_{constructor(e=new u_,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){P_.subVectors(e,this.center);const t=P_.lengthSq();if(t>this.radius*this.radius){const e=Math.sqrt(t),n=.5*(e-this.radius);this.center.add(P_.multiplyScalar(n/e)),this.radius+=n}return this}union(e){return!0===this.center.equals(e.center)?R_.set(0,0,1).multiplyScalar(e.radius):R_.subVectors(e.center,this.center).normalize().multiplyScalar(e.radius),this.expandByPoint(M_.copy(e.center).add(R_)),this.expandByPoint(M_.copy(e.center).sub(R_)),this}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return(new this.constructor).copy(this)}}const O_=new u_,D_=new u_,L_=new u_,k_=new u_,B_=new u_,z_=new u_,F_=new u_;class U_{constructor(e=new u_,t=new u_(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.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,O_)),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=O_.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(O_.copy(this.direction).multiplyScalar(t).add(this.origin),O_.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){D_.copy(e).add(t).multiplyScalar(.5),L_.copy(t).sub(e).normalize(),k_.copy(this.origin).sub(D_);const i=.5*e.distanceTo(t),o=-this.direction.dot(L_),s=k_.dot(this.direction),a=-k_.dot(L_),l=k_.lengthSq(),c=Math.abs(1-o*o);let u,d,h,p;if(c>0)if(u=o*a-s,d=o*s-a,p=i*c,u>=0)if(d>=-p)if(d<=p){const e=1/c;u*=e,d*=e,h=u*(u+o*d+2*s)+d*(o*u+d+2*a)+l}else d=i,u=Math.max(0,-(o*d+s)),h=-u*u+d*(d+2*a)+l;else d=-i,u=Math.max(0,-(o*d+s)),h=-u*u+d*(d+2*a)+l;else d<=-p?(u=Math.max(0,-(-o*i+s)),d=u>0?-i:Math.min(Math.max(-i,-a),i),h=-u*u+d*(d+2*a)+l):d<=p?(u=0,d=Math.min(Math.max(-i,-a),i),h=d*(d+2*a)+l):(u=Math.max(0,-(o*i+s)),d=u>0?i:Math.min(Math.max(-i,-a),i),h=-u*u+d*(d+2*a)+l);else d=o>0?-i:i,u=Math.max(0,-(o*d+s)),h=-u*u+d*(d+2*a)+l;return n&&n.copy(this.direction).multiplyScalar(u).add(this.origin),r&&r.copy(L_).multiplyScalar(d).add(D_),h}intersectSphere(e,t){O_.subVectors(e.center,this.origin);const n=O_.dot(this.direction),r=O_.dot(O_)-n*n,i=e.radius*e.radius;if(r>i)return null;const o=Math.sqrt(i-r),s=n-o,a=n+o;return s<0&&a<0?null:s<0?this.at(a,t):this.at(s,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,s,a;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?(s=(e.min.z-d.z)*u,a=(e.max.z-d.z)*u):(s=(e.max.z-d.z)*u,a=(e.min.z-d.z)*u),n>a||s>r?null:((s>n||n!=n)&&(n=s),(a<r||r!=r)&&(r=a),r<0?null:this.at(n>=0?n:r,t)))}intersectsBox(e){return null!==this.intersectBox(e,O_)}intersectTriangle(e,t,n,r,i){B_.subVectors(t,e),z_.subVectors(n,e),F_.crossVectors(B_,z_);let o,s=this.direction.dot(F_);if(s>0){if(r)return null;o=1}else{if(!(s<0))return null;o=-1,s=-s}k_.subVectors(this.origin,e);const a=o*this.direction.dot(z_.crossVectors(k_,z_));if(a<0)return null;const l=o*this.direction.dot(B_.cross(k_));if(l<0)return null;if(a+l>s)return null;const c=-o*k_.dot(F_);return c<0?null:this.at(c/s,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 j_{constructor(){j_.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,s,a,l,c,u,d,h,p,m,f){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]=s,g[13]=a,g[2]=l,g[6]=c,g[10]=u,g[14]=d,g[3]=h,g[7]=p,g[11]=m,g[15]=f,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 j_).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/G_.setFromMatrixColumn(e,0).length(),i=1/G_.setFromMatrixColumn(e,1).length(),o=1/G_.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),s=Math.sin(n),a=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=s*c,i=s*u;t[0]=a*c,t[4]=-a*u,t[8]=l,t[1]=n+r*l,t[5]=e-i*l,t[9]=-s*a,t[2]=i-e*l,t[6]=r+n*l,t[10]=o*a}else if("YXZ"===e.order){const e=a*c,n=a*u,r=l*c,i=l*u;t[0]=e+i*s,t[4]=r*s-n,t[8]=o*l,t[1]=o*u,t[5]=o*c,t[9]=-s,t[2]=n*s-r,t[6]=i+e*s,t[10]=o*a}else if("ZXY"===e.order){const e=a*c,n=a*u,r=l*c,i=l*u;t[0]=e-i*s,t[4]=-o*u,t[8]=r+n*s,t[1]=n+r*s,t[5]=o*c,t[9]=i-e*s,t[2]=-o*l,t[6]=s,t[10]=o*a}else if("ZYX"===e.order){const e=o*c,n=o*u,r=s*c,i=s*u;t[0]=a*c,t[4]=r*l-n,t[8]=e*l+i,t[1]=a*u,t[5]=i*l+e,t[9]=n*l-r,t[2]=-l,t[6]=s*a,t[10]=o*a}else if("YZX"===e.order){const e=o*a,n=o*l,r=s*a,i=s*l;t[0]=a*c,t[4]=i-e*u,t[8]=r*u+n,t[1]=u,t[5]=o*c,t[9]=-s*c,t[2]=-l*c,t[6]=n*u+r,t[10]=e-i*u}else if("XZY"===e.order){const e=o*a,n=o*l,r=s*a,i=s*l;t[0]=a*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]=s*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(V_,e,W_)}lookAt(e,t,n){const r=this.elements;return K_.subVectors(e,t),0===K_.lengthSq()&&(K_.z=1),K_.normalize(),q_.crossVectors(n,K_),0===q_.lengthSq()&&(1===Math.abs(n.z)?K_.x+=1e-4:K_.z+=1e-4,K_.normalize(),q_.crossVectors(n,K_)),q_.normalize(),J_.crossVectors(K_,q_),r[0]=q_.x,r[4]=J_.x,r[8]=K_.x,r[1]=q_.y,r[5]=J_.y,r[9]=K_.y,r[2]=q_.z,r[6]=J_.z,r[10]=K_.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],s=n[4],a=n[8],l=n[12],c=n[1],u=n[5],d=n[9],h=n[13],p=n[2],m=n[6],f=n[10],g=n[14],v=n[3],y=n[7],_=n[11],S=n[15],b=r[0],x=r[4],C=r[8],w=r[12],A=r[1],E=r[5],I=r[9],T=r[13],M=r[2],R=r[6],P=r[10],N=r[14],O=r[3],D=r[7],L=r[11],k=r[15];return i[0]=o*b+s*A+a*M+l*O,i[4]=o*x+s*E+a*R+l*D,i[8]=o*C+s*I+a*P+l*L,i[12]=o*w+s*T+a*N+l*k,i[1]=c*b+u*A+d*M+h*O,i[5]=c*x+u*E+d*R+h*D,i[9]=c*C+u*I+d*P+h*L,i[13]=c*w+u*T+d*N+h*k,i[2]=p*b+m*A+f*M+g*O,i[6]=p*x+m*E+f*R+g*D,i[10]=p*C+m*I+f*P+g*L,i[14]=p*w+m*T+f*N+g*k,i[3]=v*b+y*A+_*M+S*O,i[7]=v*x+y*E+_*R+S*D,i[11]=v*C+y*I+_*P+S*L,i[15]=v*w+y*T+_*N+S*k,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],s=e[5],a=e[9],l=e[13],c=e[2],u=e[6],d=e[10],h=e[14];return e[3]*(+i*a*u-r*l*u-i*s*d+n*l*d+r*s*h-n*a*h)+e[7]*(+t*a*h-t*l*d+i*o*d-r*o*h+r*l*c-i*a*c)+e[11]*(+t*l*u-t*s*h-i*o*u+n*o*h+i*s*c-n*l*c)+e[15]*(-r*s*c-t*a*u+t*s*d+r*o*u-n*o*d+n*a*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],s=e[5],a=e[6],l=e[7],c=e[8],u=e[9],d=e[10],h=e[11],p=e[12],m=e[13],f=e[14],g=e[15],v=u*f*l-m*d*l+m*a*h-s*f*h-u*a*g+s*d*g,y=p*d*l-c*f*l-p*a*h+o*f*h+c*a*g-o*d*g,_=c*m*l-p*u*l+p*s*h-o*m*h-c*s*g+o*u*g,S=p*u*a-c*m*a-p*s*d+o*m*d+c*s*f-o*u*f,b=t*v+n*y+r*_+i*S;if(0===b)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const x=1/b;return e[0]=v*x,e[1]=(m*d*i-u*f*i-m*r*h+n*f*h+u*r*g-n*d*g)*x,e[2]=(s*f*i-m*a*i+m*r*l-n*f*l-s*r*g+n*a*g)*x,e[3]=(u*a*i-s*d*i-u*r*l+n*d*l+s*r*h-n*a*h)*x,e[4]=y*x,e[5]=(c*f*i-p*d*i+p*r*h-t*f*h-c*r*g+t*d*g)*x,e[6]=(p*a*i-o*f*i-p*r*l+t*f*l+o*r*g-t*a*g)*x,e[7]=(o*d*i-c*a*i+c*r*l-t*d*l-o*r*h+t*a*h)*x,e[8]=_*x,e[9]=(p*u*i-c*m*i-p*n*h+t*m*h+c*n*g-t*u*g)*x,e[10]=(o*m*i-p*s*i+p*n*l-t*m*l-o*n*g+t*s*g)*x,e[11]=(c*s*i-o*u*i-c*n*l+t*u*l+o*n*h-t*s*h)*x,e[12]=S*x,e[13]=(c*m*r-p*u*r+p*n*d-t*m*d-c*n*f+t*u*f)*x,e[14]=(p*s*r-o*m*r-p*n*a+t*m*a+o*n*f-t*s*f)*x,e[15]=(o*u*r-c*s*r+c*n*a-t*u*a-o*n*d+t*s*d)*x,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,s=e.y,a=e.z,l=i*o,c=i*s;return this.set(l*o+n,l*s-r*a,l*a+r*s,0,l*s+r*a,c*s+n,c*a-r*o,0,l*a-r*s,c*a+r*o,i*a*a+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,s=t._z,a=t._w,l=i+i,c=o+o,u=s+s,d=i*l,h=i*c,p=i*u,m=o*c,f=o*u,g=s*u,v=a*l,y=a*c,_=a*u,S=n.x,b=n.y,x=n.z;return r[0]=(1-(m+g))*S,r[1]=(h+_)*S,r[2]=(p-y)*S,r[3]=0,r[4]=(h-_)*b,r[5]=(1-(d+g))*b,r[6]=(f+v)*b,r[7]=0,r[8]=(p+y)*x,r[9]=(f-v)*x,r[10]=(1-(d+m))*x,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=G_.set(r[0],r[1],r[2]).length();const o=G_.set(r[4],r[5],r[6]).length(),s=G_.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],H_.copy(this);const a=1/i,l=1/o,c=1/s;return H_.elements[0]*=a,H_.elements[1]*=a,H_.elements[2]*=a,H_.elements[4]*=l,H_.elements[5]*=l,H_.elements[6]*=l,H_.elements[8]*=c,H_.elements[9]*=c,H_.elements[10]*=c,t.setFromRotationMatrix(H_),n.x=i,n.y=o,n.z=s,this}makePerspective(e,t,n,r,i,o){const s=this.elements,a=2*i/(t-e),l=2*i/(n-r),c=(t+e)/(t-e),u=(n+r)/(n-r),d=-(o+i)/(o-i),h=-2*o*i/(o-i);return s[0]=a,s[4]=0,s[8]=c,s[12]=0,s[1]=0,s[5]=l,s[9]=u,s[13]=0,s[2]=0,s[6]=0,s[10]=d,s[14]=h,s[3]=0,s[7]=0,s[11]=-1,s[15]=0,this}makeOrthographic(e,t,n,r,i,o){const s=this.elements,a=1/(t-e),l=1/(n-r),c=1/(o-i),u=(t+e)*a,d=(n+r)*l,h=(o+i)*c;return s[0]=2*a,s[4]=0,s[8]=0,s[12]=-u,s[1]=0,s[5]=2*l,s[9]=0,s[13]=-d,s[2]=0,s[6]=0,s[10]=-2*c,s[14]=-h,s[3]=0,s[7]=0,s[11]=0,s[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 G_=new u_,H_=new j_,V_=new u_(0,0,0),W_=new u_(1,1,1),q_=new u_,J_=new u_,K_=new u_,Y_=new j_,X_=new c_;class Q_{constructor(e=0,t=0,n=0,r=Q_.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],s=r[8],a=r[1],l=r[5],c=r[9],u=r[2],d=r[6],h=r[10];switch(t){case"XYZ":this._y=Math.asin(wy(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-c,h),this._z=Math.atan2(-o,i)):(this._x=Math.atan2(d,l),this._z=0);break;case"YXZ":this._x=Math.asin(-wy(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(s,h),this._z=Math.atan2(a,l)):(this._y=Math.atan2(-u,i),this._z=0);break;case"ZXY":this._x=Math.asin(wy(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,h),this._z=Math.atan2(-o,l)):(this._y=0,this._z=Math.atan2(a,i));break;case"ZYX":this._y=Math.asin(-wy(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,h),this._z=Math.atan2(a,i)):(this._x=0,this._z=Math.atan2(-o,l));break;case"YZX":this._z=Math.asin(wy(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-c,l),this._y=Math.atan2(-u,i)):(this._x=0,this._y=Math.atan2(s,h));break;case"XZY":this._z=Math.asin(-wy(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(d,l),this._y=Math.atan2(s,i)):(this._x=Math.atan2(-c,h),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 Y_.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Y_,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")}}Q_.DefaultOrder="XYZ",Q_.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 Z_=0;const eS=new u_,tS=new c_,nS=new j_,rS=new u_,iS=new u_,oS=new u_,sS=new c_,aS=new u_(1,0,0),lS=new u_(0,1,0),cS=new u_(0,0,1),uS={type:"added"},dS={type:"removed"};class hS extends yy{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Z_++}),this.uuid=Cy(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=hS.DefaultUp.clone();const e=new u_,t=new Q_,n=new c_,r=new u_(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 j_},normalMatrix:{value:new Dy}}),this.matrix=new j_,this.matrixWorld=new j_,this.matrixAutoUpdate=hS.DefaultMatrixAutoUpdate,this.matrixWorldNeedsUpdate=!1,this.matrixWorldAutoUpdate=hS.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 tS.setFromAxisAngle(e,t),this.quaternion.multiply(tS),this}rotateOnWorldAxis(e,t){return tS.setFromAxisAngle(e,t),this.quaternion.premultiply(tS),this}rotateX(e){return this.rotateOnAxis(aS,e)}rotateY(e){return this.rotateOnAxis(lS,e)}rotateZ(e){return this.rotateOnAxis(cS,e)}translateOnAxis(e,t){return eS.copy(e).applyQuaternion(this.quaternion),this.position.add(eS.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(aS,e)}translateY(e){return this.translateOnAxis(lS,e)}translateZ(e){return this.translateOnAxis(cS,e)}localToWorld(e){return e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return e.applyMatrix4(nS.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?rS.copy(e):rS.set(e,t,n);const r=this.parent;this.updateWorldMatrix(!0,!1),iS.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?nS.lookAt(iS,rS,this.up):nS.lookAt(rS,iS,this.up),this.quaternion.setFromRotationMatrix(nS),r&&(nS.extractRotation(r.matrixWorld),tS.setFromRotationMatrix(nS),this.quaternion.premultiply(tS.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(uS)):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(dS)),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(dS)}return this.children.length=0,this}attach(e){return this.updateWorldMatrix(!0,!1),nS.copy(this.matrixWorld).invert(),null!==e.parent&&(e.parent.updateWorldMatrix(!0,!1),nS.multiply(e.parent.matrixWorld)),e.applyMatrix4(nS),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(iS,e,oS),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(iS,sS,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),s=o(e.images),a=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),s.length>0&&(n.images=s),a.length>0&&(n.shapes=a),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}}hS.DefaultUp=new u_(0,1,0),hS.DefaultMatrixAutoUpdate=!0,hS.DefaultMatrixWorldAutoUpdate=!0;const pS=new u_,mS=new u_,fS=new u_,gS=new u_,vS=new u_,yS=new u_,_S=new u_,SS=new u_,bS=new u_,xS=new u_;class CS{constructor(e=new u_,t=new u_,n=new u_){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,r){r.subVectors(n,t),pS.subVectors(e,t),r.cross(pS);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){pS.subVectors(r,t),mS.subVectors(n,t),fS.subVectors(e,t);const o=pS.dot(pS),s=pS.dot(mS),a=pS.dot(fS),l=mS.dot(mS),c=mS.dot(fS),u=o*l-s*s;if(0===u)return i.set(-2,-1,-1);const d=1/u,h=(l*a-s*c)*d,p=(o*c-s*a)*d;return i.set(1-h-p,p,h)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,gS),gS.x>=0&&gS.y>=0&&gS.x+gS.y<=1}static getUV(e,t,n,r,i,o,s,a){return this.getBarycoord(e,t,n,r,gS),a.set(0,0),a.addScaledVector(i,gS.x),a.addScaledVector(o,gS.y),a.addScaledVector(s,gS.z),a}static isFrontFacing(e,t,n,r){return pS.subVectors(n,t),mS.subVectors(e,t),pS.cross(mS).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 pS.subVectors(this.c,this.b),mS.subVectors(this.a,this.b),.5*pS.cross(mS).length()}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return CS.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return CS.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,n,r,i){return CS.getUV(e,this.a,this.b,this.c,t,n,r,i)}containsPoint(e){return CS.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return CS.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,s;vS.subVectors(r,n),yS.subVectors(i,n),SS.subVectors(e,n);const a=vS.dot(SS),l=yS.dot(SS);if(a<=0&&l<=0)return t.copy(n);bS.subVectors(e,r);const c=vS.dot(bS),u=yS.dot(bS);if(c>=0&&u<=c)return t.copy(r);const d=a*u-c*l;if(d<=0&&a>=0&&c<=0)return o=a/(a-c),t.copy(n).addScaledVector(vS,o);xS.subVectors(e,i);const h=vS.dot(xS),p=yS.dot(xS);if(p>=0&&h<=p)return t.copy(i);const m=h*l-a*p;if(m<=0&&l>=0&&p<=0)return s=l/(l-p),t.copy(n).addScaledVector(yS,s);const f=c*p-h*u;if(f<=0&&u-c>=0&&h-p>=0)return _S.subVectors(i,r),s=(u-c)/(u-c+(h-p)),t.copy(r).addScaledVector(_S,s);const g=1/(f+m+d);return o=m*g,s=d*g,t.copy(n).addScaledVector(vS,o).addScaledVector(yS,s)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}let wS=0;class AS extends yy{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:wS++}),this.uuid=Cy(),this.name="",this.type="Material",this.blending=Cf,this.side=_f,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.blendSrc=Bf,this.blendDst=zf,this.blendEquation=Tf,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=Jf,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=oy,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Wv,this.stencilZFail=Wv,this.stencilZPass=Wv,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!==Cf&&(n.blending=this.blending),this.side!==_f&&(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 ES extends AS{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Yy(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=$f,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 IS=new u_,TS=new Oy;class MS{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=sy,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++)TS.fromBufferAttribute(this,t),TS.applyMatrix3(e),this.setXY(t,TS.x,TS.y);else if(3===this.itemSize)for(let t=0,n=this.count;t<n;t++)IS.fromBufferAttribute(this,t),IS.applyMatrix3(e),this.setXYZ(t,IS.x,IS.y,IS.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)IS.fromBufferAttribute(this,t),IS.applyMatrix4(e),this.setXYZ(t,IS.x,IS.y,IS.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)IS.fromBufferAttribute(this,t),IS.applyNormalMatrix(e),this.setXYZ(t,IS.x,IS.y,IS.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)IS.fromBufferAttribute(this,t),IS.transformDirection(e),this.setXYZ(t,IS.x,IS.y,IS.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=Ry(t,this.array)),t}setX(e,t){return this.normalized&&(t=Py(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=Ry(t,this.array)),t}setY(e,t){return this.normalized&&(t=Py(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=Ry(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Py(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=Ry(t,this.array)),t}setW(e,t){return this.normalized&&(t=Py(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=Py(t,this.array),n=Py(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=Py(t,this.array),n=Py(n,this.array),r=Py(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=Py(t,this.array),n=Py(n,this.array),r=Py(r,this.array),i=Py(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!==sy&&(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 RS extends MS{constructor(e,t,n){super(new Int8Array(e),t,n)}}class PS extends MS{constructor(e,t,n){super(new Uint8Array(e),t,n)}}class NS extends MS{constructor(e,t,n){super(new Uint8ClampedArray(e),t,n)}}class OS extends MS{constructor(e,t,n){super(new Int16Array(e),t,n)}}class DS extends MS{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class LS extends MS{constructor(e,t,n){super(new Int32Array(e),t,n)}}class kS extends MS{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class BS extends MS{constructor(e,t,n){super(new Uint16Array(e),t,n),this.isFloat16BufferAttribute=!0}}class zS extends MS{constructor(e,t,n){super(new Float32Array(e),t,n)}}class FS extends MS{constructor(e,t,n){super(new Float64Array(e),t,n)}}let US=0;const jS=new j_,GS=new hS,HS=new u_,VS=new p_,WS=new p_,qS=new u_;class JS extends yy{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:US++}),this.uuid=Cy(),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(Ly(e)?kS:DS)(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 Dy).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 jS.makeRotationFromQuaternion(e),this.applyMatrix4(jS),this}rotateX(e){return jS.makeRotationX(e),this.applyMatrix4(jS),this}rotateY(e){return jS.makeRotationY(e),this.applyMatrix4(jS),this}rotateZ(e){return jS.makeRotationZ(e),this.applyMatrix4(jS),this}translate(e,t,n){return jS.makeTranslation(e,t,n),this.applyMatrix4(jS),this}scale(e,t,n){return jS.makeScale(e,t,n),this.applyMatrix4(jS),this}lookAt(e){return GS.lookAt(e),GS.updateMatrix(),this.applyMatrix4(GS.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(HS).negate(),this.translate(HS.x,HS.y,HS.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 zS(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 u_(-1/0,-1/0,-1/0),new u_(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];VS.setFromBufferAttribute(n),this.morphTargetsRelative?(qS.addVectors(this.boundingBox.min,VS.min),this.boundingBox.expandByPoint(qS),qS.addVectors(this.boundingBox.max,VS.max),this.boundingBox.expandByPoint(qS)):(this.boundingBox.expandByPoint(VS.min),this.boundingBox.expandByPoint(VS.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 N_);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 u_,1/0);if(e){const n=this.boundingSphere.center;if(VS.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){const n=t[e];WS.setFromBufferAttribute(n),this.morphTargetsRelative?(qS.addVectors(VS.min,WS.min),VS.expandByPoint(qS),qS.addVectors(VS.max,WS.max),VS.expandByPoint(qS)):(VS.expandByPoint(WS.min),VS.expandByPoint(WS.max))}VS.getCenter(n);let r=0;for(let t=0,i=e.count;t<i;t++)qS.fromBufferAttribute(e,t),r=Math.max(r,n.distanceToSquared(qS));if(t)for(let i=0,o=t.length;i<o;i++){const o=t[i],s=this.morphTargetsRelative;for(let t=0,i=o.count;t<i;t++)qS.fromBufferAttribute(o,t),s&&(HS.fromBufferAttribute(e,t),qS.add(HS)),r=Math.max(r,n.distanceToSquared(qS))}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,s=r.length/3;!1===this.hasAttribute("tangent")&&this.setAttribute("tangent",new MS(new Float32Array(4*s),4));const a=this.getAttribute("tangent").array,l=[],c=[];for(let e=0;e<s;e++)l[e]=new u_,c[e]=new u_;const u=new u_,d=new u_,h=new u_,p=new Oy,m=new Oy,f=new Oy,g=new u_,v=new u_;function y(e,t,n){u.fromArray(r,3*e),d.fromArray(r,3*t),h.fromArray(r,3*n),p.fromArray(o,2*e),m.fromArray(o,2*t),f.fromArray(o,2*n),d.sub(u),h.sub(u),m.sub(p),f.sub(p);const i=1/(m.x*f.y-f.x*m.y);isFinite(i)&&(g.copy(d).multiplyScalar(f.y).addScaledVector(h,-m.y).multiplyScalar(i),v.copy(h).multiplyScalar(m.x).addScaledVector(d,-f.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 _=this.groups;0===_.length&&(_=[{start:0,count:n.length}]);for(let e=0,t=_.length;e<t;++e){const t=_[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 S=new u_,b=new u_,x=new u_,C=new u_;function w(e){x.fromArray(i,3*e),C.copy(x);const t=l[e];S.copy(t),S.sub(x.multiplyScalar(x.dot(t))).normalize(),b.crossVectors(C,t);const n=b.dot(c[e])<0?-1:1;a[4*e]=S.x,a[4*e+1]=S.y,a[4*e+2]=S.z,a[4*e+3]=n}for(let e=0,t=_.length;e<t;++e){const t=_[e],r=t.start;for(let e=r,i=r+t.count;e<i;e+=3)w(n[e+0]),w(n[e+1]),w(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 MS(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 u_,i=new u_,o=new u_,s=new u_,a=new u_,l=new u_,c=new u_,u=new u_;if(e)for(let d=0,h=e.count;d<h;d+=3){const h=e.getX(d+0),p=e.getX(d+1),m=e.getX(d+2);r.fromBufferAttribute(t,h),i.fromBufferAttribute(t,p),o.fromBufferAttribute(t,m),c.subVectors(o,i),u.subVectors(r,i),c.cross(u),s.fromBufferAttribute(n,h),a.fromBufferAttribute(n,p),l.fromBufferAttribute(n,m),s.add(c),a.add(c),l.add(c),n.setXYZ(h,s.x,s.y,s.z),n.setXYZ(p,a.x,a.y,a.z),n.setXYZ(m,l.x,l.y,l.z)}else for(let e=0,s=t.count;e<s;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++)qS.fromBufferAttribute(e,t),qS.normalize(),e.setXYZ(t,qS.x,qS.y,qS.z)}toNonIndexed(){function e(e,t){const n=e.array,r=e.itemSize,i=e.normalized,o=new n.constructor(t.length*r);let s=0,a=0;for(let i=0,l=t.length;i<l;i++){s=e.isInterleavedBufferAttribute?t[i]*e.data.stride+e.offset:t[i]*r;for(let e=0;e<r;e++)o[a++]=n[s++]}return new MS(o,r,i)}if(null===this.index)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new JS,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=[],s=i[r];for(let t=0,r=s.length;t<r;t++){const r=e(s[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 s=this.boundingSphere;return null!==s&&(e.data.boundingSphere={center:s.center.toArray(),radius:s.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 s=e.boundingBox;null!==s&&(this.boundingBox=s.clone());const a=e.boundingSphere;return null!==a&&(this.boundingSphere=a.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 KS=new j_,YS=new U_,XS=new N_,QS=new u_,$S=new u_,ZS=new u_,eb=new u_,tb=new u_,nb=new u_,rb=new u_,ib=new u_,ob=new u_,sb=new Oy,ab=new Oy,lb=new Oy,cb=new u_,ub=new u_;class db extends hS{constructor(e=new JS,t=new ES){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(),XS.copy(n.boundingSphere),XS.applyMatrix4(i),!1===e.ray.intersectsSphere(XS))return;if(KS.copy(i).invert(),YS.copy(e.ray).applyMatrix4(KS),null!==n.boundingBox&&!1===YS.intersectsBox(n.boundingBox))return;let o;const s=n.index,a=n.attributes.position,l=n.morphAttributes.position,c=n.morphTargetsRelative,u=n.attributes.uv,d=n.attributes.uv2,h=n.groups,p=n.drawRange;if(null!==s)if(Array.isArray(r))for(let n=0,i=h.length;n<i;n++){const i=h[n],m=r[i.materialIndex];for(let n=Math.max(i.start,p.start),r=Math.min(s.count,Math.min(i.start+i.count,p.start+p.count));n<r;n+=3){const r=s.getX(n),h=s.getX(n+1),p=s.getX(n+2);o=hb(this,m,e,YS,a,l,c,u,d,r,h,p),o&&(o.faceIndex=Math.floor(n/3),o.face.materialIndex=i.materialIndex,t.push(o))}}else{for(let n=Math.max(0,p.start),i=Math.min(s.count,p.start+p.count);n<i;n+=3){const i=s.getX(n),h=s.getX(n+1),p=s.getX(n+2);o=hb(this,r,e,YS,a,l,c,u,d,i,h,p),o&&(o.faceIndex=Math.floor(n/3),t.push(o))}}else if(void 0!==a)if(Array.isArray(r))for(let n=0,i=h.length;n<i;n++){const i=h[n],s=r[i.materialIndex];for(let n=Math.max(i.start,p.start),r=Math.min(a.count,Math.min(i.start+i.count,p.start+p.count));n<r;n+=3){o=hb(this,s,e,YS,a,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,p.start),i=Math.min(a.count,p.start+p.count);n<i;n+=3){o=hb(this,r,e,YS,a,l,c,u,d,n,n+1,n+2),o&&(o.faceIndex=Math.floor(n/3),t.push(o))}}}}function hb(e,t,n,r,i,o,s,a,l,c,u,d){QS.fromBufferAttribute(i,c),$S.fromBufferAttribute(i,u),ZS.fromBufferAttribute(i,d);const h=e.morphTargetInfluences;if(o&&h){rb.set(0,0,0),ib.set(0,0,0),ob.set(0,0,0);for(let e=0,t=o.length;e<t;e++){const t=h[e],n=o[e];0!==t&&(eb.fromBufferAttribute(n,c),tb.fromBufferAttribute(n,u),nb.fromBufferAttribute(n,d),s?(rb.addScaledVector(eb,t),ib.addScaledVector(tb,t),ob.addScaledVector(nb,t)):(rb.addScaledVector(eb.sub(QS),t),ib.addScaledVector(tb.sub($S),t),ob.addScaledVector(nb.sub(ZS),t)))}QS.add(rb),$S.add(ib),ZS.add(ob)}e.isSkinnedMesh&&(e.boneTransform(c,QS),e.boneTransform(u,$S),e.boneTransform(d,ZS));const p=function(e,t,n,r,i,o,s,a){let l;if(l=t.side===Sf?r.intersectTriangle(s,o,i,!0,a):r.intersectTriangle(i,o,s,t.side!==bf,a),null===l)return null;ub.copy(a),ub.applyMatrix4(e.matrixWorld);const c=n.ray.origin.distanceTo(ub);return c<n.near||c>n.far?null:{distance:c,point:ub.clone(),object:e}}(e,t,n,r,QS,$S,ZS,cb);if(p){a&&(sb.fromBufferAttribute(a,c),ab.fromBufferAttribute(a,u),lb.fromBufferAttribute(a,d),p.uv=CS.getUV(cb,QS,$S,ZS,sb,ab,lb,new Oy)),l&&(sb.fromBufferAttribute(l,c),ab.fromBufferAttribute(l,u),lb.fromBufferAttribute(l,d),p.uv2=CS.getUV(cb,QS,$S,ZS,sb,ab,lb,new Oy));const e={a:c,b:u,c:d,normal:new u_,materialIndex:0};CS.getNormal(QS,$S,ZS,e.normal),p.face=e}return p}class pb extends JS{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 s=this;r=Math.floor(r),i=Math.floor(i),o=Math.floor(o);const a=[],l=[],c=[],u=[];let d=0,h=0;function p(e,t,n,r,i,o,p,m,f,g,v){const y=o/f,_=p/g,S=o/2,b=p/2,x=m/2,C=f+1,w=g+1;let A=0,E=0;const I=new u_;for(let o=0;o<w;o++){const s=o*_-b;for(let a=0;a<C;a++){const d=a*y-S;I[e]=d*r,I[t]=s*i,I[n]=x,l.push(I.x,I.y,I.z),I[e]=0,I[t]=0,I[n]=m>0?1:-1,c.push(I.x,I.y,I.z),u.push(a/f),u.push(1-o/g),A+=1}}for(let e=0;e<g;e++)for(let t=0;t<f;t++){const n=d+t+C*e,r=d+t+C*(e+1),i=d+(t+1)+C*(e+1),o=d+(t+1)+C*e;a.push(n,r,o),a.push(r,i,o),E+=6}s.addGroup(h,E,v),h+=E,d+=A}p("z","y","x",-1,-1,n,t,e,o,i,0),p("z","y","x",1,-1,n,t,-e,o,i,1),p("x","z","y",1,1,e,n,t,r,o,2),p("x","z","y",1,-1,e,n,-t,r,o,3),p("x","y","z",1,-1,e,t,n,r,i,4),p("x","y","z",-1,-1,e,t,-n,r,i,5),this.setIndex(a),this.setAttribute("position",new zS(l,3)),this.setAttribute("normal",new zS(c,3)),this.setAttribute("uv",new zS(u,2))}static fromJSON(e){return new pb(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function mb(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 fb(e){const t={};for(let n=0;n<e.length;n++){const r=mb(e[n]);for(const e in r)t[e]=r[e]}return t}const gb={clone:mb,merge:fb};class vb extends AS{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=mb(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 yb extends hS{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new j_,this.projectionMatrix=new j_,this.projectionMatrixInverse=new j_}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 _b extends yb{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*xy*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(.5*by*this.fov);return.5*this.getFilmHeight()/e}getEffectiveFOV(){return 2*xy*Math.atan(Math.tan(.5*by*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*by*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,s=o.fullHeight;i+=o.offsetX*r/e,t-=o.offsetY*n/s,r*=o.width/e,n*=o.height/s}const s=this.filmOffset;0!==s&&(i+=e*s/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 Sb=90;class bb extends hS{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n;const r=new _b(Sb,1,e,t);r.layers=this.layers,r.up.set(0,-1,0),r.lookAt(new u_(1,0,0)),this.add(r);const i=new _b(Sb,1,e,t);i.layers=this.layers,i.up.set(0,-1,0),i.lookAt(new u_(-1,0,0)),this.add(i);const o=new _b(Sb,1,e,t);o.layers=this.layers,o.up.set(0,0,1),o.lookAt(new u_(0,1,0)),this.add(o);const s=new _b(Sb,1,e,t);s.layers=this.layers,s.up.set(0,0,-1),s.lookAt(new u_(0,-1,0)),this.add(s);const a=new _b(Sb,1,e,t);a.layers=this.layers,a.up.set(0,-1,0),a.lookAt(new u_(0,0,1)),this.add(a);const l=new _b(Sb,1,e,t);l.layers=this.layers,l.up.set(0,-1,0),l.lookAt(new u_(0,0,-1)),this.add(l)}update(e,t){null===this.parent&&this.updateMatrixWorld();const n=this.renderTarget,[r,i,o,s,a,l]=this.children,c=e.getRenderTarget(),u=e.toneMapping,d=e.xr.enabled;e.toneMapping=tg,e.xr.enabled=!1;const h=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,s),e.setRenderTarget(n,4),e.render(t,a),n.texture.generateMipmaps=h,e.setRenderTarget(n,5),e.render(t,l),e.setRenderTarget(c),e.toneMapping=u,e.xr.enabled=d,n.texture.needsPMREMUpdate=!0}}class xb extends t_{constructor(e,t,n,r,i,o,s,a,l,c){super(e=void 0!==e?e:[],t=void 0!==t?t:lg,n,r,i,o,s,a,l,c),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class Cb extends r_{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 xb(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:bg}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 pb(5,5,5),i=new vb({name:"CubemapFromEquirect",uniforms:mb(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Sf,blending:xf});i.uniforms.tEquirect.value=t;const o=new db(r,i),s=t.minFilter;t.minFilter===wg&&(t.minFilter=bg);return new bb(1,10,this).update(e,o),t.minFilter=s,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 wb=new u_,Ab=new u_,Eb=new Dy;class Ib{constructor(e=new u_(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,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=wb.subVectors(n,t).cross(Ab.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(wb),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||Eb.getNormalMatrix(e),r=this.coplanarPoint(wb).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 Tb=new N_,Mb=new u_;class Rb{constructor(e=new Ib,t=new Ib,n=new Ib,r=new Ib,i=new Ib,o=new Ib){this.planes=[e,t,n,r,i,o]}set(e,t,n,r,i,o){const s=this.planes;return s[0].copy(e),s[1].copy(t),s[2].copy(n),s[3].copy(r),s[4].copy(i),s[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],s=n[3],a=n[4],l=n[5],c=n[6],u=n[7],d=n[8],h=n[9],p=n[10],m=n[11],f=n[12],g=n[13],v=n[14],y=n[15];return t[0].setComponents(s-r,u-a,m-d,y-f).normalize(),t[1].setComponents(s+r,u+a,m+d,y+f).normalize(),t[2].setComponents(s+i,u+l,m+h,y+g).normalize(),t[3].setComponents(s-i,u-l,m-h,y-g).normalize(),t[4].setComponents(s-o,u-c,m-p,y-v).normalize(),t[5].setComponents(s+o,u+c,m+p,y+v).normalize(),this}intersectsObject(e){const t=e.geometry;return null===t.boundingSphere&&t.computeBoundingSphere(),Tb.copy(t.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(Tb)}intersectsSprite(e){return Tb.center.set(0,0,0),Tb.radius=.7071067811865476,Tb.applyMatrix4(e.matrixWorld),this.intersectsSphere(Tb)}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(Mb.x=r.normal.x>0?e.max.x:e.min.x,Mb.y=r.normal.y>0?e.max.y:e.min.y,Mb.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(Mb)<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 Pb(){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 Nb(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,s=e.createBuffer();let a;if(e.bindBuffer(r,s),e.bufferData(r,i,o),t.onUploadCallback(),i instanceof Float32Array)a=5126;else if(i instanceof Uint16Array)if(t.isFloat16BufferAttribute){if(!n)throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");a=5131}else a=5123;else if(i instanceof Int16Array)a=5122;else if(i instanceof Uint32Array)a=5125;else if(i instanceof Int32Array)a=5124;else if(i instanceof Int8Array)a=5120;else if(i instanceof Uint8Array)a=5121;else{if(!(i instanceof Uint8ClampedArray))throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+i);a=5121}return{buffer:s,type:a,bytesPerElement:i.BYTES_PER_ELEMENT,version:t.version}}(t,i)):o.version<t.version&&(!function(t,r,i){const o=r.array,s=r.updateRange;e.bindBuffer(i,t),-1===s.count?e.bufferSubData(i,0,o):(n?e.bufferSubData(i,s.offset*o.BYTES_PER_ELEMENT,o,s.offset,s.count):e.bufferSubData(i,s.offset*o.BYTES_PER_ELEMENT,o.subarray(s.offset,s.offset+s.count)),s.count=-1)}(o.buffer,t,i),o.version=t.version)}}}class Ob extends JS{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,s=Math.floor(n),a=Math.floor(r),l=s+1,c=a+1,u=e/s,d=t/a,h=[],p=[],m=[],f=[];for(let e=0;e<c;e++){const t=e*d-o;for(let n=0;n<l;n++){const r=n*u-i;p.push(r,-t,0),m.push(0,0,1),f.push(n/s),f.push(1-e/a)}}for(let e=0;e<a;e++)for(let t=0;t<s;t++){const n=t+l*e,r=t+l*(e+1),i=t+1+l*(e+1),o=t+1+l*e;h.push(n,r,o),h.push(r,i,o)}this.setIndex(h),this.setAttribute("position",new zS(p,3)),this.setAttribute("normal",new zS(m,3)),this.setAttribute("uv",new zS(f,2))}static fromJSON(e){return new Ob(e.width,e.height,e.widthSegments,e.heightSegments)}}const Db={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}"},Lb={common:{diffuse:{value:new Yy(16777215)},opacity:{value:1},map:{value:null},uvTransform:{value:new Dy},uv2Transform:{value:new Dy},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 Oy(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 Yy(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 Yy(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new Dy}},sprite:{diffuse:{value:new Yy(16777215)},opacity:{value:1},center:{value:new Oy(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new Dy}}},kb={basic:{uniforms:fb([Lb.common,Lb.specularmap,Lb.envmap,Lb.aomap,Lb.lightmap,Lb.fog]),vertexShader:Db.meshbasic_vert,fragmentShader:Db.meshbasic_frag},lambert:{uniforms:fb([Lb.common,Lb.specularmap,Lb.envmap,Lb.aomap,Lb.lightmap,Lb.emissivemap,Lb.bumpmap,Lb.normalmap,Lb.displacementmap,Lb.fog,Lb.lights,{emissive:{value:new Yy(0)}}]),vertexShader:Db.meshlambert_vert,fragmentShader:Db.meshlambert_frag},phong:{uniforms:fb([Lb.common,Lb.specularmap,Lb.envmap,Lb.aomap,Lb.lightmap,Lb.emissivemap,Lb.bumpmap,Lb.normalmap,Lb.displacementmap,Lb.fog,Lb.lights,{emissive:{value:new Yy(0)},specular:{value:new Yy(1118481)},shininess:{value:30}}]),vertexShader:Db.meshphong_vert,fragmentShader:Db.meshphong_frag},standard:{uniforms:fb([Lb.common,Lb.envmap,Lb.aomap,Lb.lightmap,Lb.emissivemap,Lb.bumpmap,Lb.normalmap,Lb.displacementmap,Lb.roughnessmap,Lb.metalnessmap,Lb.fog,Lb.lights,{emissive:{value:new Yy(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Db.meshphysical_vert,fragmentShader:Db.meshphysical_frag},toon:{uniforms:fb([Lb.common,Lb.aomap,Lb.lightmap,Lb.emissivemap,Lb.bumpmap,Lb.normalmap,Lb.displacementmap,Lb.gradientmap,Lb.fog,Lb.lights,{emissive:{value:new Yy(0)}}]),vertexShader:Db.meshtoon_vert,fragmentShader:Db.meshtoon_frag},matcap:{uniforms:fb([Lb.common,Lb.bumpmap,Lb.normalmap,Lb.displacementmap,Lb.fog,{matcap:{value:null}}]),vertexShader:Db.meshmatcap_vert,fragmentShader:Db.meshmatcap_frag},points:{uniforms:fb([Lb.points,Lb.fog]),vertexShader:Db.points_vert,fragmentShader:Db.points_frag},dashed:{uniforms:fb([Lb.common,Lb.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Db.linedashed_vert,fragmentShader:Db.linedashed_frag},depth:{uniforms:fb([Lb.common,Lb.displacementmap]),vertexShader:Db.depth_vert,fragmentShader:Db.depth_frag},normal:{uniforms:fb([Lb.common,Lb.bumpmap,Lb.normalmap,Lb.displacementmap,{opacity:{value:1}}]),vertexShader:Db.meshnormal_vert,fragmentShader:Db.meshnormal_frag},sprite:{uniforms:fb([Lb.sprite,Lb.fog]),vertexShader:Db.sprite_vert,fragmentShader:Db.sprite_frag},background:{uniforms:{uvTransform:{value:new Dy},t2D:{value:null}},vertexShader:Db.background_vert,fragmentShader:Db.background_frag},cube:{uniforms:fb([Lb.envmap,{opacity:{value:1}}]),vertexShader:Db.cube_vert,fragmentShader:Db.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Db.equirect_vert,fragmentShader:Db.equirect_frag},distanceRGBA:{uniforms:fb([Lb.common,Lb.displacementmap,{referencePosition:{value:new u_},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Db.distanceRGBA_vert,fragmentShader:Db.distanceRGBA_frag},shadow:{uniforms:fb([Lb.lights,Lb.fog,{color:{value:new Yy(0)},opacity:{value:1}}]),vertexShader:Db.shadow_vert,fragmentShader:Db.shadow_frag}};function Bb(e,t,n,r,i,o){const s=new Yy(0);let a,l,c=!0===i?0:1,u=null,d=0,h=null;function p(e,t){n.buffers.color.setClear(e.r,e.g,e.b,t,o)}return{getClearColor:function(){return s},setClearColor:function(e,t=1){s.set(e),c=t,p(s,c)},getClearAlpha:function(){return c},setClearAlpha:function(e){c=e,p(s,c)},render:function(n,i){let o=!1,m=!0===i.isScene?i.background:null;m&&m.isTexture&&(m=t.get(m));const f=e.xr,g=f.getSession&&f.getSession();g&&"additive"===g.environmentBlendMode&&(m=null),null===m?p(s,c):m&&m.isColor&&(p(m,1),o=!0),(e.autoClear||o)&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),m&&(m.isCubeTexture||m.mapping===hg)?(void 0===l&&(l=new db(new pb(1,1,1),new vb({name:"BackgroundCubeMaterial",uniforms:mb(kb.cube.uniforms),vertexShader:kb.cube.vertexShader,fragmentShader:kb.cube.fragmentShader,side:Sf,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=m,l.material.uniforms.flipEnvMap.value=m.isCubeTexture&&!1===m.isRenderTargetTexture?-1:1,u===m&&d===m.version&&h===e.toneMapping||(l.material.needsUpdate=!0,u=m,d=m.version,h=e.toneMapping),l.layers.enableAll(),n.unshift(l,l.geometry,l.material,0,0,null)):m&&m.isTexture&&(void 0===a&&(a=new db(new Ob(2,2),new vb({name:"BackgroundMaterial",uniforms:mb(kb.background.uniforms),vertexShader:kb.background.vertexShader,fragmentShader:kb.background.fragmentShader,side:_f,depthTest:!1,depthWrite:!1,fog:!1})),a.geometry.deleteAttribute("normal"),Object.defineProperty(a.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(a)),a.material.uniforms.t2D.value=m,!0===m.matrixAutoUpdate&&m.updateMatrix(),a.material.uniforms.uvTransform.value.copy(m.matrix),u===m&&d===m.version&&h===e.toneMapping||(a.material.needsUpdate=!0,u=m,d=m.version,h=e.toneMapping),a.layers.enableAll(),n.unshift(a,a.geometry,a.material,0,0,null))}}}function zb(e,t,n,r){const i=e.getParameter(34921),o=r.isWebGL2?null:t.get("OES_vertex_array_object"),s=r.isWebGL2||null!==o,a={},l=p(null);let c=l,u=!1;function d(t){return r.isWebGL2?e.bindVertexArray(t):o.bindVertexArrayOES(t)}function h(t){return r.isWebGL2?e.deleteVertexArray(t):o.deleteVertexArrayOES(t)}function p(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 m(){const e=c.newAttributes;for(let t=0,n=e.length;t<n;t++)e[t]=0}function f(e){g(e,0)}function g(n,i){const o=c.newAttributes,s=c.enabledAttributes,a=c.attributeDivisors;if(o[n]=1,0===s[n]&&(e.enableVertexAttribArray(n),s[n]=1),a[n]!==i){(r.isWebGL2?e:t.get("ANGLE_instanced_arrays"))[r.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](n,i),a[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,s,a){!0!==r.isWebGL2||5124!==i&&5125!==i?e.vertexAttribPointer(t,n,i,o,s,a):e.vertexAttribIPointer(t,n,i,s,a)}function _(){S(),u=!0,c!==l&&(c=l,d(c.object))}function S(){l.geometry=null,l.program=null,l.wireframe=!1}return{setup:function(i,l,h,_,S){let b=!1;if(s){const t=function(t,n,i){const s=!0===i.wireframe;let l=a[t.id];void 0===l&&(l={},a[t.id]=l);let c=l[n.id];void 0===c&&(c={},l[n.id]=c);let u=c[s];void 0===u&&(u=p(r.isWebGL2?e.createVertexArray():o.createVertexArrayOES()),c[s]=u);return u}(_,h,l);c!==t&&(c=t,d(c.object)),b=function(e,t,n,r){const i=c.attributes,o=t.attributes;let s=0;const a=n.getAttributes();for(const t in a){if(a[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;s++}}return c.attributesNum!==s||c.index!==r}(i,_,h,S),b&&function(e,t,n,r){const i={},o=t.attributes;let s=0;const a=n.getAttributes();for(const t in a){if(a[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,s++}}c.attributes=i,c.attributesNum=s,c.index=r}(i,_,h,S)}else{const e=!0===l.wireframe;c.geometry===_.id&&c.program===h.id&&c.wireframe===e||(c.geometry=_.id,c.program=h.id,c.wireframe=e,b=!0)}null!==S&&n.update(S,34963),(b||u)&&(u=!1,function(i,o,s,a){if(!1===r.isWebGL2&&(i.isInstancedMesh||a.isInstancedBufferGeometry)&&null===t.get("ANGLE_instanced_arrays"))return;m();const l=a.attributes,c=s.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,s=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,h=o.offset;if(n.isInstancedInterleavedBuffer){for(let e=0;e<r.locationSize;e++)g(r.location+e,n.meshPerAttribute);!0!==i.isInstancedMesh&&void 0===a._maxInstanceCount&&(a._maxInstanceCount=n.meshPerAttribute*n.count)}else for(let e=0;e<r.locationSize;e++)f(r.location+e);e.bindBuffer(34962,c);for(let e=0;e<r.locationSize;e++)y(r.location+e,s/r.locationSize,u,t,l*d,(h+s/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===a._maxInstanceCount&&(a._maxInstanceCount=o.meshPerAttribute*o.count)}else for(let e=0;e<r.locationSize;e++)f(r.location+e);e.bindBuffer(34962,c);for(let e=0;e<r.locationSize;e++)y(r.location+e,s/r.locationSize,u,t,s*d,s/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,h,_),null!==S&&e.bindBuffer(34963,n.get(S).buffer))},reset:_,resetDefaultState:S,dispose:function(){_();for(const e in a){const t=a[e];for(const e in t){const n=t[e];for(const e in n)h(n[e].object),delete n[e];delete t[e]}delete a[e]}},releaseStatesOfGeometry:function(e){if(void 0===a[e.id])return;const t=a[e.id];for(const e in t){const n=t[e];for(const e in n)h(n[e].object),delete n[e];delete t[e]}delete a[e.id]},releaseStatesOfProgram:function(e){for(const t in a){const n=a[t];if(void 0===n[e.id])continue;const r=n[e.id];for(const e in r)h(r[e].object),delete r[e];delete n[e.id]}},initAttributes:m,enableAttribute:f,disableUnusedAttributes:v}}function Fb(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,s,a){if(0===a)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,s,a),n.update(s,o,a)}}function Ub(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 s=void 0!==n.precision?n.precision:"highp";const a=i(s);a!==s&&(console.warn("THREE.WebGLRenderer:",s,"not supported, using",a,"instead."),s=a);const l=o||t.has("WEBGL_draw_buffers"),c=!0===n.logarithmicDepthBuffer,u=e.getParameter(34930),d=e.getParameter(35660),h=e.getParameter(3379),p=e.getParameter(34076),m=e.getParameter(34921),f=e.getParameter(36347),g=e.getParameter(36348),v=e.getParameter(36349),y=d>0,_=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:s,logarithmicDepthBuffer:c,maxTextures:u,maxVertexTextures:d,maxTextureSize:h,maxCubemapSize:p,maxAttributes:m,maxVertexUniforms:f,maxVaryings:g,maxFragmentUniforms:v,vertexTextures:y,floatFragmentTextures:_,floatVertexTextures:y&&_,maxSamples:o?e.getParameter(36183):0}}function jb(e){const t=this;let n=null,r=0,i=!1,o=!1;const s=new Ib,a=new Dy,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;a.getNormalMatrix(i),(null===c||c.length<t)&&(c=new Float32Array(t));for(let t=0,n=r;t!==o;++t,n+=4)s.copy(e[t]).applyMatrix4(i,a),s.normal.toArray(c,n),c[n+3]=s.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 s=0!==e.length||t||0!==r||i;return i=t,n=u(e,o,0),r=e.length,s},this.beginShadows=function(){o=!0,u(null)},this.endShadows=function(){o=!1,c()},this.setState=function(t,s,a){const d=t.clippingPlanes,h=t.clipIntersection,p=t.clipShadows,m=e.get(t);if(!i||null===d||0===d.length||o&&!p)o?u(null):c();else{const e=o?0:r,t=4*e;let i=m.clippingState||null;l.value=i,i=u(d,s,t,a);for(let e=0;e!==t;++e)i[e]=n[e];m.clippingState=i,this.numIntersection=h?this.numPlanes:0,this.numPlanes+=e}}}function Gb(e){let t=new WeakMap;function n(e,t){return t===ug?e.mapping=lg:t===dg&&(e.mapping=cg),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===ug||o===dg){if(t.has(i)){return n(t.get(i).texture,i.mapping)}{const o=i.image;if(o&&o.height>0){const s=new Cb(o.height/2);return s.fromEquirectangularTexture(e,i),t.set(i,s),i.addEventListener("dispose",r),n(s.texture,i.mapping)}return null}}}return i},dispose:function(){t=new WeakMap}}}kb.physical={uniforms:fb([kb.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new Oy(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 Yy(0)},sheenColorMap:{value:null},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},transmission:{value:0},transmissionMap:{value:null},transmissionSamplerSize:{value:new Oy},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},attenuationDistance:{value:0},attenuationColor:{value:new Yy(0)},specularIntensity:{value:1},specularIntensityMap:{value:null},specularColor:{value:new Yy(1,1,1)},specularColorMap:{value:null}}]),vertexShader:Db.meshphysical_vert,fragmentShader:Db.meshphysical_frag};class Hb extends yb{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,s=r+t,a=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,s-=t*this.view.offsetY,a=s-t*this.view.height}this.projectionMatrix.makeOrthographic(i,o,s,a,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 Vb=[.125,.215,.35,.446,.526,.582],Wb=20,qb=new Hb,Jb=new Yy;let Kb=null;const Yb=(1+Math.sqrt(5))/2,Xb=1/Yb,Qb=[new u_(1,1,1),new u_(-1,1,1),new u_(1,1,-1),new u_(-1,1,-1),new u_(0,Yb,Xb),new u_(0,Yb,-Xb),new u_(Xb,0,Yb),new u_(-Xb,0,Yb),new u_(Yb,Xb,0),new u_(-Yb,Xb,0)];class $b{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){Kb=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=nx(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=tx(),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(Kb),e.scissorTest=!1,ex(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===lg||e.mapping===cg?this._setSize(0===e.image.length?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Kb=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:bg,minFilter:bg,generateMipmaps:!1,type:Og,format:Fg,encoding:Lv,depthBuffer:!1},r=Zb(e,t,n);if(null===this._pingPongRenderTarget||this._pingPongRenderTarget.width!==e){null!==this._pingPongRenderTarget&&this._dispose(),this._pingPongRenderTarget=Zb(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+Vb.length;for(let s=0;s<o;s++){const o=Math.pow(2,i);n.push(o);let a=1/o;s>e-4?a=Vb[s-e+4-1]:0===s&&(a=0),r.push(a);const l=1/(o-2),c=-l,u=1+l,d=[c,c,u,c,u,u,c,c,u,u,c,u],h=6,p=6,m=3,f=2,g=1,v=new Float32Array(m*p*h),y=new Float32Array(f*p*h),_=new Float32Array(g*p*h);for(let e=0;e<h;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,m*p*e),y.set(d,f*p*e);const i=[e,e,e,e,e,e];_.set(i,g*p*e)}const S=new JS;S.setAttribute("position",new MS(v,m)),S.setAttribute("uv",new MS(y,f)),S.setAttribute("faceIndex",new MS(_,g)),t.push(S),i>4&&i--}return{lodPlanes:t,sizeLods:n,sigmas:r}}(r)),this._blurMaterial=function(e,t,n){const r=new Float32Array(Wb),i=new u_(0,1,0),o=new vb({name:"SphericalGaussianBlur",defines:{n:Wb,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:rx(),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:xf,depthTest:!1,depthWrite:!1});return o}(r,e,t)}return r}_compileMaterial(e){const t=new db(this._lodPlanes[0],e);this._renderer.compile(t,qb)}_sceneToCubeUV(e,t,n,r){const i=new _b(90,1,t,n),o=[1,-1,1,1,1,1],s=[1,1,1,-1,-1,-1],a=this._renderer,l=a.autoClear,c=a.toneMapping;a.getClearColor(Jb),a.toneMapping=tg,a.autoClear=!1;const u=new ES({name:"PMREM.Background",side:Sf,depthWrite:!1,depthTest:!1}),d=new db(new pb,u);let h=!1;const p=e.background;p?p.isColor&&(u.color.copy(p),e.background=null,h=!0):(u.color.copy(Jb),h=!0);for(let t=0;t<6;t++){const n=t%3;0===n?(i.up.set(0,o[t],0),i.lookAt(s[t],0,0)):1===n?(i.up.set(0,0,o[t]),i.lookAt(0,s[t],0)):(i.up.set(0,o[t],0),i.lookAt(0,0,s[t]));const l=this._cubeSize;ex(r,n*l,t>2?l:0,l,l),a.setRenderTarget(r),h&&a.render(d,i),a.render(e,i)}d.geometry.dispose(),d.material.dispose(),a.toneMapping=c,a.autoClear=l,e.background=p}_textureToCubeUV(e,t){const n=this._renderer,r=e.mapping===lg||e.mapping===cg;r?(null===this._cubemapMaterial&&(this._cubemapMaterial=nx()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===e.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=tx());const i=r?this._cubemapMaterial:this._equirectMaterial,o=new db(this._lodPlanes[0],i);i.uniforms.envMap.value=e;const s=this._cubeSize;ex(t,0,0,3*s,2*s),n.setRenderTarget(t),n.render(o,qb)}_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=Qb[(t-1)%Qb.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,s){const a=this._renderer,l=this._blurMaterial;"latitudinal"!==o&&"longitudinal"!==o&&console.error("blur direction must be either latitudinal or longitudinal!");const c=new db(this._lodPlanes[r],l),u=l.uniforms,d=this._sizeLods[n]-1,h=isFinite(i)?Math.PI/(2*d):2*Math.PI/39,p=i/h,m=isFinite(i)?1+Math.floor(3*p):Wb;m>Wb&&console.warn(`sigmaRadians, ${i}, is too large and will clip, as it requested ${m} samples when the maximum is set to 20`);const f=[];let g=0;for(let e=0;e<Wb;++e){const t=e/p,n=Math.exp(-t*t/2);f.push(n),0===e?g+=n:e<m&&(g+=2*n)}for(let e=0;e<f.length;e++)f[e]=f[e]/g;u.envMap.value=e.texture,u.samples.value=m,u.weights.value=f,u.latitudinal.value="latitudinal"===o,s&&(u.poleAxis.value=s);const{_lodMax:v}=this;u.dTheta.value=h,u.mipInt.value=v-n;const y=this._sizeLods[r];ex(t,3*y*(r>v-4?r-v+4:0),4*(this._cubeSize-y),3*y,2*y),a.setRenderTarget(t),a.render(c,qb)}}function Zb(e,t,n){const r=new r_(e,t,n);return r.texture.mapping=hg,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function ex(e,t,n,r,i){e.viewport.set(t,n,r,i),e.scissor.set(t,n,r,i)}function tx(){return new vb({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:rx(),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:xf,depthTest:!1,depthWrite:!1})}function nx(){return new vb({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:rx(),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:xf,depthTest:!1,depthWrite:!1})}function rx(){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 ix(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,s=o===ug||o===dg,a=o===lg||o===cg;if(s||a){if(i.isRenderTargetTexture&&!0===i.needsPMREMUpdate){i.needsPMREMUpdate=!1;let r=t.get(i);return null===n&&(n=new $b(e)),r=s?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(s&&o&&o.height>0||a&&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 $b(e));const o=s?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 ox(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 sx(e,t,n,r){const i={},o=new WeakMap;function s(e){const a=e.target;null!==a.index&&t.remove(a.index);for(const e in a.attributes)t.remove(a.attributes[e]);a.removeEventListener("dispose",s),delete i[a.id];const l=o.get(a);l&&(t.remove(l),o.delete(a)),r.releaseStatesOfGeometry(a),!0===a.isInstancedBufferGeometry&&delete a._maxInstanceCount,n.memory.geometries--}function a(e){const n=[],r=e.index,i=e.attributes.position;let s=0;if(null!==r){const e=r.array;s=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;s=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 a=new(Ly(n)?kS:DS)(n,1);a.version=s;const l=o.get(e);l&&t.remove(l),o.set(e,a)}return{get:function(e,t){return!0===i[t.id]||(t.addEventListener("dispose",s),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&&a(e)}else a(e);return o.get(e)}}}function ax(e,t,n,r){const i=r.isWebGL2;let o,s,a;this.setMode=function(e){o=e},this.setIndex=function(e){s=e.type,a=e.bytesPerElement},this.render=function(t,r){e.drawElements(o,r,s,t*a),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,s,r*a,c),n.update(l,o,c)}}function lx(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 cx(e,t){return e[0]-t[0]}function ux(e,t){return Math.abs(t[1])-Math.abs(e[1])}function dx(e,t,n){const r={},i=new Float32Array(8),o=new WeakMap,s=new n_,a=[];for(let e=0;e<8;e++)a[e]=[e,0];return{update:function(l,c,u,d){const h=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 a=o.get(c);if(void 0===a||a.count!==i){void 0!==a&&a.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 h=0;!0===e&&(h=1),!0===n&&(h=2),!0===r&&(h=3);let p=c.attributes.position.count*h,m=1;p>t.maxTextureSize&&(m=Math.ceil(p/t.maxTextureSize),p=t.maxTextureSize);const f=new Float32Array(p*m*4*i),g=new i_(f,p,m,i);g.type=Ng,g.needsUpdate=!0;const v=4*h;for(let t=0;t<i;t++){const i=l[t],o=u[t],a=d[t],c=p*m*4*t;for(let t=0;t<i.count;t++){const l=t*v;!0===e&&(s.fromBufferAttribute(i,t),f[c+l+0]=s.x,f[c+l+1]=s.y,f[c+l+2]=s.z,f[c+l+3]=0),!0===n&&(s.fromBufferAttribute(o,t),f[c+l+4]=s.x,f[c+l+5]=s.y,f[c+l+6]=s.z,f[c+l+7]=0),!0===r&&(s.fromBufferAttribute(a,t),f[c+l+8]=s.x,f[c+l+9]=s.y,f[c+l+10]=s.z,f[c+l+11]=4===a.itemSize?s.w:1)}}a={count:i,texture:g,size:new Oy(p,m)},o.set(c,a),c.addEventListener("dispose",(function e(){g.dispose(),o.delete(c),c.removeEventListener("dispose",e)}))}let l=0;for(let e=0;e<h.length;e++)l+=h[e];const u=c.morphTargetsRelative?1:1-l;d.getUniforms().setValue(e,"morphTargetBaseInfluence",u),d.getUniforms().setValue(e,"morphTargetInfluences",h),d.getUniforms().setValue(e,"morphTargetsTexture",a.texture,n),d.getUniforms().setValue(e,"morphTargetsTextureSize",a.size)}else{const t=void 0===h?0:h.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]=h[e]}n.sort(ux);for(let e=0;e<8;e++)e<t&&n[e][1]?(a[e][0]=n[e][0],a[e][1]=n[e][1]):(a[e][0]=Number.MAX_SAFE_INTEGER,a[e][1]=0);a.sort(cx);const o=c.morphAttributes.position,s=c.morphAttributes.normal;let l=0;for(let e=0;e<8;e++){const t=a[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]),s&&c.getAttribute("morphNormal"+e)!==s[n]&&c.setAttribute("morphNormal"+e,s[n]),i[e]=r,l+=r):(o&&!0===c.hasAttribute("morphTarget"+e)&&c.deleteAttribute("morphTarget"+e),s&&!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 hx(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 s=r.render.frame,a=e.geometry,l=t.get(e,a);return i.get(l)!==s&&(t.update(l),i.set(l,s)),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 px=new t_,mx=new i_,fx=new s_,gx=new xb,vx=[],yx=[],_x=new Float32Array(16),Sx=new Float32Array(9),bx=new Float32Array(4);function xx(e,t,n){const r=e[0];if(r<=0||r>0)return e;const i=t*n;let o=vx[i];if(void 0===o&&(o=new Float32Array(i),vx[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 Cx(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 wx(e,t){for(let n=0,r=t.length;n<r;n++)e[n]=t[n]}function Ax(e,t){let n=yx[t];void 0===n&&(n=new Int32Array(t),yx[t]=n);for(let r=0;r!==t;++r)n[r]=e.allocateTextureUnit();return n}function Ex(e,t){const n=this.cache;n[0]!==t&&(e.uniform1f(this.addr,t),n[0]=t)}function Ix(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(Cx(n,t))return;e.uniform2fv(this.addr,t),wx(n,t)}}function Tx(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(Cx(n,t))return;e.uniform3fv(this.addr,t),wx(n,t)}}function Mx(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(Cx(n,t))return;e.uniform4fv(this.addr,t),wx(n,t)}}function Rx(e,t){const n=this.cache,r=t.elements;if(void 0===r){if(Cx(n,t))return;e.uniformMatrix2fv(this.addr,!1,t),wx(n,t)}else{if(Cx(n,r))return;bx.set(r),e.uniformMatrix2fv(this.addr,!1,bx),wx(n,r)}}function Px(e,t){const n=this.cache,r=t.elements;if(void 0===r){if(Cx(n,t))return;e.uniformMatrix3fv(this.addr,!1,t),wx(n,t)}else{if(Cx(n,r))return;Sx.set(r),e.uniformMatrix3fv(this.addr,!1,Sx),wx(n,r)}}function Nx(e,t){const n=this.cache,r=t.elements;if(void 0===r){if(Cx(n,t))return;e.uniformMatrix4fv(this.addr,!1,t),wx(n,t)}else{if(Cx(n,r))return;_x.set(r),e.uniformMatrix4fv(this.addr,!1,_x),wx(n,r)}}function Ox(e,t){const n=this.cache;n[0]!==t&&(e.uniform1i(this.addr,t),n[0]=t)}function Dx(e,t){const n=this.cache;Cx(n,t)||(e.uniform2iv(this.addr,t),wx(n,t))}function Lx(e,t){const n=this.cache;Cx(n,t)||(e.uniform3iv(this.addr,t),wx(n,t))}function kx(e,t){const n=this.cache;Cx(n,t)||(e.uniform4iv(this.addr,t),wx(n,t))}function Bx(e,t){const n=this.cache;n[0]!==t&&(e.uniform1ui(this.addr,t),n[0]=t)}function zx(e,t){const n=this.cache;Cx(n,t)||(e.uniform2uiv(this.addr,t),wx(n,t))}function Fx(e,t){const n=this.cache;Cx(n,t)||(e.uniform3uiv(this.addr,t),wx(n,t))}function Ux(e,t){const n=this.cache;Cx(n,t)||(e.uniform4uiv(this.addr,t),wx(n,t))}function jx(e,t,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(e.uniform1i(this.addr,i),r[0]=i),n.setTexture2D(t||px,i)}function Gx(e,t,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(e.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(t||fx,i)}function Hx(e,t,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(e.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(t||gx,i)}function Vx(e,t,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(e.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(t||mx,i)}function Wx(e,t){e.uniform1fv(this.addr,t)}function qx(e,t){const n=xx(t,this.size,2);e.uniform2fv(this.addr,n)}function Jx(e,t){const n=xx(t,this.size,3);e.uniform3fv(this.addr,n)}function Kx(e,t){const n=xx(t,this.size,4);e.uniform4fv(this.addr,n)}function Yx(e,t){const n=xx(t,this.size,4);e.uniformMatrix2fv(this.addr,!1,n)}function Xx(e,t){const n=xx(t,this.size,9);e.uniformMatrix3fv(this.addr,!1,n)}function Qx(e,t){const n=xx(t,this.size,16);e.uniformMatrix4fv(this.addr,!1,n)}function $x(e,t){e.uniform1iv(this.addr,t)}function Zx(e,t){e.uniform2iv(this.addr,t)}function eC(e,t){e.uniform3iv(this.addr,t)}function tC(e,t){e.uniform4iv(this.addr,t)}function nC(e,t){e.uniform1uiv(this.addr,t)}function rC(e,t){e.uniform2uiv(this.addr,t)}function iC(e,t){e.uniform3uiv(this.addr,t)}function oC(e,t){e.uniform4uiv(this.addr,t)}function sC(e,t,n){const r=t.length,i=Ax(n,r);e.uniform1iv(this.addr,i);for(let e=0;e!==r;++e)n.setTexture2D(t[e]||px,i[e])}function aC(e,t,n){const r=t.length,i=Ax(n,r);e.uniform1iv(this.addr,i);for(let e=0;e!==r;++e)n.setTexture3D(t[e]||fx,i[e])}function lC(e,t,n){const r=t.length,i=Ax(n,r);e.uniform1iv(this.addr,i);for(let e=0;e!==r;++e)n.setTextureCube(t[e]||gx,i[e])}function cC(e,t,n){const r=t.length,i=Ax(n,r);e.uniform1iv(this.addr,i);for(let e=0;e!==r;++e)n.setTexture2DArray(t[e]||mx,i[e])}class uC{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.setValue=function(e){switch(e){case 5126:return Ex;case 35664:return Ix;case 35665:return Tx;case 35666:return Mx;case 35674:return Rx;case 35675:return Px;case 35676:return Nx;case 5124:case 35670:return Ox;case 35667:case 35671:return Dx;case 35668:case 35672:return Lx;case 35669:case 35673:return kx;case 5125:return Bx;case 36294:return zx;case 36295:return Fx;case 36296:return Ux;case 35678:case 36198:case 36298:case 36306:case 35682:return jx;case 35679:case 36299:case 36307:return Gx;case 35680:case 36300:case 36308:case 36293:return Hx;case 36289:case 36303:case 36311:case 36292:return Vx}}(t.type)}}class dC{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 Wx;case 35664:return qx;case 35665:return Jx;case 35666:return Kx;case 35674:return Yx;case 35675:return Xx;case 35676:return Qx;case 5124:case 35670:return $x;case 35667:case 35671:return Zx;case 35668:case 35672:return eC;case 35669:case 35673:return tC;case 5125:return nC;case 36294:return rC;case 36295:return iC;case 36296:return oC;case 35678:case 36198:case 36298:case 36306:case 35682:return sC;case 35679:case 36299:case 36307:return aC;case 35680:case 36300:case 36308:case 36293:return lC;case 36289:case 36303:case 36311:case 36292:return cC}}(t.type)}}class hC{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 pC=/(\w+)(\])?(\[|\.)?/g;function mC(e,t){e.seq.push(t),e.map[t.id]=t}function fC(e,t,n){const r=e.name,i=r.length;for(pC.lastIndex=0;;){const o=pC.exec(r),s=pC.lastIndex;let a=o[1];const l="]"===o[2],c=o[3];if(l&&(a|=0),void 0===c||"["===c&&s+2===i){mC(n,void 0===c?new uC(a,e,t):new dC(a,e,t));break}{let e=n.map[a];void 0===e&&(e=new hC(a),mC(n,e)),n=e}}}class gC{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);fC(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],s=n[o.id];!1!==s.needsUpdate&&o.setValue(e,s.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 vC(e,t,n){const r=e.createShader(t);return e.shaderSource(r,n),e.compileShader(r),r}let yC=0;function _C(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 SC(e,t){const n=function(e){switch(e){case Lv:return["Linear","( value )"];case kv: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 bC(e,t){let n;switch(t){case ng:n="Linear";break;case rg:n="Reinhard";break;case ig:n="OptimizedCineon";break;case og:n="ACESFilmic";break;case sg:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),n="Linear"}return"vec3 "+e+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}function xC(e){return""!==e}function CC(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 wC(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}const AC=/^[ \t]*#include +<([\w\d./]+)>/gm;function EC(e){return e.replace(AC,IC)}function IC(e,t){const n=Db[t];if(void 0===n)throw new Error("Can not resolve #include <"+t+">");return EC(n)}const TC=/#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 MC(e){return e.replace(TC,RC)}function RC(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 PC(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 NC(e,t,n,r){const i=e.getContext(),o=n.defines;let s=n.vertexShader,a=n.fragmentShader;const l=function(e){let t="SHADOWMAP_TYPE_BASIC";return e.shadowMapType===gf?t="SHADOWMAP_TYPE_PCF":e.shadowMapType===vf?t="SHADOWMAP_TYPE_PCF_SOFT":e.shadowMapType===yf&&(t="SHADOWMAP_TYPE_VSM"),t}(n),c=function(e){let t="ENVMAP_TYPE_CUBE";if(e.envMap)switch(e.envMapMode){case lg:case cg:t="ENVMAP_TYPE_CUBE";break;case hg:t="ENVMAP_TYPE_CUBE_UV"}return t}(n),u=function(e){let t="ENVMAP_MODE_REFLECTION";e.envMap&&e.envMapMode===cg&&(t="ENVMAP_MODE_REFRACTION");return t}(n),d=function(e){let t="ENVMAP_BLENDING_NONE";if(e.envMap)switch(e.combine){case $f:t="ENVMAP_BLENDING_MULTIPLY";break;case Zf:t="ENVMAP_BLENDING_MIX";break;case eg:t="ENVMAP_BLENDING_ADD"}return t}(n),h=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),p=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(xC).join("\n")}(n),m=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),f=i.createProgram();let g,v,y=n.glslVersion?"#version "+n.glslVersion+"\n":"";n.isRawShaderMaterial?(g=[m].filter(xC).join("\n"),g.length>0&&(g+="\n"),v=[p,m].filter(xC).join("\n"),v.length>0&&(v+="\n")):(g=[PC(n),"#define SHADER_NAME "+n.shaderName,m,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(xC).join("\n"),v=[p,PC(n),"#define SHADER_NAME "+n.shaderName,m,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:"",h?"#define CUBEUV_TEXEL_WIDTH "+h.texelWidth:"",h?"#define CUBEUV_TEXEL_HEIGHT "+h.texelHeight:"",h?"#define CUBEUV_MAX_MIP "+h.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!==tg?"#define TONE_MAPPING":"",n.toneMapping!==tg?Db.tonemapping_pars_fragment:"",n.toneMapping!==tg?bC("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",Db.encodings_pars_fragment,SC("linearToOutputTexel",n.outputEncoding),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(xC).join("\n")),s=EC(s),s=CC(s,n),s=wC(s,n),a=EC(a),a=CC(a,n),a=wC(a,n),s=MC(s),a=MC(a),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===gy?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===gy?"":"#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 _=y+v+a,S=vC(i,35633,y+g+s),b=vC(i,35632,_);if(i.attachShader(f,S),i.attachShader(f,b),void 0!==n.index0AttributeName?i.bindAttribLocation(f,0,n.index0AttributeName):!0===n.morphTargets&&i.bindAttribLocation(f,0,"position"),i.linkProgram(f),e.debug.checkShaderErrors){const e=i.getProgramInfoLog(f).trim(),t=i.getShaderInfoLog(S).trim(),n=i.getShaderInfoLog(b).trim();let r=!0,o=!0;if(!1===i.getProgramParameter(f,35714)){r=!1;const t=_C(i,S,"vertex"),n=_C(i,b,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(f,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 x,C;return i.deleteShader(S),i.deleteShader(b),this.getUniforms=function(){return void 0===x&&(x=new gC(i,f)),x},this.getAttributes=function(){return void 0===C&&(C=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 s=1;35674===r.type&&(s=2),35675===r.type&&(s=3),35676===r.type&&(s=4),n[o]={type:r.type,location:e.getAttribLocation(t,o),locationSize:s}}return n}(i,f)),C},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(f),this.program=void 0},this.name=n.shaderName,this.id=yC++,this.cacheKey=t,this.usedTimes=1,this.program=f,this.vertexShader=S,this.fragmentShader=b,this}let OC=0;class DC{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 LC(e),t.set(e,n)),n}}class LC{constructor(e){this.id=OC++,this.code=e,this.usedTimes=0}}function kC(e,t,n,r,i,o,s){const a=new $_,l=new DC,c=[],u=i.isWebGL2,d=i.logarithmicDepthBuffer,h=i.vertexTextures;let p=i.precision;const m={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};return{getParameters:function(o,a,c,f,g){const v=f.fog,y=g.geometry,_=o.isMeshStandardMaterial?f.environment:null,S=(o.isMeshStandardMaterial?n:t).get(o.envMap||_),b=S&&S.mapping===hg?S.image.height:null,x=m[o.type];null!==o.precision&&(p=i.getMaxPrecision(o.precision),p!==o.precision&&console.warn("THREE.WebGLProgram.getParameters:",o.precision,"not supported, using",p,"instead."));const C=y.morphAttributes.position||y.morphAttributes.normal||y.morphAttributes.color,w=void 0!==C?C.length:0;let A,E,I,T,M=0;if(void 0!==y.morphAttributes.position&&(M=1),void 0!==y.morphAttributes.normal&&(M=2),void 0!==y.morphAttributes.color&&(M=3),x){const e=kb[x];A=e.vertexShader,E=e.fragmentShader}else A=o.vertexShader,E=o.fragmentShader,l.update(o),I=l.getVertexShaderID(o),T=l.getFragmentShaderID(o);const R=e.getRenderTarget(),P=o.alphaTest>0,N=o.clearcoat>0,O=o.iridescence>0;return{isWebGL2:u,shaderID:x,shaderName:o.type,vertexShader:A,fragmentShader:E,defines:o.defines,customVertexShaderID:I,customFragmentShaderID:T,isRawShaderMaterial:!0===o.isRawShaderMaterial,glslVersion:o.glslVersion,precision:p,instancing:!0===g.isInstancedMesh,instancingColor:!0===g.isInstancedMesh&&null!==g.instanceColor,supportsVertexTextures:h,outputEncoding:null===R?e.outputEncoding:!0===R.isXRRenderTarget?R.texture.encoding:Lv,map:!!o.map,matcap:!!o.matcap,envMap:!!S,envMapMode:S&&S.mapping,envMapCubeUVHeight:b,lightMap:!!o.lightMap,aoMap:!!o.aoMap,emissiveMap:!!o.emissiveMap,bumpMap:!!o.bumpMap,normalMap:!!o.normalMap,objectSpaceNormalMap:o.normalMapType===Uv,tangentSpaceNormalMap:o.normalMapType===Fv,decodeVideoTexture:!!o.map&&!0===o.map.isVideoTexture&&o.map.encoding===kv,clearcoat:N,clearcoatMap:N&&!!o.clearcoatMap,clearcoatRoughnessMap:N&&!!o.clearcoatRoughnessMap,clearcoatNormalMap:N&&!!o.clearcoatNormalMap,iridescence:O,iridescenceMap:O&&!!o.iridescenceMap,iridescenceThicknessMap:O&&!!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===Cf,alphaMap:!!o.alphaMap,alphaTest:P,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:w,morphTextureStride:M,numDirLights:a.directional.length,numPointLights:a.point.length,numSpotLights:a.spot.length,numSpotLightMaps:a.spotLightMap.length,numRectAreaLights:a.rectArea.length,numHemiLights:a.hemi.length,numDirLightShadows:a.directionalShadowMap.length,numPointLightShadows:a.pointShadowMap.length,numSpotLightShadows:a.spotShadowMap.length,numSpotLightShadowsWithMaps:a.numSpotLightShadowsWithMaps,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:o.dithering,shadowMapEnabled:e.shadowMap.enabled&&c.length>0,shadowMapType:e.shadowMap.type,toneMapping:o.toneMapped?e.toneMapping:tg,physicallyCorrectLights:e.physicallyCorrectLights,premultipliedAlpha:o.premultipliedAlpha,doubleSided:o.side===bf,flipSided:o.side===Sf,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){a.disableAll(),t.isWebGL2&&a.enable(0);t.supportsVertexTextures&&a.enable(1);t.instancing&&a.enable(2);t.instancingColor&&a.enable(3);t.map&&a.enable(4);t.matcap&&a.enable(5);t.envMap&&a.enable(6);t.lightMap&&a.enable(7);t.aoMap&&a.enable(8);t.emissiveMap&&a.enable(9);t.bumpMap&&a.enable(10);t.normalMap&&a.enable(11);t.objectSpaceNormalMap&&a.enable(12);t.tangentSpaceNormalMap&&a.enable(13);t.clearcoat&&a.enable(14);t.clearcoatMap&&a.enable(15);t.clearcoatRoughnessMap&&a.enable(16);t.clearcoatNormalMap&&a.enable(17);t.iridescence&&a.enable(18);t.iridescenceMap&&a.enable(19);t.iridescenceThicknessMap&&a.enable(20);t.displacementMap&&a.enable(21);t.specularMap&&a.enable(22);t.roughnessMap&&a.enable(23);t.metalnessMap&&a.enable(24);t.gradientMap&&a.enable(25);t.alphaMap&&a.enable(26);t.alphaTest&&a.enable(27);t.vertexColors&&a.enable(28);t.vertexAlphas&&a.enable(29);t.vertexUvs&&a.enable(30);t.vertexTangents&&a.enable(31);t.uvsVertexOnly&&a.enable(32);e.push(a.mask),a.disableAll(),t.fog&&a.enable(0);t.useFog&&a.enable(1);t.flatShading&&a.enable(2);t.logarithmicDepthBuffer&&a.enable(3);t.skinning&&a.enable(4);t.morphTargets&&a.enable(5);t.morphNormals&&a.enable(6);t.morphColors&&a.enable(7);t.premultipliedAlpha&&a.enable(8);t.shadowMapEnabled&&a.enable(9);t.physicallyCorrectLights&&a.enable(10);t.doubleSided&&a.enable(11);t.flipSided&&a.enable(12);t.useDepthPacking&&a.enable(13);t.dithering&&a.enable(14);t.specularIntensityMap&&a.enable(15);t.specularColorMap&&a.enable(16);t.transmission&&a.enable(17);t.transmissionMap&&a.enable(18);t.thicknessMap&&a.enable(19);t.sheen&&a.enable(20);t.sheenColorMap&&a.enable(21);t.sheenRoughnessMap&&a.enable(22);t.decodeVideoTexture&&a.enable(23);t.opaque&&a.enable(24);e.push(a.mask)}(n,t),n.push(e.outputEncoding)),n.push(t.customProgramCacheKey),n.join()},getUniforms:function(e){const t=m[e.type];let n;if(t){const e=kb[t];n=gb.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 NC(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 BC(){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 zC(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 FC(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 UC(){const e=[];let t=0;const n=[],r=[],i=[];function o(n,r,i,o,s,a){let l=e[t];return void 0===l?(l={id:n.id,object:n,geometry:r,material:i,groupOrder:o,renderOrder:n.renderOrder,z:s,group:a},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=s,l.group=a),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,s,a,l,c){const u=o(e,t,s,a,l,c);s.transmission>0?r.push(u):!0===s.transparent?i.push(u):n.push(u)},unshift:function(e,t,s,a,l,c){const u=o(e,t,s,a,l,c);s.transmission>0?r.unshift(u):!0===s.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||zC),r.length>1&&r.sort(t||FC),i.length>1&&i.sort(t||FC)}}}function jC(){let e=new WeakMap;return{get:function(t,n){const r=e.get(t);let i;return void 0===r?(i=new UC,e.set(t,[i])):n>=r.length?(i=new UC,r.push(i)):i=r[n],i},dispose:function(){e=new WeakMap}}}function GC(){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 u_,color:new Yy};break;case"SpotLight":n={position:new u_,direction:new u_,color:new Yy,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new u_,color:new Yy,distance:0,decay:0};break;case"HemisphereLight":n={direction:new u_,skyColor:new Yy,groundColor:new Yy};break;case"RectAreaLight":n={color:new Yy,position:new u_,halfWidth:new u_,halfHeight:new u_}}return e[t.id]=n,n}}}let HC=0;function VC(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function WC(e,t){const n=new GC,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 Oy};break;case"PointLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Oy,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 u_);const o=new u_,s=new j_,a=new j_;return{setup:function(o,s){let a=0,l=0,c=0;for(let e=0;e<9;e++)i.probe[e].set(0,0,0);let u=0,d=0,h=0,p=0,m=0,f=0,g=0,v=0,y=0,_=0;o.sort(VC);const S=!0!==s?Math.PI:1;for(let e=0,t=o.length;e<t;e++){const t=o[e],s=t.color,b=t.intensity,x=t.distance,C=t.shadow&&t.shadow.map?t.shadow.map.texture:null;if(t.isAmbientLight)a+=s.r*b*S,l+=s.g*b*S,c+=s.b*b*S;else if(t.isLightProbe)for(let e=0;e<9;e++)i.probe[e].addScaledVector(t.sh.coefficients[e],b);else if(t.isDirectionalLight){const e=n.get(t);if(e.color.copy(t.color).multiplyScalar(t.intensity*S),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]=C,i.directionalShadowMatrix[u]=t.shadow.matrix,f++}i.directional[u]=e,u++}else if(t.isSpotLight){const e=n.get(t);e.position.setFromMatrixPosition(t.matrixWorld),e.color.copy(s).multiplyScalar(b*S),e.distance=x,e.coneCos=Math.cos(t.angle),e.penumbraCos=Math.cos(t.angle*(1-t.penumbra)),e.decay=t.decay,i.spot[h]=e;const o=t.shadow;if(t.map&&(i.spotLightMap[y]=t.map,y++,o.updateMatrices(t),t.castShadow&&_++),i.spotLightMatrix[h]=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[h]=e,i.spotShadowMap[h]=C,v++}h++}else if(t.isRectAreaLight){const e=n.get(t);e.color.copy(s).multiplyScalar(b),e.halfWidth.set(.5*t.width,0,0),e.halfHeight.set(0,.5*t.height,0),i.rectArea[p]=e,p++}else if(t.isPointLight){const e=n.get(t);if(e.color.copy(t.color).multiplyScalar(t.intensity*S),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]=C,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(b*S),e.groundColor.copy(t.groundColor).multiplyScalar(b*S),i.hemi[m]=e,m++}}p>0&&(t.isWebGL2||!0===e.has("OES_texture_float_linear")?(i.rectAreaLTC1=Lb.LTC_FLOAT_1,i.rectAreaLTC2=Lb.LTC_FLOAT_2):!0===e.has("OES_texture_half_float_linear")?(i.rectAreaLTC1=Lb.LTC_HALF_1,i.rectAreaLTC2=Lb.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),i.ambient[0]=a,i.ambient[1]=l,i.ambient[2]=c;const b=i.hash;b.directionalLength===u&&b.pointLength===d&&b.spotLength===h&&b.rectAreaLength===p&&b.hemiLength===m&&b.numDirectionalShadows===f&&b.numPointShadows===g&&b.numSpotShadows===v&&b.numSpotMaps===y||(i.directional.length=u,i.spot.length=h,i.rectArea.length=p,i.point.length=d,i.hemi.length=m,i.directionalShadow.length=f,i.directionalShadowMap.length=f,i.pointShadow.length=g,i.pointShadowMap.length=g,i.spotShadow.length=v,i.spotShadowMap.length=v,i.directionalShadowMatrix.length=f,i.pointShadowMatrix.length=g,i.spotLightMatrix.length=v+y-_,i.spotLightMap.length=y,i.numSpotLightShadowsWithMaps=_,b.directionalLength=u,b.pointLength=d,b.spotLength=h,b.rectAreaLength=p,b.hemiLength=m,b.numDirectionalShadows=f,b.numPointShadows=g,b.numSpotShadows=v,b.numSpotMaps=y,i.version=HC++)},setupView:function(e,t){let n=0,r=0,l=0,c=0,u=0;const d=t.matrixWorldInverse;for(let t=0,h=e.length;t<h;t++){const h=e[t];if(h.isDirectionalLight){const e=i.directional[n];e.direction.setFromMatrixPosition(h.matrixWorld),o.setFromMatrixPosition(h.target.matrixWorld),e.direction.sub(o),e.direction.transformDirection(d),n++}else if(h.isSpotLight){const e=i.spot[l];e.position.setFromMatrixPosition(h.matrixWorld),e.position.applyMatrix4(d),e.direction.setFromMatrixPosition(h.matrixWorld),o.setFromMatrixPosition(h.target.matrixWorld),e.direction.sub(o),e.direction.transformDirection(d),l++}else if(h.isRectAreaLight){const e=i.rectArea[c];e.position.setFromMatrixPosition(h.matrixWorld),e.position.applyMatrix4(d),a.identity(),s.copy(h.matrixWorld),s.premultiply(d),a.extractRotation(s),e.halfWidth.set(.5*h.width,0,0),e.halfHeight.set(0,.5*h.height,0),e.halfWidth.applyMatrix4(a),e.halfHeight.applyMatrix4(a),c++}else if(h.isPointLight){const e=i.point[r];e.position.setFromMatrixPosition(h.matrixWorld),e.position.applyMatrix4(d),r++}else if(h.isHemisphereLight){const e=i.hemi[u];e.direction.setFromMatrixPosition(h.matrixWorld),e.direction.transformDirection(d),u++}}},state:i}}function qC(e,t){const n=new WC(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 JC(e,t){let n=new WeakMap;return{get:function(r,i=0){const o=n.get(r);let s;return void 0===o?(s=new qC(e,t),n.set(r,[s])):i>=o.length?(s=new qC(e,t),o.push(s)):s=o[i],s},dispose:function(){n=new WeakMap}}}class KC extends AS{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Bv,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 YC extends AS{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.referencePosition=new u_,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 XC(e,t,n){let r=new Rb;const i=new Oy,o=new Oy,s=new n_,a=new KC({depthPacking:zv}),l=new YC,c={},u=n.maxTextureSize,d={0:Sf,1:_f,2:bf},h=new vb({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Oy},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}"}),p=h.clone();p.defines.HORIZONTAL_PASS=1;const m=new JS;m.setAttribute("position",new MS(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const f=new db(m,h),g=this;function v(n,r){const o=t.update(f);h.defines.VSM_SAMPLES!==n.blurSamples&&(h.defines.VSM_SAMPLES=n.blurSamples,p.defines.VSM_SAMPLES=n.blurSamples,h.needsUpdate=!0,p.needsUpdate=!0),null===n.mapPass&&(n.mapPass=new r_(i.x,i.y)),h.uniforms.shadow_pass.value=n.map.texture,h.uniforms.resolution.value=n.mapSize,h.uniforms.radius.value=n.radius,e.setRenderTarget(n.mapPass),e.clear(),e.renderBufferDirect(r,null,o,h,f,null),p.uniforms.shadow_pass.value=n.mapPass.texture,p.uniforms.resolution.value=n.mapSize,p.uniforms.radius.value=n.radius,e.setRenderTarget(n.map),e.clear(),e.renderBufferDirect(r,null,o,p,f,null)}function y(t,n,r,i,o,s){let u=null;const h=!0===r.isPointLight?t.customDistanceMaterial:t.customDepthMaterial;if(u=void 0!==h?h:!0===r.isPointLight?l:a,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=s===yf?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 _(n,i,o,s,a){if(!1===n.visible)return;if(n.layers.test(i.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&a===yf)&&(!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,s,o.near,o.far,a);e.renderBufferDirect(o,null,r,t,n,c)}}}else if(i.visible){const t=y(n,i,s,o.near,o.far,a);e.renderBufferDirect(o,null,r,t,n,null)}}const l=n.children;for(let e=0,t=l.length;e<t;e++)_(l[e],i,o,s,a)}this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=gf,this.render=function(t,n,a){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(),h=e.state;h.setBlending(xf),h.buffers.color.setClear(1,1,1,1),h.buffers.depth.setTest(!0),h.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 p=d.getFrameExtents();if(i.multiply(p),o.copy(d.mapSize),(i.x>u||i.y>u)&&(i.x>u&&(o.x=Math.floor(u/p.x),i.x=o.x*p.x,d.mapSize.x=o.x),i.y>u&&(o.y=Math.floor(u/p.y),i.y=o.y*p.y,d.mapSize.y=o.y)),null===d.map){const e=this.type!==yf?{minFilter:gg,magFilter:gg}:{};d.map=new r_(i.x,i.y,e),d.map.texture.name=c.name+".shadowMap",d.camera.updateProjectionMatrix()}e.setRenderTarget(d.map),e.clear();const m=d.getViewportCount();for(let e=0;e<m;e++){const t=d.getViewport(e);s.set(o.x*t.x,o.y*t.y,o.x*t.z,o.y*t.w),h.viewport(s),d.updateMatrices(c,e),r=d.getFrustum(),_(n,a,d.camera,c,this.type)}!0!==d.isPointLightShadow&&this.type===yf&&v(d,a),d.needsUpdate=!1}g.needsUpdate=!1,e.setRenderTarget(l,c,d)}}function QC(e,t,n){const r=n.isWebGL2;const i=new function(){let t=!1;const n=new n_;let r=null;const i=new n_(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,s,a){!0===a&&(t*=s,r*=s,o*=s),n.set(t,r,o,s),!1===i.equals(n)&&(e.clearColor(t,r,o,s),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):j(2929)},setMask:function(r){n===r||t||(e.depthMask(r),n=r)},setFunc:function(t){if(r!==t){if(t)switch(t){case Vf:e.depthFunc(512);break;case Wf:e.depthFunc(519);break;case qf:e.depthFunc(513);break;case Jf:e.depthFunc(515);break;case Kf:e.depthFunc(514);break;case Yf:e.depthFunc(518);break;case Xf:e.depthFunc(516);break;case Qf: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}}},s=new function(){let t=!1,n=null,r=null,i=null,o=null,s=null,a=null,l=null,c=null;return{setTest:function(e){t||(e?U(2960):j(2960))},setMask:function(r){n===r||t||(e.stencilMask(r),n=r)},setFunc:function(t,n,s){r===t&&i===n&&o===s||(e.stencilFunc(t,n,s),r=t,i=n,o=s)},setOp:function(t,n,r){s===t&&a===n&&l===r||(e.stencilOp(t,n,r),s=t,a=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,s=null,a=null,l=null,c=null}}},a=new WeakMap,l=new WeakMap;let c={},u={},d=new WeakMap,h=[],p=null,m=!1,f=null,g=null,v=null,y=null,_=null,S=null,b=null,x=!1,C=null,w=null,A=null,E=null,I=null;const T=e.getParameter(35661);let M=!1,R=0;const P=e.getParameter(7938);-1!==P.indexOf("WebGL")?(R=parseFloat(/^WebGL (\d)/.exec(P)[1]),M=R>=1):-1!==P.indexOf("OpenGL ES")&&(R=parseFloat(/^OpenGL ES (\d)/.exec(P)[1]),M=R>=2);let N=null,O={};const D=e.getParameter(3088),L=e.getParameter(2978),k=(new n_).fromArray(D),B=(new n_).fromArray(L);function z(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 j(t){!1!==c[t]&&(e.disable(t),c[t]=!1)}F[3553]=z(3553,3553,1),F[34067]=z(34067,34069,6),i.setClear(0,0,0,1),o.setClear(1),s.setClear(0),U(2929),o.setFunc(Jf),W(!1),q(hf),U(2884),V(xf);const G={[Tf]:32774,[Mf]:32778,[Rf]:32779};if(r)G[Pf]=32775,G[Nf]=32776;else{const e=t.get("EXT_blend_minmax");null!==e&&(G[Pf]=e.MIN_EXT,G[Nf]=e.MAX_EXT)}const H={[Of]:0,[Df]:1,[Lf]:768,[Bf]:770,[Hf]:776,[jf]:774,[Ff]:772,[kf]:769,[zf]:771,[Gf]:775,[Uf]:773};function V(t,n,r,i,o,s,a,l){if(t!==xf){if(!1===m&&(U(3042),m=!0),t===If)o=o||n,s=s||r,a=a||i,n===g&&o===_||(e.blendEquationSeparate(G[n],G[o]),g=n,_=o),r===v&&i===y&&s===S&&a===b||(e.blendFuncSeparate(H[r],H[i],H[s],H[a]),v=r,y=i,S=s,b=a),f=t,x=null;else if(t!==f||l!==x){if(g===Tf&&_===Tf||(e.blendEquation(32774),g=Tf,_=Tf),l)switch(t){case Cf:e.blendFuncSeparate(1,771,1,771);break;case wf:e.blendFunc(1,1);break;case Af:e.blendFuncSeparate(0,769,0,1);break;case Ef:e.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",t)}else switch(t){case Cf:e.blendFuncSeparate(770,771,1,771);break;case wf:e.blendFunc(770,1);break;case Af:e.blendFuncSeparate(0,769,0,1);break;case Ef:e.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",t)}v=null,y=null,S=null,b=null,f=t,x=l}}else!0===m&&(j(3042),m=!1)}function W(t){C!==t&&(t?e.frontFace(2304):e.frontFace(2305),C=t)}function q(t){t!==df?(U(2884),t!==w&&(t===hf?e.cullFace(1029):t===pf?e.cullFace(1028):e.cullFace(1032))):j(2884),w=t}function J(t,n,r){t?(U(32823),E===n&&I===r||(e.polygonOffset(n,r),E=n,I=r)):j(32823)}function K(t){void 0===t&&(t=33984+T-1),N!==t&&(e.activeTexture(t),N=t)}return{buffers:{color:i,depth:o,stencil:s},enable:U,disable:j,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=h,s=!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,s=!0}}else 36064!==o[0]&&(o[0]=36064,s=!0);else 1029!==o[0]&&(o[0]=1029,s=!0);s&&(n.isWebGL2?e.drawBuffers(o):t.get("WEBGL_draw_buffers").drawBuffersWEBGL(o))},useProgram:function(t){return p!==t&&(e.useProgram(t),p=t,!0)},setBlending:V,setMaterial:function(e,t){e.side===bf?j(2884):U(2884);let n=e.side===Sf;t&&(n=!n),W(n),e.blending===Cf&&!1===e.transparent?V(xf):V(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;s.setTest(r),r&&(s.setMask(e.stencilWriteMask),s.setFunc(e.stencilFunc,e.stencilRef,e.stencilFuncMask),s.setOp(e.stencilFail,e.stencilZFail,e.stencilZPass)),J(e.polygonOffset,e.polygonOffsetFactor,e.polygonOffsetUnits),!0===e.alphaToCoverage?U(32926):j(32926)},setFlipSided:W,setCullFace:q,setLineWidth:function(t){t!==A&&(M&&e.lineWidth(t),A=t)},setPolygonOffset:J,setScissorTest:function(e){e?U(3089):j(3089)},activeTexture:K,bindTexture:function(t,n){null===N&&K();let r=O[N];void 0===r&&(r={type:void 0,texture:void 0},O[N]=r),r.type===t&&r.texture===n||(e.bindTexture(t,n||F[t]),r.type=t,r.texture=n)},unbindTexture:function(){const t=O[N];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);a.get(t)!==r&&(e.uniformBlockBinding(n,r,t.__bindingPointIndex),a.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===k.equals(t)&&(e.scissor(t.x,t.y,t.z,t.w),k.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={},N=null,O={},u={},d=new WeakMap,h=[],p=null,m=!1,f=null,g=null,v=null,y=null,_=null,S=null,b=null,x=!1,C=null,w=null,A=null,E=null,I=null,k.set(0,0,e.canvas.width,e.canvas.height),B.set(0,0,e.canvas.width,e.canvas.height),i.reset(),o.reset(),s.reset()}}}function $C(e,t,n,r,i,o,s){const a=i.isWebGL2,l=i.maxTextures,c=i.maxCubemapSize,u=i.maxTextureSize,d=i.maxSamples,h=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,p=/OculusBrowser/g.test(navigator.userAgent),m=new WeakMap;let f;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):zy("canvas")}function _(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?My:Math.floor,o=r(i*e.width),s=r(i*e.height);void 0===f&&(f=y(o,s));const a=n?y(o,s):f;a.width=o,a.height=s;return a.getContext("2d").drawImage(e,0,0,o,s),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+e.width+"x"+e.height+") to ("+o+"x"+s+")."),a}return"data"in e&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+e.width+"x"+e.height+")."),e}return e}function S(e){return Iy(e.width)&&Iy(e.height)}function b(e,t){return e.generateMipmaps&&t&&e.minFilter!==gg&&e.minFilter!==bg}function x(t){e.generateMipmap(t)}function C(n,r,i,o,s=!1){if(!1===a)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===kv&&!1===s?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 w(e,t,n){return!0===b(e,n)||e.isFramebufferTexture&&e.minFilter!==gg&&e.minFilter!==bg?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===gg||e===vg||e===_g?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&&T(e),0===Object.keys(i).length&&g.delete(n)}r.remove(e)}(t),t.isVideoTexture&&m.delete(t)}function I(t){const n=t.target;n.removeEventListener("dispose",I),function(t){const n=t.texture,i=r.get(t),o=r.get(n);void 0!==o.__webglTexture&&(e.deleteTexture(o.__webglTexture),s.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),s.memory.textures--),r.remove(n[t])}r.remove(n),r.remove(t)}(n)}function T(t){const n=r.get(t);e.deleteTexture(n.__webglTexture);const i=t.source;delete g.get(i)[n.__cacheKey],s.memory.textures--}let M=0;function R(e,t){const i=r.get(e);if(e.isVideoTexture&&function(e){const t=s.render.frame;m.get(e)!==t&&(m.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 P={[pg]:10497,[mg]:33071,[fg]:33648},N={[gg]:9728,[vg]:9984,[_g]:9986,[bg]:9729,[xg]:9985,[wg]:9987};function O(n,o,s){if(s?(e.texParameteri(n,10242,P[o.wrapS]),e.texParameteri(n,10243,P[o.wrapT]),32879!==n&&35866!==n||e.texParameteri(n,32882,P[o.wrapR]),e.texParameteri(n,10240,N[o.magFilter]),e.texParameteri(n,10241,N[o.minFilter])):(e.texParameteri(n,10242,33071),e.texParameteri(n,10243,33071),32879!==n&&35866!==n||e.texParameteri(n,32882,33071),o.wrapS===mg&&o.wrapT===mg||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!==gg&&o.minFilter!==bg&&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 s=t.get("EXT_texture_filter_anisotropic");if(o.type===Ng&&!1===t.has("OES_texture_float_linear"))return;if(!1===a&&o.type===Og&&!1===t.has("OES_texture_half_float_linear"))return;(o.anisotropy>1||r.get(o).__currentAnisotropy)&&(e.texParameterf(n,s.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(o.anisotropy,i.getMaxAnisotropy())),r.get(o).__currentAnisotropy=o.anisotropy)}}function D(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 a=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(a!==t.__cacheKey){void 0===o[a]&&(o[a]={texture:e.createTexture(),usedTimes:0},s.memory.textures++,r=!0),o[a].usedTimes++;const i=o[t.__cacheKey];void 0!==i&&(o[t.__cacheKey].usedTimes--,0===i.usedTimes&&T(n)),t.__cacheKey=a,t.__webglTexture=o[a].texture}return r}function L(t,r,i){let s=3553;r.isDataArrayTexture&&(s=35866),r.isData3DTexture&&(s=32879);const l=D(t,r),c=r.source;if(n.activeTexture(33984+i),n.bindTexture(s,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!a&&(e.wrapS!==mg||e.wrapT!==mg||e.minFilter!==gg&&e.minFilter!==bg)}(r)&&!1===S(r.image);let i=_(r.image,t,!1,u);i=j(r,i);const d=S(i)||a,h=o.convert(r.format,r.encoding);let p,m=o.convert(r.type),f=C(r.internalFormat,h,m,r.encoding,r.isVideoTexture);O(s,r,d);const g=r.mipmaps,v=a&&!0!==r.isVideoTexture,y=void 0===c.__currentVersion||!0===l,A=w(r,i,d);if(r.isDepthTexture)f=6402,a?f=r.type===Ng?36012:r.type===Pg?33190:r.type===kg?35056:33189:r.type===Ng&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),r.format===Gg&&6402===f&&r.type!==Mg&&r.type!==Pg&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),r.type=Pg,m=o.convert(r.type)),r.format===Hg&&6402===f&&(f=34041,r.type!==kg&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),r.type=kg,m=o.convert(r.type))),y&&(v?n.texStorage2D(3553,1,f,i.width,i.height):n.texImage2D(3553,0,f,i.width,i.height,0,h,m,null));else if(r.isDataTexture)if(g.length>0&&d){v&&y&&n.texStorage2D(3553,A,f,g[0].width,g[0].height);for(let e=0,t=g.length;e<t;e++)p=g[e],v?n.texSubImage2D(3553,e,0,0,p.width,p.height,h,m,p.data):n.texImage2D(3553,e,f,p.width,p.height,0,h,m,p.data);r.generateMipmaps=!1}else v?(y&&n.texStorage2D(3553,A,f,i.width,i.height),n.texSubImage2D(3553,0,0,0,i.width,i.height,h,m,i.data)):n.texImage2D(3553,0,f,i.width,i.height,0,h,m,i.data);else if(r.isCompressedTexture){v&&y&&n.texStorage2D(3553,A,f,g[0].width,g[0].height);for(let e=0,t=g.length;e<t;e++)p=g[e],r.format!==Fg?null!==h?v?n.compressedTexSubImage2D(3553,e,0,0,p.width,p.height,h,p.data):n.compressedTexImage2D(3553,e,f,p.width,p.height,0,p.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):v?n.texSubImage2D(3553,e,0,0,p.width,p.height,h,m,p.data):n.texImage2D(3553,e,f,p.width,p.height,0,h,m,p.data)}else if(r.isDataArrayTexture)v?(y&&n.texStorage3D(35866,A,f,i.width,i.height,i.depth),n.texSubImage3D(35866,0,0,0,0,i.width,i.height,i.depth,h,m,i.data)):n.texImage3D(35866,0,f,i.width,i.height,i.depth,0,h,m,i.data);else if(r.isData3DTexture)v?(y&&n.texStorage3D(32879,A,f,i.width,i.height,i.depth),n.texSubImage3D(32879,0,0,0,0,i.width,i.height,i.depth,h,m,i.data)):n.texImage3D(32879,0,f,i.width,i.height,i.depth,0,h,m,i.data);else if(r.isFramebufferTexture){if(y)if(v)n.texStorage2D(3553,A,f,i.width,i.height);else{let e=i.width,t=i.height;for(let r=0;r<A;r++)n.texImage2D(3553,r,f,e,t,0,h,m,null),e>>=1,t>>=1}}else if(g.length>0&&d){v&&y&&n.texStorage2D(3553,A,f,g[0].width,g[0].height);for(let e=0,t=g.length;e<t;e++)p=g[e],v?n.texSubImage2D(3553,e,0,0,h,m,p):n.texImage2D(3553,e,f,h,m,p);r.generateMipmaps=!1}else v?(y&&n.texStorage2D(3553,A,f,i.width,i.height),n.texSubImage2D(3553,0,0,0,h,m,i)):n.texImage2D(3553,0,f,h,m,i);b(r,d)&&x(s),c.__currentVersion=c.version,r.onUpdate&&r.onUpdate(r)}t.__version=r.version}function k(t,i,s,a,l){const c=o.convert(s.format,s.encoding),u=o.convert(s.type),d=C(s.internalFormat,c,u,s.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)?h.framebufferTexture2DMultisampleEXT(36160,a,l,r.get(s).__webglTexture,0,F(i)):e.framebufferTexture2D(36160,a,l,r.get(s).__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===Ng?i=36012:t.type===Pg&&(i=33190));const r=F(n);U(n)?h.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)?h.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 s=t[i],a=o.convert(s.format,s.encoding),l=o.convert(s.type),c=C(s.internalFormat,a,l,s.encoding),u=F(n);r&&!1===U(n)?e.renderbufferStorageMultisample(36161,u,c,n.width,n.height):U(n)?h.renderbufferStorageMultisampleEXT(36161,u,c,n.width,n.height):e.renderbufferStorage(36161,c,n.width,n.height)}}e.bindRenderbuffer(36161,null)}function z(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),R(i.depthTexture,0);const o=r.get(i.depthTexture).__webglTexture,s=F(i);if(i.depthTexture.format===Gg)U(i)?h.framebufferTexture2DMultisampleEXT(36160,36096,3553,o,0,s):e.framebufferTexture2D(36160,36096,3553,o,0);else{if(i.depthTexture.format!==Hg)throw new Error("Unknown depthTexture format");U(i)?h.framebufferTexture2DMultisampleEXT(36160,33306,3553,o,0,s):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 a&&e.samples>0&&!0===t.has("WEBGL_multisampled_render_to_texture")&&!1!==n.__useRenderToTexture}function j(e,n){const r=e.encoding,i=e.format,o=e.type;return!0===e.isCompressedTexture||!0===e.isVideoTexture||e.format===vy||r!==Lv&&(r===kv?!1===a?!0===t.has("EXT_sRGB")&&i===Fg?(e.format=vy,e.minFilter=bg,e.generateMipmaps=!1):n=Qy.sRGBToLinear(n):i===Fg&&o===Eg||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=M;return e>=l&&console.warn("THREE.WebGLTextures: Trying to use "+e+" texture units while this GPU supports only "+l),M+=1,e},this.resetTextureUnits=function(){M=0},this.setTexture2D=R,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 s=r.get(t);t.version>0&&s.__version!==t.version?function(t,r,i){if(6!==r.image.length)return;const s=D(t,r),l=r.source;if(n.activeTexture(33984+i),n.bindTexture(34067,t.__webglTexture),l.version!==l.__currentVersion||!0===s){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]:_(r.image[e],!1,!0,c),u[e]=j(r,u[e]);const d=u[0],h=S(d)||a,p=o.convert(r.format,r.encoding),m=o.convert(r.type),f=C(r.internalFormat,p,m,r.encoding),g=a&&!0!==r.isVideoTexture,v=void 0===l.__currentVersion||!0===s;let y,A=w(r,d,h);if(O(34067,r,h),t){g&&v&&n.texStorage2D(34067,A,f,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!==Fg?null!==p?g?n.compressedTexSubImage2D(34069+e,t,0,0,i.width,i.height,p,i.data):n.compressedTexImage2D(34069+e,t,f,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,p,m,i.data):n.texImage2D(34069+e,t,f,i.width,i.height,0,p,m,i.data)}}}else{y=r.mipmaps,g&&v&&(y.length>0&&A++,n.texStorage2D(34067,A,f,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,p,m,u[e].data):n.texImage2D(34069+e,0,f,u[e].width,u[e].height,0,p,m,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,p,m,r.data):n.texImage2D(34069+e,t+1,f,r.width,r.height,0,p,m,r.data)}}else{g?n.texSubImage2D(34069+e,0,0,0,p,m,u[e]):n.texImage2D(34069+e,0,f,p,m,u[e]);for(let t=0;t<y.length;t++){const r=y[t];g?n.texSubImage2D(34069+e,t+1,0,0,p,m,r.image[e]):n.texImage2D(34069+e,t+1,f,p,m,r.image[e])}}}b(r,h)&&x(34067),l.__currentVersion=l.version,r.onUpdate&&r.onUpdate(r)}t.__version=r.version}(s,t,i):(n.activeTexture(33984+i),n.bindTexture(34067,s.__webglTexture))},this.rebindTextures=function(e,t,n){const i=r.get(e);void 0!==t&&k(i.__webglFramebuffer,e,e.texture,36064,3553),void 0!==n&&z(e)},this.setupRenderTarget=function(t){const l=t.texture,c=r.get(t),u=r.get(l);t.addEventListener("dispose",I),!0!==t.isWebGLMultipleRenderTargets&&(void 0===u.__webglTexture&&(u.__webglTexture=e.createTexture()),u.__version=l.version,s.memory.textures++);const d=!0===t.isWebGLCubeRenderTarget,h=!0===t.isWebGLMultipleRenderTargets,p=S(t)||a;if(d){c.__webglFramebuffer=[];for(let t=0;t<6;t++)c.__webglFramebuffer[t]=e.createFramebuffer()}else{if(c.__webglFramebuffer=e.createFramebuffer(),h)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(),s.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(a&&t.samples>0&&!1===U(t)){const r=h?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 s=o.convert(i.format,i.encoding),a=o.convert(i.type),l=C(i.internalFormat,s,a,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),O(34067,l,p);for(let e=0;e<6;e++)k(c.__webglFramebuffer[e],t,l,36064,34069+e);b(l,p)&&x(34067),n.unbindTexture()}else if(h){const e=t.texture;for(let i=0,o=e.length;i<o;i++){const o=e[i],s=r.get(o);n.bindTexture(3553,s.__webglTexture),O(3553,o,p),k(c.__webglFramebuffer,t,o,36064+i,3553),b(o,p)&&x(3553)}n.unbindTexture()}else{let e=3553;(t.isWebGL3DRenderTarget||t.isWebGLArrayRenderTarget)&&(a?e=t.isWebGL3DRenderTarget?32879:35866:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),n.bindTexture(e,u.__webglTexture),O(e,l,p),k(c.__webglFramebuffer,t,l,36064,e),b(l,p)&&x(e),n.unbindTexture()}t.depthBuffer&&z(t)},this.updateRenderTargetMipmap=function(e){const t=S(e)||a,i=!0===e.isWebGLMultipleRenderTargets?e.texture:[e.texture];for(let o=0,s=i.length;o<s;o++){const s=i[o];if(b(s,t)){const t=e.isWebGLCubeRenderTarget?34067:3553,i=r.get(s).__webglTexture;n.bindTexture(t,i),x(t),n.unbindTexture()}}},this.updateMultisampleRenderTarget=function(t){if(a&&t.samples>0&&!1===U(t)){const i=t.isWebGLMultipleRenderTargets?t.texture:[t.texture],o=t.width,s=t.height;let a=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 h=void 0!==u.__ignoreDepthValues&&u.__ignoreDepthValues;if(!1===h&&(t.depthBuffer&&(a|=256),t.stencilBuffer&&(a|=1024)),d&&e.framebufferRenderbuffer(36008,36064,36161,u.__webglColorRenderbuffer[n]),!0===h&&(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,s,0,0,o,s,a,9728),p&&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=z,this.setupFrameBufferTexture=k,this.useMultisampledRTT=U}function ZC(e,t,n){const r=n.isWebGL2;return{convert:function(n,i=null){let o;if(n===Eg)return 5121;if(n===Dg)return 32819;if(n===Lg)return 32820;if(n===Ig)return 5120;if(n===Tg)return 5122;if(n===Mg)return 5123;if(n===Rg)return 5124;if(n===Pg)return 5125;if(n===Ng)return 5126;if(n===Og)return r?5131:(o=t.get("OES_texture_half_float"),null!==o?o.HALF_FLOAT_OES:null);if(n===Bg)return 6406;if(n===Fg)return 6408;if(n===Ug)return 6409;if(n===jg)return 6410;if(n===Gg)return 6402;if(n===Hg)return 34041;if(n===Vg)return 6403;if(n===zg)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===vy)return o=t.get("EXT_sRGB"),null!==o?o.SRGB_ALPHA_EXT:null;if(n===Wg)return 36244;if(n===qg)return 33319;if(n===Jg)return 33320;if(n===Kg)return 36249;if(n===Yg||n===Xg||n===Qg||n===$g)if(i===kv){if(o=t.get("WEBGL_compressed_texture_s3tc_srgb"),null===o)return null;if(n===Yg)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Xg)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Qg)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===$g)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else{if(o=t.get("WEBGL_compressed_texture_s3tc"),null===o)return null;if(n===Yg)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Xg)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Qg)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===$g)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(n===Zg||n===ev||n===tv||n===nv){if(o=t.get("WEBGL_compressed_texture_pvrtc"),null===o)return null;if(n===Zg)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===ev)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===tv)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===nv)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(n===rv)return o=t.get("WEBGL_compressed_texture_etc1"),null!==o?o.COMPRESSED_RGB_ETC1_WEBGL:null;if(n===iv||n===ov){if(o=t.get("WEBGL_compressed_texture_etc"),null===o)return null;if(n===iv)return i===kv?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(n===ov)return i===kv?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC}if(n===sv||n===av||n===lv||n===cv||n===uv||n===dv||n===hv||n===pv||n===mv||n===fv||n===gv||n===vv||n===yv||n===_v){if(o=t.get("WEBGL_compressed_texture_astc"),null===o)return null;if(n===sv)return i===kv?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===av)return i===kv?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===lv)return i===kv?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===cv)return i===kv?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===uv)return i===kv?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===dv)return i===kv?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===hv)return i===kv?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===pv)return i===kv?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===mv)return i===kv?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===fv)return i===kv?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===gv)return i===kv?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===vv)return i===kv?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===yv)return i===kv?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===_v)return i===kv?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}if(n===Sv){if(o=t.get("EXT_texture_compression_bptc"),null===o)return null;if(n===Sv)return i===kv?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT}return n===kg?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 ew extends _b{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class tw extends hS{constructor(){super(),this.isGroup=!0,this.type="Group"}}const nw={type:"move"};class rw{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return null===this._hand&&(this._hand=new tw,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 tw,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new u_,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new u_),this._targetRay}getGripSpace(){return null===this._grip&&(this._grip=new tw,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new u_,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new u_),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 s=this._targetRay,a=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 tw;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"],s=r.position.distanceTo(i.position),a=.02,c=.005;l.inputState.pinching&&s>a+c?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&s<=a-c&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else null!==a&&e.gripSpace&&(i=t.getPose(e.gripSpace,n),null!==i&&(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),i.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(i.linearVelocity)):a.hasLinearVelocity=!1,i.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(i.angularVelocity)):a.hasAngularVelocity=!1));null!==s&&(r=t.getPose(e.targetRaySpace,n),null===r&&null!==i&&(r=i),null!==r&&(s.matrix.fromArray(r.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale),r.linearVelocity?(s.hasLinearVelocity=!0,s.linearVelocity.copy(r.linearVelocity)):s.hasLinearVelocity=!1,r.angularVelocity?(s.hasAngularVelocity=!0,s.angularVelocity.copy(r.angularVelocity)):s.hasAngularVelocity=!1,this.dispatchEvent(nw)))}return null!==s&&(s.visible=null!==r),null!==a&&(a.visible=null!==i),null!==l&&(l.visible=null!==o),this}}class iw extends t_{constructor(e,t,n,r,i,o,s,a,l,c){if((c=void 0!==c?c:Gg)!==Gg&&c!==Hg)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===n&&c===Gg&&(n=Pg),void 0===n&&c===Hg&&(n=kg),super(null,r,i,o,s,a,c,n,l),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=void 0!==s?s:gg,this.minFilter=void 0!==a?a:gg,this.flipY=!1,this.generateMipmaps=!1}}class ow extends yy{constructor(e,t){super();const n=this;let r=null,i=1,o=null,s="local-floor",a=null,l=null,c=null,u=null,d=null,h=null;const p=t.getContextAttributes();let m=null,f=null;const g=[],v=[],y=new _b;y.layers.enable(1),y.viewport=new n_;const _=new _b;_.layers.enable(2),_.viewport=new n_;const S=[y,_],b=new ew;b.layers.enable(1),b.layers.enable(2);let x=null,C=null;function w(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",w),r.removeEventListener("selectstart",w),r.removeEventListener("selectend",w),r.removeEventListener("squeeze",w),r.removeEventListener("squeezestart",w),r.removeEventListener("squeezeend",w),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))}x=null,C=null,e.setRenderTarget(m),d=null,u=null,c=null,r=null,f=null,P.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 rw,g[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=g[e];return void 0===t&&(t=new rw,g[e]=t),t.getGripSpace()},this.getHand=function(e){let t=g[e];return void 0===t&&(t=new rw,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){s=e,!0===n.isPresenting&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return a||o},this.setReferenceSpace=function(e){a=e},this.getBaseLayer=function(){return null!==u?u:d},this.getBinding=function(){return c},this.getFrame=function(){return h},this.getSession=function(){return r},this.setSession=async function(l){if(r=l,null!==r){if(m=e.getRenderTarget(),r.addEventListener("select",w),r.addEventListener("selectstart",w),r.addEventListener("selectend",w),r.addEventListener("squeeze",w),r.addEventListener("squeezestart",w),r.addEventListener("squeezeend",w),r.addEventListener("end",A),r.addEventListener("inputsourceschange",E),!0!==p.xrCompatible&&await t.makeXRCompatible(),void 0===r.renderState.layers||!1===e.capabilities.isWebGL2){const n={antialias:void 0!==r.renderState.layers||p.antialias,alpha:p.alpha,depth:p.depth,stencil:p.stencil,framebufferScaleFactor:i};d=new XRWebGLLayer(r,t,n),r.updateRenderState({baseLayer:d}),f=new r_(d.framebufferWidth,d.framebufferHeight,{format:Fg,type:Eg,encoding:e.outputEncoding,stencilBuffer:p.stencil})}else{let n=null,o=null,s=null;p.depth&&(s=p.stencil?35056:33190,n=p.stencil?Hg:Gg,o=p.stencil?kg:Pg);const a={colorFormat:32856,depthFormat:s,scaleFactor:i};c=new XRWebGLBinding(r,t),u=c.createProjectionLayer(a),r.updateRenderState({layers:[u]}),f=new r_(u.textureWidth,u.textureHeight,{format:Fg,type:Eg,depthTexture:new iw(u.textureWidth,u.textureHeight,o,void 0,void 0,void 0,void 0,void 0,void 0,n),stencilBuffer:p.stencil,encoding:e.outputEncoding,samples:p.antialias?4:0});e.properties.get(f).__ignoreDepthValues=u.ignoreDepthValues}f.isXRRenderTarget=!0,this.setFoveation(1),a=null,o=await r.requestReferenceSpace(s),P.setContext(r),P.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}};const I=new u_,T=new u_;function M(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;b.near=_.near=y.near=e.near,b.far=_.far=y.far=e.far,x===b.near&&C===b.far||(r.updateRenderState({depthNear:b.near,depthFar:b.far}),x=b.near,C=b.far);const t=e.parent,n=b.cameras;M(b,t);for(let e=0;e<n.length;e++)M(n[e],t);b.matrixWorld.decompose(b.position,b.quaternion,b.scale),e.matrix.copy(b.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){I.setFromMatrixPosition(t.matrixWorld),T.setFromMatrixPosition(n.matrixWorld);const r=I.distanceTo(T),i=t.projectionMatrix.elements,o=n.projectionMatrix.elements,s=i[14]/(i[10]-1),a=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],h=s*u,p=s*d,m=r/(-u+d),f=m*-u;t.matrixWorld.decompose(e.position,e.quaternion,e.scale),e.translateX(f),e.translateZ(m),e.matrixWorld.compose(e.position,e.quaternion,e.scale),e.matrixWorldInverse.copy(e.matrixWorld).invert();const g=s+m,v=a+m,y=h-f,_=p+(r-f),S=l*a/v*g,b=c*a/v*g;e.projectionMatrix.makePerspective(y,_,S,b,g,v)}(b,y,_):b.projectionMatrix.copy(y.projectionMatrix)},this.getCamera=function(){return b},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 R=null;const P=new Pb;P.setAnimationLoop((function(t,n){if(l=n.getViewerPose(a||o),h=n,null!==l){const t=l.views;null!==d&&(e.setRenderTargetFramebuffer(f,d.framebuffer),e.setRenderTarget(f));let n=!1;t.length!==b.cameras.length&&(b.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(f,t.colorTexture,u.ignoreDepthValues?void 0:t.depthStencilTexture),e.setRenderTarget(f))}let s=S[r];void 0===s&&(s=new _b,s.layers.enable(r),s.viewport=new n_,S[r]=s),s.matrix.fromArray(i.transform.matrix),s.projectionMatrix.fromArray(i.projectionMatrix),s.viewport.set(o.x,o.y,o.width,o.height),0===r&&b.matrix.copy(s.matrix),!0===n&&b.cameras.push(s)}}for(let e=0;e<g.length;e++){const t=v[e],r=g[e];null!==t&&void 0!==r&&r.update(t,n,a||o)}R&&R(t,n),h=null})),this.setAnimationLoop=function(e){R=e},this.dispose=function(){}}}function sw(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===Sf&&(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===Sf&&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,s;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?s=r.aoMap:r.lightMap&&(s=r.lightMap),void 0!==s&&(s.isWebGLRenderTarget&&(s=s.texture),!0===s.matrixAutoUpdate&&s.updateMatrix(),n.uv2Transform.value.copy(s.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,s){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===Sf&&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,s)):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 aw(e,t,n,r){let i={},o={},s=[];const a=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=s.indexOf(n.__bindingPointIndex);s.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 h=i[n.id];void 0===h&&(!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],s=c(o);if(o.__data=new Float32Array(s.storage/Float32Array.BYTES_PER_ELEMENT),o.__offset=n,e>0){i=n%r;0!==i&&r-i-s.boundary<0&&(n+=r-i,o.__offset=n)}n+=s.storage}i=n%r,i>0&&(n+=r-i);e.__size=n,e.__cache={}}(n),h=function(t){const n=function(){for(let e=0;e<a;e++)if(-1===s.indexOf(e))return s.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]=h,n.addEventListener("dispose",u));const p=d.program;r.updateUBOMapping(n,p);const m=t.render.frame;o[n.id]!==m&&(!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]=m)},dispose:function(){for(const t in i)e.deleteBuffer(i[t]);s=[],i={},o={}}}}function lw(e={}){this.isWebGLRenderer=!0;const t=void 0!==e.canvas?e.canvas:function(){const e=zy("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,s=void 0===e.premultipliedAlpha||e.premultipliedAlpha,a=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,h=null;const p=[],m=[];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=Lv,this.physicallyCorrectLights=!1,this.toneMapping=tg,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 f=this;let g=!1,v=0,y=0,_=null,S=-1,b=null;const x=new n_,C=new n_;let w=null,A=t.width,E=t.height,I=1,T=null,M=null;const R=new n_(0,0,A,E),P=new n_(0,0,A,E);let N=!1;const O=new Rb;let D=!1,L=!1,k=null;const B=new j_,z=new Oy,F=new u_,U={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function j(){return null===_?I:1}let G,H,V,W,q,J,K,Y,X,Q,$,Z,ee,te,ne,re,ie,oe,se,ae,le,ce,ue,de,he=n;function pe(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:s,preserveDrawingBuffer:a,powerPreference:l,failIfMajorPerformanceCaveat:c};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${lf}`),t.addEventListener("webglcontextlost",ge,!1),t.addEventListener("webglcontextrestored",ve,!1),t.addEventListener("webglcontextcreationerror",ye,!1),null===he){const t=["webgl2","webgl","experimental-webgl"];if(!0===f.isWebGL1Renderer&&t.shift(),he=pe(t,e),null===he)throw pe(t)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}void 0===he.getShaderPrecisionFormat&&(he.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(e){throw console.error("THREE.WebGLRenderer: "+e.message),e}function me(){G=new ox(he),H=new Ub(he,G,e),G.init(H),ce=new ZC(he,G,H),V=new QC(he,G,H),W=new lx,q=new BC,J=new $C(he,G,V,q,H,ce,W),K=new Gb(f),Y=new ix(f),X=new Nb(he,H),ue=new zb(he,G,X,H),Q=new sx(he,X,W,ue),$=new hx(he,Q,X,W),se=new dx(he,H,J),re=new jb(q),Z=new kC(f,K,Y,G,H,ue,re),ee=new sw(f,q),te=new jC,ne=new JC(G,H),oe=new Bb(f,K,V,$,u,s),ie=new XC(f,$,H),de=new aw(he,W,H,V),ae=new Fb(he,G,W,H),le=new ax(he,G,W,H),W.programs=Z.programs,f.capabilities=H,f.extensions=G,f.properties=q,f.renderLists=te,f.shadowMap=ie,f.state=V,f.info=W}me();const fe=new ow(f,he);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=W.autoReset,t=ie.enabled,n=ie.autoUpdate,r=ie.needsUpdate,i=ie.type;me(),W.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 _e(e){const t=e.target;t.removeEventListener("dispose",_e),function(e){(function(e){const t=q.get(e).programs;void 0!==t&&(t.forEach((function(e){Z.releaseProgram(e)})),e.isShaderMaterial&&Z.releaseShaderCache(e))})(e),q.remove(e)}(t)}this.xr=fe,this.getContext=function(){return he},this.getContextAttributes=function(){return he.getContextAttributes()},this.forceContextLoss=function(){const e=G.get("WEBGL_lose_context");e&&e.loseContext()},this.forceContextRestore=function(){const e=G.get("WEBGL_lose_context");e&&e.restoreContext()},this.getPixelRatio=function(){return I},this.setPixelRatio=function(e){void 0!==e&&(I=e,this.setSize(A,E,!1))},this.getSize=function(e){return e.set(A,E)},this.setSize=function(e,n,r){fe.isPresenting?console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting."):(A=e,E=n,t.width=Math.floor(e*I),t.height=Math.floor(n*I),!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*I,E*I).floor()},this.setDrawingBufferSize=function(e,n,r){A=e,E=n,I=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(x)},this.getViewport=function(e){return e.copy(R)},this.setViewport=function(e,t,n,r){e.isVector4?R.set(e.x,e.y,e.z,e.w):R.set(e,t,n,r),V.viewport(x.copy(R).multiplyScalar(I).floor())},this.getScissor=function(e){return e.copy(P)},this.setScissor=function(e,t,n,r){e.isVector4?P.set(e.x,e.y,e.z,e.w):P.set(e,t,n,r),V.scissor(C.copy(P).multiplyScalar(I).floor())},this.getScissorTest=function(){return N},this.setScissorTest=function(e){V.setScissorTest(N=e)},this.setOpaqueSort=function(e){T=e},this.setTransparentSort=function(e){M=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),he.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(),K.dispose(),Y.dispose(),$.dispose(),ue.dispose(),de.dispose(),Z.dispose(),fe.dispose(),fe.removeEventListener("sessionstart",be),fe.removeEventListener("sessionend",xe),k&&(k.dispose(),k=null),Ce.stop()},this.renderBufferDirect=function(e,t,n,r,i,o){null===t&&(t=U);const s=i.isMesh&&i.matrixWorld.determinant()<0,a=function(e,t,n,r,i){!0!==t.isScene&&(t=U);J.resetTextureUnits();const o=t.fog,s=r.isMeshStandardMaterial?t.environment:null,a=null===_?f.outputEncoding:!0===_.isXRRenderTarget?_.texture.encoding:Lv,l=(r.isMeshStandardMaterial?Y:K).get(r.envMap||s),c=!0===r.vertexColors&&!!n.attributes.color&&4===n.attributes.color.itemSize,u=!!r.normalMap&&!!n.attributes.tangent,d=!!n.morphAttributes.position,p=!!n.morphAttributes.normal,m=!!n.morphAttributes.color,g=r.toneMapped?f.toneMapping:tg,v=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,y=void 0!==v?v.length:0,x=q.get(r),C=h.state.lights;if(!0===D&&(!0===L||e!==b)){const t=e===b&&r.id===S;re.setState(r,e,t)}let w=!1;r.version===x.__version?x.needsLights&&x.lightsStateVersion!==C.state.version||x.outputEncoding!==a||i.isInstancedMesh&&!1===x.instancing?w=!0:i.isInstancedMesh||!0!==x.instancing?i.isSkinnedMesh&&!1===x.skinning?w=!0:i.isSkinnedMesh||!0!==x.skinning?x.envMap!==l||!0===r.fog&&x.fog!==o?w=!0:void 0===x.numClippingPlanes||x.numClippingPlanes===re.numPlanes&&x.numIntersection===re.numIntersection?(x.vertexAlphas!==c||x.vertexTangents!==u||x.morphTargets!==d||x.morphNormals!==p||x.morphColors!==m||x.toneMapping!==g||!0===H.isWebGL2&&x.morphTargetsCount!==y)&&(w=!0):w=!0:w=!0:w=!0:(w=!0,x.__version=r.version);let A=x.currentProgram;!0===w&&(A=Te(r,t,i));let T=!1,M=!1,R=!1;const P=A.getUniforms(),N=x.uniforms;V.useProgram(A.program)&&(T=!0,M=!0,R=!0);r.id!==S&&(S=r.id,M=!0);if(T||b!==e){if(P.setValue(he,"projectionMatrix",e.projectionMatrix),H.logarithmicDepthBuffer&&P.setValue(he,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),b!==e&&(b=e,M=!0,R=!0),r.isShaderMaterial||r.isMeshPhongMaterial||r.isMeshToonMaterial||r.isMeshStandardMaterial||r.envMap){const t=P.map.cameraPosition;void 0!==t&&t.setValue(he,F.setFromMatrixPosition(e.matrixWorld))}(r.isMeshPhongMaterial||r.isMeshToonMaterial||r.isMeshLambertMaterial||r.isMeshBasicMaterial||r.isMeshStandardMaterial||r.isShaderMaterial)&&P.setValue(he,"isOrthographic",!0===e.isOrthographicCamera),(r.isMeshPhongMaterial||r.isMeshToonMaterial||r.isMeshLambertMaterial||r.isMeshBasicMaterial||r.isMeshStandardMaterial||r.isShaderMaterial||r.isShadowMaterial||i.isSkinnedMesh)&&P.setValue(he,"viewMatrix",e.matrixWorldInverse)}if(i.isSkinnedMesh){P.setOptional(he,i,"bindMatrix"),P.setOptional(he,i,"bindMatrixInverse");const e=i.skeleton;e&&(H.floatVertexTextures?(null===e.boneTexture&&e.computeBoneTexture(),P.setValue(he,"boneTexture",e.boneTexture,J),P.setValue(he,"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 O=n.morphAttributes;(void 0!==O.position||void 0!==O.normal||void 0!==O.color&&!0===H.isWebGL2)&&se.update(i,n,r,A);(M||x.receiveShadow!==i.receiveShadow)&&(x.receiveShadow=i.receiveShadow,P.setValue(he,"receiveShadow",i.receiveShadow));r.isMeshGouraudMaterial&&null!==r.envMap&&(N.envMap.value=l,N.flipEnvMap.value=l.isCubeTexture&&!1===l.isRenderTargetTexture?-1:1);M&&(P.setValue(he,"toneMappingExposure",f.toneMappingExposure),x.needsLights&&(z=R,(B=N).ambientLightColor.needsUpdate=z,B.lightProbe.needsUpdate=z,B.directionalLights.needsUpdate=z,B.directionalLightShadows.needsUpdate=z,B.pointLights.needsUpdate=z,B.pointLightShadows.needsUpdate=z,B.spotLights.needsUpdate=z,B.spotLightShadows.needsUpdate=z,B.rectAreaLights.needsUpdate=z,B.hemisphereLights.needsUpdate=z),o&&!0===r.fog&&ee.refreshFogUniforms(N,o),ee.refreshMaterialUniforms(N,r,I,E,k),gC.upload(he,x.uniformsList,N,J));var B,z;r.isShaderMaterial&&!0===r.uniformsNeedUpdate&&(gC.upload(he,x.uniformsList,N,J),r.uniformsNeedUpdate=!1);r.isSpriteMaterial&&P.setValue(he,"center",i.center);if(P.setValue(he,"modelViewMatrix",i.modelViewMatrix),P.setValue(he,"normalMatrix",i.normalMatrix),P.setValue(he,"modelMatrix",i.matrixWorld),r.isShaderMaterial||r.isRawShaderMaterial){const e=r.uniformsGroups;for(let t=0,n=e.length;t<n;t++)if(H.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);V.setMaterial(r,s);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=Q.getWireframeAttribute(n),d=2),ue.setup(i,r,a,n,l);let p=ae;null!==l&&(u=X.get(l),p=le,p.setIndex(u));const m=null!==l?l.count:c.count,g=n.drawRange.start*d,v=n.drawRange.count*d,y=null!==o?o.start*d:0,x=null!==o?o.count*d:1/0,C=Math.max(g,y),w=Math.min(m,g+v,y+x)-1,A=Math.max(0,w-C+1);if(0!==A){if(i.isMesh)!0===r.wireframe?(V.setLineWidth(r.wireframeLinewidth*j()),p.setMode(1)):p.setMode(4);else if(i.isLine){let e=r.linewidth;void 0===e&&(e=1),V.setLineWidth(e*j()),i.isLineSegments?p.setMode(1):i.isLineLoop?p.setMode(2):p.setMode(3)}else i.isPoints?p.setMode(0):i.isSprite&&p.setMode(4);if(i.isInstancedMesh)p.renderInstances(C,A,i.count);else if(n.isInstancedBufferGeometry){const e=Math.min(n.instanceCount,n._maxInstanceCount);p.renderInstances(C,A,e)}else p.render(C,A)}},this.compile=function(e,t){function n(e,t,n){!0===e.transparent&&e.side===bf?(e.side=Sf,e.needsUpdate=!0,Te(e,t,n),e.side=_f,e.needsUpdate=!0,Te(e,t,n),e.side=bf):Te(e,t,n)}h=ne.get(e),h.init(),m.push(h),e.traverseVisible((function(e){e.isLight&&e.layers.test(t.layers)&&(h.pushLight(e),e.castShadow&&h.pushShadow(e))})),h.setupLights(f.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)})),m.pop(),h=null};let Se=null;function be(){Ce.stop()}function xe(){Ce.start()}const Ce=new Pb;function we(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)h.pushLight(e),e.castShadow&&h.pushShadow(e);else if(e.isSprite){if(!e.frustumCulled||O.intersectsSprite(e)){r&&F.setFromMatrixPosition(e.matrixWorld).applyMatrix4(B);const t=$.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!==W.render.frame&&(e.skeleton.update(),e.skeleton.frame=W.render.frame),!e.frustumCulled||O.intersectsObject(e))){r&&F.setFromMatrixPosition(e.matrixWorld).applyMatrix4(B);const t=$.update(e),i=e.material;if(Array.isArray(i)){const r=t.groups;for(let o=0,s=r.length;o<s;o++){const s=r[o],a=i[s.materialIndex];a&&a.visible&&d.push(e,t,a,n,F.z,s)}}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++)we(i[e],t,n,r)}function Ae(e,t,n,r){const i=e.opaque,s=e.transmissive,a=e.transparent;h.setupLightsView(n),s.length>0&&function(e,t,n){const r=H.isWebGL2;null===k&&(k=new r_(1,1,{generateMipmaps:!0,type:G.has("EXT_color_buffer_half_float")?Og:Eg,minFilter:wg,samples:r&&!0===o?4:0}));f.getDrawingBufferSize(z),r?k.setSize(z.x,z.y):k.setSize(My(z.x),My(z.y));const i=f.getRenderTarget();f.setRenderTarget(k),f.clear();const s=f.toneMapping;f.toneMapping=tg,Ee(e,t,n),f.toneMapping=s,J.updateMultisampleRenderTarget(k),J.updateRenderTargetMipmap(k),f.setRenderTarget(i)}(i,t,n),r&&V.viewport(x.copy(r)),i.length>0&&Ee(i,t,n),s.length>0&&Ee(s,t,n),a.length>0&&Ee(a,t,n),V.buffers.depth.setTest(!0),V.buffers.depth.setMask(!0),V.buffers.color.setMask(!0),V.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],s=o.object,a=o.geometry,l=null===r?o.material:r,c=o.group;s.layers.test(n.layers)&&Ie(s,t,n,a,l,c)}}function Ie(e,t,n,r,i,o){e.onBeforeRender(f,t,n,r,i,o),e.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix),i.onBeforeRender(f,t,n,r,e,o),!0===i.transparent&&i.side===bf?(i.side=Sf,i.needsUpdate=!0,f.renderBufferDirect(n,t,r,i,e,o),i.side=_f,i.needsUpdate=!0,f.renderBufferDirect(n,t,r,i,e,o),i.side=bf):f.renderBufferDirect(n,t,r,i,e,o),e.onAfterRender(f,t,n,r,i,o)}function Te(e,t,n){!0!==t.isScene&&(t=U);const r=q.get(e),i=h.state.lights,o=h.state.shadowsArray,s=i.state.version,a=Z.getParameters(e,i.state,o,t,n),l=Z.getProgramCacheKey(a);let c=r.programs;r.environment=e.isMeshStandardMaterial?t.environment:null,r.fog=t.fog,r.envMap=(e.isMeshStandardMaterial?Y:K).get(e.envMap||r.environment),void 0===c&&(e.addEventListener("dispose",_e),c=new Map,r.programs=c);let u=c.get(l);if(void 0!==u){if(r.currentProgram===u&&r.lightsStateVersion===s)return Me(e,a),u}else a.uniforms=Z.getUniforms(e),e.onBuild(n,a,f),e.onBeforeCompile(a,f),u=Z.acquireProgram(a,l),c.set(l,u),r.uniforms=a.uniforms;const d=r.uniforms;(e.isShaderMaterial||e.isRawShaderMaterial)&&!0!==e.clipping||(d.clippingPlanes=re.uniform),Me(e,a),r.needsLights=function(e){return e.isMeshLambertMaterial||e.isMeshToonMaterial||e.isMeshPhongMaterial||e.isMeshStandardMaterial||e.isShadowMaterial||e.isShaderMaterial&&!0===e.lights}(e),r.lightsStateVersion=s,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 p=u.getUniforms(),m=gC.seqWithValue(p.seq,d);return r.currentProgram=u,r.uniformsList=m,u}function Me(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}Ce.setAnimationLoop((function(e){Se&&Se(e)})),"undefined"!=typeof self&&Ce.setContext(self),this.setAnimationLoop=function(e){Se=e,fe.setAnimationLoop(e),null===e?Ce.stop():Ce.start()},fe.addEventListener("sessionstart",be),fe.addEventListener("sessionend",xe),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===fe.enabled&&!0===fe.isPresenting&&(!0===fe.cameraAutoUpdate&&fe.updateCamera(t),t=fe.getCamera()),!0===e.isScene&&e.onBeforeRender(f,e,t,_),h=ne.get(e,m.length),h.init(),m.push(h),B.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),O.setFromProjectionMatrix(B),L=this.localClippingEnabled,D=re.init(this.clippingPlanes,L,t),d=te.get(e,p.length),d.init(),p.push(d),we(e,t,0,f.sortObjects),d.finish(),!0===f.sortObjects&&d.sort(T,M),!0===D&&re.beginShadows();const n=h.state.shadowsArray;if(ie.render(n,e,t),!0===D&&re.endShadows(),!0===this.info.autoReset&&this.info.reset(),oe.render(d,e),h.setupLights(f.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!==_&&(J.updateMultisampleRenderTarget(_),J.updateRenderTargetMipmap(_)),!0===e.isScene&&e.onAfterRender(f,e,t),ue.resetDefaultState(),S=-1,b=null,m.pop(),h=m.length>0?m[m.length-1]:null,p.pop(),d=p.length>0?p[p.length-1]:null},this.getActiveCubeFace=function(){return v},this.getActiveMipmapLevel=function(){return y},this.getRenderTarget=function(){return _},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===G.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){_=e,v=t,y=n;let r=!0;if(e){const t=q.get(e);void 0!==t.__useDefaultFramebuffer?(V.bindFramebuffer(36160,null),r=!1):void 0===t.__webglFramebuffer?J.setupRenderTarget(e):t.__hasExternalTextures&&J.rebindTextures(e,q.get(e.texture).__webglTexture,q.get(e.depthTexture).__webglTexture)}let i=null,o=!1,s=!1;if(e){const n=e.texture;(n.isData3DTexture||n.isDataArrayTexture)&&(s=!0);const r=q.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(i=r[t],o=!0):i=H.isWebGL2&&e.samples>0&&!1===J.useMultisampledRTT(e)?q.get(e).__webglMultisampledFramebuffer:r,x.copy(e.viewport),C.copy(e.scissor),w=e.scissorTest}else x.copy(R).multiplyScalar(I).floor(),C.copy(P).multiplyScalar(I).floor(),w=N;if(V.bindFramebuffer(36160,i)&&H.drawBuffers&&r&&V.drawBuffers(e,i),V.viewport(x),V.scissor(C),V.setScissorTest(w),o){const r=q.get(e.texture);he.framebufferTexture2D(36160,36064,34069+t,r.__webglTexture,n)}else if(s){const r=q.get(e.texture),i=t||0;he.framebufferTextureLayer(36160,36064,r.__webglTexture,n||0,i)}S=-1},this.readRenderTargetPixels=function(e,t,n,r,i,o,s){if(!e||!e.isWebGLRenderTarget)return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let a=q.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==s&&(a=a[s]),a){V.bindFramebuffer(36160,a);try{const s=e.texture,a=s.format,l=s.type;if(a!==Fg&&ce.convert(a)!==he.getParameter(35739))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");const c=l===Og&&(G.has("EXT_color_buffer_half_float")||H.isWebGL2&&G.has("EXT_color_buffer_float"));if(!(l===Eg||ce.convert(l)===he.getParameter(35738)||l===Ng&&(H.isWebGL2||G.has("OES_texture_float")||G.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&&he.readPixels(t,n,r,i,ce.convert(a),ce.convert(l),o)}finally{const e=null!==_?q.get(_).__webglFramebuffer:null;V.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);J.setTexture2D(t,0),he.copyTexSubImage2D(3553,n,0,0,e.x,e.y,i,o),V.unbindTexture()},this.copyTextureToTexture=function(e,t,n,r=0){const i=t.image.width,o=t.image.height,s=ce.convert(n.format),a=ce.convert(n.type);J.setTexture2D(n,0),he.pixelStorei(37440,n.flipY),he.pixelStorei(37441,n.premultiplyAlpha),he.pixelStorei(3317,n.unpackAlignment),t.isDataTexture?he.texSubImage2D(3553,r,e.x,e.y,i,o,s,a,t.image.data):t.isCompressedTexture?he.compressedTexSubImage2D(3553,r,e.x,e.y,t.mipmaps[0].width,t.mipmaps[0].height,s,t.mipmaps[0].data):he.texSubImage2D(3553,r,e.x,e.y,s,a,t.image),0===r&&n.generateMipmaps&&he.generateMipmap(3553),V.unbindTexture()},this.copyTextureToTexture3D=function(e,t,n,r,i=0){if(f.isWebGL1Renderer)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");const o=e.max.x-e.min.x+1,s=e.max.y-e.min.y+1,a=e.max.z-e.min.z+1,l=ce.convert(r.format),c=ce.convert(r.type);let u;if(r.isData3DTexture)J.setTexture3D(r,0),u=32879;else{if(!r.isDataArrayTexture)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");J.setTexture2DArray(r,0),u=35866}he.pixelStorei(37440,r.flipY),he.pixelStorei(37441,r.premultiplyAlpha),he.pixelStorei(3317,r.unpackAlignment);const d=he.getParameter(3314),h=he.getParameter(32878),p=he.getParameter(3316),m=he.getParameter(3315),g=he.getParameter(32877),v=n.isCompressedTexture?n.mipmaps[0]:n.image;he.pixelStorei(3314,v.width),he.pixelStorei(32878,v.height),he.pixelStorei(3316,e.min.x),he.pixelStorei(3315,e.min.y),he.pixelStorei(32877,e.min.z),n.isDataTexture||n.isData3DTexture?he.texSubImage3D(u,i,t.x,t.y,t.z,o,s,a,l,c,v.data):n.isCompressedTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),he.compressedTexSubImage3D(u,i,t.x,t.y,t.z,o,s,a,l,v.data)):he.texSubImage3D(u,i,t.x,t.y,t.z,o,s,a,l,c,v),he.pixelStorei(3314,d),he.pixelStorei(32878,h),he.pixelStorei(3316,p),he.pixelStorei(3315,m),he.pixelStorei(32877,g),0===i&&r.generateMipmaps&&he.generateMipmap(u),V.unbindTexture()},this.initTexture=function(e){e.isCubeTexture?J.setTextureCube(e,0):e.isData3DTexture?J.setTexture3D(e,0):e.isDataArrayTexture?J.setTexture2DArray(e,0):J.setTexture2D(e,0),V.unbindTexture()},this.resetState=function(){v=0,y=0,_=null,V.reset(),ue.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}class cw extends lw{}cw.prototype.isWebGL1Renderer=!0;class uw{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new Yy(e),this.density=t}clone(){return new uw(this.color,this.density)}toJSON(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}}class dw{constructor(e,t=1,n=1e3){this.isFog=!0,this.name="",this.color=new Yy(e),this.near=t,this.far=n}clone(){return new dw(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}}class hw extends hS{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 pw{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=void 0!==e?e.length/t:0,this.usage=sy,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=Cy()}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=Cy()),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=Cy()),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 mw=new u_;class fw{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++)mw.fromBufferAttribute(this,t),mw.applyMatrix4(e),this.setXYZ(t,mw.x,mw.y,mw.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)mw.fromBufferAttribute(this,t),mw.applyNormalMatrix(e),this.setXYZ(t,mw.x,mw.y,mw.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)mw.fromBufferAttribute(this,t),mw.transformDirection(e),this.setXYZ(t,mw.x,mw.y,mw.z);return this}setX(e,t){return this.normalized&&(t=Py(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=Py(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=Py(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=Py(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=Ry(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=Ry(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=Ry(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=Ry(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=Py(t,this.array),n=Py(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=Py(t,this.array),n=Py(n,this.array),r=Py(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=Py(t,this.array),n=Py(n,this.array),r=Py(r,this.array),i=Py(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 MS(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 fw(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 gw extends AS{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new Yy(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 vw;const yw=new u_,_w=new u_,Sw=new u_,bw=new Oy,xw=new Oy,Cw=new j_,ww=new u_,Aw=new u_,Ew=new u_,Iw=new Oy,Tw=new Oy,Mw=new Oy;class Rw extends hS{constructor(e){if(super(),this.isSprite=!0,this.type="Sprite",void 0===vw){vw=new JS;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 pw(e,5);vw.setIndex([0,1,2,0,2,3]),vw.setAttribute("position",new fw(t,3,0,!1)),vw.setAttribute("uv",new fw(t,2,3,!1))}this.geometry=vw,this.material=void 0!==e?e:new gw,this.center=new Oy(.5,.5)}raycast(e,t){null===e.camera&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),_w.setFromMatrixScale(this.matrixWorld),Cw.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Sw.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&!1===this.material.sizeAttenuation&&_w.multiplyScalar(-Sw.z);const n=this.material.rotation;let r,i;0!==n&&(i=Math.cos(n),r=Math.sin(n));const o=this.center;Pw(ww.set(-.5,-.5,0),Sw,o,_w,r,i),Pw(Aw.set(.5,-.5,0),Sw,o,_w,r,i),Pw(Ew.set(.5,.5,0),Sw,o,_w,r,i),Iw.set(0,0),Tw.set(1,0),Mw.set(1,1);let s=e.ray.intersectTriangle(ww,Aw,Ew,!1,yw);if(null===s&&(Pw(Aw.set(-.5,.5,0),Sw,o,_w,r,i),Tw.set(0,1),s=e.ray.intersectTriangle(ww,Ew,Aw,!1,yw),null===s))return;const a=e.ray.origin.distanceTo(yw);a<e.near||a>e.far||t.push({distance:a,point:yw.clone(),uv:CS.getUV(yw,ww,Aw,Ew,Iw,Tw,Mw,new Oy),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 Pw(e,t,n,r,i,o){bw.subVectors(e,n).addScalar(.5).multiply(r),void 0!==i?(xw.x=o*bw.x-i*bw.y,xw.y=i*bw.x+o*bw.y):xw.copy(bw),e.copy(t),e.x+=xw.x,e.y+=xw.y,e.applyMatrix4(Cw)}const Nw=new u_,Ow=new u_;class Dw extends hS{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){Nw.setFromMatrixPosition(this.matrixWorld);const n=e.ray.origin.distanceTo(Nw);this.getObjectForDistance(n).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){Nw.setFromMatrixPosition(e.matrixWorld),Ow.setFromMatrixPosition(this.matrixWorld);const n=Nw.distanceTo(Ow)/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 Lw=new u_,kw=new n_,Bw=new n_,zw=new u_,Fw=new j_;class Uw extends db{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new j_,this.bindMatrixInverse=new j_}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 n_,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;kw.fromBufferAttribute(r.attributes.skinIndex,e),Bw.fromBufferAttribute(r.attributes.skinWeight,e),Lw.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let e=0;e<4;e++){const r=Bw.getComponent(e);if(0!==r){const i=kw.getComponent(e);Fw.multiplyMatrices(n.bones[i].matrixWorld,n.boneInverses[i]),t.addScaledVector(zw.copy(Lw).applyMatrix4(Fw),r)}}return t.applyMatrix4(this.bindMatrixInverse)}}class jw extends hS{constructor(){super(),this.isBone=!0,this.type="Bone"}}class Gw extends t_{constructor(e=null,t=1,n=1,r,i,o,s,a,l=gg,c=gg,u,d){super(null,o,s,a,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 Hw=new j_,Vw=new j_;class Ww{constructor(e=[],t=[]){this.uuid=Cy(),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 j_)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const t=new j_;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:Vw;Hw.multiplyMatrices(i,t[r]),Hw.toArray(n,16*r)}null!==r&&(r.needsUpdate=!0)}clone(){return new Ww(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(4*this.bones.length);e=Ty(e),e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const n=new Gw(t,e,e,Fg,Ng);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 jw),this.bones.push(i),this.boneInverses.push((new j_).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 qw extends MS{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 Jw=new j_,Kw=new j_,Yw=[],Xw=new db;class Qw extends db{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new qw(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(Xw.geometry=this.geometry,Xw.material=this.material,void 0!==Xw.material)for(let i=0;i<r;i++){this.getMatrixAt(i,Jw),Kw.multiplyMatrices(n,Jw),Xw.matrixWorld=Kw,Xw.raycast(e,Yw);for(let e=0,n=Yw.length;e<n;e++){const n=Yw[e];n.instanceId=i,n.object=this,t.push(n)}Yw.length=0}}setColorAt(e,t){null===this.instanceColor&&(this.instanceColor=new qw(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 $w extends AS{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Yy(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 Zw=new u_,eA=new u_,tA=new j_,nA=new U_,rA=new N_;class iA extends hS{constructor(e=new JS,t=new $w){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++)Zw.fromBufferAttribute(t,e-1),eA.fromBufferAttribute(t,e),n[e]=n[e-1],n[e]+=Zw.distanceTo(eA);e.setAttribute("lineDistance",new zS(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(),rA.copy(n.boundingSphere),rA.applyMatrix4(r),rA.radius+=i,!1===e.ray.intersectsSphere(rA))return;tA.copy(r).invert(),nA.copy(e.ray).applyMatrix4(tA);const s=i/((this.scale.x+this.scale.y+this.scale.z)/3),a=s*s,l=new u_,c=new u_,u=new u_,d=new u_,h=this.isLineSegments?2:1,p=n.index,m=n.attributes.position;if(null!==p){for(let n=Math.max(0,o.start),r=Math.min(p.count,o.start+o.count)-1;n<r;n+=h){const r=p.getX(n),i=p.getX(n+1);l.fromBufferAttribute(m,r),c.fromBufferAttribute(m,i);if(nA.distanceSqToSegment(l,c,d,u)>a)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(m.count,o.start+o.count)-1;n<r;n+=h){l.fromBufferAttribute(m,n),c.fromBufferAttribute(m,n+1);if(nA.distanceSqToSegment(l,c,d,u)>a)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 oA=new u_,sA=new u_;class aA extends iA{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)oA.fromBufferAttribute(t,e),sA.fromBufferAttribute(t,e+1),n[e]=0===e?0:n[e-1],n[e+1]=n[e]+oA.distanceTo(sA);e.setAttribute("lineDistance",new zS(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class lA extends iA{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class cA extends AS{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Yy(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 uA=new j_,dA=new U_,hA=new N_,pA=new u_;class mA extends hS{constructor(e=new JS,t=new cA){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(),hA.copy(n.boundingSphere),hA.applyMatrix4(r),hA.radius+=i,!1===e.ray.intersectsSphere(hA))return;uA.copy(r).invert(),dA.copy(e.ray).applyMatrix4(uA);const s=i/((this.scale.x+this.scale.y+this.scale.z)/3),a=s*s,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);pA.fromBufferAttribute(c,i),fA(pA,i,a,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++)pA.fromBufferAttribute(c,n),fA(pA,n,a,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 fA(e,t,n,r,i,o,s){const a=dA.distanceSqToPoint(e);if(a<n){const n=new u_;dA.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(a),point:n,index:t,face:null,object:s})}}class gA extends t_{constructor(e,t,n,r,i,o,s,a,l){super(e,t,n,r,i,o,s,a,l),this.isVideoTexture=!0,this.minFilter=void 0!==o?o:bg,this.magFilter=void 0!==i?i:bg,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 vA extends t_{constructor(e,t,n){super({width:e,height:t}),this.isFramebufferTexture=!0,this.format=n,this.magFilter=gg,this.minFilter=gg,this.generateMipmaps=!1,this.needsUpdate=!0}}class yA extends t_{constructor(e,t,n,r,i,o,s,a,l,c,u,d){super(null,o,s,a,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 _A extends t_{constructor(e,t,n,r,i,o,s,a,l){super(e,t,n,r,i,o,s,a,l),this.isCanvasTexture=!0,this.needsUpdate=!0}}class SA{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 s,a=0,l=i-1;for(;a<=l;)if(r=Math.floor(a+(l-a)/2),s=n[r]-o,s<0)a=r+1;else{if(!(s>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),s=this.getPoint(i),a=t||(o.isVector2?new Oy:new u_);return a.copy(s).sub(o).normalize(),a}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t){const n=new u_,r=[],i=[],o=[],s=new u_,a=new j_;for(let t=0;t<=e;t++){const n=t/e;r[t]=this.getTangentAt(n,new u_)}i[0]=new u_,o[0]=new u_;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),s.crossVectors(r[0],n).normalize(),i[0].crossVectors(r[0],s),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(),s.crossVectors(r[t-1],r[t]),s.length()>Number.EPSILON){s.normalize();const e=Math.acos(wy(r[t-1].dot(r[t]),-1,1));i[t].applyMatrix4(a.makeRotationAxis(s,e))}o[t].crossVectors(r[t],i[t])}if(!0===t){let t=Math.acos(wy(i[0].dot(i[e]),-1,1));t/=e,r[0].dot(s.crossVectors(i[0],i[e]))>0&&(t=-t);for(let n=1;n<=e;n++)i[n].applyMatrix4(a.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 bA extends SA{constructor(e=0,t=0,n=1,r=1,i=0,o=2*Math.PI,s=!1,a=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=s,this.aRotation=a}getPoint(e,t){const n=t||new Oy,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 s=this.aStartAngle+e*i;let a=this.aX+this.xRadius*Math.cos(s),l=this.aY+this.yRadius*Math.sin(s);if(0!==this.aRotation){const e=Math.cos(this.aRotation),t=Math.sin(this.aRotation),n=a-this.aX,r=l-this.aY;a=n*e-r*t+this.aX,l=n*t+r*e+this.aY}return n.set(a,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 xA extends bA{constructor(e,t,n,r,i,o){super(e,t,n,n,r,i,o),this.isArcCurve=!0,this.type="ArcCurve"}}function CA(){let e=0,t=0,n=0,r=0;function i(i,o,s,a){e=i,t=s,n=-3*i+3*o-2*s-a,r=2*i-2*o+s+a}return{initCatmullRom:function(e,t,n,r,o){i(t,n,o*(n-e),o*(r-t))},initNonuniformCatmullRom:function(e,t,n,r,o,s,a){let l=(t-e)/o-(n-e)/(o+s)+(n-t)/s,c=(n-t)/s-(r-t)/(s+a)+(r-n)/a;l*=s,c*=s,i(t,n,l,c)},calc:function(i){const o=i*i;return e+t*i+n*o+r*(o*i)}}}const wA=new u_,AA=new CA,EA=new CA,IA=new CA;class TA extends SA{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 u_){const n=t,r=this.points,i=r.length,o=(i-(this.closed?0:1))*e;let s,a,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?s=r[(l-1)%i]:(wA.subVectors(r[0],r[1]).add(r[0]),s=wA);const u=r[l%i],d=r[(l+1)%i];if(this.closed||l+2<i?a=r[(l+2)%i]:(wA.subVectors(r[i-1],r[i-2]).add(r[i-1]),a=wA),"centripetal"===this.curveType||"chordal"===this.curveType){const e="chordal"===this.curveType?.5:.25;let t=Math.pow(s.distanceToSquared(u),e),n=Math.pow(u.distanceToSquared(d),e),r=Math.pow(d.distanceToSquared(a),e);n<1e-4&&(n=1),t<1e-4&&(t=n),r<1e-4&&(r=n),AA.initNonuniformCatmullRom(s.x,u.x,d.x,a.x,t,n,r),EA.initNonuniformCatmullRom(s.y,u.y,d.y,a.y,t,n,r),IA.initNonuniformCatmullRom(s.z,u.z,d.z,a.z,t,n,r)}else"catmullrom"===this.curveType&&(AA.initCatmullRom(s.x,u.x,d.x,a.x,this.tension),EA.initCatmullRom(s.y,u.y,d.y,a.y,this.tension),IA.initCatmullRom(s.z,u.z,d.z,a.z,this.tension));return n.set(AA.calc(c),EA.calc(c),IA.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 u_).fromArray(n))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}}function MA(e,t,n,r,i){const o=.5*(r-t),s=.5*(i-n),a=e*e;return(2*n-2*r+o+s)*(e*a)+(-3*n+3*r-2*o-s)*a+o*e+n}function RA(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 PA(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 NA extends SA{constructor(e=new Oy,t=new Oy,n=new Oy,r=new Oy){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=n,this.v3=r}getPoint(e,t=new Oy){const n=t,r=this.v0,i=this.v1,o=this.v2,s=this.v3;return n.set(PA(e,r.x,i.x,o.x,s.x),PA(e,r.y,i.y,o.y,s.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 OA extends SA{constructor(e=new u_,t=new u_,n=new u_,r=new u_){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=n,this.v3=r}getPoint(e,t=new u_){const n=t,r=this.v0,i=this.v1,o=this.v2,s=this.v3;return n.set(PA(e,r.x,i.x,o.x,s.x),PA(e,r.y,i.y,o.y,s.y),PA(e,r.z,i.z,o.z,s.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 DA extends SA{constructor(e=new Oy,t=new Oy){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new Oy){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 Oy;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 LA extends SA{constructor(e=new u_,t=new u_){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new u_){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 kA extends SA{constructor(e=new Oy,t=new Oy,n=new Oy){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new Oy){const n=t,r=this.v0,i=this.v1,o=this.v2;return n.set(RA(e,r.x,i.x,o.x),RA(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 BA extends SA{constructor(e=new u_,t=new u_,n=new u_){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new u_){const n=t,r=this.v0,i=this.v1,o=this.v2;return n.set(RA(e,r.x,i.x,o.x),RA(e,r.y,i.y,o.y),RA(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 zA extends SA{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new Oy){const n=t,r=this.points,i=(r.length-1)*e,o=Math.floor(i),s=i-o,a=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(MA(s,a.x,l.x,c.x,u.x),MA(s,a.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 Oy).fromArray(n))}return this}}var FA=Object.freeze({__proto__:null,ArcCurve:xA,CatmullRomCurve3:TA,CubicBezierCurve:NA,CubicBezierCurve3:OA,EllipseCurve:bA,LineCurve:DA,LineCurve3:LA,QuadraticBezierCurve:kA,QuadraticBezierCurve3:BA,SplineCurve:zA});class UA extends SA{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 DA(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],s=o.getLength(),a=0===s?0:1-e/s;return o.getPointAt(a,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],s=o.isEllipseCurve?2*e:o.isLineCurve||o.isLineCurve3?1:o.isSplineCurve?e*o.points.length:e,a=o.getPoints(s);for(let e=0;e<a.length;e++){const r=a[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 FA[n.type]).fromJSON(n))}return this}}class jA extends UA{constructor(e){super(),this.type="Path",this.currentPoint=new Oy,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 DA(this.currentPoint.clone(),new Oy(e,t));return this.curves.push(n),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,n,r){const i=new kA(this.currentPoint.clone(),new Oy(e,t),new Oy(n,r));return this.curves.push(i),this.currentPoint.set(n,r),this}bezierCurveTo(e,t,n,r,i,o){const s=new NA(this.currentPoint.clone(),new Oy(e,t),new Oy(n,r),new Oy(i,o));return this.curves.push(s),this.currentPoint.set(i,o),this}splineThru(e){const t=[this.currentPoint.clone()].concat(e),n=new zA(t);return this.curves.push(n),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,n,r,i,o){const s=this.currentPoint.x,a=this.currentPoint.y;return this.absarc(e+s,t+a,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,s,a){const l=this.currentPoint.x,c=this.currentPoint.y;return this.absellipse(e+l,t+c,n,r,i,o,s,a),this}absellipse(e,t,n,r,i,o,s,a){const l=new bA(e,t,n,r,i,o,s,a);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 GA extends JS{constructor(e=[new Oy(0,-.5),new Oy(.5,0),new Oy(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=wy(r,0,2*Math.PI);const i=[],o=[],s=[],a=[],l=[],c=1/t,u=new u_,d=new Oy,h=new u_,p=new u_,m=new u_;let f=0,g=0;for(let t=0;t<=e.length-1;t++)switch(t){case 0:f=e[t+1].x-e[t].x,g=e[t+1].y-e[t].y,h.x=1*g,h.y=-f,h.z=0*g,m.copy(h),h.normalize(),a.push(h.x,h.y,h.z);break;case e.length-1:a.push(m.x,m.y,m.z);break;default:f=e[t+1].x-e[t].x,g=e[t+1].y-e[t].y,h.x=1*g,h.y=-f,h.z=0*g,p.copy(h),h.x+=m.x,h.y+=m.y,h.z+=m.z,h.normalize(),a.push(h.x,h.y,h.z),m.copy(p)}for(let i=0;i<=t;i++){const h=n+i*c*r,p=Math.sin(h),m=Math.cos(h);for(let n=0;n<=e.length-1;n++){u.x=e[n].x*p,u.y=e[n].y,u.z=e[n].x*m,o.push(u.x,u.y,u.z),d.x=i/t,d.y=n/(e.length-1),s.push(d.x,d.y);const r=a[3*n+0]*p,c=a[3*n+1],h=a[3*n+0]*m;l.push(r,c,h)}}for(let n=0;n<t;n++)for(let t=0;t<e.length-1;t++){const r=t+n*e.length,o=r,s=r+e.length,a=r+e.length+1,l=r+1;i.push(o,s,l),i.push(a,l,s)}this.setIndex(i),this.setAttribute("position",new zS(o,3)),this.setAttribute("uv",new zS(s,2)),this.setAttribute("normal",new zS(l,3))}static fromJSON(e){return new GA(e.points,e.segments,e.phiStart,e.phiLength)}}class HA extends GA{constructor(e=1,t=1,n=4,r=8){const i=new jA;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 HA(e.radius,e.length,e.capSegments,e.radialSegments)}}class VA extends JS{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=[],s=[],a=[],l=new u_,c=new Oy;o.push(0,0,0),s.push(0,0,1),a.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),s.push(0,0,1),c.x=(o[u]/e+1)/2,c.y=(o[u+1]/e+1)/2,a.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 zS(o,3)),this.setAttribute("normal",new zS(s,3)),this.setAttribute("uv",new zS(a,2))}static fromJSON(e){return new VA(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class WA extends JS{constructor(e=1,t=1,n=1,r=8,i=1,o=!1,s=0,a=2*Math.PI){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:r,heightSegments:i,openEnded:o,thetaStart:s,thetaLength:a};const l=this;r=Math.floor(r),i=Math.floor(i);const c=[],u=[],d=[],h=[];let p=0;const m=[],f=n/2;let g=0;function v(n){const i=p,o=new Oy,m=new u_;let v=0;const y=!0===n?e:t,_=!0===n?1:-1;for(let e=1;e<=r;e++)u.push(0,f*_,0),d.push(0,_,0),h.push(.5,.5),p++;const S=p;for(let e=0;e<=r;e++){const t=e/r*a+s,n=Math.cos(t),i=Math.sin(t);m.x=y*i,m.y=f*_,m.z=y*n,u.push(m.x,m.y,m.z),d.push(0,_,0),o.x=.5*n+.5,o.y=.5*i*_+.5,h.push(o.x,o.y),p++}for(let e=0;e<r;e++){const t=i+e,r=S+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 u_,v=new u_;let y=0;const _=(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*a+s,l=Math.sin(i),m=Math.cos(i);v.x=y*l,v.y=-g*n+f,v.z=y*m,u.push(v.x,v.y,v.z),o.set(l,_,m).normalize(),d.push(o.x,o.y,o.z),h.push(t,1-g),c.push(p++)}m.push(c)}for(let e=0;e<r;e++)for(let t=0;t<i;t++){const n=m[t][e],r=m[t+1][e],i=m[t+1][e+1],o=m[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 zS(u,3)),this.setAttribute("normal",new zS(d,3)),this.setAttribute("uv",new zS(h,2))}static fromJSON(e){return new WA(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class qA extends WA{constructor(e=1,t=1,n=8,r=1,i=!1,o=0,s=2*Math.PI){super(0,e,t,n,r,i,o,s),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:r,openEnded:i,thetaStart:o,thetaLength:s}}static fromJSON(e){return new qA(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class JA extends JS{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 s(e,t,n,r){const i=r+1,o=[];for(let r=0;r<=i;r++){o[r]=[];const s=e.clone().lerp(n,r/i),a=t.clone().lerp(n,r/i),l=i-r;for(let e=0;e<=l;e++)o[r][e]=0===e&&r===i?s:s.clone().lerp(a,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?(a(o[e][n+1]),a(o[e+1][n]),a(o[e][n])):(a(o[e][n+1]),a(o[e+1][n+1]),a(o[e+1][n]))}}function a(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 u_,r=new u_,i=new u_;for(let o=0;o<t.length;o+=3)l(t[o+0],n),l(t[o+1],r),l(t[o+2],i),s(n,r,i,e)}(r),function(e){const t=new u_;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 u_;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,s=(t=e,Math.atan2(-t.y,Math.sqrt(t.x*t.x+t.z*t.z))/Math.PI+.5);o.push(r,1-s)}var t;(function(){const e=new u_,t=new u_,n=new u_,r=new u_,s=new Oy,a=new Oy,l=new Oy;for(let d=0,h=0;d<i.length;d+=9,h+=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]),s.set(o[h+0],o[h+1]),a.set(o[h+2],o[h+3]),l.set(o[h+4],o[h+5]),r.copy(e).add(t).add(n).divideScalar(3);const p=u(r);c(s,h+0,e,p),c(a,h+2,t,p),c(l,h+4,n,p)}})(),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),s=Math.min(t,n,r);i>.9&&s<.1&&(t<.2&&(o[e+0]+=1),n<.2&&(o[e+2]+=1),r<.2&&(o[e+4]+=1))}}()}(),this.setAttribute("position",new zS(i,3)),this.setAttribute("normal",new zS(i.slice(),3)),this.setAttribute("uv",new zS(o,2)),0===r?this.computeVertexNormals():this.normalizeNormals()}static fromJSON(e){return new JA(e.vertices,e.indices,e.radius,e.details)}}class KA extends JA{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 KA(e.radius,e.detail)}}const YA=new u_,XA=new u_,QA=new u_,$A=new CS;class ZA extends JS{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(by*t),o=e.getIndex(),s=e.getAttribute("position"),a=o?o.count:s.count,l=[0,0,0],c=["a","b","c"],u=new Array(3),d={},h=[];for(let e=0;e<a;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:a}=$A;if(t.fromBufferAttribute(s,l[0]),n.fromBufferAttribute(s,l[1]),a.fromBufferAttribute(s,l[2]),$A.getNormal(QA),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(a.x*r)},${Math.round(a.y*r)},${Math.round(a.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=$A[c[e]],s=$A[c[t]],a=`${n}_${r}`,p=`${r}_${n}`;p in d&&d[p]?(QA.dot(d[p].normal)<=i&&(h.push(o.x,o.y,o.z),h.push(s.x,s.y,s.z)),d[p]=null):a in d||(d[a]={index0:l[e],index1:l[t],normal:QA.clone()})}}for(const e in d)if(d[e]){const{index0:t,index1:n}=d[e];YA.fromBufferAttribute(s,t),XA.fromBufferAttribute(s,n),h.push(YA.x,YA.y,YA.z),h.push(XA.x,XA.y,XA.z)}this.setAttribute("position",new zS(h,3))}}}class eE extends jA{constructor(e){super(e),this.uuid=Cy(),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 jA).fromJSON(n))}return this}}const tE=function(e,t,n=2){const r=t&&t.length,i=r?t[0]*n:e.length;let o=nE(e,0,i,n,!0);const s=[];if(!o||o.next===o.prev)return s;let a,l,c,u,d,h,p;if(r&&(o=function(e,t,n,r){const i=[];let o,s,a,l,c;for(o=0,s=t.length;o<s;o++)a=t[o]*r,l=o<s-1?t[o+1]*r:e.length,c=nE(e,a,l,r,!1),c===c.next&&(c.steiner=!0),i.push(pE(c));for(i.sort(cE),o=0;o<i.length;o++)uE(i[o],n),n=rE(n,n.next);return n}(e,t,o,n)),e.length>80*n){a=c=e[0],l=u=e[1];for(let t=n;t<i;t+=n)d=e[t],h=e[t+1],d<a&&(a=d),h<l&&(l=h),d>c&&(c=d),h>u&&(u=h);p=Math.max(c-a,u-l),p=0!==p?1/p:0}return iE(o,s,n,a,l,p),s};function nE(e,t,n,r,i){let o,s;if(i===function(e,t,n,r){let i=0;for(let o=t,s=n-r;o<n;o+=r)i+=(e[s]-e[o])*(e[o+1]+e[s+1]),s=o;return i}(e,t,n,r)>0)for(o=t;o<n;o+=r)s=CE(o,e[o],e[o+1],s);else for(o=n-r;o>=t;o-=r)s=CE(o,e[o],e[o+1],s);return s&&vE(s,s.next)&&(wE(s),s=s.next),s}function rE(e,t){if(!e)return e;t||(t=e);let n,r=e;do{if(n=!1,r.steiner||!vE(r,r.next)&&0!==gE(r.prev,r,r.next))r=r.next;else{if(wE(r),r=t=r.prev,r===r.next)break;n=!0}}while(n||r!==t);return t}function iE(e,t,n,r,i,o,s){if(!e)return;!s&&o&&function(e,t,n,r){let i=e;do{null===i.z&&(i.z=hE(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,s,a,l,c=1;do{for(n=e,e=null,o=null,s=0;n;){for(s++,r=n,a=0,t=0;t<c&&(a++,r=r.nextZ,r);t++);for(l=c;a>0||l>0&&r;)0!==a&&(0===l||!r||n.z<=r.z)?(i=n,n=n.nextZ,a--):(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(s>1)}(i)}(e,r,i,o);let a,l,c=e;for(;e.prev!==e.next;)if(a=e.prev,l=e.next,o?sE(e,r,i,o):oE(e))t.push(a.i/n),t.push(e.i/n),t.push(l.i/n),wE(e),e=l.next,c=l.next;else if((e=l)===c){s?1===s?iE(e=aE(rE(e),t,n),t,n,r,i,o,2):2===s&&lE(e,t,n,r,i,o):iE(rE(e),t,n,r,i,o,1);break}}function oE(e){const t=e.prev,n=e,r=e.next;if(gE(t,n,r)>=0)return!1;let i=e.next.next;for(;i!==e.prev;){if(mE(t.x,t.y,n.x,n.y,r.x,r.y,i.x,i.y)&&gE(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function sE(e,t,n,r){const i=e.prev,o=e,s=e.next;if(gE(i,o,s)>=0)return!1;const a=i.x<o.x?i.x<s.x?i.x:s.x:o.x<s.x?o.x:s.x,l=i.y<o.y?i.y<s.y?i.y:s.y:o.y<s.y?o.y:s.y,c=i.x>o.x?i.x>s.x?i.x:s.x:o.x>s.x?o.x:s.x,u=i.y>o.y?i.y>s.y?i.y:s.y:o.y>s.y?o.y:s.y,d=hE(a,l,t,n,r),h=hE(c,u,t,n,r);let p=e.prevZ,m=e.nextZ;for(;p&&p.z>=d&&m&&m.z<=h;){if(p!==e.prev&&p!==e.next&&mE(i.x,i.y,o.x,o.y,s.x,s.y,p.x,p.y)&&gE(p.prev,p,p.next)>=0)return!1;if(p=p.prevZ,m!==e.prev&&m!==e.next&&mE(i.x,i.y,o.x,o.y,s.x,s.y,m.x,m.y)&&gE(m.prev,m,m.next)>=0)return!1;m=m.nextZ}for(;p&&p.z>=d;){if(p!==e.prev&&p!==e.next&&mE(i.x,i.y,o.x,o.y,s.x,s.y,p.x,p.y)&&gE(p.prev,p,p.next)>=0)return!1;p=p.prevZ}for(;m&&m.z<=h;){if(m!==e.prev&&m!==e.next&&mE(i.x,i.y,o.x,o.y,s.x,s.y,m.x,m.y)&&gE(m.prev,m,m.next)>=0)return!1;m=m.nextZ}return!0}function aE(e,t,n){let r=e;do{const i=r.prev,o=r.next.next;!vE(i,o)&&yE(i,r,r.next,o)&&bE(i,o)&&bE(o,i)&&(t.push(i.i/n),t.push(r.i/n),t.push(o.i/n),wE(r),wE(r.next),r=e=o),r=r.next}while(r!==e);return rE(r)}function lE(e,t,n,r,i,o){let s=e;do{let e=s.next.next;for(;e!==s.prev;){if(s.i!==e.i&&fE(s,e)){let a=xE(s,e);return s=rE(s,s.next),a=rE(a,a.next),iE(s,t,n,r,i,o),void iE(a,t,n,r,i,o)}e=e.next}s=s.next}while(s!==e)}function cE(e,t){return e.x-t.x}function uE(e,t){if(t=function(e,t){let n=t;const r=e.x,i=e.y;let o,s=-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>s){if(s=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===s)return o;const a=o,l=o.x,c=o.y;let u,d=1/0;n=o;do{r>=n.x&&n.x>=l&&r!==n.x&&mE(i<c?r:s,i,l,c,i<c?s:r,i,n.x,n.y)&&(u=Math.abs(i-n.y)/(r-n.x),bE(n,e)&&(u<d||u===d&&(n.x>o.x||n.x===o.x&&dE(o,n)))&&(o=n,d=u)),n=n.next}while(n!==a);return o}(e,t),t){const n=xE(t,e);rE(t,t.next),rE(n,n.next)}}function dE(e,t){return gE(e.prev,e,t.prev)<0&&gE(t.next,e,e.next)<0}function hE(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 pE(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 mE(e,t,n,r,i,o,s,a){return(i-s)*(t-a)-(e-s)*(o-a)>=0&&(e-s)*(r-a)-(n-s)*(t-a)>=0&&(n-s)*(o-a)-(i-s)*(r-a)>=0}function fE(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&&yE(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}(e,t)&&(bE(e,t)&&bE(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)&&(gE(e.prev,e,t.prev)||gE(e,t.prev,t))||vE(e,t)&&gE(e.prev,e,e.next)>0&&gE(t.prev,t,t.next)>0)}function gE(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function vE(e,t){return e.x===t.x&&e.y===t.y}function yE(e,t,n,r){const i=SE(gE(e,t,n)),o=SE(gE(e,t,r)),s=SE(gE(n,r,e)),a=SE(gE(n,r,t));return i!==o&&s!==a||(!(0!==i||!_E(e,n,t))||(!(0!==o||!_E(e,r,t))||(!(0!==s||!_E(n,e,r))||!(0!==a||!_E(n,t,r)))))}function _E(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 SE(e){return e>0?1:e<0?-1:0}function bE(e,t){return gE(e.prev,e,e.next)<0?gE(e,t,e.next)>=0&&gE(e,e.prev,t)>=0:gE(e,t,e.prev)<0||gE(e,e.next,t)<0}function xE(e,t){const n=new AE(e.i,e.x,e.y),r=new AE(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 CE(e,t,n,r){const i=new AE(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 wE(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 AE(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 EE{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 EE.area(e)<0}static triangulateShape(e,t){const n=[],r=[],i=[];IE(e),TE(n,e);let o=e.length;t.forEach(IE);for(let e=0;e<t.length;e++)r.push(o),o+=t[e].length,TE(n,t[e]);const s=tE(n,r);for(let e=0;e<s.length;e+=3)i.push(s.slice(e,e+3));return i}}function IE(e){const t=e.length;t>2&&e[t-1].equals(e[0])&&e.pop()}function TE(e,t){for(let n=0;n<t.length;n++)e.push(t[n].x),e.push(t[n].y)}class ME extends JS{constructor(e=new eE([new Oy(.5,.5),new Oy(-.5,.5),new Oy(-.5,-.5),new Oy(.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=[],s=void 0!==t.curveSegments?t.curveSegments:12,a=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,h=void 0!==t.bevelOffset?t.bevelOffset:0,p=void 0!==t.bevelSegments?t.bevelSegments:3;const m=t.extrudePath,f=void 0!==t.UVGenerator?t.UVGenerator:RE;let g,v,y,_,S,b=!1;m&&(g=m.getSpacedPoints(a),b=!0,c=!1,v=m.computeFrenetFrames(a,!1),y=new u_,_=new u_,S=new u_),c||(p=0,u=0,d=0,h=0);const x=e.extractPoints(s);let C=x.shape;const w=x.holes;if(!EE.isClockWise(C)){C=C.reverse();for(let e=0,t=w.length;e<t;e++){const t=w[e];EE.isClockWise(t)&&(w[e]=t.reverse())}}const A=EE.triangulateShape(C,w),E=C;for(let e=0,t=w.length;e<t;e++){const t=w[e];C=C.concat(t)}function I(e,t,n){return t||console.error("THREE.ExtrudeGeometry: vec does not exist"),t.clone().multiplyScalar(n).add(e)}const T=C.length,M=A.length;function R(e,t,n){let r,i,o;const s=e.x-t.x,a=e.y-t.y,l=n.x-e.x,c=n.y-e.y,u=s*s+a*a,d=s*c-a*l;if(Math.abs(d)>Number.EPSILON){const d=Math.sqrt(u),h=Math.sqrt(l*l+c*c),p=t.x-a/d,m=t.y+s/d,f=((n.x-c/h-p)*c-(n.y+l/h-m)*l)/(s*c-a*l);r=p+s*f-e.x,i=m+a*f-e.y;const g=r*r+i*i;if(g<=2)return new Oy(r,i);o=Math.sqrt(g/2)}else{let e=!1;s>Number.EPSILON?l>Number.EPSILON&&(e=!0):s<-Number.EPSILON?l<-Number.EPSILON&&(e=!0):Math.sign(a)===Math.sign(c)&&(e=!0),e?(r=-a,i=s,o=Math.sqrt(u)):(r=s,i=a,o=Math.sqrt(u/2))}return new Oy(r/o,i/o)}const P=[];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),P[e]=R(E[e],E[n],E[r]);const N=[];let O,D=P.concat();for(let e=0,t=w.length;e<t;e++){const t=w[e];O=[];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),O[e]=R(t[e],t[r],t[i]);N.push(O),D=D.concat(O)}for(let e=0;e<p;e++){const t=e/p,n=u*Math.cos(t*Math.PI/2),r=d*Math.sin(t*Math.PI/2)+h;for(let e=0,t=E.length;e<t;e++){const t=I(E[e],P[e],r);B(t.x,t.y,-n)}for(let e=0,t=w.length;e<t;e++){const t=w[e];O=N[e];for(let e=0,i=t.length;e<i;e++){const i=I(t[e],O[e],r);B(i.x,i.y,-n)}}}const L=d+h;for(let e=0;e<T;e++){const t=c?I(C[e],D[e],L):C[e];b?(_.copy(v.normals[0]).multiplyScalar(t.x),y.copy(v.binormals[0]).multiplyScalar(t.y),S.copy(g[0]).add(_).add(y),B(S.x,S.y,S.z)):B(t.x,t.y,0)}for(let e=1;e<=a;e++)for(let t=0;t<T;t++){const n=c?I(C[t],D[t],L):C[t];b?(_.copy(v.normals[e]).multiplyScalar(n.x),y.copy(v.binormals[e]).multiplyScalar(n.y),S.copy(g[e]).add(_).add(y),B(S.x,S.y,S.z)):B(n.x,n.y,l/a*e)}for(let e=p-1;e>=0;e--){const t=e/p,n=u*Math.cos(t*Math.PI/2),r=d*Math.sin(t*Math.PI/2)+h;for(let e=0,t=E.length;e<t;e++){const t=I(E[e],P[e],r);B(t.x,t.y,l+n)}for(let e=0,t=w.length;e<t;e++){const t=w[e];O=N[e];for(let e=0,i=t.length;e<i;e++){const i=I(t[e],O[e],r);b?B(i.x,i.y+g[a-1].y,g[a-1].x+n):B(i.x,i.y,l+n)}}}function k(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=a+2*p;e<n;e++){const n=T*e,o=T*(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 z(e,t,i){U(e),U(t),U(i);const o=r.length/3,s=f.generateTopUV(n,r,o-3,o-2,o-1);j(s[0]),j(s[1]),j(s[2])}function F(e,t,i,o){U(e),U(t),U(o),U(t),U(i),U(o);const s=r.length/3,a=f.generateSideWallUV(n,r,s-6,s-3,s-2,s-1);j(a[0]),j(a[1]),j(a[3]),j(a[1]),j(a[2]),j(a[3])}function U(e){r.push(o[3*e+0]),r.push(o[3*e+1]),r.push(o[3*e+2])}function j(e){i.push(e.x),i.push(e.y)}!function(){const e=r.length/3;if(c){let e=0,t=T*e;for(let e=0;e<M;e++){const n=A[e];z(n[2]+t,n[1]+t,n[0]+t)}e=a+2*p,t=T*e;for(let e=0;e<M;e++){const n=A[e];z(n[0]+t,n[1]+t,n[2]+t)}}else{for(let e=0;e<M;e++){const t=A[e];z(t[2],t[1],t[0])}for(let e=0;e<M;e++){const t=A[e];z(t[0]+T*a,t[1]+T*a,t[2]+T*a)}}n.addGroup(e,r.length/3-e,0)}(),function(){const e=r.length/3;let t=0;k(E,t),t+=E.length;for(let e=0,n=w.length;e<n;e++){const n=w[e];k(n,t),t+=n.length}n.addGroup(e,r.length/3-e,1)}()}this.setAttribute("position",new zS(r,3)),this.setAttribute("uv",new zS(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 FA[r.type]).fromJSON(r)),new ME(n,e.options)}}const RE={generateTopUV:function(e,t,n,r,i){const o=t[3*n],s=t[3*n+1],a=t[3*r],l=t[3*r+1],c=t[3*i],u=t[3*i+1];return[new Oy(o,s),new Oy(a,l),new Oy(c,u)]},generateSideWallUV:function(e,t,n,r,i,o){const s=t[3*n],a=t[3*n+1],l=t[3*n+2],c=t[3*r],u=t[3*r+1],d=t[3*r+2],h=t[3*i],p=t[3*i+1],m=t[3*i+2],f=t[3*o],g=t[3*o+1],v=t[3*o+2];return Math.abs(a-u)<Math.abs(s-c)?[new Oy(s,1-l),new Oy(c,1-d),new Oy(h,1-m),new Oy(f,1-v)]:[new Oy(a,1-l),new Oy(u,1-d),new Oy(p,1-m),new Oy(g,1-v)]}};class PE extends JA{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 PE(e.radius,e.detail)}}class NE extends JA{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 NE(e.radius,e.detail)}}class OE extends JS{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 s=[],a=[],l=[],c=[];let u=e;const d=(t-e)/(r=Math.max(1,r)),h=new u_,p=new Oy;for(let e=0;e<=r;e++){for(let e=0;e<=n;e++){const r=i+e/n*o;h.x=u*Math.cos(r),h.y=u*Math.sin(r),a.push(h.x,h.y,h.z),l.push(0,0,1),p.x=(h.x/t+1)/2,p.y=(h.y/t+1)/2,c.push(p.x,p.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,a=r+n+2,l=r+1;s.push(i,o,l),s.push(o,a,l)}}this.setIndex(s),this.setAttribute("position",new zS(a,3)),this.setAttribute("normal",new zS(l,3)),this.setAttribute("uv",new zS(c,2))}static fromJSON(e){return new OE(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}}class DE extends JS{constructor(e=new eE([new Oy(0,.5),new Oy(-.5,-.5),new Oy(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};const n=[],r=[],i=[],o=[];let s=0,a=0;if(!1===Array.isArray(e))l(e);else for(let t=0;t<e.length;t++)l(e[t]),this.addGroup(s,a,t),s+=a,a=0;function l(e){const s=r.length/3,l=e.extractPoints(t);let c=l.shape;const u=l.holes;!1===EE.isClockWise(c)&&(c=c.reverse());for(let e=0,t=u.length;e<t;e++){const t=u[e];!0===EE.isClockWise(t)&&(u[e]=t.reverse())}const d=EE.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]+s,i=t[1]+s,o=t[2]+s;n.push(r,i,o),a+=3}}this.setIndex(n),this.setAttribute("position",new zS(r,3)),this.setAttribute("normal",new zS(i,3)),this.setAttribute("uv",new zS(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 DE(n,e.curveSegments)}}class LE extends JS{constructor(e=1,t=32,n=16,r=0,i=2*Math.PI,o=0,s=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:r,phiLength:i,thetaStart:o,thetaLength:s},t=Math.max(3,Math.floor(t)),n=Math.max(2,Math.floor(n));const a=Math.min(o+s,Math.PI);let l=0;const c=[],u=new u_,d=new u_,h=[],p=[],m=[],f=[];for(let h=0;h<=n;h++){const g=[],v=h/n;let y=0;0==h&&0==o?y=.5/t:h==n&&a==Math.PI&&(y=-.5/t);for(let n=0;n<=t;n++){const a=n/t;u.x=-e*Math.cos(r+a*i)*Math.sin(o+v*s),u.y=e*Math.cos(o+v*s),u.z=e*Math.sin(r+a*i)*Math.sin(o+v*s),p.push(u.x,u.y,u.z),d.copy(u).normalize(),m.push(d.x,d.y,d.z),f.push(a+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],s=c[e+1][r],l=c[e+1][r+1];(0!==e||o>0)&&h.push(t,i,l),(e!==n-1||a<Math.PI)&&h.push(i,s,l)}this.setIndex(h),this.setAttribute("position",new zS(p,3)),this.setAttribute("normal",new zS(m,3)),this.setAttribute("uv",new zS(f,2))}static fromJSON(e){return new LE(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class kE extends JA{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 kE(e.radius,e.detail)}}class BE extends JS{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=[],s=[],a=[],l=[],c=new u_,u=new u_,d=new u_;for(let o=0;o<=n;o++)for(let h=0;h<=r;h++){const p=h/r*i,m=o/n*Math.PI*2;u.x=(e+t*Math.cos(m))*Math.cos(p),u.y=(e+t*Math.cos(m))*Math.sin(p),u.z=t*Math.sin(m),s.push(u.x,u.y,u.z),c.x=e*Math.cos(p),c.y=e*Math.sin(p),d.subVectors(u,c).normalize(),a.push(d.x,d.y,d.z),l.push(h/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,s=(r+1)*(e-1)+t,a=(r+1)*e+t;o.push(n,i,a),o.push(i,s,a)}this.setIndex(o),this.setAttribute("position",new zS(s,3)),this.setAttribute("normal",new zS(a,3)),this.setAttribute("uv",new zS(l,2))}static fromJSON(e){return new BE(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}class zE extends JS{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 s=[],a=[],l=[],c=[],u=new u_,d=new u_,h=new u_,p=new u_,m=new u_,f=new u_,g=new u_;for(let s=0;s<=n;++s){const y=s/n*i*Math.PI*2;v(y,i,o,e,h),v(y+.01,i,o,e,p),f.subVectors(p,h),g.addVectors(p,h),m.crossVectors(f,g),g.crossVectors(m,f),m.normalize(),g.normalize();for(let e=0;e<=r;++e){const i=e/r*Math.PI*2,o=-t*Math.cos(i),p=t*Math.sin(i);u.x=h.x+(o*g.x+p*m.x),u.y=h.y+(o*g.y+p*m.y),u.z=h.z+(o*g.z+p*m.z),a.push(u.x,u.y,u.z),d.subVectors(u,h).normalize(),l.push(d.x,d.y,d.z),c.push(s/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,a=(r+1)*(e-1)+t;s.push(n,i,a),s.push(i,o,a)}function v(e,t,n,r,i){const o=Math.cos(e),s=Math.sin(e),a=n/t*e,l=Math.cos(a);i.x=r*(2+l)*.5*o,i.y=r*(2+l)*s*.5,i.z=r*Math.sin(a)*.5}this.setIndex(s),this.setAttribute("position",new zS(a,3)),this.setAttribute("normal",new zS(l,3)),this.setAttribute("uv",new zS(c,2))}static fromJSON(e){return new zE(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}}class FE extends JS{constructor(e=new BA(new u_(-1,-1,0),new u_(-1,1,0),new u_(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 s=new u_,a=new u_,l=new Oy;let c=new u_;const u=[],d=[],h=[],p=[];function m(i){c=e.getPointAt(i/t,c);const l=o.normals[i],h=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);a.x=o*l.x+i*h.x,a.y=o*l.y+i*h.y,a.z=o*l.z+i*h.z,a.normalize(),d.push(a.x,a.y,a.z),s.x=c.x+n*a.x,s.y=c.y+n*a.y,s.z=c.z+n*a.z,u.push(s.x,s.y,s.z)}}!function(){for(let e=0;e<t;e++)m(e);m(!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,h.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,s=(r+1)*(e-1)+t;p.push(n,i,s),p.push(i,o,s)}}()}(),this.setIndex(p),this.setAttribute("position",new zS(u,3)),this.setAttribute("normal",new zS(d,3)),this.setAttribute("uv",new zS(h,2))}toJSON(){const e=super.toJSON();return e.path=this.parameters.path.toJSON(),e}static fromJSON(e){return new FE((new FA[e.path.type]).fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}}class UE extends JS{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},null!==e){const t=[],n=new Set,r=new u_,i=new u_;if(null!==e.index){const o=e.attributes.position,s=e.index;let a=e.groups;0===a.length&&(a=[{start:0,count:s.count,materialIndex:0}]);for(let e=0,l=a.length;e<l;++e){const l=a[e],c=l.start;for(let e=c,a=c+l.count;e<a;e+=3)for(let a=0;a<3;a++){const l=s.getX(e+a),c=s.getX(e+(a+1)%3);r.fromBufferAttribute(o,l),i.fromBufferAttribute(o,c),!0===jE(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,s=o.count/3;e<s;e++)for(let s=0;s<3;s++){const a=3*e+s,l=3*e+(s+1)%3;r.fromBufferAttribute(o,a),i.fromBufferAttribute(o,l),!0===jE(r,i,n)&&(t.push(r.x,r.y,r.z),t.push(i.x,i.y,i.z))}}this.setAttribute("position",new zS(t,3))}}}function jE(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 GE=Object.freeze({__proto__:null,BoxGeometry:pb,CapsuleGeometry:HA,CircleGeometry:VA,ConeGeometry:qA,CylinderGeometry:WA,DodecahedronGeometry:KA,EdgesGeometry:ZA,ExtrudeGeometry:ME,IcosahedronGeometry:PE,LatheGeometry:GA,OctahedronGeometry:NE,PlaneGeometry:Ob,PolyhedronGeometry:JA,RingGeometry:OE,ShapeGeometry:DE,SphereGeometry:LE,TetrahedronGeometry:kE,TorusGeometry:BE,TorusKnotGeometry:zE,TubeGeometry:FE,WireframeGeometry:UE});class HE extends AS{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new Yy(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 VE extends vb{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class WE extends AS{constructor(e){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new Yy(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 Yy(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Fv,this.normalScale=new Oy(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 qE extends WE{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 Oy(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return wy(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 Yy(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 Yy(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Yy(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 JE extends AS{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Yy(16777215),this.specular=new Yy(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Yy(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Fv,this.normalScale=new Oy(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=$f,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 KE extends AS{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new Yy(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Yy(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Fv,this.normalScale=new Oy(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 YE extends AS{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Fv,this.normalScale=new Oy(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 XE extends AS{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Yy(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Yy(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Fv,this.normalScale=new Oy(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=$f,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 QE extends AS{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Yy(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Fv,this.normalScale=new Oy(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 $E extends $w{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 ZE(e,t,n){return tI(e)?new e.constructor(e.subarray(t,void 0!==n?n:e.length)):e.slice(t,n)}function eI(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 tI(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function nI(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 rI(e,t,n){const r=e.length,i=new e.constructor(r);for(let o=0,s=0;s!==r;++o){const r=n[o]*t;for(let n=0;n!==t;++n)i[s++]=e[r+n]}return i}function iI(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 s=o[r];if(void 0!==s)if(Array.isArray(s))do{s=o[r],void 0!==s&&(t.push(o.time),n.push.apply(n,s)),o=e[i++]}while(void 0!==o);else if(void 0!==s.toArray)do{s=o[r],void 0!==s&&(t.push(o.time),s.toArray(n,n.length)),o=e[i++]}while(void 0!==o);else do{s=o[r],void 0!==s&&(t.push(o.time),n.push(s)),o=e[i++]}while(void 0!==o)}var oI=Object.freeze({__proto__:null,arraySlice:ZE,convertArray:eI,isTypedArray:tI,getKeyframeOrder:nI,sortedArray:rI,flattenJSON:iI,subclip:function(e,t,n,r,i=30){const o=e.clone();o.name=t;const s=[];for(let e=0;e<o.tracks.length;++e){const t=o.tracks[e],a=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<a;++n)c.push(t.values[e*a+n])}}0!==l.length&&(t.times=eI(l,t.times.constructor),t.values=eI(c,t.values.constructor),s.push(t))}o.tracks=s;let a=1/0;for(let e=0;e<o.tracks.length;++e)a>o.tracks[e].times[0]&&(a=o.tracks[e].times[0]);for(let e=0;e<o.tracks.length;++e)o.tracks[e].shift(-1*a);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 s=e.tracks.find((function(e){return e.name===r.name&&e.ValueTypeName===i}));if(void 0===s)continue;let a=0;const l=r.getValueSize();r.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(a=l/3);let c=0;const u=s.getValueSize();s.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(c=u/3);const d=r.times.length-1;let h;if(o<=r.times[0]){const e=a,t=l-a;h=ZE(r.values,e,t)}else if(o>=r.times[d]){const e=d*l+a,t=e+l-a;h=ZE(r.values,e,t)}else{const e=r.createInterpolant(),t=a,n=l-a;e.evaluate(o),h=ZE(e.resultBuffer,t,n)}if("quaternion"===i){(new c_).fromArray(h).normalize().conjugate().toArray(h)}const p=s.times.length;for(let e=0;e<p;++e){const t=e*u+c;if("quaternion"===i)c_.multiplyQuaternionsFlat(s.values,t,h,0,s.values,t);else{const e=u-2*c;for(let n=0;n<e;++n)s.values[t+n]-=h[n]}}}return e.blendMode=Pv,e}});class sI{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 s=t[1];e<s&&(n=2,i=s);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 aI extends sI{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:Iv,endingEnd:Iv}}intervalChanged_(e,t,n){const r=this.parameterPositions;let i=e-2,o=e+1,s=r[i],a=r[o];if(void 0===s)switch(this.getSettings_().endingStart){case Tv:i=e,s=2*t-n;break;case Mv:i=r.length-2,s=t+r[i]-r[i+1];break;default:i=e,s=n}if(void 0===a)switch(this.getSettings_().endingEnd){case Tv:o=e,a=2*n-t;break;case Mv:o=1,a=n+r[1]-r[0];break;default:o=e-1,a=t}const l=.5*(n-t),c=this.valueSize;this._weightPrev=l/(t-s),this._weightNext=l/(a-n),this._offsetPrev=i*c,this._offsetNext=o*c}interpolate_(e,t,n,r){const i=this.resultBuffer,o=this.sampleValues,s=this.valueSize,a=e*s,l=a-s,c=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,h=this._weightNext,p=(n-t)/(r-t),m=p*p,f=m*p,g=-d*f+2*d*m-d*p,v=(1+d)*f+(-1.5-2*d)*m+(-.5+d)*p+1,y=(-1-h)*f+(1.5+h)*m+.5*p,_=h*f-h*m;for(let e=0;e!==s;++e)i[e]=g*o[c+e]+v*o[l+e]+y*o[a+e]+_*o[u+e];return i}}class lI extends sI{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){const i=this.resultBuffer,o=this.sampleValues,s=this.valueSize,a=e*s,l=a-s,c=(n-t)/(r-t),u=1-c;for(let e=0;e!==s;++e)i[e]=o[l+e]*u+o[a+e]*c;return i}}class cI extends sI{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e){return this.copySampleValue_(e-1)}}class uI{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=eI(t,this.TimeBufferType),this.values=eI(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:eI(e.times,Array),values:eI(e.values,Array)};const t=e.getInterpolation();t!==e.DefaultInterpolation&&(n.interpolation=t)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new cI(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new lI(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new aI(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case wv:t=this.InterpolantFactoryMethodDiscrete;break;case Av:t=this.InterpolantFactoryMethodLinear;break;case Ev: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 wv;case this.InterpolantFactoryMethodLinear:return Av;case this.InterpolantFactoryMethodSmooth:return Ev}}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=ZE(n,i,o),this.values=ZE(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&&tI(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=ZE(this.times),t=ZE(this.values),n=this.getValueSize(),r=this.getInterpolation()===Ev,i=e.length-1;let o=1;for(let s=1;s<i;++s){let i=!1;const a=e[s];if(a!==e[s+1]&&(1!==s||a!==e[0]))if(r)i=!0;else{const e=s*n,r=e-n,o=e+n;for(let s=0;s!==n;++s){const n=t[e+s];if(n!==t[r+s]||n!==t[o+s]){i=!0;break}}}if(i){if(s!==o){e[o]=e[s];const r=s*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,s=0;s!==n;++s)t[r+s]=t[e+s];++o}return o!==e.length?(this.times=ZE(e,0,o),this.values=ZE(t,0,o*n)):(this.times=e,this.values=t),this}clone(){const e=ZE(this.times,0),t=ZE(this.values,0),n=new(0,this.constructor)(this.name,e,t);return n.createInterpolant=this.createInterpolant,n}}uI.prototype.TimeBufferType=Float32Array,uI.prototype.ValueBufferType=Float32Array,uI.prototype.DefaultInterpolation=Av;class dI extends uI{}dI.prototype.ValueTypeName="bool",dI.prototype.ValueBufferType=Array,dI.prototype.DefaultInterpolation=wv,dI.prototype.InterpolantFactoryMethodLinear=void 0,dI.prototype.InterpolantFactoryMethodSmooth=void 0;class hI extends uI{}hI.prototype.ValueTypeName="color";class pI extends uI{}pI.prototype.ValueTypeName="number";class mI extends sI{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){const i=this.resultBuffer,o=this.sampleValues,s=this.valueSize,a=(n-t)/(r-t);let l=e*s;for(let e=l+s;l!==e;l+=4)c_.slerpFlat(i,0,o,l-s,o,l,a);return i}}class fI extends uI{InterpolantFactoryMethodLinear(e){return new mI(this.times,this.values,this.getValueSize(),e)}}fI.prototype.ValueTypeName="quaternion",fI.prototype.DefaultInterpolation=Av,fI.prototype.InterpolantFactoryMethodSmooth=void 0;class gI extends uI{}gI.prototype.ValueTypeName="string",gI.prototype.ValueBufferType=Array,gI.prototype.DefaultInterpolation=wv,gI.prototype.InterpolantFactoryMethodLinear=void 0,gI.prototype.InterpolantFactoryMethodSmooth=void 0;class vI extends uI{}vI.prototype.ValueTypeName="vector";class yI{constructor(e,t=-1,n,r=Rv){this.name=e,this.tracks=n,this.duration=t,this.blendMode=r,this.uuid=Cy(),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(_I(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(uI.toJSON(n[e]));return r}static CreateFromMorphTargetSequence(e,t,n,r){const i=t.length,o=[];for(let e=0;e<i;e++){let s=[],a=[];s.push((e+i-1)%i,e,(e+1)%i),a.push(0,1,0);const l=nI(s);s=rI(s,1,l),a=rI(a,1,l),r||0!==s[0]||(s.push(i),a.push(a[0])),o.push(new pI(".morphTargetInfluences["+t[e].name+"]",s,a).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=[],s=[];iI(n,o,s,r),0!==o.length&&i.push(new e(t,o,s))}},r=[],i=e.name||"default",o=e.fps||30,s=e.blendMode;let a=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 pI(".morphTargetInfluence["+n+"]",e,o))}a=e.length*o}else{const o=".bones["+t[e].name+"]";n(vI,o+".position",i,"pos",r),n(fI,o+".quaternion",i,"rot",r),n(vI,o+".scale",i,"scl",r)}}if(0===r.length)return null;return new this(i,a,r,s)}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 _I(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 pI;case"vector":case"vector2":case"vector3":case"vector4":return vI;case"color":return hI;case"quaternion":return fI;case"bool":case"boolean":return dI;case"string":return gI}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}(e.type);if(void 0===e.times){const t=[],n=[];iI(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 SI={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 bI{constructor(e,t,n){const r=this;let i,o=!1,s=0,a=0;const l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(e){a++,!1===o&&void 0!==r.onStart&&r.onStart(e,s,a),o=!0},this.itemEnd=function(e){s++,void 0!==r.onProgress&&r.onProgress(e,s,a),s===a&&(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 xI=new bI;class CI{constructor(e){this.manager=void 0!==e?e:xI,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 wI={};class AI extends Error{constructor(e,t){super(e),this.response=t}}class EI extends CI{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=SI.get(e);if(void 0!==i)return this.manager.itemStart(e),setTimeout((()=>{t&&t(i),this.manager.itemEnd(e)}),0),i;if(void 0!==wI[e])return void wI[e].push({onLoad:t,onProgress:n,onError:r});wI[e]=[],wI[e].push({onLoad:t,onProgress:n,onError:r});const o=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),s=this.mimeType,a=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=wI[e],r=t.body.getReader(),i=t.headers.get("Content-Length"),o=i?parseInt(i):0,s=0!==o;let a=0;const l=new ReadableStream({start(e){!function t(){r.read().then((({done:r,value:i})=>{if(r)e.close();else{a+=i.byteLength;const r=new ProgressEvent("progress",{lengthComputable:s,loaded:a,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 AI(`fetch for "${t.url}" responded with ${t.status}: ${t.statusText}`,t)})).then((e=>{switch(a){case"arraybuffer":return e.arrayBuffer();case"blob":return e.blob();case"document":return e.text().then((e=>(new DOMParser).parseFromString(e,s)));case"json":return e.json();default:if(void 0===s)return e.text();{const t=/charset="?([^;"\s]*)"?/i.exec(s),n=t&&t[1]?t[1].toLowerCase():void 0,r=new TextDecoder(n);return e.arrayBuffer().then((e=>r.decode(e)))}}})).then((t=>{SI.add(e,t);const n=wI[e];delete wI[e];for(let e=0,r=n.length;e<r;e++){const r=n[e];r.onLoad&&r.onLoad(t)}})).catch((t=>{const n=wI[e];if(void 0===n)throw this.manager.itemError(e),t;delete wI[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 II extends CI{constructor(e){super(e)}load(e,t,n,r){const i=this,o=new EI(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=yI.parse(e[n]);t.push(r)}return t}}class TI extends CI{constructor(e){super(e)}load(e,t,n,r){const i=this,o=[],s=new yA,a=new EI(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(i.withCredentials);let l=0;function c(c){a.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&&(s.minFilter=bg),s.image=o,s.format=n.format,s.needsUpdate=!0,t&&t(s))}),n,r)}if(Array.isArray(e))for(let t=0,n=e.length;t<n;++t)c(t);else a.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}s.image=o}else s.image.width=n.width,s.image.height=n.height,s.mipmaps=n.mipmaps;1===n.mipmapCount&&(s.minFilter=bg),s.format=n.format,s.needsUpdate=!0,t&&t(s)}),n,r);return s}}class MI extends CI{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=SI.get(e);if(void 0!==o)return i.manager.itemStart(e),setTimeout((function(){t&&t(o),i.manager.itemEnd(e)}),0),o;const s=zy("img");function a(){c(),SI.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(){s.removeEventListener("load",a,!1),s.removeEventListener("error",l,!1)}return s.addEventListener("load",a,!1),s.addEventListener("error",l,!1),"data:"!==e.slice(0,5)&&void 0!==this.crossOrigin&&(s.crossOrigin=this.crossOrigin),i.manager.itemStart(e),s.src=e,s}}class RI extends CI{constructor(e){super(e)}load(e,t,n,r){const i=new xb,o=new MI(this.manager);o.setCrossOrigin(this.crossOrigin),o.setPath(this.path);let s=0;function a(n){o.load(e[n],(function(e){i.images[n]=e,s++,6===s&&(i.needsUpdate=!0,t&&t(i))}),void 0,r)}for(let t=0;t<e.length;++t)a(t);return i}}class PI extends CI{constructor(e){super(e)}load(e,t,n,r){const i=this,o=new Gw,s=new EI(this.manager);return s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setPath(this.path),s.setWithCredentials(i.withCredentials),s.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:mg,o.wrapT=void 0!==n.wrapT?n.wrapT:mg,o.magFilter=void 0!==n.magFilter?n.magFilter:bg,o.minFilter=void 0!==n.minFilter?n.minFilter:bg,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=wg),1===n.mipmapCount&&(o.minFilter=bg),void 0!==n.generateMipmaps&&(o.generateMipmaps=n.generateMipmaps),o.needsUpdate=!0,t&&t(o,n))}),n,r),o}}class NI extends CI{constructor(e){super(e)}load(e,t,n,r){const i=new t_,o=new MI(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 OI extends hS{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Yy(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 DI extends OI{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(hS.DefaultUp),this.updateMatrix(),this.groundColor=new Yy(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}}const LI=new j_,kI=new u_,BI=new u_;class zI{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Oy(512,512),this.map=null,this.mapPass=null,this.matrix=new j_,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Rb,this._frameExtents=new Oy(1,1),this._viewportCount=1,this._viewports=[new n_(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;kI.setFromMatrixPosition(e.matrixWorld),t.position.copy(kI),BI.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(BI),t.updateMatrixWorld(),LI.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(LI),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 FI extends zI{constructor(){super(new _b(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){const t=this.camera,n=2*xy*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 UI extends OI{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(hS.DefaultUp),this.updateMatrix(),this.target=new hS,this.distance=n,this.angle=r,this.penumbra=i,this.decay=o,this.map=null,this.shadow=new FI}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 jI=new j_,GI=new u_,HI=new u_;class VI extends zI{constructor(){super(new _b(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new Oy(4,2),this._viewportCount=6,this._viewports=[new n_(2,1,1,1),new n_(0,1,1,1),new n_(3,1,1,1),new n_(1,1,1,1),new n_(3,0,1,1),new n_(1,0,1,1)],this._cubeDirections=[new u_(1,0,0),new u_(-1,0,0),new u_(0,0,1),new u_(0,0,-1),new u_(0,1,0),new u_(0,-1,0)],this._cubeUps=[new u_(0,1,0),new u_(0,1,0),new u_(0,1,0),new u_(0,1,0),new u_(0,0,1),new u_(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()),GI.setFromMatrixPosition(e.matrixWorld),n.position.copy(GI),HI.copy(n.position),HI.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(HI),n.updateMatrixWorld(),r.makeTranslation(-GI.x,-GI.y,-GI.z),jI.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(jI)}}class WI extends OI{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 VI}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 qI extends zI{constructor(){super(new Hb(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class JI extends OI{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(hS.DefaultUp),this.updateMatrix(),this.target=new hS,this.shadow=new qI}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class KI extends OI{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class YI extends OI{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 XI{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new u_)}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 QI extends OI{constructor(e=new XI,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 $I extends CI{constructor(e){super(e),this.textures={}}load(e,t,n,r){const i=this,o=new EI(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=$I.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 Yy).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 Yy).setHex(i.value);break;case"v2":r.uniforms[t].value=(new Oy).fromArray(i.value);break;case"v3":r.uniforms[t].value=(new u_).fromArray(i.value);break;case"v4":r.uniforms[t].value=(new n_).fromArray(i.value);break;case"m3":r.uniforms[t].value=(new Dy).fromArray(i.value);break;case"m4":r.uniforms[t].value=(new j_).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 Oy).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 Oy).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:HE,SpriteMaterial:gw,RawShaderMaterial:VE,ShaderMaterial:vb,PointsMaterial:cA,MeshPhysicalMaterial:qE,MeshStandardMaterial:WE,MeshPhongMaterial:JE,MeshToonMaterial:KE,MeshNormalMaterial:YE,MeshLambertMaterial:XE,MeshDepthMaterial:KC,MeshDistanceMaterial:YC,MeshBasicMaterial:ES,MeshMatcapMaterial:QE,LineDashedMaterial:$E,LineBasicMaterial:$w,Material:AS}[e]}}class ZI{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 eT extends JS{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 tT extends CI{constructor(e){super(e)}load(e,t,n,r){const i=this,o=new EI(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),s=By(i.type,o),a=new pw(s,i.stride);return a.uuid=i.uuid,t[r]=a,a}const i=e.isInstancedBufferGeometry?new eT:new JS,o=e.data.index;if(void 0!==o){const e=By(o.type,o.array);i.setIndex(new MS(e,1))}const s=e.data.attributes;for(const t in s){const n=s[t];let o;if(n.isInterleavedBufferAttribute){const t=r(e.data,n.data);o=new fw(t,n.itemSize,n.offset,n.normalized)}else{const e=By(n.type,n.array);o=new(n.isInstancedBufferAttribute?qw:MS)(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 a=e.data.morphAttributes;if(a)for(const t in a){const n=a[t],o=[];for(let t=0,i=n.length;t<i;t++){const i=n[t];let s;if(i.isInterleavedBufferAttribute){const t=r(e.data,i.data);s=new fw(t,i.itemSize,i.offset,i.normalized)}else{const e=By(i.type,i.array);s=new MS(e,i.itemSize,i.normalized)}void 0!==i.name&&(s.name=i.name),o.push(s)}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 u_;void 0!==c.center&&e.fromArray(c.center),i.boundingSphere=new N_(e,c.radius)}return e.name&&(i.name=e.name),e.userData&&(i.userData=e.userData),i}}class nT extends CI{constructor(e){super(e)}load(e,t,n,r){const i=this,o=""===this.path?ZI.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||o;const s=new EI(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.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 s=o.metadata;void 0!==s&&void 0!==s.type&&"geometry"!==s.type.toLowerCase()?i.parse(o,t):console.error("THREE.ObjectLoader: Can't load "+e)}),n,r)}async loadAsync(e,t){const n=""===this.path?ZI.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||n;const r=new EI(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),s=o.metadata;if(void 0===s||void 0===s.type||"geometry"===s.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)})),s=this.parseTextures(e.textures,o),a=this.parseMaterials(e.materials,s),l=this.parseObject(e.object,i,a,s,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),s=this.parseMaterials(e.materials,o),a=this.parseObject(e.object,r,s,o,t),l=this.parseSkeletons(e.skeletons,a);return this.bindSkeletons(a,l),a}parseShapes(e){const t={};if(void 0!==e)for(let n=0,r=e.length;n<r;n++){const r=(new eE).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 Ww).fromJSON(e[t],r);n[i.uuid]=i}return n}parseGeometries(e,t){const n={};if(void 0!==e){const r=new tT;for(let i=0,o=e.length;i<o;i++){let o;const s=e[i];switch(s.type){case"BufferGeometry":case"InstancedBufferGeometry":o=r.parse(s);break;default:s.type in GE?o=GE[s.type].fromJSON(s,t):console.warn(`THREE.ObjectLoader: Unsupported geometry type "${s.type}"`)}o.uuid=s.uuid,void 0!==s.name&&(o.name=s.name),!0===o.isBufferGeometry&&void 0!==s.userData&&(o.userData=s.userData),n[s.uuid]=o}}return n}parseMaterials(e,t){const n={},r={};if(void 0!==e){const i=new $I;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=yI.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:By(e.type,e.data),width:e.width,height:e.height}:null}if(void 0!==e&&e.length>0){const n=new bI(t);i=new MI(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 Gw(n.data,n.width,n.height)))}r[n.uuid]=new $y(e)}else{const e=o(n.url);r[n.uuid]=new $y(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:By(e.type,e.data),width:e.width,height:e.height}:null}if(void 0!==e&&e.length>0){r=new MI(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 Gw(r.data,r.width,r.height)))}n[r.uuid]=new $y(e)}else{const e=await i(r.url);n[r.uuid]=new $y(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 s=t[o.image],a=s.data;let l;Array.isArray(a)?(l=new xb,6===a.length&&(l.needsUpdate=!0)):(l=a&&a.data?new Gw:new t_,a&&(l.needsUpdate=!0)),l.source=s,l.uuid=o.uuid,void 0!==o.name&&(l.name=o.name),void 0!==o.mapping&&(l.mapping=n(o.mapping,rT)),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],iT),l.wrapT=n(o.wrap[1],iT)),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,oT)),void 0!==o.magFilter&&(l.magFilter=n(o.magFilter,oT)),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,s,a;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 hw,void 0!==e.background&&(Number.isInteger(e.background)?o.background=new Yy(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 dw(e.fog.color,e.fog.near,e.fog.far):"FogExp2"===e.fog.type&&(o.fog=new uw(e.fog.color,e.fog.density)));break;case"PerspectiveCamera":o=new _b(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 Hb(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 KI(e.color,e.intensity);break;case"DirectionalLight":o=new JI(e.color,e.intensity);break;case"PointLight":o=new WI(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":o=new YI(e.color,e.intensity,e.width,e.height);break;case"SpotLight":o=new UI(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay);break;case"HemisphereLight":o=new DI(e.color,e.groundColor,e.intensity);break;case"LightProbe":o=(new QI).fromJSON(e);break;case"SkinnedMesh":s=l(e.geometry),a=c(e.material),o=new Uw(s,a),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":s=l(e.geometry),a=c(e.material),o=new db(s,a);break;case"InstancedMesh":s=l(e.geometry),a=c(e.material);const t=e.count,n=e.instanceMatrix,r=e.instanceColor;o=new Qw(s,a,t),o.instanceMatrix=new qw(new Float32Array(n.array),16),void 0!==r&&(o.instanceColor=new qw(new Float32Array(r.array),r.itemSize));break;case"LOD":o=new Dw;break;case"Line":o=new iA(l(e.geometry),c(e.material));break;case"LineLoop":o=new lA(l(e.geometry),c(e.material));break;case"LineSegments":o=new aA(l(e.geometry),c(e.material));break;case"PointCloud":case"Points":o=new mA(l(e.geometry),c(e.material));break;case"Sprite":o=new Rw(c(e.material));break;case"Group":o=new tw;break;case"Bone":o=new jw;break;default:o=new hS}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 s=e.children;for(let e=0;e<s.length;e++)o.add(this.parseObject(s[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 rT={UVMapping:ag,CubeReflectionMapping:lg,CubeRefractionMapping:cg,EquirectangularReflectionMapping:ug,EquirectangularRefractionMapping:dg,CubeUVReflectionMapping:hg},iT={RepeatWrapping:pg,ClampToEdgeWrapping:mg,MirroredRepeatWrapping:fg},oT={NearestFilter:gg,NearestMipmapNearestFilter:vg,NearestMipmapLinearFilter:_g,LinearFilter:bg,LinearMipmapNearestFilter:xg,LinearMipmapLinearFilter:wg};class sT extends CI{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=SI.get(e);if(void 0!==o)return i.manager.itemStart(e),setTimeout((function(){t&&t(o),i.manager.itemEnd(e)}),0),o;const s={};s.credentials="anonymous"===this.crossOrigin?"same-origin":"include",s.headers=this.requestHeader,fetch(e,s).then((function(e){return e.blob()})).then((function(e){return createImageBitmap(e,Object.assign(i.options,{colorSpaceConversion:"none"}))})).then((function(n){SI.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 aT;const lT={getContext:function(){return void 0===aT&&(aT=new(window.AudioContext||window.webkitAudioContext)),aT},setContext:function(e){aT=e}};class cT extends CI{constructor(e){super(e)}load(e,t,n,r){const i=this,o=new EI(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);lT.getContext().decodeAudioData(e,(function(e){t(e)}))}catch(t){r?r(t):console.error(t),i.manager.itemError(e)}}),n,r)}}class uT extends QI{constructor(e,t,n=1){super(void 0,n),this.isHemisphereLightProbe=!0;const r=(new Yy).set(e),i=(new Yy).set(t),o=new u_(r.r,r.g,r.b),s=new u_(i.r,i.g,i.b),a=Math.sqrt(Math.PI),l=a*Math.sqrt(.75);this.sh.coefficients[0].copy(o).add(s).multiplyScalar(a),this.sh.coefficients[1].copy(o).sub(s).multiplyScalar(l)}}class dT extends QI{constructor(e,t=1){super(void 0,t),this.isAmbientLightProbe=!0;const n=(new Yy).set(e);this.sh.coefficients[0].set(n.r,n.g,n.b).multiplyScalar(2*Math.sqrt(Math.PI))}}const hT=new j_,pT=new j_,mT=new j_;class fT{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new _b,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new _b,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,mT.copy(e.projectionMatrix);const n=t.eyeSep/2,r=n*t.near/t.focus,i=t.near*Math.tan(by*t.fov*.5)/t.zoom;let o,s;pT.elements[12]=-n,hT.elements[12]=n,o=-i*t.aspect+r,s=i*t.aspect+r,mT.elements[0]=2*t.near/(s-o),mT.elements[8]=(s+o)/(s-o),this.cameraL.projectionMatrix.copy(mT),o=-i*t.aspect-r,s=i*t.aspect-r,mT.elements[0]=2*t.near/(s-o),mT.elements[8]=(s+o)/(s-o),this.cameraR.projectionMatrix.copy(mT)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(pT),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(hT)}}class gT{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=vT(),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=vT();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}function vT(){return("undefined"==typeof performance?Date:performance).now()}const yT=new u_,_T=new c_,ST=new u_,bT=new u_;class xT extends hS{constructor(){super(),this.type="AudioListener",this.context=lT.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new gT}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(yT,_T,ST),bT.set(0,0,-1).applyQuaternion(_T),t.positionX){const e=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(yT.x,e),t.positionY.linearRampToValueAtTime(yT.y,e),t.positionZ.linearRampToValueAtTime(yT.z,e),t.forwardX.linearRampToValueAtTime(bT.x,e),t.forwardY.linearRampToValueAtTime(bT.y,e),t.forwardZ.linearRampToValueAtTime(bT.z,e),t.upX.linearRampToValueAtTime(n.x,e),t.upY.linearRampToValueAtTime(n.y,e),t.upZ.linearRampToValueAtTime(n.z,e)}else t.setPosition(yT.x,yT.y,yT.z),t.setOrientation(bT.x,bT.y,bT.z,n.x,n.y,n.z)}}class CT extends hS{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 wT=new u_,AT=new c_,ET=new u_,IT=new u_;class TT extends CT{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(wT,AT,ET),IT.set(0,0,1).applyQuaternion(AT);const t=this.panner;if(t.positionX){const e=this.context.currentTime+this.listener.timeDelta;t.positionX.linearRampToValueAtTime(wT.x,e),t.positionY.linearRampToValueAtTime(wT.y,e),t.positionZ.linearRampToValueAtTime(wT.z,e),t.orientationX.linearRampToValueAtTime(IT.x,e),t.orientationY.linearRampToValueAtTime(IT.y,e),t.orientationZ.linearRampToValueAtTime(IT.z,e)}else t.setPosition(wT.x,wT.y,wT.z),t.setOrientation(IT.x,IT.y,IT.z)}}class MT{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 RT{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,s=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]){s.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){c_.slerpFlat(e,t,e,t,e,n,r)}_slerpAdditive(e,t,n,r,i){const o=this._workIndex*i;c_.multiplyQuaternionsFlat(e,o,e,t,e,n),c_.slerpFlat(e,t,e,t,e,o,r)}_lerp(e,t,n,r,i){const o=1-r;for(let s=0;s!==i;++s){const i=t+s;e[i]=e[i]*o+e[n+s]*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 PT="\\[\\]\\.:\\/",NT=new RegExp("["+PT+"]","g"),OT="[^"+PT+"]",DT="[^"+PT.replace("\\.","")+"]",LT=new RegExp("^"+/((?:WC+[\/:])*)/.source.replace("WC",OT)+/(WCOD+)?/.source.replace("WCOD",DT)+/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",OT)+/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",OT)+"$"),kT=["material","materials","bones","map"];class BT{constructor(e,t,n){this.path=t,this.parsedPath=n||BT.parseTrackName(t),this.node=BT.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 BT.Composite(e,t,n):new BT(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(NT,"")}static parseTrackName(e){const t=LT.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!==kT.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=BT.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 s=this.Versioning.None;this.targetObject=e,void 0!==e.needsUpdate?s=this.Versioning.NeedsUpdate:void 0!==e.matrixWorldNeedsUpdate&&(s=this.Versioning.MatrixWorldNeedsUpdate);let a=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])}a=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=i}else void 0!==o.fromArray&&void 0!==o.toArray?(a=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(a=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=r;this.getValue=this.GetterByBindingType[a],this.setValue=this.SetterByBindingTypeAndVersioning[a][s]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}BT.Composite=class{constructor(e,t,n){const r=n||BT.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()}},BT.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},BT.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},BT.prototype.GetterByBindingType=[BT.prototype._getValue_direct,BT.prototype._getValue_array,BT.prototype._getValue_arrayElement,BT.prototype._getValue_toArray],BT.prototype.SetterByBindingTypeAndVersioning=[[BT.prototype._setValue_direct,BT.prototype._setValue_direct_setNeedsUpdate,BT.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[BT.prototype._setValue_array,BT.prototype._setValue_array_setNeedsUpdate,BT.prototype._setValue_array_setMatrixWorldNeedsUpdate],[BT.prototype._setValue_arrayElement,BT.prototype._setValue_arrayElement_setNeedsUpdate,BT.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[BT.prototype._setValue_fromArray,BT.prototype._setValue_fromArray_setNeedsUpdate,BT.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class zT{constructor(){this.isAnimationObjectGroup=!0,this.uuid=Cy(),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 s,a=e.length,l=this.nCachedObjects_;for(let c=0,u=arguments.length;c!==u;++c){const u=arguments[c],d=u.uuid;let h=t[d];if(void 0===h){h=a++,t[d]=h,e.push(u);for(let e=0,t=o;e!==t;++e)i[e].push(new BT(u,n[e],r[e]))}else if(h<l){s=e[h];const a=--l,c=e[a];t[c.uuid]=h,e[h]=c,t[d]=a,e[a]=u;for(let e=0,t=o;e!==t;++e){const t=i[e],o=t[a];let s=t[h];t[h]=o,void 0===s&&(s=new BT(u,n[e],r[e])),t[a]=s}}else e[h]!==s&&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,s=arguments.length;o!==s;++o){const s=arguments[o],a=s.uuid,l=t[a];if(void 0!==l&&l>=i){const o=i++,c=e[o];t[c.uuid]=l,e[l]=c,t[a]=o,e[o]=s;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 s=0,a=arguments.length;s!==a;++s){const a=arguments[s].uuid,l=t[a];if(void 0!==l)if(delete t[a],l<i){const s=--i,a=e[s],c=--o,u=e[c];t[a.uuid]=l,e[l]=a,t[u.uuid]=s,e[s]=u,e.pop();for(let e=0,t=r;e!==t;++e){const t=n[e],r=t[s],i=t[c];t[l]=r,t[s]=i,t.pop()}}else{const i=--o,s=e[i];i>0&&(t[s.uuid]=l),e[l]=s,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,s=this._parsedPaths,a=this._objects,l=a.length,c=this.nCachedObjects_,u=new Array(l);r=i.length,n[e]=r,o.push(e),s.push(t),i.push(u);for(let n=c,r=a.length;n!==r;++n){const r=a[n];u[n]=new BT(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,s=o.length-1,a=o[s];t[e[s]]=n,o[n]=a,o.pop(),i[n]=i[s],i.pop(),r[n]=r[s],r.pop()}}}class FT{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,s=new Array(o),a={endingStart:Iv,endingEnd:Iv};for(let e=0;e!==o;++e){const t=i[e].createInterpolant(null);s[e]=t,t.settings=a}this._interpolantSettings=a,this._interpolants=s,this._propertyBindings=new Array(o),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=xv,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 s=this._timeScaleInterpolant;null===s&&(s=r._lendControlInterpolant(),this._timeScaleInterpolant=s);const a=s.parameterPositions,l=s.sampleValues;return a[0]=i,a[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),s=this._updateWeight(e);if(s>0){const e=this._interpolants,t=this._propertyBindings;if(this.blendMode===Pv)for(let n=0,r=e.length;n!==r;++n)e[n].evaluate(o),t[n].accumulateAdditive(s);else for(let n=0,i=e.length;n!==i;++n)e[n].evaluate(o),t[n].accumulate(r,s)}}_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===Cv;if(0===e)return-1===i?r:o&&1==(1&i)?t-r:r;if(n===bv){-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 s=this.repetitions-i;if(s<=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===s){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=Tv,r.endingEnd=Tv):(r.endingStart=e?this.zeroSlopeAtStart?Tv:Iv:Mv,r.endingEnd=t?this.zeroSlopeAtEnd?Tv:Iv:Mv)}_scheduleFading(e,t,n){const r=this._mixer,i=r.time;let o=this._weightInterpolant;null===o&&(o=r._lendControlInterpolant(),this._weightInterpolant=o);const s=o.parameterPositions,a=o.sampleValues;return s[0]=i,a[0]=t,s[1]=i+e,a[1]=n,this}}const UT=new Float32Array(1);class jT extends yy{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,s=e._interpolants,a=n.uuid,l=this._bindingsByRootAndName;let c=l[a];void 0===c&&(c={},l[a]=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,a,l));continue}const r=t&&t._propertyBindings[e].binding.parsedPath;u=new RT(BT.create(n,l,r),i.ValueTypeName,i.getValueSize()),++u.referenceCount,this._addInactiveBinding(u,a,l),o[e]=u}s[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,s=o[i],a=s.knownActions,l=a[a.length-1],c=e._byClipCacheIndex;l._byClipCacheIndex=c,a[c]=l,a.pop(),e._byClipCacheIndex=null;delete s.actionByRoot[(e._localRoot||this._root).uuid],0===a.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,s=o[r],a=t[t.length-1],l=e._cacheIndex;a._cacheIndex=l,t[l]=a,t.pop(),delete s[i],0===Object.keys(s).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 lI(new Float32Array(2),new Float32Array(2),1,UT),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?yI.findByName(r,e):e;const s=null!==o?o.uuid:e,a=this._actionsByClip[s];let l=null;if(void 0===n&&(n=null!==o?o.blendMode:Rv),void 0!==a){const e=a.actionByRoot[i];if(void 0!==e&&e.blendMode===n)return e;l=a.knownActions[0],null===o&&(o=l._clip)}if(null===o)return null;const c=new FT(this,o,t,n);return this._bindAction(c,l),this._addInactiveAction(c,s,i),c}existingAction(e,t){const n=t||this._root,r=n.uuid,i="string"==typeof e?yI.findByName(n,e):e,o=i?i.uuid:e,s=this._actionsByClip[o];return void 0!==s&&s.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 s=0;s!==n;++s){t[s]._update(r,e,i,o)}const s=this._bindings,a=this._nActiveBindings;for(let e=0;e!==a;++e)s[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 GT{constructor(e){this.value=e}clone(){return new GT(void 0===this.value.clone?this.value:this.value.clone())}}let HT=0;class VT extends yy{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:HT++}),this.name="",this.usage=sy,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 WT extends pw{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 qT{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 JT{constructor(e,t,n=0,r=1/0){this.ray=new U_(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 YT(e,this,n,t),n.sort(KT),n}intersectObjects(e,t=!0,n=[]){for(let r=0,i=e.length;r<i;r++)YT(e[r],this,n,t);return n.sort(KT),n}}function KT(e,t){return e.distance-t.distance}function YT(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++)YT(r[e],t,n,!0)}}class XT{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(wy(t/this.radius,-1,1))),this}clone(){return(new this.constructor).copy(this)}}class QT{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 $T=new Oy;class ZT{constructor(e=new Oy(1/0,1/0),t=new Oy(-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=$T.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 $T.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 eM=new u_,tM=new u_;class nM{constructor(e=new u_,t=new u_){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){eM.subVectors(e,this.start),tM.subVectors(this.end,this.start);const n=tM.dot(tM);let r=tM.dot(eM)/n;return t&&(r=wy(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 rM=new u_;class iM extends hS{constructor(e,t){super(),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t;const n=new JS,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 zS(r,3));const i=new $w({fog:!1,toneMapped:!1});this.cone=new aA(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),rM.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(rM),void 0!==this.color?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}}const oM=new u_,sM=new j_,aM=new j_;class lM extends aA{constructor(e){const t=cM(e),n=new JS,r=[],i=[],o=new Yy(0,0,1),s=new Yy(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(s.r,s.g,s.b))}n.setAttribute("position",new zS(r,3)),n.setAttribute("color",new zS(i,3));super(n,new $w({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");aM.copy(this.root.matrixWorld).invert();for(let e=0,n=0;e<t.length;e++){const i=t[e];i.parent&&i.parent.isBone&&(sM.multiplyMatrices(aM,i.matrixWorld),oM.setFromMatrixPosition(sM),r.setXYZ(n,oM.x,oM.y,oM.z),sM.multiplyMatrices(aM,i.parent.matrixWorld),oM.setFromMatrixPosition(sM),r.setXYZ(n+1,oM.x,oM.y,oM.z),n+=2)}n.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}}function cM(e){const t=[];!0===e.isBone&&t.push(e);for(let n=0;n<e.children.length;n++)t.push.apply(t,cM(e.children[n]));return t}class uM extends db{constructor(e,t,n){super(new LE(t,4,2),new ES({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 dM=new u_,hM=new Yy,pM=new Yy;class mM extends hS{constructor(e,t,n){super(),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n;const r=new NE(t);r.rotateY(.5*Math.PI),this.material=new ES({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 MS(o,3)),this.add(new db(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");hM.copy(this.light.color),pM.copy(this.light.groundColor);for(let e=0,n=t.count;e<n;e++){const r=e<n/2?hM:pM;t.setXYZ(e,r.r,r.g,r.b)}t.needsUpdate=!0}e.lookAt(dM.setFromMatrixPosition(this.light.matrixWorld).negate())}}class fM extends aA{constructor(e=10,t=10,n=4473924,r=8947848){n=new Yy(n),r=new Yy(r);const i=t/2,o=e/t,s=e/2,a=[],l=[];for(let e=0,c=0,u=-s;e<=t;e++,u+=o){a.push(-s,0,u,s,0,u),a.push(u,0,-s,u,0,s);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 JS;c.setAttribute("position",new zS(a,3)),c.setAttribute("color",new zS(l,3));super(c,new $w({vertexColors:!0,toneMapped:!1})),this.type="GridHelper"}}class gM extends aA{constructor(e=10,t=16,n=8,r=64,i=4473924,o=8947848){i=new Yy(i),o=new Yy(o);const s=[],a=[];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;s.push(0,0,0),s.push(l,0,c);const u=1&n?i:o;a.push(u.r,u.g,u.b),a.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;s.push(n,0,i),a.push(l.r,l.g,l.b),t=(e+1)/r*(2*Math.PI),n=Math.sin(t)*c,i=Math.cos(t)*c,s.push(n,0,i),a.push(l.r,l.g,l.b)}}const l=new JS;l.setAttribute("position",new zS(s,3)),l.setAttribute("color",new zS(a,3));super(l,new $w({vertexColors:!0,toneMapped:!1})),this.type="PolarGridHelper"}}const vM=new u_,yM=new u_,_M=new u_;class SM extends hS{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 JS;r.setAttribute("position",new zS([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));const i=new $w({fog:!1,toneMapped:!1});this.lightPlane=new iA(r,i),this.add(this.lightPlane),r=new JS,r.setAttribute("position",new zS([0,0,0,0,0,1],3)),this.targetLine=new iA(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(){vM.setFromMatrixPosition(this.light.matrixWorld),yM.setFromMatrixPosition(this.light.target.matrixWorld),_M.subVectors(yM,vM),this.lightPlane.lookAt(yM),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(yM),this.targetLine.scale.z=_M.length()}}const bM=new u_,xM=new yb;class CM extends aA{constructor(e){const t=new JS,n=new $w({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],i=[],o={};function s(e,t){a(e),a(t)}function a(e){r.push(0,0,0),i.push(0,0,0),void 0===o[e]&&(o[e]=[]),o[e].push(r.length/3-1)}s("n1","n2"),s("n2","n4"),s("n4","n3"),s("n3","n1"),s("f1","f2"),s("f2","f4"),s("f4","f3"),s("f3","f1"),s("n1","f1"),s("n2","f2"),s("n3","f3"),s("n4","f4"),s("p","n1"),s("p","n2"),s("p","n3"),s("p","n4"),s("u1","u2"),s("u2","u3"),s("u3","u1"),s("c","t"),s("p","c"),s("cn1","cn2"),s("cn3","cn4"),s("cf1","cf2"),s("cf3","cf4"),t.setAttribute("position",new zS(r,3)),t.setAttribute("color",new zS(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 Yy(16755200),c=new Yy(16711680),u=new Yy(43775),d=new Yy(16777215),h=new Yy(3355443);this.setColors(l,c,u,d,h)}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;xM.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),wM("c",t,e,xM,0,0,-1),wM("t",t,e,xM,0,0,1),wM("n1",t,e,xM,-1,-1,-1),wM("n2",t,e,xM,1,-1,-1),wM("n3",t,e,xM,-1,1,-1),wM("n4",t,e,xM,1,1,-1),wM("f1",t,e,xM,-1,-1,1),wM("f2",t,e,xM,1,-1,1),wM("f3",t,e,xM,-1,1,1),wM("f4",t,e,xM,1,1,1),wM("u1",t,e,xM,.7,1.1,-1),wM("u2",t,e,xM,-.7,1.1,-1),wM("u3",t,e,xM,0,2,-1),wM("cf1",t,e,xM,-1,0,1),wM("cf2",t,e,xM,1,0,1),wM("cf3",t,e,xM,0,-1,1),wM("cf4",t,e,xM,0,1,1),wM("cn1",t,e,xM,-1,0,-1),wM("cn2",t,e,xM,1,0,-1),wM("cn3",t,e,xM,0,-1,-1),wM("cn4",t,e,xM,0,1,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}}function wM(e,t,n,r,i,o,s){bM.set(i,o,s).unproject(r);const a=t[e];if(void 0!==a){const e=n.getAttribute("position");for(let t=0,n=a.length;t<n;t++)e.setXYZ(a[t],bM.x,bM.y,bM.z)}}const AM=new p_;class EM extends aA{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 JS;i.setIndex(new MS(n,1)),i.setAttribute("position",new MS(r,3)),super(i,new $w({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&&AM.setFromObject(this.object),AM.isEmpty())return;const t=AM.min,n=AM.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 IM extends aA{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 JS;r.setIndex(new MS(n,1)),r.setAttribute("position",new zS([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 $w({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 TM extends iA{constructor(e,t=1,n=16776960){const r=n,i=new JS;i.setAttribute("position",new zS([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 $w({color:r,toneMapped:!1})),this.type="PlaneHelper",this.plane=e,this.size=t;const o=new JS;o.setAttribute("position",new zS([1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],3)),o.computeBoundingSphere(),this.add(new db(o,new ES({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 MM=new u_;let RM,PM;class NM extends hS{constructor(e=new u_(0,0,1),t=new u_(0,0,0),n=1,r=16776960,i=.2*n,o=.2*i){super(),this.type="ArrowHelper",void 0===RM&&(RM=new JS,RM.setAttribute("position",new zS([0,0,0,0,1,0],3)),PM=new WA(0,.5,1,5,1),PM.translate(0,-.5,0)),this.position.copy(t),this.line=new iA(RM,new $w({color:r,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new db(PM,new ES({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{MM.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(MM,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 OM extends aA{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 JS;n.setAttribute("position",new zS(t,3)),n.setAttribute("color",new zS([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],3));super(n,new $w({vertexColors:!0,toneMapped:!1})),this.type="AxesHelper"}setColors(e,t,n){const r=new Yy,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 DM{constructor(){this.type="ShapePath",this.color=new Yy,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new jA,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],s=t[o],a=s.x-n.x,l=s.y-n.y;if(Math.abs(l)>Number.EPSILON){if(l<0&&(n=t[o],a=-a,s=t[i],l=-l),e.y<n.y||e.y>s.y)continue;if(e.y===n.y){if(e.x===n.x)return!0}else{const t=l*(e.x-n.x)-a*(e.y-n.y);if(0===t)return!0;if(t<0)continue;r=!r}}else{if(e.y!==n.y)continue;if(s.x<=e.x&&e.x<=n.x||n.x<=e.x&&e.x<=s.x)return!0}}return r}const n=EE.isClockWise,r=this.subPaths;if(0===r.length)return[];let i,o,s;const a=[];if(1===r.length)return o=r[0],s=new eE,s.curves=o.curves,a.push(s),a;let l=!n(r[0].getPoints());l=e?!l:l;const c=[],u=[];let d,h,p=[],m=0;u[m]=void 0,p[m]=[];for(let t=0,s=r.length;t<s;t++)o=r[t],d=o.getPoints(),i=n(d),i=e?!i:i,i?(!l&&u[m]&&m++,u[m]={s:new eE,p:d},u[m].s.curves=o.curves,l&&m++,p[m]=[]):p[m].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 eE;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=p[r];for(let o=0;o<i.length;o++){const s=i[o];let a=!0;for(let i=0;i<u.length;i++)t(s.p,u[i].p)&&(r!==i&&n++,a?(a=!1,c[i].push(s)):e=!0);a&&c[r].push(s)}}n>0&&!1===e&&(p=c)}for(let e=0,t=u.length;e<t;e++){s=u[e].s,a.push(s),h=p[e];for(let e=0,t=h.length;e<t;e++)s.holes.push(h[e].h)}return a}}const LM=kM();function kM(){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),s=new Uint32Array(64),a=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)s[e]=e<<23;s[31]=1199570944,s[32]=2147483648;for(let e=33;e<63;++e)s[e]=2147483648+(e-32<<23);s[63]=3347054592;for(let e=1;e<64;++e)32!==e&&(a[e]=1024);return{floatView:t,uint32View:n,baseTable:r,shiftTable:i,mantissaTable:o,exponentTable:s,offsetTable:a}}var BM=Object.freeze({__proto__:null,toHalfFloat:function(e){Math.abs(e)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),e=wy(e,-65504,65504),LM.floatView[0]=e;const t=LM.uint32View[0],n=t>>23&511;return LM.baseTable[n]+((8388607&t)>>LM.shiftTable[n])},fromHalfFloat:function(e){const t=e>>10;return LM.uint32View[0]=LM.mantissaTable[LM.offsetTable[t]+(1023&e)]+LM.exponentTable[t],LM.floatView[0]}});function zM(){console.error("THREE.ImmediateRenderObject has been removed.")}class FM extends r_{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 UM extends i_{constructor(e,t,n,r){console.warn("THREE.DataTexture2DArray has been renamed to DataArrayTexture."),super(e,t,n,r)}}class jM extends s_{constructor(e,t,n,r){console.warn("THREE.DataTexture3D has been renamed to Data3DTexture."),super(e,t,n,r)}}class GM extends pb{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 HM extends HA{constructor(e,t,n,r){console.warn("THREE.CapsuleBufferGeometry has been renamed to THREE.CapsuleGeometry."),super(e,t,n,r)}}class VM extends VA{constructor(e,t,n,r){console.warn("THREE.CircleBufferGeometry has been renamed to THREE.CircleGeometry."),super(e,t,n,r)}}class WM extends qA{constructor(e,t,n,r,i,o,s){console.warn("THREE.ConeBufferGeometry has been renamed to THREE.ConeGeometry."),super(e,t,n,r,i,o,s)}}class qM extends WA{constructor(e,t,n,r,i,o,s,a){console.warn("THREE.CylinderBufferGeometry has been renamed to THREE.CylinderGeometry."),super(e,t,n,r,i,o,s,a)}}class JM extends KA{constructor(e,t){console.warn("THREE.DodecahedronBufferGeometry has been renamed to THREE.DodecahedronGeometry."),super(e,t)}}class KM extends ME{constructor(e,t){console.warn("THREE.ExtrudeBufferGeometry has been renamed to THREE.ExtrudeGeometry."),super(e,t)}}class YM extends PE{constructor(e,t){console.warn("THREE.IcosahedronBufferGeometry has been renamed to THREE.IcosahedronGeometry."),super(e,t)}}class XM extends GA{constructor(e,t,n,r){console.warn("THREE.LatheBufferGeometry has been renamed to THREE.LatheGeometry."),super(e,t,n,r)}}class QM extends NE{constructor(e,t){console.warn("THREE.OctahedronBufferGeometry has been renamed to THREE.OctahedronGeometry."),super(e,t)}}class $M extends Ob{constructor(e,t,n,r){console.warn("THREE.PlaneBufferGeometry has been renamed to THREE.PlaneGeometry."),super(e,t,n,r)}}class ZM extends JA{constructor(e,t,n,r){console.warn("THREE.PolyhedronBufferGeometry has been renamed to THREE.PolyhedronGeometry."),super(e,t,n,r)}}class eR extends OE{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 tR extends DE{constructor(e,t){console.warn("THREE.ShapeBufferGeometry has been renamed to THREE.ShapeGeometry."),super(e,t)}}class nR extends LE{constructor(e,t,n,r,i,o,s){console.warn("THREE.SphereBufferGeometry has been renamed to THREE.SphereGeometry."),super(e,t,n,r,i,o,s)}}class rR extends kE{constructor(e,t){console.warn("THREE.TetrahedronBufferGeometry has been renamed to THREE.TetrahedronGeometry."),super(e,t)}}class iR extends BE{constructor(e,t,n,r,i){console.warn("THREE.TorusBufferGeometry has been renamed to THREE.TorusGeometry."),super(e,t,n,r,i)}}class oR extends zE{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 sR extends FE{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:lf}})),"undefined"!=typeof window&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=lf);const aR=()=>{let e=!1;if("undefined"==typeof window||"undefined"==typeof navigator)return e;if("maxTouchPoints"in navigator)e=navigator.maxTouchPoints>0;else if("msMaxTouchPoints"in navigator)e=navigator.msMaxTouchPoints>0;else{const n=window&&"matchMedia"in window&&matchMedia("(pointer:coarse)");if(n&&"(pointer:coarse)"===n.media)e=!!n.matches;else if("orientation"in window)e=!0;else{var t=null===navigator||void 0===navigator?void 0:navigator.userAgent;e=/\b(BlackBerry|webOS|iPhone|IEMobile)\b/i.test(t)||/\b(Android|Windows Phone|iPad|iPod)\b/i.test(t)}}return e},lR=/^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$_:;|,~+=\{\}\[\]%^&*-]).{8,}$/,cR=/^\w+([.-]?[+]?\w+)*@\w+([.-]?\w+)*(\.\w{2,})+$/,uR=/^(?!.*\.\.)(?!.*\.$)[^\W][\w.+-]{2,32}$/;function dR(e,t){const n=(0,c.useRef)(),r=(0,c.useRef)(null);return(0,c.useEffect)((()=>(r.current=e,()=>{r.current=null})),[e]),(0,c.useEffect)((()=>()=>{clearTimeout(n.current)}),[]),(0,c.useMemo)((()=>(...e)=>{clearTimeout(n.current),n.current=window.setTimeout((()=>{r.current&&r.current(...e)}),t)}),[t])}const hR=e=>e.slice(0,e.length/2).trim().toLowerCase()===e.slice(e.length/2+1).trim().toLowerCase()?e.slice(0,e.length/2):e,pR=e=>e.replaceAll(/[^\p{L}\p{N}\p{P}\p{Z}^$\n]/gu,"").trim(),mR=e=>e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=e.replaceAll(/```*?```/g,"")).replaceAll(/```[\s\S]*?```/g,"")).replaceAll(/`[^`]*`/g,"")).replaceAll(/!\[[^\]]*\]\([^)]*\)/g,"")).replaceAll(/\[([^\]]*)\]\([^)]*\)/g,"$1")).replaceAll(/^> /gm,"")).replaceAll(/^#+ /gm,"")).replaceAll(/[*_]/g,"")).replaceAll(/---/g,"")).replaceAll(/~~/g,"")).replaceAll(/^\s*[-*+] /gm,"")).replaceAll(/^\s*\d+\.\s+/gm,"")).replaceAll(/^\|.*\|$/gm,"")).replaceAll(/\$\$[\s\S]*?\$\$/g,"")).replaceAll(/\$[\s\S]*?\$/g,"")).replaceAll(/\\\([\s\S]*?\\\)/g,"")).replaceAll(/\\\[[\s\S]*?\\\]/g,"")).replaceAll(/\s+/g," ").trim(),fR=e=>{const t=/<output.*?<\/output>/gs;if(!t.test(e))return e;const n=e.replace(t,"");return fR(n)},gR=e=>{const t=document.createElement("div");return t.innerHTML=e,t.textContent||""},vR=e=>{const t=document.createElement("textarea");return t.textContent=e,t.innerHTML};function yR(e){try{e=encodeURI(e).replace(/%25/g,"%")}catch(e){return null}return e}const _R={startup:{elements:[".memori-chat--bubble-content"]},options:{processHtmlClass:"memori-chat--bubble-content"},tex:{inlineMath:[["$","$"],["\\$","\\$"]],displayMath:[["$$","$$"]],processEscapes:!0},asciimath:{fixphi:!0,displaystyle:!0,decimalsign:"."},skipStartupTypeset:!0,chtml:{displayAlign:"left"},svg:{fontCache:"global"}},SR=()=>{window.MathJax=_R,(()=>{const e=document.createElement("script");e.src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js",e.async=!0,e.id="mathjax-script",document.head.appendChild(e)})()};function bR(e){Object.values(e).forEach((e=>{e instanceof WE&&(e.roughness=.8,e.metalness=.1,e.shadowSide=2,e.map&&(e.map.anisotropy=16))}))}function xR(e){return!0===e.isSkinnedMesh}const CR=(e,t=!1)=>{try{return JSON.parse(e)}catch(n){return t?e:null}};c=o("85Hg2"),c=o("85Hg2");function wR(e,t){let[n,r]=(0,c.useState)(e),i=Dh(e);return Nh((()=>r(i.current)),[i,r,...t]),n}c=o("85Hg2");function AR(e){var t;if(e.type)return e.type;let n=null!=(t=e.as)?t:"button";return"string"==typeof n&&"button"===n.toLowerCase()?"button":void 0}function ER(e,t){let[n,r]=(0,c.useState)((()=>AR(e)));return Nh((()=>{r(AR(e))}),[e.type,e.as]),Nh((()=>{n||!t.current||t.current instanceof HTMLButtonElement&&!t.current.hasAttribute("type")&&r("button")}),[n,t]),n}c=o("85Hg2");function IR({container:e,accept:t,walk:n,enabled:r=!0}){let i=(0,c.useRef)(t),o=(0,c.useRef)(n);(0,c.useEffect)((()=>{i.current=t,o.current=n}),[t,n]),Nh((()=>{if(!e||!r)return;let t=bp(e);if(!t)return;let n=i.current,s=o.current,a=Object.assign((e=>n(e)),{acceptNode:n}),l=t.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,a,!1);for(;l.nextNode();)s(l.currentNode)}),[e,r,i,o])}var TR=(e=>(e[e.First=0]="First",e[e.Previous=1]="Previous",e[e.Next=2]="Next",e[e.Last=3]="Last",e[e.Specific=4]="Specific",e[e.Nothing=5]="Nothing",e))(TR||{});function MR(e,t){let n=t.resolveItems();if(n.length<=0)return null;let r=t.resolveActiveIndex(),i=null!=r?r:-1,o=(()=>{switch(e.focus){case 0:return n.findIndex((e=>!t.resolveDisabled(e)));case 1:{let e=n.slice().reverse().findIndex(((e,n,r)=>!(-1!==i&&r.length-n-1>=i)&&!t.resolveDisabled(e)));return-1===e?e:n.length-1-e}case 2:return n.findIndex(((e,n)=>!(n<=i)&&!t.resolveDisabled(e)));case 3:{let e=n.slice().reverse().findIndex((e=>!t.resolveDisabled(e)));return-1===e?e:n.length-1-e}case 4:return n.findIndex((n=>t.resolveId(n)===e.id));case 5:return null;default:!function(e){throw new Error("Unexpected object: "+e)}(e)}})();return-1===o?r:o}function RR(e={},t=null,n=[]){for(let[r,i]of Object.entries(e))NR(n,PR(t,r),i);return n}function PR(e,t){return e?e+"["+t+"]":t}function NR(e,t,n){if(Array.isArray(n))for(let[r,i]of n.entries())NR(e,PR(t,r.toString()),i);else n instanceof Date?e.push([t,n.toISOString()]):"boolean"==typeof n?e.push([t,n?"1":"0"]):"string"==typeof n?e.push([t,n]):"number"==typeof n?e.push([t,`${n}`]):null==n?e.push([t,""]):RR(n,t,e)}function OR(e){var t;let n=null!=(t=null==e?void 0:e.form)?t:e.closest("form");if(n)for(let e of n.elements)if("INPUT"===e.tagName&&"submit"===e.type||"BUTTON"===e.tagName&&"submit"===e.type||"INPUT"===e.nodeName&&"image"===e.type)return void e.click()}c=o("85Hg2");function DR(e,t,n){let[r,i]=(0,c.useState)(n),o=void 0!==e,s=(0,c.useRef)(o),a=(0,c.useRef)(!1),l=(0,c.useRef)(!1);return!o||s.current||a.current?!o&&s.current&&!l.current&&(l.current=!0,s.current=o,console.error("A component is changing from controlled to uncontrolled. This may be caused by the value changing from a defined value to undefined, which should not happen.")):(a.current=!0,s.current=o,console.error("A component is changing from uncontrolled to controlled. This may be caused by the value changing from undefined to a defined value, which should not happen.")),[o?e:r,Bh((e=>(o||i(e),null==t?void 0:t(e))))]}var LR=(e=>(e[e.Open=0]="Open",e[e.Closed=1]="Closed",e))(LR||{}),kR=(e=>(e[e.Single=0]="Single",e[e.Multi=1]="Multi",e))(kR||{}),BR=(e=>(e[e.Pointer=0]="Pointer",e[e.Other=1]="Other",e))(BR||{}),zR=(e=>(e[e.OpenCombobox=0]="OpenCombobox",e[e.CloseCombobox=1]="CloseCombobox",e[e.GoToOption=2]="GoToOption",e[e.RegisterOption=3]="RegisterOption",e[e.UnregisterOption=4]="UnregisterOption",e[e.RegisterLabel=5]="RegisterLabel",e))(zR||{});function FR(e,t=(e=>e)){let n=null!==e.activeOptionIndex?e.options[e.activeOptionIndex]:null,r=Op(t(e.options.slice()),(e=>e.dataRef.current.domRef.current)),i=n?r.indexOf(n):null;return-1===i&&(i=null),{options:r,activeOptionIndex:i}}let UR={1:e=>e.dataRef.current.disabled||1===e.comboboxState?e:{...e,activeOptionIndex:null,comboboxState:1},0(e){if(e.dataRef.current.disabled||0===e.comboboxState)return e;let t=e.activeOptionIndex,{isSelected:n}=e.dataRef.current,r=e.options.findIndex((e=>n(e.dataRef.current.value)));return-1!==r&&(t=r),{...e,comboboxState:0,activeOptionIndex:t}},2(e,t){var n;if(e.dataRef.current.disabled||e.dataRef.current.optionsRef.current&&!e.dataRef.current.optionsPropsRef.current.static&&1===e.comboboxState)return e;let r=FR(e);if(null===r.activeOptionIndex){let e=r.options.findIndex((e=>!e.dataRef.current.disabled));-1!==e&&(r.activeOptionIndex=e)}let i=MR(t,{resolveItems:()=>r.options,resolveActiveIndex:()=>r.activeOptionIndex,resolveId:e=>e.id,resolveDisabled:e=>e.dataRef.current.disabled});return{...e,...r,activeOptionIndex:i,activationTrigger:null!=(n=t.trigger)?n:1}},3:(e,t)=>{let n={id:t.id,dataRef:t.dataRef},r=FR(e,(e=>[...e,n]));null===e.activeOptionIndex&&e.dataRef.current.isSelected(t.dataRef.current.value)&&(r.activeOptionIndex=r.options.indexOf(n));let i={...e,...r,activationTrigger:1};return e.dataRef.current.__demoMode&&void 0===e.dataRef.current.value&&(i.activeOptionIndex=0),i},4:(e,t)=>{let n=FR(e,(e=>{let n=e.findIndex((e=>e.id===t.id));return-1!==n&&e.splice(n,1),e}));return{...e,...n,activationTrigger:1}},5:(e,t)=>({...e,labelId:t.id})},jR=(0,c.createContext)(null);function GR(e){let t=(0,c.useContext)(jR);if(null===t){let t=new Error(`<${e} /> is missing a parent <Combobox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(t,GR),t}return t}jR.displayName="ComboboxActionsContext";let HR=(0,c.createContext)(null);function VR(e){let t=(0,c.useContext)(HR);if(null===t){let t=new Error(`<${e} /> is missing a parent <Combobox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(t,VR),t}return t}function WR(e,t){return vh(t.type,UR,e,t)}HR.displayName="ComboboxDataContext";let qR=c.Fragment;let JR=wh((function(e,n){let{value:r,defaultValue:i,onChange:o,name:s,by:a=((e,t)=>e===t),disabled:l=!1,__demoMode:u=!1,nullable:d=!1,multiple:h=!1,...p}=e,[m,f]=DR(r,o,i),[g,v]=(0,c.useReducer)(WR,{dataRef:(0,c.createRef)(),comboboxState:u?0:1,options:[],activeOptionIndex:null,activationTrigger:1,labelId:null}),y=(0,c.useRef)(!1),_=(0,c.useRef)({static:!1,hold:!1}),S=(0,c.useRef)(null),b=(0,c.useRef)(null),x=(0,c.useRef)(null),C=(0,c.useRef)(null),w=Bh("string"==typeof a?(e,t)=>{let n=a;return(null==e?void 0:e[n])===(null==t?void 0:t[n])}:a),A=(0,c.useCallback)((e=>vh(E.mode,{1:()=>m.some((t=>w(t,e))),0:()=>w(m,e)})),[m]),E=(0,c.useMemo)((()=>({...g,optionsPropsRef:_,labelRef:S,inputRef:b,buttonRef:x,optionsRef:C,value:m,disabled:l,mode:h?1:0,get activeOptionIndex(){if(y.current&&null===g.activeOptionIndex&&g.options.length>0){let e=g.options.findIndex((e=>!e.dataRef.current.disabled));if(-1!==e)return e}return g.activeOptionIndex},compare:w,isSelected:A,nullable:d,__demoMode:u})),[m,l,h,d,u,g]);Nh((()=>{g.dataRef.current=E}),[E]),hm([E.buttonRef,E.inputRef,E.optionsRef],(()=>v({type:1})),0===E.comboboxState);let I=(0,c.useMemo)((()=>({open:0===E.comboboxState,disabled:l,activeIndex:E.activeOptionIndex,activeOption:null===E.activeOptionIndex?null:E.options[E.activeOptionIndex].dataRef.current.value,value:m})),[E,l,m]),T=Bh((e=>{let t=E.options.find((t=>t.id===e));!t||L(t.dataRef.current.value)})),M=Bh((()=>{if(null!==E.activeOptionIndex){let{dataRef:e,id:t}=E.options[E.activeOptionIndex];L(e.current.value),v({type:2,focus:TR.Specific,id:t})}})),R=Bh((()=>{v({type:0}),y.current=!0})),P=Bh((()=>{v({type:1}),y.current=!1})),N=Bh(((e,t,n)=>(y.current=!1,e===TR.Specific?v({type:2,focus:TR.Specific,id:t,trigger:n}):v({type:2,focus:e,trigger:n})))),O=Bh(((e,t)=>(v({type:3,id:e,dataRef:t}),()=>v({type:4,id:e})))),D=Bh((e=>(v({type:5,id:e}),()=>v({type:5,id:null})))),L=Bh((e=>vh(E.mode,{0:()=>null==f?void 0:f(e),1(){let t=E.value.slice(),n=t.findIndex((t=>w(t,e)));return-1===n?t.push(e):t.splice(n,1),null==f?void 0:f(t)}}))),k=(0,c.useMemo)((()=>({onChange:L,registerOption:O,registerLabel:D,goToOption:N,closeCombobox:P,openCombobox:R,selectActiveOption:M,selectOption:T})),[]),B=null===n?{}:{ref:n};return t(c).createElement(jR.Provider,{value:k},t(c).createElement(HR.Provider,{value:E},t(c).createElement(Rh,{value:vh(E.comboboxState,{0:Th.Open,1:Th.Closed})},null!=s&&null!=m&&RR({[s]:m}).map((([e,n])=>t(c).createElement(Sp,{features:_p.Hidden,...Ah({key:e,as:"input",type:"hidden",hidden:!0,readOnly:!0,name:e,value:n})}))),bh({ourProps:B,theirProps:p,slot:I,defaultTag:qR,name:"Combobox"}))))})),KR=wh((function(e,t){var n,r;let{value:i,onChange:o,displayValue:s,type:a="text",...l}=e,u=VR("Combobox.Input"),d=GR("Combobox.Input"),h=Uh(u.inputRef,t),p=`headlessui-combobox-input-${yp()}`,m=Yh(),f=!1;jp((([e,t],[n,r])=>{!u.inputRef.current||(0===r&&1===t?function(e){var t;let n=u.inputRef.current;if(!n||n.value===e)return;let r=Object.getOwnPropertyDescriptor(n.constructor.prototype,"value");null==(t=null==r?void 0:r.set)||t.call(n,e),f=!0,n.dispatchEvent(new Event("input",{bubbles:!0})),n.value=e,f=!1}(e):e!==n&&(u.inputRef.current.value=e))}),[(0,c.useMemo)((()=>{var e;return"function"==typeof s?null!=(e=s(u.value))?e:"":"string"==typeof u.value?u.value:""}),[u.value]),u.comboboxState]);let g=(0,c.useRef)(!1),v=Bh((()=>{g.current=!0})),y=Bh((()=>{setTimeout((()=>{g.current=!1}))})),_=Bh((e=>{switch(e.key){case pp.Backspace:case pp.Delete:if(0!==u.mode||!u.nullable)return;let t=e.currentTarget;m.requestAnimationFrame((()=>{""===t.value&&(d.onChange(null),u.optionsRef.current&&(u.optionsRef.current.scrollTop=0),d.goToOption(TR.Nothing))}));break;case pp.Enter:if(0!==u.comboboxState||g.current)return;if(e.preventDefault(),e.stopPropagation(),null===u.activeOptionIndex)return void d.closeCombobox();d.selectActiveOption(),0===u.mode&&d.closeCombobox();break;case pp.ArrowDown:return e.preventDefault(),e.stopPropagation(),vh(u.comboboxState,{0:()=>{d.goToOption(TR.Next)},1:()=>{d.openCombobox()}});case pp.ArrowUp:return e.preventDefault(),e.stopPropagation(),vh(u.comboboxState,{0:()=>{d.goToOption(TR.Previous)},1:()=>{d.openCombobox(),m.nextFrame((()=>{u.value||d.goToOption(TR.Last)}))}});case pp.Home:case pp.PageUp:return e.preventDefault(),e.stopPropagation(),d.goToOption(TR.First);case pp.End:case pp.PageDown:return e.preventDefault(),e.stopPropagation(),d.goToOption(TR.Last);case pp.Escape:return 0!==u.comboboxState?void 0:(e.preventDefault(),u.optionsRef.current&&!u.optionsPropsRef.current.static&&e.stopPropagation(),d.closeCombobox());case pp.Tab:if(0!==u.comboboxState)return;0===u.mode&&d.selectActiveOption(),d.closeCombobox()}})),S=Bh((e=>{f||d.openCombobox(),null==o||o(e)})),b=wR((()=>{if(u.labelId)return[u.labelId].join(" ")}),[u.labelId]),x=(0,c.useMemo)((()=>({open:0===u.comboboxState,disabled:u.disabled})),[u]);return bh({ourProps:{ref:h,id:p,role:"combobox",type:a,"aria-controls":null==(n=u.optionsRef.current)?void 0:n.id,"aria-expanded":u.disabled?void 0:0===u.comboboxState,"aria-activedescendant":null===u.activeOptionIndex||null==(r=u.options[u.activeOptionIndex])?void 0:r.id,"aria-multiselectable":1===u.mode||void 0,"aria-labelledby":b,disabled:u.disabled,onCompositionStart:v,onCompositionEnd:y,onKeyDown:_,onChange:S},theirProps:l,slot:x,defaultTag:"input",name:"Combobox.Input"})})),YR=wh((function(e,t){var n;let r=VR("Combobox.Button"),i=GR("Combobox.Button"),o=Uh(r.buttonRef,t),s=`headlessui-combobox-button-${yp()}`,a=Yh(),l=Bh((e=>{switch(e.key){case pp.ArrowDown:return e.preventDefault(),e.stopPropagation(),1===r.comboboxState&&i.openCombobox(),a.nextFrame((()=>{var e;return null==(e=r.inputRef.current)?void 0:e.focus({preventScroll:!0})}));case pp.ArrowUp:return e.preventDefault(),e.stopPropagation(),1===r.comboboxState&&(i.openCombobox(),a.nextFrame((()=>{r.value||i.goToOption(TR.Last)}))),a.nextFrame((()=>{var e;return null==(e=r.inputRef.current)?void 0:e.focus({preventScroll:!0})}));case pp.Escape:return 0!==r.comboboxState?void 0:(e.preventDefault(),r.optionsRef.current&&!r.optionsPropsRef.current.static&&e.stopPropagation(),i.closeCombobox(),a.nextFrame((()=>{var e;return null==(e=r.inputRef.current)?void 0:e.focus({preventScroll:!0})})));default:return}})),u=Bh((e=>{if(mp(e.currentTarget))return e.preventDefault();0===r.comboboxState?i.closeCombobox():(e.preventDefault(),i.openCombobox()),a.nextFrame((()=>{var e;return null==(e=r.inputRef.current)?void 0:e.focus({preventScroll:!0})}))})),d=wR((()=>{if(r.labelId)return[r.labelId,s].join(" ")}),[r.labelId,s]),h=(0,c.useMemo)((()=>({open:0===r.comboboxState,disabled:r.disabled,value:r.value})),[r]),p=e;return bh({ourProps:{ref:o,id:s,type:ER(e,r.buttonRef),tabIndex:-1,"aria-haspopup":!0,"aria-controls":null==(n=r.optionsRef.current)?void 0:n.id,"aria-expanded":r.disabled?void 0:0===r.comboboxState,"aria-labelledby":d,disabled:r.disabled,onClick:u,onKeyDown:l},theirProps:p,slot:h,defaultTag:"button",name:"Combobox.Button"})})),XR=wh((function(e,t){let n=VR("Combobox.Label"),r=`headlessui-combobox-label-${yp()}`,i=GR("Combobox.Label"),o=Uh(n.labelRef,t);Nh((()=>i.registerLabel(r)),[r]);let s=Bh((()=>{var e;return null==(e=n.inputRef.current)?void 0:e.focus({preventScroll:!0})})),a=(0,c.useMemo)((()=>({open:0===n.comboboxState,disabled:n.disabled})),[n]);return bh({ourProps:{ref:o,id:r,onClick:s},theirProps:e,slot:a,defaultTag:"label",name:"Combobox.Label"})})),QR=_h.RenderStrategy|_h.Static,$R=wh((function(e,t){var n;let{hold:r=!1,...i}=e,o=VR("Combobox.Options"),s=Uh(o.optionsRef,t),a=`headlessui-combobox-options-${yp()}`,l=Mh(),u=null!==l?l===Th.Open:0===o.comboboxState;Nh((()=>{var t;o.optionsPropsRef.current.static=null!=(t=e.static)&&t}),[o.optionsPropsRef,e.static]),Nh((()=>{o.optionsPropsRef.current.hold=r}),[o.optionsPropsRef,r]),IR({container:o.optionsRef.current,enabled:0===o.comboboxState,accept:e=>"option"===e.getAttribute("role")?NodeFilter.FILTER_REJECT:e.hasAttribute("role")?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT,walk(e){e.setAttribute("role","none")}});let d=wR((()=>{var e,t;return null!=(t=o.labelId)?t:null==(e=o.buttonRef.current)?void 0:e.id}),[o.labelId,o.buttonRef.current]),h=(0,c.useMemo)((()=>({open:0===o.comboboxState})),[o]);return bh({ourProps:{"aria-activedescendant":null===o.activeOptionIndex||null==(n=o.options[o.activeOptionIndex])?void 0:n.id,"aria-labelledby":d,role:"listbox",id:a,ref:s},theirProps:i,slot:h,defaultTag:"ul",features:QR,visible:u,name:"Combobox.Options"})})),ZR=wh((function(e,t){var n,r;let{disabled:i=!1,value:o,...s}=e,a=VR("Combobox.Option"),l=GR("Combobox.Option"),u=`headlessui-combobox-option-${yp()}`,d=null!==a.activeOptionIndex&&a.options[a.activeOptionIndex].id===u,h=a.isSelected(o),p=(0,c.useRef)(null),m=Dh({disabled:i,value:o,domRef:p,textValue:null==(r=null==(n=p.current)?void 0:n.textContent)?void 0:r.toLowerCase()}),f=Uh(t,p),g=Bh((()=>l.selectOption(u)));Nh((()=>l.registerOption(u,m)),[m,u]);let v=(0,c.useRef)(!a.__demoMode);Nh((()=>{if(!a.__demoMode)return;let e=Hh();return e.requestAnimationFrame((()=>{v.current=!0})),e.dispose}),[]),Nh((()=>{if(0!==a.comboboxState||!d||!v.current||0===a.activationTrigger)return;let e=Hh();return e.requestAnimationFrame((()=>{var e,t;null==(t=null==(e=p.current)?void 0:e.scrollIntoView)||t.call(e,{block:"nearest"})})),e.dispose}),[p,d,a.comboboxState,a.activationTrigger,a.activeOptionIndex]);let y=Bh((e=>{if(i)return e.preventDefault();g(),0===a.mode&&l.closeCombobox()})),_=Bh((()=>{if(i)return l.goToOption(TR.Nothing);l.goToOption(TR.Specific,u)})),S=Bh((()=>{i||d||l.goToOption(TR.Specific,u,0)})),b=Bh((()=>{i||!d||a.optionsPropsRef.current.hold||l.goToOption(TR.Nothing)})),x=(0,c.useMemo)((()=>({active:d,selected:h,disabled:i})),[d,h,i]);return bh({ourProps:{id:u,ref:f,role:"option",tabIndex:!0===i?void 0:-1,"aria-disabled":!0===i||void 0,"aria-selected":h,disabled:void 0,onClick:y,onFocus:_,onPointerMove:S,onMouseMove:S,onPointerLeave:b,onMouseLeave:b},theirProps:s,slot:x,defaultTag:"li",name:"Combobox.Option"})})),eP=Object.assign(JR,{Input:KR,Button:YR,Label:XR,Options:$R,Option:ZR});const tP=({center:e,size:n})=>{const r=Fm();return(0,c.useEffect)((()=>{const i=new(t(Um).Circle)(e,n),o=r.layerContainer||r.map;return o.addLayer(i),()=>{o.removeLayer(i)}})),null},nP=({center:e,uncertainty:t})=>{const[n,r]=(0,c.useState)(!1),i=sf(),o=(0,c.useCallback)((()=>{let n=void 0!==t?Math.round(Math.log2(1e7/t)):i.getZoom();i.setView(e,n)}),[e,t,i]);return(0,c.useEffect)((()=>{n||(o(),r(!0))}),[]),(0,c.useEffect)((()=>{o()}),[e,t,o]),null};let rP=t(Um).icon({iconUrl:"https://unpkg.com/leaflet@1.9.4/dist/images/marker-icon.png",shadowUrl:"https://unpkg.com/leaflet@1.9.4/dist/images/marker-shadow.png",iconSize:[25,41],iconAnchor:[12.5,20.5],shadowAnchor:[12.5,20.5]});t(Um).Marker.prototype.options.icon=rP;const iP=e=>{let t="Position";return(null==e?void 0:e.address)?t=[e.address.village||e.address.suburb,e.address.town||e.address.city||e.address.county||e.address.state,e.address.country].filter(Boolean).filter(((e,t,n)=>n.indexOf(e)===t)).join(", "):(null==e?void 0:e.display_name)&&(t=e.display_name),t};var oP=({venue:e,setVenue:n,showUncertainty:r=!1,showGpsButton:i=!0,saveAndClose:o})=>{var a,l,u;const{t:d}=Ie(),[h,p]=(0,c.useState)(!1),[m,f]=(0,c.useState)(!1),[g,v]=(0,c.useState)(!1),[y,_]=(0,c.useState)(""),[S,b]=(0,c.useState)([]),x=dR((async e=>{v(!0);try{let t=await fetch(`https://nominatim.openstreetmap.org/search?q=${e}&format=jsonv2&limit=5&addressdetails=1`),n=await t.json();b(n)}catch(e){console.error(e)}finally{v(!1)}}),1e3);return(0,c.useEffect)((()=>{p(!0)}),[]),(0,c.useEffect)((()=>{const e=document.createElement("link");return e.href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css",e.rel="stylesheet",e.integrity="sha256-p4NxAoJBhIIN+hmNHrzRCf9tD/miZyoHS5obTRR9BMY=",e.crossOrigin="",document.head.appendChild(e),()=>{document.head.removeChild(e)}}),[]),(0,s.jsxs)("fieldset",{className:"memori--venue-widget",children:[(0,s.jsx)("legend",{className:"sr-only",children:"Venue"}),(0,s.jsxs)("div",{className:"memori--venue-widget__form-item",children:[(0,s.jsx)("div",{className:"memori--venue-widget__geosuggest",children:m?(0,s.jsx)("p",{children:d("write_and_speak.updatingPosition")}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"memori--venue-widget-search",children:(0,s.jsxs)(eP,{value:(null==e?void 0:e.latitude)&&(null==e?void 0:e.longitude)?{place_id:0,lat:null==e?void 0:e.latitude,lon:null==e?void 0:e.longitude,display_name:null==e?void 0:e.placeName}:void 0,onChange:e=>{console.log(e);const t=iP(e);n({latitude:e.lat,longitude:e.lon,placeName:t,uncertainty:(null==e?void 0:e.boundingbox)?Lm(e.boundingbox):2})},children:[(0,s.jsx)(eP.Input,{className:"memori--venue-widget-search--input",displayValue:e=>e?iP(e):"",placeholder:d("searchVenue"),onChange:e=>{return t=e.target.value,_(t),void x(t);var t}}),(g||S.length>0||0===S.length&&""!==y)&&(0,s.jsx)(dp,{as:c.Fragment,leave:"transition ease-in duration-100",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:(0,s.jsx)(eP.Options,{className:"memori--venue-widget-search--options",children:g?(0,s.jsx)(Tm,{spinning:!0,children:(0,s.jsxs)("div",{className:"memori--venue-widget-search--option memori--venue-widget-search--option-centered",children:[d("loading"),"..."]})}):0===S.length&&""!==y?(0,s.jsx)("div",{className:"memori--venue-widget-search--option memori--venue-widget-search--option-centered",children:d("nothingFound")}):null==S?void 0:S.map((e=>(0,s.jsx)(eP.Option,{as:c.Fragment,value:e,children:({active:n,selected:r})=>(0,s.jsx)("li",{className:t(Is)("memori--venue-widget-search--option",{"memori--venue-widget-search--option-active":n,"memori--venue-widget-search--option-selected":r}),children:e.display_name})},e.place_id)))})})]})}),i&&(0,s.jsx)(Mm,{className:"memori--venue-widget__gps-button",primary:!0,loading:m,onClick:()=>{f(!0),(async()=>{f(!0),navigator.geolocation.getCurrentPosition((async e=>{let r={latitude:e.coords.latitude,longitude:e.coords.longitude,placeName:"Position",uncertainty:e.coords.accuracy/1e3};try{const t=await fetch(`https://nominatim.openstreetmap.org/reverse?lat=${e.coords.latitude}&lon=${e.coords.longitude}&format=jsonv2&addressdetails=1`),i=await t.json(),s=iP(i);r={latitude:e.coords.latitude,longitude:e.coords.longitude,placeName:s,uncertainty:e.coords.accuracy/1e3},n(r)}catch(e){let i=e;console.error("[POSITION ERROR]",i),(null==i?void 0:i.message)&&t(rd).error(i.message),n(r)}finally{o&&o(r)}f(!1)}),(e=>{console.error("[POSITION ERROR]",e),t(rd).error(e.message),f(!1)}))})()},children:d("write_and_speak.useMyPosition")})]})}),(0,s.jsx)("div",{children:(0,s.jsx)(Mm,{outlined:!0,className:"memori--venue-widget__no-location-button",onClick:()=>{let e={latitude:0,longitude:0,placeName:"Position",uncertainty:0};n(e),o&&o(e)},children:d("write_and_speak.dontWantToProvidePosition")})}),r&&(0,s.jsxs)("label",{className:"memori--venue-widget__select-label",children:[(0,s.jsxs)("span",{children:[d("uncertain"),": "]}),(0,s.jsxs)("select",{className:"memori-select--button memori--venue-widget__uncertainty",value:parseFloat((null!==(a=null==e?void 0:e.uncertainty)&&void 0!==a?a:0).toFixed(2)),disabled:!(e&&e.placeName&&e.latitude&&e.longitude),onChange:t=>{n({...e,uncertainty:parseFloat(t.target.value)})},children:[(null==e?void 0:e.uncertainty)&&![0,1,2,5,10,20,50,100].includes(e.uncertainty)&&(0,s.jsxs)("option",{value:e.uncertainty,children:[e.uncertainty," Km"]}),(0,s.jsx)("option",{value:0,children:d("exactPosition")}),(0,s.jsx)("option",{value:1,children:"1 km"}),(0,s.jsx)("option",{value:2,children:"2 km"}),(0,s.jsx)("option",{value:5,children:"5 km"}),(0,s.jsx)("option",{value:10,children:"10 km"}),(0,s.jsx)("option",{value:20,children:"20 km"}),(0,s.jsx)("option",{value:50,children:"50 km"}),(0,s.jsx)("option",{value:100,children:"100 km"})]})]})]}),(0,s.jsxs)("div",{className:"memori--venue-widget__form-item",children:[(null==e?void 0:e.placeName)&&"Position"!==e.placeName&&(0,s.jsxs)("p",{className:"memori--venue--widget__place-name",children:[(0,s.jsx)("strong",{children:d("venue")}),": ",e.placeName]}),(0,s.jsx)("div",{className:"memori--venue-widget__map",children:h&&(0,s.jsxs)(Hm,{className:"memori--venue-widget__map",center:(null==e?void 0:e.latitude)&&(null==e?void 0:e.longitude)?[e.latitude,e.longitude]:[44.66579,11.48823],zoom:13,scrollWheelZoom:!0,children:[(0,s.jsx)(of,{attribution:'© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',url:"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"}),(0,s.jsx)(nP,{center:(null==e?void 0:e.latitude)&&(null==e?void 0:e.longitude)?[e.latitude,e.longitude]:[44.66579,11.48823],uncertainty:1e3*(null!==(l=null==e?void 0:e.uncertainty)&&void 0!==l?l:0)}),(null==e?void 0:e.latitude)&&(null==e?void 0:e.longitude)&&(0,s.jsx)(tf,{position:[e.latitude,e.longitude],icon:rP,children:(0,s.jsx)(nf,{children:null!==(u=e.placeName)&&void 0!==u?u:""})}),(null==e?void 0:e.latitude)&&(null==e?void 0:e.longitude)&&void 0!==(null==e?void 0:e.uncertainty)&&(0,s.jsx)(tP,{center:[e.latitude,e.longitude],size:1e3*e.uncertainty})]})})]})]})};var sP=({memori:e,open:t,onClose:n,venue:r,setVenue:i})=>{const{t:o}=Ie();return(0,s.jsxs)(Om,{className:"memori-position-drawer",open:t,onClose:()=>n(r),title:o("widget.position")||"Position",animated:!1,children:[(0,s.jsx)("p",{children:o("write_and_speak.requirePositionHelp",{name:e.name})}),(0,s.jsx)(oP,{venue:r,setVenue:i,showUncertainty:!1,saveAndClose:e=>{i(e),n(e)}})]})};c=o("85Hg2"),c=o("85Hg2");var aP=({open:e=!1,onClose:n,className:r,title:i,description:o,children:a,footer:l,loading:u=!1,closable:d=!0,width:h="100%",widthMd:p="100%"})=>{const{t:m}=Ie();return(0,s.jsx)(dp,{appear:!0,show:e,as:t(c).Fragment,children:(0,s.jsxs)(Em,{open:e,onClose:n,className:t(Is)("memori-modal",r),children:[(0,s.jsx)(dp.Child,{as:t(c).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-modal--backdrop"})}),(0,s.jsx)("div",{className:"memori-modal--container",children:(0,s.jsx)("div",{className:"memori-modal--container-scrollable",children:(0,s.jsx)(dp.Child,{as:t(c).Fragment,enter:"ease-out duration-300",enterFrom:"opacity-0 scale-95",enterTo:"opacity-100 scale-100",leave:"ease-in duration-200",leaveFrom:"opacity-100 scale-100",leaveTo:"opacity-0 scale-95",children:(0,s.jsxs)(Em.Panel,{className:"memori-modal--panel",children:[(0,s.jsx)("style",{dangerouslySetInnerHTML:{__html:`\n .memori-modal--panel {\n --memori-modal--width: ${h};\n --memori-modal--width-md: ${p};\n }\n `}}),d&&(0,s.jsx)("div",{className:"memori-modal--close",children:(0,s.jsx)(Mm,{ghost:!0,padded:!0,shape:"circle",icon:(0,s.jsx)(Rm,{}),title:m("close")||"Close",onClick:()=>n(!1)})}),(0,s.jsxs)(Tm,{spinning:u,children:[i&&(0,s.jsx)(Em.Title,{className:"memori-modal--title",children:i}),o&&(0,s.jsx)(Em.Description,{className:"memori-modal--description",children:o}),a,l&&(0,s.jsx)("div",{className:"memori-modal--footer",children:l})]})]})})})})]})})},lP=(c=o("85Hg2"),e=>"checkbox"===e.type),cP=e=>e instanceof Date,uP=e=>null==e;const dP=e=>"object"==typeof e;var hP=e=>!uP(e)&&!Array.isArray(e)&&dP(e)&&!cP(e),pP=e=>hP(e)&&e.target?lP(e.target)?e.target.checked:e.target.value:e,mP=(e,t)=>e.has((e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e)(t)),fP=e=>Array.isArray(e)?e.filter(Boolean):[],gP=e=>void 0===e,vP=(e,t,n)=>{if(!t||!hP(e))return n;const r=fP(t.split(/[,[\].]+?/)).reduce(((e,t)=>uP(e)?e:e[t]),e);return gP(r)||r===e?gP(e[t])?n:e[t]:r};const yP="blur",_P="focusout",SP="onBlur",bP="onChange",xP="onSubmit",CP="onTouched",wP="all",AP="max",EP="min",IP="maxLength",TP="minLength",MP="pattern",RP="required",PP="validate";t(c).createContext(null);var NP=(e,t,n,r=!0)=>{const i={defaultValues:t._defaultValues};for(const o in e)Object.defineProperty(i,o,{get:()=>{const i=o;return t._proxyFormState[i]!==wP&&(t._proxyFormState[i]=!r||wP),n&&(n[i]=!0),e[i]}});return i},OP=e=>hP(e)&&!Object.keys(e).length,DP=(e,t,n)=>{const{name:r,...i}=e;return OP(i)||Object.keys(i).length>=Object.keys(t).length||Object.keys(i).find((e=>t[e]===(!n||wP)))},LP=e=>Array.isArray(e)?e:[e];function kP(e){const n=t(c).useRef(e);n.current=e,t(c).useEffect((()=>{const t=!e.disabled&&n.current.subject.subscribe({next:n.current.callback});return()=>{t&&t.unsubscribe()}}),[e.disabled])}var BP=e=>"string"==typeof e,zP=(e,t,n,r)=>BP(e)?(r&&t.watch.add(e),vP(n,e)):Array.isArray(e)?e.map((e=>(r&&t.watch.add(e),vP(n,e)))):(t.watchAll=!!r,n),FP="undefined"!=typeof window&&void 0!==window.HTMLElement&&"undefined"!=typeof document;function UP(e){let t;const n=Array.isArray(e);if(e instanceof Date)t=new Date(e);else if(e instanceof Set)t=new Set(e);else{if(FP&&(e instanceof Blob||e instanceof FileList)||!n&&!hP(e))return e;if(t=n?[]:{},Array.isArray(e)||(e=>{const t=e.constructor&&e.constructor.prototype;return hP(t)&&t.hasOwnProperty("isPrototypeOf")})(e))for(const n in e)t[n]=UP(e[n]);else t=e}return t}var jP=(e,t,n,r,i)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[r]:i||!0}}:{},GP=e=>/^\w*$/.test(e),HP=e=>fP(e.replace(/["|']|\]/g,"").split(/\.|\[/));function VP(e,t,n){let r=-1;const i=GP(t)?[t]:HP(t),o=i.length,s=o-1;for(;++r<o;){const t=i[r];let o=n;if(r!==s){const n=e[t];o=hP(n)||Array.isArray(n)?n:isNaN(+i[r+1])?{}:[]}e[t]=o,e=e[t]}return e}const WP=(e,t,n)=>{for(const r of n||Object.keys(e)){const n=vP(e,r);if(n){const{_f:e,...r}=n;if(e&&t(e.name)){if(e.ref.focus){e.ref.focus();break}if(e.refs&&e.refs[0].focus){e.refs[0].focus();break}}else hP(r)&&WP(r,t)}}};var qP=(e,t,n)=>!n&&(t.watchAll||t.watch.has(e)||[...t.watch].some((t=>e.startsWith(t)&&/^\.\w+/.test(e.slice(t.length))))),JP=(e,t,n)=>{const r=fP(vP(e,n));return VP(r,"root",t[n]),VP(e,n,r),e},KP=e=>"boolean"==typeof e,YP=e=>"file"===e.type,XP=e=>"function"==typeof e,QP=e=>BP(e)||t(c).isValidElement(e),$P=e=>"radio"===e.type,ZP=e=>e instanceof RegExp;const eN={value:!1,isValid:!1},tN={value:!0,isValid:!0};var nN=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter((e=>e&&e.checked&&!e.disabled)).map((e=>e.value));return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!gP(e[0].attributes.value)?gP(e[0].value)||""===e[0].value?tN:{value:e[0].value,isValid:!0}:tN:eN}return eN};const rN={isValid:!1,value:null};var iN=e=>Array.isArray(e)?e.reduce(((e,t)=>t&&t.checked&&!t.disabled?{isValid:!0,value:t.value}:e),rN):rN;function oN(e,t,n="validate"){if(QP(e)||Array.isArray(e)&&e.every(QP)||KP(e)&&!e)return{type:n,message:QP(e)?e:"",ref:t}}var sN=e=>hP(e)&&!ZP(e)?e:{value:e,message:""},aN=async(e,t,n,r,i)=>{const{ref:o,refs:s,required:a,maxLength:l,minLength:c,min:u,max:d,pattern:h,validate:p,name:m,valueAsNumber:f,mount:g,disabled:v}=e._f;if(!g||v)return{};const y=s?s[0]:o,_=e=>{r&&y.reportValidity&&(y.setCustomValidity(KP(e)?"":e||""),y.reportValidity())},S={},b=$P(o),x=lP(o),C=b||x,w=(f||YP(o))&&!o.value||""===t||Array.isArray(t)&&!t.length,A=jP.bind(null,m,n,S),E=(e,t,n,r=IP,i=TP)=>{const s=e?t:n;S[m]={type:e?r:i,message:s,ref:o,...A(e?r:i,s)}};if(i?!Array.isArray(t)||!t.length:a&&(!C&&(w||uP(t))||KP(t)&&!t||x&&!nN(s).isValid||b&&!iN(s).isValid)){const{value:e,message:t}=QP(a)?{value:!!a,message:a}:sN(a);if(e&&(S[m]={type:RP,message:t,ref:y,...A(RP,t)},!n))return _(t),S}if(!(w||uP(u)&&uP(d))){let e,r;const i=sN(d),s=sN(u);if(uP(t)||isNaN(t)){const n=o.valueAsDate||new Date(t),a=e=>new Date((new Date).toDateString()+" "+e),l="time"==o.type,c="week"==o.type;BP(i.value)&&t&&(e=l?a(t)>a(i.value):c?t>i.value:n>new Date(i.value)),BP(s.value)&&t&&(r=l?a(t)<a(s.value):c?t<s.value:n<new Date(s.value))}else{const n=o.valueAsNumber||(t?+t:t);uP(i.value)||(e=n>i.value),uP(s.value)||(r=n<s.value)}if((e||r)&&(E(!!e,i.message,s.message,AP,EP),!n))return _(S[m].message),S}if((l||c)&&!w&&(BP(t)||i&&Array.isArray(t))){const e=sN(l),r=sN(c),i=!uP(e.value)&&t.length>e.value,o=!uP(r.value)&&t.length<r.value;if((i||o)&&(E(i,e.message,r.message),!n))return _(S[m].message),S}if(h&&!w&&BP(t)){const{value:e,message:r}=sN(h);if(ZP(e)&&!t.match(e)&&(S[m]={type:MP,message:r,ref:o,...A(MP,r)},!n))return _(r),S}if(p)if(XP(p)){const e=oN(await p(t),y);if(e&&(S[m]={...e,...A(PP,e.message)},!n))return _(e.message),S}else if(hP(p)){let e={};for(const r in p){if(!OP(e)&&!n)break;const i=oN(await p[r](t),y,r);i&&(e={...i,...A(r,i.message)},_(i.message),n&&(S[m]=e))}if(!OP(e)&&(S[m]={ref:y,...e},!n))return S}return _(!0),S};var lN=e=>({isOnSubmit:!e||e===xP,isOnBlur:e===SP,isOnChange:e===bP,isOnAll:e===wP,isOnTouch:e===CP});function cN(e){for(const t in e)if(!gP(e[t]))return!1;return!0}function uN(e,t){const n=GP(t)?[t]:HP(t),r=1==n.length?e:function(e,t){const n=t.slice(0,-1).length;let r=0;for(;r<n;)e=gP(e)?r++:e[t[r++]];return e}(e,n),i=n[n.length-1];let o;r&&delete r[i];for(let t=0;t<n.slice(0,-1).length;t++){let r,i=-1;const s=n.slice(0,-(t+1)),a=s.length-1;for(t>0&&(o=e);++i<s.length;){const t=s[i];r=r?r[t]:e[t],a===i&&(hP(r)&&OP(r)||Array.isArray(r)&&cN(r))&&(o?delete o[t]:delete e[t]),o=r}}return e}function dN(){let e=[];return{get observers(){return e},next:t=>{for(const n of e)n.next(t)},subscribe:t=>(e.push(t),{unsubscribe:()=>{e=e.filter((e=>e!==t))}}),unsubscribe:()=>{e=[]}}}var hN=e=>uP(e)||!dP(e);function pN(e,t){if(hN(e)||hN(t))return e===t;if(cP(e)&&cP(t))return e.getTime()===t.getTime();const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const i of n){const n=e[i];if(!r.includes(i))return!1;if("ref"!==i){const e=t[i];if(cP(n)&&cP(e)||hP(n)&&hP(e)||Array.isArray(n)&&Array.isArray(e)?!pN(n,e):n!==e)return!1}}return!0}var mN=e=>{const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},fN=e=>"select-multiple"===e.type,gN=e=>mN(e)&&e.isConnected,vN=e=>{for(const t in e)if(XP(e[t]))return!0;return!1};function yN(e,t={}){const n=Array.isArray(e);if(hP(e)||n)for(const n in e)Array.isArray(e[n])||hP(e[n])&&!vN(e[n])?(t[n]=Array.isArray(e[n])?[]:{},yN(e[n],t[n])):uP(e[n])||(t[n]=!0);return t}function _N(e,t,n){const r=Array.isArray(e);if(hP(e)||r)for(const r in e)Array.isArray(e[r])||hP(e[r])&&!vN(e[r])?gP(t)||hN(n[r])?n[r]=Array.isArray(e[r])?yN(e[r],[]):{...yN(e[r])}:_N(e[r],uP(t)?{}:t[r],n[r]):pN(e[r],t[r])?delete n[r]:n[r]=!0;return n}var SN=(e,t)=>_N(e,t,yN(t)),bN=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:r})=>gP(e)?e:t?""===e?NaN:e?+e:e:n&&BP(e)?new Date(e):r?r(e):e;function xN(e){const t=e.ref;if(!(e.refs?e.refs.every((e=>e.disabled)):t.disabled))return YP(t)?t.files:$P(t)?iN(e.refs).value:fN(t)?[...t.selectedOptions].map((({value:e})=>e)):lP(t)?nN(e.refs).value:bN(gP(t.value)?e.ref.value:t.value,e)}var CN=e=>gP(e)?e:ZP(e)?e.source:hP(e)?ZP(e.value)?e.value.source:e.value:e;function wN(e,t,n){const r=vP(e,n);if(r||GP(n))return{error:r,name:n};const i=n.split(".");for(;i.length;){const r=i.join("."),o=vP(t,r),s=vP(e,r);if(o&&!Array.isArray(o)&&n!==r)return{name:n};if(s&&s.type)return{name:r,error:s};i.pop()}return{name:n}}const AN={mode:xP,reValidateMode:bP,shouldFocusError:!0};function EN(e={}){let t,n={...AN,...e},r={submitCount:0,isDirty:!1,isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},errors:{}},i={},o=UP(n.defaultValues)||{},s=n.shouldUnregister?{}:UP(o),a={action:!1,mount:!1,watch:!1},l={mount:new Set,unMount:new Set,array:new Set,watch:new Set},c=0,u={};const d={isDirty:!1,dirtyFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},h={watch:dN(),array:dN(),state:dN()},p=lN(n.mode),m=lN(n.reValidateMode),f=n.criteriaMode===wP,g=async()=>{let e=!1;return d.isValid&&(e=n.resolver?OP((await S()).errors):await b(i,!0),e!==r.isValid&&(r.isValid=e,h.state.next({isValid:e}))),e},v=(e,t,n,r)=>{const l=vP(i,e);if(l){const i=vP(s,e,gP(n)?vP(o,e):n);gP(i)||r&&r.defaultChecked||t?VP(s,e,t?i:xN(l._f)):w(e,i),a.mount&&g()}},y=(e,t,n,i,s)=>{let a=!1,l=!1;const c={name:e};if(d.isDirty&&(l=r.isDirty,r.isDirty=c.isDirty=x(),a=l!==c.isDirty),d.dirtyFields&&(!n||i)){l=vP(r.dirtyFields,e);const n=pN(vP(o,e),t);n?uN(r.dirtyFields,e):VP(r.dirtyFields,e,!0),c.dirtyFields=r.dirtyFields,a=a||l!==!n}if(n){const t=vP(r.touchedFields,e);t||(VP(r.touchedFields,e,n),c.touchedFields=r.touchedFields,a=a||d.touchedFields&&t!==n)}return a&&s&&h.state.next(c),a?c:{}},_=(n,i,o,s)=>{const a=vP(r.errors,n),l=d.isValid&&KP(i)&&r.isValid!==i;var p;if(e.delayError&&o?(p=()=>((e,t)=>{VP(r.errors,e,t),h.state.next({errors:r.errors})})(n,o),t=e=>{clearTimeout(c),c=window.setTimeout(p,e)},t(e.delayError)):(clearTimeout(c),t=null,o?VP(r.errors,n,o):uN(r.errors,n)),(o?!pN(a,o):a)||!OP(s)||l){const e={...s,...l&&KP(i)?{isValid:i}:{},errors:r.errors,name:n};r={...r,...e},h.state.next(e)}u[n]--,d.isValidating&&!Object.values(u).some((e=>e))&&(h.state.next({isValidating:!1}),u={})},S=async e=>n.resolver?await n.resolver({...s},n.context,((e,t,n,r)=>{const i={};for(const n of e){const e=vP(t,n);e&&VP(i,n,e._f)}return{criteriaMode:n,names:[...e],fields:i,shouldUseNativeValidation:r}})(e||l.mount,i,n.criteriaMode,n.shouldUseNativeValidation)):{},b=async(e,t,i={valid:!0})=>{for(const o in e){const a=e[o];if(a){const{_f:e,...o}=a;if(e){const o=l.array.has(e.name),c=await aN(a,vP(s,e.name),f,n.shouldUseNativeValidation,o);if(c[e.name]&&(i.valid=!1,t))break;!t&&(vP(c,e.name)?o?JP(r.errors,c,e.name):VP(r.errors,e.name,c[e.name]):uN(r.errors,e.name))}o&&await b(o,t,i)}}return i.valid},x=(e,t)=>(e&&t&&VP(s,e,t),!pN(M(),o)),C=(e,t,n)=>zP(e,l,{...a.mount?s:gP(t)?o:BP(e)?{[e]:t}:t},n),w=(e,t,n={})=>{const r=vP(i,e);let o=t;if(r){const n=r._f;n&&(!n.disabled&&VP(s,e,bN(t,n)),o=FP&&mN(n.ref)&&uP(t)?"":t,fN(n.ref)?[...n.ref.options].forEach((e=>e.selected=o.includes(e.value))):n.refs?lP(n.ref)?n.refs.length>1?n.refs.forEach((e=>(!e.defaultChecked||!e.disabled)&&(e.checked=Array.isArray(o)?!!o.find((t=>t===e.value)):o===e.value))):n.refs[0]&&(n.refs[0].checked=!!o):n.refs.forEach((e=>e.checked=e.value===o)):YP(n.ref)?n.ref.value="":(n.ref.value=o,n.ref.type||h.watch.next({name:e})))}(n.shouldDirty||n.shouldTouch)&&y(e,o,n.shouldTouch,n.shouldDirty,!0),n.shouldValidate&&T(e)},A=(e,t,n)=>{for(const r in t){const o=t[r],s=`${e}.${r}`,a=vP(i,s);!l.array.has(e)&&hN(o)&&(!a||a._f)||cP(o)?w(s,o,n):A(s,o,n)}},E=(e,t,n={})=>{const a=vP(i,e),c=l.array.has(e),u=UP(t);VP(s,e,u),c?(h.array.next({name:e,values:s}),(d.isDirty||d.dirtyFields)&&n.shouldDirty&&(r.dirtyFields=SN(o,s),h.state.next({name:e,dirtyFields:r.dirtyFields,isDirty:x(e,u)}))):!a||a._f||uP(u)?w(e,u,n):A(e,u,n),qP(e,l)&&h.state.next({}),h.watch.next({name:e})},I=async e=>{const o=e.target;let a=o.name;const c=vP(i,a);if(c){let b,x;const C=o.type?xN(c._f):pP(e),w=e.type===yP||e.type===_P,A=!((v=c._f).mount&&(v.required||v.min||v.max||v.maxLength||v.minLength||v.pattern||v.validate)||n.resolver||vP(r.errors,a)||c._f.deps)||((e,t,n,r,i)=>!i.isOnAll&&(!n&&i.isOnTouch?!(t||e):(n?r.isOnBlur:i.isOnBlur)?!e:!(n?r.isOnChange:i.isOnChange)||e))(w,vP(r.touchedFields,a),r.isSubmitted,m,p),E=qP(a,l,w);VP(s,a,C),w?(c._f.onBlur&&c._f.onBlur(e),t&&t(0)):c._f.onChange&&c._f.onChange(e);const I=y(a,C,w,!1),M=!OP(I)||E;if(!w&&h.watch.next({name:a,type:e.type}),A)return d.isValid&&g(),M&&h.state.next({name:a,...E?{}:I});if(!w&&E&&h.state.next({}),u[a]=u[a]?u[a]+1:1,h.state.next({isValidating:!0}),n.resolver){const{errors:e}=await S([a]),t=wN(r.errors,i,a),n=wN(e,i,t.name||a);b=n.error,a=n.name,x=OP(e)}else b=(await aN(c,vP(s,a),f,n.shouldUseNativeValidation))[a],g();c._f.deps&&T(c._f.deps),_(a,x,b,I)}var v},T=async(e,t={})=>{let o,s;const a=LP(e);if(h.state.next({isValidating:!0}),n.resolver){const t=await(async e=>{const{errors:t}=await S();if(e)for(const n of e){const e=vP(t,n);e?VP(r.errors,n,e):uN(r.errors,n)}else r.errors=t;return t})(gP(e)?e:a);o=OP(t),s=e?!a.some((e=>vP(t,e))):o}else e?(s=(await Promise.all(a.map((async e=>{const t=vP(i,e);return await b(t&&t._f?{[e]:t}:t)})))).every(Boolean),(s||r.isValid)&&g()):s=o=await b(i);return h.state.next({...!BP(e)||d.isValid&&o!==r.isValid?{}:{name:e},...n.resolver||!e?{isValid:o}:{},errors:r.errors,isValidating:!1}),t.shouldFocus&&!s&&WP(i,(e=>e&&vP(r.errors,e)),e?a:l.mount),s},M=e=>{const t={...o,...a.mount?s:{}};return gP(e)?t:BP(e)?vP(t,e):e.map((e=>vP(t,e)))},R=(e,t)=>({invalid:!!vP((t||r).errors,e),isDirty:!!vP((t||r).dirtyFields,e),isTouched:!!vP((t||r).touchedFields,e),error:vP((t||r).errors,e)}),P=(e,t={})=>{for(const a of e?LP(e):l.mount)l.mount.delete(a),l.array.delete(a),vP(i,a)&&(t.keepValue||(uN(i,a),uN(s,a)),!t.keepError&&uN(r.errors,a),!t.keepDirty&&uN(r.dirtyFields,a),!t.keepTouched&&uN(r.touchedFields,a),!n.shouldUnregister&&!t.keepDefaultValue&&uN(o,a));h.watch.next({}),h.state.next({...r,...t.keepDirty?{isDirty:x()}:{}}),!t.keepIsValid&&g()},N=(e,t={})=>{let r=vP(i,e);const c=KP(t.disabled);return VP(i,e,{...r||{},_f:{...r&&r._f?r._f:{ref:{name:e}},name:e,mount:!0,...t}}),l.mount.add(e),r?c&&VP(s,e,t.disabled?void 0:vP(s,e,xN(r._f))):v(e,!0,t.value),{...c?{disabled:t.disabled}:{},...n.shouldUseNativeValidation?{required:!!t.required,min:CN(t.min),max:CN(t.max),minLength:CN(t.minLength),maxLength:CN(t.maxLength),pattern:CN(t.pattern)}:{},name:e,onChange:I,onBlur:I,ref:s=>{if(s){N(e,t),r=vP(i,e);const n=gP(s.value)&&s.querySelectorAll&&s.querySelectorAll("input,select,textarea")[0]||s,a=(e=>$P(e)||lP(e))(n),l=r._f.refs||[];if(a?l.find((e=>e===n)):n===r._f.ref)return;VP(i,e,{_f:{...r._f,...a?{refs:[...l.filter(gN),n,...Array.isArray(vP(o,e))?[{}]:[]],ref:{type:n.type,name:e}}:{ref:n}}}),v(e,!1,void 0,n)}else r=vP(i,e,{}),r._f&&(r._f.mount=!1),(n.shouldUnregister||t.shouldUnregister)&&(!mP(l.array,e)||!a.action)&&l.unMount.add(e)}}},O=()=>n.shouldFocusError&&WP(i,(e=>e&&vP(r.errors,e)),l.mount);return{control:{register:N,unregister:P,getFieldState:R,_executeSchema:S,_focusError:O,_getWatch:C,_getDirty:x,_updateValid:g,_removeUnmounted:()=>{for(const e of l.unMount){const t=vP(i,e);t&&(t._f.refs?t._f.refs.every((e=>!gN(e))):!gN(t._f.ref))&&P(e)}l.unMount=new Set},_updateFieldArray:(e,t=[],n,l,c=!0,u=!0)=>{if(l&&n){if(a.action=!0,u&&Array.isArray(vP(i,e))){const t=n(vP(i,e),l.argA,l.argB);c&&VP(i,e,t)}if(u&&Array.isArray(vP(r.errors,e))){const t=n(vP(r.errors,e),l.argA,l.argB);c&&VP(r.errors,e,t),((e,t)=>{!fP(vP(e,t)).length&&uN(e,t)})(r.errors,e)}if(d.touchedFields&&u&&Array.isArray(vP(r.touchedFields,e))){const t=n(vP(r.touchedFields,e),l.argA,l.argB);c&&VP(r.touchedFields,e,t)}d.dirtyFields&&(r.dirtyFields=SN(o,s)),h.state.next({isDirty:x(e,t),dirtyFields:r.dirtyFields,errors:r.errors,isValid:r.isValid})}else VP(s,e,t)},_getFieldArray:t=>fP(vP(a.mount?s:o,t,e.shouldUnregister?vP(o,t,[]):[])),_subjects:h,_proxyFormState:d,get _fields(){return i},get _formValues(){return s},get _stateFlags(){return a},set _stateFlags(e){a=e},get _defaultValues(){return o},get _names(){return l},set _names(e){l=e},get _formState(){return r},set _formState(e){r=e},get _options(){return n},set _options(e){n={...n,...e}}},trigger:T,register:N,handleSubmit:(e,t)=>async o=>{o&&(o.preventDefault&&o.preventDefault(),o.persist&&o.persist());let a=!0,l=UP(s);h.state.next({isSubmitting:!0});try{if(n.resolver){const{errors:e,values:t}=await S();r.errors=e,l=t}else await b(i);OP(r.errors)?(h.state.next({errors:{},isSubmitting:!0}),await e(l,o)):(t&&await t({...r.errors},o),O())}catch(e){throw a=!1,e}finally{r.isSubmitted=!0,h.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:OP(r.errors)&&a,submitCount:r.submitCount+1,errors:r.errors})}},watch:(e,t)=>XP(e)?h.watch.subscribe({next:n=>e(C(void 0,t),n)}):C(e,t,!0),setValue:E,getValues:M,reset:(t,n)=>((t,n={})=>{const c=t||o,u=UP(c),p=t&&!OP(t)?u:o;if(n.keepDefaultValues||(o=c),!n.keepValues){if(n.keepDirtyValues)for(const e of l.mount)vP(r.dirtyFields,e)?VP(p,e,vP(s,e)):E(e,vP(p,e));else{if(FP&&gP(t))for(const e of l.mount){const t=vP(i,e);if(t&&t._f){const e=Array.isArray(t._f.refs)?t._f.refs[0]:t._f.ref;if(mN(e)){const t=e.closest("form");if(t){t.reset();break}}}}i={}}s=e.shouldUnregister?n.keepDefaultValues?UP(o):{}:u,h.array.next({values:p}),h.watch.next({values:p})}l={mount:new Set,unMount:new Set,array:new Set,watch:new Set,watchAll:!1,focus:""},a.mount=!d.isValid||!!n.keepIsValid,a.watch=!!e.shouldUnregister,h.state.next({submitCount:n.keepSubmitCount?r.submitCount:0,isDirty:n.keepDirty||n.keepDirtyValues?r.isDirty:!(!n.keepDefaultValues||pN(t,o)),isSubmitted:!!n.keepIsSubmitted&&r.isSubmitted,dirtyFields:n.keepDirty||n.keepDirtyValues?r.dirtyFields:n.keepDefaultValues&&t?SN(o,t):{},touchedFields:n.keepTouched?r.touchedFields:{},errors:n.keepErrors?r.errors:{},isSubmitting:!1,isSubmitSuccessful:!1})})(XP(t)?t(s):t,n),resetField:(e,t={})=>{vP(i,e)&&(gP(t.defaultValue)?E(e,vP(o,e)):(E(e,t.defaultValue),VP(o,e,t.defaultValue)),t.keepTouched||uN(r.touchedFields,e),t.keepDirty||(uN(r.dirtyFields,e),r.isDirty=t.defaultValue?x(e,vP(o,e)):x()),t.keepError||(uN(r.errors,e),d.isValid&&g()),h.state.next({...r}))},clearErrors:e=>{e?LP(e).forEach((e=>uN(r.errors,e))):r.errors={},h.state.next({errors:r.errors})},unregister:P,setError:(e,t,n)=>{const o=(vP(i,e,{_f:{}})._f||{}).ref;VP(r.errors,e,{...t,ref:o}),h.state.next({name:e,errors:r.errors,isValid:!1}),n&&n.shouldFocus&&o&&o.focus&&o.focus()},setFocus:(e,t={})=>{const n=vP(i,e),r=n&&n._f;if(r){const e=r.refs?r.refs[0]:r.ref;e.focus&&(e.focus(),t.shouldSelect&&e.select())}},getFieldState:R}}function IN(e={}){const n=t(c).useRef(),[r,i]=t(c).useState({isDirty:!1,isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},errors:{},defaultValues:e.defaultValues});n.current||(n.current={...EN(e),formState:r});const o=n.current.control;return o._options=e,kP({subject:o._subjects.state,callback:t(c).useCallback((e=>{DP(e,o._proxyFormState,!0)&&(o._formState={...o._formState,...e},i({...o._formState}))}),[o])}),t(c).useEffect((()=>{o._stateFlags.mount||(o._proxyFormState.isValid&&o._updateValid(),o._stateFlags.mount=!0),o._stateFlags.watch&&(o._stateFlags.watch=!1,o._subjects.state.next({})),o._removeUnmounted()})),t(c).useEffect((()=>{r.submitCount&&o._focusError()}),[o,r.submitCount]),n.current.formState=NP(r,o),n.current}var TN=({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:"M482 152h60q8 0 8 8v704q0 8-8 8h-60q-8 0-8-8V160q0-8 8-8z"}),(0,s.jsx)("path",{d:"M176 474h672q8 0 8 8v60q0 8-8 8H176q-8 0-8-8v-60q0-8 8-8z"})]});var MN=({pwdOrTokens:e,setPwdOrTokens:t,onFinish:n,minimumNumberOfRecoveryTokens:r=1,showTokens:i=!0,openModal:o=!1,withModal:a=!1})=>{var l;const{t:u}=Ie(),{register:d,handleSubmit:h,formState:{errors:p},setError:m}=IN(),[f,g]=(0,c.useState)(1),[v,y]=(0,c.useState)(!!e),_=(0,s.jsxs)("form",{name:"memoriAuth",onSubmit:h((t=>{var i,o,s;"password"===e&&!(null===(i=t.password)||void 0===i?void 0:i.length)||"tokens"===e&&(((null===(o=null==t?void 0:t.tokens)||void 0===o?void 0:o.length)||0)<r||!(null===(s=null==t?void 0:t.tokens)||void 0===s?void 0:s.every((e=>e.length))))?m("tokens",{type:"minLength",message:"Tokens"}):n&&n(t).then((()=>{y(!1)}))})),className:"memori-auth-widget--form",children:[("password"===e||!i)&&(0,s.jsxs)("fieldset",{className:"memori-auth-widget--password-fieldset",children:[(0,s.jsxs)("label",{children:["Password:"," ",(0,s.jsx)("input",{className:"memori-auth-widget--input",required:!0,type:"password",placeholder:"Password",...d("password",{required:!0})})]}),i&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("hr",{}),(0,s.jsx)(Mm,{outlined:!0,onClick:()=>t("tokens"),children:u("auth.useRecoveryTokens")||"Recovery tokens"})]})]}),"tokens"===e&&i&&(0,s.jsxs)("fieldset",{className:"memori-auth-widget--tokens-fieldset",name:"tokens",children:[(0,s.jsxs)("legend",{children:[u("auth.tokens"),": "]}),(S=f,Array.from({length:S},((e,t)=>t))).map((e=>(0,s.jsx)("label",{className:"memori-auth-widget--token",children:(0,s.jsx)("input",{type:"password",className:"memori-auth-widget--input",placeholder:"Recovery token",required:!0,autoComplete:"off",...d(`tokens.${e}`,{required:!0})})},e))),(0,s.jsx)(Mm,{onClick:()=>g((e=>e+1)),className:"memori-auth-widget--token-add",icon:(0,s.jsx)(TN,{}),children:u("auth.addToken")||"Add token"}),(0,s.jsx)("hr",{}),(0,s.jsx)(Mm,{outlined:!0,onClick:()=>t("password"),children:u("auth.usePassword")||"Password"})]}),"minLength"===(null===(l=p.tokens)||void 0===l?void 0:l.type)&&(0,s.jsxs)("div",{className:"memori-auth-widget--error",children:[u("auth.atLeast")||"At least"," ",r]}),(0,s.jsx)(Mm,{htmlType:"submit",primary:!0,className:"memori-auth-widget--submit",children:u("confirm")||"Submit"})]});var S;return a?(0,s.jsx)(aP,{open:o||v,title:u("auth.title")||"Authentication",onClose:()=>t(null),closable:!1,children:_}):_};c=o("85Hg2");const RN=({type:e,resourceURI:t,sessionID:n,baseURL:r="",apiURL:i=""})=>{let o="cover"===e?`${r}/images/memoriCover.png`:`${r}/images/memoriAvatar.png?v=20231208`;try{return t&&0!==t.length?t.includes("memoriai/memory")&&!t.includes("memori-ai-session-id")&&n?`${t}?memori-ai-session-id=${n}`:(t.startsWith("https://")||t.startsWith("http://"))&&(new URL(t).hostname.includes("memori.ai")||new URL(t).hostname.includes("aclambda.online")||new URL(t).hostname.includes("localhost"))?`${t}${t.endsWith("/")||!n?"":"/"}${n||""}`:t.startsWith("cloud://")?`${(null==i?void 0:i.replace(/v2/,"v1"))||""}/CloudAsset/${t.replace("cloud://","")}`:t.startsWith("guid://")?`${(null==i?void 0:i.replace(/v2/,"v1"))||""}/GuidAsset/${t.replace("guid://","")}`:t||o:o}catch(e){return t||o}};c=o("85Hg2");var PN=({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:"M858.5 763.6a374 374 0 0 0-80.6-119.5 375.63 375.63 0 0 0-119.5-80.6c-.4-.2-.8-.3-1.2-.5C719.5 518 760 444.7 760 362c0-137-111-248-248-248S264 225 264 362c0 82.7 40.5 156 102.8 201.1-.4.2-.8.3-1.2.5-44.8 18.9-85 46-119.5 80.6a375.63 375.63 0 0 0-80.6 119.5A371.7 371.7 0 0 0 136 901.8a8 8 0 0 0 8 8.2h60c4.4 0 7.9-3.5 8-7.8 2-77.2 33-149.5 87.8-204.3 56.7-56.7 132-87.9 212.2-87.9s155.5 31.2 212.2 87.9C779 752.7 810 825 812 902.2c.1 4.4 3.6 7.8 8 7.8h60a8 8 0 0 0 8-8.2c-1-47.8-10.9-94.3-29.5-138.2zM512 534c-45.9 0-89.1-17.9-121.6-50.4S340 407.9 340 362c0-45.9 17.9-89.1 50.4-121.6S466.1 190 512 190s89.1 17.9 121.6 50.4S684 316.1 684 362c0 45.9-17.9 89.1-50.4 121.6S557.9 534 512 534z"})});var NN=({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 24 24",fill:"none",className:e,"aria-label":t,children:(0,s.jsxs)("g",{fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd",children:[(0,s.jsx)("path",{fillRule:"evenodd",d:"M0 4a4 4 0 014-4h16a4 4 0 014 4v16a4 4 0 01-4 4H4a4 4 0 01-4-4zm4-2.4A2.4 2.4 0 001.6 4v16A2.4 2.4 0 004 22.4h16a2.4 2.4 0 002.4-2.4V4A2.4 2.4 0 0020 1.6z",clipRule:"evenodd"}),(0,s.jsx)("path",{fillRule:"evenodd",d:"M9.715 8.442a.798.798 0 00-1.43 0l-3.2 6.4a.799.799 0 101.431.716l.579-1.158h3.811l.578 1.158a.8.8 0 001.431-.716zm.391 4.358L9 10.589 7.894 12.8z",clipRule:"evenodd"}),(0,s.jsx)("path",{fillRule:"evenodd",d:"M17 8c.552 0 1 .358 1 .8v6.4c0 .442-.448.8-1 .8s-1-.358-1-.8V8.8c0-.442.448-.8 1-.8z",clipRule:"evenodd"})]})});var ON=({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:"M140 188h584v164h76V144c0-17.7-14.3-32-32-32H96c-17.7 0-32 14.3-32 32v736c0 17.7 14.3 32 32 32h544v-76H140V188z"}),(0,s.jsx)("path",{d:"M414.3 256h-60.6c-3.4 0-6.4 2.2-7.6 5.4L219 629.4c-.3.8-.4 1.7-.4 2.6 0 4.4 3.6 8 8 8h55.1c3.4 0 6.4-2.2 7.6-5.4L322 540h196.2L422 261.4c-1.3-3.2-4.3-5.4-7.7-5.4zm12.4 228h-85.5L384 360.2 426.7 484zM936 528H800v-93c0-4.4-3.6-8-8-8h-56c-4.4 0-8 3.6-8 8v93H592c-13.3 0-24 10.7-24 24v176c0 13.3 10.7 24 24 24h136v152c0 4.4 3.6 8 8 8h56c4.4 0 8-3.6 8-8V752h136c13.3 0 24-10.7 24-24V552c0-13.3-10.7-24-24-24zM728 680h-88v-80h88v80zm160 0h-88v-80h88v80z"})]});var DN=({content:e,className:n,align:r="right",disabled:i=!1,visible:o=!1,children:a})=>(0,s.jsxs)("div",{className:t(Is)("memori-tooltip",`memori-tooltip--align-${r}`,n,{"memori-tooltip--disabled":i,"memori-tooltip--visible":o}),children:[(0,s.jsx)("div",{className:"memori-tooltip--content",children:e}),(0,s.jsx)("div",{className:"memori-tooltip--trigger",children:a})]}),LN=(c=o("85Hg2"),c=o("85Hg2"),(e=>(e[e.Open=0]="Open",e[e.Closed=1]="Closed",e))(LN||{})),kN=(e=>(e[e.Pointer=0]="Pointer",e[e.Other=1]="Other",e))(kN||{}),BN=(e=>(e[e.OpenMenu=0]="OpenMenu",e[e.CloseMenu=1]="CloseMenu",e[e.GoToItem=2]="GoToItem",e[e.Search=3]="Search",e[e.ClearSearch=4]="ClearSearch",e[e.RegisterItem=5]="RegisterItem",e[e.UnregisterItem=6]="UnregisterItem",e))(BN||{});function zN(e,t=(e=>e)){let n=null!==e.activeItemIndex?e.items[e.activeItemIndex]:null,r=Op(t(e.items.slice()),(e=>e.dataRef.current.domRef.current)),i=n?r.indexOf(n):null;return-1===i&&(i=null),{items:r,activeItemIndex:i}}let FN={1:e=>1===e.menuState?e:{...e,activeItemIndex:null,menuState:1},0:e=>0===e.menuState?e:{...e,menuState:0},2:(e,t)=>{var n;let r=zN(e),i=MR(t,{resolveItems:()=>r.items,resolveActiveIndex:()=>r.activeItemIndex,resolveId:e=>e.id,resolveDisabled:e=>e.dataRef.current.disabled});return{...e,...r,searchQuery:"",activeItemIndex:i,activationTrigger:null!=(n=t.trigger)?n:1}},3:(e,t)=>{let n=""!==e.searchQuery?0:1,r=e.searchQuery+t.value.toLowerCase(),i=(null!==e.activeItemIndex?e.items.slice(e.activeItemIndex+n).concat(e.items.slice(0,e.activeItemIndex+n)):e.items).find((e=>{var t;return(null==(t=e.dataRef.current.textValue)?void 0:t.startsWith(r))&&!e.dataRef.current.disabled})),o=i?e.items.indexOf(i):-1;return-1===o||o===e.activeItemIndex?{...e,searchQuery:r}:{...e,searchQuery:r,activeItemIndex:o,activationTrigger:1}},4:e=>""===e.searchQuery?e:{...e,searchQuery:"",searchActiveItemIndex:null},5:(e,t)=>{let n=zN(e,(e=>[...e,{id:t.id,dataRef:t.dataRef}]));return{...e,...n}},6:(e,t)=>{let n=zN(e,(e=>{let n=e.findIndex((e=>e.id===t.id));return-1!==n&&e.splice(n,1),e}));return{...e,...n,activationTrigger:1}}},UN=(0,c.createContext)(null);function jN(e){let t=(0,c.useContext)(UN);if(null===t){let t=new Error(`<${e} /> is missing a parent <Menu /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(t,jN),t}return t}function GN(e,t){return vh(t.type,FN,e,t)}UN.displayName="MenuContext";let HN=c.Fragment,VN=wh((function(e,n){let r=(0,c.useReducer)(GN,{menuState:1,buttonRef:(0,c.createRef)(),itemsRef:(0,c.createRef)(),items:[],searchQuery:"",activeItemIndex:null,activationTrigger:1}),[{menuState:i,itemsRef:o,buttonRef:s},a]=r,l=Uh(n);hm([s,o],((e,t)=>{var n;a({type:1}),Mp(t,Tp.Loose)||(e.preventDefault(),null==(n=s.current)||n.focus())}),0===i);let u=Bh((()=>{a({type:1})})),d=(0,c.useMemo)((()=>({open:0===i,close:u})),[i,u]),h=e,p={ref:l};return t(c).createElement(UN.Provider,{value:r},t(c).createElement(Rh,{value:vh(i,{0:Th.Open,1:Th.Closed})},bh({ourProps:p,theirProps:h,slot:d,defaultTag:HN,name:"Menu"})))})),WN=wh((function(e,t){var n;let[r,i]=jN("Menu.Button"),o=Uh(r.buttonRef,t),s=`headlessui-menu-button-${yp()}`,a=Yh(),l=Bh((e=>{switch(e.key){case pp.Space:case pp.Enter:case pp.ArrowDown:e.preventDefault(),e.stopPropagation(),i({type:0}),a.nextFrame((()=>i({type:2,focus:TR.First})));break;case pp.ArrowUp:e.preventDefault(),e.stopPropagation(),i({type:0}),a.nextFrame((()=>i({type:2,focus:TR.Last})))}})),u=Bh((e=>{if(e.key===pp.Space)e.preventDefault()})),d=Bh((t=>{if(mp(t.currentTarget))return t.preventDefault();e.disabled||(0===r.menuState?(i({type:1}),a.nextFrame((()=>{var e;return null==(e=r.buttonRef.current)?void 0:e.focus({preventScroll:!0})}))):(t.preventDefault(),i({type:0})))})),h=(0,c.useMemo)((()=>({open:0===r.menuState})),[r]),p=e;return bh({ourProps:{ref:o,id:s,type:ER(e,r.buttonRef),"aria-haspopup":!0,"aria-controls":null==(n=r.itemsRef.current)?void 0:n.id,"aria-expanded":e.disabled?void 0:0===r.menuState,onKeyDown:l,onKeyUp:u,onClick:d},theirProps:p,slot:h,defaultTag:"button",name:"Menu.Button"})})),qN=_h.RenderStrategy|_h.Static,JN=wh((function(e,t){var n,r;let[i,o]=jN("Menu.Items"),s=Uh(i.itemsRef,t),a=Fp(i.itemsRef),l=`headlessui-menu-items-${yp()}`,u=Yh(),d=Mh(),h=null!==d?d===Th.Open:0===i.menuState;(0,c.useEffect)((()=>{let e=i.itemsRef.current;!e||0===i.menuState&&e!==(null==a?void 0:a.activeElement)&&e.focus({preventScroll:!0})}),[i.menuState,i.itemsRef,a]),IR({container:i.itemsRef.current,enabled:0===i.menuState,accept:e=>"menuitem"===e.getAttribute("role")?NodeFilter.FILTER_REJECT:e.hasAttribute("role")?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT,walk(e){e.setAttribute("role","none")}});let p=Bh((e=>{var t,n;switch(u.dispose(),e.key){case pp.Space:if(""!==i.searchQuery)return e.preventDefault(),e.stopPropagation(),o({type:3,value:e.key});case pp.Enter:if(e.preventDefault(),e.stopPropagation(),o({type:1}),null!==i.activeItemIndex){let{dataRef:e}=i.items[i.activeItemIndex];null==(n=null==(t=e.current)?void 0:t.domRef.current)||n.click()}Rp(i.buttonRef.current);break;case pp.ArrowDown:return e.preventDefault(),e.stopPropagation(),o({type:2,focus:TR.Next});case pp.ArrowUp:return e.preventDefault(),e.stopPropagation(),o({type:2,focus:TR.Previous});case pp.Home:case pp.PageUp:return e.preventDefault(),e.stopPropagation(),o({type:2,focus:TR.First});case pp.End:case pp.PageDown:return e.preventDefault(),e.stopPropagation(),o({type:2,focus:TR.Last});case pp.Escape:e.preventDefault(),e.stopPropagation(),o({type:1}),Hh().nextFrame((()=>{var e;return null==(e=i.buttonRef.current)?void 0:e.focus({preventScroll:!0})}));break;case pp.Tab:e.preventDefault(),e.stopPropagation(),o({type:1}),Hh().nextFrame((()=>{Dp(i.buttonRef.current,e.shiftKey?wp.Previous:wp.Next)}));break;default:1===e.key.length&&(o({type:3,value:e.key}),u.setTimeout((()=>o({type:4})),350))}})),m=Bh((e=>{if(e.key===pp.Space)e.preventDefault()})),f=(0,c.useMemo)((()=>({open:0===i.menuState})),[i]),g=e;return bh({ourProps:{"aria-activedescendant":null===i.activeItemIndex||null==(n=i.items[i.activeItemIndex])?void 0:n.id,"aria-labelledby":null==(r=i.buttonRef.current)?void 0:r.id,id:l,onKeyDown:p,onKeyUp:m,role:"menu",tabIndex:0,ref:s},theirProps:g,slot:f,defaultTag:"div",features:qN,visible:h,name:"Menu.Items"})})),KN=c.Fragment,YN=wh((function(e,t){let{disabled:n=!1,...r}=e,[i,o]=jN("Menu.Item"),s=`headlessui-menu-item-${yp()}`,a=null!==i.activeItemIndex&&i.items[i.activeItemIndex].id===s,l=(0,c.useRef)(null),u=Uh(t,l);Nh((()=>{if(0!==i.menuState||!a||0===i.activationTrigger)return;let e=Hh();return e.requestAnimationFrame((()=>{var e,t;null==(t=null==(e=l.current)?void 0:e.scrollIntoView)||t.call(e,{block:"nearest"})})),e.dispose}),[l,a,i.menuState,i.activationTrigger,i.activeItemIndex]);let d=(0,c.useRef)({disabled:n,domRef:l});Nh((()=>{d.current.disabled=n}),[d,n]),Nh((()=>{var e,t;d.current.textValue=null==(t=null==(e=l.current)?void 0:e.textContent)?void 0:t.toLowerCase()}),[d,l]),Nh((()=>(o({type:5,id:s,dataRef:d}),()=>o({type:6,id:s}))),[d,s]);let h=Bh((()=>{o({type:1})})),p=Bh((e=>{if(n)return e.preventDefault();o({type:1}),Rp(i.buttonRef.current)})),m=Bh((()=>{if(n)return o({type:2,focus:TR.Nothing});o({type:2,focus:TR.Specific,id:s})})),f=Bh((()=>{n||a||o({type:2,focus:TR.Specific,id:s,trigger:0})})),g=Bh((()=>{n||!a||o({type:2,focus:TR.Nothing})})),v=(0,c.useMemo)((()=>({active:a,disabled:n,close:h})),[a,n,h]);return bh({ourProps:{id:s,ref:u,role:"menuitem",tabIndex:!0===n?void 0:-1,"aria-disabled":!0===n||void 0,disabled:void 0,onClick:p,onFocus:m,onPointerMove:f,onMouseMove:f,onPointerLeave:g,onMouseLeave:g},theirProps:r,slot:v,defaultTag:KN,name:"Menu.Item"})})),XN=Object.assign(VN,{Button:WN,Items:JN,Item:YN});var QN=({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 24 24",className:e,"aria-label":t,children:[(0,s.jsx)("path",{fill:"none",d:"M0 0h24v24H0V0z"}),(0,s.jsx)("path",{d:"M20 2H4c-1.1 0-1.99.9-1.99 2L2 22l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm0 14H5.17l-.59.59-.58.58V4h16v12zm-9-4h2v2h-2zm0-6h2v4h-2z"})]});const $N={"it-IT":"Non è quello che ti ho chiesto","fr-FR":"Ce n'est pas ce que je t'ai demandé","en-GB":"It's not what I asked"},ZN={"it-IT":"La risposta non era corretta","fr-FR":"La réponse n'était pas correcte","en-GB":"The answer was not correct"},eO={"it-IT":"Non mi è piaciuta la risposta","fr-FR":"Je n'ai pas aimé la réponse","en-GB":"I didn't like the answer"};var tO=({memori:e,className:n,onNegativeClick:r,toggle:i=!1,dropdown:o=!1})=>{const[a,l]=(0,c.useState)(),u="it-IT"===e.culture?"it-IT":"fr-FR"===e.culture?"fr-FR":"en-GB",d=$N[u],h=ZN[u],p=eO[u];return(0,s.jsx)("div",{className:"memori-chat--feedback"+(n?` ${n}`:""),children:o?(0,s.jsxs)(XN,{as:"div",className:"memori-chat--feedback-menu",children:[(0,s.jsx)(XN.Button,{as:t(c).Fragment,children:(0,s.jsx)(Mm,{ghost:!0,shape:"circle",title:"Feedback",className:"memori-chat--feedback-menu-button",disabled:!!a,icon:(0,s.jsx)(QN,{className:a?"memori-chat--feedback-clicked":void 0})})}),(0,s.jsx)(dp,{as:t(c).Fragment,enter:"transition ease-out duration-200",enterFrom:"transform opacity-0 scale-95",enterTo:"transform opacity-100 scale-100",leave:"transition ease-in duration-75",leaveFrom:"transform opacity-100 scale-100",leaveTo:"transform opacity-0 scale-95",children:(0,s.jsx)(XN.Items,{className:"memori-chat--feedback-menu-items",children:(0,s.jsxs)("div",{className:"memori-chat--feedback-menu-items-container",children:[(0,s.jsx)(XN.Item,{children:({active:e})=>(0,s.jsx)("button",{className:"memori-chat--feedback-menu-item"+(e?" memori-chat--feedback-menu-item-active":""),onClick:()=>{l("up"===a&&i?void 0:"up")},children:p})},"ok"),(0,s.jsx)(XN.Item,{children:({active:e})=>(0,s.jsx)("button",{className:"memori-chat--feedback-menu-item"+(e?" memori-chat--feedback-menu-item-active":""),onClick:()=>{l("down"===a&&i?void 0:"down"),r(d)},children:h})},"no")]})})})]}):(0,s.jsx)(DN,{align:"left",content:"Feedback",children:(0,s.jsx)(Mm,{title:"Feedback",onClick:()=>{l("down"===a&&i?void 0:"down"),r(d)},ghost:!0,shape:"circle",icon:(0,s.jsx)(QN,{className:a?"memori-chat--feedback-clicked":void 0})})})})};var nO=({className:e,title:t})=>(0,s.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",...t?{}:{"aria-hidden":"true"},focusable:"false",role:"img",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5",viewBox:"0 0 24 24",className:e,"aria-label":t,children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,s.jsx)("path",{d:"M9.09 9a3 3 0 015.83 1c0 2-3 3-3 3"}),(0,s.jsx)("path",{d:"M12 17L12.01 17"})]});var rO=({className:e,title:t})=>(0,s.jsxs)("svg",{...t?{}:{"aria-hidden":"true"},xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",focusable:"false",role:"img",className:e,"aria-label":t,children:[(0,s.jsx)("rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"}),(0,s.jsx)("path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"})]});var iO=({className:e,title:t})=>(0,s.jsxs)("svg",{...t?{}:{"aria-hidden":"true"},xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",focusable:"false",role:"img",className:e,"aria-label":t,children:[(0,s.jsx)("path",{d:"M10 9.5 8 12l2 2.5"}),(0,s.jsx)("path",{d:"m14 9.5 2 2.5-2 2.5"}),(0,s.jsx)("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"})]});var oO=({className:e,title:t})=>(0,s.jsxs)("svg",{width:"800px",height:"800px",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,"aria-label":t,color:"currentColor",children:[(0,s.jsx)("path",{d:"M19 15V11.9375C19 9.76288 17.2371 8 15.0625 8H8.9375C6.76288 8 5 9.76288 5 11.9375V15C5 18.866 8.13401 22 12 22C15.866 22 19 18.866 19 15Z",stroke:"currentColor",strokeWidth:"1.5"}),(0,s.jsx)("path",{d:"M16.5 8.5V7.5C16.5 5.01472 14.4853 3 12 3C9.51472 3 7.5 5.01472 7.5 7.5V8.5",stroke:"currentColor",strokeWidth:"1.5"}),(0,s.jsx)("path",{d:"M19 14H22",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),(0,s.jsx)("path",{d:"M5 14H2",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),(0,s.jsx)("path",{d:"M14.5 3.5L17 2",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),(0,s.jsx)("path",{d:"M9.5 3.5L7 2",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),(0,s.jsx)("path",{d:"M20.5 20.0002L18.5 19.2002",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),(0,s.jsx)("path",{d:"M20.5 7.9998L18.5 8.7998",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),(0,s.jsx)("path",{d:"M3.5 20.0002L5.5 19.2002",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),(0,s.jsx)("path",{d:"M3.5 7.9998L5.5 8.7998",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),(0,s.jsx)("path",{d:"M12 21.5V15",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),sO=(c=o("85Hg2"),c=o("85Hg2"),{});!function(e){"use strict";function t(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}function n(t){e.defaults=t}e.defaults=t();const r={exec:()=>null};function i(e,t=""){let n="string"==typeof e?e:e.source;const r={replace:(e,t)=>{let i="string"==typeof t?t:t.source;return i=i.replace(o.caret,"$1"),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}const o={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>new RegExp(`^( {0,3}${e})((?:[\t ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ \t][^\\n]*)?(?:\\n|$))`),hrRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,"i")},s=/^(?:[ \t]*(?:\n|$))+/,a=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,l=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,c=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,u=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,d=/(?:[*+-]|\d{1,9}[.)])/,h=i(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g,d).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).getRegex(),p=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,m=/^[^\n]+/,f=/(?!\s*\])(?:\\.|[^\[\]\\])+/,g=i(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",f).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),v=i(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,d).getRegex(),y="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",_=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,S=i("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$))","i").replace("comment",_).replace("tag",y).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),b=i(p).replace("hr",c).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",y).getRegex(),x={blockquote:i(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",b).getRegex(),code:a,def:g,fences:l,heading:u,hr:c,html:S,lheading:h,list:v,newline:s,paragraph:b,table:r,text:m},C=i("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",c).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3}\t)[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",y).getRegex(),w={...x,table:C,paragraph:i(p).replace("hr",c).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",C).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",y).getRegex()},A={...x,html:i("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:\"[^\"]*\"|'[^']*'|\\s[^'\"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment",_).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:r,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:i(p).replace("hr",c).replace("heading"," *#{1,6} *[^\n]").replace("lheading",h).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},E=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,I=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,T=/^( {2,}|\\)\n(?!\s*$)/,M=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,R=/\p{P}\p{S}/u,P=i(/^((?![*_])[\spunctuation])/,"u").replace(/punctuation/g,R).getRegex(),N=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,O=i(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/,"u").replace(/punct/g,R).getRegex(),D=i("^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)[punct](\\*+)(?=[\\s]|$)|[^punct\\s](\\*+)(?!\\*)(?=[punct\\s]|$)|(?!\\*)[punct\\s](\\*+)(?=[^punct\\s])|[\\s](\\*+)(?!\\*)(?=[punct])|(?!\\*)[punct](\\*+)(?!\\*)(?=[punct])|[^punct\\s](\\*+)(?=[^punct\\s])","gu").replace(/punct/g,R).getRegex(),L=i("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\\s]|$)|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)|(?!_)[punct\\s](_+)(?=[^punct\\s])|[\\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])","gu").replace(/punct/g,R).getRegex(),k=i(/\\([punct])/,"gu").replace(/punct/g,R).getRegex(),B=i(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),z=i(_).replace("(?:--\x3e|$)","--\x3e").getRegex(),F=i("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",z).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),U=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,j=i(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label",U).replace("href",/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),G=i(/^!?\[(label)\]\[(ref)\]/).replace("label",U).replace("ref",f).getRegex(),H=i(/^!?\[(ref)\](?:\[\])?/).replace("ref",f).getRegex(),V=i("reflink|nolink(?!\\()","g").replace("reflink",G).replace("nolink",H).getRegex(),W={_backpedal:r,anyPunctuation:k,autolink:B,blockSkip:N,br:T,code:I,del:r,emStrongLDelim:O,emStrongRDelimAst:D,emStrongRDelimUnd:L,escape:E,link:j,nolink:H,punctuation:P,reflink:G,reflinkSearch:V,tag:F,text:M,url:r},q={...W,link:i(/^!?\[(label)\]\((.*?)\)/).replace("label",U).getRegex(),reflink:i(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",U).getRegex()},J={...W,escape:i(E).replace("])","~|])").getRegex(),url:i(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},K={...J,br:i(T).replace("{2,}","*").getRegex(),text:i(J.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Y={normal:x,gfm:w,pedantic:A},X={normal:W,gfm:J,breaks:K,pedantic:q},Q={"&":"&","<":"<",">":">",'"':""","'":"'"},$=e=>Q[e];function Z(e,t){if(t){if(o.escapeTest.test(e))return e.replace(o.escapeReplace,$)}else if(o.escapeTestNoEncode.test(e))return e.replace(o.escapeReplaceNoEncode,$);return e}function ee(e){try{e=encodeURI(e).replace(o.percentDecode,"%")}catch{return null}return e}function te(e,t){const n=e.replace(o.findPipe,((e,t,n)=>{let r=!1,i=t;for(;--i>=0&&"\\"===n[i];)r=!r;return r?"|":" |"})).split(o.splitPipe);let r=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t)if(n.length>t)n.splice(t);else for(;n.length<t;)n.push("");for(;r<n.length;r++)n[r]=n[r].trim().replace(o.slashPipe,"|");return n}function ne(e,t,n){const r=e.length;if(0===r)return"";let i=0;for(;i<r;){const o=e.charAt(r-i-1);if(o!==t||n){if(o===t||!n)break;i++}else i++}return e.slice(0,r-i)}function re(e,t){if(-1===e.indexOf(t[1]))return-1;let n=0;for(let r=0;r<e.length;r++)if("\\"===e[r])r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&(n--,n<0))return r;return-1}function ie(e,t,n,r,i){const o=t.href,s=t.title||null,a=e[1].replace(i.other.outputLinkReplace,"$1");if("!"!==e[0].charAt(0)){r.state.inLink=!0;const e={type:"link",raw:n,href:o,title:s,text:a,tokens:r.inlineTokens(a)};return r.state.inLink=!1,e}return{type:"image",raw:n,href:o,title:s,text:a}}function oe(e,t,n){const r=e.match(n.other.indentCodeCompensation);if(null===r)return t;const i=r[1];return t.split("\n").map((e=>{const t=e.match(n.other.beginningSpace);if(null===t)return e;const[r]=t;return r.length>=i.length?e.slice(i.length):e})).join("\n")}class se{options;rules;lexer;constructor(t){this.options=t||e.defaults}space(e){const t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){const t=this.rules.block.code.exec(e);if(t){const e=t[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?e:ne(e,"\n")}}}fences(e){const t=this.rules.block.fences.exec(e);if(t){const e=t[0],n=oe(e,t[3]||"",this.rules);return{type:"code",raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:n}}}heading(e){const t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){const t=ne(e,"#");this.options.pedantic?e=t.trim():t&&!this.rules.other.endingSpaceChar.test(t)||(e=t.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){const t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:ne(t[0],"\n")}}blockquote(e){const t=this.rules.block.blockquote.exec(e);if(t){let e=ne(t[0],"\n").split("\n"),n="",r="";const i=[];for(;e.length>0;){let t=!1;const o=[];let s;for(s=0;s<e.length;s++)if(this.rules.other.blockquoteStart.test(e[s]))o.push(e[s]),t=!0;else{if(t)break;o.push(e[s])}e=e.slice(s);const a=o.join("\n"),l=a.replace(this.rules.other.blockquoteSetextReplace,"\n $1").replace(this.rules.other.blockquoteSetextReplace2,"");n=n?`${n}\n${a}`:a,r=r?`${r}\n${l}`:l;const c=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(l,i,!0),this.lexer.state.top=c,0===e.length)break;const u=i.at(-1);if("code"===u?.type)break;if("blockquote"===u?.type){const t=u,o=t.raw+"\n"+e.join("\n"),s=this.blockquote(o);i[i.length-1]=s,n=n.substring(0,n.length-t.raw.length)+s.raw,r=r.substring(0,r.length-t.text.length)+s.text;break}if("list"!==u?.type);else{const t=u,o=t.raw+"\n"+e.join("\n"),s=this.list(o);i[i.length-1]=s,n=n.substring(0,n.length-u.raw.length)+s.raw,r=r.substring(0,r.length-t.raw.length)+s.raw,e=o.substring(i.at(-1).raw.length).split("\n")}}return{type:"blockquote",raw:n,tokens:i,text:r}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim();const r=n.length>1,i={type:"list",raw:"",ordered:r,start:r?+n.slice(0,-1):"",loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:"[*+-]");const o=this.rules.other.listItemRegex(n);let s=!1;for(;e;){let n=!1,r="",a="";if(!(t=o.exec(e)))break;if(this.rules.block.hr.test(e))break;r=t[0],e=e.substring(r.length);let l=t[2].split("\n",1)[0].replace(this.rules.other.listReplaceTabs,(e=>" ".repeat(3*e.length))),c=e.split("\n",1)[0],u=!l.trim(),d=0;if(this.options.pedantic?(d=2,a=l.trimStart()):u?d=t[1].length+1:(d=t[2].search(this.rules.other.nonSpaceChar),d=d>4?1:d,a=l.slice(d),d+=t[1].length),u&&this.rules.other.blankLine.test(c)&&(r+=c+"\n",e=e.substring(c.length+1),n=!0),!n){const t=this.rules.other.nextBulletRegex(d),n=this.rules.other.hrRegex(d),i=this.rules.other.fencesBeginRegex(d),o=this.rules.other.headingBeginRegex(d),s=this.rules.other.htmlBeginRegex(d);for(;e;){const h=e.split("\n",1)[0];let p;if(c=h,this.options.pedantic?(c=c.replace(this.rules.other.listReplaceNesting," "),p=c):p=c.replace(this.rules.other.tabCharGlobal," "),i.test(c))break;if(o.test(c))break;if(s.test(c))break;if(t.test(c))break;if(n.test(c))break;if(p.search(this.rules.other.nonSpaceChar)>=d||!c.trim())a+="\n"+p.slice(d);else{if(u)break;if(l.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4)break;if(i.test(l))break;if(o.test(l))break;if(n.test(l))break;a+="\n"+c}u||c.trim()||(u=!0),r+=h+"\n",e=e.substring(h.length+1),l=p.slice(d)}}i.loose||(s?i.loose=!0:this.rules.other.doubleBlankLine.test(r)&&(s=!0));let h,p=null;this.options.gfm&&(p=this.rules.other.listIsTask.exec(a),p&&(h="[ ] "!==p[0],a=a.replace(this.rules.other.listReplaceTask,""))),i.items.push({type:"list_item",raw:r,task:!!p,checked:h,loose:!1,text:a,tokens:[]}),i.raw+=r}const a=i.items.at(-1);a&&(a.raw=a.raw.trimEnd(),a.text=a.text.trimEnd()),i.raw=i.raw.trimEnd();for(let e=0;e<i.items.length;e++)if(this.lexer.state.top=!1,i.items[e].tokens=this.lexer.blockTokens(i.items[e].text,[]),!i.loose){const t=i.items[e].tokens.filter((e=>"space"===e.type)),n=t.length>0&&t.some((e=>this.rules.other.anyLine.test(e.raw)));i.loose=n}if(i.loose)for(let e=0;e<i.items.length;e++)i.items[e].loose=!0;return i}}html(e){const t=this.rules.block.html.exec(e);if(t)return{type:"html",block:!0,raw:t[0],pre:"pre"===t[1]||"script"===t[1]||"style"===t[1],text:t[0]}}def(e){const t=this.rules.block.def.exec(e);if(t){const e=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),n=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:e,raw:t[0],href:n,title:r}}}table(e){const t=this.rules.block.table.exec(e);if(!t)return;if(!this.rules.other.tableDelimiter.test(t[2]))return;const n=te(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split("\n"):[],o={type:"table",raw:t[0],header:[],align:[],rows:[]};if(n.length===r.length){for(const e of r)this.rules.other.tableAlignRight.test(e)?o.align.push("right"):this.rules.other.tableAlignCenter.test(e)?o.align.push("center"):this.rules.other.tableAlignLeft.test(e)?o.align.push("left"):o.align.push(null);for(let e=0;e<n.length;e++)o.header.push({text:n[e],tokens:this.lexer.inline(n[e]),header:!0,align:o.align[e]});for(const e of i)o.rows.push(te(e,o.header.length).map(((e,t)=>({text:e,tokens:this.lexer.inline(e),header:!1,align:o.align[t]}))));return o}}lheading(e){const t=this.rules.block.lheading.exec(e);if(t)return{type:"heading",raw:t[0],depth:"="===t[2].charAt(0)?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){const t=this.rules.block.paragraph.exec(e);if(t){const e="\n"===t[1].charAt(t[1].length-1)?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){const t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){const t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){const t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){const t=this.rules.inline.link.exec(e);if(t){const e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;const t=ne(e.slice(0,-1),"\\");if((e.length-t.length)%2==0)return}else{const e=re(t[2],"()");if(e>-1){const n=(0===t[0].indexOf("!")?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=""}}let n=t[2],r="";if(this.options.pedantic){const e=this.rules.other.pedanticHrefTitle.exec(n);e&&(n=e[1],r=e[3])}else r=t[3]?t[3].slice(1,-1):"";return n=n.trim(),this.rules.other.startAngleBracket.test(n)&&(n=this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?n.slice(1):n.slice(1,-1)),ie(t,{href:n?n.replace(this.rules.inline.anyPunctuation,"$1"):n,title:r?r.replace(this.rules.inline.anyPunctuation,"$1"):r},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){const e=t[(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," ").toLowerCase()];if(!e){const e=n[0].charAt(0);return{type:"text",raw:e,text:e}}return ie(n,e,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let r=this.rules.inline.emStrongLDelim.exec(e);if(r&&(!r[3]||!n.match(this.rules.other.unicodeAlphaNumeric))&&(!r[1]&&!r[2]||!n||this.rules.inline.punctuation.exec(n))){const n=[...r[0]].length-1;let i,o,s=n,a=0;const l="*"===r[0][0]?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(l.lastIndex=0,t=t.slice(-1*e.length+n);null!=(r=l.exec(t));){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i)continue;if(o=[...i].length,r[3]||r[4]){s+=o;continue}if((r[5]||r[6])&&n%3&&!((n+o)%3)){a+=o;continue}if(s-=o,s>0)continue;o=Math.min(o,o+s+a);const t=[...r[0]][0].length,l=e.slice(0,n+r.index+t+o);if(Math.min(n,o)%2){const e=l.slice(1,-1);return{type:"em",raw:l,text:e,tokens:this.lexer.inlineTokens(e)}}const c=l.slice(2,-2);return{type:"strong",raw:l,text:c,tokens:this.lexer.inlineTokens(c)}}}}codespan(e){const t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal," ");const n=this.rules.other.nonSpaceChar.test(e),r=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return n&&r&&(e=e.substring(1,e.length-1)),{type:"codespan",raw:t[0],text:e}}}br(e){const t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e){const t=this.rules.inline.del.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){const t=this.rules.inline.autolink.exec(e);if(t){let e,n;return"@"===t[2]?(e=t[1],n="mailto:"+e):(e=t[1],n=e),{type:"link",raw:t[0],text:e,href:n,tokens:[{type:"text",raw:e,text:e}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let e,n;if("@"===t[2])e=t[0],n="mailto:"+e;else{let r;do{r=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??""}while(r!==t[0]);e=t[0],n="www."===t[1]?"http://"+t[0]:t[0]}return{type:"link",raw:t[0],text:e,href:n,tokens:[{type:"text",raw:e,text:e}]}}}inlineText(e){const t=this.rules.inline.text.exec(e);if(t){const e=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:e}}}}class ae{tokens;options;state;tokenizer;inlineQueue;constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||e.defaults,this.options.tokenizer=this.options.tokenizer||new se,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const n={other:o,block:Y.normal,inline:X.normal};this.options.pedantic?(n.block=Y.pedantic,n.inline=X.pedantic):this.options.gfm&&(n.block=Y.gfm,this.options.breaks?n.inline=X.breaks:n.inline=X.gfm),this.tokenizer.rules=n}static get rules(){return{block:Y,inline:X}}static lex(e,t){return new ae(t).lex(e)}static lexInline(e,t){return new ae(t).inlineTokens(e)}lex(e){e=e.replace(o.carriageReturn,"\n"),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){const t=this.inlineQueue[e];this.inlineTokens(t.src,t.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=!1){for(this.options.pedantic&&(e=e.replace(o.tabCharGlobal," ").replace(o.spaceLine,""));e;){let r;if(this.options.extensions?.block?.some((n=>!!(r=n.call({lexer:this},e,t))&&(e=e.substring(r.raw.length),t.push(r),!0))))continue;if(r=this.tokenizer.space(e)){e=e.substring(r.raw.length);const n=t.at(-1);1===r.raw.length&&void 0!==n?n.raw+="\n":t.push(r);continue}if(r=this.tokenizer.code(e)){e=e.substring(r.raw.length);const n=t.at(-1);"paragraph"===n?.type||"text"===n?.type?(n.raw+="\n"+r.raw,n.text+="\n"+r.text,this.inlineQueue.at(-1).src=n.text):t.push(r);continue}if(r=this.tokenizer.fences(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.heading(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.hr(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.blockquote(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.list(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.html(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.def(e)){e=e.substring(r.raw.length);const n=t.at(-1);"paragraph"===n?.type||"text"===n?.type?(n.raw+="\n"+r.raw,n.text+="\n"+r.raw,this.inlineQueue.at(-1).src=n.text):this.tokens.links[r.tag]||(this.tokens.links[r.tag]={href:r.href,title:r.title});continue}if(r=this.tokenizer.table(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.lheading(e)){e=e.substring(r.raw.length),t.push(r);continue}let i=e;if(this.options.extensions?.startBlock){let t=1/0;const n=e.slice(1);let r;this.options.extensions.startBlock.forEach((e=>{r=e.call({lexer:this},n),"number"==typeof r&&r>=0&&(t=Math.min(t,r))})),t<1/0&&t>=0&&(i=e.substring(0,t+1))}if(this.state.top&&(r=this.tokenizer.paragraph(i))){const o=t.at(-1);n&&"paragraph"===o?.type?(o.raw+="\n"+r.raw,o.text+="\n"+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=o.text):t.push(r),n=i.length!==e.length,e=e.substring(r.raw.length)}else if(r=this.tokenizer.text(e)){e=e.substring(r.raw.length);const n=t.at(-1);"text"===n?.type?(n.raw+="\n"+r.raw,n.text+="\n"+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(r)}else if(e){const t="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw new Error(t)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let n=e,r=null;if(this.tokens.links){const e=Object.keys(this.tokens.links);if(e.length>0)for(;null!=(r=this.tokenizer.rules.inline.reflinkSearch.exec(n));)e.includes(r[0].slice(r[0].lastIndexOf("[")+1,-1))&&(n=n.slice(0,r.index)+"["+"a".repeat(r[0].length-2)+"]"+n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;null!=(r=this.tokenizer.rules.inline.blockSkip.exec(n));)n=n.slice(0,r.index)+"["+"a".repeat(r[0].length-2)+"]"+n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;null!=(r=this.tokenizer.rules.inline.anyPunctuation.exec(n));)n=n.slice(0,r.index)+"++"+n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let i=!1,o="";for(;e;){let r;if(i||(o=""),i=!1,this.options.extensions?.inline?.some((n=>!!(r=n.call({lexer:this},e,t))&&(e=e.substring(r.raw.length),t.push(r),!0))))continue;if(r=this.tokenizer.escape(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.tag(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.link(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(r.raw.length);const n=t.at(-1);"text"===r.type&&"text"===n?.type?(n.raw+=r.raw,n.text+=r.text):t.push(r);continue}if(r=this.tokenizer.emStrong(e,n,o)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.codespan(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.br(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.del(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.autolink(e)){e=e.substring(r.raw.length),t.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(e))){e=e.substring(r.raw.length),t.push(r);continue}let s=e;if(this.options.extensions?.startInline){let t=1/0;const n=e.slice(1);let r;this.options.extensions.startInline.forEach((e=>{r=e.call({lexer:this},n),"number"==typeof r&&r>=0&&(t=Math.min(t,r))})),t<1/0&&t>=0&&(s=e.substring(0,t+1))}if(r=this.tokenizer.inlineText(s)){e=e.substring(r.raw.length),"_"!==r.raw.slice(-1)&&(o=r.raw.slice(-1)),i=!0;const n=t.at(-1);"text"===n?.type?(n.raw+=r.raw,n.text+=r.text):t.push(r)}else if(e){const t="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw new Error(t)}}return t}}class le{options;parser;constructor(t){this.options=t||e.defaults}space(e){return""}code({text:e,lang:t,escaped:n}){const r=(t||"").match(o.notSpaceStart)?.[0],i=e.replace(o.endingNewline,"")+"\n";return r?'<pre><code class="language-'+Z(r)+'">'+(n?i:Z(i,!0))+"</code></pre>\n":"<pre><code>"+(n?i:Z(i,!0))+"</code></pre>\n"}blockquote({tokens:e}){return`<blockquote>\n${this.parser.parse(e)}</blockquote>\n`}html({text:e}){return e}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>\n`}hr(e){return"<hr>\n"}list(e){const t=e.ordered,n=e.start;let r="";for(let t=0;t<e.items.length;t++){const n=e.items[t];r+=this.listitem(n)}const i=t?"ol":"ul";return"<"+i+(t&&1!==n?' start="'+n+'"':"")+">\n"+r+"</"+i+">\n"}listitem(e){let t="";if(e.task){const n=this.checkbox({checked:!!e.checked});e.loose?"paragraph"===e.tokens[0]?.type?(e.tokens[0].text=n+" "+e.tokens[0].text,e.tokens[0].tokens&&e.tokens[0].tokens.length>0&&"text"===e.tokens[0].tokens[0].type&&(e.tokens[0].tokens[0].text=n+" "+Z(e.tokens[0].tokens[0].text),e.tokens[0].tokens[0].escaped=!0)):e.tokens.unshift({type:"text",raw:n+" ",text:n+" ",escaped:!0}):t+=n+" "}return t+=this.parser.parse(e.tokens,!!e.loose),`<li>${t}</li>\n`}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox">'}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>\n`}table(e){let t="",n="";for(let t=0;t<e.header.length;t++)n+=this.tablecell(e.header[t]);t+=this.tablerow({text:n});let r="";for(let t=0;t<e.rows.length;t++){const i=e.rows[t];n="";for(let e=0;e<i.length;e++)n+=this.tablecell(i[e]);r+=this.tablerow({text:n})}return r&&(r=`<tbody>${r}</tbody>`),"<table>\n<thead>\n"+t+"</thead>\n"+r+"</table>\n"}tablerow({text:e}){return`<tr>\n${e}</tr>\n`}tablecell(e){const t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>\n`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${Z(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){const r=this.parser.parseInline(n),i=ee(e);if(null===i)return r;let o='<a href="'+(e=i)+'"';return t&&(o+=' title="'+Z(t)+'"'),o+=">"+r+"</a>",o}image({href:e,title:t,text:n}){const r=ee(e);if(null===r)return Z(n);let i=`<img src="${e=r}" alt="${n}"`;return t&&(i+=` title="${Z(t)}"`),i+=">",i}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:Z(e.text)}}class ce{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}}class ue{options;renderer;textRenderer;constructor(t){this.options=t||e.defaults,this.options.renderer=this.options.renderer||new le,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new ce}static parse(e,t){return new ue(t).parse(e)}static parseInline(e,t){return new ue(t).parseInline(e)}parse(e,t=!0){let n="";for(let r=0;r<e.length;r++){const i=e[r];if(this.options.extensions?.renderers?.[i.type]){const e=i,t=this.options.extensions.renderers[e.type].call({parser:this},e);if(!1!==t||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(e.type)){n+=t||"";continue}}const o=i;switch(o.type){case"space":n+=this.renderer.space(o);continue;case"hr":n+=this.renderer.hr(o);continue;case"heading":n+=this.renderer.heading(o);continue;case"code":n+=this.renderer.code(o);continue;case"table":n+=this.renderer.table(o);continue;case"blockquote":n+=this.renderer.blockquote(o);continue;case"list":n+=this.renderer.list(o);continue;case"html":n+=this.renderer.html(o);continue;case"paragraph":n+=this.renderer.paragraph(o);continue;case"text":{let i=o,s=this.renderer.text(i);for(;r+1<e.length&&"text"===e[r+1].type;)i=e[++r],s+="\n"+this.renderer.text(i);n+=t?this.renderer.paragraph({type:"paragraph",raw:s,text:s,tokens:[{type:"text",raw:s,text:s,escaped:!0}]}):s;continue}default:{const e='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(e),"";throw new Error(e)}}}return n}parseInline(e,t=this.renderer){let n="";for(let r=0;r<e.length;r++){const i=e[r];if(this.options.extensions?.renderers?.[i.type]){const e=this.options.extensions.renderers[i.type].call({parser:this},i);if(!1!==e||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(i.type)){n+=e||"";continue}}const o=i;switch(o.type){case"escape":case"text":n+=t.text(o);break;case"html":n+=t.html(o);break;case"link":n+=t.link(o);break;case"image":n+=t.image(o);break;case"strong":n+=t.strong(o);break;case"em":n+=t.em(o);break;case"codespan":n+=t.codespan(o);break;case"br":n+=t.br(o);break;case"del":n+=t.del(o);break;default:{const e='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(e),"";throw new Error(e)}}}return n}}class de{options;block;constructor(t){this.options=t||e.defaults}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}provideLexer(){return this.block?ae.lex:ae.lexInline}provideParser(){return this.block?ue.parse:ue.parseInline}}class he{defaults=t();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=ue;Renderer=le;TextRenderer=ce;Lexer=ae;Tokenizer=se;Hooks=de;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(this,r)),r.type){case"table":{const e=r;for(const r of e.header)n=n.concat(this.walkTokens(r.tokens,t));for(const r of e.rows)for(const e of r)n=n.concat(this.walkTokens(e.tokens,t));break}case"list":{const e=r;n=n.concat(this.walkTokens(e.items,t));break}default:{const e=r;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach((r=>{const i=e[r].flat(1/0);n=n.concat(this.walkTokens(i,t))})):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){const t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach((e=>{const n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach((e=>{if(!e.name)throw new Error("extension name required");if("renderer"in e){const n=t.renderers[e.name];t.renderers[e.name]=n?function(...t){let r=e.renderer.apply(this,t);return!1===r&&(r=n.apply(this,t)),r}:e.renderer}if("tokenizer"in e){if(!e.level||"block"!==e.level&&"inline"!==e.level)throw new Error("extension level must be 'block' or 'inline'");const n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&("block"===e.level?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:"inline"===e.level&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}"childTokens"in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)})),n.extensions=t),e.renderer){const t=this.defaults.renderer||new le(this.defaults);for(const n in e.renderer){if(!(n in t))throw new Error(`renderer '${n}' does not exist`);if(["options","parser"].includes(n))continue;const r=n,i=e.renderer[r],o=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return!1===n&&(n=o.apply(t,e)),n||""}}n.renderer=t}if(e.tokenizer){const t=this.defaults.tokenizer||new se(this.defaults);for(const n in e.tokenizer){if(!(n in t))throw new Error(`tokenizer '${n}' does not exist`);if(["options","rules","lexer"].includes(n))continue;const r=n,i=e.tokenizer[r],o=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return!1===n&&(n=o.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){const t=this.defaults.hooks||new de;for(const n in e.hooks){if(!(n in t))throw new Error(`hook '${n}' does not exist`);if(["options","block"].includes(n))continue;const r=n,i=e.hooks[r],o=t[r];de.passThroughHooks.has(n)?t[r]=e=>{if(this.defaults.async)return Promise.resolve(i.call(t,e)).then((e=>o.call(t,e)));const n=i.call(t,e);return o.call(t,n)}:t[r]=(...e)=>{let n=i.apply(t,e);return!1===n&&(n=o.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){const t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}})),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return ae.lex(e,t??this.defaults)}parser(e,t){return ue.parse(e,t??this.defaults)}parseMarkdown(e){const t=(t,n)=>{const r={...n},i={...this.defaults,...r},o=this.onError(!!i.silent,!!i.async);if(!0===this.defaults.async&&!1===r.async)return o(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(null==t)return o(new Error("marked(): input parameter is undefined or null"));if("string"!=typeof t)return o(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));i.hooks&&(i.hooks.options=i,i.hooks.block=e);const s=i.hooks?i.hooks.provideLexer():e?ae.lex:ae.lexInline,a=i.hooks?i.hooks.provideParser():e?ue.parse:ue.parseInline;if(i.async)return Promise.resolve(i.hooks?i.hooks.preprocess(t):t).then((e=>s(e,i))).then((e=>i.hooks?i.hooks.processAllTokens(e):e)).then((e=>i.walkTokens?Promise.all(this.walkTokens(e,i.walkTokens)).then((()=>e)):e)).then((e=>a(e,i))).then((e=>i.hooks?i.hooks.postprocess(e):e)).catch(o);try{i.hooks&&(t=i.hooks.preprocess(t));let e=s(t,i);i.hooks&&(e=i.hooks.processAllTokens(e)),i.walkTokens&&this.walkTokens(e,i.walkTokens);let n=a(e,i);return i.hooks&&(n=i.hooks.postprocess(n)),n}catch(e){return o(e)}};return t}onError(e,t){return n=>{if(n.message+="\nPlease report this to https://github.com/markedjs/marked.",e){const e="<p>An error occurred:</p><pre>"+Z(n.message+"",!0)+"</pre>";return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}}const pe=new he;function me(e,t){return pe.parse(e,t)}me.options=me.setOptions=function(e){return pe.setOptions(e),me.defaults=pe.defaults,n(me.defaults),me},me.getDefaults=t,me.defaults=e.defaults,me.use=function(...e){return pe.use(...e),me.defaults=pe.defaults,n(me.defaults),me},me.walkTokens=function(e,t){return pe.walkTokens(e,t)},me.parseInline=pe.parseInline,me.Parser=ue,me.parser=ue.parse,me.Renderer=le,me.TextRenderer=ce,me.Lexer=ae,me.lexer=ae.lex,me.Tokenizer=se,me.Hooks=de,me.parse=me;const fe=me.options,ge=me.setOptions,ve=me.use,ye=me.walkTokens,_e=me.parseInline,Se=me,be=ue.parse,xe=ae.lex;e.Hooks=de,e.Lexer=ae,e.Marked=he,e.Parser=ue,e.Renderer=le,e.TextRenderer=ce,e.Tokenizer=se,e.getDefaults=t,e.lexer=xe,e.marked=me,e.options=fe,e.parse=Se,e.parseInline=_e,e.parser=be,e.setOptions=ge,e.use=ve,e.walkTokens=ye}(sO);var aO={};
|
|
245
|
-
/*! @license DOMPurify 3.2.1 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.1/LICENSE */aO=function(){"use strict";const{entries:e,setPrototypeOf:t,isFrozen:n,getPrototypeOf:r,getOwnPropertyDescriptor:i}=Object;let{freeze:o,seal:s,create:a}=Object,{apply:l,construct:c}="undefined"!=typeof Reflect&&Reflect;o||(o=function(e){return e}),s||(s=function(e){return e}),l||(l=function(e,t,n){return e.apply(t,n)}),c||(c=function(e,t){return new e(...t)});const u=x(Array.prototype.forEach),d=x(Array.prototype.pop),h=x(Array.prototype.push),p=x(String.prototype.toLowerCase),m=x(String.prototype.toString),f=x(String.prototype.match),g=x(String.prototype.replace),v=x(String.prototype.indexOf),y=x(String.prototype.trim),_=x(Object.prototype.hasOwnProperty),S=x(RegExp.prototype.test),b=C(TypeError);function x(e){return 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];return l(e,t,r)}}function C(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return c(e,n)}}function w(e,r){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:p;t&&t(e,null);let o=r.length;for(;o--;){let t=r[o];if("string"==typeof t){const e=i(t);e!==t&&(n(r)||(r[o]=e),t=e)}e[t]=!0}return e}function A(e){for(let t=0;t<e.length;t++)_(e,t)||(e[t]=null);return e}function E(t){const n=a(null);for(const[r,i]of e(t))_(t,r)&&(Array.isArray(i)?n[r]=A(i):i&&"object"==typeof i&&i.constructor===Object?n[r]=E(i):n[r]=i);return n}function I(e,t){for(;null!==e;){const n=i(e,t);if(n){if(n.get)return x(n.get);if("function"==typeof n.value)return x(n.value)}e=r(e)}function n(){return null}return n}const T=o(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","shadow","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),M=o(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),R=o(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),P=o(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),N=o(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),O=o(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),D=o(["#text"]),L=o(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","face","for","headers","height","hidden","high","href","hreflang","id","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),k=o(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),B=o(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),z=o(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),F=s(/\{\{[\w\W]*|[\w\W]*\}\}/gm),U=s(/<%[\w\W]*|[\w\W]*%>/gm),j=s(/\${[\w\W]*}/gm),G=s(/^data-[\-\w.\u00B7-\uFFFF]/),H=s(/^aria-[\-\w]+$/),V=s(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),W=s(/^(?:\w+script|data):/i),q=s(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),J=s(/^html$/i),K=s(/^[a-z][.\w]*(-[.\w]+)+$/i);var Y=Object.freeze({__proto__:null,ARIA_ATTR:H,ATTR_WHITESPACE:q,CUSTOM_ELEMENT:K,DATA_ATTR:G,DOCTYPE_NAME:J,ERB_EXPR:U,IS_ALLOWED_URI:V,IS_SCRIPT_OR_DATA:W,MUSTACHE_EXPR:F,TMPLIT_EXPR:j});const X={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,progressingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Q=function(){return"undefined"==typeof window?null:window},$=function(e,t){if("object"!=typeof e||"function"!=typeof e.createPolicy)return null;let n=null;const r="data-tt-policy-suffix";t&&t.hasAttribute(r)&&(n=t.getAttribute(r));const i="dompurify"+(n?"#"+n:"");try{return e.createPolicy(i,{createHTML:e=>e,createScriptURL:e=>e})}catch(e){return console.warn("TrustedTypes policy "+i+" could not be created."),null}};function Z(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Q();const n=e=>Z(e);if(n.version="3.2.1",n.removed=[],!t||!t.document||t.document.nodeType!==X.document)return n.isSupported=!1,n;let{document:r}=t;const i=r,s=i.currentScript,{DocumentFragment:l,HTMLTemplateElement:c,Node:x,Element:C,NodeFilter:A,NamedNodeMap:F=t.NamedNodeMap||t.MozNamedAttrMap,HTMLFormElement:U,DOMParser:j,trustedTypes:G}=t,H=C.prototype,W=I(H,"cloneNode"),q=I(H,"remove"),K=I(H,"nextSibling"),ee=I(H,"childNodes"),te=I(H,"parentNode");if("function"==typeof c){const e=r.createElement("template");e.content&&e.content.ownerDocument&&(r=e.content.ownerDocument)}let ne,re="";const{implementation:ie,createNodeIterator:oe,createDocumentFragment:se,getElementsByTagName:ae}=r,{importNode:le}=i;let ce={};n.isSupported="function"==typeof e&&"function"==typeof te&&ie&&void 0!==ie.createHTMLDocument;const{MUSTACHE_EXPR:ue,ERB_EXPR:de,TMPLIT_EXPR:he,DATA_ATTR:pe,ARIA_ATTR:me,IS_SCRIPT_OR_DATA:fe,ATTR_WHITESPACE:ge,CUSTOM_ELEMENT:ve}=Y;let{IS_ALLOWED_URI:ye}=Y,_e=null;const Se=w({},[...T,...M,...R,...N,...D]);let be=null;const xe=w({},[...L,...k,...B,...z]);let Ce=Object.seal(a(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),we=null,Ae=null,Ee=!0,Ie=!0,Te=!1,Me=!0,Re=!1,Pe=!0,Ne=!1,Oe=!1,De=!1,Le=!1,ke=!1,Be=!1,ze=!0,Fe=!1;const Ue="user-content-";let je=!0,Ge=!1,He={},Ve=null;const We=w({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let qe=null;const Je=w({},["audio","video","img","source","image","track"]);let Ke=null;const Ye=w({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Xe="http://www.w3.org/1998/Math/MathML",Qe="http://www.w3.org/2000/svg",$e="http://www.w3.org/1999/xhtml";let Ze=$e,et=!1,tt=null;const nt=w({},[Xe,Qe,$e],m);let rt=w({},["mi","mo","mn","ms","mtext"]),it=w({},["annotation-xml"]);const ot=w({},["title","style","font","a","script"]);let st=null;const at=["application/xhtml+xml","text/html"],lt="text/html";let ct=null,ut=null;const dt=r.createElement("form"),ht=function(e){return e instanceof RegExp||e instanceof Function},pt=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!ut||ut!==e){if(e&&"object"==typeof e||(e={}),e=E(e),st=-1===at.indexOf(e.PARSER_MEDIA_TYPE)?lt:e.PARSER_MEDIA_TYPE,ct="application/xhtml+xml"===st?m:p,_e=_(e,"ALLOWED_TAGS")?w({},e.ALLOWED_TAGS,ct):Se,be=_(e,"ALLOWED_ATTR")?w({},e.ALLOWED_ATTR,ct):xe,tt=_(e,"ALLOWED_NAMESPACES")?w({},e.ALLOWED_NAMESPACES,m):nt,Ke=_(e,"ADD_URI_SAFE_ATTR")?w(E(Ye),e.ADD_URI_SAFE_ATTR,ct):Ye,qe=_(e,"ADD_DATA_URI_TAGS")?w(E(Je),e.ADD_DATA_URI_TAGS,ct):Je,Ve=_(e,"FORBID_CONTENTS")?w({},e.FORBID_CONTENTS,ct):We,we=_(e,"FORBID_TAGS")?w({},e.FORBID_TAGS,ct):{},Ae=_(e,"FORBID_ATTR")?w({},e.FORBID_ATTR,ct):{},He=!!_(e,"USE_PROFILES")&&e.USE_PROFILES,Ee=!1!==e.ALLOW_ARIA_ATTR,Ie=!1!==e.ALLOW_DATA_ATTR,Te=e.ALLOW_UNKNOWN_PROTOCOLS||!1,Me=!1!==e.ALLOW_SELF_CLOSE_IN_ATTR,Re=e.SAFE_FOR_TEMPLATES||!1,Pe=!1!==e.SAFE_FOR_XML,Ne=e.WHOLE_DOCUMENT||!1,Le=e.RETURN_DOM||!1,ke=e.RETURN_DOM_FRAGMENT||!1,Be=e.RETURN_TRUSTED_TYPE||!1,De=e.FORCE_BODY||!1,ze=!1!==e.SANITIZE_DOM,Fe=e.SANITIZE_NAMED_PROPS||!1,je=!1!==e.KEEP_CONTENT,Ge=e.IN_PLACE||!1,ye=e.ALLOWED_URI_REGEXP||V,Ze=e.NAMESPACE||$e,rt=e.MATHML_TEXT_INTEGRATION_POINTS||rt,it=e.HTML_INTEGRATION_POINTS||it,Ce=e.CUSTOM_ELEMENT_HANDLING||{},e.CUSTOM_ELEMENT_HANDLING&&ht(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(Ce.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&&ht(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(Ce.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(Ce.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Re&&(Ie=!1),ke&&(Le=!0),He&&(_e=w({},D),be=[],!0===He.html&&(w(_e,T),w(be,L)),!0===He.svg&&(w(_e,M),w(be,k),w(be,z)),!0===He.svgFilters&&(w(_e,R),w(be,k),w(be,z)),!0===He.mathMl&&(w(_e,N),w(be,B),w(be,z))),e.ADD_TAGS&&(_e===Se&&(_e=E(_e)),w(_e,e.ADD_TAGS,ct)),e.ADD_ATTR&&(be===xe&&(be=E(be)),w(be,e.ADD_ATTR,ct)),e.ADD_URI_SAFE_ATTR&&w(Ke,e.ADD_URI_SAFE_ATTR,ct),e.FORBID_CONTENTS&&(Ve===We&&(Ve=E(Ve)),w(Ve,e.FORBID_CONTENTS,ct)),je&&(_e["#text"]=!0),Ne&&w(_e,["html","head","body"]),_e.table&&(w(_e,["tbody"]),delete we.tbody),e.TRUSTED_TYPES_POLICY){if("function"!=typeof e.TRUSTED_TYPES_POLICY.createHTML)throw b('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof e.TRUSTED_TYPES_POLICY.createScriptURL)throw b('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');ne=e.TRUSTED_TYPES_POLICY,re=ne.createHTML("")}else void 0===ne&&(ne=$(G,s)),null!==ne&&"string"==typeof re&&(re=ne.createHTML(""));o&&o(e),ut=e}},mt=w({},[...M,...R,...P]),ft=w({},[...N,...O]),gt=function(e){let t=te(e);t&&t.tagName||(t={namespaceURI:Ze,tagName:"template"});const n=p(e.tagName),r=p(t.tagName);return!!tt[e.namespaceURI]&&(e.namespaceURI===Qe?t.namespaceURI===$e?"svg"===n:t.namespaceURI===Xe?"svg"===n&&("annotation-xml"===r||rt[r]):Boolean(mt[n]):e.namespaceURI===Xe?t.namespaceURI===$e?"math"===n:t.namespaceURI===Qe?"math"===n&&it[r]:Boolean(ft[n]):e.namespaceURI===$e?!(t.namespaceURI===Qe&&!it[r])&&!(t.namespaceURI===Xe&&!rt[r])&&!ft[n]&&(ot[n]||!mt[n]):!("application/xhtml+xml"!==st||!tt[e.namespaceURI]))},vt=function(e){h(n.removed,{element:e});try{te(e).removeChild(e)}catch(t){q(e)}},yt=function(e,t){try{h(n.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){h(n.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e&&!be[e])if(Le||ke)try{vt(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}},_t=function(e){let t=null,n=null;if(De)e="<remove></remove>"+e;else{const t=f(e,/^[\r\n\t ]+/);n=t&&t[0]}"application/xhtml+xml"===st&&Ze===$e&&(e='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+e+"</body></html>");const i=ne?ne.createHTML(e):e;if(Ze===$e)try{t=(new j).parseFromString(i,st)}catch(e){}if(!t||!t.documentElement){t=ie.createDocument(Ze,"template",null);try{t.documentElement.innerHTML=et?re:i}catch(e){}}const o=t.body||t.documentElement;return e&&n&&o.insertBefore(r.createTextNode(n),o.childNodes[0]||null),Ze===$e?ae.call(t,Ne?"html":"body")[0]:Ne?t.documentElement:o},St=function(e){return oe.call(e.ownerDocument||e,e,A.SHOW_ELEMENT|A.SHOW_COMMENT|A.SHOW_TEXT|A.SHOW_PROCESSING_INSTRUCTION|A.SHOW_CDATA_SECTION,null)},bt=function(e){return e instanceof U&&("string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||!(e.attributes instanceof F)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore||"function"!=typeof e.hasChildNodes)},xt=function(e){return"function"==typeof x&&e instanceof x};function Ct(e,t,r){ce[e]&&u(ce[e],(e=>{e.call(n,t,r,ut)}))}const wt=function(e){let t=null;if(Ct("beforeSanitizeElements",e,null),bt(e))return vt(e),!0;const r=ct(e.nodeName);if(Ct("uponSanitizeElement",e,{tagName:r,allowedTags:_e}),e.hasChildNodes()&&!xt(e.firstElementChild)&&S(/<[/\w]/g,e.innerHTML)&&S(/<[/\w]/g,e.textContent))return vt(e),!0;if(e.nodeType===X.progressingInstruction)return vt(e),!0;if(Pe&&e.nodeType===X.comment&&S(/<[/\w]/g,e.data))return vt(e),!0;if(!_e[r]||we[r]){if(!we[r]&&Et(r)){if(Ce.tagNameCheck instanceof RegExp&&S(Ce.tagNameCheck,r))return!1;if(Ce.tagNameCheck instanceof Function&&Ce.tagNameCheck(r))return!1}if(je&&!Ve[r]){const t=te(e)||e.parentNode,n=ee(e)||e.childNodes;if(n&&t)for(let r=n.length-1;r>=0;--r){const i=W(n[r],!0);i.__removalCount=(e.__removalCount||0)+1,t.insertBefore(i,K(e))}}return vt(e),!0}return e instanceof C&&!gt(e)?(vt(e),!0):"noscript"!==r&&"noembed"!==r&&"noframes"!==r||!S(/<\/no(script|embed|frames)/i,e.innerHTML)?(Re&&e.nodeType===X.text&&(t=e.textContent,u([ue,de,he],(e=>{t=g(t,e," ")})),e.textContent!==t&&(h(n.removed,{element:e.cloneNode()}),e.textContent=t)),Ct("afterSanitizeElements",e,null),!1):(vt(e),!0)},At=function(e,t,n){if(ze&&("id"===t||"name"===t)&&(n in r||n in dt))return!1;if(Ie&&!Ae[t]&&S(pe,t));else if(Ee&&S(me,t));else if(!be[t]||Ae[t]){if(!(Et(e)&&(Ce.tagNameCheck instanceof RegExp&&S(Ce.tagNameCheck,e)||Ce.tagNameCheck instanceof Function&&Ce.tagNameCheck(e))&&(Ce.attributeNameCheck instanceof RegExp&&S(Ce.attributeNameCheck,t)||Ce.attributeNameCheck instanceof Function&&Ce.attributeNameCheck(t))||"is"===t&&Ce.allowCustomizedBuiltInElements&&(Ce.tagNameCheck instanceof RegExp&&S(Ce.tagNameCheck,n)||Ce.tagNameCheck instanceof Function&&Ce.tagNameCheck(n))))return!1}else if(Ke[t]);else if(S(ye,g(n,ge,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==v(n,"data:")||!qe[e])if(Te&&!S(fe,g(n,ge,"")));else if(n)return!1;return!0},Et=function(e){return"annotation-xml"!==e&&f(e,ve)},It=function(e){Ct("beforeSanitizeAttributes",e,null);const{attributes:t}=e;if(!t)return;const r={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:be,forceKeepAttr:void 0};let i=t.length;for(;i--;){const o=t[i],{name:s,namespaceURI:a,value:l}=o,c=ct(s);let h="value"===s?l:y(l);if(r.attrName=c,r.attrValue=h,r.keepAttr=!0,r.forceKeepAttr=void 0,Ct("uponSanitizeAttribute",e,r),h=r.attrValue,!Fe||"id"!==c&&"name"!==c||(yt(s,e),h=Ue+h),Pe&&S(/((--!?|])>)|<\/(style|title)/i,h)){yt(s,e);continue}if(r.forceKeepAttr)continue;if(yt(s,e),!r.keepAttr)continue;if(!Me&&S(/\/>/i,h)){yt(s,e);continue}Re&&u([ue,de,he],(e=>{h=g(h,e," ")}));const p=ct(e.nodeName);if(At(p,c,h)){if(ne&&"object"==typeof G&&"function"==typeof G.getAttributeType)if(a);else switch(G.getAttributeType(p,c)){case"TrustedHTML":h=ne.createHTML(h);break;case"TrustedScriptURL":h=ne.createScriptURL(h)}try{a?e.setAttributeNS(a,s,h):e.setAttribute(s,h),bt(e)?vt(e):d(n.removed)}catch(e){}}}Ct("afterSanitizeAttributes",e,null)},Tt=function e(t){let n=null;const r=St(t);for(Ct("beforeSanitizeShadowDOM",t,null);n=r.nextNode();)Ct("uponSanitizeShadowNode",n,null),wt(n)||(n.content instanceof l&&e(n.content),It(n));Ct("afterSanitizeShadowDOM",t,null)};return n.sanitize=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=null,o=null,s=null,a=null;if(et=!e,et&&(e="\x3c!--\x3e"),"string"!=typeof e&&!xt(e)){if("function"!=typeof e.toString)throw b("toString is not a function");if("string"!=typeof(e=e.toString()))throw b("dirty is not a string, aborting")}if(!n.isSupported)return e;if(Oe||pt(t),n.removed=[],"string"==typeof e&&(Ge=!1),Ge){if(e.nodeName){const t=ct(e.nodeName);if(!_e[t]||we[t])throw b("root node is forbidden and cannot be sanitized in-place")}}else if(e instanceof x)r=_t("\x3c!----\x3e"),o=r.ownerDocument.importNode(e,!0),o.nodeType===X.element&&"BODY"===o.nodeName||"HTML"===o.nodeName?r=o:r.appendChild(o);else{if(!Le&&!Re&&!Ne&&-1===e.indexOf("<"))return ne&&Be?ne.createHTML(e):e;if(r=_t(e),!r)return Le?null:Be?re:""}r&&De&&vt(r.firstChild);const c=St(Ge?e:r);for(;s=c.nextNode();)wt(s)||(s.content instanceof l&&Tt(s.content),It(s));if(Ge)return e;if(Le){if(ke)for(a=se.call(r.ownerDocument);r.firstChild;)a.appendChild(r.firstChild);else a=r;return(be.shadowroot||be.shadowrootmode)&&(a=le.call(i,a,!0)),a}let d=Ne?r.outerHTML:r.innerHTML;return Ne&&_e["!doctype"]&&r.ownerDocument&&r.ownerDocument.doctype&&r.ownerDocument.doctype.name&&S(J,r.ownerDocument.doctype.name)&&(d="<!DOCTYPE "+r.ownerDocument.doctype.name+">\n"+d),Re&&u([ue,de,he],(e=>{d=g(d,e," ")})),ne&&Be?ne.createHTML(d):d},n.setConfig=function(){pt(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),Oe=!0},n.clearConfig=function(){ut=null,Oe=!1},n.isValidAttribute=function(e,t,n){ut||pt({});const r=ct(e),i=ct(t);return At(r,i,n)},n.addHook=function(e,t){"function"==typeof t&&(ce[e]=ce[e]||[],h(ce[e],t))},n.removeHook=function(e){if(ce[e])return d(ce[e])},n.removeHooks=function(e){ce[e]&&(ce[e]=[])},n.removeAllHooks=function(){ce={}},n}return Z()}();const lO=[{value:"IT",label:"Italiano"},{value:"EN",label:"English"},{value:"DE",label:"Deutsch"},{value:"ES",label:"Español"},{value:"FR",label:"Français"},{value:"PT",label:"Português"},{value:"UK",label:"Українська"},{value:"RU",label:"Русский"},{value:"PL",label:"Polski"},{value:"FI",label:"Suomi"},{value:"EL",label:"Ελληνικά"},{value:"AR",label:"العربية"},{value:"ZH",label:"中文"},{value:"JA",label:"日本語"}],cO=["en","it","fr","es","de"],uO=["image/jpeg","image/png","image/jpg","image/gif","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/pdf","video/mp4","video/avi","audio/mpeg3","audio/wav","audio/mpeg","video/mpeg","model/gltf-binary"],dO="👤",hO=[{name:"text",lang:"text",mimeType:"text/plain",monacoLang:"plaintext",executable:!0},{name:"javascript/jsx",lang:"jsx",mimeType:"text/javascript",monacoLang:"javascript",executable:!0},{name:"typescript/tsx",lang:"tsx",mimeType:"text/ecmascript",monacoLang:"typescript",executable:!0},{name:"json",lang:"json",mimeType:"application/json",monacoLang:"json",executable:!0},{name:"css",lang:"scss",mimeType:"text/css",monacoLang:"css",executable:!0},{name:"html/xml",lang:"tsx",mimeType:"application/xml",monacoLang:"xml"},{name:"bash",lang:"bash",mimeType:"application/x-sh",monacoLang:"shell"},{name:"python",lang:"python",mimeType:"text/x-python",monacoLang:"python"},{name:"cpp/csharp",lang:"cpp",mimeType:"text/x-c++src",monacoLang:"cpp"},{name:"php",lang:"php",mimeType:"application/x-php",monacoLang:"php"},{name:"ruby",lang:"ruby",mimeType:"text/x-ruby",monacoLang:"ruby"},{name:"sql",lang:"sql",mimeType:"text/x-sql",monacoLang:"sql"}],pO={it:[{text:"",delayAfter:10},{text:"Cerco l'esperto più adatto",delayAfter:5},{text:"Contatto l'esperto",delayAfter:3},{text:"Spiego all'esperto la domanda",delayAfter:2},{text:"L'esperto sta preparando una risposta",delayAfter:6},{text:"Genero una risposta adatta",delayAfter:3}],en:[{text:"",delayAfter:10},{text:"I'm looking for the most suitable expert",delayAfter:5},{text:"I'm contacting the expert",delayAfter:3},{text:"I'm explaining the question to the expert",delayAfter:2},{text:"The expert is preparing an answer",delayAfter:6},{text:"I am generating a suitable answer",delayAfter:3}]},mO=4e3,fO=300;var gO={};gO=function(){"use strict";var e=/[\0-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,t=/[\0-\x1F\x7F-\x9F]/,n=/[!-#%-\*,-\/:;\?@\[-\]_\{\}\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061D-\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1B7D\u1B7E\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u2E52-\u2E5D\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD803[\uDEAD\uDF55-\uDF59\uDF86-\uDF89]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDC4B-\uDC4F\uDC5A\uDC5B\uDC5D\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDE60-\uDE6C\uDEB9\uDF3C-\uDF3E]|\uD806[\uDC3B\uDD44-\uDD46\uDDE2\uDE3F-\uDE46\uDE9A-\uDE9C\uDE9E-\uDEA2\uDF00-\uDF09]|\uD807[\uDC41-\uDC45\uDC70\uDC71\uDEF7\uDEF8\uDF43-\uDF4F\uDFFF]|\uD809[\uDC70-\uDC74]|\uD80B[\uDFF1\uDFF2]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD81B[\uDE97-\uDE9A\uDFE2]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]|\uD83A[\uDD5E\uDD5F]/,r=/[ \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/;function i(i){const o={};i=i||{},o.src_Any=e.source,o.src_Cc=t.source,o.src_Z=r.source,o.src_P=n.source,o.src_ZPCc=[o.src_Z,o.src_P,o.src_Cc].join("|"),o.src_ZCc=[o.src_Z,o.src_Cc].join("|");const s="[><|]";return o.src_pseudo_letter="(?:(?!"+s+"|"+o.src_ZPCc+")"+o.src_Any+")",o.src_ip4="(?:(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)",o.src_auth="(?:(?:(?!"+o.src_ZCc+"|[@/\\[\\]()]).)+@)?",o.src_port="(?::(?:6(?:[0-4]\\d{3}|5(?:[0-4]\\d{2}|5(?:[0-2]\\d|3[0-5])))|[1-5]?\\d{1,4}))?",o.src_host_terminator="(?=$|"+s+"|"+o.src_ZPCc+")(?!"+(i["---"]?"-(?!--)|":"-|")+"_|:\\d|\\.-|\\.(?!$|"+o.src_ZPCc+"))",o.src_path="(?:[/?#](?:(?!"+o.src_ZCc+"|"+s+"|[()[\\]{}.,\"'?!\\-;]).|\\[(?:(?!"+o.src_ZCc+"|\\]).)*\\]|\\((?:(?!"+o.src_ZCc+"|[)]).)*\\)|\\{(?:(?!"+o.src_ZCc+'|[}]).)*\\}|\\"(?:(?!'+o.src_ZCc+'|["]).)+\\"|\\\'(?:(?!'+o.src_ZCc+"|[']).)+\\'|\\'(?="+o.src_pseudo_letter+"|[-])|\\.{2,}[a-zA-Z0-9%/&]|\\.(?!"+o.src_ZCc+"|[.]|$)|"+(i["---"]?"\\-(?!--(?:[^-]|$))(?:-*)|":"\\-+|")+",(?!"+o.src_ZCc+"|$)|;(?!"+o.src_ZCc+"|$)|\\!+(?!"+o.src_ZCc+"|[!]|$)|\\?(?!"+o.src_ZCc+"|[?]|$))+|\\/)?",o.src_email_name='[\\-;:&=\\+\\$,\\.a-zA-Z0-9_][\\-;:&=\\+\\$,\\"\\.a-zA-Z0-9_]*',o.src_xn="xn--[a-z0-9\\-]{1,59}",o.src_domain_root="(?:"+o.src_xn+"|"+o.src_pseudo_letter+"{1,63})",o.src_domain="(?:"+o.src_xn+"|(?:"+o.src_pseudo_letter+")|(?:"+o.src_pseudo_letter+"(?:-|"+o.src_pseudo_letter+"){0,61}"+o.src_pseudo_letter+"))",o.src_host="(?:(?:(?:(?:"+o.src_domain+")\\.)*"+o.src_domain+"))",o.tpl_host_fuzzy="(?:"+o.src_ip4+"|(?:(?:(?:"+o.src_domain+")\\.)+(?:%TLDS%)))",o.tpl_host_no_ip_fuzzy="(?:(?:(?:"+o.src_domain+")\\.)+(?:%TLDS%))",o.src_host_strict=o.src_host+o.src_host_terminator,o.tpl_host_fuzzy_strict=o.tpl_host_fuzzy+o.src_host_terminator,o.src_host_port_strict=o.src_host+o.src_port+o.src_host_terminator,o.tpl_host_port_fuzzy_strict=o.tpl_host_fuzzy+o.src_port+o.src_host_terminator,o.tpl_host_port_no_ip_fuzzy_strict=o.tpl_host_no_ip_fuzzy+o.src_port+o.src_host_terminator,o.tpl_host_fuzzy_test="localhost|www\\.|\\.\\d{1,3}\\.|(?:\\.(?:%TLDS%)(?:"+o.src_ZPCc+"|>|$))",o.tpl_email_fuzzy="(^|"+s+'|"|\\(|'+o.src_ZCc+")("+o.src_email_name+"@"+o.tpl_host_fuzzy_strict+")",o.tpl_link_fuzzy="(^|(?![.:/\\-_@])(?:[$+<=>^`||]|"+o.src_ZPCc+"))((?![$+<=>^`||])"+o.tpl_host_port_fuzzy_strict+o.src_path+")",o.tpl_link_no_ip_fuzzy="(^|(?![.:/\\-_@])(?:[$+<=>^`||]|"+o.src_ZPCc+"))((?![$+<=>^`||])"+o.tpl_host_port_no_ip_fuzzy_strict+o.src_path+")",o}function o(e){return Array.prototype.slice.call(arguments,1).forEach((function(t){t&&Object.keys(t).forEach((function(n){e[n]=t[n]}))})),e}function s(e){return Object.prototype.toString.call(e)}function a(e){return"[object String]"===s(e)}function l(e){return"[object Object]"===s(e)}function c(e){return"[object RegExp]"===s(e)}function u(e){return"[object Function]"===s(e)}function d(e){return e.replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}const h={fuzzyLink:!0,fuzzyEmail:!0,fuzzyIP:!1};function p(e){return Object.keys(e||{}).reduce((function(e,t){return e||h.hasOwnProperty(t)}),!1)}const m={"http:":{validate:function(e,t,n){const r=e.slice(t);return n.re.http||(n.re.http=new RegExp("^\\/\\/"+n.re.src_auth+n.re.src_host_port_strict+n.re.src_path,"i")),n.re.http.test(r)?r.match(n.re.http)[0].length:0}},"https:":"http:","ftp:":"http:","//":{validate:function(e,t,n){const r=e.slice(t);return n.re.no_http||(n.re.no_http=new RegExp("^"+n.re.src_auth+"(?:localhost|(?:(?:"+n.re.src_domain+")\\.)+"+n.re.src_domain_root+")"+n.re.src_port+n.re.src_host_terminator+n.re.src_path,"i")),n.re.no_http.test(r)?t>=3&&":"===e[t-3]||t>=3&&"/"===e[t-3]?0:r.match(n.re.no_http)[0].length:0}},"mailto:":{validate:function(e,t,n){const r=e.slice(t);return n.re.mailto||(n.re.mailto=new RegExp("^"+n.re.src_email_name+"@"+n.re.src_host_strict,"i")),n.re.mailto.test(r)?r.match(n.re.mailto)[0].length:0}}},f="a[cdefgilmnoqrstuwxz]|b[abdefghijmnorstvwyz]|c[acdfghiklmnoruvwxyz]|d[ejkmoz]|e[cegrstu]|f[ijkmor]|g[abdefghilmnpqrstuwy]|h[kmnrtu]|i[delmnoqrst]|j[emop]|k[eghimnprwyz]|l[abcikrstuvy]|m[acdeghklmnopqrstuvwxyz]|n[acefgilopruz]|om|p[aefghklmnrstwy]|qa|r[eosuw]|s[abcdeghijklmnortuvxyz]|t[cdfghjklmnortvwz]|u[agksyz]|v[aceginu]|w[fs]|y[et]|z[amw]",g="biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф".split("|");function v(e){e.__index__=-1,e.__text_cache__=""}function y(e){return function(t,n){const r=t.slice(n);return e.test(r)?r.match(e)[0].length:0}}function _(){return function(e,t){t.normalize(e)}}function S(e){const t=e.re=i(e.__opts__),n=e.__tlds__.slice();function r(e){return e.replace("%TLDS%",t.src_tlds)}e.onCompile(),e.__tlds_replaced__||n.push(f),n.push(t.src_xn),t.src_tlds=n.join("|"),t.email_fuzzy=RegExp(r(t.tpl_email_fuzzy),"i"),t.link_fuzzy=RegExp(r(t.tpl_link_fuzzy),"i"),t.link_no_ip_fuzzy=RegExp(r(t.tpl_link_no_ip_fuzzy),"i"),t.host_fuzzy_test=RegExp(r(t.tpl_host_fuzzy_test),"i");const o=[];function s(e,t){throw new Error('(LinkifyIt) Invalid schema "'+e+'": '+t)}e.__compiled__={},Object.keys(e.__schemas__).forEach((function(t){const n=e.__schemas__[t];if(null===n)return;const r={validate:null,link:null};if(e.__compiled__[t]=r,l(n))return c(n.validate)?r.validate=y(n.validate):u(n.validate)?r.validate=n.validate:s(t,n),void(u(n.normalize)?r.normalize=n.normalize:n.normalize?s(t,n):r.normalize=_());a(n)?o.push(t):s(t,n)})),o.forEach((function(t){e.__compiled__[e.__schemas__[t]]&&(e.__compiled__[t].validate=e.__compiled__[e.__schemas__[t]].validate,e.__compiled__[t].normalize=e.__compiled__[e.__schemas__[t]].normalize)})),e.__compiled__[""]={validate:null,normalize:_()};const h=Object.keys(e.__compiled__).filter((function(t){return t.length>0&&e.__compiled__[t]})).map(d).join("|");e.re.schema_test=RegExp("(^|(?!_)(?:[><|]|"+t.src_ZPCc+"))("+h+")","i"),e.re.schema_search=RegExp("(^|(?!_)(?:[><|]|"+t.src_ZPCc+"))("+h+")","ig"),e.re.schema_at_start=RegExp("^"+e.re.schema_search.source,"i"),e.re.pretest=RegExp("("+e.re.schema_test.source+")|("+e.re.host_fuzzy_test.source+")|@","i"),v(e)}function b(e,t){const n=e.__index__,r=e.__last_index__,i=e.__text_cache__.slice(n,r);this.schema=e.__schema__.toLowerCase(),this.index=n+t,this.lastIndex=r+t,this.raw=i,this.text=i,this.url=i}function x(e,t){const n=new b(e,t);return e.__compiled__[n.schema].normalize(n,e),n}function C(e,t){if(!(this instanceof C))return new C(e,t);t||p(e)&&(t=e,e={}),this.__opts__=o({},h,t),this.__index__=-1,this.__last_index__=-1,this.__schema__="",this.__text_cache__="",this.__schemas__=o({},m,e),this.__compiled__={},this.__tlds__=g,this.__tlds_replaced__=!1,this.re={},S(this)}function w(e={},t={}){const n=new C(e,t);return E(n,t),{extensions:[{name:"autolink",level:"inline",start:e=>{const t=A(n,e);if(t)return t.index},tokenizer(e){if(this.lexer.state.inLink)return;const t=A(n,e);if(!t)return;let r;return 0===t.index?r=t.raw:1===t.index&&"<"===e.charAt(0)&&">"===e.charAt(t.lastIndex)&&(r=`<${t.raw}>`),r?{type:"link",raw:r,text:t.text,href:t.url,tokens:[{type:"text",raw:t.text,text:t.text}]}:void 0}}]}}function A(e,t){const n=e.match(t);if(n&&n.length)return n[0]}function E(e,t){const n=t.tlds;delete t.tlds;const r=t.tldsKeepOld;delete t.tldsKeepOld,n&&e.tlds(n,r)}return C.prototype.add=function(e,t){return this.__schemas__[e]=t,S(this),this},C.prototype.set=function(e){return this.__opts__=o(this.__opts__,e),this},C.prototype.test=function(e){if(this.__text_cache__=e,this.__index__=-1,!e.length)return!1;let t,n,r,i,o,s,a,l,c;if(this.re.schema_test.test(e))for(a=this.re.schema_search,a.lastIndex=0;null!==(t=a.exec(e));)if(i=this.testSchemaAt(e,t[2],a.lastIndex),i){this.__schema__=t[2],this.__index__=t.index+t[1].length,this.__last_index__=t.index+t[0].length+i;break}return this.__opts__.fuzzyLink&&this.__compiled__["http:"]&&(l=e.search(this.re.host_fuzzy_test),l>=0&&(this.__index__<0||l<this.__index__)&&null!==(n=e.match(this.__opts__.fuzzyIP?this.re.link_fuzzy:this.re.link_no_ip_fuzzy))&&(o=n.index+n[1].length,(this.__index__<0||o<this.__index__)&&(this.__schema__="",this.__index__=o,this.__last_index__=n.index+n[0].length))),this.__opts__.fuzzyEmail&&this.__compiled__["mailto:"]&&(c=e.indexOf("@"),c>=0&&null!==(r=e.match(this.re.email_fuzzy))&&(o=r.index+r[1].length,s=r.index+r[0].length,(this.__index__<0||o<this.__index__||o===this.__index__&&s>this.__last_index__)&&(this.__schema__="mailto:",this.__index__=o,this.__last_index__=s))),this.__index__>=0},C.prototype.pretest=function(e){return this.re.pretest.test(e)},C.prototype.testSchemaAt=function(e,t,n){return this.__compiled__[t.toLowerCase()]?this.__compiled__[t.toLowerCase()].validate(e,n,this):0},C.prototype.match=function(e){const t=[];let n=0;this.__index__>=0&&this.__text_cache__===e&&(t.push(x(this,n)),n=this.__last_index__);let r=n?e.slice(n):e;for(;this.test(r);)t.push(x(this,n)),r=r.slice(this.__last_index__),n+=this.__last_index__;return t.length?t:null},C.prototype.matchAtStart=function(e){if(this.__text_cache__=e,this.__index__=-1,!e.length)return null;const t=this.re.schema_at_start.exec(e);if(!t)return null;const n=this.testSchemaAt(e,t[2],t[0].length);return n?(this.__schema__=t[2],this.__index__=t.index+t[1].length,this.__last_index__=t.index+t[0].length+n,x(this,0)):null},C.prototype.tlds=function(e,t){return e=Array.isArray(e)?e:[e],t?(this.__tlds__=this.__tlds__.concat(e).sort().filter((function(e,t,n){return e!==n[t-1]})).reverse(),S(this),this):(this.__tlds__=e.slice(),this.__tlds_replaced__=!0,S(this),this)},C.prototype.normalize=function(e){e.schema||(e.url="http://"+e.url),"mailto:"!==e.schema||/^mailto:/i.test(e.url)||(e.url="mailto:"+e.url)},C.prototype.onCompile=function(){},w}();var vO={};vO=function(e){"use strict";const t=/^(\${1,2})(?!\$)((?:\\.|[^\\\n])*?(?:\\.|[^\\\n\$]))\1(?=[\s?!\.,:?!。,:]|$)/,n=/^(\${1,2})(?!\$)((?:\\.|[^\\\n])*?(?:\\.|[^\\\n\$]))\1/,r=/^(\${1,2})\n((?:\\[^]|[^\\])+?)\n\1(?:\n|$)/;function i(e={}){return{extensions:[s(e,o(e,!1)),a(e,o(e,!0))]}}function o(t,n){return r=>e.renderToString(r.text,{...t,displayMode:r.displayMode})+(n?"\n":"")}function s(e,r){const i=e&&e.nonStandard,o=i?n:t;return{name:"inlineKatex",level:"inline",start(e){let t,n=e;for(;n;){if(t=n.indexOf("$"),-1===t)return;if((i?t>-1:0===t||" "===n.charAt(t-1))&&n.substring(t).match(o))return t;n=n.substring(t+1).replace(/^\$+/,"")}},tokenizer(e,t){const n=e.match(o);if(n)return{type:"inlineKatex",raw:n[0],text:n[2].trim(),displayMode:2===n[1].length}},renderer:r}}function a(e,t){return{name:"blockKatex",level:"block",tokenizer(e,t){const n=e.match(r);if(n)return{type:"blockKatex",raw:n[0],text:n[2].trim(),displayMode:2===n[1].length}},renderer:t}}return i}(o("kqAxc"));const yO=(e,t,n,r)=>{if(!t.rowspan)return"";return`${`<${n}`+(t.colspan>1?` colspan=${t.colspan}`:"")+(t.rowspan>1?` rowspan=${t.rowspan}`:"")+(r?` align=${r}`:"")+">"+e}</${n}>\n`},_O=(e,t,n=[])=>{var r,i,o;const s=[...e.matchAll(/(?:[^|\\]|\\.?)+(?:\|+|$)/g)].map((e=>e[0]));(null===(r=s[0])||void 0===r?void 0:r.trim())||s.shift(),(null===(i=s[s.length-1])||void 0===i?void 0:i.trim())||s.pop();let a,l,c,u,d,h=0;for(a=0;a<s.length;a++){if(c=s[a].split(/\|+$/)[0],s[a]={rowspan:1,colspan:Math.max(s[a].length-c.length,1),text:c.trim().replace(/\\\|/g,"|")},"^"===c.slice(-1)&&n.length)for(d=0,l=0;l<n.length;l++){if(u=n[l],d===h&&u.colspan===s[a].colspan){s[a].rowSpanTarget=null!==(o=u.rowSpanTarget)&&void 0!==o?o:u,s[a].rowSpanTarget.text+=` ${s[a].text.slice(0,-1)}`,s[a].rowSpanTarget.rowspan+=1,s[a].rowspan=0;break}if(d+=u.colspan,d>h)break}h+=s[a].colspan}if(h>t)s.splice(t);else for(;h<t;)s.push({colspan:1,text:""}),h+=1;return s};sO.marked.use({async:!1,gfm:!0,pedantic:!1,renderer:{link:({href:e,title:t,text:n})=>{const r=e?yR(e):null;if(null===r)return n;let i='<a href="'+(e=r)+'"';return t&&(i+=' title="'+t+'"'),i+=' target="_blank" rel="noopener noreferrer">'+n+"</a>",i}}}),sO.marked.use(t(gO)()),sO.marked.use({extensions:[{name:"spanTable",level:"block",start(e){var t;return null===(t=e.match(/^\n *([^\n ].*\|.*)\n/))||void 0===t?void 0:t.index},tokenizer(e,t){const n=new RegExp("^ *([^\\n ].*\\|.*\\n(?: *[^\\s].*\\n)*?) {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n| {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)| {0,3}#{1,6} | {0,3}>| {4}[^\\n]| {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n| {0,3}(?:[*+-]|1[.)]) |<\\/?(?:address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)(?: +|\\n|\\/?>)|<(?:script|pre|style|textarea|!--)).*(?:\\n|$))*)\\n*|$)").exec(e);if(n){const e={type:"spanTable",header:n[1].replace(/\n$/,"").split("\n"),align:n[2].replace(/^ *|\| *$/g,"").split(/ *\| */),rows:n[3]?n[3].replace(/\n$/,"").split("\n"):[]};e.header[0]=_O(e.header[0]);const t=e.header[0].reduce(((e,t)=>e+t.colspan),0);if(t===e.align.length){let r,i,o,s;e.raw=n[0];let a=e.align.length;for(r=0;r<a;r++)/^ *-+: *$/.test(e.align[r])?e.align[r]="right":/^ *:-+: *$/.test(e.align[r])?e.align[r]="center":/^ *:-+ *$/.test(e.align[r])?e.align[r]="left":e.align[r]=null;for(a=e.header.length,r=1;r<a;r++)e.header[r]=_O(e.header[r],t,e.header[r-1]);for(a=e.rows.length,r=0;r<a;r++)e.rows[r]=_O(e.rows[r],t,e.rows[r-1]);for(a=e.header.length,i=0;i<a;i++)for(s=e.header[i],o=0;o<s.length;o++)s[o].tokens=[],this.lexer.inline(s[o].text,s[o].tokens);for(a=e.rows.length,i=0;i<a;i++)for(s=e.rows[i],o=0;o<s.length;o++)s[o].tokens=[],this.lexer.inline(s[o].text,s[o].tokens);return e}}},renderer(e){let t,n,r,i,o,s,a='<div class="memori--responsive-table-wrapper"><table class="memori--table memori--table--compact">';for(a+="<thead>",t=0;t<e.header.length;t++){r=e.header[t];let o=0;for(a+="<tr>",n=0;n<r.length;n++)i=r[n],s=this.parser.parseInline(i.tokens),a+=yO(s,i,"th",e.align[o]),o+=i.colspan;a+="</tr>"}if(a+="</thead>",e.rows.length){for(a+="<tbody>",t=0;t<e.rows.length;t++){for(r=e.rows[t],o=0,a+="<tr>",n=0;n<r.length;n++)i=r[n],s=this.parser.parseInline(i.tokens),a+=yO(s,i,"td",e.align[o]),o+=i.colspan;a+="</tr>"}a+="</tbody>"}return a+="</table></div>",a}}]});const SO=e=>{let t=e;return e.length>mO&&(t=`${e.slice(0,mO)}\n<br />...`),t.split(" ").length>fO&&(t=t.split(" ").slice(0,fO).join(" ")),t},bO=(e,n=!1,r="Reasoning...")=>{try{let i=e.trim().replaceAll(/\[([^\]]+)\]\(([^\)]+)\)/g,'<a href="$2" target="_blank" rel="noopener noreferrer">$1</a>').replaceAll(/<think>([\s\S]*?)<\/think>/g,`<details class="memori-think"><summary>${r}</summary>$1</details>`).replaceAll(/<document_attachment filename="([^"]+)" type="([^"]+)">([\s\S]*?)<\/document_attachment>/g,"").replaceAll(/```markdown([^```]+)```/g,"$1").replaceAll("($","( $").replaceAll(":$",": $").replaceAll("\frac","\\frac").replaceAll("\beta","\\beta").replaceAll("cdot","\\cdot");n&&(sO.marked.use(t(vO)({})),i=i.replace(/\\+\[(.*?)\\*\]/gs,((e,t)=>`$$${t}$$`)),i=i.replace(/\[([^[\]]+?)\]/g,((e,t)=>!/[\\+a-z0-9_{}^=\-\+\*\/]+/i.test(t)||e.startsWith("[http")||e.includes("](")?e:`$$${t}$$`)));let o=sO.marked.parse(i).toString().trim();o=t(aO).sanitize(o,{ADD_ATTR:["target"]});return{text:o.replace(/(<br>)+/g,"<br>").replace(/<p><\/p>/g,"<br>").replace(/<p><br><\/p>/g,"<br>")}}catch(t){return console.error("Error rendering message:",t),{text:e}}};var xO=({rows:e,className:n,innerClassName:r,btnClassName:i,lineHeightMultiplier:o=1.2,defaultExpanded:a=!1,expandSymbol:l=(()=>"..."),collapseSymbol:u=(e=>"it"===e?"Mostra meno":"Show less"),children:d,mode:h="rows"})=>{const{i18n:p}=Ie(),m=p.language,f=u(m),g=l(m),[v,y]=(0,c.useState)(a),[_,S]=(0,c.useState)(!1),[b,x]=(0,c.useState)(16),C=(0,c.useRef)(null);(0,c.useEffect)((()=>{if(C.current)if("rows"===h){let t=C.current.getBoundingClientRect().height,n=getComputedStyle(C.current),r=n.lineHeight,i="normal"!==r&&(null==r?void 0:r.length)?parseInt(r,10):o*parseInt(n.fontSize,10);x(i),t&&e&&t>e*i&&S(!0)}else if("characters"===h){const e=C.current.textContent||"";(e.length>mO||e.split(" ").length>fO)&&S(!0)}}),[e,h,C.current]);return(0,s.jsxs)("div",{className:t(Is)("memori-expandable",n),children:[(0,s.jsx)("div",{ref:C,className:t(Is)("memori-expandable--inner",r),style:{maxHeight:v||!_||"characters"===h?"9999px":b*(e||1)+"px"},children:(()=>{var e;if("characters"===h&&!v&&_){const t=(null===(e=C.current)||void 0===e?void 0:e.textContent)||"";return SO(t)}return d})()}),_&&!v&&(0,s.jsx)(Mm,{ghost:!0,padded:!1,className:i,onClick:()=>y(!0),children:g}),_&&v&&(0,s.jsx)(Mm,{ghost:!0,padded:!1,className:i,onClick:()=>y(!1),children:f})]})};const CO=new Map(Object.entries({TENANT_NOT_FOUND:-1,TENANT_REGISTRATION_DISABLED:-2,TENANT_MISSING_NAME:-3,TENANT_MAX_USERS_REACHED:-4,TENANT_MAX_ADMINS_REACHED:-5,TENANT_ALREADY_EXISTS:-6,TENANT_MISSING_DESCRIPTION:-7,TENANT_CANT_SET_COMPLETION_PROVIDER:-8,TENANT_INVALID_TYPE:-9,USER_NOT_CONFIRMED:-11,USER_NOT_FOUND:-12,USER_OR_PASSWORD_INVALID:-13,USER_MUST_CHANGE_PASSWORD:-14,USER_MUST_ENTER_VERIFICATION_CODE:-15,USER_MISSING_TENANT:-21,USER_MISSING_NAME:-22,USER_MISSING_PASSWORD:-23,USER_MISSING_EMAIL:-24,USER_MISSING_VERIFICATION_CODE:-25,USER_NAME_ALREADY_USED:-26,USER_PASSWORD_NOT_CONFORMING_TO_POLICY:-27,USER_EMAIL_ALREADY_USED:-28,USER_EMAIL_INVALID:-29,USER_VERIFICATION_CODE_INVALID:-30,USER_MISSING_NAME_OR_EMAIL:-31,USER_NAME_INVALID:-32,USER_HAS_ONE_OR_MORE_MEMORI:-33,USER_MISSING_NEW_PASSWORD:-34,USER_CANT_CREATE_MEMORI:-35,USER_MAX_MEMORI_REACHED:-36,USER_TOO_MANY_ATTEMPTS:-38,USER_MUST_ACCEPT_TNC_AND_PP:-39,USER_BIRTH_DATE_CANT_BE_CHANGED:-40,USER_CANT_SET_COMPLETION_PROVIDER:-41,USER_CANT_ENABLE_DEEP_THOUGHT:-42,USER_CANT_ENABLE_DCM_INTEGRATION:-43,USER_CANT_ENABLE_CHAINING_OR_BOARD_OF_EXPERTS:-44,USER_CREATION_BILLING_DENIED_PERMISSION:-46,USER_HAS_ONE_OR_MORE_COMPLETION_CONFIGS:-47,USER_CANT_BE_DELETED:-48,USER_ORDER_BY_INVALID:-49,MEMORI_NOT_FOUND:-51,MEMORI_NOT_ACCESSIBLE:-52,MEMORI_ONLY_OWNER_CAN_CHANGE_GIVER_TAG_AND_PIN:-53,SESSION_NOT_FOUND:-101,SESSION_IS_NOT_ADMINISTRATIVE:-102,SESSION_EXPIRED:-103,MEMORI_MISSING_CONFIGURATION:-201,MEMORI_CONFIGURATION_NOT_FOUND:-202,MEMORI_INVALID_PRIVACY_TYPE:-203,MEMORI_MISSING_PASSWORD:-204,MEMORI_INVALID_TOTAL_NUMBER_OF_RECOVERY_TOKENS:-205,MEMORI_INVALID_MINIMUM_NUMBER_OF_RECOVERY_TOKENS:-206,MEMORI_INVALID_VOICE_TYPE:-207,MEMORI_MISSING_NAME:-208,MEMORI_MISSING_PASSWORD_OR_RECOVERY_TOKENS:-209,MEMORI_INVALID_ID:-210,MEMORI_NAME_ALREADY_USED:-211,MEMORI_INVALID_PIN:-212,MEMORI_GIVER_TAG_PIN_CHANGE_REQUIRES_SEPARATE_OPERATION:-213,MEMORI_NO_PASSWORD_WHEN_PUBLIC:-214,MEMORI_DEEP_THOUGHT_REQUIRES_COMPLETIONS:-215,MEMORI_BOARD_OF_EXPERTS_REQUIRES_COMPLETIONS:-216,MEMORI_INVALID_COMPLETION_CONFIG:-217,MEMORI_MACRO_FUNCTIONS_REQUIRES_COMPLETIONS:-218,MEMORI_BLOCKING_DATE_MISSING_OR_WRONG:-219,MEMORI_LIST_FILTER_NOT_SPECIFIED:-220,MEMORI_TRANSFER_MISSING_DESTINATION_USER:-231,MEMORI_TRANSFER_INVALID_DESTINATION_USER_ID:-232,MEMORI_TRANSFER_DESTINATION_USER_DATA_INCONSISTENT:-233,MEMORI_TRANSFER_NOTHING_TO_DO:-234,MEMORI_CONFIGURATION_CANT_BE_CHANGED:-251,MEMORI_MISSING_NEW_PASSWORD:-252,MEMORI_SESSIONS_INVALID_DATE_FROM_FORMAT:-261,MEMORI_SESSIONS_INVALID_DATE_TO_FORMAT:-262,MEMORI_SESSION_NOT_FOUND:-263,MEMORI_SESSION_DOESNT_ACCEPT_MEDIA:-264,MEMORI_FEATURE_REQUIRES_SUBSCRIPTION:-271,INTEGRATION_NOT_FOUND:-301,INTEGRATION_INVALID_TYPE:-401,INTEGRATION_ALREADY_EXISTS:-402,INTEGRATION_MEMORI_IS_NOT_PUBLIC:-403,INTEGRATION_MISSING_INVOCATION_TEXT:-404,INTEGRATION_MISSING_DEVICE_EMAILS:-405,INTEGRATION_MEMORI_IS_EMPTY:-406,INTEGRATION_MISSING_PRIVACY_POLICY:-407,INTEGRATION_MISSING_CATEGORY:-408,INTEGRATION_MISSING_DESCRIPTION:-409,INTEGRATION_INVALID_INVOCATION_TEXT:-410,INTEGRATION_GOOGLE_NO_MORE_AVAILABLE:-411,UPLOAD_REQUIRES_MULTIPART_ENCODING:-501,UPLOAD_MISSING_CONTENT_TYPE_BOUNDARY:-502,UPLOAD_MAX_LENGTH_EXCEEDED:-503,UPLOAD_FILE_IS_EMPTY:-504,UPLOAD_INVALID_FILE_TYPE_OR_SIGNATURE:-505,UPLOAD_MISSING_FILE_NAME:-506,UPLOAD_INVALID_MEMORY_ID:-507,UPLOAD_MISSING_FILE_CONTENT:-508,ASSET_NOT_FOUND:-601,ASSET_NOT_ACCESSIBLE:-602,ASSET_MISSING_SESSION_ID:-603,ASSET_INVALID_FILE_NAME:-604,ASSET_MALWARE_SCAN_THREATS_FOUND:-605,INVITATION_NOT_FOUND:-701,INVITATION_NOT_ACCESSIBLE:-702,INVITATION_ALREADY_ACCEPTED:-703,INVITATION_ALREADY_REJECTED:-704,INVITATION_MISSING_DESTINATION_EMAIL:-705,INVITATION_DESTINATION_EMAIL_INVALID:-706,INVITATION_MISSING_TAG:-707,INVITATION_MISSING_PIN:-708,INVITATION_INVALID_PIN:-709,INVITATION_INVALID_TYPE:-710,INVITATION_MISSING_DESTINATION_NAME:-711,INVITATION_TAG_PIN_CANT_BE_CHANGED:-712,INVITATION_CANT_BE_CHANGED:-713,ACTIONLOG_INVALID_USER_ID:-801,ACTIONLOG_INVALID_DATE_FROM_FORMAT:-802,ACTIONLOG_INVALID_DATE_TO_FORMAT:-803,ACTIONLOG_INVALID_MEMORI_ID:-804,CONSUMPTIONLOG_INVALID_TYPE:-901,CONSUMPTIONLOG_INVALID_DATE_FROM_FORMAT:-902,CONSUMPTIONLOG_INVALID_DATE_TO_FORMAT:-903,CONSUMPTIONLOG_INVALID_USER_ID:-904,CONSUMPTIONLOG_INVALID_MEMORI_ID:-905,NOTIFICATIONPREFS_INVALID_CHATLOG_EXTRACTION_PERIOD:-1001,BROADCAST_NOT_ALLOWED:-1002,INVALID_NOTIFICATION_TYPE:-1003,NOTIFICATION_NOT_FOUND:-1004,INVALID_NOTIFICATION_FILTER:-1005,INVALID_NOTIFICATION_PERIOD:-1006,PROCESS_INVALID_TYPE:-1401,PROCESS_ALREADY_RUNNING:-1401,PROCESS_NOT_FOUND:-1402,IMPORTCSV_MISSING_CSV:-1502,IMPORTCSV_MISSING_SEPARATOR:-1503,IMPORTCSV_INVALID_SEPARATOR:-1504,IMPORTCSV_MISSING_HEADERS:-1505,IMPORTCSV_MISSING_TITLE_VARIANT_SEPARATOR:-1506,IMPORTCSV_INVALID_RECEIVER_ID:-1507,IMPORTCSV_INVALID_MEDIA_LINK:-1508,IMPORTCSV_INVALID_LINK_TITLE_HANDLING:-1509,IMPORTCSV_UNDETECTABLE_CHAR_ENCODING:-1521,IMPORTTXT_INVALID_GRANULARITY:-1602,IMPORTTXT_INVALID_RECEIVER_ID:-1603,IMPORTTXT_INVALID_MEDIA_LINK:-1604,IMPORTTXT_INVALID_LINK_TITLE_HANDLING:-1605,IMPORTTXT_UNDETECTABLE_CHAR_ENCODING:-1621,IMPORTTXT_IMPORT_LIMIT_EXCEEDED:-1632,IMPORTTXT_IMPORT_ON_GPT4_REQUIRES_API_KEY:-1633,IMPORTTXT_IMPORT_REQUIRES_PAYING:-1634,IMPORTTXT_BILLING_DENIED_PERMISSION:-1635,IMPORT_MISSING_ROWS:-1701,IMPORT_CANT_IMPORT_TO_SECRET_MEMORI:-1702,IMPORTMEMORI_INVALID_MEMORI_SPECS:-1711,IMPORT_MISSING_JSONL:-1712,IMPORTMEMORI_INVALID_SPECS:-1713,EXPORT_MISSING_PASSWORD:1711,EXPORTCSV_MISSING_CSV_SPECS:-1801,EXPORTCSV_MISSING_SEPARATOR:-1802,EXPORTCSV_INVALID_SEPARATOR:-1803,EXPORTCSV_MISSING_TITLE_VARIANT_SEPARATOR:-1804,EXPORTCSV_MISSING_NEW_LINE_CHAR:-1805,EXPORTCSV_INVALID_NEW_LINE_CHAR:-1806,EXPORTJSONL_MISSING_JSONL_SPECS:-1821,EXPORTJSONL_MISSING_PLATFORM:-1822,EXPORTJSONL_INVALID_PLATFORM:-1823,EXPORTJSONL_EXPORT_REQUIRES_PAYING:-1832,ANALYSIS_MISSING_QUERY:-1901,ANALYSIS_CANT_ANALYZE_SECRET_MEMORI:-1902,ANALYSIS_USER_QUERY_MATCH_REQUIRES_DEEP_THOUGHT:-1903,BADGE_ASSIGNMENT_WRONG_OR_MISSING_CREDENTIALS:-2001,BADGE_ASSIGNMENT_MISSING_REF_ID:-2002,BADGE_ASSIGNMENT_OUTCOME_NOT_FOUND:-2003,BADGE_ASSIGNMENT_MISSING_ASSERTION_URL:-2004,BADGE_ASSIGNMENT_MISSING_BADGE_URL:-2005,BADGE_ASSIGNMENT_MISSING_ISSUER_URL:-2006,BADGE_ASSIGNMENT_INVALID_URL:-2007,BADGE_ASSIGNMENT_MISSING_RECIPIENT:-2021,BADGE_ASSIGNMENT_UNKNOWN_RECIPIENT_TYPE:-2022,BADGE_ASSIGNMENT_MISSING_RECIPIENT_IDENTITY:-2023,BADGE_ASSIGNMENT_MISSING_RECIPIENT_HASH_TYPE:-2024,BADGE_ASSIGNMENT_UNKNOWN_RECIPIENT_HASH_TYPE:-2025,BADGE_ASSIGNMENT_WRONG_RECIPIENT_IDENTITY:-2026,BADGE_NOT_FOUND:-2051,OUTCOME_NO_DCM_CONFIGURED:-2071,OUTCOME_USER_BADGES_DISABLED:-2072,COMPLETION_CONFIG_MISSING_NAME:-2401,COMPLETION_CONFIG_MISSING_PROVIDER:-2402,COMPLETION_CONFIG_MISSING_ENDPOINT:-2403,COMPLETION_CONFIG_MISSING_API_KEY:-2404,COMPLETION_CONFIG_MISSING_MODEL:-2405,COMPLETION_CONFIG_NO_PURPOSE_SPECIFIED:-2406,COMPLETION_CONFIG_INVALID_NAME:-2407,COMPLETION_CONFIG_INVALID_PURPOSE:-2411,COMPLETION_CONFIG_INVALID_ENDPOINT:-2412,COMPLETION_CONFIG_INCONSISTENT_ENDPOINT:-2413,COMPLETION_CONFIG_INVALID_PROVIDER:-2414,COMPLETION_CONFIG_NOT_FOUND:-2421,COMPLETION_CONFIG_NOT_ACCESSIBLE:-2422,COMPLETION_CONFIG_NAME_RESERVED:-2441,COMPLETION_CONFIG_NAME_ALREADY_EXISTS:-2442,COMPLETION_CONFIG_VISIBILITY_CHANGE_NOT_ALLOWED:-2443,COMPLETION_CONFIG_MISSING_MANDATORY_PREFIX:-2444,COMPLETION_CONFIG_VISIBILITY_NOT_PERMITTED:-2445,COMPLETION_CONFIG_USE_AS_DEFAULT_NOT_PERMITTED:-2446,COMPLETION_CONFIG_USE_AS_DEFAULT_REQUIRES_TENANT_VISIBILITY:-2447,COMPLETION_CONFIG_CHARGEABLE_NOT_PERMITTED:-2448,COMPLETION_CONFIG_INVALID_APPLY_TO:-2449,COMPLETION_CONFIG_APPLY_TO_TENANT_NOT_ALLOWED:-2450,TRUSTED_APPLICATION_NOT_FOUND:-2501,TRUSTED_APPLICATION_NOT_ACCESSIBLE:-2502,TRUSTED_APPLICATION_NAME_REQUIRED:-2503,TRUSTED_APPLICATION_TOKEN_REQUIRED:-2504,TRUSTED_APPLICATION_NAME_ALREADY_EXISTS:-2505,TRUSTED_APPLICATION_INVALID_TOKEN:-2506}).map((([e,t])=>[t,e]))),wO=e=>{if(!e)return"error.generic";if(401===e||403===e)return"error.unauthorized";if(404===e)return"error.notFound";if(422===e)return"error.unprocessableEntity";if(500===e)return"internal server error";let t=CO.get(e);return t?`errors.${t}`:"error.generic"};c=o("85Hg2");var AO=({medium:e,className:n,preview:r=!1,showCopyButton:i=!0})=>{var o,a,l,u,d;const{t:h}=Ie();return(0,c.useEffect)((()=>{(()=>{if(document.getElementById("memori-prism-script"))return;const e=document.createElement("script");e.src="https://cdn.jsdelivr.net/npm/prismjs@1.29.0/prism.min.js",e.async=!0,e.id="memori-prism-script";const t=document.createElement("script");t.src="https://cdn.jsdelivr.net/npm/prismjs@v1.29.0/plugins/autoloader/prism-autoloader.min.js",t.async=!0,t.id="memori-prism-autoloader-script";const n=document.createElement("link");n.rel="stylesheet",n.href="https://cdn.jsdelivr.net/npm/prismjs@1.29.0/themes/prism-tomorrow.min.css",document.head.appendChild(n),document.head.appendChild(e),document.head.appendChild(t)})()}),[]),(0,c.useEffect)((()=>{"Prism"in window&&window.Prism.highlightAll&&Prism.highlightAll()}),[e.content]),(0,s.jsxs)("div",{className:"memori-snippet",children:[(0,s.jsxs)("div",{className:"memori-snippet--content",children:[(0,s.jsx)("pre",{className:t(Is)("line-numbers",n),"aria-labelledby":(null===(o=e.title)||void 0===o?void 0:o.length)?`#snippet-${e.mediumID}`:void 0,children:(0,s.jsx)("code",{className:`language-${null!==(l=null===(a=hO.find((t=>e.mimeType===t.mimeType)))||void 0===a?void 0:a.lang)&&void 0!==l?l:"text"}`,children:(null===(u=e.content)||void 0===u?void 0:u.length)&&e.content.length>200&&r?`${e.content.slice(0,200)}\n...`:`${e.content}`})}),i&&(0,s.jsx)(Mm,{padded:!1,ghost:!0,className:"memori-snippet--copy-button",title:h("copy")||"Copy",icon:(0,s.jsx)(rO,{}),onClick:()=>{var t;return navigator.clipboard.writeText(null!==(t=e.content)&&void 0!==t?t:"")}})]}),!!(null===(d=e.title)||void 0===d?void 0:d.length)&&(0,s.jsx)("p",{id:`snippet-${e.mediumID}`,className:"memori-snippet--caption",children:e.title})]})};c=o("85Hg2"),c=o("85Hg2");var EO,IO=({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:"M574 665.4a8.03 8.03 0 0 0-11.3 0L446.5 781.6c-53.8 53.8-144.6 59.5-204 0-59.5-59.5-53.8-150.2 0-204l116.2-116.2c3.1-3.1 3.1-8.2 0-11.3l-39.8-39.8a8.03 8.03 0 0 0-11.3 0L191.4 526.5c-84.6 84.6-84.6 221.5 0 306s221.5 84.6 306 0l116.2-116.2c3.1-3.1 3.1-8.2 0-11.3L574 665.4zm258.6-474c-84.6-84.6-221.5-84.6-306 0L410.3 307.6a8.03 8.03 0 0 0 0 11.3l39.7 39.7c3.1 3.1 8.2 3.1 11.3 0l116.2-116.2c53.8-53.8 144.6-59.5 204 0 59.5 59.5 53.8 150.2 0 204L665.3 562.6a8.03 8.03 0 0 0 0 11.3l39.8 39.8c3.1 3.1 8.2 3.1 11.3 0l116.2-116.2c84.5-84.6 84.5-221.5 0-306.1zM610.1 372.3a8.03 8.03 0 0 0-11.3 0L372.3 598.7a8.03 8.03 0 0 0 0 11.3l39.6 39.6c3.1 3.1 8.2 3.1 11.3 0l226.4-226.4c3.1-3.1 3.1-8.2 0-11.3l-39.5-39.6z"})}),TO={};EO=function(e){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var t=Object.assign||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};function n(e,n){var r=e.el,i=e.elStyle,o=e.elHeight,s=e.rowsLimit,a=e.rowsWrapped,l=e.options,c=e.buffer,u=c;if(a===s+1)return t({},e);var d=c,h=a,p=o;return r.innerHTML=u=c.length?""+c+l.delimiter+n+l.replaceStr:""+n+l.replaceStr,parseFloat(i.height)>parseFloat(o)&&(h++,p=i.height,h===s+1)?(r.innerHTML=u="."===d[d.length-1]&&"..."===l.replaceStr?d+"..":""+d+l.replaceStr,t({},e,{elHeight:p,rowsWrapped:h})):(r.innerHTML=u=d.length?""+d+l.delimiter+n:""+n,t({},e,{buffer:u,elHeight:p,rowsWrapped:h}))}e.disableResponsive=function(e){window.removeEventListener("resize",e)},e.ellipsis=function e(){for(var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},s={replaceStr:"...",responsive:!1,debounceDelay:250,delimiter:" "},a=t({},s,o),l=r&&(r instanceof NodeList?r:1===r.nodeType?[r]:document.querySelectorAll(r)),c=[],u=0;u<l.length;u++){var d=l[u];c[u]=d.innerHTML;var h=d.innerHTML.split(a.delimiter);d.innerHTML="";var p=window.getComputedStyle(d);h.reduce(n,{el:d,buffer:d.innerHTML,elStyle:p,elHeight:0,rowsLimit:i,rowsWrapped:0,options:a})}if(a.responsive){var m=!1,f=window.innerWidth,g=function(){if(window.innerWidth!==f){f=window.innerWidth;for(var n=0;n<l.length;n++)l[n].innerHTML=c[n];e(r,i,t({},o,{responsive:!1}))}},v=function(){clearTimeout(m),m=setTimeout(g,a.debounceDelay)};return window.addEventListener("resize",v),v}}},"function"==typeof define&&define.amd?define(["exports"],EO):EO(TO);var MO=({loading:e=!1,className:n,title:r,description:i,cover:o,hoverable:a=!1,children:l,onClick:c})=>(0,s.jsx)("div",{onClick:c,className:t(Is)("memori-card",n,{"memori-card--loading":e,"memori-card--with-cover":o,"memori-card--hoverable":a,"memori-card--pointer":!!c}),children:(0,s.jsxs)(Tm,{spinning:e,children:[o&&(0,s.jsx)("div",{className:"memori-card--cover",children:o}),(0,s.jsxs)("div",{className:"memori-card--content",children:[r&&(0,s.jsx)("h3",{className:"memori-card--title",children:r}),i&&(0,s.jsx)("p",{className:"memori-card--description",children:i}),(0,s.jsx)("div",{className:"memori-card--children",children:l})]})]})});const RO=({isChild:e=!1,item:n,baseUrl:r,onLinkPreviewInfo:i,descriptionOneLine:o=!1})=>{var a,l,u,d;const[h,p]=(0,c.useState)(null),m=(null===(a=n.url)||void 0===a?void 0:a.startsWith("http"))||!n.url||0===(null===(l=n.url)||void 0===l?void 0:l.length)?n.url:`https://${n.url}`;(0,c.useEffect)((()=>{var e,t;let o=(null===(e=n.url)||void 0===e?void 0:e.startsWith("http"))||!n.url||0===(null===(t=n.url)||void 0===t?void 0:t.length)?n.url:`https://${n.url}`;o&&o!==(null==h?void 0:h.urlKey)&&(async(e,t)=>{try{const n=await fetch(`${t||"https://aisuru.com"}/api/linkpreview/${encodeURIComponent(e)}`);return await n.json()}catch(e){return console.error("getSiteInfo",e),null}})(o,r).then((e=>{p(e?{...e,urlKey:o}:null),i&&e&&i(e)}))}),[null==n?void 0:n.url,r,i]);const f=n.title&&n.title.length>0?n.title:null==h?void 0:h.title,g=null==h?void 0:h.description,v=null==h?void 0:h.video,y=null!==(u=null==h?void 0:h.image)&&void 0!==u?u:null===(d=null==h?void 0:h.images)||void 0===d?void 0:d[0];return(0,c.useEffect)((()=>{setTimeout((()=>{(0,TO.ellipsis)(".memori-link-item--card .memori-card--description",3,{responsive:!0})}),300)}),[g,n.mediumID]),(0,s.jsx)("a",{href:m,target:"_blank",rel:"noopener noreferrer",className:t(Is)("memori-link-item--link",{"memori-link-item--link--child":e}),onClick:t=>{e||(t.preventDefault(),t.stopPropagation(),window.open(m,"_blank",`toolbar=yes,top=${.1*window.innerHeight},left=${.1*window.innerWidth},width=${.8*window.innerWidth},height=${.8*window.innerHeight}`))},children:(0,s.jsx)(MO,{hoverable:!0,className:t(Is)("memori-link-item--card",{"memori-link-item--card-description-oneline":o,"memori-link-item--card-has-image":y,"memori-link-item--card-has-video":v}),cover:v?(0,s.jsx)("iframe",{width:"100%",height:"100%",src:v,title:"Video player",frameBorder:"0",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0}):y?(0,s.jsx)("img",{className:"memori-link-item--card-cover-img",src:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMIAAADDCAYAAADQvc6UAAABRWlDQ1BJQ0MgUHJvZmlsZQAAKJFjYGASSSwoyGFhYGDIzSspCnJ3UoiIjFJgf8LAwSDCIMogwMCcmFxc4BgQ4ANUwgCjUcG3awyMIPqyLsis7PPOq3QdDFcvjV3jOD1boQVTPQrgSkktTgbSf4A4LbmgqISBgTEFyFYuLykAsTuAbJEioKOA7DkgdjqEvQHEToKwj4DVhAQ5A9k3gGyB5IxEoBmML4BsnSQk8XQkNtReEOBxcfXxUQg1Mjc0dyHgXNJBSWpFCYh2zi+oLMpMzyhRcASGUqqCZ16yno6CkYGRAQMDKMwhqj/fAIcloxgHQqxAjIHBEugw5sUIsSQpBobtQPdLciLEVJYzMPBHMDBsayhILEqEO4DxG0txmrERhM29nYGBddr//5/DGRjYNRkY/l7////39v///y4Dmn+LgeHANwDrkl1AuO+pmgAAADhlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAAqACAAQAAAABAAAAwqADAAQAAAABAAAAwwAAAAD9b/HnAAAHlklEQVR4Ae3dP3PTWBSGcbGzM6GCKqlIBRV0dHRJFarQ0eUT8LH4BnRU0NHR0UEFVdIlFRV7TzRksomPY8uykTk/zewQfKw/9znv4yvJynLv4uLiV2dBoDiBf4qP3/ARuCRABEFAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghgg0Aj8i0JO4OzsrPv69Wv+hi2qPHr0qNvf39+iI97soRIh4f3z58/u7du3SXX7Xt7Z2enevHmzfQe+oSN2apSAPj09TSrb+XKI/f379+08+A0cNRE2ANkupk+ACNPvkSPcAAEibACyXUyfABGm3yNHuAECRNgAZLuYPgEirKlHu7u7XdyytGwHAd8jjNyng4OD7vnz51dbPT8/7z58+NB9+/bt6jU/TI+AGWHEnrx48eJ/EsSmHzx40L18+fLyzxF3ZVMjEyDCiEDjMYZZS5wiPXnyZFbJaxMhQIQRGzHvWR7XCyOCXsOmiDAi1HmPMMQjDpbpEiDCiL358eNHurW/5SnWdIBbXiDCiA38/Pnzrce2YyZ4//59F3ePLNMl4PbpiL2J0L979+7yDtHDhw8vtzzvdGnEXdvUigSIsCLAWavHp/+qM0BcXMd/q25n1vF57TYBp0a3mUzilePj4+7k5KSLb6gt6ydAhPUzXnoPR0dHl79WGTNCfBnn1uvSCJdegQhLI1vvCk+fPu2ePXt2tZOYEV6/fn31dz+shwAR1sP1cqvLntbEN9MxA9xcYjsxS1jWR4AIa2Ibzx0tc44fYX/16lV6NDFLXH+YL32jwiACRBiEbf5KcXoTIsQSpzXx4N28Ja4BQoK7rgXiydbHjx/P25TaQAJEGAguWy0+2Q8PD6/Ki4R8EVl+bzBOnZY95fq9rj9zAkTI2SxdidBHqG9+skdw43borCXO/ZcJdraPWdv22uIEiLA4q7nvvCug8WTqzQveOH26fodo7g6uFe/a17W3+nFBAkRYENRdb1vkkz1CH9cPsVy/jrhr27PqMYvENYNlHAIesRiBYwRy0V+8iXP8+/fvX11Mr7L7ECueb/r48eMqm7FuI2BGWDEG8cm+7G3NEOfmdcTQw4h9/55lhm7DekRYKQPZF2ArbXTAyu4kDYB2YxUzwg0gi/41ztHnfQG26HbGel/crVrm7tNY+/1btkOEAZ2M05r4FB7r9GbAIdxaZYrHdOsgJ/wCEQY0J74TmOKnbxxT9n3FgGGWWsVdowHtjt9Nnvf7yQM2aZU/TIAIAxrw6dOnAWtZZcoEnBpNuTuObWMEiLAx1HY0ZQJEmHJ3HNvGCBBhY6jtaMoEiJB0Z29vL6ls58vxPcO8/zfrdo5qvKO+d3Fx8Wu8zf1dW4p/cPzLly/dtv9Ts/EbcvGAHhHyfBIhZ6NSiIBTo0LNNtScABFyNiqFCBChULMNNSdAhJyNSiECRCjUbEPNCRAhZ6NSiAARCjXbUHMCRMjZqBQiQIRCzTbUnAARcjYqhQgQoVCzDTUnQIScjUohAkQo1GxDzQkQIWejUogAEQo121BzAkTI2agUIkCEQs021JwAEXI2KoUIEKFQsw01J0CEnI1KIQJEKNRsQ80JECFno1KIABEKNdtQcwJEyNmoFCJAhELNNtScABFyNiqFCBChULMNNSdAhJyNSiECRCjUbEPNCRAhZ6NSiAARCjXbUHMCRMjZqBQiQIRCzTbUnAARcjYqhQgQoVCzDTUnQIScjUohAkQo1GxDzQkQIWejUogAEQo121BzAkTI2agUIkCEQs021JwAEXI2KoUIEKFQsw01J0CEnI1KIQJEKNRsQ80JECFno1KIABEKNdtQcwJEyNmoFCJAhELNNtScABFyNiqFCBChULMNNSdAhJyNSiECRCjUbEPNCRAhZ6NSiAARCjXbUHMCRMjZqBQiQIRCzTbUnAARcjYqhQgQoVCzDTUnQIScjUohAkQo1GxDzQkQIWejUogAEQo121BzAkTI2agUIkCEQs021JwAEXI2KoUIEKFQsw01J0CEnI1KIQJEKNRsQ80JECFno1KIABEKNdtQcwJEyNmoFCJAhELNNtScABFyNiqFCBChULMNNSdAhJyNSiEC/wGgKKC4YMA4TAAAAABJRU5ErkJggg==",srcSet:y.includes("data:image")?void 0:y.startsWith("https")?y:`https://${y.replace("http://","")}`,alt:n.title}):(0,s.jsx)("div",{className:"memori-link-item--card-cover-icon",children:(0,s.jsx)(IO,{className:"memori-link-item--icon"})}),title:f,description:g})})};var PO=({items:e,baseUrl:n,descriptionOneLine:r=!1,onLinkPreviewInfo:i,fromUser:o=!1})=>(0,s.jsx)(dp,{appear:!0,show:!0,as:"div",className:"memori-link-items",children:(0,s.jsx)("div",{className:t(Is)("memori-link-items--grid",{"memori-link-items--user":o,"memori-link-items--agent":!o}),children:e.map(((e,t)=>(0,s.jsx)(dp.Child,{as:"div",className:"memori-link-item",enter:"ease-out duration-500 delay-"+100*t,enterFrom:"opacity-0 scale-95",enterTo:"opacity-1 scale-100",leave:"ease-in duration-300",leaveFrom:"opacity-1 scale-100",leaveTo:"opacity-0 scale-95",children:(0,s.jsx)(RO,{item:e,baseUrl:n,descriptionOneLine:r,onLinkPreviewInfo:i})},e.mediumID)))})});c=o("85Hg2");const NO=["va bene","no grazie","si","no","sì","arrivederci","non c'entrava","non mi è piaciuto"],OO=async(e,t,n,r)=>{var i;let o=(e=>e.replaceAll(/<output.*?>(.*?)<\/output>/g,""))(e);const s=NO.indexOf(e.toLowerCase())>-1?"IT":null==n?void 0:n.toUpperCase(),a=t.toUpperCase(),l=await fetch(`${r||"https://www.aisuru.com"}/api/translate`,{cache:"no-cache",method:"POST",body:JSON.stringify({text:o,target_lang:a,source_lang:s}),headers:{Accept:"*/*","Content-Type":"application/json"}}),c=await l.json();return null===(i=null==c?void 0:c.translations)||void 0===i?void 0:i[0]};c=o("85Hg2");var DO=({src:e,poster:t,alt:n=""})=>((0,c.useEffect)((()=>{const e=document.createElement("script");return e.src="https://unpkg.com/@google/model-viewer/dist/model-viewer.min.js",e.type="module",document.head.appendChild(e),()=>{document.head.removeChild(e)}}),[]),(0,s.jsx)("div",{className:"model-viewer",children:(0,s.jsx)("model-viewer",{src:e,"ios-src":"",poster:t,alt:n,"shadow-intensity":"1","disable-zoom":!0,"camera-controls":!0,autoplay:!0})}));var LO=({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:"M854.6 288.6L639.4 73.4c-6-6-14.1-9.4-22.6-9.4H192c-17.7 0-32 14.3-32 32v832c0 17.7 14.3 32 32 32h640c17.7 0 32-14.3 32-32V311.3c0-8.5-3.4-16.7-9.4-22.7zM790.2 326H602V137.8L790.2 326zm1.8 562H232V136h302v216a42 42 0 0 0 42 42h216v494z"})});var kO=({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:"M531.3 574.4l.3-1.4c5.8-23.9 13.1-53.7 7.4-80.7-3.8-21.3-19.5-29.6-32.9-30.2-15.8-.7-29.9 8.3-33.4 21.4-6.6 24-.7 56.8 10.1 98.6-13.6 32.4-35.3 79.5-51.2 107.5-29.6 15.3-69.3 38.9-75.2 68.7-1.2 5.5.2 12.5 3.5 18.8 3.7 7 9.6 12.4 16.5 15 3 1.1 6.6 2 10.8 2 17.6 0 46.1-14.2 84.1-79.4 5.8-1.9 11.8-3.9 17.6-5.9 27.2-9.2 55.4-18.8 80.9-23.1 28.2 15.1 60.3 24.8 82.1 24.8 21.6 0 30.1-12.8 33.3-20.5 5.6-13.5 2.9-30.5-6.2-39.6-13.2-13-45.3-16.4-95.3-10.2-24.6-15-40.7-35.4-52.4-65.8zM421.6 726.3c-13.9 20.2-24.4 30.3-30.1 34.7 6.7-12.3 19.8-25.3 30.1-34.7zm87.6-235.5c5.2 8.9 4.5 35.8.5 49.4-4.9-19.9-5.6-48.1-2.7-51.4.8.1 1.5.7 2.2 2zm-1.6 120.5c10.7 18.5 24.2 34.4 39.1 46.2-21.6 4.9-41.3 13-58.9 20.2-4.2 1.7-8.3 3.4-12.3 5 13.3-24.1 24.4-51.4 32.1-71.4zm155.6 65.5c.1.2.2.5-.4.9h-.2l-.2.3c-.8.5-9 5.3-44.3-8.6 40.6-1.9 45 7.3 45.1 7.4zm191.4-388.2L639.4 73.4c-6-6-14.1-9.4-22.6-9.4H192c-17.7 0-32 14.3-32 32v832c0 17.7 14.3 32 32 32h640c17.7 0 32-14.3 32-32V311.3c0-8.5-3.4-16.7-9.4-22.7zM790.2 326H602V137.8L790.2 326zm1.8 562H232V136h302v216a42 42 0 0 0 42 42h216v494z"})});var BO=({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:"M854.6 288.6L639.4 73.4c-6-6-14.1-9.4-22.6-9.4H192c-17.7 0-32 14.3-32 32v832c0 17.7 14.3 32 32 32h640c17.7 0 32-14.3 32-32V311.3c0-8.5-3.4-16.7-9.4-22.7zM790.2 326H602V137.8L790.2 326zm1.8 562H232V136h302v216a42 42 0 0 0 42 42h216v494zM514.1 580.1l-61.8-102.4c-2.2-3.6-6.1-5.8-10.3-5.8h-38.4c-2.3 0-4.5.6-6.4 1.9-5.6 3.5-7.3 10.9-3.7 16.6l82.3 130.4-83.4 132.8a12.04 12.04 0 0 0 10.2 18.4h34.5c4.2 0 8-2.2 10.2-5.7L510 664.8l62.3 101.4c2.2 3.6 6.1 5.7 10.2 5.7H620c2.3 0 4.5-.7 6.5-1.9 5.6-3.6 7.2-11 3.6-16.6l-84-130.4 85.3-132.5a12.04 12.04 0 0 0-10.1-18.5h-35.7c-4.2 0-8.1 2.2-10.3 5.8l-61.2 102.3z"})});var zO=({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:"M854.6 288.6L639.4 73.4c-6-6-14.1-9.4-22.6-9.4H192c-17.7 0-32 14.3-32 32v832c0 17.7 14.3 32 32 32h640c17.7 0 32-14.3 32-32V311.3c0-8.5-3.4-16.7-9.4-22.7zM790.2 326H602V137.8L790.2 326zm1.8 562H232V136h302v216a42 42 0 0 0 42 42h216v494zM528.1 472h-32.2c-5.5 0-10.3 3.7-11.6 9.1L434.6 680l-46.1-198.7c-1.3-5.4-6.1-9.3-11.7-9.3h-35.4a12.02 12.02 0 0 0-11.6 15.1l74.2 276c1.4 5.2 6.2 8.9 11.6 8.9h32c5.4 0 10.2-3.6 11.6-8.9l52.8-197 52.8 197c1.4 5.2 6.2 8.9 11.6 8.9h31.8c5.4 0 10.2-3.6 11.6-8.9l74.4-276a12.04 12.04 0 0 0-11.6-15.1H647c-5.6 0-10.4 3.9-11.7 9.3l-45.8 199.1-49.8-199.3c-1.3-5.4-6.1-9.1-11.6-9.1z"})});const FO=({isChild:e=!1,item:t,sessionID:n,tenantID:r,preview:i=!1,baseURL:o,apiURL:a,onClick:l,customMediaRenderer:u})=>{var d,h;const[p,m]=(0,c.useState)(!1),[f,g]=(0,c.useState)(!1),v=RN({resourceURI:t.url,sessionID:n,tenantID:r,baseURL:o,apiURL:a}),y=null==u?void 0:u(t.mimeType);if(y)return y;const _=e=>{switch(e.mimeType){case"image/jpeg":case"image/png":case"image/jpg":case"image/gif":return S?(0,s.jsxs)("picture",{className:"memori-media-item--figure",children:[(0,s.jsx)("div",{className:"memori-media-item--rgb-item",style:{backgroundColor:e.url}}),e.title&&(0,s.jsx)("figcaption",{className:"memori-media-item--figure-caption",children:e.title})]}):(0,s.jsxs)("picture",{className:"memori-media-item--figure",children:[!i&&(0,s.jsx)("source",{srcSet:[v,e.url,e.content].join(", "),type:e.mimeType}),(0,s.jsx)("img",{alt:e.title,src:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMIAAADDCAYAAADQvc6UAAABRWlDQ1BJQ0MgUHJvZmlsZQAAKJFjYGASSSwoyGFhYGDIzSspCnJ3UoiIjFJgf8LAwSDCIMogwMCcmFxc4BgQ4ANUwgCjUcG3awyMIPqyLsis7PPOq3QdDFcvjV3jOD1boQVTPQrgSkktTgbSf4A4LbmgqISBgTEFyFYuLykAsTuAbJEioKOA7DkgdjqEvQHEToKwj4DVhAQ5A9k3gGyB5IxEoBmML4BsnSQk8XQkNtReEOBxcfXxUQg1Mjc0dyHgXNJBSWpFCYh2zi+oLMpMzyhRcASGUqqCZ16yno6CkYGRAQMDKMwhqj/fAIcloxgHQqxAjIHBEugw5sUIsSQpBobtQPdLciLEVJYzMPBHMDBsayhILEqEO4DxG0txmrERhM29nYGBddr//5/DGRjYNRkY/l7////39v///y4Dmn+LgeHANwDrkl1AuO+pmgAAADhlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAAqACAAQAAAABAAAAwqADAAQAAAABAAAAwwAAAAD9b/HnAAAHlklEQVR4Ae3dP3PTWBSGcbGzM6GCKqlIBRV0dHRJFarQ0eUT8LH4BnRU0NHR0UEFVdIlFRV7TzRksomPY8uykTk/zewQfKw/9znv4yvJynLv4uLiV2dBoDiBf4qP3/ARuCRABEFAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghgg0Aj8i0JO4OzsrPv69Wv+hi2qPHr0qNvf39+iI97soRIh4f3z58/u7du3SXX7Xt7Z2enevHmzfQe+oSN2apSAPj09TSrb+XKI/f379+08+A0cNRE2ANkupk+ACNPvkSPcAAEibACyXUyfABGm3yNHuAECRNgAZLuYPgEirKlHu7u7XdyytGwHAd8jjNyng4OD7vnz51dbPT8/7z58+NB9+/bt6jU/TI+AGWHEnrx48eJ/EsSmHzx40L18+fLyzxF3ZVMjEyDCiEDjMYZZS5wiPXnyZFbJaxMhQIQRGzHvWR7XCyOCXsOmiDAi1HmPMMQjDpbpEiDCiL358eNHurW/5SnWdIBbXiDCiA38/Pnzrce2YyZ4//59F3ePLNMl4PbpiL2J0L979+7yDtHDhw8vtzzvdGnEXdvUigSIsCLAWavHp/+qM0BcXMd/q25n1vF57TYBp0a3mUzilePj4+7k5KSLb6gt6ydAhPUzXnoPR0dHl79WGTNCfBnn1uvSCJdegQhLI1vvCk+fPu2ePXt2tZOYEV6/fn31dz+shwAR1sP1cqvLntbEN9MxA9xcYjsxS1jWR4AIa2Ibzx0tc44fYX/16lV6NDFLXH+YL32jwiACRBiEbf5KcXoTIsQSpzXx4N28Ja4BQoK7rgXiydbHjx/P25TaQAJEGAguWy0+2Q8PD6/Ki4R8EVl+bzBOnZY95fq9rj9zAkTI2SxdidBHqG9+skdw43borCXO/ZcJdraPWdv22uIEiLA4q7nvvCug8WTqzQveOH26fodo7g6uFe/a17W3+nFBAkRYENRdb1vkkz1CH9cPsVy/jrhr27PqMYvENYNlHAIesRiBYwRy0V+8iXP8+/fvX11Mr7L7ECueb/r48eMqm7FuI2BGWDEG8cm+7G3NEOfmdcTQw4h9/55lhm7DekRYKQPZF2ArbXTAyu4kDYB2YxUzwg0gi/41ztHnfQG26HbGel/crVrm7tNY+/1btkOEAZ2M05r4FB7r9GbAIdxaZYrHdOsgJ/wCEQY0J74TmOKnbxxT9n3FgGGWWsVdowHtjt9Nnvf7yQM2aZU/TIAIAxrw6dOnAWtZZcoEnBpNuTuObWMEiLAx1HY0ZQJEmHJ3HNvGCBBhY6jtaMoEiJB0Z29vL6ls58vxPcO8/zfrdo5qvKO+d3Fx8Wu8zf1dW4p/cPzLly/dtv9Ts/EbcvGAHhHyfBIhZ6NSiIBTo0LNNtScABFyNiqFCBChULMNNSdAhJyNSiECRCjUbEPNCRAhZ6NSiAARCjXbUHMCRMjZqBQiQIRCzTbUnAARcjYqhQgQoVCzDTUnQIScjUohAkQo1GxDzQkQIWejUogAEQo121BzAkTI2agUIkCEQs021JwAEXI2KoUIEKFQsw01J0CEnI1KIQJEKNRsQ80JECFno1KIABEKNdtQcwJEyNmoFCJAhELNNtScABFyNiqFCBChULMNNSdAhJyNSiECRCjUbEPNCRAhZ6NSiAARCjXbUHMCRMjZqBQiQIRCzTbUnAARcjYqhQgQoVCzDTUnQIScjUohAkQo1GxDzQkQIWejUogAEQo121BzAkTI2agUIkCEQs021JwAEXI2KoUIEKFQsw01J0CEnI1KIQJEKNRsQ80JECFno1KIABEKNdtQcwJEyNmoFCJAhELNNtScABFyNiqFCBChULMNNSdAhJyNSiECRCjUbEPNCRAhZ6NSiAARCjXbUHMCRMjZqBQiQIRCzTbUnAARcjYqhQgQoVCzDTUnQIScjUohAkQo1GxDzQkQIWejUogAEQo121BzAkTI2agUIkCEQs021JwAEXI2KoUIEKFQsw01J0CEnI1KIQJEKNRsQ80JECFno1KIABEKNdtQcwJEyNmoFCJAhELNNtScABFyNiqFCBChULMNNSdAhJyNSiEC/wGgKKC4YMA4TAAAAABJRU5ErkJggg=="}),e.title&&(0,s.jsx)("figcaption",{className:"memori-media-item--figure-caption",children:e.title})]});case"application/msword":case"application/vnd.openxmlformats-officedocument.wordprocessingml.document":return(0,s.jsx)(zO,{className:"memori-media-item--icon"});case"application/vnd.ms-excel":case"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":return(0,s.jsx)(BO,{className:"memori-media-item--icon"});case"application/pdf":return(0,s.jsx)(kO,{className:"memori-media-item--icon"});case"video/mp4":case"video/quicktime":case"video/avi":case"video/mpeg":return(0,s.jsxs)("video",{style:{width:"100%",height:"100%"},controls:!0,src:v,title:e.title,children:["video/quicktime"===e.mimeType&&(0,s.jsx)("source",{src:e.url,type:"video/mp4"}),(0,s.jsx)("source",{src:e.url,type:e.mimeType}),"Your browser does not support this video format.",(0,s.jsx)("br",{}),(0,s.jsx)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",children:"Download the video"})]});case"audio/mpeg3":case"audio/wav":case"audio/mpeg":return(0,s.jsx)("audio",{style:{width:"100%",height:"100%"},controls:!0,src:v});case"model/gltf-binary":return(0,s.jsx)(DO,{src:v,alt:"",poster:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMIAAADDCAYAAADQvc6UAAABRWlDQ1BJQ0MgUHJvZmlsZQAAKJFjYGASSSwoyGFhYGDIzSspCnJ3UoiIjFJgf8LAwSDCIMogwMCcmFxc4BgQ4ANUwgCjUcG3awyMIPqyLsis7PPOq3QdDFcvjV3jOD1boQVTPQrgSkktTgbSf4A4LbmgqISBgTEFyFYuLykAsTuAbJEioKOA7DkgdjqEvQHEToKwj4DVhAQ5A9k3gGyB5IxEoBmML4BsnSQk8XQkNtReEOBxcfXxUQg1Mjc0dyHgXNJBSWpFCYh2zi+oLMpMzyhRcASGUqqCZ16yno6CkYGRAQMDKMwhqj/fAIcloxgHQqxAjIHBEugw5sUIsSQpBobtQPdLciLEVJYzMPBHMDBsayhILEqEO4DxG0txmrERhM29nYGBddr//5/DGRjYNRkY/l7////39v///y4Dmn+LgeHANwDrkl1AuO+pmgAAADhlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAAqACAAQAAAABAAAAwqADAAQAAAABAAAAwwAAAAD9b/HnAAAHlklEQVR4Ae3dP3PTWBSGcbGzM6GCKqlIBRV0dHRJFarQ0eUT8LH4BnRU0NHR0UEFVdIlFRV7TzRksomPY8uykTk/zewQfKw/9znv4yvJynLv4uLiV2dBoDiBf4qP3/ARuCRABEFAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghgg0Aj8i0JO4OzsrPv69Wv+hi2qPHr0qNvf39+iI97soRIh4f3z58/u7du3SXX7Xt7Z2enevHmzfQe+oSN2apSAPj09TSrb+XKI/f379+08+A0cNRE2ANkupk+ACNPvkSPcAAEibACyXUyfABGm3yNHuAECRNgAZLuYPgEirKlHu7u7XdyytGwHAd8jjNyng4OD7vnz51dbPT8/7z58+NB9+/bt6jU/TI+AGWHEnrx48eJ/EsSmHzx40L18+fLyzxF3ZVMjEyDCiEDjMYZZS5wiPXnyZFbJaxMhQIQRGzHvWR7XCyOCXsOmiDAi1HmPMMQjDpbpEiDCiL358eNHurW/5SnWdIBbXiDCiA38/Pnzrce2YyZ4//59F3ePLNMl4PbpiL2J0L979+7yDtHDhw8vtzzvdGnEXdvUigSIsCLAWavHp/+qM0BcXMd/q25n1vF57TYBp0a3mUzilePj4+7k5KSLb6gt6ydAhPUzXnoPR0dHl79WGTNCfBnn1uvSCJdegQhLI1vvCk+fPu2ePXt2tZOYEV6/fn31dz+shwAR1sP1cqvLntbEN9MxA9xcYjsxS1jWR4AIa2Ibzx0tc44fYX/16lV6NDFLXH+YL32jwiACRBiEbf5KcXoTIsQSpzXx4N28Ja4BQoK7rgXiydbHjx/P25TaQAJEGAguWy0+2Q8PD6/Ki4R8EVl+bzBOnZY95fq9rj9zAkTI2SxdidBHqG9+skdw43borCXO/ZcJdraPWdv22uIEiLA4q7nvvCug8WTqzQveOH26fodo7g6uFe/a17W3+nFBAkRYENRdb1vkkz1CH9cPsVy/jrhr27PqMYvENYNlHAIesRiBYwRy0V+8iXP8+/fvX11Mr7L7ECueb/r48eMqm7FuI2BGWDEG8cm+7G3NEOfmdcTQw4h9/55lhm7DekRYKQPZF2ArbXTAyu4kDYB2YxUzwg0gi/41ztHnfQG26HbGel/crVrm7tNY+/1btkOEAZ2M05r4FB7r9GbAIdxaZYrHdOsgJ/wCEQY0J74TmOKnbxxT9n3FgGGWWsVdowHtjt9Nnvf7yQM2aZU/TIAIAxrw6dOnAWtZZcoEnBpNuTuObWMEiLAx1HY0ZQJEmHJ3HNvGCBBhY6jtaMoEiJB0Z29vL6ls58vxPcO8/zfrdo5qvKO+d3Fx8Wu8zf1dW4p/cPzLly/dtv9Ts/EbcvGAHhHyfBIhZ6NSiIBTo0LNNtScABFyNiqFCBChULMNNSdAhJyNSiECRCjUbEPNCRAhZ6NSiAARCjXbUHMCRMjZqBQiQIRCzTbUnAARcjYqhQgQoVCzDTUnQIScjUohAkQo1GxDzQkQIWejUogAEQo121BzAkTI2agUIkCEQs021JwAEXI2KoUIEKFQsw01J0CEnI1KIQJEKNRsQ80JECFno1KIABEKNdtQcwJEyNmoFCJAhELNNtScABFyNiqFCBChULMNNSdAhJyNSiECRCjUbEPNCRAhZ6NSiAARCjXbUHMCRMjZqBQiQIRCzTbUnAARcjYqhQgQoVCzDTUnQIScjUohAkQo1GxDzQkQIWejUogAEQo121BzAkTI2agUIkCEQs021JwAEXI2KoUIEKFQsw01J0CEnI1KIQJEKNRsQ80JECFno1KIABEKNdtQcwJEyNmoFCJAhELNNtScABFyNiqFCBChULMNNSdAhJyNSiECRCjUbEPNCRAhZ6NSiAARCjXbUHMCRMjZqBQiQIRCzTbUnAARcjYqhQgQoVCzDTUnQIScjUohAkQo1GxDzQkQIWejUogAEQo121BzAkTI2agUIkCEQs021JwAEXI2KoUIEKFQsw01J0CEnI1KIQJEKNRsQ80JECFno1KIABEKNdtQcwJEyNmoFCJAhELNNtScABFyNiqFCBChULMNNSdAhJyNSiEC/wGgKKC4YMA4TAAAAABJRU5ErkJggg=="});default:return(0,s.jsx)(LO,{className:"memori-media-item--icon"})}};if(!t.url&&"document"===(null==t?void 0:t.type)&&t.content)return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("a",{className:"memori-media-item--link",href:"#",onClick:e=>{e.preventDefault(),m(!0)},title:t.title,children:(0,s.jsx)(MO,{hoverable:!0,cover:_(t),title:t.title})}),(0,s.jsx)(aP,{open:p,onClose:()=>m(!1),title:t.title,className:"memori-media-item-preview--modal",width:"60%",widthMd:"70%",footer:(0,s.jsx)("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem"},children:(0,s.jsx)(Mm,{onClick:async()=>{try{await navigator.clipboard.writeText(t.content||""),g(!0),setTimeout((()=>g(!1)),2e3)}catch(e){console.error("Failed to copy content:",e)}},icon:(0,s.jsx)(rO,{}),children:f?"Copied!":"Copy Content"})}),children:(0,s.jsx)("div",{className:"memori-media-item-preview--content",children:(0,s.jsx)("div",{className:"memori-media-item-preview--text",dangerouslySetInnerHTML:{__html:gR(t.content||"")}})})})]});const S=(null===(d=t.url)||void 0===d?void 0:d.startsWith("rgb("))||(null===(h=t.url)||void 0===h?void 0:h.startsWith("rgba("));switch(t.mimeType){case"image/jpeg":case"image/png":case"image/jpg":case"image/gif":return S?(0,s.jsx)(MO,{hoverable:!0,className:"memori-media-item--card memori-media-item--image",cover:_(t)}):(0,s.jsx)("a",{className:"memori-media-item--link",href:t.url,onClick:n=>{e&&n.preventDefault(),l&&(n.preventDefault(),l(t.mediumID))},target:"_blank",rel:"noopener noreferrer",title:t.title,children:(0,s.jsx)(MO,{hoverable:!0,className:"memori-media-item--card memori-media-item--image",cover:_(t)})});case"application/msword":case"application/vnd.openxmlformats-officedocument.wordprocessingml.document":case"application/vnd.ms-excel":case"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":case"application/pdf":case"audio/mpeg3":case"audio/wav":case"audio/mpeg":default:return(0,s.jsx)("a",{className:"memori-media-item--link",href:v,target:"_blank",rel:"noopener noreferrer",title:t.title,children:(0,s.jsx)(MO,{hoverable:!0,cover:_(t),title:t.title})});case"video/mp4":case"video/quicktime":case"video/avi":case"video/mpeg":return(0,s.jsx)("a",{className:"memori-media-item--link",href:v,onClick:n=>{e&&n.preventDefault(),l&&(n.preventDefault(),l(t.mediumID))},target:"_blank",rel:"noopener noreferrer",title:t.title,children:(0,s.jsx)(MO,{hoverable:!0,cover:_(t),title:t.title})});case"model/gltf-binary":return(0,s.jsx)(MO,{hoverable:!0,cover:_(t)})}};var UO=(0,c.memo)((({items:e,sessionID:n,tenantID:r,translateTo:i,baseURL:o,apiURL:a,customMediaRenderer:l,fromUser:u=!1})=>{const[d,h]=(0,c.useState)(e),[p,m]=(0,c.useState)(),f=(0,c.useCallback)((async()=>{if(!i)return;const t=await Promise.all((null!=e?e:[]).map((async e=>{var t;if(!e.title)return e;try{const n=await OO(e.title,i);return{...e,title:null!==(t=n.text)&&void 0!==t?t:e.title}}catch(t){return console.error(t),e}})));h(t)}),[i,e]);(0,c.useEffect)((()=>{i&&f()}),[i,f]);const g=d.filter((e=>{var t;return!(null===(t=e.properties)||void 0===t?void 0:t.executable)&&!hO.map((e=>e.mimeType)).includes(e.mimeType)})).sort(((e,t)=>e.creationTimestamp>t.creationTimestamp?1:e.creationTimestamp<t.creationTimestamp?-1:0)),v=d.filter((e=>{var t;return!(null===(t=e.properties)||void 0===t?void 0:t.executable)&&hO.map((e=>e.mimeType)).includes(e.mimeType)})),y=d.filter((e=>{var t;return"text/css"===e.mimeType&&!!(null===(t=e.properties)||void 0===t?void 0:t.executable)}));return(0,s.jsxs)(dp,{appear:!0,show:!0,as:"div",className:"memori-media-items",children:[!!g.length&&(0,s.jsx)("div",{className:t(Is)("memori-media-items--grid",{"memori-media-items--user":u,"memori-media-items--agent":!u}),children:g.map(((e,t)=>(0,s.jsx)(dp.Child,{as:"div",className:"memori-media-item",enter:"ease-out duration-500 delay-"+100*t,enterFrom:"opacity-0 scale-95",enterTo:"opacity-1 scale-100",leave:"ease-in duration-300",leaveFrom:"opacity-1 scale-100",leaveTo:"opacity-0 scale-95",children:(0,s.jsx)(FO,{isChild:!0,sessionID:n,tenantID:r,baseURL:o,apiURL:a,onClick:e=>{m(d.find((t=>t.mediumID===e)))},item:{...e,title:e.title,url:e.url,content:e.content,type:"document"},customMediaRenderer:l})},e.url+"&index="+t)))}),v.map((e=>(0,s.jsx)(dp.Child,{as:"div",className:"memori-media-item--snippet",enter:"ease-out duration-500",enterFrom:"opacity-0 translate-y-1",enterTo:"opacity-1 translate-y-0",leave:"ease-in duration-300",leaveFrom:"opacity-1",leaveTo:"opacity-0",children:(0,s.jsx)(AO,{medium:e},e.mediumID)},e.mediumID))),y.map((e=>(0,s.jsx)("style",{dangerouslySetInnerHTML:{__html:e.content||""}},e.mediumID))),(null==p?void 0:p.mediumID)&&(0,s.jsx)(aP,{width:"100%",widthMd:"100%",className:"memori-media-item--modal",open:!!p,onClose:()=>m(void 0),footer:null,children:(0,s.jsx)(FO,{isChild:!0,sessionID:n,tenantID:r,baseURL:o,apiURL:a,item:{...p,title:p.title,url:p.url,content:p.content,type:"document"},customMediaRenderer:l})})]})}));var jO=(0,c.memo)((({hints:e=[],links:n=[],media:r=[],simulateUserPrompt:i=(()=>{}),sessionID:o,baseUrl:a,apiUrl:l,translateTo:u,customMediaRenderer:d,fromUser:h=!1})=>{const{t:p}=Ie(),[m,f]=(0,c.useState)(!0),[g,v]=(0,c.useState)(6);return(0,c.useEffect)((()=>{f(!0)}),[e]),(0,s.jsxs)("div",{className:"memori-media-widget",children:[(null==r?void 0:r.length)>0&&(0,s.jsx)(UO,{items:r,sessionID:o,translateTo:u,baseURL:a,apiURL:l,customMediaRenderer:d,fromUser:h}),(null==n?void 0:n.length)>0&&(0,s.jsx)(PO,{items:n,baseUrl:a,fromUser:h}),(null==e?void 0:e.length)>0&&m&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(dp,{appear:!0,show:!0,as:"ul",className:"memori-media--hints",children:e.slice(0,g).map(((e,n)=>(0,s.jsx)(dp.Child,{as:"li",enter:"ease-out duration-500",enterFrom:"opacity-0 translate-y-1",enterTo:"opacity-1 translate-y-0",leave:"ease-in duration-300",leaveFrom:"opacity-1",leaveTo:"opacity-0",children:(0,s.jsx)(Mm,{className:t(Is)("memori-media--hint"),primary:!0,onClick:()=>{i(e.originalText,e.text),f(!1)},onTouchEnd:()=>{i(e.originalText,e.text),f(!1)},children:e.text},e.text+n)},e.text+n)))}),e.length>g&&(0,s.jsx)("div",{className:"memori-hints--show-more",children:(0,s.jsx)(Mm,{className:"memori-hints--show-more-button",id:"showMoreHints",onClick:()=>v(g+6),children:p("expand")||"Expand"})})]})]})}));const GO=e=>e.endsWith("?")?e:`${e}?`;var HO=({message:e,apiURL:n,sessionID:r,visible:i=!0,initialMatches:o=[],closeDrawer:a,_TEST_loading:l=!1})=>{const{t:u}=Ie(),d=ne(n).search.searchMemory,[h,p]=(0,c.useState)(o),[m,f]=(0,c.useState)(l),g=(0,c.useCallback)((async()=>{if(f(!0),!l){try{const{matches:n,...i}=await d(r,{searchType:"Semantic",numberOfResults:3,text:e.questionAnswered,date:e.date,placeName:e.placeName,placeLatitude:e.placeLatitude,placeLongitude:e.placeLongitude,placeUncertaintyKm:e.placeUncertaintyKm,contextVars:e.contextVars,tag:e.tag,memoryTags:e.memoryTags});0!==i.resultCode?(console.error(i),t(rd).error(u(wO(i.resultCode)))):p(null!=n?n:[])}catch(e){console.error("WHYTHISANSWER/FETCH",e),p(null!=o?o:[])}f(!1)}}),[e,r]);return(0,c.useEffect)((()=>{g()}),[g,e,r]),(0,s.jsxs)(Om,{open:i,width:"80%",animated:!1,className:"memori-whythisanswer-drawer",onClose:()=>a(),title:u("whyThisAnswer"),children:[(0,s.jsx)("p",{children:u("whyThisAnswerHelper")}),e.questionAnswered&&(0,s.jsxs)("p",{className:"memori--whythisanswer-question-answered",children:[(0,s.jsxs)("strong",{children:[u("question")||"Question",":"]})," ",e.questionAnswered]}),(0,s.jsxs)(Tm,{primary:!0,spinning:m,children:[!m&&0===h.length&&(0,s.jsx)("p",{role:"info",className:"memori--whythisanswer-no-results",children:u("nothingFound")}),m&&0===h.length&&(0,s.jsxs)("ul",{className:"memori--whythisanswer-list memori--whythisanswer-skeleton",children:[(0,s.jsxs)("li",{children:[(0,s.jsxs)("div",{className:"memori--whythisanswer-title",children:[(0,s.jsx)("span",{className:"memori--whythisanswer-confidence",children:(0,s.jsx)("span",{className:"memori--whythisanswer-skeleton-text"})}),(0,s.jsx)("div",{className:"memori--whythisanswer-title-text",children:(0,s.jsx)("p",{className:"memori--whythisanswer-skeleton-text"})})]}),(0,s.jsxs)("p",{children:[(0,s.jsx)("div",{className:"memori--whythisanswer-skeleton-text"}),(0,s.jsx)("div",{className:"memori--whythisanswer-skeleton-text"}),(0,s.jsx)("div",{className:"memori--whythisanswer-skeleton-text"})]}),(0,s.jsx)("div",{className:"memori--whythisanswer-skeleton-block"})]}),(0,s.jsxs)("li",{children:[(0,s.jsxs)("div",{className:"memori--whythisanswer-title",children:[(0,s.jsx)("span",{className:"memori--whythisanswer-confidence",children:(0,s.jsx)("span",{className:"memori--whythisanswer-skeleton-text"})}),(0,s.jsxs)("div",{className:"memori--whythisanswer-title-text",children:[(0,s.jsx)("p",{className:"memori--whythisanswer-skeleton-text"}),(0,s.jsx)("p",{className:"memori--whythisanswer-skeleton-text"})]})]}),(0,s.jsxs)("p",{children:[(0,s.jsx)("div",{className:"memori--whythisanswer-skeleton-text"}),(0,s.jsx)("div",{className:"memori--whythisanswer-skeleton-text"})]}),(0,s.jsx)("div",{className:"memori--whythisanswer-skeleton-block"})]})]}),h.length>0&&(0,s.jsx)("ul",{className:"memori--whythisanswer-list",children:h.map((e=>{var t,n,r,i,o,a,l;return(0,s.jsxs)("li",{children:[(0,s.jsxs)("div",{className:"memori--whythisanswer-title",children:[(0,s.jsx)("span",{className:"memori--whythisanswer-confidence",children:e.confidenceLevel}),(0,s.jsxs)("div",{className:"memori--whythisanswer-title-text",children:[(0,s.jsx)("div",{className:"memori--whythisanswer-title-text-top-container",children:(0,s.jsx)("p",{children:(0,s.jsx)("strong",{children:GO(null!==(t=e.memory.title)&&void 0!==t?t:"")})})}),(0,s.jsx)("p",{children:null===(r=null===(n=e.memory.titleVariants)||void 0===n?void 0:n.map((e=>GO(e))))||void 0===r?void 0:r.join(" | ")}),(e.memory.receiverName||e.memory.receiverTag)&&(0,s.jsxs)("p",{className:"memori--whythisanswer-title-text-top",children:[u("receiverLabel"),": ",e.memory.receiverTag," ",e.memory.receiverName]})]})]}),e.memory.contextVars&&(0,s.jsx)("div",{className:"memori--whythisanswer-contextvars",children:Object.entries(e.memory.contextVars||{}).map((([e,t])=>(0,s.jsx)(MO,{className:"memori--whythisanswer-contextvars-card",children:(0,s.jsxs)("span",{children:[e,": ",(null==t?void 0:t.toString())||"✔️"]})},e)))}),null===(i=e.memory.answers)||void 0===i?void 0:i.map(((e,t)=>(0,s.jsx)("p",{className:"memori--whythisanswer-answer",children:(0,s.jsx)(xO,{mode:"rows",rows:3,children:e.text})},t))),(0,s.jsx)(jO,{links:null===(o=e.memory.media)||void 0===o?void 0:o.filter((e=>"text/html"===e.mimeType))}),null===(l=null===(a=e.memory.media)||void 0===a?void 0:a.filter((e=>"text/plain"===e.mimeType)))||void 0===l?void 0:l.map((e=>(0,s.jsx)(xO,{mode:"rows",rows:2,lineHeightMultiplier:2,innerClassName:"memori--whythisanswer-snippet-expandable",children:(0,s.jsx)(AO,{medium:e,showCopyButton:!1},e.mediumID)},e.mediumID)))]},e.memory.memoryID)}))})]})]})};var VO=({message:e,memori:n,tenant:r,baseUrl:i,apiUrl:o,sessionID:a,showFeedback:l,showWhyThisAnswer:u=!0,showCopyButton:d=!0,showTranslationOriginal:h=!1,simulateUserPrompt:p,showAIicon:m=!0,isFirst:f=!1,useMathFormatting:g=!1,user:v,userAvatar:y,experts:_,showFunctionCache:S=!1})=>{var b,x,C,w,A,E,I,T;const{t:M,i18n:R}=Ie(),P=R.language||"en",[N,O]=(0,c.useState)(!1),[D,L]=(0,c.useState)(!1),[k,B]=(0,c.useState)([]);(0,c.useEffect)((()=>{"undefined"==typeof window||window.MathJax||SR()}),[]),(0,c.useEffect)((()=>{const t=e.translatedText||e.text,n=/<document_attachment filename="([^"]+)" type="([^"]+)">([\s\S]*?)<\/document_attachment>/g,r=[];let i;for(;null!==(i=n.exec(t));){const[,e,t,n]=i;r.push({mediumID:`doc_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,url:"",mimeType:t,title:e,content:n.trim(),properties:{isDocumentAttachment:!0},type:"document"})}B(r)}),[e.text,e.translatedText]);const z=(e.translatedText||e.text).replace(/<document_attachment filename="([^"]+)" type="([^"]+)">([\s\S]*?)<\/document_attachment>/g,""),{text:F}=bO(z,g,M("reasoning")||"Reasoning..."),U=e.fromUser?SO(z):gR(fR(F)),j=null===(b=e.media)||void 0===b?void 0:b.find((e=>{var t;return"true"===(null===(t=e.properties)||void 0===t?void 0:t.functionCache)}));return(0,c.useLayoutEffect)((()=>{if("undefined"!=typeof window&&!e.fromUser){const e=setTimeout((()=>{if(window.MathJax&&window.MathJax.typesetPromise)try{if(document.querySelectorAll(".memori-chat--bubble-content").length>0){const e=document.querySelector(".memori-chat--history"),t=(null==e?void 0:e.scrollTop)||0,n=(null==e?void 0:e.scrollHeight)||0;window.MathJax.typesetPromise([".memori-chat--bubble-content"]).then((()=>{if(e){const r=e.scrollHeight-n;e.scrollTop=t+r}})).catch((e=>console.error("MathJax typesetting failed:",e)))}}catch(e){console.error("Error during MathJax typesetting:",e)}}),100);return()=>clearTimeout(e)}}),[z,e.fromUser,F]),console.log("media",null==e?void 0:e.media),(0,s.jsxs)(s.Fragment,{children:[(e.initial||f)&&(0,s.jsx)("div",{className:"memori-chat--bubble-initial"}),(0,s.jsxs)(dp,{show:!0,appear:!0,as:"div",className:t(Is)("memori-chat--bubble-container",{"memori-chat--bubble-from-user":!!e.fromUser,"memori-chat--with-addon":e.generatedByAI&&m||l&&p}),children:[!e.fromUser&&(0,s.jsx)(dp.Child,{as:"picture",className:"memori-chat--bubble-avatar",enter:"transition ease-in-out duration-300",enterFrom:"opacity-0 scale-075 "+(e.fromUser?"translate-x-15":"translate-x--15"),enterTo:"opacity-1 scale-1 translate-x-0",leave:"transition ease-in-out duration-300",leaveFrom:"opacity-1 scale-1 translate-x-0",leaveTo:"opacity-0 scale-075 "+(e.fromUser?"translate-x-15":"translate-x--15"),title:(null===(x=e.emitter)||void 0===x?void 0:x.length)&&n.enableBoardOfExperts?e.emitter:n.name,children:(0,s.jsx)("img",{className:"memori-chat--bubble-avatar-img",alt:(null===(C=e.emitter)||void 0===C?void 0:C.length)&&n.enableBoardOfExperts?e.emitter:n.name,src:(null===(w=e.emitter)||void 0===w?void 0:w.length)&&n.enableBoardOfExperts&&(null==_?void 0:_.find((t=>t.name===e.emitter)))?`${new URL(null!=o?o:"/").origin}/api/v1/memoriai/memori/avatar/${null===(A=_.find((t=>t.name===e.emitter)))||void 0===A?void 0:A.expertMemoriID}`:n.avatarURL&&n.avatarURL.length>0?RN({type:"avatar",tenantID:null==r?void 0:r.name,resourceURI:n.avatarURL,baseURL:i,apiURL:o}):RN({tenantID:null==r?void 0:r.name,type:"avatar",baseURL:i||"https://www.aisuru.com",apiURL:o}),onError:e=>{e.currentTarget.src=n.avatarURL&&n.avatarURL.length>0?RN({type:"avatar",tenantID:null==r?void 0:r.name,resourceURI:n.avatarURL,baseURL:i}):RN({tenantID:null==r?void 0:r.name,type:"avatar",baseURL:i}),e.currentTarget.onerror=null}})}),(0,s.jsxs)(dp.Child,{as:"div",className:t(Is)("memori-chat--bubble",{"memori-chat--user-bubble":!!e.fromUser,"memori-chat--with-addon":!e.fromUser&&d||e.generatedByAI&&m||l&&p,"memori-chat--ai-generated":e.generatedByAI&&m,"memori-chat--with-feedback":l}),enter:"transition ease-in-out duration-300",enterFrom:"opacity-0 scale-09 translate-x-"+(e.fromUser?"30":"-30"),enterTo:"opacity-1 scale-1 translate-x-0",leave:"transition ease-in-out duration-300",leaveFrom:"opacity-1 scale-1 translate-x-0",leaveTo:"opacity-0 scale-09 translate-x-"+(e.fromUser?"30":"-30"),children:[e.fromUser?(0,s.jsx)(xO,{className:"memori-chat--bubble-content",mode:"characters",children:(0,s.jsx)("div",{dir:"auto",className:"memori-chat--bubble-content",dangerouslySetInnerHTML:{__html:F}})}):(0,s.jsx)("div",{dir:"auto",className:"memori-chat--bubble-content",dangerouslySetInnerHTML:{__html:F}}),(!e.fromUser&&d||e.generatedByAI&&m||e.generatedByAI&&S||l&&p)&&(0,s.jsxs)("div",{className:"memori-chat--bubble-addon",children:[!e.fromUser&&d&&(0,s.jsx)(Mm,{ghost:!0,shape:"circle",title:M("copy")||"Copy",className:"memori-chat--bubble-action-icon",icon:(0,s.jsx)(rO,{"aria-label":M("copy")||"Copy"}),onClick:()=>navigator.clipboard.writeText(U)}),!e.fromUser&&d&&U!==e.text&&(0,s.jsx)(Mm,{ghost:!0,shape:"circle",title:M("copyRawCode")||"Copy raw code",className:"memori-chat--bubble-action-icon",icon:(0,s.jsx)(iO,{"aria-label":M("copyRawCode")||"Copy raw code"}),onClick:()=>navigator.clipboard.writeText(e.text)}),!e.fromUser&&S&&(null===(E=e.media)||void 0===E?void 0:E.some((e=>{var t,n;return Boolean(null===(t=e.properties)||void 0===t?void 0:t.functionCache)||"true"===(null===(n=e.properties)||void 0===n?void 0:n.functionCache)})))&&(0,s.jsx)(Mm,{ghost:!0,shape:"circle",title:"Debug",className:"memori-chat--bubble-action-icon memori-chat--bubble-action-icon--debug",icon:(0,s.jsx)(oO,{"aria-label":"Debug"}),onClick:()=>L(!0)}),l&&!!p&&(0,s.jsx)(tO,{memori:n,className:"memori-chat--bubble-feedback",dropdown:!0,onNegativeClick:e=>{e&&p(e)}}),e.generatedByAI&&m&&(0,s.jsx)(DN,{align:"left",content:M("generatedByAI")||("it"===P?"Risposta generata da IA, può talvolta generare informazioni non corrette":"Answer generated by AI, may occasionally generate incorrect informations"),className:"memori-chat--bubble-action-icon memori-chat--bubble-action-icon--ai",children:(0,s.jsx)("span",{children:(0,s.jsx)(NN,{title:M("generatedByAI")||("it"===P?"Risposta generata da IA, può talvolta generare informazioni non corrette":"Answer generated by AI, may occasionally generate incorrect informations")})})}),h&&e.translatedText&&e.translatedText!==e.text&&(0,s.jsx)(DN,{align:"left",content:`${"it"===P?"Testo originale":"Original text"}: ${e.text}`,className:"memori-chat--bubble-action-icon memori-chat--bubble-action-icon--ai",children:(0,s.jsx)("span",{children:(0,s.jsx)(ON,{"aria-label":"it"===P?"Testo originale":"Original text"})})}),!e.fromUser&&e.questionAnswered&&o&&u&&(0,s.jsx)(Mm,{ghost:!0,shape:"circle",title:M("whyThisAnswer")||void 0,className:"memori-chat--bubble-action-icon",onClick:()=>O(!0),disabled:N,icon:(0,s.jsx)(nO,{title:M("whyThisAnswer")||void 0})})]})]}),e.fromUser&&(0,s.jsx)(s.Fragment,{children:y&&"string"==typeof y||!y&&(null===(I=null==v?void 0:v.avatarURL)||void 0===I?void 0:I.length)?(0,s.jsx)(dp.Child,{as:"picture",className:"memori-chat--bubble-avatar",enter:"transition ease-in-out duration-300",enterFrom:"opacity-0 scale-075 "+(e.fromUser?"translate-x-15":"translate-x--15"),enterTo:"opacity-1 scale-1 translate-x-0",leave:"transition ease-in-out duration-300",leaveFrom:"opacity-1 scale-1 translate-x-0",leaveTo:"opacity-0 scale-075 "+(e.fromUser?"translate-x-15":"translate-x--15"),children:(0,s.jsx)("img",{className:"memori-chat--bubble-avatar-img",alt:null!==(T=null==v?void 0:v.userName)&&void 0!==T?T:"User",src:null!=y?y:null==v?void 0:v.avatarURL})}):y?(0,s.jsx)(dp.Child,{as:"div",className:"memori-chat--bubble-avatar",enter:"transition ease-in-out duration-300",enterFrom:"opacity-0 scale-075 "+(e.fromUser?"translate-x-15":"translate-x--15"),enterTo:"opacity-1 scale-1 translate-x-0",leave:"transition ease-in-out duration-300",leaveFrom:"opacity-1 scale-1 translate-x-0",leaveTo:"opacity-0 scale-075 "+(e.fromUser?"translate-x-15":"translate-x--15"),children:y}):(0,s.jsx)(dp.Child,{as:"div",className:"memori-chat--bubble-avatar",enter:"transition ease-in-out duration-300",enterFrom:"opacity-0 scale-075 "+(e.fromUser?"translate-x-15":"translate-x--15"),enterTo:"opacity-1 scale-1 translate-x-0",leave:"transition ease-in-out duration-300",leaveFrom:"opacity-1 scale-1 translate-x-0",leaveTo:"opacity-0 scale-075 "+(e.fromUser?"translate-x-15":"translate-x--15"),children:(0,s.jsx)(PN,{})})})]}),k.length>0&&(0,s.jsx)(jO,{media:k,sessionID:a,baseUrl:i,apiUrl:o,fromUser:e.fromUser}),e.media&&e.media.length>0&&(0,s.jsx)(jO,{media:e.media.filter((e=>"text/html"!==e.mimeType&&"text/plain"!==e.mimeType)),links:e.media.filter((e=>"text/html"===e.mimeType)),sessionID:a,baseUrl:i,apiUrl:o,fromUser:e.fromUser}),N&&o&&(0,s.jsx)(HO,{visible:N,message:e,closeDrawer:()=>O(!1),apiURL:o,sessionID:a}),(0,s.jsx)(aP,{title:null==j?void 0:j.title,open:D,onClose:()=>L(!1),className:"memori-chat--function-cache-modal",children:(0,s.jsx)("pre",{style:{whiteSpace:"pre-wrap",wordWrap:"break-word"},children:null==j?void 0:j.content})})]})};c=o("85Hg2"),c=o("85Hg2");var WO=({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:"M855 160.1l-189.2 23.5c-6.6.8-9.3 8.8-4.7 13.5l54.7 54.7-153.5 153.5a8.03 8.03 0 0 0 0 11.3l45.1 45.1c3.1 3.1 8.2 3.1 11.3 0l153.6-153.6 54.7 54.7a7.94 7.94 0 0 0 13.5-4.7L863.9 169a7.9 7.9 0 0 0-8.9-8.9zM416.6 562.3a8.03 8.03 0 0 0-11.3 0L251.8 715.9l-54.7-54.7a7.94 7.94 0 0 0-13.5 4.7L160.1 855c-.6 5.2 3.7 9.5 8.9 8.9l189.2-23.5c6.6-.8 9.3-8.8 4.7-13.5l-54.7-54.7 153.6-153.6c3.1-3.1 3.1-8.2 0-11.3l-45.2-45z"})});var qO=({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:"M391 240.9c-.8-6.6-8.9-9.4-13.6-4.7l-43.7 43.7L200 146.3a8.03 8.03 0 0 0-11.3 0l-42.4 42.3a8.03 8.03 0 0 0 0 11.3L280 333.6l-43.9 43.9a8.01 8.01 0 0 0 4.7 13.6L401 410c5.1.6 9.5-3.7 8.9-8.9L391 240.9zm10.1 373.2L240.8 633c-6.6.8-9.4 8.9-4.7 13.6l43.9 43.9L146.3 824a8.03 8.03 0 0 0 0 11.3l42.4 42.3c3.1 3.1 8.2 3.1 11.3 0L333.7 744l43.7 43.7A8.01 8.01 0 0 0 391 783l18.9-160.1c.6-5.1-3.7-9.4-8.8-8.8zm221.8-204.2L783.2 391c6.6-.8 9.4-8.9 4.7-13.6L744 333.6 877.7 200c3.1-3.1 3.1-8.2 0-11.3l-42.4-42.3a8.03 8.03 0 0 0-11.3 0L690.3 279.9l-43.7-43.7a8.01 8.01 0 0 0-13.6 4.7L614.1 401c-.6 5.2 3.7 9.5 8.8 8.9zM744 690.4l43.9-43.9a8.01 8.01 0 0 0-4.7-13.6L623 614c-5.1-.6-9.5 3.7-8.9 8.9L633 783.1c.8 6.6 8.9 9.4 13.6 4.7l43.7-43.7L824 877.7c3.1 3.1 8.2 3.1 11.3 0l42.4-42.3c3.1-3.1 3.1-8.2 0-11.3L744 690.4z"})});var JO=({disabled:e=!1,value:n,onChange:r,onPressEnter:i,onFocus:o,onBlur:a})=>{const{t:l}=Ie(),[u,d]=(0,c.useState)(!1);return(0,s.jsx)("div",{"data-testid":"chat-textarea",className:t(Is)("memori-chat-textarea",{"memori-chat-textarea--expanded":u,"memori-chat-textarea--disabled":e}),children:(0,s.jsxs)("div",{className:"memori-chat-textarea--inner",children:[(0,s.jsx)("textarea",{className:"memori-chat-textarea--input",disabled:e,value:n,onChange:e=>{r(e.target.value)},onKeyDownCapture:e=>{"Enter"===e.key&&!e.shiftKey&&i&&i(e)},onFocus:o,onBlur:a,maxLength:1e5}),(0,s.jsx)("div",{className:"memori-chat-textarea--expand",children:(0,s.jsx)(Mm,{className:t(Is)("memori-chat-textarea--expand-button"),onClick:()=>d(!u),padded:!1,ghost:!0,title:u?l("collapse")||"Collapse":l("expand")||"Expand",icon:u?(0,s.jsx)(qO,{}):(0,s.jsx)(WO,{})})})]})})};var KO=({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:"M931.4 498.9L94.9 79.5c-3.4-1.7-7.3-2.1-11-1.2-8.5 2.1-13.8 10.7-11.7 19.3l86.2 352.2c1.3 5.3 5.2 9.6 10.4 11.3l147.7 50.7-147.6 50.7c-5.2 1.8-9.1 6-10.3 11.3L72.2 926.5c-.9 3.7-.5 7.6 1.2 10.9 3.9 7.9 13.5 11.1 21.5 7.2l836.5-417c3.1-1.5 5.6-4.1 7.2-7.1 3.9-8 .7-17.6-7.2-21.6zM170.8 826.3l50.3-205.6 295.2-101.3c2.3-.8 4.2-2.6 5-5 1.4-4.2-.8-8.7-5-10.2L221.1 403 171 198.2l628 314.9-628.2 313.2z"})});c=o("85Hg2");var YO=({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:"M842 454c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8 0 140.3-113.7 254-254 254S258 594.3 258 454c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8 0 168.7 126.6 307.9 290 327.6V884H326.7c-13.7 0-24.7 14.3-24.7 32v36c0 4.4 2.8 8 6.2 8h407.6c3.4 0 6.2-3.6 6.2-8v-36c0-17.7-11-32-24.7-32H548V782.1c165.3-18 294-158 294-328.1zM512 624c93.9 0 170-75.2 170-168V232c0-92.8-76.1-168-170-168s-170 75.2-170 168v224c0 92.8 76.1 168 170 168zm-94-392c0-50.6 41.9-92 94-92s94 41.4 94 92v224c0 50.6-41.9 92-94 92s-94-41.4-94-92V232z"})});var XO=({listening:e,stopAudio:n,startListening:r,stopListening:i})=>{const{t:o}=Ie(),[a,l]=(0,c.useState)(),u=(0,c.useRef)(null),d=e=>{e.preventDefault(),l(o("write_and_speak.holdToSpeak")||"Hold to record"),u.current||(u.current=setTimeout((()=>{n(),l(o("write_and_speak.releaseToEndListening")||"Release to end listening"),r()}),300))},h=()=>{u.current&&(clearTimeout(u.current),u.current=null),i(),l(void 0)};return(0,c.useEffect)((()=>()=>h()),[]),(0,s.jsx)(DN,{visible:!!a,content:(0,s.jsx)("span",{children:a||o("write_and_speak.pressAndHoldToSpeak")||"Press and hold to speak"}),align:"topLeft",className:"memori-mic-btn-tooltip",children:(0,s.jsx)(Mm,{primary:!0,className:t(Is)("memori-chat-inputs--mic",{"memori-chat-inputs--mic--listening":e}),title:e?o("write_and_speak.micButtonPopoverListening")||"Listening":o("write_and_speak.micButtonPopover")||"Start listening",onMouseDown:d,onTouchStart:d,onMouseUp:h,onTouchEnd:h,shape:"circle",icon:(0,s.jsx)(YO,{})})})};c=o("85Hg2");const QO=({className:e})=>(0,s.jsxs)("svg",{className:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,s.jsx)("path",{d:"M14 2.5H6C5.60218 2.5 5.22064 2.65804 4.93934 2.93934C4.65804 3.22064 4.5 3.60218 4.5 4V20C4.5 20.3978 4.65804 20.7794 4.93934 21.0607C5.22064 21.342 5.60218 21.5 6 21.5H18C18.3978 21.5 18.7794 21.342 19.0607 21.0607C19.342 20.7794 19.5 20.3978 19.5 20V8L14 2.5Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),(0,s.jsx)("path",{d:"M14 2.5V8H19.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),(0,s.jsx)("path",{d:"M16 13H8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),(0,s.jsx)("path",{d:"M16 17H8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),(0,s.jsx)("path",{d:"M10 9H8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]});const $O=({className:e})=>(0,s.jsxs)("svg",{className:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,s.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),(0,s.jsx)("circle",{cx:"8.5",cy:"8.5",r:"1.5",fill:"currentColor"}),(0,s.jsx)("path",{d:"M21 15L16 10L5 21",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),ZO=({className:e})=>(0,s.jsxs)("svg",{className:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,s.jsx)("path",{d:"M21 15V19C21 19.5304 20.7893 20.0391 20.4142 20.4142C20.0391 20.7893 19.5304 21 19 21H5C4.46957 21 3.96086 20.7893 3.58579 20.4142C3.21071 20.0391 3 19.5304 3 19V15",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),(0,s.jsx)("path",{d:"M17 8L12 3L7 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),(0,s.jsx)("path",{d:"M12 3V15",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]});c=o("85Hg2");var eD=({open:e=!1,onClose:n,className:r,title:i,description:o,children:a,type:l="info",icon:u,closable:d=!0,duration:h=null,action:p,width:m="400px"})=>{const{t:f}=Ie();t(c).useEffect((()=>{if(h&&e){const e=setTimeout((()=>{n(!1)}),h);return()=>clearTimeout(e)}}),[h,e,n]);return(0,s.jsx)(dp,{show:e,as:t(c).Fragment,appear:!0,children:(0,s.jsxs)("div",{className:t(Is)("memori-alert",(e=>{switch(e){case"success":return"memori-alert--success";case"warning":return"memori-alert--warning";case"error":return"memori-alert--error";default:return"memori-alert--info"}})(l),r),children:[(0,s.jsx)("style",{dangerouslySetInnerHTML:{__html:`\n .memori-alert {\n --memori-alert--width: ${m};\n }\n `}}),(0,s.jsx)(dp.Child,{as:t(c).Fragment,enter:"ease-out duration-300",enterFrom:"opacity-0 translate-y-4",enterTo:"opacity-100 translate-y-0",leave:"ease-in duration-200",leaveFrom:"opacity-100 translate-y-0",leaveTo:"opacity-0 translate-y-4",children:(0,s.jsxs)("div",{className:"memori-alert--container",children:[u&&(0,s.jsx)("div",{className:"memori-alert--icon",children:u}),(0,s.jsxs)("div",{className:"memori-alert--content",children:[i&&(0,s.jsx)("div",{className:"memori-alert--title",children:i}),o&&(0,s.jsx)("div",{className:"memori-alert--description",children:o}),a]}),(0,s.jsxs)("div",{className:"memori-alert--actions",children:[p&&(0,s.jsx)("div",{className:"memori-alert--action",children:p}),d&&(0,s.jsx)(Mm,{ghost:!0,padded:!0,shape:"circle",icon:(0,s.jsx)(Rm,{}),title:f("close")||"Close",onClick:()=>n(!1),className:"memori-alert--close"})]})]})})]})})};c=o("85Hg2");const tD=10485760,nD=1e5,rD="3.11.174",iD=`https://cdnjs.cloudflare.com/ajax/libs/pdf.js/${rD}/pdf.worker.min.js`,oD=`https://cdnjs.cloudflare.com/ajax/libs/pdf.js/${rD}/pdf.min.js`;var sD=({setDocumentPreviewFiles:e,maxDocuments:n,documentPreviewFiles:r})=>{const[i,o]=(0,c.useState)(!1),[a,l]=(0,c.useState)([]),[u,d]=(0,c.useState)(null),h=(0,c.useRef)(null),p=e=>{l((t=>t.filter((t=>t.message!==e))))},m=e=>{l((t=>[...t,e])),setTimeout((()=>p(e.message)),5e3)},f=async e=>{var t;const n=(null===(t=e.name.split(".").pop())||void 0===t?void 0:t.toLowerCase())||"";try{let t=null;return"pdf"===n?t=await(async e=>{try{window.pdfjsLib||await new Promise(((e,t)=>{const n=document.createElement("script");n.src=oD,n.onload=()=>{window.pdfjsLib.GlobalWorkerOptions.workerSrc=iD,e(!0)},n.onerror=t,document.head.appendChild(n)}));const t=await e.arrayBuffer(),n=await window.pdfjsLib.getDocument({data:t}).promise;let r="";for(let e=1;e<=n.numPages;e++){const t=await n.getPage(e);r+=(await t.getTextContent()).items.filter((e=>e.str&&"string"==typeof e.str)).map((e=>e.str)).join(" ")+"\n"}return r}catch(e){throw new Error(`PDF extraction failed: ${e instanceof Error?e.message:"Unknown error"}`)}})(e):["txt","md","json","csv"].includes(n)?t=await e.text():"xlsx"===n&&(t=await(async e=>{try{window.XLSX||await new Promise(((e,t)=>{const n=document.createElement("script");n.src="https://cdn.sheetjs.com/xlsx-0.20.0/package/dist/xlsx.full.min.js",n.onload=e,n.onerror=t,document.head.appendChild(n)}));const t=await e.arrayBuffer(),n=window.XLSX.read(t,{type:"array",cellFormula:!0,cellNF:!0,cellText:!0,cellDates:!0});let r="";for(const e of n.SheetNames){const t=n.Sheets[e],i=window.XLSX.utils.sheet_to_json(t,{header:1,raw:!1}),o=i.reduce(((e,t)=>(t.forEach(((t,n)=>{const r=(t||"").toString().length;e[n]=Math.max(e[n]||0,r)})),e)),[]),s=i.map((e=>e.map(((e,t)=>(e||"").toString().padEnd(o[t]+2))).join("|").trim()));if(s.length>0){const e=o.map((e=>"-".repeat(e+2))).join("+");s.splice(1,0,e)}r+=`Sheet: ${e}\n${s.join("\n")}\n\n`}return r}catch(e){throw new Error(`XLSX extraction failed: ${e instanceof Error?e.message:"Unknown error"}`)}})(e)),t&&t.length>nD&&(m({message:`File "${e.name}" content exceeds 100000 characters and was truncated`,severity:"warning",fileId:e.name}),t=t.substring(0,nD)+"\n\n[Content truncated due to size limits]"),t}catch(t){throw new Error(`Failed to process "${e.name}": ${t instanceof Error?t.message:"Unknown error"}`)}};return(0,s.jsxs)("div",{className:"memori--document-upload-wrapper",children:[(0,s.jsx)("input",{ref:h,type:"file",accept:".pdf,.txt,.md,.json,.xlsx,.csv",className:"memori--upload-file-input",onChange:async t=>{const n=Array.from(t.target.files||[]);if(0===n.length)return;const r=n[0];if(o(!0),l([]),!(e=>{var t;const n=`.${null===(t=e.name.split(".").pop())||void 0===t?void 0:t.toLowerCase()}`,r=[".pdf",".txt",".json",".xlsx",".csv",".md"];return r.includes(n)?!(e.size>tD&&(m({message:`File "${e.name}" exceeds 10MB limit`,severity:"error",fileId:e.name}),1)):(m({message:`File type "${n}" is not supported. Please use: ${r.join(", ")}`,severity:"error",fileId:e.name}),!1)})(r))return o(!1),void(h.current&&(h.current.value=""));const i=Math.random().toString(36).substr(2,9);try{const t=await f(r);t&&e([{name:r.name,id:i,content:t,mimeType:r.type}])}catch(e){m({message:`${e instanceof Error?e.message:"Unknown error"}`,severity:"error",fileId:r.name})}o(!1),h.current&&(h.current.value="")}}),(0,s.jsx)("button",{className:t(Is)("memori-button","memori-button--circle","memori-button--icon-only","memori-share-button--button","memori--conversation-button","memori--document-upload-button",{"memori--error":a.length>0}),onClick:()=>{var e;return null===(e=h.current)||void 0===e?void 0:e.click()},disabled:i||n&&r.filter((e=>"image"!==e.type)).length>=n||!1,title:"Upload documents",children:i?(0,s.jsx)(Tm,{spinning:!0,className:"memori--upload-icon"}):(0,s.jsx)(t(c).Fragment,{children:(0,s.jsx)(QO,{className:"memori--upload-icon"})})}),(0,s.jsx)(aP,{width:"80%",widthMd:"80%",open:!!u,className:"memori--modal-preview-file",onClose:()=>d(null),closable:!0,title:null==u?void 0:u.name,children:(0,s.jsx)("div",{className:"memori--preview-content",style:{maxHeight:"70vh",overflowY:"auto",textAlign:"center",whiteSpace:"pre-wrap"},children:null==u?void 0:u.content})}),(0,s.jsx)("div",{className:"memori--error-message-container",children:a.map(((e,t)=>(0,s.jsx)(eD,{open:!0,type:e.severity,title:"Upload notification",description:e.message,onClose:()=>p(e.message),width:"350px"},`${e.message}-${t}`)))})]})};c=o("85Hg2");const aD=10485760,lD=[".jpg",".jpeg",".png"];var cD=({authToken:e="",apiUrl:n="",sessionID:r="",isMediaAccepted:i=!1,setDocumentPreviewFiles:o,documentPreviewFiles:a,onLoadingChange:l,maxImages:u=5,memoriID:d=""})=>{var h,p,m;const{t:f,i18n:g}=Ie(),v=n?ne(n):null,{backend:y,dialog:_}=v||{backend:{uploadAsset:null,uploadAssetUnlogged:null},dialog:{postMediumSelectedEvent:null,postMediumDeselectedEvent:null}},[S,b]=(0,c.useState)(!1),[x,C]=(0,c.useState)([]),[w,A]=(0,c.useState)(null),[E,I]=(0,c.useState)(null),[T,M]=(0,c.useState)(""),[R,P]=(0,c.useState)(!1),N=(0,c.useRef)(null);(0,c.useEffect)((()=>{l&&l(S)}),[S,l]);const O=e=>{C((t=>t.filter((t=>t.message!==e))))},D=e=>{C((t=>[...t,e])),setTimeout((()=>O(e.message)),5e3)},L=a.filter((e=>"image"===e.type)).length,k=()=>{P(!1),A(null),I(null),M("")};return(0,s.jsxs)("div",{className:"memori--image-upload-wrapper",children:[(0,s.jsx)("input",{ref:N,type:"file",accept:lD.join(","),className:"memori--upload-file-input",onChange:async e=>{var t;const n=Array.from(e.target.files||[]);if(0===n.length)return;if(L>=u)return void D({message:null!==(t=f("upload.maxImagesReached"))&&void 0!==t?t:`Maximum ${u} images allowed.`,severity:"error"});C([]);const r=n[0];if(!(e=>{var t;const n=`.${null===(t=e.name.split(".").pop())||void 0===t?void 0:t.toLowerCase()}`;return lD.includes(n)||e.type.startsWith("image/")?!(e.size>aD&&(D({message:`File "${e.name}" exceeds 10MB limit`,severity:"error",fileId:e.name}),1)):(D({message:`File type "${n}" is not supported. Please use: ${lD.join(", ")}`,severity:"error",fileId:e.name}),!1)})(r))return void(N.current&&(N.current.value=""));A(r),I(URL.createObjectURL(r));const i=r.name.split(".").slice(0,-1).join(".");M(i),P(!0),N.current&&(N.current.value="")},disabled:S||!i||L>=u}),(0,s.jsx)("button",{className:t(Is)("memori-button","memori-button--circle","memori-button--icon-only","memori-share-button--button","memori--conversation-button","memori--image-upload-button"),onClick:()=>{var e;return null===(e=N.current)||void 0===e?void 0:e.click()},disabled:S||!i||L>=u,children:S?(0,s.jsx)(Tm,{spinning:!0,className:"memori--upload-icon"}):(0,s.jsx)($O,{className:"memori--upload-icon"})}),(0,s.jsx)(aP,{width:"80%",widthMd:"80%",open:R&&!!w,className:"memori--modal-preview-file",onClose:k,closable:!0,title:f("upload.titleImage",{title:T}),children:(0,s.jsxs)("div",{className:"memori--preview-content",style:{maxHeight:"70vh",overflowY:"auto",textAlign:"center"},children:[E&&(0,s.jsx)("img",{src:E,alt:(null==w?void 0:w.name)||"Preview",style:{maxWidth:"100%",maxHeight:"40vh",marginBottom:"20px"}}),(0,s.jsxs)("div",{style:{maxWidth:"400px",margin:"0 auto",textAlign:"left"},children:[(0,s.jsx)("p",{style:{marginBottom:"10px",color:"#666"},children:f("upload.titleHelp")}),(0,s.jsx)("input",{value:T,onChange:e=>M(e.target.value),placeholder:null!==(h=f("upload.titlePlaceholder"))&&void 0!==h?h:"Enter image title",style:{width:"90%",marginBottom:"20px"},className:"memori--upload-title-input"}),(0,s.jsxs)("div",{style:{display:"flex",gap:"10px"},children:[(0,s.jsx)(Mm,{onClick:async()=>{var t;if(w&&T.trim()){b(!0),P(!1);try{const t=new FileReader;t.onload=async t=>{var i,s,l,c,u;const h=null===(i=t.target)||void 0===i?void 0:i.result,p=Math.random().toString(36).substr(2,9);if(n)try{let t,n;if(e&&(null==y?void 0:y.uploadAsset))n=await y.uploadAsset(w.name,h,e);else{if(!(d&&r&&(null==y?void 0:y.uploadAssetUnlogged)))throw new Error("Missing required parameters for upload");if(n=await y.uploadAssetUnlogged(w.name,h,d,r),!n)throw new Error("Upload failed")}if(t=n.asset,0!==n.resultCode)throw new Error(n.resultMessage||"Upload failed");let i,c=null;if((null==_?void 0:_.postMediumSelectedEvent)&&r&&(c=await _.postMediumSelectedEvent(r,{url:t.assetURL,mimeType:t.mimeType})),null===(s=null==c?void 0:c.currentState)||void 0===s?void 0:s.currentMedia){const e=new Set(a.map((e=>e.mediumID)));i=null===(l=c.currentState.currentMedia.find((t=>!e.has(t.mediumID))))||void 0===l?void 0:l.mediumID}o((e=>[...e,{name:T,id:p,url:t.assetURL,content:t.assetURL,type:"image",mediumID:i,mimeType:t.mimeType}]))}catch(e){D({message:null!==(c=f("upload.uploadFailed"))&&void 0!==c?c:"Upload failed",severity:"error",fileId:w.name})}else D({message:null!==(u=f("upload.apiClientNotConfigured"))&&void 0!==u?u:"API client not configured properly for media upload",severity:"warning"});b(!1)},t.onerror=()=>{var e;D({message:null!==(e=f("upload.fileReadingFailed"))&&void 0!==e?e:"File reading failed",severity:"error",fileId:w.name}),b(!1)},t.readAsDataURL(w)}catch(e){D({message:null!==(t=f("upload.uploadFailed"))&&void 0!==t?t:"Upload failed",severity:"error",fileId:w.name}),b(!1)}}},disabled:!w||!T.trim(),className:"memori-button memori-button--primary",children:null!==(p=f("confirm"))&&void 0!==p?p:"Confirm"}),(0,s.jsx)(Mm,{onClick:k,className:"memori-button memori-button--primary",children:null!==(m=f("cancel"))&&void 0!==m?m:"Cancel"})]})]})]})}),(0,s.jsx)("div",{className:"memori--error-message-container",children:x.map(((e,t)=>(0,s.jsx)(eD,{open:!0,type:e.severity,title:"Upload notification",description:e.message,onClose:()=>O(e.message),width:"350px"},`${e.message}-${t}`)))})]})};var uD=({authToken:e="",apiUrl:n="",sessionID:r="",isMediaAccepted:i=!1,setDocumentPreviewFiles:o,documentPreviewFiles:a,memoriID:l=""})=>{var u,d,h,p,m,f,g,v,y,_,S;const[b,x]=(0,c.useState)(!1),[C,w]=(0,c.useState)(!1),[A,E]=(0,c.useState)([]),{t:I,i18n:T}=Ie(),M=(0,c.useRef)(null),R=(0,c.useRef)(null),P=(0,c.useRef)(null),N=(0,c.useRef)(null),O=a.filter((e=>"image"===e.type)).length,D=5-O,L=a.filter((e=>"document"===e.type)).length,k=1-L,B=D<=0,z=k<=0,F=e=>{E((t=>t.filter((t=>t.message!==e))))},U=e=>{E((t=>[...t,e])),setTimeout((()=>F(e.message)),5e3)},j=()=>{w(!1)};(0,c.useEffect)((()=>{const e=e=>{M.current&&R.current&&!M.current.contains(e.target)&&!R.current.contains(e.target)&&j()};return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}}),[]);return(0,s.jsxs)("div",{className:"memori--unified-upload-wrapper",children:[(0,s.jsx)("button",{ref:R,className:t(Is)("memori-button","memori-button--circle","memori-button--icon-only","memori-share-button--button","memori--conversation-button","memori--unified-upload-button",{"memori--error":A.length>0}),onClick:()=>{w((e=>!e))},disabled:b,title:null!==(u=I("upload.uploadFiles"))&&void 0!==u?u:"Upload files",children:b?(0,s.jsx)(Tm,{spinning:!0,className:"memori--upload-icon"}):(0,s.jsx)(ZO,{className:"memori--upload-icon"})}),O>0&&(0,s.jsxs)("div",{className:t(Is)("memori--image-count",{"memori--image-count-full":B}),children:[O,"/",5]}),C&&(0,s.jsxs)("div",{className:"memori--upload-menu",ref:M,children:[(0,s.jsxs)("div",{className:t(Is)("memori--upload-menu-item",{"memori--upload-menu-item--disabled":z}),onClick:()=>{var e;const t=null===(e=P.current)||void 0===e?void 0:e.querySelector("button");t&&t.click(),j()},children:[(0,s.jsx)(QO,{className:"memori--upload-menu-icon"}),(0,s.jsxs)("span",{children:[null!==(d=I("upload.uploadDocument"))&&void 0!==d?d:"Upload document",L>0&&(0,s.jsx)("span",{className:"memori--upload-slots-info",children:z?` (${null!==(h=I("upload.maxReached"))&&void 0!==h?h:"Max reached"})`:` (${k} ${null!==(p=I("upload.remaining"))&&void 0!==p?p:"remaining"})`})]})]}),(0,s.jsxs)("div",{className:t(Is)("memori--upload-menu-item",{"memori--upload-menu-item--disabled":!i||B}),onClick:()=>{var e,t,n;if(!i)return U({message:null!==(e=I("upload.mediaNotAccepted"))&&void 0!==e?e:"Media uploads are not accepted",severity:"info"}),void j();if(B)return U({message:null!==(t=I("upload.maxImagesReached",{max:5}))&&void 0!==t?t:"Maximum 5 images already uploaded",severity:"warning"}),void j();const r=null===(n=N.current)||void 0===n?void 0:n.querySelector("button");r&&r.click(),j()},title:i?B?null!==(f=I("upload.maxImagesReached",{max:5}))&&void 0!==f?f:"Maximum 5 images already uploaded":1===D?null!==(g=I("upload.lastImageSlot"))&&void 0!==g?g:"Upload last image":null!==(v=I("upload.uploadImage",{remaining:D}))&&void 0!==v?v:`Upload image (${D} remaining)`:null!==(m=I("upload.mediaNotAccepted"))&&void 0!==m?m:"Media uploads not accepted",children:[(0,s.jsx)($O,{className:"memori--upload-menu-icon-image"}),(0,s.jsxs)("span",{children:[null!==(y=I("upload.uploadImage"))&&void 0!==y?y:"Upload image",O>0&&(0,s.jsx)("span",{className:"memori--upload-slots-info",children:B?` (${null!==(_=I("upload.maxReached"))&&void 0!==_?_:"Max reached"})`:` (${D} ${null!==(S=I("upload.remaining"))&&void 0!==S?S:"remaining"})`})]})]})]}),(0,s.jsx)("div",{className:"memori--hidden-uploader",ref:P,children:(0,s.jsx)(sD,{setDocumentPreviewFiles:e=>{if(0===e.length)return;const t=e[0];const n=`<document_attachment filename="${t.name.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}" type="${t.mimeType}">\n\n${t.content}\n\n</document_attachment>`,r=a.filter((e=>"image"===e.type));o([{name:t.name,id:t.id,content:n,type:"file",mimeType:t.mimeType},...r]),x(!1)},maxDocuments:1,documentPreviewFiles:a})}),(0,s.jsx)("div",{className:"memori--hidden-uploader",ref:N,children:(0,s.jsx)(cD,{authToken:e,apiUrl:n,setDocumentPreviewFiles:o,sessionID:r,documentPreviewFiles:a,isMediaAccepted:i,onLoadingChange:e=>{x(e)},maxImages:5,memoriID:l})}),(0,s.jsx)("div",{className:"memori--error-message-container",children:A.map(((e,t)=>(0,s.jsx)(eD,{open:!0,type:e.severity,title:"Upload notification",description:e.message,onClose:()=>F(e.message),width:"350px"},`${e.message}-${t}`)))})]})};c=o("85Hg2");var dD=({previewFiles:e,removeFile:t,allowRemove:n=!0,isMessagePreview:r=!1})=>{const[i,o]=(0,c.useState)(null),[a,l]=(0,c.useState)(null),u=(e,t)=>{var n,r;if("image"===t){switch(null===(n=e.split(".").pop())||void 0===n?void 0:n.toLowerCase()){case"jpg":case"jpeg":return"JPEG";case"png":return"PNG";default:return"Image"}}switch(null===(r=e.split(".").pop())||void 0===r?void 0:r.toLowerCase()){case"pdf":return"PDF";case"txt":return"Text";case"json":return"JSON";case"xlsx":return"Excel";case"csv":return"CSV";case"jpg":case"jpeg":return"JPEG";case"png":return"PNG";default:return"Document"}},d=(e,t)=>{if("image"===t)return!0;const n=/\.(jpg|jpeg|png|gif|webp|svg)$/i.test(e);return e.startsWith("http")&&(e.includes("/image/")||e.includes("/img/")||n)||n};return(0,s.jsxs)(s.Fragment,{children:[e.length>0&&(0,s.jsx)("div",{className:"memori--preview-container "+(r?"memori--message-preview":"memori--absolute-preview"),children:(0,s.jsx)("div",{className:"memori--preview-list",children:e.map((e=>(0,s.jsxs)("div",{className:"memori--preview-item "+(d(e.content,e.type)?"memori--preview-item--image":"memori--preview-item--document"),onMouseEnter:()=>l(e.id),onMouseLeave:()=>l(null),onClick:()=>o(e),children:[d(e.content,e.type)?(0,s.jsx)("div",{className:"memori--preview-thumbnail",children:(0,s.jsx)("img",{src:e.content,alt:e.name})}):(0,s.jsx)(QO,{className:"memori--preview-icon"}),(0,s.jsxs)("div",{className:"memori--preview-file-info",children:[(0,s.jsx)("span",{className:"memori--preview-filename",children:e.name}),(0,s.jsx)("span",{className:"memori--preview-filetype",children:u(e.name,e.type)})]}),n&&(0,s.jsx)(Mm,{shape:"rounded",icon:(0,s.jsx)(Rm,{}),danger:!0,className:"memori--remove-button "+(a===e.id?"visible":""),onClick:n=>{n.stopPropagation(),t(e.id,null==e?void 0:e.mediumID)}})]},e.id)))})}),(0,s.jsx)(aP,{width:"80%",widthMd:"80%",open:!!i,className:"memori--modal-preview-file",onClose:()=>o(null),closable:!0,title:null==i?void 0:i.name,children:(0,s.jsx)("div",{className:"memori--preview-content",style:{maxHeight:"70vh",overflowY:"auto",textAlign:"center",whiteSpace:i&&!d(i.content,i.type)?"pre-wrap":"normal"},children:i&&d(i.content,i.type)?(0,s.jsx)(s.Fragment,{children:(0,s.jsx)("img",{src:i.content,alt:i.name,style:{maxWidth:"100%",maxHeight:"60vh"}})}):gR((null==i?void 0:i.content)||"")})})]})};var hD=({dialogState:e,userMessage:n="",sendOnEnter:r,onChangeUserMessage:i,sendMessage:o,onTextareaFocus:a,onTextareaBlur:l,resetTranscript:u,showMicrophone:d=!1,microphoneMode:h="HOLD_TO_TALK",listening:p=!1,stopAudio:m,startListening:f,stopListening:g,showUpload:v=!1,sessionID:y,authToken:_,apiURL:S,memoriID:b})=>{const{t:x}=Ie(),[C,w]=(0,c.useState)([]),A=S?ne(S):null,{dialog:E}=A||{dialog:{postMediumDeselectedEvent:null}};return(0,s.jsxs)("fieldset",{id:"chat-fieldset",className:"memori-chat-inputs",disabled:"X2a"===(null==e?void 0:e.state)||"X3"===(null==e?void 0:e.state),children:[(0,s.jsx)(JO,{value:n,onChange:i,onPressEnter:()=>{"keypress"===r&&(null==n?void 0:n.length)>0&&(g(),o(n,C.map((e=>({mediumID:e.mediumID||"",mimeType:e.mimeType,content:e.content,title:e.name,properties:{isAttachedFile:!0},type:e.type,url:e.url})))),w([]),i(""),u())},onFocus:a,onBlur:l,disabled:["R2","R3","R4","R5","G3","X3"].includes((null==e?void 0:e.state)||"")}),v&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(dD,{previewFiles:C,removeFile:async(e,t)=>{console.log("removeFile",e),E.postMediumDeselectedEvent&&y&&t&&await E.postMediumDeselectedEvent(y,t),w((t=>t.filter((t=>t.id!==e))))}}),(0,s.jsx)(uD,{authToken:_,apiUrl:S,sessionID:y,isMediaAccepted:(null==e?void 0:e.acceptsMedia)||!1,setDocumentPreviewFiles:w,documentPreviewFiles:C,memoriID:b})]}),(0,s.jsx)(Mm,{shape:"circle",primary:!!(null==n?void 0:n.length),disabled:!n||0===n.length,className:"memori-chat-inputs--send",onClick:()=>{o(n,C.map((e=>({mediumID:e.mediumID||"",mimeType:e.mimeType,content:e.content,title:e.name,properties:{isAttachedFile:!0},type:e.type,url:e.url})))),w([]),m(),speechSynthesis.speak(new SpeechSynthesisUtterance(""))},title:x("send")||"Send",icon:(0,s.jsx)(KO,{})}),d&&"HOLD_TO_TALK"===h&&(0,s.jsx)(XO,{listening:p,startListening:f,stopListening:()=>{g(),(null==n?void 0:n.length)&&o(n)},stopAudio:m}),d&&"CONTINUOUS"===h&&(0,s.jsx)(Mm,{primary:!0,className:t(Is)("memori-chat-inputs--mic",{"memori-chat-inputs--mic--listening":p}),title:p?x("write_and_speak.micButtonPopoverListening")||"Listening":x("write_and_speak.micButtonPopover")||"Start listening",onClick:()=>{p?g():(m(),f())},shape:"circle",icon:(0,s.jsx)(YO,{})})]})};c=o("85Hg2");const pD=15,mD={en:[{delayAfter:pD,text:"Processing in progress..."},{delayAfter:pD,text:"I'm thinking..."},{delayAfter:pD,text:"Analysing the request..."},{delayAfter:pD,text:"Preparing the reply..."},{delayAfter:pD,text:"Gathering information..."},{delayAfter:pD,text:"Formulating ideas..."},{delayAfter:pD,text:"One moment please..."},{delayAfter:pD,text:"Almost ready..."},{delayAfter:pD,text:"Connecting concepts..."},{delayAfter:pD,text:"Organising ideas..."},{delayAfter:pD,text:"Evaluating options..."},{delayAfter:pD,text:"Looking for the best solution..."},{delayAfter:pD,text:"Working for you..."},{delayAfter:pD,text:"Please wait..."},{delayAfter:pD,text:"Processing data..."},{delayAfter:pD,text:"Calculating response..."},{delayAfter:pD,text:"Synthesising information..."},{delayAfter:pD,text:"Generating content..."},{delayAfter:pD,text:"Reflecting on question..."},{delayAfter:pD,text:"Refining the answer"}],it:[{delayAfter:pD,text:"Elaborazione in corso..."},{delayAfter:pD,text:"Sto pensando..."},{delayAfter:pD,text:"Analizzando la richiesta..."},{delayAfter:pD,text:"Preparando la risposta..."},{delayAfter:pD,text:"Raccogliendo informazioni..."},{delayAfter:pD,text:"Formulando idee..."},{delayAfter:pD,text:"Un momento per favore..."},{delayAfter:pD,text:"Quasi pronto..."},{delayAfter:pD,text:"Connettendo i concetti..."},{delayAfter:pD,text:"Organizzando le idee..."},{delayAfter:pD,text:"Valutando le opzioni..."},{delayAfter:pD,text:"Cercando la soluzione migliore..."},{delayAfter:pD,text:"Sto lavorando per te..."},{delayAfter:pD,text:"Attendere prego..."},{delayAfter:pD,text:"Elaborazione dati in corso..."},{delayAfter:pD,text:"Calcolando la risposta..."},{delayAfter:pD,text:"Sintetizzando informazioni..."},{delayAfter:pD,text:"Generando contenuti..."},{delayAfter:pD,text:"Sto riflettendo sulla domanda..."},{delayAfter:pD,text:"Perfezionando la risposta..."}]},fD=(e=15)=>new Array(20*e).fill(" ").join("");var gD=({useDefaultSentences:e=!1,lang:t="en",sentence:n,sentences:r})=>{var i;const[o,a]=(0,c.useState)(0),[l,u]=(0,c.useState)((null===(i=null==r?void 0:r[t])||void 0===i?void 0:i.length)?`${r[t][0].text.endsWith("...")||!r[t][0].text.length?r[t][0].text:`${r[t][0].text}...`}${fD(r[t][0].delayAfter)}`:n?`${n.endsWith("...")||!n.length?n:`${n}...`}${fD()}`:""),[d,h]=(0,c.useState)(""),[p,m]=(0,c.useState)(0);return(0,c.useEffect)((()=>{const i=setInterval((()=>{var i;m((e=>e+50));const s=l[d.length];if(void 0!==s&&l.length>0)h((e=>e+s));else if((null===(i=null==r?void 0:r[t])||void 0===i?void 0:i.length)&&o<r[t].length-1){const e=o+1,n=r[t][e];u(`${n.text.endsWith("...")||!n.text.length?n.text:`${n.text}...`}${fD(n.delayAfter)}`),h(""),a(e)}else if(!r&&!n&&(e||p>2e4)){const e=mD[t][Math.floor(Math.random()*mD[t].length)];u(`${e.text}${fD(e.delayAfter)}`),h("")}}),50);return()=>clearInterval(i)})),(0,s.jsx)("div",{className:"memori-chat--bubble",children:(0,s.jsxs)("div",{className:"memori-chat--bubble-typing",children:[(0,s.jsxs)("div",{id:"wave",children:[(0,s.jsx)("span",{className:"dot"}),(0,s.jsx)("span",{className:"dot"}),(0,s.jsx)("span",{className:"dot"})]}),l.length>0&&(0,s.jsx)("p",{children:d})]})})};var vD=(0,c.memo)((({memori:e,tenant:n,sessionID:r,baseUrl:i,apiUrl:o,translateTo:a,memoriTyping:l,typingText:u,showTypingText:d=!1,history:h=[],authToken:p,dialogState:m,simulateUserPrompt:f,showDates:g=!1,showContextPerLine:v=!1,showAIicon:y=!0,showWhyThisAnswer:_=!0,showCopyButton:S=!0,showTranslationOriginal:b=!1,preview:x=!1,instruct:C=!1,showInputs:w=!0,showMicrophone:A=!1,microphoneMode:E="HOLD_TO_TALK",sendOnEnter:I,setSendOnEnter:T,attachmentsMenuOpen:M,setAttachmentsMenuOpen:R,userMessage:P="",onChangeUserMessage:N,sendMessage:O,listening:D,setEnableFocusChatInput:L,isPlayingAudio:k,stopAudio:B,startListening:z,stopListening:F,resetTranscript:U,customMediaRenderer:j,user:G,userAvatar:H,showUpload:V=!1,experts:W,useMathFormatting:q=!1,isHistoryView:J=!1,showFunctionCache:K=!1})=>{var Y,X,Q,$,Z,ee,te;const ne=()=>{J||setTimeout((()=>{var e,t;let n=document.querySelectorAll(".memori-chat--bubble-container.memori-chat--bubble-from-user");null===(t=null===(e=n[n.length-1])||void 0===e?void 0:e.scrollIntoView)||void 0===t||t.call(e)}),200)};(0,c.useEffect)((()=>{!x&&!J&&ne()}),[h,x,J]);return(0,s.jsxs)("div",{className:t(Is)("memori-chat--wrapper",{"memori-chat-wrapper--translate":a}),id:"chat-wrapper",lang:null==a?void 0:a.toUpperCase(),"data-memori-lang":null!==($=null===(Q=null===(X=null===(Y=e.culture)||void 0===Y?void 0:Y.split("-"))||void 0===X?void 0:X[0])||void 0===Q?void 0:Q.toUpperCase())&&void 0!==$?$:"EN",children:[(0,s.jsx)("div",{className:t(Is)("memori-chat--history",{"memori-chat--history-touch":aR()}),children:(0,s.jsxs)("div",{className:t(Is)("memori-chat--content",{"memori-chat--content-touch":aR()}),children:[(0,s.jsx)("div",{className:t(Is)("memori-chat--cover"),style:{backgroundImage:`url("${RN({type:"cover",tenantID:null==n?void 0:n.name,resourceURI:e.coverURL,baseURL:i,apiURL:o})}"), url("${RN({type:"cover",tenantID:null==n?void 0:n.name,baseURL:i||"https://www.aisuru.com",apiURL:o})}")`}}),h.map(((l,u)=>{var d,p,x,C,w,A;return(0,s.jsxs)(t(c).Fragment,{children:[(0,s.jsx)(VO,{isFirst:0===u,message:l,memori:e,tenant:n,baseUrl:i,apiUrl:o,sessionID:r,simulateUserPrompt:f,showAIicon:y,showWhyThisAnswer:_,showTranslationOriginal:b,showFeedback:u===h.length-1&&!l.fromUser&&(null==m?void 0:m.acceptsFeedback),user:G,userAvatar:H,experts:W,showCopyButton:S,useMathFormatting:q,showFunctionCache:K},`chatbubble-${u}-${(null===(d=l.text)||void 0===d?void 0:d.includes("<document_attachment"))?"has-attachments":"no-attachments"}-${l.timestamp}`),g&&!!l.timestamp&&(0,s.jsx)("small",{className:"memori-chat--timestamp "+(l.fromUser?"text-right":"text-left"),children:new Intl.DateTimeFormat("it",{hour:"2-digit",minute:"2-digit",second:"2-digit"}).format(new Date(l.timestamp.endsWith("Z")?l.timestamp:`${l.timestamp}Z`))}),v&&!!Object.keys(null!==(p=l.contextVars)&&void 0!==p?p:{}).length&&(0,s.jsx)("div",{className:"memori-chat--context-vars",children:Object.keys(null!==(x=l.contextVars)&&void 0!==x?x:{}).map((e=>{var t,n,r;return"-"===(null===(t=l.contextVars)||void 0===t?void 0:t[e])?(0,s.jsx)("div",{className:"memori-chat--context-tag memori-chat--context-tag-canceled",children:(0,s.jsx)("span",{className:"memori-chat--context-tag-text",children:e})},e):"✔️"===(null===(n=l.contextVars)||void 0===n?void 0:n[e])?(0,s.jsx)("div",{className:"memori-chat--context-tag",children:(0,s.jsx)("span",{className:"memori-chat--context-tag-text",children:e})},e):(0,s.jsx)("div",{className:"memori-chat--context-tag",children:(0,s.jsxs)("span",{className:"memori-chat--context-tag-text",children:[e,": ",null===(r=l.contextVars)||void 0===r?void 0:r[e]]})},e)}))}),(0,s.jsx)(jO,{simulateUserPrompt:f,media:null===(C=null==l?void 0:l.media)||void 0===C?void 0:C.filter((e=>"text/html"!==e.mimeType&&"text/plain"!==e.mimeType)),links:null===(w=null==l?void 0:l.media)||void 0===w?void 0:w.filter((e=>"text/html"===e.mimeType)),sessionID:r,baseUrl:i,apiUrl:o,translateTo:a,customMediaRenderer:j,fromUser:l.fromUser})]},`${u}-${(null===(A=l.text)||void 0===A?void 0:A.includes("<document_attachment"))?"has-attachments":"no-attachments"}-${l.timestamp}`)})),(null==m?void 0:m.hints)&&m.hints.length>0&&!l&&(0,s.jsx)(jO,{simulateUserPrompt:f,hints:m.translatedHints?m.translatedHints:m.hints.map((e=>({text:e,originalText:e})))}),!!l&&(0,s.jsx)(gD,{useDefaultSentences:d,lang:a?"it"===a.toLowerCase()?"it":"en":"it"===(null===(te=null===(ee=null===(Z=e.culture)||void 0===Z?void 0:Z.split("-"))||void 0===ee?void 0:ee[0])||void 0===te?void 0:te.toLowerCase())?"it":"en",sentence:u,sentences:e.enableBoardOfExperts?pO:void 0},u),(0,s.jsx)("div",{id:"end-messages-ref"})]})}),w&&(0,s.jsx)(hD,{apiURL:o||"",resetTranscript:U,userMessage:P,onChangeUserMessage:N,dialogState:m,instruct:C,authToken:p,sendMessage:O,microphoneMode:E,sendOnEnter:I,setSendOnEnter:T,sessionID:r,showUpload:V,attachmentsMenuOpen:M,setAttachmentsMenuOpen:R,onTextareaFocus:()=>{var e,t,n,r;F();const i=aR();i&&L(!0),i&&window.innerWidth<=768&&(null===(t=null===(e=document.getElementById("chat-wrapper"))||void 0===e?void 0:e.classList)||void 0===t||t.add("chat-focused"),null===(r=null===(n=document.querySelector(".memori.memori-widget"))||void 0===n?void 0:n.classList)||void 0===r||r.add("chat-focused"),setTimeout((()=>{ne()}),300))},onTextareaBlur:()=>{var e,t,n,r,i;(null===(t=null===(e=document.getElementById("chat-wrapper"))||void 0===e?void 0:e.classList)||void 0===t?void 0:t.contains("chat-focused"))&&(null===(n=document.getElementById("chat-wrapper"))||void 0===n||n.classList.remove("chat-focused"),null===(i=null===(r=document.querySelector(".memori.memori-widget"))||void 0===r?void 0:r.classList)||void 0===i||i.remove("chat-focused"),ne())},startListening:z,stopListening:F,stopAudio:B,listening:D,isPlayingAudio:k,showMicrophone:A,memoriID:null==e?void 0:e.memoriID})]})}));c=o("85Hg2");var yD=({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,color:"currentColor",children:(0,s.jsx)("path",{fill:"currentColor",d:"M464 720a48 48 0 1096 0 48 48 0 10-96 0zm16-304v184c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V416c0-4.4-3.6-8-8-8h-48c-4.4 0-8 3.6-8 8zm475.7 440l-416-720c-6.2-10.7-16.9-16-27.7-16s-21.6 5.3-27.7 16l-416 720C56 877.4 71.4 904 96 904h832c24.6 0 40-26.6 27.7-48zm-783.5-27.9L512 239.9l339.8 588.2H172.2z"})});var _D=({memoriName:e,blockedUntil:t,notEnoughCredits:n=!1,showGiverInfo:r=!1,showTitle:i=!1,marginLeft:o=!1})=>{const{t:a}=Ie(),l=new Date(t||Date.now());return n||l>new Date(Date.now())?(0,s.jsx)(DN,{className:"blocked-memori-badge--tooltip",content:n?(0,s.jsx)(s.Fragment,{children:a("notEnoughCredits")}):(0,s.jsxs)(s.Fragment,{children:[!r&&a("memoriBlockedAnon",{name:e,date:new Intl.DateTimeFormat("it",{day:"numeric",month:"long",year:"numeric"}).format(l)}),r&&a("memoriBlockedUntil",{date:new Intl.DateTimeFormat("it",{day:"numeric",month:"long",year:"numeric"}).format(l)}),r&&` ${a("memoriBlockedReasonExceedChats")}`,r&&(0,s.jsx)("br",{}),r&&`\n${a("memoriBlockedGiverHelper")}`]}),children:(0,s.jsxs)("div",{className:"blocked-memori-badge--wrapper",children:[(0,s.jsx)("div",{className:"blocked-memori-badge "+(o?" margin-left":""),children:(0,s.jsx)(yD,{className:"blocked-memori-badge--icon"})}),i&&(0,s.jsx)("span",{className:"blocked-memori-badge--title",children:a("memoriBlockedTitle")})]})}):null};var SD=({className:e,title:t})=>(0,s.jsx)("svg",{...t?{}:{"aria-hidden":"true"},focusable:"false",role:"img",xmlns:"http://www.w3.org/2000/svg",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",width:"20",height:"16",viewBox:"0 0 640 512",className:e,"aria-label":t,children:(0,s.jsx)("path",{d:"M211.2 96a64 64 0 10-128 0 64 64 0 10128 0zM32 256c0 17.7 14.3 32 32 32h85.6c10.1-39.4 38.6-71.5 75.8-86.6-9.7-6-21.2-9.4-33.4-9.4H96c-35.3 0-64 28.7-64 64zm461.6 32H576c17.7 0 32-14.3 32-32 0-35.3-28.7-64-64-64h-96c-11.7 0-22.7 3.1-32.1 8.6 38.1 14.8 67.4 47.3 77.7 87.4zm-102.4-61.6c-6.9-1.6-14.2-2.4-21.6-2.4h-96c-8.5 0-16.7 1.1-24.5 3.1-30.8 8.1-55.6 31.1-66.1 60.9-3.5 10-5.5 20.8-5.5 32 0 17.7 14.3 32 32 32h224c17.7 0 32-14.3 32-32 0-11.2-1.9-22-5.5-32-10.8-30.7-36.8-54.2-68.9-61.6zM563.2 96a64 64 0 10-128 0 64 64 0 10128 0zm-241.6 96a80 80 0 100-160 80 80 0 100 160zM32 416c-17.7 0-32 14.3-32 32s14.3 32 32 32h576c17.7 0 32-14.3 32-32s-14.3-32-32-32H32z"})});var bD=({className:e,title:t})=>(0,s.jsxs)("svg",{...t?{}:{"aria-hidden":"true"},focusable:"false",role:"img",xmlns:"http://www.w3.org/2000/svg",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"3",width:"20",height:"20",viewBox:"0 0 48 48",className:e,"aria-label":t,children:[(0,s.jsx)("path",{d:"M30.106 48v-2.745a2.213 2.213 0 012.213-2.212h6.11a2.392 2.392 0 002.326-2.466v-3.223a1.834 1.834 0 01.459-1.145 2.912 2.912 0 00.712-1.926l-.007-.667a1.016 1.016 0 01.651-.952h1.067a1.363 1.363 0 001.051-.456 1.304 1.304 0 00.19-1.395 67.032 67.032 0 01-3.037-7.51 4.767 4.767 0 01-.217-1.507l-.002-4.994a14.513 14.513 0 00-.552-3.963l-.006-.022a13.959 13.959 0 00-3.137-5.702q-.479-.516-1.006-1.003a17.67 17.67 0 00-.677-.623A18.303 18.303 0 0024.194 1a19.617 19.617 0 00-12.539 4.489 17.555 17.555 0 00-3.945 21.69C9.945 31.507 11.694 38.622 12.14 46v2",strokeMiterlimit:10}),(0,s.jsx)("path",{d:"M27.917 12L31.417 12"}),(0,s.jsx)("path",{d:"M27.917 26L31.417 26"}),(0,s.jsx)("path",{d:"M29.667 12L29.667 26"}),(0,s.jsx)("path",{d:"M23.992 26L19.904 12 19.226 12 15.159 26"}),(0,s.jsx)("path",{d:"M16.854 21.133L22.276 21.133"})]});c=o("85Hg2");var xD=({className:e,title:t})=>(0,s.jsx)("svg",{width:"800px",height:"800px",viewBox:"0 0 24 24",fill:"none",...t?{}:{"aria-hidden":"true"},xmlns:"http://www.w3.org/2000/svg",className:e,"aria-label":t,color:"currentColor",children:(0,s.jsx)("path",{d:"M12 16H12.01M12 8V12M12 21C16.9706 21 21 16.9706 21 12C21 7.02944 16.9706 3 12 3C7.02944 3 3 7.02944 3 12C3 16.9706 7.02944 21 12 21Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})});var CD=({className:e,title:t})=>(0,s.jsxs)("svg",{width:"800px",height:"800px",viewBox:"0 0 24 24",fill:"none",...t?{}:{"aria-hidden":"true"},xmlns:"http://www.w3.org/2000/svg",className:e,"aria-label":t,children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"1.5"}),(0,s.jsx)("path",{d:"M12 17V11",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),(0,s.jsx)("circle",{cx:"1",cy:"1",r:"1",transform:"matrix(1 0 0 -1 11 9)",fill:"currentColor"})]});const wD={OpenAI:{statusUrl:"https://status.openai.com/api/v2/summary.json",statusPage:"https://status.openai.com/",apiComponentName:["Chat","Completions (legacy)"]},Mistral:{statusUrl:"https://status.mistral-data.com/api/v2/summary.json",statusPage:"https://status.mistral-data.com/",apiComponentName:["Mistral"]},Anthropic:{statusUrl:"https://status.anthropic.com/api/v2/summary.json",statusPage:"https://status.anthropic.com/",apiComponentName:["api.anthropic.com"]}};var AD=({forceStatus:e,provider:t="Anthropic"})=>{const{t:n}=Ie(),[r,i]=(0,c.useState)(null!=e?e:"operational"),[o,a]=(0,c.useState)(!1),l=wD[t],u=(0,c.useCallback)((async()=>l?(async e=>{try{const t=await fetch(e.statusUrl);if(!t.ok)return console.warn(`Status API returned ${t.status}`),"operational";const n=await t.json();if(n.incidents&&Array.isArray(n.incidents)&&n.incidents.length>0){const e=n.incidents.filter((e=>!["resolved","completed","postmortem"].includes(e.status.toLowerCase())));if(e.length>0){const t=e.some((e=>"critical"===e.impact||"major"===e.impact)),n=e.some((e=>"moderate"===e.impact));return t?"major_outage":n?"partial_outage":"degraded_performance"}}if(n.components){if(e.apiComponentName){const t=Array.isArray(e.apiComponentName)?e.apiComponentName:[e.apiComponentName];for(const e of t){const t=n.components.find((t=>t.name===e));if(t&&"operational"!==t.status)return t.status}}if(n.components.some((e=>"operational"!==e.status)))return"degraded_performance"}if(n.status&&"none"!==n.status.indicator){if("critical"===n.status.indicator)return"major_outage";if("major"===n.status.indicator)return"partial_outage";if("minor"===n.status.indicator)return"degraded_performance"}return"operational"}catch(e){return console.error("Error fetching provider status:",e),"operational"}})(l):"operational"),[l]);if((0,c.useEffect)((()=>{let t=!0;const n=new AbortController;return(async()=>{if(!e){a(!0);try{const e=await u();t&&i(e)}catch(e){console.error("Failed to check status:",e),t&&i("operational")}finally{t&&a(!1)}}})(),()=>{t=!1,n.abort()}}),[e,u]),o)return(0,s.jsx)("div",{className:"memori--completion-provider-status--loading",children:(0,s.jsx)(Tm,{spinning:!0})});if(!r||"operational"===r)return null;const{Icon:d,message:h,className:p}=(()=>{switch(r){case"major_outage":return{Icon:xD,message:n("completionProviderMajorOutage",{provider:null!=t?t:n("completionProviderFallbackName"),fallback:n("completionProviderDown",{provider:null!=t?t:n("completionProviderFallbackName")})}),className:"memori--completion-provider-status--icon-error"};case"partial_outage":return{Icon:yD,message:n("completionProviderPartialOutage",{provider:null!=t?t:n("completionProviderFallbackName"),fallback:n("completionProviderDown",{provider:null!=t?t:n("completionProviderFallbackName")})}),className:"memori--completion-provider-status--icon-warning"};default:return{Icon:CD,message:n("completionProviderDegraded",{provider:null!=t?t:n("completionProviderFallbackName"),fallback:n("completionProviderDown",{provider:null!=t?t:n("completionProviderFallbackName")})}),className:"memori--completion-provider-status--icon-info"}}})();return(0,s.jsx)(DN,{className:"memori--completion-provider-status--tooltip",align:"right",content:(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{children:h}),(null==l?void 0:l.statusPage)&&(0,s.jsx)("p",{children:(0,s.jsx)("a",{href:l.statusPage,rel:"noopener noreferrer",target:"_blank",children:n("completionProviderCheckStatusPage")})})]}),children:(0,s.jsx)(d,{className:`memori--completion-provider-status--icon ${p}`})})};var ED=({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 ID=({memori:e,tenant:t,language:n,userLang:r,setUserLang:i,baseUrl:o,apiUrl:a,position:l,openPositionDrawer:u,instruct:d=!1,hasInitialSession:h=!1,clickedStart:p,onClickStart:m,initializeTTS:f,_TEST_forceProviderStatus:g,isUserLoggedIn:v=!1,user:y,showLogin:_=!1,setShowLoginDrawer:S,notEnoughCredits:b=!1,isMultilanguageEnabled:x})=>{var C,w;const{t:A,i18n:E}=Ie(),[I,T]=(0,c.useState)(e.description),[M,R]=(0,c.useState)(!0);return(0,c.useEffect)((()=>{var t,r,i,s,a,l;(null!==(r=null===(t=E.language)||void 0===t?void 0:t.toUpperCase())&&void 0!==r?r:"IT")===(null!==(i=null==n?void 0:n.toUpperCase())&&void 0!==i?i:"IT")&&I===e.description||!(null===(s=e.description)||void 0===s?void 0:s.length)||OO(e.description,null!==(l=null===(a=E.language)||void 0===a?void 0:a.toUpperCase())&&void 0!==l?l:"IT",n,o).then((e=>{T(e.text)})).catch(console.error)}),[E.language,n,e.description,o]),(0,s.jsxs)("div",{className:"memori--start-panel",children:[(0,s.jsxs)("div",{className:"memori--cover",style:{backgroundImage:`url("${RN({type:"cover",tenantID:null==t?void 0:t.name,resourceURI:e.coverURL,baseURL:o,apiURL:a})}"), url("${RN({type:"cover",tenantID:null==t?void 0:t.name,baseURL:o,apiURL:a})}")`},children:[!!e.enableCompletions&&!e.enableBoardOfExperts&&(0,s.jsx)("div",{className:"memori--completions-enabled",children:(0,s.jsx)(DN,{align:"left",content:A("completionsEnabled"),children:(0,s.jsx)("span",{"aria-label":A("completionsEnabled")||"Completions",children:(0,s.jsx)(NN,{})})})}),!!e.enableBoardOfExperts&&(0,s.jsx)("div",{className:"memori--board-of-experts",children:(0,s.jsx)(DN,{align:"left",content:A("boardOfExperts"),children:(0,s.jsx)("span",{"aria-label":A("boardOfExperts")||"Board of Experts",children:(0,s.jsx)(SD,{})})})}),!!e.nsfw&&(0,s.jsx)("div",{className:"memori--nsfw",children:(0,s.jsx)(DN,{align:"left",content:A("nsfw"),children:(0,s.jsx)("span",{title:A("nsfw")||"NSFW",children:"🔞"})})})]}),(0,s.jsxs)("picture",{className:"memori--avatar",children:[(0,s.jsx)("source",{src:null!==(C=e.avatarURL)&&void 0!==C?C:RN({type:"avatar",tenantID:null==t?void 0:t.name,resourceURI:e.avatarURL,baseURL:o,apiURL:a})}),(0,s.jsx)("img",{alt:e.name,src:e.avatarURL&&e.avatarURL.length>0?RN({type:"avatar",tenantID:null==t?void 0:t.name,resourceURI:e.avatarURL,baseURL:o,apiURL:a}):RN({type:"avatar",tenantID:null==t?void 0:t.name,baseURL:o,apiURL:a})})]}),(0,s.jsx)("h2",{className:"memori--title",children:e.name}),e.needsPosition&&!l&&(0,s.jsxs)("div",{className:"memori--needsPosition",children:[(0,s.jsx)("p",{children:A("write_and_speak.requirePositionHelp",{name:e.name})}),(0,s.jsx)(Mm,{primary:!0,onClick:()=>u(),className:"memori--start-button",icon:(0,s.jsx)(ED,{}),children:A("widget.position")})]}),(e.needsPosition&&l||!e.needsPosition)&&!!e.requireLoginToken&&!v&&(0,s.jsxs)("div",{className:"memori--needsLogin",children:[(0,s.jsx)("p",{children:A("write_and_speak.requirePositionHelp",{name:e.name})}),(0,s.jsx)(Mm,{primary:!0,onClick:()=>S(!0),className:"memori--start-button",icon:(0,s.jsx)(PN,{}),children:A("login.login")||"Login"})]}),(e.needsPosition&&l||!e.needsPosition)&&(!e.requireLoginToken||e.requireLoginToken&&v)&&(0,s.jsxs)("div",{className:"memori--description",children:[(0,s.jsxs)("p",{children:[(0,s.jsx)("span",{className:"memori--description-text",children:I&&M?I:e.description}),I!==e.description&&(0,s.jsx)(Mm,{ghost:!0,className:"memori--translation-toggle",icon:(0,s.jsx)(ON,{}),onClick:()=>{R((e=>!e))},children:A(M?"showOriginalText":"showTranslatedText")})]}),x&&!d&&(0,s.jsxs)("div",{className:"memori--language-chooser",children:[(0,s.jsx)("label",{id:"user-lang-pref-label",htmlFor:"user-lang-pref",children:A("write_and_speak.iWantToTalkToIn",{name:e.name})}),(0,s.jsx)("select",{id:"user-lang-pref",className:"memori-select--button",value:(null!=r?r:E.language).toUpperCase(),"aria-labelledby":"user-lang-pref-label",onChange:e=>{i(e.target.value)},children:lO.map((e=>(0,s.jsx)("option",{value:e.value,"aria-label":e.label,children:e.label},e.value)))})]}),(0,s.jsxs)("div",{className:"memori--start-privacy-explanation-container",children:[(0,s.jsx)("p",{className:"memori--start-privacy-explanation",children:A("write_and_speak.pagePrivacyExplanation")}),(0,s.jsx)(DN,{align:"right",content:(0,s.jsxs)("div",{className:"memori--privacy-tooltip-content",children:[(0,s.jsxs)("p",{children:[" ",A("write_and_speak.pagePrivacyExplanationList.allConversations")]}),(0,s.jsxs)("ul",{className:"memori--privacy-tooltip-content-list",children:[(0,s.jsx)("li",{children:A("write_and_speak.pagePrivacyExplanationList.anonymousUser")}),(0,s.jsx)("li",{children:A("write_and_speak.pagePrivacyExplanationList.registeredUser")})]}),(0,s.jsx)("p",{children:A("write_and_speak.pagePrivacyExplanationList.authorUsesInfo")}),(0,s.jsx)("a",{href:"https://memori.ai/en/privacy-policy",target:"_blank",rel:"noopener noreferrer",children:A("privacyPolicy")})]}),children:(0,s.jsx)(nO,{className:"memori--start-privacy-explanation-icon"})})]}),(0,s.jsx)(Mm,{primary:!0,disabled:!!e.blockedUntil&&!e.isGiver||b,loading:p,onClick:e=>{try{window.speechSynthesis.speak(new SpeechSynthesisUtterance(""))}catch(e){console.error(e)}f&&f(),m&&m()},className:"memori--start-button",children:A("write_and_speak."+(d?"instructButton":h?"resumeButton":"tryMeButton"))}),(0,s.jsx)(AD,{provider:null===(w=null==e?void 0:e.completionConfigForQuestionAnswering)||void 0===w?void 0:w.provider,forceStatus:g}),(0,s.jsx)("p",{className:"memori--start-description",children:A(d?"write_and_speak.pageInstructExplanation":"write_and_speak.pageTryMeExplanation")}),(e.blockedUntil||b)&&(0,s.jsx)(_D,{memoriName:e.name,blockedUntil:e.blockedUntil,notEnoughCredits:b,showGiverInfo:e.isGiver,showTitle:!0,marginLeft:!0}),!!e.enableDeepThought&&!d&&(0,s.jsxs)("div",{className:"memori--deep-thought-disclaimer",children:[(0,s.jsx)(DN,{align:"left",content:A("deepThoughtHelper"),children:(0,s.jsx)(bD,{})}),(0,s.jsx)("h2",{children:v&&(null==y?void 0:y.pAndCUAccepted)?A("deepThoughtDisclaimerTitle"):A("deepThought")}),v&&!(null==y?void 0:y.pAndCUAccepted)&&(0,s.jsx)("p",{children:A("deepThoughtPreDisclaimerNotAllowed")}),!v&&(0,s.jsx)("p",{children:A("deepThoughtPreDisclaimerUnlogged")}),!v&&_&&(0,s.jsx)("p",{children:(0,s.jsx)(Mm,{outlined:!0,padded:!1,onClick:()=>S(!0),children:A("login.login")||"Login"})}),(0,s.jsx)("p",{className:"memori--deep-thought-disclaimer-text",children:A("deepThoughtDisclaimer")})]})]})]})},TD=(c=o("85Hg2"),c=o("85Hg2"),re=o("hcaHr"),{}),MD={};(MD=function(e,t){if(null==e)return{};var n,r,i={},o=Object.keys(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||(i[n]=e[n]);return i}).__esModule=!0,MD.default=MD,(TD=function(e,t){if(null==e)return{};var n,r,i=MD(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}).__esModule=!0,TD.default=TD;c=o("85Hg2");var RD=["forwardedRef"];function PD(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 ND(e){for(var n=1;n<arguments.length;n++){var r=null!=arguments[n]?arguments[n]:{};n%2?PD(Object(r),!0).forEach((function(n){t(ie)(e,n,r[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):PD(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}class OD extends c.Component{constructor(){super(...arguments),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0}}componentDidCatch(e,t){console.error("Uncaught error:",e,t)}render(){return this.state.hasError?this.props.fallback?this.props.fallback:(0,s.jsxs)("div",{style:{background:"rgba(255, 255, 255, 0.4)",color:"#000",padding:"2rem",borderRadius:"10px"},children:[(0,s.jsx)("h2",{children:this.props.t("error.generic")}),(0,s.jsx)(Mm,{primary:!0,onClick:()=>this.setState({hasError:!1}),children:this.props.t("error.tryAgain")||"Try again"})]}):this.props.children}}var DD=function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(r){function i(i){var o=i.forwardedRef,s=t(TD)(i,RD),a=Ie(e,ND(ND({},s),{},{keyPrefix:n.keyPrefix})),l=t(re)(a,3),u=l[0],d=l[1],h=l[2],p=ND(ND({},s),{},{t:u,i18n:d,tReady:h});return n.withRef&&o?p.ref=o:!n.withRef&&o&&(p.forwardedRef=o),(0,c.createElement)(r,p)}i.displayName="withI18nextTranslation(".concat(Ce(r),")"),i.WrappedComponent=r;return n.withRef?(0,c.forwardRef)((function(e,t){return(0,c.createElement)(i,Object.assign({},e,{forwardedRef:t}))})):i}}(["common"])(OD);var LD=({avatar:e,speaking:n=!1})=>(0,s.jsxs)("div",{className:t(Is)("memori-blob",{"memori-blob--speaking":n}),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 kD=({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 BD=({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 zD=({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"})}),FD=(c=o("85Hg2"),c=o("85Hg2"),c=o("85Hg2"),{});Object.defineProperty(FD,"__esModule",{value:!0});c=o("85Hg2");function UD(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 s=r(t);function a(){var n=r(t);if(!o(s,n)){var i=s;e(s=n,i)}}return n.add(a),function(){return n.delete(a)}}(e,r,o):(n.add(e),function(){return n.delete(e)})},destroy:function(){return n.clear()}};return t=e(r,i,o),o}var jD="undefined"==typeof window||!window.navigator||/ServerSideRendering|^Deno\//.test(window.navigator.userAgent)?c.useEffect:c.useLayoutEffect;FD.default=function(e){var t="function"==typeof e?UD(e):e,n=function(e,n){void 0===e&&(e=t.getState),void 0===n&&(n=Object.is);var r,i=c.useReducer((function(e){return e+1}),0)[1],o=t.getState(),s=c.useRef(o),a=c.useRef(e),l=c.useRef(n),u=c.useRef(!1),d=c.useRef();void 0===d.current&&(d.current=e(o));var h=!1;(s.current!==o||a.current!==e||l.current!==n||u.current)&&(r=e(o),h=!n(d.current,r)),jD((function(){h&&(d.current=r),s.current=o,a.current=e,l.current=n,u.current=!1}));var p=c.useRef(o);jD((function(){var e=function(){try{var e=t.getState(),n=a.current(e);l.current(d.current,n)||(s.current=e,d.current=n,i())}catch(e){u.current=!0,i()}},n=t.subscribe(e);return t.getState()!==p.current&&e(),n}),[]);var m=h?r:d.current;return c.useDebugValue(m),m};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 GD;GD=o("YtP34");var HD,VD=o("kMsGZ");HD=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 s=o[i];if(!e(t[s],n[s]))return!1}return!0}return t!=t&&n!=n};const WD=[];function qD(e,n,r,i=0,o=!1){for(const e of n)if(t(HD)(r,e.args)){if(o)return;if(e.error)throw e.error;if(e.response)return e.response;throw e.promise}const s={args:r,promise:e(...r).then((e=>s.response=null==e||e)).catch((e=>s.error=null!=e?e:"unknown error")).then((()=>{i>0&&setTimeout((()=>{const e=n.indexOf(s);-1!==e&&n.splice(e,1)}),i)}))};if(n.push(s),!o)throw s.promise}function JD(e,...n){if(void 0===n||0===n.length)e.splice(0,e.length);else{const r=e.find((e=>t(HD)(n,e.args)));if(r){const t=e.indexOf(r);-1!==t&&e.splice(t,1)}}}function KD(e,...t){return qD(e,WD,t,KD.lifespan)}KD.lifespan=0,KD.clear=(...e)=>JD(WD,...e),KD.preload=(e,...t)=>{qD(e,WD,t,KD.lifespan,!0)},KD.peek=(...e)=>{var n;return null==(n=WD.find((n=>t(HD)(e,n.args))))?void 0:n.response};var YD,XD=function(e){return function(t){e.forEach((function(e){"function"==typeof e?e(t):null!=e&&(e.current=t)}))}};c=o("85Hg2");function QD(e,t,n){var r,i,o,s,a;function l(){var c=Date.now()-s;c<t&&c>=0?r=setTimeout(l,t-c):(r=null,n||(a=e.apply(o,i),o=i=null))}null==t&&(t=100);var c=function(){o=this,i=arguments,s=Date.now();var c=n&&!r;return r||(r=setTimeout(l,t)),c&&(a=e.apply(o,i),o=i=null),a};return c.clear=function(){r&&(clearTimeout(r),r=null)},c.flush=function(){r&&(a=e.apply(o,i),o=i=null,clearTimeout(r),r=null)},c}function $D(e){let{debounce:n,scroll:r,polyfill:i,offsetSize:o}=void 0===e?{debounce:0,scroll:!1,offsetSize:!1}:e;const s=i||("undefined"==typeof window?class{}:window.ResizeObserver);if(!s)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[a,l]=(0,c.useState)({left:0,top:0,width:0,height:0,bottom:0,right:0,x:0,y:0}),u=(0,c.useRef)({element:null,scrollContainers:null,resizeObserver:null,lastBounds:a}),d=n?"number"==typeof n?n:n.scroll:null,h=n?"number"==typeof n?n:n.resize:null,p=(0,c.useRef)(!1);(0,c.useEffect)((()=>(p.current=!0,()=>{p.current=!1})));const[m,f,g]=(0,c.useMemo)((()=>{const e=()=>{if(!u.current.element)return;const{left:e,top:t,width:n,height:r,bottom:i,right:s,x:a,y:c}=u.current.element.getBoundingClientRect(),d={left:e,top:t,width:n,height:r,bottom:i,right:s,x:a,y:c};u.current.element instanceof HTMLElement&&o&&(d.height=u.current.element.offsetHeight,d.width=u.current.element.offsetWidth),Object.freeze(d),p.current&&!tL(u.current.lastBounds,d)&&l(u.current.lastBounds=d)};return[e,h?t(YD)(e,h):e,d?t(YD)(e,d):e]}),[l,o,d,h]);function v(){u.current.scrollContainers&&(u.current.scrollContainers.forEach((e=>e.removeEventListener("scroll",g,!0))),u.current.scrollContainers=null),u.current.resizeObserver&&(u.current.resizeObserver.disconnect(),u.current.resizeObserver=null)}function y(){u.current.element&&(u.current.resizeObserver=new s(g),u.current.resizeObserver.observe(u.current.element),r&&u.current.scrollContainers&&u.current.scrollContainers.forEach((e=>e.addEventListener("scroll",g,{capture:!0,passive:!0}))))}var _,S,b;return _=g,S=Boolean(r),(0,c.useEffect)((()=>{if(S){const e=_;return window.addEventListener("scroll",e,{capture:!0,passive:!0}),()=>{window.removeEventListener("scroll",e,!0)}}}),[_,S]),b=f,(0,c.useEffect)((()=>{const e=b;return window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}}),[b]),(0,c.useEffect)((()=>{v(),y()}),[r,g,f]),(0,c.useEffect)((()=>v),[]),[e=>{e&&e!==u.current.element&&(v(),u.current.element=e,u.current.scrollContainers=ZD(e),y())},a,m]}function ZD(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,...ZD(e.parentElement)]}QD.debounce=QD,YD=QD;const eL=["x","y","top","bottom","left","right","width","height"],tL=(e,t)=>eL.every((n=>e[n]===t[n]));const nL={obj:e=>e===Object(e)&&!nL.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(nL.str(e)||nL.num(e)||nL.obj(e))return e===t;if(nL.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!nL.und(n)||e===t}};function rL(e){return(e.eventObject||e.object).uuid+"/"+e.index+e.instanceId}function iL(e,t,n,r){const i=n.get(t);i&&(n.delete(t),0===n.size&&(e.delete(r),i.target.releasePointerCapture(r)))}function oL(e){const t=new af.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(rL(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 s=>{const{onPointerMissed:a,internal:l}=e.getState();!function(t){var n;const r=e.getState(),{raycaster:i,mouse:o,camera:s,size:a}=r,{offsetX:l,offsetY:c}=null!=(n=null==i.computeOffsets?void 0:i.computeOffsets(t,r))?n:t,{width:u,height:d}=a;o.set(l/u*2-1,-c/d*2+1),i.setFromCamera(o,s)}(s),l.lastEvent.current=s;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,s=[],a=t?t(i.interaction):i.interaction;let l=r.intersectObjects(a,!0).filter((e=>{const t=rL(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&&s.push({...e,eventObject:t}),t=t.parent}}return s}(c?n:void 0),s),h=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))}(s):0;"onPointerDown"===o&&(l.initialClick=[s.offsetX,s.offsetY],l.initialHits=d.map((e=>e.eventObject))),u&&!d.length&&h<=2&&(i(s,l.interaction),a&&a(s)),c&&r(d),function(n,i,o,s){const{raycaster:a,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 h=e=>{var n,r;return null!=(n=null==(r=u.capturedMap.get(e))?void 0:r.has(t.eventObject))&&n},p=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)},m=e=>{const n=u.capturedMap.get(e);n&&iL(u.capturedMap,t.eventObject,n,e)};let f={};for(let e in i){let t=i[e];"function"!=typeof t&&(f[e]=t)}let g={...t,...f,spaceX:l.x,spaceY:l.y,intersections:n,stopped:d.stopped,delta:o,unprojectedPoint:e,ray:a.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:h,setPointerCapture:p,releasePointerCapture:m},currentTarget:{hasPointerCapture:h,setPointerCapture:p,releasePointerCapture:m},sourceEvent:i,nativeEvent:i};if(s(g),!0===d.stopped)break}}}(d,s,h,(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=rL(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(s,l.interaction.filter((e=>!l.initialHits.includes(e)))),n(e)):u&&l.initialHits.includes(t)&&i(s,l.interaction.filter((e=>!l.initialHits.includes(e))))}}))}}}}const sL=e=>e&&!!e.getState,aL=(e,t)=>{var n,r;return{root:sL(e)?e:null!=(n=null==(r=e.__r3f)?void 0:r.root)?n:t.__r3f.root,container:sL(e)?e.getState().scene:e}},lL="__default",cL={};let uL={};function dL(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 hL=e=>e&&e.isOrthographicCamera;function pL(e){return Array.isArray(e)?Math.min(Math.max(e[0],window.devicePixelRatio),e[1]):e}const mL=c.createContext(null);let fL,gL=[],vL=[],yL=[];function _L(e,t){for(fL=0;fL<e.length;fL++)e[fL](t)}function SL(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),fL=0;fL<t.internal.subscribers.length;fL++)t.internal.subscribers[fL].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 bL(e){const{handlePointer:t}=oL(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 xL="undefined"!=typeof window?c.useLayoutEffect:c.useEffect;function CL({set:e}){return xL((()=>(e(new Promise((()=>null))),()=>e(!1))),[]),null}class wL extends c.Component{constructor(...e){super(...e),this.state={error:!1}}componentDidCatch(e){this.props.set(e)}render(){return this.state.error?null:this.props.children}}wL.getDerivedStateFromError=()=>({error:!0});const AL=c.forwardRef((function({children:e,fallback:n,tabIndex:r,resize:i,id:o,style:s,className:a,events:l,...u},d){const[h,{width:p,height:m}]=$D({scroll:!0,debounce:{scroll:50,resize:0},...i}),f=c.useRef(null),[g,v]=c.useState(!1),[y,_]=c.useState(!1);if(g)throw g;if(y)throw y;return xL((()=>{p>0&&m>0&&function(e,n,{gl:r,size:i,mode:o=OL[1],events:s,onCreated:a,...l}={}){var u,d,h,p,m;i||(i={width:null!=(d=null==(h=n.parentElement)?void 0:h.clientWidth)?d:0,height:null!=(p=null==(m=n.parentElement)?void 0:m.clientHeight)?p:0});let f=NL.get(n),g=null==f?void 0:f.fiber,v=null==f?void 0:f.store,y=null==(u=v)?void 0:u.getState();if(g&&y){void 0===l.dpr||nL.equ(y.viewport.dpr,pL(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&&(FL(n),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 af.WebGLRenderer({powerPreference:"high-performance",canvas:t,antialias:!0,alpha:!0,...e});i.outputEncoding=af.sRGBEncoding,i.toneMapping=af.ACESFilmicToneMapping,e&&BL(i,e);return i})(r,n);l.vr&&(e.xr.enabled=!0,e.setAnimationLoop((e=>LL(e,!0)))),v=((e,n,r,i)=>{const{gl:o,size:s,shadows:a=!1,linear:l=!1,flat:u=!1,vr:d=!1,orthographic:h=!1,frameloop:p="always",dpr:m=1,performance:f,clock:g=new af.Clock,raycaster:v,camera:y,onPointerMissed:_}=i;a&&(o.shadowMap.enabled=!0,"object"==typeof a?Object.assign(o.shadowMap,a):o.shadowMap.type=af.PCFSoftShadowMap),l&&(o.outputEncoding=af.LinearEncoding),u&&(o.toneMapping=af.NoToneMapping),"never"===p&&(g.stop(),g.elapsedTime=0);const S=t(FD)(((t,s)=>{const a=new af.Raycaster,{params:S,...b}=v||{};e(a,{enabled:!0,...b,params:{...a.params,...S}});const x=y instanceof af.Camera,C=x?y:h?new af.OrthographicCamera(0,0,0,0,.1,1e3):new af.PerspectiveCamera(75,0,.1,1e3);x||(C.position.z=5,y&&e(C,y),null!=y&&y.rotation||C.lookAt(0,0,0));const w=pL(m),A=new af.Vector3,E=new af.Vector3,I=new af.Vector3;function T(e=s().camera,t=E,n=s().size){const{width:r,height:i}=n,o=r/i;t instanceof af.Vector3?I.copy(t):I.set(...t);const a=e.getWorldPosition(A).distanceTo(I);if(hL(e))return{width:r/e.zoom,height:i/e.zoom,factor:1,distance:a,aspect:o};{const t=e.fov*Math.PI/180,n=2*Math.tan(t/2)*a,s=n*(r/i);return{width:s,height:n,factor:r/s,distance:a,aspect:o}}}let M;const R=e=>t((t=>({performance:{...t.performance,current:e}})));return{gl:o,set:t,get:s,invalidate:()=>n(s()),advance:(e,t)=>r(e,t,s()),linear:l,flat:u,scene:dL(new af.Scene),camera:C,controls:null,raycaster:a,clock:g,mouse:new af.Vector2,vr:d,frameloop:p,onPointerMissed:_,performance:{current:1,min:.5,max:1,debounce:200,...f,regress:()=>{const e=s();M&&clearTimeout(M),e.performance.current!==e.performance.min&&R(e.performance.min),M=setTimeout((()=>R(s().performance.max)),e.performance.debounce)}},size:{width:0,height:0},viewport:{initialDpr:w,dpr:w,width:0,height:0,aspect:0,distance:0,factor:0,getCurrentViewport:T},setSize:(e,n)=>{const r={width:e,height:n};t((e=>({size:r,viewport:{...e.viewport,...T(C,E,r)}})))},setDpr:e=>t((t=>({viewport:{...t.viewport,dpr:pL(e)}}))),setFrameloop:(e="always")=>t((()=>({frameloop:e}))),events:{connected:!1},internal:{active:!1,priority:0,frames:0,lastProps:i,lastEvent:c.createRef(),interaction:[],hovered:new Map,subscribers:[],initialClick:[0,0],initialHits:[],capturedMap:new Map,subscribe:(e,n=0)=>(t((({internal:t})=>({internal:{...t,priority:t.priority+(n>0?1:0),subscribers:[...t.subscribers,{ref:e,priority:n}].sort(((e,t)=>e.priority-t.priority))}}))),()=>{t((({internal:t})=>({internal:{...t,priority:t.priority-(n>0?1:0),subscribers:t.subscribers.filter((t=>t.ref!==e))}})))})}}})),b=S.getState();let x=b.size,C=b.viewport.dpr;return S.subscribe((()=>{const{camera:e,size:t,viewport:n,internal:r}=S.getState();t===x&&n.dpr===C||(e.manual||r.lastProps.camera instanceof af.Camera||(hL(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),x=t,C=n.dpr)})),s&&b.setSize(s.width,s.height),S.subscribe((e=>n(e))),S})(BL,DL,LL,{gl:e,size:i,...l});const a=v.getState();g=kL.createContainer(v,OL.indexOf(o),!1,null),NL.set(n,{fiber:g,store:v}),s&&a.set({events:s(v)})}if(v&&g)return kL.updateContainer(c.createElement(zL,{store:v,element:e,onCreated:a,target:n}),g,null,(()=>{})),v;throw"Error creating root!"}(c.createElement(wL,{set:_},c.createElement(c.Suspense,{fallback:c.createElement(CL,{set:v})},e)),f.current,{...u,size:{width:p,height:m},events:l||bL})}),[p,m,e]),xL((()=>{const e=f.current;return()=>FL(e)}),[]),c.createElement("div",{ref:h,id:o,className:a,tabIndex:r,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden",...s}},c.createElement("canvas",{ref:XD([f,d]),style:{display:"block"}},n))}));function EL(){const e=c.useContext(mL);if(!e)throw"R3F hooks can only be used within the Canvas component!";return e}function IL(e=(e=>e),t){return EL()(e,t)}function TL(e,t=0){const n=EL().getState().internal.subscribe,r=c.useRef(e);return c.useLayoutEffect((()=>{r.current=e}),[e]),c.useLayoutEffect((()=>n(r,t)),[t,n]),null}function ML(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 RL(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,ML(e.scene)),n(e)}),t,(t=>r(`Could not load ${e}: ${t.message}`))))))))}}function PL(e,t,n,r){const i=Array.isArray(t)?t:[t],o=KD(RL(n,r),e,...i);return Array.isArray(t)?o:o[0]}PL.preload=function(e,t,n){const r=Array.isArray(t)?t:[t];return KD.preload(RL(n),e,...r)},PL.clear=function(e,t){const n=Array.isArray(t)?t:[t];return KD.clear(e,...n)};const NL=new Map,OL=["legacy","blocking","concurrent"],{invalidate:DL,advance:LL}=function(e){let t,n=!1;function r(i){if(n=!0,t=0,_L(gL,i),e.forEach((e=>{const n=e.store.getState();n.internal.active&&("always"===n.frameloop||n.internal.frames>0)&&(t+=SL(i,n))})),_L(vL,i),t>0)return requestAnimationFrame(r);_L(yL,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&&_L(gL,t),r?SL(t,r):e.forEach((e=>SL(t,e.store.getState()))),n&&_L(vL,t)}}}(NL),{reconciler:kL,applyProps:BL}=function(e){function n(e,{children:t,key:n,ref:r,...i},{children:o,key:s,ref:a,...l}={},c=!1){var u;const d=null!=(u=null==e?void 0:e.__r3f)?u:{},h=Object.entries(i),p=[];if(c){const e=Object.keys(l);for(let t=0;t<e.length;t++)i.hasOwnProperty(e[t])||h.unshift([e[t],lL+"remove"])}h.forEach((([t,n])=>{var r;if(null!=(r=e.__r3f)&&r.primitive&&"object"===t)return;if(function(e,t){return!(!nL.arr(e)||!nL.equ(e,t))||e===t}(n,l[t]))return;if(/^on(Pointer|Click|DoubleClick|ContextMenu|Wheel)/.test(t))return p.push([t,n,!0,[]]);let i=[];t.includes("-")&&(i=t.split("-")),p.push([t,n,!1,i])}));const m={...i};return d.memoizedProps&&d.memoizedProps.args&&(m.args=d.memoizedProps.args),d.memoizedProps&&d.memoizedProps.attach&&(m.attach=d.memoizedProps.attach),{accumulative:c,memoized:m,changes:p}}function r(e,t){var r,s,a;const l=null!=(r=null==e?void 0:e.__r3f)?r:{},c=l.root,u=null!=(s=null==c||null==c.getState?void 0:c.getState())?s:{},{memoized:d,changes:h}=(p=t)&&p.memoized&&p.changes?t:n(e,t);var p;const m=l.eventCount;if(e.__r3f&&(e.__r3f.memoizedProps=d),h.forEach((([t,n,r,o])=>{var s;let a=e,c=a[t];if(o.length&&(c=o.reduce(((e,t)=>e[t]),e),!c||!c.set)){const[n,...r]=o.reverse();a=r.reverse().reduce(((e,t)=>e[t]),e),t=n}if(n===lL+"remove")if(c&&c.constructor)n=new c.constructor(d.args);else if(a.constructor){const e=new a.constructor(a.__r3f.memoizedProps.args);n=e[c],e.dispose&&e.dispose()}else n=0;const h=(null==u||null==(s=u.gl)?void 0:s.outputEncoding)===af.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 af.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 af.Color;!e&&c.setScalar?c.setScalar(n):c instanceof af.Layers&&n instanceof af.Layers?c.mask=n.mask:c.set(n),!h&&e&&c.convertSRGBToLinear()}}else a[t]=n,!h&&a[t]instanceof af.Texture&&(a[t].encoding=af.sRGBEncoding);i(e)})),l.parent&&u.internal&&e.raycast&&m!==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 h.length&&null!=(a=e.__r3f)&&a.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 s(e,{args:t=[],...n},i,o,s){let a,l=`${e[0].toUpperCase()}${e.slice(1)}`;if(!sL(i)&&s){const e=t=>t.return?e(t.return):t.stateNode&&t.stateNode.containerInfo;i=e(s)}if(!i||!sL(i))throw`No valid root for ${l}!`;if("primitive"===e){if(void 0===n.object)throw"Primitives without 'object' are invalid!";a=dL(n.object,{root:i,primitive:!0})}else{const e=uL[l]||af[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!";a=dL(new e(...t),{root:i,memoizedProps:{args:0===t.length?null:t}})}return"attachFns"in n||(l.endsWith("Geometry")?n={attach:"geometry",...n}:l.endsWith("Material")&&(n={attach:"material",...n})),r(a,n),a}function a(e,t){let n=!1;if(t){if(t.attachArray)nL.arr(e[t.attachArray])||(e[t.attachArray]=[]),e[t.attachArray].push(t);else if(t.attachObject)nL.obj(e[t.attachObject[0]])||(e[t.attachObject[0]]={}),e[t.attachObject[0]][t.attachObject[1]]=t;else if(t.attach&&!nL.fun(t.attach))e[t.attach]=t;else if(nL.arr(t.attachFns)){const[n]=t.attachFns;nL.str(n)&&nL.fun(e[n])?e[n](t):nL.fun(n)&&n(t,e)}else t.isObject3D&&e.isObject3D&&(e.add(t),n=!0);n||e.__r3f.objects.push(t),t.__r3f||dL(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];nL.arr(r)||(e[t.attachArray]=[]),r.splice(r.indexOf(n),0,t)}else{if(t.attachObject||t.attach&&!nL.fun(t.attach))return a(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||dL(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&&!nL.fun(t.attach)&&e[t.attach]===t)e[t.attach]=null;else if(nL.arr(t.attachFns)){const[,n]=t.attachFns;nL.str(n)&&nL.fun(e[n])?e[n](t):nL.fun(n)&&n(t,e)}else if(t.isObject3D&&e.isObject3D){var s;e.remove(t),null!=(s=t.__r3f)&&s.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)=>{iL(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 a;if(!l)c(null==(a=t.__r3f)?void 0:a.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,VD.unstable_runWithPriority)(VD.unstable_IdlePriority,(()=>{try{t.dispose()}catch(e){}})),i(e)}}return{reconciler:t(GD)({now:VD.unstable_now,createInstance:s,removeChild:u,appendChild:a,appendInitialChild:a,insertBefore:l,warnsIfNotActing:!0,supportsMutation:!0,isPrimaryRenderer:!1,scheduleTimeout:nL.fun(setTimeout)?setTimeout:void 0,cancelTimeout:nL.fun(clearTimeout)?clearTimeout:void 0,setTimeout:nL.fun(setTimeout)?setTimeout:void 0,clearTimeout:nL.fun(clearTimeout)?clearTimeout:void 0,noTimeout:-1,appendChildToContainer:(e,t)=>{const{container:n,root:r}=aL(e,t);n.__r3f.root=r,a(n,t)},removeChildFromContainer:(e,t)=>u(aL(e,t).container,t),insertInContainerBefore:(e,t,n)=>l(aL(e,t).container,t,n),prepareUpdate(e,t,r,i){if(e.__r3f.primitive&&i.object&&i.object!==e)return[!0];{const{args:t=[],children:o,...s}=i,{args:l=[],children:c,...u}=r;if(!Array.isArray(t))throw"The args prop must be an array!";if(t.some(((e,t)=>e!==l[t])))return[!0];const d=n(e,s,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&&a(t,e)}return null}},commitUpdate(e,[t,n],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=s(t,n,e.__r3f.root);"primitive"!==t&&e.children&&(e.children.forEach((e=>a(l,e))),e.children=[]),e.__r3f.objects.forEach((e=>a(l,e))),e.__r3f.objects=[],u(o,e),a(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):r(e,n)},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=>cL,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){dL(e)},resetAfterCommit(){},shouldSetTextContent:()=>!1,clearContainer:()=>!1}),applyProps:r}}();function zL({store:e,element:t,onCreated:n,target:r}){return c.useEffect((()=>{const t=e.getState();t.set((e=>({internal:{...e.internal,active:!0}}))),null==t.events.connect||t.events.connect(r),n&&n(t)}),[]),c.createElement(mL.Provider,{value:e},t)}function FL(e,t){const n=NL.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),kL.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(),function(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]}}(i),NL.delete(e),t&&t(e)}),500)}))}}kL.act;function UL(){return UL=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},UL.apply(this,arguments)}kL.injectIntoDevTools({bundleType:0,rendererPackageName:"@react-three/fiber",version:"17.0.2"});c=o("85Hg2");function jL(e){return jL="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},jL(e)}function GL(e,t){if("object"!==jL(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!==jL(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function HL(e){var t=GL(e,"string");return"symbol"===jL(t)?t:String(t)}function VL(e,t,n){return(t=HL(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const WL=(e,t)=>(e%t+t)%t;class qL extends yy{constructor(e,t){super(),VL(this,"object",void 0),VL(this,"domElement",void 0),VL(this,"enabled",!0),VL(this,"target",new u_),VL(this,"minDistance",0),VL(this,"maxDistance",1/0),VL(this,"minZoom",0),VL(this,"maxZoom",1/0),VL(this,"minPolarAngle",0),VL(this,"maxPolarAngle",Math.PI),VL(this,"minAzimuthAngle",-1/0),VL(this,"maxAzimuthAngle",1/0),VL(this,"enableDamping",!1),VL(this,"dampingFactor",.05),VL(this,"enableZoom",!0),VL(this,"zoomSpeed",1),VL(this,"enableRotate",!0),VL(this,"rotateSpeed",1),VL(this,"enablePan",!0),VL(this,"panSpeed",1),VL(this,"screenSpacePanning",!0),VL(this,"keyPanSpeed",7),VL(this,"autoRotate",!1),VL(this,"autoRotateSpeed",2),VL(this,"reverseOrbit",!1),VL(this,"keys",{LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"}),VL(this,"mouseButtons",{LEFT:cf.ROTATE,MIDDLE:cf.DOLLY,RIGHT:cf.PAN}),VL(this,"touches",{ONE:uf.ROTATE,TWO:uf.DOLLY_PAN}),VL(this,"target0",void 0),VL(this,"position0",void 0),VL(this,"zoom0",void 0),VL(this,"_domElementKeyEvents",null),VL(this,"getPolarAngle",void 0),VL(this,"getAzimuthalAngle",void 0),VL(this,"setPolarAngle",void 0),VL(this,"setAzimuthalAngle",void 0),VL(this,"getDistance",void 0),VL(this,"listenToKeyEvents",void 0),VL(this,"saveState",void 0),VL(this,"reset",void 0),VL(this,"update",void 0),VL(this,"connect",void 0),VL(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 _b?this.object.zoom:1,this.getPolarAngle=()=>c.phi,this.getAzimuthalAngle=()=>c.theta,this.setPolarAngle=e=>{let t=WL(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=WL(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 _b?n.object.zoom:1},this.reset=()=>{n.target.copy(n.target0),n.object.position.copy(n.position0),n.object instanceof _b&&(n.object.zoom=n.zoom0,n.object.updateProjectionMatrix()),n.dispatchEvent(r),n.update(),a=s.NONE},this.update=(()=>{const t=new u_,i=(new c_).setFromUnitVectors(e.up,new u_(0,1,0)),o=i.clone().invert(),m=new u_,f=new c_,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&&a===s.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(h,n.dampingFactor):n.target.add(h),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,h.multiplyScalar(1-n.dampingFactor)):(u.set(0,0,0),h.set(0,0,0)),d=1,!!(p||m.distanceToSquared(n.object.position)>l||8*(1-f.dot(n.object.quaternion))>l)&&(n.dispatchEvent(r),m.copy(n.object.position),f.copy(n.object.quaternion),p=!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",J),n.domElement.addEventListener("pointerdown",j),n.domElement.addEventListener("pointercancel",V),n.domElement.addEventListener("wheel",W)},this.dispose=()=>{var e,t,r,i,o,s;null===(e=n.domElement)||void 0===e||e.removeEventListener("contextmenu",J),null===(t=n.domElement)||void 0===t||t.removeEventListener("pointerdown",j),null===(r=n.domElement)||void 0===r||r.removeEventListener("pointercancel",V),null===(i=n.domElement)||void 0===i||i.removeEventListener("wheel",W),null===(o=n.domElement)||void 0===o||o.ownerDocument.removeEventListener("pointermove",G),null===(s=n.domElement)||void 0===s||s.ownerDocument.removeEventListener("pointerup",H),null!==n._domElementKeyEvents&&n._domElementKeyEvents.removeEventListener("keydown",q)};const n=this,r={type:"change"},i={type:"start"},o={type:"end"},s={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let a=s.NONE;const l=1e-6,c=new XT,u=new XT;let d=1;const h=new u_;let p=!1;const m=new Oy,f=new Oy,g=new Oy,v=new Oy,y=new Oy,_=new Oy,S=new Oy,b=new Oy,x=new Oy,C=[],w={};function A(){return Math.pow(.95,n.zoomSpeed)}function E(e){n.reverseOrbit?u.theta+=e:u.theta-=e}function I(e){n.reverseOrbit?u.phi+=e:u.phi-=e}const T=(()=>{const e=new u_;return function(t,n){e.setFromMatrixColumn(n,0),e.multiplyScalar(-t),h.add(e)}})(),M=(()=>{const e=new u_;return function(t,r){!0===n.screenSpacePanning?e.setFromMatrixColumn(r,1):(e.setFromMatrixColumn(r,0),e.crossVectors(n.object.up,e)),e.multiplyScalar(t),h.add(e)}})(),R=(()=>{const e=new u_;return function(t,r){const i=n.domElement;if(i&&n.object instanceof _b&&n.object.isPerspectiveCamera){const o=n.object.position;e.copy(o).sub(n.target);let s=e.length();s*=Math.tan(n.object.fov/2*Math.PI/180),T(2*t*s/i.clientHeight,n.object.matrix),M(2*r*s/i.clientHeight,n.object.matrix)}else i&&n.object instanceof Hb&&n.object.isOrthographicCamera?(T(t*(n.object.right-n.object.left)/n.object.zoom/i.clientWidth,n.object.matrix),M(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 P(e){n.object instanceof _b&&n.object.isPerspectiveCamera?d/=e:n.object instanceof Hb&&n.object.isOrthographicCamera?(n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom*e)),n.object.updateProjectionMatrix(),p=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function N(e){n.object instanceof _b&&n.object.isPerspectiveCamera?d*=e:n.object instanceof Hb&&n.object.isOrthographicCamera?(n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/e)),n.object.updateProjectionMatrix(),p=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function O(e){m.set(e.clientX,e.clientY)}function D(e){v.set(e.clientX,e.clientY)}function L(){if(1==C.length)m.set(C[0].pageX,C[0].pageY);else{const e=.5*(C[0].pageX+C[1].pageX),t=.5*(C[0].pageY+C[1].pageY);m.set(e,t)}}function k(){if(1==C.length)v.set(C[0].pageX,C[0].pageY);else{const e=.5*(C[0].pageX+C[1].pageX),t=.5*(C[0].pageY+C[1].pageY);v.set(e,t)}}function B(){const e=C[0].pageX-C[1].pageX,t=C[0].pageY-C[1].pageY,n=Math.sqrt(e*e+t*t);S.set(0,n)}function z(e){if(1==C.length)f.set(e.pageX,e.pageY);else{const t=X(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);f.set(n,r)}g.subVectors(f,m).multiplyScalar(n.rotateSpeed);const t=n.domElement;t&&(E(2*Math.PI*g.x/t.clientHeight),I(2*Math.PI*g.y/t.clientHeight)),m.copy(f)}function F(e){if(1==C.length)y.set(e.pageX,e.pageY);else{const t=X(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);y.set(n,r)}_.subVectors(y,v).multiplyScalar(n.panSpeed),R(_.x,_.y),v.copy(y)}function U(e){const t=X(e),r=e.pageX-t.x,i=e.pageY-t.y,o=Math.sqrt(r*r+i*i);b.set(0,o),x.set(0,Math.pow(b.y/S.y,n.zoomSpeed)),P(x.y),S.copy(b)}function j(e){if(!1!==n.enabled){var t,r;if(0===C.length)null===(t=n.domElement)||void 0===t||t.ownerDocument.addEventListener("pointermove",G),null===(r=n.domElement)||void 0===r||r.ownerDocument.addEventListener("pointerup",H);!function(e){C.push(e)}(e),"touch"===e.pointerType?function(e){switch(Y(e),C.length){case 1:switch(n.touches.ONE){case uf.ROTATE:if(!1===n.enableRotate)return;L(),a=s.TOUCH_ROTATE;break;case uf.PAN:if(!1===n.enablePan)return;k(),a=s.TOUCH_PAN;break;default:a=s.NONE}break;case 2:switch(n.touches.TWO){case uf.DOLLY_PAN:if(!1===n.enableZoom&&!1===n.enablePan)return;n.enableZoom&&B(),n.enablePan&&k(),a=s.TOUCH_DOLLY_PAN;break;case uf.DOLLY_ROTATE:if(!1===n.enableZoom&&!1===n.enableRotate)return;n.enableZoom&&B(),n.enableRotate&&L(),a=s.TOUCH_DOLLY_ROTATE;break;default:a=s.NONE}break;default:a=s.NONE}a!==s.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 cf.DOLLY:if(!1===n.enableZoom)return;!function(e){S.set(e.clientX,e.clientY)}(e),a=s.DOLLY;break;case cf.ROTATE:if(e.ctrlKey||e.metaKey||e.shiftKey){if(!1===n.enablePan)return;D(e),a=s.PAN}else{if(!1===n.enableRotate)return;O(e),a=s.ROTATE}break;case cf.PAN:if(e.ctrlKey||e.metaKey||e.shiftKey){if(!1===n.enableRotate)return;O(e),a=s.ROTATE}else{if(!1===n.enablePan)return;D(e),a=s.PAN}break;default:a=s.NONE}a!==s.NONE&&n.dispatchEvent(i)}(e)}}function G(e){!1!==n.enabled&&("touch"===e.pointerType?function(e){switch(Y(e),a){case s.TOUCH_ROTATE:if(!1===n.enableRotate)return;z(e),n.update();break;case s.TOUCH_PAN:if(!1===n.enablePan)return;F(e),n.update();break;case s.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 s.TOUCH_DOLLY_ROTATE:if(!1===n.enableZoom&&!1===n.enableRotate)return;!function(e){n.enableZoom&&U(e),n.enableRotate&&z(e)}(e),n.update();break;default:a=s.NONE}}(e):function(e){if(!1===n.enabled)return;switch(a){case s.ROTATE:if(!1===n.enableRotate)return;!function(e){f.set(e.clientX,e.clientY),g.subVectors(f,m).multiplyScalar(n.rotateSpeed);const t=n.domElement;t&&(E(2*Math.PI*g.x/t.clientHeight),I(2*Math.PI*g.y/t.clientHeight)),m.copy(f),n.update()}(e);break;case s.DOLLY:if(!1===n.enableZoom)return;!function(e){b.set(e.clientX,e.clientY),x.subVectors(b,S),x.y>0?P(A()):x.y<0&&N(A()),S.copy(b),n.update()}(e);break;case s.PAN:if(!1===n.enablePan)return;!function(e){y.set(e.clientX,e.clientY),_.subVectors(y,v).multiplyScalar(n.panSpeed),R(_.x,_.y),v.copy(y),n.update()}(e)}}(e))}function H(e){var t,r,i;(K(e),0===C.length)&&(null===(t=n.domElement)||void 0===t||t.releasePointerCapture(e.pointerId),null===(r=n.domElement)||void 0===r||r.ownerDocument.removeEventListener("pointermove",G),null===(i=n.domElement)||void 0===i||i.ownerDocument.removeEventListener("pointerup",H));n.dispatchEvent(o),a=s.NONE}function V(e){K(e)}function W(e){!1===n.enabled||!1===n.enableZoom||a!==s.NONE&&a!==s.ROTATE||(e.preventDefault(),n.dispatchEvent(i),function(e){e.deltaY<0?N(A()):e.deltaY>0&&P(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:R(0,n.keyPanSpeed),t=!0;break;case n.keys.BOTTOM:R(0,-n.keyPanSpeed),t=!0;break;case n.keys.LEFT:R(n.keyPanSpeed,0),t=!0;break;case n.keys.RIGHT:R(-n.keyPanSpeed,0),t=!0}t&&(e.preventDefault(),n.update())}(e)}function J(e){!1!==n.enabled&&e.preventDefault()}function K(e){delete w[e.pointerId];for(let t=0;t<C.length;t++)if(C[t].pointerId==e.pointerId)return void C.splice(t,1)}function Y(e){let t=w[e.pointerId];void 0===t&&(t=new Oy,w[e.pointerId]=t),t.set(e.pageX,e.pageY)}function X(e){const t=e.pointerId===C[0].pointerId?C[1]:C[0];return w[t.pointerId]}void 0!==t&&this.connect(t),this.update()}}const JL=c.forwardRef((({makeDefault:e,camera:t,regress:n,domElement:r,enableDamping:i=!0,onChange:o,onStart:s,onEnd:a,...l},u)=>{const d=IL((e=>e.invalidate)),h=IL((e=>e.camera)),p=IL((e=>e.gl)),m=IL((e=>e.events)),f=IL((e=>e.set)),g=IL((e=>e.get)),v=IL((e=>e.performance)),y=t||h,_=r||m.connected||p.domElement,S=c.useMemo((()=>new qL(y)),[y]);return TL((()=>{S.enabled&&S.update()})),c.useEffect((()=>(S.connect(_),()=>{S.dispose()})),[_,n,S,d]),c.useEffect((()=>{const e=e=>{d(),n&&v.regress(),o&&o(e)};return S.addEventListener("change",e),s&&S.addEventListener("start",s),a&&S.addEventListener("end",a),()=>{s&&S.removeEventListener("start",s),a&&S.removeEventListener("end",a),S.removeEventListener("change",e)}}),[o,s,a]),c.useEffect((()=>{if(e){const e=g().controls;return f({controls:S}),()=>f({controls:e})}}),[e,S]),c.createElement("primitive",UL({ref:u,object:S,enableDamping:i},l))}));const KL=(c=o("85Hg2")).forwardRef((({makeDefault:e,...t},n)=>{const r=IL((({set:e})=>e)),i=IL((({camera:e})=>e)),o=IL((({size:e})=>e)),s=c.useRef();return c.useLayoutEffect((()=>{const{current:e}=s;e&&!t.manual&&(e.aspect=o.width/o.height,e.updateProjectionMatrix())}),[o,t]),c.useLayoutEffect((()=>{if(e&&s.current){const e=i;return r((()=>({camera:s.current}))),()=>r((()=>({camera:e})))}}),[i,s,e,r]),c.createElement("perspectiveCamera",UL({ref:XD([s,n])},t))}));c=o("85Hg2"),c=o("85Hg2");const YL=new WeakMap;class XL extends CI{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 EI(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(YL.has(e)){const t=YL.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,s=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 s.catch((()=>!0)).then((()=>{r&&i&&this._releaseTask(r,i)})),YL.set(e,{key:n,promise:s}),s}_createGeometry(e){const t=new JS;e.index&&t.setIndex(new MS(e.index.array,1));for(let n=0;n<e.attributes.length;n++){const r=e.attributes[n],i=r.name,o=r.array,s=r.itemSize;t.setAttribute(i,new MS(o,s))}return t}_loadLibrary(e,t){const n=new EI(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=QL.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 QL(){let e,t;function n(e,t,n,r,i,o){const s=o.num_components(),a=n.num_points()*s,l=a*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,a).slice();return e._free(u),{name:r,array:d,itemSize:s}}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,s=new t.Decoder,a=new t.DecoderBuffer;a.Init(new Int8Array(r),r.byteLength);try{const e=function(e,t,r,i){const o=i.attributeIDs,s=i.attributeTypes;let a,l;const c=t.GetEncodedGeometryType(r);if(c===e.TRIANGULAR_MESH)a=new e.Mesh,l=t.DecodeBufferToMesh(r,a);else{if(c!==e.POINT_CLOUD)throw new Error("THREE.DRACOLoader: Unexpected geometry type.");a=new e.PointCloud,l=t.DecodeBufferToPointCloud(r,a)}if(!l.ok()||0===a.ptr)throw new Error("THREE.DRACOLoader: Decoding failed: "+l.error_msg());const u={index:null,attributes:[]};for(const r in o){const l=self[s[r]];let c,d;if(i.useUniqueIDs)d=o[r],c=t.GetAttributeByUniqueId(a,d);else{if(d=t.GetAttributeId(a,e[o[r]]),-1===d)continue;c=t.GetAttribute(a,d)}u.attributes.push(n(e,t,a,r,l,c))}c===e.TRIANGULAR_MESH&&(u.index=function(e,t,n){const r=n.num_faces(),i=3*r,o=4*i,s=e._malloc(o);t.GetTrianglesUInt32Array(n,o,s);const a=new Uint32Array(e.HEAPF32.buffer,s,i).slice();return e._free(s),{array:a,itemSize:1}}(e,t,a));return e.destroy(a),u}(t,s,a,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(a),t.destroy(s)}}))}}}let $L;const ZL=()=>{if($L)return $L;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,s){const a=n.exports.sbrk,l=r+3&-4,c=a(l*i),u=a(o.length),d=new Uint8Array(n.exports.memory.buffer);d.set(o,u);const h=e(c,r,i,u,o.length);if(0===h&&s&&s(c,l,i),t.set(d.subarray(c,c+r*i)),a(c-a(0)),0!==h)throw new Error(`Malformed buffer data: ${h}`)}const s={0:"",1:"meshopt_decodeFilterOct",2:"meshopt_decodeFilterQuat",3:"meshopt_decodeFilterExp",NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},a={0:"meshopt_decodeVertexBuffer",1:"meshopt_decodeIndexBuffer",2:"meshopt_decodeIndexSequence",ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return $L={ready:i,supported:!0,decodeVertexBuffer(e,t,r,i,a){o(n.exports.meshopt_decodeVertexBuffer,e,t,r,i,n.exports[s[a]])},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[a[l]],e,t,r,i,n.exports[s[c]])}},$L};class ek extends CI{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register((function(e){return new sk(e)})),this.register((function(e){return new pk(e)})),this.register((function(e){return new mk(e)})),this.register((function(e){return new lk(e)})),this.register((function(e){return new ck(e)})),this.register((function(e){return new uk(e)})),this.register((function(e){return new dk(e)})),this.register((function(e){return new ok(e)})),this.register((function(e){return new hk(e)})),this.register((function(e){return new ak(e)})),this.register((function(e){return new rk(e)})),this.register((function(e){return new fk(e)}))}load(e,t,n,r){const i=this;let o;o=""!==this.resourcePath?this.resourcePath:""!==this.path?this.path:ZI.extractUrlBase(e),this.manager.itemStart(e);const s=function(t){r?r(t):console.error(t),i.manager.itemError(e),i.manager.itemEnd(e)},a=new EI(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,(function(n){try{i.parse(n,o,(function(n){t(n),i.manager.itemEnd(e)}),s)}catch(e){s(e)}}),n,s)}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={},s={};if("string"==typeof e)i=e;else{if(ZI.decodeText(new Uint8Array(e,0,4))===gk){try{o[nk.KHR_BINARY_GLTF]=new _k(e)}catch(e){return void(r&&r(e))}i=o[nk.KHR_BINARY_GLTF].content}else i=ZI.decodeText(new Uint8Array(e))}const a=JSON.parse(i);if(void 0===a.asset||a.asset.version[0]<2)return void(r&&r(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));const l=new Qk(a,{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);s[t.name]=t,o[t.name]=!0}if(a.extensionsUsed)for(let e=0;e<a.extensionsUsed.length;++e){const t=a.extensionsUsed[e],n=a.extensionsRequired||[];switch(t){case nk.KHR_MATERIALS_UNLIT:o[t]=new ik;break;case nk.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:o[t]=new Ck;break;case nk.KHR_DRACO_MESH_COMPRESSION:o[t]=new Sk(a,this.dracoLoader);break;case nk.KHR_TEXTURE_TRANSFORM:o[t]=new bk;break;case nk.KHR_MESH_QUANTIZATION:o[t]=new wk;break;default:n.indexOf(t)>=0&&void 0===s[t]&&console.warn('THREE.GLTFLoader: Unknown extension "'+t+'".')}}l.setExtensions(o),l.setPlugins(s),l.parse(n,r)}parseAsync(e,t){const n=this;return new Promise((function(r,i){n.parse(e,t,r,i)}))}}function tk(){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 nk={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 rk{constructor(e){this.parser=e,this.name=nk.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 s;const a=new Yy(16777215);void 0!==o.color&&a.fromArray(o.color);const l=void 0!==o.range?o.range:0;switch(o.type){case"directional":s=new JI(a),s.target.position.set(0,0,-1),s.add(s.target);break;case"point":s=new WI(a),s.distance=l;break;case"spot":s=new UI(a),s.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,s.angle=o.spot.outerConeAngle,s.penumbra=1-o.spot.innerConeAngle/o.spot.outerConeAngle,s.target.position.set(0,0,-1),s.add(s.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+o.type)}return s.position.set(0,0,0),s.decay=2,void 0!==o.intensity&&(s.intensity=o.intensity),s.name=t.createUniqueName(o.name||"light_"+e),r=Promise.resolve(s),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 ik{constructor(){this.name=nk.KHR_MATERIALS_UNLIT}getMaterialType(){return ES}extendParams(e,t,n){const r=[];e.color=new Yy(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,kv))}return Promise.all(r)}}class ok{constructor(e){this.parser=e,this.name=nk.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 sk{constructor(e){this.parser=e,this.name=nk.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?qE: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 Oy(e,e)}return Promise.all(i)}}class ak{constructor(e){this.parser=e,this.name=nk.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?qE: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 lk{constructor(e){this.parser=e,this.name=nk.KHR_MATERIALS_SHEEN}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?qE: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 Yy(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,kv)),void 0!==o.sheenRoughnessTexture&&i.push(n.assignTexture(t,"sheenRoughnessMap",o.sheenRoughnessTexture)),Promise.all(i)}}class ck{constructor(e){this.parser=e,this.name=nk.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?qE: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 uk{constructor(e){this.parser=e,this.name=nk.KHR_MATERIALS_VOLUME}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?qE: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 s=o.attenuationColor||[1,1,1];return t.attenuationColor=new Yy(s[0],s[1],s[2]),Promise.all(i)}}class dk{constructor(e){this.parser=e,this.name=nk.KHR_MATERIALS_IOR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?qE: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 hk{constructor(e){this.parser=e,this.name=nk.KHR_MATERIALS_SPECULAR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?qE: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 s=o.specularColorFactor||[1,1,1];return t.specularColor=new Yy(s[0],s[1],s[2]),void 0!==o.specularColorTexture&&i.push(n.assignTexture(t,"specularColorMap",o.specularColorTexture,kv)),Promise.all(i)}}class pk{constructor(e){this.parser=e,this.name=nk.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 mk{constructor(e){this.parser=e,this.name=nk.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],s=r.images[o.source];let a=n.textureLoader;if(s.uri){const e=n.options.manager.getHandler(s.uri);null!==e&&(a=e)}return this.detectSupport().then((function(i){if(i)return n.loadTextureImage(e,o.source,a);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 fk{constructor(e){this.name=nk.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,s=e.byteStride,a=new Uint8Array(t,n,r);return i.decodeGltfBufferAsync?i.decodeGltfBufferAsync(o,s,a,e.mode,e.filter).then((function(e){return e.buffer})):i.ready.then((function(){const t=new ArrayBuffer(o*s);return i.decodeGltfBuffer(new Uint8Array(t),o,s,a,e.mode,e.filter),t}))}))}return null}}const gk="glTF",vk=1313821514,yk=5130562;class _k{constructor(e){this.name=nk.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,12);if(this.header={magic:ZI.decodeText(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==gk)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===vk){const n=new Uint8Array(e,12+i,t);this.content=ZI.decodeText(n)}else if(n===yk){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 Sk{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=nk.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,s={},a={},l={};for(const e in o){const t=Fk[e]||e.toLowerCase();s[t]=o[e]}for(const t in e.attributes){const r=Fk[t]||t.toLowerCase();if(void 0!==o[t]){const i=n.accessors[e.attributes[t]],o=Lk[i.componentType];l[r]=o.name,a[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=a[t];void 0!==r&&(n.normalized=r)}t(e)}),s,l)}))}))}}class bk{constructor(){this.name=nk.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 xk extends WE{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"),s={specular:{value:(new Yy).setHex(16777215)},glossiness:{value:1},specularMap:{value:null},glossinessMap:{value:null}};this._extraUniforms=s,this.onBeforeCompile=function(e){for(const t in s)e.uniforms[t]=s[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 s.specular.value},set:function(e){s.specular.value=e}},specularMap:{get:function(){return s.specularMap.value},set:function(e){s.specularMap.value=e,e?this.defines.USE_SPECULARMAP="":delete this.defines.USE_SPECULARMAP}},glossiness:{get:function(){return s.glossiness.value},set:function(e){s.glossiness.value=e}},glossinessMap:{get:function(){return s.glossinessMap.value},set:function(e){s.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 Ck{constructor(){this.name=nk.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 xk}extendParams(e,t,n){const r=t.extensions[this.name];e.color=new Yy(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,kv)),e.emissive=new Yy(0,0,0),e.glossiness=void 0!==r.glossinessFactor?r.glossinessFactor:1,e.specular=new Yy(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,kv))}return Promise.all(i)}createMaterial(e){const t=new xk(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=Fv,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 wk{constructor(){this.name=nk.KHR_MESH_QUANTIZATION}}class Ak extends sI{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,s=this.valueSize,a=2*s,l=3*s,c=r-t,u=(n-t)/c,d=u*u,h=d*u,p=e*l,m=p-l,f=-2*h+3*d,g=h-d,v=1-f,y=g-d+u;for(let e=0;e!==s;e++){const t=o[m+e+s],n=o[m+e+a]*c,r=o[p+e+s],l=o[p+e]*c;i[e]=v*t+y*n+f*r+g*l}return i}}const Ek=new c_;class Ik extends Ak{interpolate_(e,t,n,r){const i=super.interpolate_(e,t,n,r);return Ek.fromArray(i).normalize().toArray(i),i}}const Tk=0,Mk=1,Rk=2,Pk=3,Nk=4,Ok=5,Dk=6,Lk={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},kk={9728:gg,9729:bg,9984:vg,9985:xg,9986:_g,9987:wg},Bk={33071:mg,33648:fg,10497:pg},zk={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Fk={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},Uk={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},jk={CUBICSPLINE:void 0,LINEAR:Av,STEP:wv},Gk="OPAQUE",Hk="MASK",Vk="BLEND";function Wk(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 qk(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 Jk(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 Kk(e){const t=e.extensions&&e.extensions[nk.KHR_DRACO_MESH_COMPRESSION];let n;return n=t?"draco:"+t.bufferView+":"+t.indices+":"+Yk(t.attributes):e.indices+":"+Yk(e.attributes)+":"+e.mode,n}function Yk(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 Xk(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 Qk{constructor(e={},t={}){var n,r;this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new tk,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,s="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&&s<98?this.textureLoader=new NI(this.options.manager):this.textureLoader=new sT(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new EI(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:{}};Wk(i,o,r),qk(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[nk.KHR_BINARY_GLTF].body);const r=this.options;return new Promise((function(e,i){n.load(ZI.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=zk[r.type],s=Lk[r.componentType],a=s.BYTES_PER_ELEMENT,l=a*o,c=r.byteOffset||0,u=void 0!==r.bufferView?n.bufferViews[r.bufferView].byteStride:void 0,d=!0===r.normalized;let h,p;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||(h=new s(i,e*u,r.count*u/a),l=new pw(h,u/a),t.cache.add(n,l)),p=new fw(l,o,c%u/a,d)}else h=null===i?new s(r.count*o):new s(i,c,r.count*o),p=new MS(h,o,d);if(void 0!==r.sparse){const t=zk.SCALAR,n=Lk[r.sparse.indices.componentType],a=r.sparse.indices.byteOffset||0,l=r.sparse.values.byteOffset||0,c=new n(e[1],a,r.sparse.count*t),u=new s(e[2],l,r.sparse.count*o);null!==i&&(p=new MS(p.array.slice(),p.itemSize,p.normalized));for(let e=0,t=c.length;e<t;e++){const t=c[e];if(p.setX(t,u[e*o]),o>=2&&p.setY(t,u[e*o+1]),o>=3&&p.setZ(t,u[e*o+2]),o>=4&&p.setW(t,u[e*o+3]),o>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return p}))}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],s=i.images[t],a=(s.uri||s.bufferView)+":"+o.sampler;if(this.textureCache[a])return this.textureCache[a];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=kk[n.magFilter]||bg,t.minFilter=kk[n.minFilter]||wg,t.wrapS=Bk[n.wrapS]||pg,t.wrapT=Bk[n.wrapT]||pg,r.associations.set(t,{textures:e}),t})).catch((function(){return null}));return this.textureCache[a]=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 s=i.uri||"",a=!1;if(void 0!==i.bufferView)s=this.getDependency("bufferView",i.bufferView).then((function(e){a=!0;const t=new Blob([e],{type:i.mimeType});return s=o.createObjectURL(t),s}));else if(void 0===i.uri)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const l=Promise.resolve(s).then((function(e){return new Promise((function(n,i){let o=n;!0===t.isImageBitmapLoader&&(o=function(e){const t=new t_(e);t.needsUpdate=!0,n(t)}),t.load(ZI.resolveURL(e,r.path),o,void 0,i)}))})).then((function(e){var t;return!0===a&&o.revokeObjectURL(s),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",s),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[nk.KHR_TEXTURE_TRANSFORM]){const e=void 0!==n.extensions?n.extensions[nk.KHR_TEXTURE_TRANSFORM]:void 0;if(e){const t=i.associations.get(o);o=i.extensions[nk.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 cA,AS.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 $w,AS.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 WE}loadMaterial(e){const t=this,n=this.json,r=this.extensions,i=n.materials[e];let o;const s={},a=i.extensions||{},l=[];if(a[nk.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]){const e=r[nk.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS];o=e.getMaterialType(),l.push(e.extendParams(s,i,t))}else if(a[nk.KHR_MATERIALS_UNLIT]){const e=r[nk.KHR_MATERIALS_UNLIT];o=e.getMaterialType(),l.push(e.extendParams(s,i,t))}else{const n=i.pbrMetallicRoughness||{};if(s.color=new Yy(1,1,1),s.opacity=1,Array.isArray(n.baseColorFactor)){const e=n.baseColorFactor;s.color.fromArray(e),s.opacity=e[3]}void 0!==n.baseColorTexture&&l.push(t.assignTexture(s,"map",n.baseColorTexture,kv)),s.metalness=void 0!==n.metallicFactor?n.metallicFactor:1,s.roughness=void 0!==n.roughnessFactor?n.roughnessFactor:1,void 0!==n.metallicRoughnessTexture&&(l.push(t.assignTexture(s,"metalnessMap",n.metallicRoughnessTexture)),l.push(t.assignTexture(s,"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,s)}))))}!0===i.doubleSided&&(s.side=bf);const c=i.alphaMode||Gk;if(c===Vk?(s.transparent=!0,s.depthWrite=!1):(s.transparent=!1,c===Hk&&(s.alphaTest=void 0!==i.alphaCutoff?i.alphaCutoff:.5)),void 0!==i.normalTexture&&o!==ES&&(l.push(t.assignTexture(s,"normalMap",i.normalTexture)),s.normalScale=new Oy(1,1),void 0!==i.normalTexture.scale)){const e=i.normalTexture.scale;s.normalScale.set(e,e)}return void 0!==i.occlusionTexture&&o!==ES&&(l.push(t.assignTexture(s,"aoMap",i.occlusionTexture)),void 0!==i.occlusionTexture.strength&&(s.aoMapIntensity=i.occlusionTexture.strength)),void 0!==i.emissiveFactor&&o!==ES&&(s.emissive=(new Yy).fromArray(i.emissiveFactor)),void 0!==i.emissiveTexture&&o!==ES&&l.push(t.assignTexture(s,"emissiveMap",i.emissiveTexture,kv)),Promise.all(l).then((function(){let n;return n=o===xk?r[nk.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].createMaterial(s):new o(s),i.name&&(n.name=i.name),qk(n,i),t.associations.set(n,{materials:e}),i.extensions&&Wk(r,n,i),n}))}createUniqueName(e){const t=BT.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[nk.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then((function(n){return Zk(n,e,t)}))}const o=[];for(let n=0,s=e.length;n<s;n++){const s=e[n],a=Kk(s),l=r[a];if(l)o.push(l.promise);else{let e;e=s.extensions&&s.extensions[nk.KHR_DRACO_MESH_COMPRESSION]?i(s):Zk(new JS,s,t),r[a]={primitive:s,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,s=[];for(let e=0,t=o.length;e<t;e++){const t=void 0===o[e].material?(void 0===(a=this.cache).DefaultMaterial&&(a.DefaultMaterial=new WE({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:_f})),a.DefaultMaterial):this.getDependency("material",o[e].material);s.push(t)}var a;return s.push(t.loadGeometries(o)),Promise.all(s).then((function(n){const s=n.slice(0,n.length-1),a=n[n.length-1],l=[];for(let n=0,c=a.length;n<c;n++){const c=a[n],u=o[n];let d;const h=s[n];if(u.mode===Nk||u.mode===Ok||u.mode===Dk||void 0===u.mode)d=!0===i.isSkinnedMesh?new Uw(c,h):new db(c,h),!0!==d.isSkinnedMesh||d.geometry.attributes.skinWeight.normalized||d.normalizeSkinWeights(),u.mode===Ok?d.geometry=eB(d.geometry,Ov):u.mode===Dk&&(d.geometry=eB(d.geometry,Dv));else if(u.mode===Mk)d=new aA(c,h);else if(u.mode===Pk)d=new iA(c,h);else if(u.mode===Rk)d=new lA(c,h);else{if(u.mode!==Tk)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+u.mode);d=new mA(c,h)}Object.keys(d.geometry.morphAttributes).length>0&&Jk(d,i),d.name=t.createUniqueName(i.name||"mesh_"+e),qk(d,i),u.extensions&&Wk(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 tw;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 _b(Ny.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):"orthographic"===n.type&&(t=new Hb(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),qk(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=[],s=[];for(let e=0,a=t.channels.length;e<a;e++){const a=t.channels[e],l=t.samplers[a.sampler],c=a.target,u=c.node,d=void 0!==t.parameters?t.parameters[l.input]:l.input,h=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",h)),o.push(l),s.push(c)}return Promise.all([Promise.all(n),Promise.all(r),Promise.all(i),Promise.all(o),Promise.all(s)]).then((function(n){const r=n[0],i=n[1],o=n[2],s=n[3],a=n[4],l=[];for(let e=0,t=r.length;e<t;e++){const t=r[e],n=i[e],c=o[e],u=s[e],d=a[e];if(void 0===t)continue;let h;switch(t.updateMatrix(),Uk[d.path]){case Uk.weights:h=pI;break;case Uk.rotation:h=fI;break;default:h=vI}const p=t.name?t.name:t.uuid,m=void 0!==u.interpolation?jk[u.interpolation]:Av,f=[];Uk[d.path]===Uk.weights?t.traverse((function(e){e.morphTargetInfluences&&f.push(e.name?e.name:e.uuid)})):f.push(p);let g=c.array;if(c.normalized){const e=Xk(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=f.length;e<t;e++){const t=new h(f[e]+"."+Uk[d.path],n.array,g,m);"CUBICSPLINE"===u.interpolation&&(t.createInterpolant=function(e){return new(this instanceof fI?Ik:Ak)(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 yI(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 s;if(s=!0===i.isBone?new jw:t.length>1?new tw:1===t.length?t[0]:new hS,s!==t[0])for(let e=0,n=t.length;e<n;e++)s.add(t[e]);if(i.name&&(s.userData.name=i.name,s.name=o),qk(s,i),i.extensions&&Wk(n,s,i),void 0!==i.matrix){const e=new j_;e.fromArray(i.matrix),s.applyMatrix4(e)}else void 0!==i.translation&&s.position.fromArray(i.translation),void 0!==i.rotation&&s.quaternion.fromArray(i.rotation),void 0!==i.scale&&s.scale.fromArray(i.scale);return r.associations.has(s)||r.associations.set(s,{}),r.associations.get(s).nodes=e,s}))}loadScene(e){const t=this.json,n=this.extensions,r=this.json.scenes[e],i=this,o=new tw;r.name&&(o.name=i.createUniqueName(r.name)),qk(o,r),r.extensions&&Wk(n,o,r);const s=r.nodes||[],a=[];for(let e=0,n=s.length;e<n;e++)a.push($k(s[e],o,t,i));return Promise.all(a).then((function(){return i.associations=(e=>{const t=new Map;for(const[e,n]of i.associations)(e instanceof AS||e instanceof t_)&&t.set(e,n);return e.traverse((e=>{const n=i.associations.get(e);null!=n&&t.set(e,n)})),t})(o),o}))}}function $k(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 j_;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 Ww(r,i),e.matrixWorld)})),e}))})).then((function(e){t.add(e);const o=[];if(i.children){const t=i.children;for(let i=0,s=t.length;i<s;i++){const s=t[i];o.push($k(s,e,n,r))}}return Promise.all(o)}))}function Zk(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=Fk[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 qk(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 u_(t[0],t[1],t[2]),new u_(o[0],o[1],o[2])),e.normalized){const t=Xk(Lk[e.componentType]);i.min.multiplyScalar(t),i.max.multiplyScalar(t)}}const o=t.targets;if(void 0!==o){const e=new u_,t=new u_;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,s=r.max;if(void 0!==o&&void 0!==s){if(t.setX(Math.max(Math.abs(o[0]),Math.abs(s[0]))),t.setY(Math.max(Math.abs(o[1]),Math.abs(s[1]))),t.setZ(Math.max(Math.abs(o[2]),Math.abs(s[2]))),r.normalized){const e=Xk(Lk[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 s=new N_;i.getCenter(s.center),s.radius=i.min.distanceTo(i.max)/2,e.boundingSphere=s}(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 s=[],a=[],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;s.push(t)}if(i){const t=void 0!==u.NORMAL?n.getDependency("accessor",u.NORMAL):e.attributes.normal;a.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(s),Promise.all(a),Promise.all(l)]).then((function(t){const n=t[0],s=t[1],a=t[2];return r&&(e.morphAttributes.position=n),i&&(e.morphAttributes.normal=s),o&&(e.morphAttributes.color=a),e.morphTargetsRelative=!0,e}))}(e,t.targets,n):e}))}function eB(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===Dv)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 tB=null;function nB(e,t,n){return r=>{n&&n(r),e&&(tB||(tB=new XL),tB.setDecoderPath("string"==typeof e?e:"https://www.gstatic.com/draco/versioned/decoders/1.4.3/"),r.setDRACOLoader(tB)),t&&r.setMeshoptDecoder(ZL())}}function rB(e,t=!0,n=!0,r){return PL(ek,e,nB(t,n,r))}rB.preload=(e,t=!0,n=!0,r)=>PL.preload(ek,e,nB(t,n,r)),rB.clear=e=>PL.clear(ek,e);c=o("85Hg2");function iB(e,t){const n=c.useRef(),[r]=c.useState((()=>t?t instanceof hS?{current:t}:t:n)),[i]=c.useState((()=>new jT(void 0))),o=c.useRef({}),[s]=c.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 TL(((e,t)=>i.update(t))),c.useEffect((()=>{const e=r.current;return()=>{o.current={},Object.values(s.actions).forEach((t=>{e&&i.uncacheAction(t,e)}))}}),[e]),s}const oB=new u_(0,-1,0),sB=new Q_(.175,0,0),aB=new u_(0,-1.45,0),lB=[{italian:"Gioia",english:"Joy"},{italian:"Rabbia",english:"Anger"},{italian:"Sorpresa",english:"Surprise"},{italian:"Tristezza",english:"Sadness"},{italian:"Timore",english:"Fear"}],cB=[{emotion:{italian:"Rabbia",english:"Anger"},blendShapes:{browDownLeft:.5,browDownRight:.5,browOuterUpLeft:.5,browOuterUpRight:.5,mouthSmile:-.2}},{emotion:{italian:"Timore",english:"Fear"},blendShapes:{browOuterUpLeft:-.5,browOuterUpRight:-.5,eyeWideLeft:-.5,eyeWideRight:-.5}},{emotion:{italian:"Tristezza",english:"Sadness"},blendShapes:{browDownLeft:-.5,browDownRight:-.5,eyeSquintLeft:.5,eyeSquintRight:.5,mouthSmile:-.6}},{emotion:{italian:"Sorpresa",english:"Surprise"},blendShapes:{browInnerUp:.5,browOuterUpLeft:.5,browOuterUpRight:.5,eyeWideLeft:.5,eyeWideRight:.5}},{emotion:{italian:"Gioia",english:"Joy"},blendShapes:{browDownLeft:.5,browDownRight:.5,browInnerUp:.5,mouthSmile:.8}}],uB={MALE:"https://assets.memori.ai/api/v2/asset/2c5e88a4-cf62-408b-9ef0-518b099dfcb2.glb",FEMALE:"https://assets.memori.ai/api/v2/asset/2adc934b-24b2-45bd-94ad-ffec58d3cb32.glb"},dB={minInterval:1e3,maxInterval:5e3,blinkDuration:150};class hB{constructor(e,t,n){this.currentEmotionValues={},this.previousEmotionKeys=new Set,this.isRPM=!1,this.rpmBlendShapes=cB,this.customGlbMapping=lB,this.headMesh=e,this.isRPM="GBNL__Head"!==e.name,t&&(this.rpmBlendShapes=t),n&&(this.customGlbMapping=n)}processChatEmission(e,t){var n,r;const i=this.getDefaultEmotionMorphTargets();if(t||!e)return i;if(!(null==e?void 0:e.includes('<output class="memori-emotion">')))return i;const o=null===(r=null===(n=null==e?void 0:e.split('<output class="memori-emotion">')[1])||void 0===n?void 0:n.split("</output>")[0])||void 0===r?void 0:r.trim();return o?this.processEmotion(o):i}processEmotion(e){const t=this.getDefaultEmotionMorphTargets();if(this.isRPM){const n=this.rpmBlendShapes.find((t=>t.emotion.italian.toLowerCase()===e.toLowerCase()||t.emotion.english.toLowerCase()===e.toLowerCase()));if(n)return{...t,...n.blendShapes}}else{const n=this.customGlbMapping.find((t=>t.italian.toLowerCase()===e.toLowerCase()||t.english.toLowerCase()===e.toLowerCase()));if(n)return{...t,[n.english]:1}}return console.log("[MorphTargetController] No emotion found:",e),t}getDefaultEmotionMorphTargets(){if(this.isRPM){const e=new Set;return this.rpmBlendShapes.forEach((t=>{Object.keys(t.blendShapes).forEach((t=>e.add(t)))})),Array.from(e).reduce(((e,t)=>({...e,[t]:0})),{})}return this.customGlbMapping.reduce(((e,t)=>({...e,[t.english]:0})),{})}updateMorphTargets(e,t,n,r,i,o){if(!this.headMesh.morphTargetDictionary||!this.headMesh.morphTargetInfluences)return void console.error("[MorphTargetController] Missing morphTargetDictionary or morphTargetInfluences");const s=this.processChatEmission(t,n),a=this.calculateBlinkValue(e,o,i),l=new Set(Object.keys(s));Object.entries(this.headMesh.morphTargetDictionary).forEach((([e,t])=>{if("number"!=typeof t)return;let n=0;if(l.has(e)){const t=s[e],r=this.currentEmotionValues[e]||0,i=Ny.lerp(r,3*t,.3);this.currentEmotionValues[e]=i,n+=i}if(r&&e===r.name&&(n+=r.weight),"eyesClosed"===e&&i&&(n+=a),n=Ny.clamp(n,0,1),this.headMesh.morphTargetInfluences){const e=Ny.lerp(this.headMesh.morphTargetInfluences[t]||0,n,.5);this.headMesh.morphTargetInfluences[t]=e}})),this.previousEmotionKeys=l}calculateBlinkValue(e,t,n){if(!n)return 0;let r=0;if(e>=t.nextBlinkTime&&!t.isBlinking&&(t.isBlinking=!0,t.blinkStartTime=e,t.lastBlinkTime=e,t.nextBlinkTime=e+Math.random()*(dB.maxInterval-dB.minInterval)+dB.minInterval),t.isBlinking){const n=(e-t.blinkStartTime)/dB.blinkDuration;n<=.5?r=2*n:n<=1?r=2-2*n:(t.isBlinking=!1,r=0)}return r}}class pB{constructor(e=oB.clone(),t=aB.clone(),n=.6){this.defaultPosition=e,this.zoomedPosition=t,this.currentScale=new u_(1,1,1),this.targetScale=new u_(1,1,1),this.currentPosition=e.clone(),this.basePosition=e.clone(),this.initialCameraPosition=new u_(0,0,n)}mapHeightToScale(e,t){return t?Ny.lerp(1.4,2.1,e/100):Ny.lerp(.5,1.5,e/100)}mapDepthToCamera(e,t){const n=this.initialCameraPosition.z;return Ny.lerp(n,n+3,e/100)}updateHeight(e,t){const n=this.mapHeightToScale(e,t);this.targetScale.set(n,n,n)}updateDepth(e,t){return this.mapDepthToCamera(e,t)}updateBasePosition(e){const t=e?this.zoomedPosition:this.defaultPosition;this.basePosition.copy(t),this.currentPosition.copy(t)}updateScale(e){return this.currentScale.lerp(this.targetScale,e),this.currentScale}getPosition(){return this.currentPosition}reset(){this.currentScale.set(1,1,1),this.targetScale.set(1,1,1),this.currentPosition.copy(this.defaultPosition),this.basePosition.copy(this.defaultPosition)}}class mB{constructor(){this.mixer=null,this.actions={},this.animations=new Map,this.currentAnimation=null,this.currentSequence=null,this.sequenceIndex=0,this.isTransitioning=!1,this.timeScale=1,this.fadeInDuration=.8,this.fadeOutDuration=.8,this.avatarType="CUSTOM_GLB",this.eventListeners={start:[],complete:[],loop:[],transition:[],error:[]},this.initialized=!1,this.idleRotationCount=0,this.currentIdleAnimation=null,this.idleRotationLimit=5,this.lastAnimationTime=null}async initialize(e,t,n=[],r="CUSTOM_GLB"){if(this.initialized||this.mixer)return void console.warn("[AvatarAnimator] Already initialized, ignoring duplicate initialization");this.mixer=new jT(e),this.avatarType=r,this.actions={},this.registerClipsDirectly(n),Object.entries(t).forEach((([e,t])=>{this.actions[e]||(this.actions[e]=t,this.registerAnimation(e,t))})),this.setupMixerEvents();const i=["Idle1","Idle2","Idle3","Idle4","Idle5"];let o=!1;for(const e of i)if(this.actions[e])try{const t=this.actions[e];t.reset(),t.setEffectiveTimeScale(1),t.setEffectiveWeight(1),t.setLoop(1/0,1/0),t.play(),this.currentAnimation=e,this.currentIdleAnimation=e,this.idleRotationCount=0,o=!0;break}catch(t){console.error(`Error starting ${e}:`,t)}o||console.warn("[AvatarAnimator] Could not start any idle animation directly"),this.initialized=!0}registerClipsDirectly(e){this.mixer&&e.forEach((e=>{var t;const n=null===(t=this.mixer)||void 0===t?void 0:t.clipAction(e);n?(this.actions[e.name]=n,this.registerAnimation(e.name,n)):console.warn(`[AvatarAnimator] Failed to create action for clip: ${e.name}`)}))}registerAnimations(e,t=[]){const n=new Set;t.forEach((e=>n.add(e.name))),Object.keys(e).forEach((e=>n.add(e))),t.forEach((e=>{if(this.mixer){const t=this.mixer.clipAction(e);this.actions[e.name]=t,this.registerAnimation(e.name,t)}})),Object.entries(e).forEach((([e,t])=>{this.actions[e]||(this.actions[e]=t,this.registerAnimation(e,t))}));this.getAnimationsByCategory("IDLE"),this.getAnimationsByCategory("LOADING"),this.getAnimationsByCategory("ACTION")}registerAnimation(e,t){const n=t.getClip().duration;let r="ACTION",i=1,o=!1;const s=e.toLowerCase();s.includes("idle")?(r="IDLE",i=0,o=!0):(s.includes("loading")||s.includes("wait"))&&(r="LOADING",i=0,o=!0),this.animations.set(e,{name:e,category:r,duration:n,canLoop:o,defaultLoopCount:i})}play(e,t={}){var n,r,i,o;try{if(!this.initialized||!this.mixer)return void console.warn(`[AvatarAnimator] Cannot play ${e} - not initialized`);const s=this.actions[e];if(!s){if(console.warn(`[AvatarAnimator] Animation not found: ${e}`),!1!==t.fallbackToIdle){const e=Object.keys(this.actions)[0];e&&this.play(e,{...t,fallbackToIdle:!1})}return}const a=this.getAnimationInfo(e);if(!a)return console.warn(`[AvatarAnimator] Animation info not found: ${e}`),void(!1!==t.fallbackToIdle&&this.idle());if(this.currentAnimation===e&&!this.isTransitioning&&void 0===t.loopCount)return;if(this.isTransitioning&&this.currentAnimation){const e=this.actions[this.currentAnimation];e&&e.fadeOut(.1)}const l=null!==(n=t.fadeInDuration)&&void 0!==n?n:this.fadeInDuration,c=null!==(r=t.fadeOutDuration)&&void 0!==r?r:this.fadeOutDuration,u=null!==(i=t.loopCount)&&void 0!==i?i:a.defaultLoopCount,d=null!==(o=t.timeScale)&&void 0!==o?o:this.timeScale;if("IDLE"===a.category&&(this.currentIdleAnimation=e,this.idleRotationCount=0),this.emit("transition",{from:this.currentAnimation,to:e}),this.currentAnimation){const t=this.actions[this.currentAnimation];t&&(this.currentAnimation===e?t.stop():t.fadeOut(c))}s.reset(),s.fadeIn(l),s.timeScale=d,s.enabled=!0,0===u?s.setLoop(1/0,1/0):(s.setLoop(u>1?u:bv,u>1?u:1),s.clampWhenFinished=!0),s.play(),this.currentAnimation=e,this.isTransitioning=!0;const h=1e3*Math.max(l,c);setTimeout((()=>{this.isTransitioning=!1}),h),this.emit("start",{animation:e,category:a.category,loopCount:u})}catch(n){if(console.error(`[AvatarAnimator] Error in play method for ${e}:`,n),!1!==t.fallbackToIdle)try{this.idle()}catch(e){console.error("[AvatarAnimator] Failed to recover with idle animation:",e)}}}execute(e){if(this.initialized)try{let t;const n=e.match(/\[loop=(\d+)\]/);if(n&&(t=parseInt(n[1],10),e=e.replace(n[0],"").trim()),e.includes("->")){const n=e.split("->").map((e=>e.trim()));this.playSequence(n,{loopCount:t})}else this.play(e,{loopCount:t})}catch(t){console.error("[AvatarAnimator] Error executing animation command:",t),this.emit("error",{error:t,command:e}),this.idle()}else console.warn("[AvatarAnimator] Cannot execute - not initialized")}processChatEmission(e,t){if(!this.initialized)return void console.warn("[AvatarAnimator] Cannot process chat emission - not initialized");const n="LOADING"===this.getAnimationCategory();if(t){if(n)return;return void this.loading()}if(!e){if("IDLE"===this.getAnimationCategory())return;return void this.idle(n?{fadeInDuration:1.2,fadeOutDuration:1}:void 0)}const r=e.match(/<output class="animation-sequence">(.*?)<\/output>/),i=e.match(/<output class="animation">(.*?)(\[loop=(\d+)\])?<\/output>/),o=e.match(/<output class="memori-emotion">(.*?)<\/output>/),s=this.calculateTransitionOptions();if(r&&r[1]){const e=r[1].trim();if(this.currentSequence&&this.currentSequence.join("->")===e&&this.sequenceIndex<this.currentSequence.length)return;this.executeWithTransition(e,s)}else{if(i&&i[1]){const e=i[1].trim();let t;return i[3]&&(t=parseInt(i[3],10)),void this.play(e,{...s,loopCount:t})}if(o&&o[1]){const e=o[1].trim();console.log("[AvatarAnimator] Processing emotion:",e);let t=[];if(lB.find((t=>t.english===e))){console.log("[AvatarAnimator] Found emotion in English mapping");let n=lB.filter((t=>t.english===e));console.log("[AvatarAnimator] Matching emotions:",n),t=this.getAllAnimationNames().filter((e=>n.some((t=>e.toLowerCase().startsWith(t.italian.toLowerCase())))))}else console.log("[AvatarAnimator] Using generalized emotion matching approach"),t=this.getAllAnimationNames().filter((t=>t.toLowerCase().startsWith(e.toLowerCase())));if(console.log("[AvatarAnimator] Found matching animations:",t),t.length>0){const e=t[Math.floor(Math.random()*t.length)];return console.log("[AvatarAnimator] Selected animation to play:",e),void this.play(e,s)}console.log("[AvatarAnimator] No matching animations found for emotion:",e)}"IDLE"!==this.getAnimationCategory()&&this.idle(s)}}calculateTransitionOptions(){var e,t;const n={fadeInDuration:this.fadeInDuration,fadeOutDuration:this.fadeOutDuration,timeScale:this.timeScale},r=(this.getAnimationCategory(),this.currentAnimation?this.actions[this.currentAnimation]:null);if(n.fadeOutDuration=.8,n.fadeInDuration=.8,r){const i=r.getClip(),o=r.time/i.duration;o>.75?n.fadeOutDuration=Math.max(.4,.8*(null!==(e=n.fadeOutDuration)&&void 0!==e?e:.8)):o<.25&&(n.fadeInDuration=Math.max(.4,.8*(null!==(t=n.fadeInDuration)&&void 0!==t?t:.8)))}return n}executeWithTransition(e,t={}){if(this.initialized)try{let n;const r=e.match(/\[loop=(\d+)\]/);if(r&&(n=parseInt(r[1],10),e=e.replace(r[0],"").trim()),e.includes("->")){const r=e.split("->").map((e=>e.trim())),i={...t,loopCount:n||1};this.playSequence(r,i)}else this.play(e,{...t,loopCount:n})}catch(t){console.error("[AvatarAnimator] Error executing animation command:",t),this.emit("error",{error:t,command:e}),this.idle()}else console.warn("[AvatarAnimator] Cannot execute - not initialized")}idle(e={}){var t,n,r,i,o,s,a,l,c;const u=this.getAnimationsByCategory("IDLE");if(u.length>0){let i=u;"IDLE"===this.getAnimationCategory()&&(i=u.filter((e=>e.name!==this.currentAnimation)),0===i.length&&(i=u));const o=i[Math.floor(Math.random()*i.length)].name,s={fadeInDuration:null!==(t=e.fadeInDuration)&&void 0!==t?t:.7,fadeOutDuration:null!==(n=e.fadeOutDuration)&&void 0!==n?n:.7,timeScale:null!==(r=e.timeScale)&&void 0!==r?r:.9,loopCount:0,...e};return s.loopCount=0,this.play(o,s),this.currentIdleAnimation=o,void(this.idleRotationCount=0)}{console.warn("[AvatarAnimator] No idle animations available, checking fallback options");const t=Array.from(this.animations.values()).filter((e=>e.canLoop)).map((e=>e.name));if(t.length>0){const n=t[Math.floor(Math.random()*t.length)];this.play(n,{loopCount:0,fadeInDuration:null!==(i=e.fadeInDuration)&&void 0!==i?i:.7,fadeOutDuration:null!==(o=e.fadeOutDuration)&&void 0!==o?o:.7,timeScale:null!==(s=e.timeScale)&&void 0!==s?s:.9}),this.currentIdleAnimation=n,this.idleRotationCount=0}else if(Object.keys(this.actions).length>0){const t=Object.keys(this.actions)[0];this.play(t,{loopCount:0,fadeInDuration:null!==(a=e.fadeInDuration)&&void 0!==a?a:.7,fadeOutDuration:null!==(l=e.fadeOutDuration)&&void 0!==l?l:.7,timeScale:null!==(c=e.timeScale)&&void 0!==c?c:.9}),this.currentIdleAnimation=t,this.idleRotationCount=0}}}loading(e={}){var t,n,r;const i=this.getRandomAnimation("LOADING");if(i){const o={loopCount:0,fadeInDuration:null!==(t=e.fadeInDuration)&&void 0!==t?t:.8,fadeOutDuration:null!==(n=e.fadeOutDuration)&&void 0!==n?n:.8,timeScale:null!==(r=e.timeScale)&&void 0!==r?r:this.timeScale,...e};o.loopCount=0,this.play(i,o)}else console.warn("[AvatarAnimator] No loading animations available, using idle instead"),this.idle(e)}playSequence(e,t={}){var n;if(!e||0===e.length)return void console.warn("[AvatarAnimator] Empty animation sequence provided");e.length>5&&(console.warn(`[AvatarAnimator] Sequence too long (${e.length}), limiting to 5 animations`),e=e.slice(0,5));const r=e.filter((e=>this.actions[e]));if(0===r.length)return console.error("[AvatarAnimator] No valid animations in sequence, defaulting to idle"),void this.idle();if(this.isTransitioning)return void setTimeout((()=>{this.playSequence(e,t)}),100);this.currentSequence=[...r],this.sequenceIndex=0;const i={fadeInDuration:.6,fadeOutDuration:.6,loopCount:1,timeScale:null!==(n=t.timeScale)&&void 0!==n?n:this.timeScale},o=r[0];this.play(o,i)}forceIdle(){const e=this.getAnimationsByCategory("IDLE");if(e.length>0){const t=e[0].name;this.play(t,{loopCount:0,fadeInDuration:.8,fadeOutDuration:.8}),this.currentIdleAnimation=t,this.idleRotationCount=0}else console.error("[AvatarAnimator] No idle animations available for forced transition")}update(e){if(!this.initialized||!this.mixer)return;const t=Math.min(e,.1);if(this.mixer.update(t),!this.isTransitioning){if(this.currentSequence&&this.currentAnimation){const e=this.actions[this.currentAnimation];if(e){const t=e.getClip().duration;if(e.time/t>.85&&!this.isTransitioning)if(this.sequenceIndex<this.currentSequence.length-1){this.sequenceIndex++;const e=this.currentSequence[this.sequenceIndex];this.play(e,{fadeInDuration:.5,fadeOutDuration:.5,loopCount:1})}else this.currentSequence=null,this.sequenceIndex=0,this.idle({fadeInDuration:.7,fadeOutDuration:.7})}}if(this.currentAnimation&&this.currentIdleAnimation&&"IDLE"===this.getAnimationCategory()){const e=this.actions[this.currentAnimation];if(e){const t=e.getClip().duration,n=e.time%t;(this.lastAnimationTime||0)>n+.1&&(this.idleRotationCount++,this.idleRotationCount>=this.idleRotationLimit&&(this.idleRotationCount=0,this.idle({fadeInDuration:.6,fadeOutDuration:.6}))),this.lastAnimationTime=n}}}}isAnimationPlaying(e){if(!this.actions[e])return!1;const t=this.actions[e];return t.isRunning()&&t.getEffectiveWeight()>.1}setupMixerEvents(){this.mixer?(this.mixer.addEventListener("loop",(e=>{const t=e.action;t&&this.currentAnimation&&t===this.actions[this.currentAnimation]&&this.emit("loop",{animation:this.currentAnimation})})),this.mixer.addEventListener("finished",(e=>{const t=e.action;if(t&&this.currentAnimation&&t===this.actions[this.currentAnimation]){if(this.isTransitioning)return;this.emit("complete",{animation:this.currentAnimation}),setTimeout((()=>{var e;this.currentSequence&&this.sequenceIndex<this.currentSequence.length-1?(this.sequenceIndex++,this.play(this.currentSequence[this.sequenceIndex],{fadeInDuration:.5,fadeOutDuration:.5,loopCount:1})):this.currentSequence&&this.sequenceIndex>=this.currentSequence.length-1?(this.currentSequence=null,this.sequenceIndex=0,this.idle({fadeInDuration:.7,fadeOutDuration:.7})):this.currentAnimation&&"IDLE"!==(null===(e=this.getAnimationInfo(this.currentAnimation))||void 0===e?void 0:e.category)&&this.idle({fadeInDuration:.7,fadeOutDuration:.7})}),50)}}))):console.warn("[AvatarAnimator] Cannot setup mixer events - mixer not initialized")}handleSequenceProgressionIfNeeded(){if(!this.currentSequence||!this.currentAnimation||this.sequenceIndex>=this.currentSequence.length-1)return;const e=this.actions[this.currentAnimation];if(!e)return;const t=e.getClip().duration;if(e.time/t>.9&&!this.isTransitioning)if(this.sequenceIndex++,this.sequenceIndex<this.currentSequence.length){const e=this.currentSequence[this.sequenceIndex];this.play(e,{fadeInDuration:.3,fadeOutDuration:.3,loopCount:1})}else this.currentSequence=null,this.sequenceIndex=0,this.idle()}handleIdleRotationIfNeeded(){if(!this.currentAnimation||!this.currentIdleAnimation||"IDLE"!==this.getAnimationCategory())return;const e=this.actions[this.currentAnimation];if(!e)return;const t=e.getClip().duration,n=e.time%t;(this.lastAnimationTime||0)>n+.1&&(this.idleRotationCount++,this.idleRotationCount>=this.idleRotationLimit&&(this.idleRotationCount=0,this.idle())),this.lastAnimationTime=n}setTimeScale(e){if(this.timeScale=e,this.currentAnimation){const t=this.actions[this.currentAnimation];t&&(t.timeScale=e)}}getRandomAnimation(e,t=[]){const n=Array.from(this.animations.values()).filter((n=>n.category===e&&!t.includes(n.name)));if(0===n.length)return null;return n[Math.floor(Math.random()*n.length)].name}getAnimationInfo(e){return this.animations.get(e)||null}getAnimationCategory(){var e;return this.currentAnimation&&(null===(e=this.getAnimationInfo(this.currentAnimation))||void 0===e?void 0:e.category)||null}on(e,t){this.eventListeners[e]&&this.eventListeners[e].push(t)}off(e,t){this.eventListeners[e]&&(this.eventListeners[e]=this.eventListeners[e].filter((e=>e!==t)))}emit(e,t){this.eventListeners[e]&&this.eventListeners[e].forEach((n=>{try{n(t)}catch(t){console.error(`Error in ${e} event handler:`,t)}}))}getCurrentAnimationName(){return this.currentAnimation}getAvatarType(){return this.avatarType}isInitialized(){return this.initialized}getAllAnimationNames(){return Array.from(this.animations.keys())}getAnimationsByCategory(e){return Array.from(this.animations.values()).filter((t=>t.category===e))}}c=o("85Hg2");const fB={uniforms:{tDiffuse:{value:null},h:{value:1/512}},vertexShader:"\n varying vec2 vUv;\n\n void main() {\n\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }\n ",fragmentShader:"\n uniform sampler2D tDiffuse;\n uniform float h;\n\n varying vec2 vUv;\n\n void main() {\n\n \tvec4 sum = vec4( 0.0 );\n\n \tsum += texture2D( tDiffuse, vec2( vUv.x - 4.0 * h, vUv.y ) ) * 0.051;\n \tsum += texture2D( tDiffuse, vec2( vUv.x - 3.0 * h, vUv.y ) ) * 0.0918;\n \tsum += texture2D( tDiffuse, vec2( vUv.x - 2.0 * h, vUv.y ) ) * 0.12245;\n \tsum += texture2D( tDiffuse, vec2( vUv.x - 1.0 * h, vUv.y ) ) * 0.1531;\n \tsum += texture2D( tDiffuse, vec2( vUv.x, vUv.y ) ) * 0.1633;\n \tsum += texture2D( tDiffuse, vec2( vUv.x + 1.0 * h, vUv.y ) ) * 0.1531;\n \tsum += texture2D( tDiffuse, vec2( vUv.x + 2.0 * h, vUv.y ) ) * 0.12245;\n \tsum += texture2D( tDiffuse, vec2( vUv.x + 3.0 * h, vUv.y ) ) * 0.0918;\n \tsum += texture2D( tDiffuse, vec2( vUv.x + 4.0 * h, vUv.y ) ) * 0.051;\n\n \tgl_FragColor = sum;\n\n }\n "},gB={uniforms:{tDiffuse:{value:null},v:{value:1/512}},vertexShader:"\n varying vec2 vUv;\n\n void main() {\n\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }\n ",fragmentShader:"\n\n uniform sampler2D tDiffuse;\n uniform float v;\n\n varying vec2 vUv;\n\n void main() {\n\n vec4 sum = vec4( 0.0 );\n\n sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 4.0 * v ) ) * 0.051;\n sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 3.0 * v ) ) * 0.0918;\n sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 2.0 * v ) ) * 0.12245;\n sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 1.0 * v ) ) * 0.1531;\n sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y ) ) * 0.1633;\n sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 1.0 * v ) ) * 0.1531;\n sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 2.0 * v ) ) * 0.12245;\n sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 3.0 * v ) ) * 0.0918;\n sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 4.0 * v ) ) * 0.051;\n\n gl_FragColor = sum;\n\n }\n "},vB=c.forwardRef((({scale:e,frames:t=1/0,opacity:n=1,width:r=1,height:i=1,blur:o=1,far:s=10,resolution:a=256,smooth:l=!0,color:u="#000000",...d},h)=>{const p=IL((({scene:e})=>e)),m=IL((({gl:e})=>e)),f=c.useRef(null);r*=Array.isArray(e)?e[0]:e||1,i*=Array.isArray(e)?e[1]:e||1;const[g,v,y,_,S,b,x]=c.useMemo((()=>{const e=new r_(a,a),t=new r_(a,a);t.texture.generateMipmaps=e.texture.generateMipmaps=!1;const n=new $M(r,i).rotateX(Math.PI/2),o=new db(n),s=new KC;s.depthTest=s.depthWrite=!1,s.onBeforeCompile=e=>{e.uniforms={...e.uniforms,ucolor:{value:new Yy(u).convertSRGBToLinear()}},e.fragmentShader=e.fragmentShader.replace("void main() {","uniform vec3 ucolor;\n void main() {\n "),e.fragmentShader=e.fragmentShader.replace("vec4( vec3( 1.0 - fragCoordZ ), opacity );","vec4( ucolor, ( 1.0 - fragCoordZ ) * 1.0 );")};const l=new vb(fB),c=new vb(gB);return c.depthTest=l.depthTest=!1,[e,n,s,o,l,c,t]}),[a,r,i,e]),C=c.useCallback((e=>{_.visible=!0,_.material=S,S.uniforms.tDiffuse.value=g.texture,S.uniforms.h.value=1*e/256,m.setRenderTarget(x),m.render(_,f.current),_.material=b,b.uniforms.tDiffuse.value=x.texture,b.uniforms.v.value=1*e/256,m.setRenderTarget(g),m.render(_,f.current),_.visible=!1}),[]);let w=0;return TL((()=>{if(f.current&&(t===1/0||w<t)){const e=p.background;p.background=null;const t=p.overrideMaterial;p.overrideMaterial=y,m.setRenderTarget(g),m.render(p,f.current),p.overrideMaterial=t,C(o),l&&C(.4*o),m.setRenderTarget(null),p.background=e,w++}})),c.createElement("group",UL({"rotation-x":Math.PI/2},d,{ref:h}),c.createElement("mesh",{geometry:v,scale:[1,-1,1],rotation:[-Math.PI/2,0,0]},c.createElement("meshBasicMaterial",{map:g.texture,transparent:!0,opacity:n})),c.createElement("orthographicCamera",{ref:f,args:[-r/2,r/2,i/2,-i/2,0,s]}))}));var yB=({animator:e,avatarPosition:t})=>{const n=(()=>{var t,n,r,i,o;const s={width:10,height:10,blur:2.5,scale:10,far:5,resolution:1024,color:"#000000"};return e?(null===(t=e.getCurrentAnimationName())||void 0===t?void 0:t.startsWith("Loading"))?{...s,opacity:.85,blur:3,width:12,height:12}:(null===(n=e.getCurrentAnimationName())||void 0===n?void 0:n.includes("Gioia"))||(null===(r=e.getCurrentAnimationName())||void 0===r?void 0:r.includes("Joy"))?{...s,opacity:.9,blur:2,width:11,height:11}:(null===(i=e.getCurrentAnimationName())||void 0===i?void 0:i.includes("Rabbia"))||(null===(o=e.getCurrentAnimationName())||void 0===o?void 0:o.includes("Anger"))?{...s,opacity:.95,blur:1.8,width:12,height:12}:{...s,opacity:.9,blur:2.2}:{...s,opacity:0}})();return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(vB,{opacity:n.opacity,scale:n.scale,blur:n.blur,far:n.far,resolution:n.resolution,color:n.color,frames:1/0,position:[0,t.y,0]}),(0,s.jsx)(vB,{opacity:1,width:5,height:5,blur:1,far:2,resolution:1024,color:"#000000",position:[0,-.98,0]})]})};c=o("85Hg2");const _B=(e,t,n=.05)=>e*(1-n)+t*n,SB=(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,bB=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))};c=o("85Hg2");const xB=Math.PI/180;let CB,wB=!1;const AB=new Oy(0,0),EB=new Oy(0,0),IB=()=>{CB=setTimeout((()=>{wB=!0}),1e3)},TB=()=>{clearTimeout(CB),wB=!1};function MB(e,t){const{gl:n}=IL();(0,c.useEffect)((()=>{if(e)return n.domElement.addEventListener("mouseleave",IB),n.domElement.addEventListener("mouseenter",TB),()=>{n.domElement.removeEventListener("mouseleave",IB),n.domElement.removeEventListener("mouseenter",TB)}}),[n.domElement,e]),TL((n=>{if(!e||!(null==t?void 0:t.Neck)||!(null==t?void 0:t.Head))return;const r=Math.abs(n.camera.rotation.z);!wB&&r<.2?(AB.x=SB(n.mouse.y,-1,1,5*xB,-5*xB),AB.y=SB(n.mouse.x,-1,1,-10*xB,10*xB)):AB.set(0,0),EB.x=_B(EB.x,AB.x),EB.y=_B(EB.y,AB.y),t.Neck.rotation.x=EB.x+.1,t.Neck.rotation.y=EB.y,t.Head.rotation.x=2*EB.x,t.Head.rotation.y=2*EB.y}))}const RB=(0,c.memo)((function({url:e,sex:t,eyeBlink:n,updateCurrentViseme:r,avatarHeight:i=50,avatarDepth:o=0,onCameraZChange:a,chatEmission:l,loading:u,setAnimatorRef:d}){const{scene:h,animations:p}=rB(e),{animations:m}=rB(uB[t]),f=(0,c.useMemo)((()=>{let e=!1;return h.traverse((t=>{t instanceof Uw&&("GBNL__Head"===t.name||"Wolf3D_Avatar"===t.name||"Wolf3D_Avatar006_1"===t.name)&&(e=!0)})),e}),[h]),g=(0,c.useMemo)((()=>f?[...p,...m]:p),[p,m,f]),{actions:v}=iB(g,h),y=(0,c.useRef)(null),_=(0,c.useRef)(null),S=(0,c.useRef)(null),b=(0,c.useRef)(!1),x=(0,c.useRef)(oB.clone()),C=(0,c.useRef)(0),[w,A]=(0,c.useState)(!1),E=(0,c.useRef)({isBlinking:!1,lastBlinkTime:0,nextBlinkTime:0,blinkStartTime:0});(0,c.useEffect)((()=>{if(!h)return;let e=null;h.traverse((t=>{if(t instanceof Uw){if("Wolf3D_Avatar"===t.name||"Wolf3D_Avatar006_1"===t.name)return A(!0),console.log("RPM avatar detected"),void(e=t);if("GBNL__Head"===t.name)e=t;else{if(t.morphTargetDictionary&&Object.keys(t.morphTargetDictionary).length>0){const n=Object.keys(t.morphTargetDictionary||{}),r=n.some((e=>e.toLowerCase().includes("viseme"))),i=n.some((e=>{const t=e.toLowerCase();return t.includes("mouth")||t.includes("eye")||t.includes("jaw")||t.includes("smile")}));(r||i)&&(console.log("🎭 Custom avatar detected:",{name:t.name,morphTargets:n,visemeCount:n.filter((e=>e.toLowerCase().includes("viseme"))).length}),e=t)}}}})),e?y.current||(y.current=new hB(e)):console.warn("⚠️ No suitable avatar mesh found")}),[h]),(0,c.useEffect)((()=>(_.current||(_.current=new pB(oB)),()=>{})),[]),(0,c.useEffect)((()=>{_.current&&_.current.updateHeight(i,!1)}),[i]),(0,c.useEffect)((()=>{if(_.current&&a){const e=_.current.updateDepth(o,!1);a(e)}}),[o,a]),(0,c.useEffect)((()=>{if(!h||!v||b.current)return;console.log("Initializing animator"),S.current||(S.current=new mB);const e=S.current;return(async()=>{try{if(e.isInitialized())return void console.log("Animator already initialized, skipping initialization");await e.initialize(h,v,g,w?"RPM":"CUSTOM_GLB"),console.log("AvatarAnimator initialized with",Object.keys(v).length,"animations"),d&&d(e),b.current=!0,e.setTimeScale(.8)}catch(e){console.error("Error initializing AvatarAnimator:",e)}})(),()=>{S.current&&b.current&&(console.log("Cleaning up animator"),"mixer"in S.current&&S.current.mixer&&S.current.mixer.stopAllAction(),d&&d(null),b.current=!1)}}),[h,v,g,t,d]),TL((0,c.useCallback)(((e,t)=>{const i=1e3*e.clock.elapsedTime;if(S.current&&b.current&&S.current.update(t),y.current){const e=r(i/1e3);y.current.updateMorphTargets(i,l,u,e,n,E.current)}if(h&&_.current){const e=_.current.updateScale(.1);if(h.scale.copy(e),i-C.current>=1){const e=_.current.getPosition();e.setX(Number(e.x.toFixed(6))),e.setY(Number(e.y.toFixed(6))),e.setZ(Number(e.z.toFixed(6))),x.current.copy(e),C.current=i}}}),[h,r,l,u,n]));const I=(0,c.useMemo)((()=>{var e;return(null===(e=_.current)||void 0===e?void 0:e.getPosition())||oB.clone()}),[]);return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(yB,{animator:S.current,avatarPosition:I}),(0,s.jsx)("group",{position:I,rotation:sB,children:(0,s.jsx)("primitive",{object:h})})]})})),PB=(0,c.memo)((function({url:e,updateCurrentViseme:t,eyeBlink:n=!1,avatarHeight:r=50,avatarDepth:i=0,headMovement:o=!1,onLoaded:a,onCameraZChange:l,chatEmission:u,loading:d=!1}){var h;const{scene:p}=rB(e),{nodes:m,materials:f}=(g=p,c.useMemo((()=>ML(g)),[g]));var g;const{camera:v}=IL(),y=(0,c.useRef)(null),_=(0,c.useRef)(null);(0,c.useRef)(v.position.z),MB(o,m);const S=(0,c.useRef)({isBlinking:!1,lastBlinkTime:0,nextBlinkTime:0,blinkStartTime:0}),b=(0,c.useMemo)((()=>{let e;return null==p||p.traverse((t=>{t instanceof Uw&&("GBNL__Head"===t.name||"Wolf3D_Avatar"===t.name||"Wolf3D_Avatar006_1"===t.name)&&(e=t)})),e}),[p]);(0,c.useEffect)((()=>(_.current||(_.current=new pB(oB,aB)),b&&(y.current=new hB(b)),bR(f),null==a||a(),bB(m),()=>{Object.values(f).forEach((e=>e.dispose())),Object.values(m).filter(xR).forEach((e=>e.geometry.dispose()))})),[f,m,e,a,p,b]),(0,c.useEffect)((()=>{_.current&&_.current.updateHeight(r,!0)}),[r]),(0,c.useEffect)((()=>{if(_.current&&l){const e=_.current.updateDepth(i,!0);l(e)}}),[i,l]),TL((e=>{const r=1e3*e.clock.elapsedTime;if(y.current){const e=t(r/1e3);y.current.updateMorphTargets(r,u,d,e,n,S.current)}if(p&&_.current){const e=_.current.updateScale(.1);p.scale.copy(e)}}));const x=(null===(h=_.current)||void 0===h?void 0:h.getPosition())||oB;return(0,s.jsx)("group",{position:x,children:(0,s.jsx)("primitive",{object:p})})})),NB=({chatEmission:e,url:t,sex:n,eyeBlink:r,halfBody:i,loading:o,avatarHeight:a=50,avatarDepth:l=-50,updateCurrentViseme:u,setCameraZ:d,headMovement:h,showControls:p})=>{const m=(0,c.useRef)(null),f=(0,c.useCallback)((e=>{e!==m.current&&(console.log("[AvatarView] Animator reference updated"),m.current=e)}),[]);(0,c.useEffect)((()=>{if(m.current)try{m.current.processChatEmission(e,o)}catch(e){console.error("Error processing chat emission:",e)}}),[o,e]);const g=(0,c.useCallback)((()=>({url:t,onCameraZChange:d,updateCurrentViseme:u,avatarHeight:a,avatarDepth:l,setAnimatorRef:f})),[t,d,u,a,l,f]);return(0,s.jsxs)(s.Fragment,{children:[i?(0,s.jsx)(PB,{...g(),eyeBlink:r,headMovement:h}):(0,s.jsx)(RB,{...g(),sex:n,eyeBlink:r,chatEmission:e,loading:o}),p&&m.current&&(0,s.jsx)("div",{className:"animation-controls"})]})};(0,c.memo)(NB),c=o("85Hg2");const OB={muteSpeaker:"@memori:muteSpeaker",microphoneMode:"@memori:microphoneMode",continuousSpeechTimeout:"@memori:continuousSpeechTimeout",birthDate:"@memori:birthDate",controlsPosition:"@memori:controlsPosition",hideEmissions:"@memori:hideEmissions",loginToken:"@memori:loginToken",location:"@memori:location"},DB=(e,t)=>{var n;try{const r=window.localStorage.getItem(null!==(n=OB[e])&&void 0!==n?n:e);if(!r)return t;try{return JSON.parse(r)}catch(e){return r}}catch(e){return console.error("error",e),t}},LB=(e,t)=>{var n;try{window.localStorage.setItem(null!==(n=OB[e])&&void 0!==n?n:e,t.toString())}catch(e){console.error("error",e)}},kB=e=>{var t;try{window.localStorage.removeItem(null!==(t=OB[e])&&void 0!==t?t:e)}catch(e){console.error("error",e)}};c=o("85Hg2"),c=o("85Hg2");var BB=(e=>(e[e.Open=0]="Open",e[e.Closed=1]="Closed",e))(BB||{}),zB=(e=>(e[e.Single=0]="Single",e[e.Multi=1]="Multi",e))(zB||{}),FB=(e=>(e[e.Pointer=0]="Pointer",e[e.Other=1]="Other",e))(FB||{}),UB=(e=>(e[e.OpenListbox=0]="OpenListbox",e[e.CloseListbox=1]="CloseListbox",e[e.SetDisabled=2]="SetDisabled",e[e.SetOrientation=3]="SetOrientation",e[e.GoToOption=4]="GoToOption",e[e.Search=5]="Search",e[e.ClearSearch=6]="ClearSearch",e[e.RegisterOption=7]="RegisterOption",e[e.UnregisterOption=8]="UnregisterOption",e))(UB||{});function jB(e,t=(e=>e)){let n=null!==e.activeOptionIndex?e.options[e.activeOptionIndex]:null,r=Op(t(e.options.slice()),(e=>e.dataRef.current.domRef.current)),i=n?r.indexOf(n):null;return-1===i&&(i=null),{options:r,activeOptionIndex:i}}let GB={1:e=>e.disabled||1===e.listboxState?e:{...e,activeOptionIndex:null,listboxState:1},0(e){if(e.disabled||0===e.listboxState)return e;let t=e.activeOptionIndex,{value:n,mode:r,compare:i}=e.propsRef.current,o=e.options.findIndex((e=>{let t=e.dataRef.current.value;return vh(r,{1:()=>n.some((e=>i(e,t))),0:()=>i(n,t)})}));return-1!==o&&(t=o),{...e,listboxState:0,activeOptionIndex:t}},2:(e,t)=>e.disabled===t.disabled?e:{...e,disabled:t.disabled},3:(e,t)=>e.orientation===t.orientation?e:{...e,orientation:t.orientation},4(e,t){var n;if(e.disabled||1===e.listboxState)return e;let r=jB(e),i=MR(t,{resolveItems:()=>r.options,resolveActiveIndex:()=>r.activeOptionIndex,resolveId:e=>e.id,resolveDisabled:e=>e.dataRef.current.disabled});return{...e,...r,searchQuery:"",activeOptionIndex:i,activationTrigger:null!=(n=t.trigger)?n:1}},5:(e,t)=>{if(e.disabled||1===e.listboxState)return e;let n=""!==e.searchQuery?0:1,r=e.searchQuery+t.value.toLowerCase(),i=(null!==e.activeOptionIndex?e.options.slice(e.activeOptionIndex+n).concat(e.options.slice(0,e.activeOptionIndex+n)):e.options).find((e=>{var t;return!e.dataRef.current.disabled&&(null==(t=e.dataRef.current.textValue)?void 0:t.startsWith(r))})),o=i?e.options.indexOf(i):-1;return-1===o||o===e.activeOptionIndex?{...e,searchQuery:r}:{...e,searchQuery:r,activeOptionIndex:o,activationTrigger:1}},6:e=>e.disabled||1===e.listboxState||""===e.searchQuery?e:{...e,searchQuery:""},7:(e,t)=>{let n={id:t.id,dataRef:t.dataRef},r=jB(e,(e=>[...e,n]));if(null===e.activeOptionIndex){let{value:i,mode:o,compare:s}=e.propsRef.current,a=t.dataRef.current.value;vh(o,{1:()=>i.some((e=>s(e,a))),0:()=>s(i,a)})&&(r.activeOptionIndex=r.options.indexOf(n))}return{...e,...r}},8:(e,t)=>{let n=jB(e,(e=>{let n=e.findIndex((e=>e.id===t.id));return-1!==n&&e.splice(n,1),e}));return{...e,...n,activationTrigger:1}}},HB=(0,c.createContext)(null);function VB(e){let t=(0,c.useContext)(HB);if(null===t){let t=new Error(`<${e} /> is missing a parent <Listbox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(t,VB),t}return t}function WB(e,t){return vh(t.type,GB,e,t)}HB.displayName="ListboxContext";let qB=c.Fragment,JB=wh((function(e,n){let{value:r,defaultValue:i,name:o,onChange:s,by:a=((e,t)=>e===t),disabled:l=!1,horizontal:u=!1,multiple:d=!1,...h}=e;const p=u?"horizontal":"vertical";let m=Uh(n),[f,g]=DR(r,s,i),v=(0,c.useReducer)(WB,{listboxState:1,propsRef:{current:{value:f,onChange:g,mode:d?1:0,compare:Bh("string"==typeof a?(e,t)=>{let n=a;return(null==e?void 0:e[n])===(null==t?void 0:t[n])}:a)}},labelRef:(0,c.createRef)(),buttonRef:(0,c.createRef)(),optionsRef:(0,c.createRef)(),disabled:l,orientation:p,options:[],searchQuery:"",activeOptionIndex:null,activationTrigger:1}),[{listboxState:y,propsRef:_,optionsRef:S,buttonRef:b},x]=v;_.current.value=f,_.current.mode=d?1:0,Nh((()=>{_.current.onChange=e=>vh(_.current.mode,{0:()=>g(e),1(){let t=_.current.value.slice(),{compare:n}=_.current,r=t.findIndex((t=>n(t,e)));return-1===r?t.push(e):t.splice(r,1),g(t)}})}),[g,_]),Nh((()=>x({type:2,disabled:l})),[l]),Nh((()=>x({type:3,orientation:p})),[p]),hm([b,S],((e,t)=>{var n;x({type:1}),Mp(t,Tp.Loose)||(e.preventDefault(),null==(n=b.current)||n.focus())}),0===y);let C=(0,c.useMemo)((()=>({open:0===y,disabled:l,value:f})),[y,l,f]),w={ref:m};return t(c).createElement(HB.Provider,{value:v},t(c).createElement(Rh,{value:vh(y,{0:Th.Open,1:Th.Closed})},null!=o&&null!=f&&RR({[o]:f}).map((([e,n])=>t(c).createElement(Sp,{features:_p.Hidden,...Ah({key:e,as:"input",type:"hidden",hidden:!0,readOnly:!0,name:e,value:n})}))),bh({ourProps:w,theirProps:h,slot:C,defaultTag:qB,name:"Listbox"})))})),KB=wh((function(e,t){var n;let[r,i]=VB("Listbox.Button"),o=Uh(r.buttonRef,t),s=`headlessui-listbox-button-${yp()}`,a=Yh(),l=Bh((e=>{switch(e.key){case pp.Space:case pp.Enter:case pp.ArrowDown:e.preventDefault(),i({type:0}),a.nextFrame((()=>{r.propsRef.current.value||i({type:4,focus:TR.First})}));break;case pp.ArrowUp:e.preventDefault(),i({type:0}),a.nextFrame((()=>{r.propsRef.current.value||i({type:4,focus:TR.Last})}))}})),u=Bh((e=>{if(e.key===pp.Space)e.preventDefault()})),d=Bh((e=>{if(mp(e.currentTarget))return e.preventDefault();0===r.listboxState?(i({type:1}),a.nextFrame((()=>{var e;return null==(e=r.buttonRef.current)?void 0:e.focus({preventScroll:!0})}))):(e.preventDefault(),i({type:0}))})),h=wR((()=>{if(r.labelRef.current)return[r.labelRef.current.id,s].join(" ")}),[r.labelRef.current,s]),p=(0,c.useMemo)((()=>({open:0===r.listboxState,disabled:r.disabled,value:r.propsRef.current.value})),[r]),m=e;return bh({ourProps:{ref:o,id:s,type:ER(e,r.buttonRef),"aria-haspopup":!0,"aria-controls":null==(n=r.optionsRef.current)?void 0:n.id,"aria-expanded":r.disabled?void 0:0===r.listboxState,"aria-labelledby":h,disabled:r.disabled,onKeyDown:l,onKeyUp:u,onClick:d},theirProps:m,slot:p,defaultTag:"button",name:"Listbox.Button"})})),YB=wh((function(e,t){let[n]=VB("Listbox.Label"),r=`headlessui-listbox-label-${yp()}`;return bh({ourProps:{ref:Uh(n.labelRef,t),id:r,onClick:Bh((()=>{var e;return null==(e=n.buttonRef.current)?void 0:e.focus({preventScroll:!0})}))},theirProps:e,slot:(0,c.useMemo)((()=>({open:0===n.listboxState,disabled:n.disabled})),[n]),defaultTag:"label",name:"Listbox.Label"})})),XB=_h.RenderStrategy|_h.Static,QB=wh((function(e,t){var n;let[r,i]=VB("Listbox.Options"),o=Uh(r.optionsRef,t),s=`headlessui-listbox-options-${yp()}`,a=Yh(),l=Yh(),u=Mh(),d=null!==u?u===Th.Open:0===r.listboxState;(0,c.useEffect)((()=>{var e;let t=r.optionsRef.current;!t||0===r.listboxState&&t!==(null==(e=bp(t))?void 0:e.activeElement)&&t.focus({preventScroll:!0})}),[r.listboxState,r.optionsRef]);let h=Bh((e=>{switch(l.dispose(),e.key){case pp.Space:if(""!==r.searchQuery)return e.preventDefault(),e.stopPropagation(),i({type:5,value:e.key});case pp.Enter:if(e.preventDefault(),e.stopPropagation(),null!==r.activeOptionIndex){let{dataRef:e}=r.options[r.activeOptionIndex];r.propsRef.current.onChange(e.current.value)}0===r.propsRef.current.mode&&(i({type:1}),Hh().nextFrame((()=>{var e;return null==(e=r.buttonRef.current)?void 0:e.focus({preventScroll:!0})})));break;case vh(r.orientation,{vertical:pp.ArrowDown,horizontal:pp.ArrowRight}):return e.preventDefault(),e.stopPropagation(),i({type:4,focus:TR.Next});case vh(r.orientation,{vertical:pp.ArrowUp,horizontal:pp.ArrowLeft}):return e.preventDefault(),e.stopPropagation(),i({type:4,focus:TR.Previous});case pp.Home:case pp.PageUp:return e.preventDefault(),e.stopPropagation(),i({type:4,focus:TR.First});case pp.End:case pp.PageDown:return e.preventDefault(),e.stopPropagation(),i({type:4,focus:TR.Last});case pp.Escape:return e.preventDefault(),e.stopPropagation(),i({type:1}),a.nextFrame((()=>{var e;return null==(e=r.buttonRef.current)?void 0:e.focus({preventScroll:!0})}));case pp.Tab:e.preventDefault(),e.stopPropagation();break;default:1===e.key.length&&(i({type:5,value:e.key}),l.setTimeout((()=>i({type:6})),350))}})),p=wR((()=>{var e,t,n;return null!=(n=null==(e=r.labelRef.current)?void 0:e.id)?n:null==(t=r.buttonRef.current)?void 0:t.id}),[r.labelRef.current,r.buttonRef.current]),m=(0,c.useMemo)((()=>({open:0===r.listboxState})),[r]),f=e;return bh({ourProps:{"aria-activedescendant":null===r.activeOptionIndex||null==(n=r.options[r.activeOptionIndex])?void 0:n.id,"aria-multiselectable":1===r.propsRef.current.mode||void 0,"aria-labelledby":p,"aria-orientation":r.orientation,id:s,onKeyDown:h,role:"listbox",tabIndex:0,ref:o},theirProps:f,slot:m,defaultTag:"ul",features:XB,visible:d,name:"Listbox.Options"})})),$B=wh((function(e,t){let{disabled:n=!1,value:r,...i}=e,[o,s]=VB("Listbox.Option"),a=`headlessui-listbox-option-${yp()}`,l=null!==o.activeOptionIndex&&o.options[o.activeOptionIndex].id===a,{value:u,compare:d}=o.propsRef.current,h=vh(o.propsRef.current.mode,{1:()=>u.some((e=>d(e,r))),0:()=>d(u,r)}),p=(0,c.useRef)(null),m=Uh(t,p);Nh((()=>{if(0!==o.listboxState||!l||0===o.activationTrigger)return;let e=Hh();return e.requestAnimationFrame((()=>{var e,t;null==(t=null==(e=p.current)?void 0:e.scrollIntoView)||t.call(e,{block:"nearest"})})),e.dispose}),[p,l,o.listboxState,o.activationTrigger,o.activeOptionIndex]);let f=(0,c.useRef)({disabled:n,value:r,domRef:p});Nh((()=>{f.current.disabled=n}),[f,n]),Nh((()=>{f.current.value=r}),[f,r]),Nh((()=>{var e,t;f.current.textValue=null==(t=null==(e=p.current)?void 0:e.textContent)?void 0:t.toLowerCase()}),[f,p]);let g=Bh((()=>o.propsRef.current.onChange(r)));Nh((()=>(s({type:7,id:a,dataRef:f}),()=>s({type:8,id:a}))),[f,a]);let v=Bh((e=>{if(n)return e.preventDefault();g(),0===o.propsRef.current.mode&&(s({type:1}),Hh().nextFrame((()=>{var e;return null==(e=o.buttonRef.current)?void 0:e.focus({preventScroll:!0})})))})),y=Bh((()=>{if(n)return s({type:4,focus:TR.Nothing});s({type:4,focus:TR.Specific,id:a})})),_=Bh((()=>{n||l||s({type:4,focus:TR.Specific,id:a,trigger:0})})),S=Bh((()=>{n||!l||s({type:4,focus:TR.Nothing})})),b=(0,c.useMemo)((()=>({active:l,selected:h,disabled:n})),[l,h,n]);return bh({ourProps:{id:a,ref:m,role:"option",tabIndex:!0===n?void 0:-1,"aria-disabled":!0===n||void 0,"aria-selected":h,disabled:void 0,onClick:v,onFocus:y,onPointerMove:_,onMouseMove:_,onPointerLeave:S,onMouseLeave:S},theirProps:i,slot:b,defaultTag:"li",name:"Listbox.Option"})})),ZB=Object.assign(JB,{Button:KB,Label:YB,Options:QB,Option:$B});var ez=({min:e=0,max:n=100,step:r=1,defaultValue:i=50,label:o,onChange:a,disabled:l=!1})=>{const[u,d]=(0,c.useState)(i),[h,p]=(0,c.useState)(!1),m=(0,c.useRef)(null),f=(u-e)/(n-e)*100,g=[];for(let t=e;t<=n;t+=(n-e)/4)g.push(Math.round(t));const v=t=>{if(!m.current)return u;const i=m.current.getBoundingClientRect(),o=t-i.left,s=i.width,a=Math.max(0,Math.min(100,o/s*100)),l=Math.round(a/100*(n-e)+e),c=Math.round(l/r)*r;return Math.min(Math.max(c,e),n)},y=e=>{if(l)return;p(!0);const t=v(e);d(t),null==a||a(t)},_=e=>{if(!h||l)return;const t=v(e);d(t),null==a||a(t)};return(0,c.useEffect)((()=>{const e=e=>{h&&(e.preventDefault(),_(e.touches[0].clientX))},t=e=>{_(e.clientX)},n=()=>{p(!1)};return h&&(window.addEventListener("touchmove",e,{passive:!1}),window.addEventListener("mousemove",t),window.addEventListener("touchend",n),window.addEventListener("mouseup",n)),()=>{window.removeEventListener("touchmove",e),window.removeEventListener("mousemove",t),window.removeEventListener("touchend",n),window.removeEventListener("mouseup",n)}}),[h]),(0,c.useEffect)((()=>{d(i)}),[i]),(0,s.jsxs)("div",{className:t(Is)("memori--slider-container",{"memori--slider-disabled":l}),style:{"--percentage":`${f}%`},children:[(0,s.jsxs)("div",{className:"memori--slider-header",children:[o&&(0,s.jsx)("div",{className:"memori--slider-label",children:o}),(0,s.jsx)("div",{className:"memori--slider-value",children:u})]}),(0,s.jsxs)("div",{ref:m,className:"memori--slider-track-container",onMouseDown:e=>y(e.clientX),onTouchStart:e=>y(e.touches[0].clientX),children:[(0,s.jsx)("div",{className:"memori--slider-track",children:(0,s.jsx)("div",{className:"memori--slider-track-fill"})}),(0,s.jsx)("div",{className:"memori--slider-marks",children:g.map((e=>(0,s.jsxs)("div",{className:"memori--slider-mark",children:[(0,s.jsx)("div",{className:"memori--slider-mark-line"}),(0,s.jsx)("span",{className:"memori--slider-mark-value",children:e})]},e)))}),(0,s.jsx)(ZB,{value:u,onChange:d,disabled:l,children:(0,s.jsx)("div",{className:"memori--slider-thumb",role:"slider","aria-valuemin":e,"aria-valuemax":n,"aria-valuenow":u,tabIndex:l?-1:0})})]})]})};var tz=({avatarHeight:e,avatarDepth:t,setAvatarHeight:n,setAvatarDepth:r,halfBody:i,setEnablePositionControls:o})=>{const a=i?{height:80,depth:50}:{height:25,depth:25},l=i?{height:55,depth:10}:{height:15,depth:5},u=i?{height:100,depth:80}:{height:65,depth:100},d=(0,c.useRef)({height:e,depth:t,zoomed:!1,normal:!1,far:!1}),{t:h}=Ie();return(0,c.useEffect)((()=>{d.current.height=e,d.current.depth=t}),[e,t]),(0,c.useEffect)((()=>{const e=e=>{if("-"===e.key||"_"===e.key&&d.current.depth<100){const e=Math.min(d.current.depth+10,100);r(e),LB("avatarDepth",e)}else if(("+"===e.key||"="===e.key)&&d.current.depth>-100){const e=Math.max(d.current.depth-10,-100);r(e),LB("avatarDepth",e)}};return window.addEventListener("keydown",e),()=>{window.removeEventListener("keydown",e)}}),[r]),(0,c.useEffect)((()=>{const e=e=>{if("ArrowUp"===e.key&&d.current.height<100){const e=d.current.height+5;n(e),LB("avatarHeight",e)}},t=e=>{if("ArrowDown"===e.key&&d.current.height>0){const e=d.current.height-5;n(e),LB("avatarHeight",e)}};return window.addEventListener("keydown",e),window.addEventListener("keydown",t),()=>{window.removeEventListener("keydown",e),window.removeEventListener("keydown",t)}}),[n]),(0,s.jsxs)("div",{className:"memori--position-controls",children:[(0,s.jsx)("div",{className:"memori--position-controls-close",children:(0,s.jsx)(Mm,{ghost:!0,icon:(0,s.jsx)(Rm,{}),outlined:!0,danger:!0,shape:"circle",className:"memori--position-controls-close-button",onClick:()=>{o(!1)}})}),(0,s.jsx)(ez,{defaultValue:d.current.height,min:.5,max:100,label:h("write_and_speak.height"),step:1,onChange:e=>{n(e),LB("avatarHeight",e)}}),(0,s.jsx)(ez,{defaultValue:d.current.depth,min:.5,max:100,step:5,label:h("write_and_speak.depth"),onChange:e=>{r(e),LB("avatarDepth",e)}}),(0,s.jsxs)("div",{className:"memori--preset-buttons",children:[(0,s.jsx)(Mm,{outlined:!0,isActive:e===(i?l.height:a.height)&&t===(i?l.depth:a.depth),onClick:()=>{n(l.height),r(l.depth),LB("avatarHeight",l.height),LB("avatarDepth",l.depth)},children:h("write_and_speak.zoomed")}),(0,s.jsx)(Mm,{outlined:!0,isActive:e===(i?a.height:l.height)&&t===(i?a.depth:l.depth),onClick:()=>{n(a.height),r(a.depth),LB("avatarHeight",a.height),LB("avatarDepth",a.depth)},children:h("write_and_speak.normal")}),(0,s.jsx)(Mm,{outlined:!0,isActive:e===(i?u.height:a.height)&&t===(i?u.depth:a.depth),onClick:()=>{n(u.height),r(u.depth),LB("avatarHeight",u.height),LB("avatarDepth",u.depth)},children:h("write_and_speak.far")})]})]})};let nz=0;const rz=t(FD)((e=>(xI.onStart=(t,n,r)=>{e({active:!0,item:t,loaded:n,total:r,progress:(n-nz)/(r-nz)*100})},xI.onLoad=()=>{e({active:!1})},xI.onError=t=>e((e=>({errors:[...e.errors,t]}))),xI.onProgress=(t,n,r)=>{n===r&&(nz=r),e({active:!0,item:t,loaded:n,total:r,progress:(n-nz)/(r-nz)*100||100})},{errors:[],active:!1,progress:0,item:"",loaded:0,total:0})));c=o("85Hg2");const iz=new u_,oz=new u_,sz=new u_;function az(e,t,n){const r=iz.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 lz=e=>Math.abs(e)<1e-10?0:e;function cz(e,t,n=""){let r="matrix3d(";for(let n=0;16!==n;n++)r+=lz(t[n]*e.elements[n])+(15!==n?",":")");return n+r}const uz=(dz=[1,-1,1,1,1,-1,1,1,1,-1,1,1,1,-1,1,1],e=>cz(e,dz));var dz;const hz=(e,t)=>{return cz(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},pz=c.forwardRef((({children:e,eps:t=.001,style:n,className:r,prepend:i,center:o,fullscreen:s,portal:l,distanceFactor:u,sprite:d=!1,transform:h=!1,occlude:p,onOcclude:m,zIndexRange:f=[16777271,0],calculatePosition:g=az,as:v="div",wrapperClass:y,pointerEvents:_="auto",...S},b)=>{var x;const C=IL((({gl:e})=>e)),w=IL((({camera:e})=>e)),A=IL((({scene:e})=>e)),E=IL((({size:e})=>e)),I=IL((({raycaster:e})=>e)),[T]=c.useState((()=>document.createElement(v))),M=c.useRef(null),R=c.useRef(0),P=c.useRef([0,0]),N=c.useRef(null),O=c.useRef(null),D=null!==(x=null==l?void 0:l.current)&&void 0!==x?x:C.domElement.parentNode;c.useEffect((()=>{if(M.current){if(A.updateMatrixWorld(),h)T.style.cssText="position:absolute;top:0;left:0;pointer-events:none;overflow:hidden;";else{const e=g(M.current,w,E);T.style.cssText=`position:absolute;top:0;left:0;transform:translate3d(${e[0]}px,${e[1]}px,0);transform-origin:0 0;`}return D&&(i?D.prepend(T):D.appendChild(T)),()=>{D&&D.removeChild(T),a.unmountComponentAtNode(T)}}}),[D,h]),c.useLayoutEffect((()=>{y&&(T.className=y)}),[y]);const L=c.useMemo((()=>h?{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",...s&&{top:-E.height/2,left:-E.width/2,width:E.width,height:E.height},...n}),[n,o,s,E,h]),k=c.useMemo((()=>({position:"absolute",pointerEvents:_})),[_]);c.useLayoutEffect((()=>{h?a.render(c.createElement("div",{ref:N,style:L},c.createElement("div",{ref:O,style:k},c.createElement("div",{ref:b,className:r,style:n,children:e}))),T):a.render(c.createElement("div",{ref:b,style:L,className:r,children:e}),T)}));const B=c.useRef(!0);return TL((()=>{if(M.current){w.updateMatrixWorld(),M.current.updateWorldMatrix(!0,!1);const e=h?P.current:g(M.current,w,E);if(h||Math.abs(R.current-w.zoom)>t||Math.abs(P.current[0]-e[0])>t||Math.abs(P.current[1]-e[1])>t){const t=function(e,t){const n=iz.setFromMatrixPosition(e.matrixWorld),r=oz.setFromMatrixPosition(t.matrixWorld),i=n.sub(r),o=t.getWorldDirection(sz);return i.angleTo(o)>Math.PI/2}(M.current,w);let n=!1;"boolean"==typeof p?!0===p&&(n=[A]):Array.isArray(p)&&(n=p.map((e=>e.current)));const r=B.current;if(n){const e=function(e,t,n,r){const i=iz.setFromMatrixPosition(e.matrixWorld),o=i.clone();o.project(t),n.setFromCamera(o,t);const s=n.intersectObjects(r,!0);if(s.length){const e=s[0].distance;return i.distanceTo(n.ray.origin)<e}return!0}(M.current,w,I,n);B.current=e&&!t}else B.current=!t;if(r!==B.current&&(m?m(!B.current):T.style.display=B.current?"block":"none"),T.style.zIndex=`${function(e,t,n){if(t instanceof _b||t instanceof Hb){const r=iz.setFromMatrixPosition(e.matrixWorld),i=oz.setFromMatrixPosition(t.matrixWorld),o=r.distanceTo(i),s=(n[1]-n[0])/(t.far-t.near),a=n[1]-s*t.far;return Math.round(s*o+a)}}(M.current,w,f)}`,h){const[e,t]=[E.width/2,E.height/2],n=w.projectionMatrix.elements[5]*t,{isOrthographicCamera:r,top:i,left:o,bottom:s,right:a}=w,l=uz(w.matrixWorldInverse),c=r?`scale(${n})translate(${lz(-(a+o)/2)}px,${lz((i+s)/2)}px)`:`translateZ(${n}px)`;let h=M.current.matrixWorld;d&&(h=w.matrixWorldInverse.clone().transpose().copyPosition(h).scale(M.current.scale),h.elements[3]=h.elements[7]=h.elements[11]=0,h.elements[15]=1),T.style.width=E.width+"px",T.style.height=E.height+"px",T.style.perspective=r?"":`${n}px`,N.current&&O.current&&(N.current.style.transform=`${c}${l}translate(${e}px,${t}px)`,O.current.style.transform=hz(h,1/((u||10)/400)))}else{const t=void 0===u?1:function(e,t){if(t instanceof Hb)return t.zoom;if(t instanceof _b){const n=iz.setFromMatrixPosition(e.matrixWorld),r=oz.setFromMatrixPosition(t.matrixWorld),i=t.fov*Math.PI/180,o=n.distanceTo(r);return 1/(2*Math.tan(i/2)*o)}return 1}(M.current,w)*u;T.style.transform=`translate3d(${e[0]}px,${e[1]}px,0) scale(${t})`}P.current=e,R.current=w.zoom}}})),c.createElement("group",UL({},S,{ref:M}))}));var mz=({fallbackImg:e})=>{const{progress:t}=rz();return(0,s.jsx)(pz,{center:!0,className:"avatar-loader",children:(0,s.jsx)(Tm,{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"]})})})};c=o("85Hg2");const fz=e=>{return t=Object.entries(e).filter((([e,t])=>void 0!==t)),Object.assign({},...t.map((([e,t])=>({[e]:t}))));var t},gz=Object.freeze({fillLightAngle:Math.PI/3,backLightAngle:Math.PI/8,keyLightAngle:Math.PI/2,silhouetteLightAngle:1.25*Math.PI,keyLightPosition:new u_(.75,1.75,.75),liftLightPosition:new u_(.25,1.5,2),dirLightPosition:new u_(-.75,2.5,-1),silhouetteLightPosition:new u_(-1.25,.25,-1.25),defaultProps:{keyLightIntensity:1.2,keyLightColor:"#FFF5EB",fillLightIntensity:2.5,fillLightColor:"#A4C4FF",fillLightPosition:new u_(-.6,1.7,-.4),backLightIntensity:4,backLightColor:"#FFD4A8",backLightPosition:new u_(.6,1.7,-1),lightTarget:new u_(0,1.65,0)}});var vz=e=>{const{keyLightIntensity:t,keyLightColor:n,fillLightIntensity:r,fillLightColor:i,fillLightPosition:o,backLightIntensity:a,backLightColor:l,backLightPosition:u,lightTarget:d}=Object.assign(gz.defaultProps,fz(e)),{scene:h}=IL(),[p]=(0,c.useState)({head:new hS,shoe:new hS});return(0,c.useEffect)((()=>(p.head.position.copy(d),p.shoe.position.set(0,.1,0),h.add(p.head),h.add(p.shoe),()=>{h.remove(p.head),h.remove(p.shoe)})),[h,p,d]),(0,s.jsxs)("group",{children:[(0,s.jsx)("spotLight",{position:o,target:p.head,angle:gz.fillLightAngle,color:i,intensity:r,castShadow:!0,"shadow-bias":-1e-4,penumbra:.2}),(0,s.jsx)("spotLight",{position:u,target:p.head,angle:gz.backLightAngle,color:l,intensity:a,castShadow:!0,"shadow-bias":-1e-4,penumbra:.2}),(0,s.jsx)("spotLight",{position:gz.keyLightPosition,target:p.head,angle:gz.keyLightAngle,color:n,intensity:t,penumbra:.3,castShadow:!0}),(0,s.jsx)("spotLight",{position:gz.liftLightPosition,target:p.shoe,angle:gz.keyLightAngle,color:n,intensity:.3*t,penumbra:.4}),(0,s.jsx)("spotLight",{position:gz.silhouetteLightPosition,target:p.head,angle:gz.silhouetteLightAngle,color:n,intensity:.3*t,penumbra:.3}),(0,s.jsx)("ambientLight",{intensity:.2,color:"#FFF8EF"})]})};const yz={halfBody:{width:"100%",height:"100%",minHeight:"500px",backgroundColor:"white",borderRadius:"100%"},fullBody:{width:"500px",height:"500px",backgroundColor:"white"}},_z=(e,t)=>({fov:t?44:40,position:[0,0,e?.6:3],target:[0,0,0]});function Sz({url:e,sex:t,style:n,rotateAvatar:r,eyeBlink:i,headMovement:o,speaking:a,fallback:l,fallbackImg:u,halfBody:d=!0,loading:h,showControls:p=!1,isZoomed:m,chatEmission:f,updateCurrentViseme:g,enablePositionControls:v,setEnablePositionControls:y,isTotem:_=!1}){const[S,b]=(0,c.useState)((()=>_z(d,m||!1).position[2])),[x,C]=(0,c.useState)((()=>{if(_){return DB("avatarHeight",50)}return d?80:m?16:65})()),[w,A]=(0,c.useState)((()=>{if(_){return DB("avatarDepth",50)}return d?50:m?5:100})());return(0,s.jsxs)(s.Fragment,{children:[v&&(0,s.jsx)(tz,{avatarHeight:x,avatarDepth:w,halfBody:d,setAvatarHeight:C,setAvatarDepth:A,setEnablePositionControls:y}),(0,s.jsxs)(AL,{style:n||yz.fullBody,shadows:!0,dpr:[1,2],gl:{antialias:!0,alpha:!0,powerPreference:"high-performance",stencil:!1},children:[(0,s.jsx)(KL,{makeDefault:!0,position:[0,0,S],fov:_z(d,m||!1).fov,near:.1,far:1e3}),r&&(0,s.jsx)(JL,{enablePan:!1,enableZoom:!1,target:[0,0,0],enableDamping:!0,dampingFactor:.05}),(0,s.jsxs)(c.Suspense,{fallback:l||(0,s.jsx)(mz,{fallbackImg:u}),children:[(0,s.jsx)(vz,{}),(0,s.jsx)(NB,{url:e,sex:t,showControls:p,loading:h||!1,eyeBlink:i||!1,headMovement:o||!1,speaking:a||!1,halfBody:d,chatEmission:f,updateCurrentViseme:g,setCameraZ:b,avatarHeight:x,avatarDepth:w})]})]})]})}const bz=(0,(c=o("85Hg2")).createContext)(void 0),xz={0:"viseme_sil",1:"viseme_PP",2:"viseme_FF",3:"viseme_TH",4:"viseme_DD",5:"viseme_kk",6:"viseme_CH",7:"viseme_SS",8:"viseme_nn",9:"viseme_RR",10:"viseme_aa",11:"viseme_E",12:"viseme_I",13:"viseme_O",14:"viseme_U",15:"viseme_kk",16:"viseme_CH",17:"viseme_SS",18:"viseme_TH",19:"viseme_RR",20:"viseme_kk",21:"viseme_PP"},{DEFAULT_VISEME_DURATION:Cz,VISEME_OVERLAP:wz,SMOOTHING_FACTOR:Az,LOG_INTERVAL:Ez,PRELOAD:Iz,WEIGHT_MULTIPLIER:Tz}={DEFAULT_VISEME_DURATION:.12,VISEME_OVERLAP:.02,SMOOTHING_FACTOR:.4,LOG_INTERVAL:60,PRELOAD:.2,WEIGHT_MULTIPLIER:.8},Mz=(e,t)=>e.endTime<t-wz,Rz=e=>Math.sin(Math.PI*Math.min(e,1))*Tz,Pz=(e,t)=>e+(t-e)*Az,Nz=({children:e})=>{const t=(0,c.useRef)([]),n=(0,c.useRef)(null),r=(0,c.useRef)(null),[i,o]=(0,c.useState)(!1),[a,l]=(0,c.useState)("idle"),u=(0,c.useRef)(null),d=(0,c.useRef)(0),h=(0,c.useRef)(null),p=(0,c.useCallback)((e=>{n.current=e,e.onstatechange=()=>{switch(e.state){case"running":l("active");break;case"suspended":l("paused");break;case"closed":l("finished"),g()}}}),[]),m=(0,c.useCallback)(((e,n)=>{if("finished"===a)return;const r=xz[e]||"viseme_sil",i=n/1e7;null===h.current&&(h.current=i);const o=i-(h.current||0),s={name:r,weight:0,startTime:o,endTime:o+Cz};t.current.push(s),"idle"===a&&l("preparing")}),[a]),f=(0,c.useCallback)((e=>{e&&(n.current=e,r.current=e.currentTime,d.current=0,o(!0),l("active"))}),[]),g=(0,c.useCallback)((()=>{o(!1),l("finished"),r.current=null,u.current=null,d.current=0,n.current=null}),[]),v=(0,c.useCallback)((e=>{if(!i||!n.current)return null;const o=n.current.currentTime-(r.current||0)+Iz;t.current=t.current.filter((e=>!Mz(e,o)));const s=t.current.find((e=>e.startTime<=o&&e.endTime>o-wz));if(s){const e=(o-s.startTime)/(s.endTime-s.startTime),t=Rz(e),n=u.current?Pz(u.current.weight,t):t,r={...s,weight:n};return u.current=r,r}if(u.current){const e=u.current.weight*(1-Az);u.current={...u.current,weight:e}}return u.current=null,null}),[i]),y=(0,c.useCallback)((()=>{t.current=[],u.current=null,r.current=null,h.current=null,d.current=0,l("idle")}),[a]),_=(0,c.useCallback)((e=>{g(),y(),f(e)}),[g,y,f,a]),S=(0,c.useMemo)((()=>({addViseme:m,updateCurrentViseme:v,startProcessing:f,stopProcessing:g,resetAndStartProcessing:_,resetVisemeQueue:y,isProcessing:i,setAudioContext:p})),[m,v,f,g,_,y,i,p]);return(0,s.jsx)(bz.Provider,{value:S,children:e})},Oz=()=>{const e=(0,c.useContext)(bz);if(!e)throw new Error("useVisemeContext must be used within a VisemeProvider");return e};var Dz=(0,c.memo)((({memori:e,integration:n,integrationConfig:r,tenant:i,instruct:o=!1,avatar3dVisible:a=!1,setAvatar3dVisible:l,hasUserActivatedSpeak:u=!1,isPlayingAudio:d=!1,loading:h=!1,baseUrl:p,apiUrl:m,animation:f,isZoomed:g=!1,chatProps:v,avatarType:y=null,enablePositionControls:_,setEnablePositionControls:S,isTotem:b=!1})=>{const{t:x}=Ie(),[C,w]=(0,c.useState)(!1),{stopProcessing:A,updateCurrentViseme:E,resetVisemeQueue:I}=Oz();(0,c.useEffect)((()=>{w(!0)}),[]);const T=()=>{if("userAvatar"===(null==r?void 0:r.avatar)&&e.avatarURL&&e.avatarURL.length>0)return RN({type:"avatar",tenantID:null==i?void 0:i.name,resourceURI:e.avatarURL,baseURL:p,apiURL:m})},M=()=>{var t;return C?"readyplayerme"===(null==r?void 0:r.avatar)||"readyplayerme-full"===(null==r?void 0:r.avatar)||"customrpm"===(null==r?void 0:r.avatar)?(0,s.jsx)(DD,{fallback:(0,s.jsx)("div",{className:"memori--blob-container",children:C&&(0,s.jsx)(LD,{speaking:d,avatar:T()})}),children:(0,s.jsx)(Sz,{enablePositionControls:_,updateCurrentViseme:E,url:r.avatarURL,sex:"FEMALE"===e.voiceType?"FEMALE":"MALE",fallbackImg:T(),headMovement:!0,eyeBlink:!0,animation:f,halfBody:"readyplayerme"===r.avatar,speaking:d,loading:h,style:P(),stopProcessing:A,resetVisemeQueue:I,isZoomed:g,isTotem:b,chatEmission:null===(t=null==v?void 0:v.dialogState)||void 0===t?void 0:t.emission,setEnablePositionControls:S})}):"customglb"===(null==r?void 0:r.avatar)?(0,s.jsx)(DO,{poster:T()||"",src:r.avatarURL,alt:""}):null:null},R=()=>(0,s.jsx)("div",{className:"memori--avatar-toggle",children:(0,s.jsx)(Mm,{ghost:!0,onClick:()=>l(!a),icon:a?(0,s.jsx)(BD,{}):(0,s.jsx)(kD,{}),children:(0,s.jsx)("span",{className:"memori--avatar-toggle-text",children:x(a?"hide":"show")})})}),P=()=>"readyplayerme"===(null==r?void 0:r.avatar)?{width:"100%",height:"100%",backgroundColor:"none",boxShadow:"none"}:{width:"100%",height:"100%",backgroundColor:"none"};return(0,s.jsxs)(s.Fragment,{children:[("readyplayerme"===(null==r?void 0:r.avatar)||"readyplayerme-full"===(null==r?void 0:r.avatar)||"customglb"===(null==r?void 0:r.avatar)||"customrpm"===(null==r?void 0:r.avatar))&&(null==r?void 0:r.avatarURL)&&y&&"blob"!==y?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:t(Is)("memori--avatar-wrapper",`memori--avatar-${(null==r?void 0:r.avatar)||"default"}`,{hidden:!a}),children:M()}),R()]}):(0,s.jsx)("div",{className:"memori--blob-container",children:C&&(0,s.jsx)(LD,{speaking:d,avatar:T()})}),(()=>{if(!o||u||!e.isGiver||!(null==i?void 0:i.name))return null;const t=`https://${i.name}/${"it-IT"===e.culture?"it":"en"}/${e.ownerUserName}/${e.name}/integrations${(null==n?void 0:n.integrationID)?`?integration=${n.integrationID}&openAvatarModal=true`:""}`;return(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:t,children:(0,s.jsx)(DN,{content:x("widgetgoToIntegrationsToCustomizeAvatar"),children:(0,s.jsx)("span",{className:"memori-button--icon",children:(0,s.jsx)(zD,{})})})})})})()]})}),((e,t)=>JSON.stringify(e)===JSON.stringify(t)));c=o("85Hg2");var Lz=({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 kz=({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"})});var Bz=({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"})});c=o("85Hg2");var zz=({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 Fz=({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 Uz=({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 jz=({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 Gz=({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 Hz=({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 Vz=({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 Wz,qz=({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"})}),Jz=(c=o("85Hg2"),Object.defineProperty),Kz=Object.getOwnPropertySymbols,Yz=Object.prototype.hasOwnProperty,Xz=Object.prototype.propertyIsEnumerable,Qz=(e,t,n)=>t in e?Jz(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,$z=(e,t)=>{for(var n in t||(t={}))Yz.call(t,n)&&Qz(e,n,t[n]);if(Kz)for(var n of Kz(t))Xz.call(t,n)&&Qz(e,n,t[n]);return e},Zz=(e,t)=>{var n={};for(var r in e)Yz.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&Kz)for(var r of Kz(e))t.indexOf(r)<0&&Xz.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 s=[];for(let e=0;e<this.size;e++)s.push(!1);for(let e=0;e<this.size;e++)this.modules.push(s.slice()),this.isFunction.push(s.slice());this.drawFunctionPatterns();const a=this.addEccAndInterleave(r);if(this.drawCodewords(a),-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,s=40,l=-1,c=!0){if(!(t.MIN_VERSION<=i&&i<=s&&s<=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=a.getTotalBits(e,u);if(i<=r){d=i;break}if(u>=s)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 h=[];for(const t of e){r(t.mode.modeBits,4,h),r(t.numChars,t.mode.numCharCountBits(u),h);for(const e of t.getData())h.push(e)}o(h.length==d);const p=8*t.getNumDataCodewords(u,n);o(h.length<=p),r(0,Math.min(4,p-h.length),h),r(0,(8-h.length%8)%8,h),o(h.length%8==0);for(let e=236;h.length<p;e^=253)r(e,8,h);let m=[];for(;8*m.length<h.length;)m.push(0);return h.forEach(((e,t)=>m[t>>>3]|=e<<7-(7&t))),new t(u,n,m,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,s=t+n;0<=o&&o<this.size&&0<=s&&s<this.size&&this.setFunctionModule(o,s,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],s=t.ECC_CODEWORDS_PER_BLOCK[r.ordinal][n],a=Math.floor(t.getNumRawDataModules(n)/8),l=i-a%i,c=Math.floor(a/i);let u=[];const d=t.reedSolomonComputeDivisor(s);for(let n=0,r=0;n<i;n++){let i=e.slice(r,r+c-s+(n<l?0:1));r+=i.length;const o=t.reedSolomonComputeRemainder(i,d);n<l&&i.push(0),u.push(i.concat(o))}let h=[];for(let e=0;e<u[0].length;e++)u.forEach(((t,n)=>{(e!=c-s||n>=l)&&h.push(t[e])}));return o(h.length==a),h}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 s=t-o,a=0==(t+1&2)?this.size-1-r:r;!this.isFunction[a][s]&&n<8*e.length&&(this.modules[a][s]=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 s=0;s<this.size;s++)this.modules[n][s]==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][s],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 s=0;s<this.size;s++)this.modules[s][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[s][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 s=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 s(s.Mode.BYTE,e.length,t)}static makeNumeric(e){if(!s.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 s(s.Mode.NUMERIC,e.length,t)}static makeAlphanumeric(e){if(!s.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*s.ALPHANUMERIC_CHARSET.indexOf(e.charAt(t));i+=s.ALPHANUMERIC_CHARSET.indexOf(e.charAt(t+1)),r(i,11,n)}return t<e.length&&r(s.ALPHANUMERIC_CHARSET.indexOf(e.charAt(t)),6,n),new s(s.Mode.ALPHANUMERIC,e.length,n)}static makeSegments(e){return""==e?[]:s.isNumeric(e)?[s.makeNumeric(e)]:s.isAlphanumeric(e)?[s.makeAlphanumeric(e)]:[s.makeBytes(s.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 s(s.Mode.ECI,0,t)}static isNumeric(e){return s.NUMERIC_REGEX.test(e)}static isAlphanumeric(e){return s.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 a=s;a.NUMERIC_REGEX=/^[0-9]*$/,a.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,a.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:",e.QrSegment=a})(Wz||(Wz={})),(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={}))})(Wz||(Wz={})),(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={}))})(Wz||(Wz={}));var eF=Wz,tF={L:eF.QrCode.Ecc.LOW,M:eF.QrCode.Ecc.MEDIUM,Q:eF.QrCode.Ecc.QUARTILE,H:eF.QrCode.Ecc.HIGH},nF=128,rF="L",iF="#FFFFFF",oF="#000000",sF=!1;
|
|
245
|
+
/*! @license DOMPurify 3.2.1 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.1/LICENSE */aO=function(){"use strict";const{entries:e,setPrototypeOf:t,isFrozen:n,getPrototypeOf:r,getOwnPropertyDescriptor:i}=Object;let{freeze:o,seal:s,create:a}=Object,{apply:l,construct:c}="undefined"!=typeof Reflect&&Reflect;o||(o=function(e){return e}),s||(s=function(e){return e}),l||(l=function(e,t,n){return e.apply(t,n)}),c||(c=function(e,t){return new e(...t)});const u=x(Array.prototype.forEach),d=x(Array.prototype.pop),h=x(Array.prototype.push),p=x(String.prototype.toLowerCase),m=x(String.prototype.toString),f=x(String.prototype.match),g=x(String.prototype.replace),v=x(String.prototype.indexOf),y=x(String.prototype.trim),_=x(Object.prototype.hasOwnProperty),S=x(RegExp.prototype.test),b=C(TypeError);function x(e){return 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];return l(e,t,r)}}function C(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return c(e,n)}}function w(e,r){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:p;t&&t(e,null);let o=r.length;for(;o--;){let t=r[o];if("string"==typeof t){const e=i(t);e!==t&&(n(r)||(r[o]=e),t=e)}e[t]=!0}return e}function A(e){for(let t=0;t<e.length;t++)_(e,t)||(e[t]=null);return e}function E(t){const n=a(null);for(const[r,i]of e(t))_(t,r)&&(Array.isArray(i)?n[r]=A(i):i&&"object"==typeof i&&i.constructor===Object?n[r]=E(i):n[r]=i);return n}function I(e,t){for(;null!==e;){const n=i(e,t);if(n){if(n.get)return x(n.get);if("function"==typeof n.value)return x(n.value)}e=r(e)}function n(){return null}return n}const T=o(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","shadow","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),M=o(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),R=o(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),P=o(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),N=o(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),O=o(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),D=o(["#text"]),L=o(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","face","for","headers","height","hidden","high","href","hreflang","id","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),k=o(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),B=o(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),z=o(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),F=s(/\{\{[\w\W]*|[\w\W]*\}\}/gm),U=s(/<%[\w\W]*|[\w\W]*%>/gm),j=s(/\${[\w\W]*}/gm),G=s(/^data-[\-\w.\u00B7-\uFFFF]/),H=s(/^aria-[\-\w]+$/),V=s(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),W=s(/^(?:\w+script|data):/i),q=s(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),J=s(/^html$/i),K=s(/^[a-z][.\w]*(-[.\w]+)+$/i);var Y=Object.freeze({__proto__:null,ARIA_ATTR:H,ATTR_WHITESPACE:q,CUSTOM_ELEMENT:K,DATA_ATTR:G,DOCTYPE_NAME:J,ERB_EXPR:U,IS_ALLOWED_URI:V,IS_SCRIPT_OR_DATA:W,MUSTACHE_EXPR:F,TMPLIT_EXPR:j});const X={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,progressingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Q=function(){return"undefined"==typeof window?null:window},$=function(e,t){if("object"!=typeof e||"function"!=typeof e.createPolicy)return null;let n=null;const r="data-tt-policy-suffix";t&&t.hasAttribute(r)&&(n=t.getAttribute(r));const i="dompurify"+(n?"#"+n:"");try{return e.createPolicy(i,{createHTML:e=>e,createScriptURL:e=>e})}catch(e){return console.warn("TrustedTypes policy "+i+" could not be created."),null}};function Z(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Q();const n=e=>Z(e);if(n.version="3.2.1",n.removed=[],!t||!t.document||t.document.nodeType!==X.document)return n.isSupported=!1,n;let{document:r}=t;const i=r,s=i.currentScript,{DocumentFragment:l,HTMLTemplateElement:c,Node:x,Element:C,NodeFilter:A,NamedNodeMap:F=t.NamedNodeMap||t.MozNamedAttrMap,HTMLFormElement:U,DOMParser:j,trustedTypes:G}=t,H=C.prototype,W=I(H,"cloneNode"),q=I(H,"remove"),K=I(H,"nextSibling"),ee=I(H,"childNodes"),te=I(H,"parentNode");if("function"==typeof c){const e=r.createElement("template");e.content&&e.content.ownerDocument&&(r=e.content.ownerDocument)}let ne,re="";const{implementation:ie,createNodeIterator:oe,createDocumentFragment:se,getElementsByTagName:ae}=r,{importNode:le}=i;let ce={};n.isSupported="function"==typeof e&&"function"==typeof te&&ie&&void 0!==ie.createHTMLDocument;const{MUSTACHE_EXPR:ue,ERB_EXPR:de,TMPLIT_EXPR:he,DATA_ATTR:pe,ARIA_ATTR:me,IS_SCRIPT_OR_DATA:fe,ATTR_WHITESPACE:ge,CUSTOM_ELEMENT:ve}=Y;let{IS_ALLOWED_URI:ye}=Y,_e=null;const Se=w({},[...T,...M,...R,...N,...D]);let be=null;const xe=w({},[...L,...k,...B,...z]);let Ce=Object.seal(a(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),we=null,Ae=null,Ee=!0,Ie=!0,Te=!1,Me=!0,Re=!1,Pe=!0,Ne=!1,Oe=!1,De=!1,Le=!1,ke=!1,Be=!1,ze=!0,Fe=!1;const Ue="user-content-";let je=!0,Ge=!1,He={},Ve=null;const We=w({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let qe=null;const Je=w({},["audio","video","img","source","image","track"]);let Ke=null;const Ye=w({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Xe="http://www.w3.org/1998/Math/MathML",Qe="http://www.w3.org/2000/svg",$e="http://www.w3.org/1999/xhtml";let Ze=$e,et=!1,tt=null;const nt=w({},[Xe,Qe,$e],m);let rt=w({},["mi","mo","mn","ms","mtext"]),it=w({},["annotation-xml"]);const ot=w({},["title","style","font","a","script"]);let st=null;const at=["application/xhtml+xml","text/html"],lt="text/html";let ct=null,ut=null;const dt=r.createElement("form"),ht=function(e){return e instanceof RegExp||e instanceof Function},pt=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!ut||ut!==e){if(e&&"object"==typeof e||(e={}),e=E(e),st=-1===at.indexOf(e.PARSER_MEDIA_TYPE)?lt:e.PARSER_MEDIA_TYPE,ct="application/xhtml+xml"===st?m:p,_e=_(e,"ALLOWED_TAGS")?w({},e.ALLOWED_TAGS,ct):Se,be=_(e,"ALLOWED_ATTR")?w({},e.ALLOWED_ATTR,ct):xe,tt=_(e,"ALLOWED_NAMESPACES")?w({},e.ALLOWED_NAMESPACES,m):nt,Ke=_(e,"ADD_URI_SAFE_ATTR")?w(E(Ye),e.ADD_URI_SAFE_ATTR,ct):Ye,qe=_(e,"ADD_DATA_URI_TAGS")?w(E(Je),e.ADD_DATA_URI_TAGS,ct):Je,Ve=_(e,"FORBID_CONTENTS")?w({},e.FORBID_CONTENTS,ct):We,we=_(e,"FORBID_TAGS")?w({},e.FORBID_TAGS,ct):{},Ae=_(e,"FORBID_ATTR")?w({},e.FORBID_ATTR,ct):{},He=!!_(e,"USE_PROFILES")&&e.USE_PROFILES,Ee=!1!==e.ALLOW_ARIA_ATTR,Ie=!1!==e.ALLOW_DATA_ATTR,Te=e.ALLOW_UNKNOWN_PROTOCOLS||!1,Me=!1!==e.ALLOW_SELF_CLOSE_IN_ATTR,Re=e.SAFE_FOR_TEMPLATES||!1,Pe=!1!==e.SAFE_FOR_XML,Ne=e.WHOLE_DOCUMENT||!1,Le=e.RETURN_DOM||!1,ke=e.RETURN_DOM_FRAGMENT||!1,Be=e.RETURN_TRUSTED_TYPE||!1,De=e.FORCE_BODY||!1,ze=!1!==e.SANITIZE_DOM,Fe=e.SANITIZE_NAMED_PROPS||!1,je=!1!==e.KEEP_CONTENT,Ge=e.IN_PLACE||!1,ye=e.ALLOWED_URI_REGEXP||V,Ze=e.NAMESPACE||$e,rt=e.MATHML_TEXT_INTEGRATION_POINTS||rt,it=e.HTML_INTEGRATION_POINTS||it,Ce=e.CUSTOM_ELEMENT_HANDLING||{},e.CUSTOM_ELEMENT_HANDLING&&ht(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(Ce.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&&ht(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(Ce.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(Ce.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Re&&(Ie=!1),ke&&(Le=!0),He&&(_e=w({},D),be=[],!0===He.html&&(w(_e,T),w(be,L)),!0===He.svg&&(w(_e,M),w(be,k),w(be,z)),!0===He.svgFilters&&(w(_e,R),w(be,k),w(be,z)),!0===He.mathMl&&(w(_e,N),w(be,B),w(be,z))),e.ADD_TAGS&&(_e===Se&&(_e=E(_e)),w(_e,e.ADD_TAGS,ct)),e.ADD_ATTR&&(be===xe&&(be=E(be)),w(be,e.ADD_ATTR,ct)),e.ADD_URI_SAFE_ATTR&&w(Ke,e.ADD_URI_SAFE_ATTR,ct),e.FORBID_CONTENTS&&(Ve===We&&(Ve=E(Ve)),w(Ve,e.FORBID_CONTENTS,ct)),je&&(_e["#text"]=!0),Ne&&w(_e,["html","head","body"]),_e.table&&(w(_e,["tbody"]),delete we.tbody),e.TRUSTED_TYPES_POLICY){if("function"!=typeof e.TRUSTED_TYPES_POLICY.createHTML)throw b('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof e.TRUSTED_TYPES_POLICY.createScriptURL)throw b('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');ne=e.TRUSTED_TYPES_POLICY,re=ne.createHTML("")}else void 0===ne&&(ne=$(G,s)),null!==ne&&"string"==typeof re&&(re=ne.createHTML(""));o&&o(e),ut=e}},mt=w({},[...M,...R,...P]),ft=w({},[...N,...O]),gt=function(e){let t=te(e);t&&t.tagName||(t={namespaceURI:Ze,tagName:"template"});const n=p(e.tagName),r=p(t.tagName);return!!tt[e.namespaceURI]&&(e.namespaceURI===Qe?t.namespaceURI===$e?"svg"===n:t.namespaceURI===Xe?"svg"===n&&("annotation-xml"===r||rt[r]):Boolean(mt[n]):e.namespaceURI===Xe?t.namespaceURI===$e?"math"===n:t.namespaceURI===Qe?"math"===n&&it[r]:Boolean(ft[n]):e.namespaceURI===$e?!(t.namespaceURI===Qe&&!it[r])&&!(t.namespaceURI===Xe&&!rt[r])&&!ft[n]&&(ot[n]||!mt[n]):!("application/xhtml+xml"!==st||!tt[e.namespaceURI]))},vt=function(e){h(n.removed,{element:e});try{te(e).removeChild(e)}catch(t){q(e)}},yt=function(e,t){try{h(n.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){h(n.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e&&!be[e])if(Le||ke)try{vt(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}},_t=function(e){let t=null,n=null;if(De)e="<remove></remove>"+e;else{const t=f(e,/^[\r\n\t ]+/);n=t&&t[0]}"application/xhtml+xml"===st&&Ze===$e&&(e='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+e+"</body></html>");const i=ne?ne.createHTML(e):e;if(Ze===$e)try{t=(new j).parseFromString(i,st)}catch(e){}if(!t||!t.documentElement){t=ie.createDocument(Ze,"template",null);try{t.documentElement.innerHTML=et?re:i}catch(e){}}const o=t.body||t.documentElement;return e&&n&&o.insertBefore(r.createTextNode(n),o.childNodes[0]||null),Ze===$e?ae.call(t,Ne?"html":"body")[0]:Ne?t.documentElement:o},St=function(e){return oe.call(e.ownerDocument||e,e,A.SHOW_ELEMENT|A.SHOW_COMMENT|A.SHOW_TEXT|A.SHOW_PROCESSING_INSTRUCTION|A.SHOW_CDATA_SECTION,null)},bt=function(e){return e instanceof U&&("string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||!(e.attributes instanceof F)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore||"function"!=typeof e.hasChildNodes)},xt=function(e){return"function"==typeof x&&e instanceof x};function Ct(e,t,r){ce[e]&&u(ce[e],(e=>{e.call(n,t,r,ut)}))}const wt=function(e){let t=null;if(Ct("beforeSanitizeElements",e,null),bt(e))return vt(e),!0;const r=ct(e.nodeName);if(Ct("uponSanitizeElement",e,{tagName:r,allowedTags:_e}),e.hasChildNodes()&&!xt(e.firstElementChild)&&S(/<[/\w]/g,e.innerHTML)&&S(/<[/\w]/g,e.textContent))return vt(e),!0;if(e.nodeType===X.progressingInstruction)return vt(e),!0;if(Pe&&e.nodeType===X.comment&&S(/<[/\w]/g,e.data))return vt(e),!0;if(!_e[r]||we[r]){if(!we[r]&&Et(r)){if(Ce.tagNameCheck instanceof RegExp&&S(Ce.tagNameCheck,r))return!1;if(Ce.tagNameCheck instanceof Function&&Ce.tagNameCheck(r))return!1}if(je&&!Ve[r]){const t=te(e)||e.parentNode,n=ee(e)||e.childNodes;if(n&&t)for(let r=n.length-1;r>=0;--r){const i=W(n[r],!0);i.__removalCount=(e.__removalCount||0)+1,t.insertBefore(i,K(e))}}return vt(e),!0}return e instanceof C&&!gt(e)?(vt(e),!0):"noscript"!==r&&"noembed"!==r&&"noframes"!==r||!S(/<\/no(script|embed|frames)/i,e.innerHTML)?(Re&&e.nodeType===X.text&&(t=e.textContent,u([ue,de,he],(e=>{t=g(t,e," ")})),e.textContent!==t&&(h(n.removed,{element:e.cloneNode()}),e.textContent=t)),Ct("afterSanitizeElements",e,null),!1):(vt(e),!0)},At=function(e,t,n){if(ze&&("id"===t||"name"===t)&&(n in r||n in dt))return!1;if(Ie&&!Ae[t]&&S(pe,t));else if(Ee&&S(me,t));else if(!be[t]||Ae[t]){if(!(Et(e)&&(Ce.tagNameCheck instanceof RegExp&&S(Ce.tagNameCheck,e)||Ce.tagNameCheck instanceof Function&&Ce.tagNameCheck(e))&&(Ce.attributeNameCheck instanceof RegExp&&S(Ce.attributeNameCheck,t)||Ce.attributeNameCheck instanceof Function&&Ce.attributeNameCheck(t))||"is"===t&&Ce.allowCustomizedBuiltInElements&&(Ce.tagNameCheck instanceof RegExp&&S(Ce.tagNameCheck,n)||Ce.tagNameCheck instanceof Function&&Ce.tagNameCheck(n))))return!1}else if(Ke[t]);else if(S(ye,g(n,ge,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==v(n,"data:")||!qe[e])if(Te&&!S(fe,g(n,ge,"")));else if(n)return!1;return!0},Et=function(e){return"annotation-xml"!==e&&f(e,ve)},It=function(e){Ct("beforeSanitizeAttributes",e,null);const{attributes:t}=e;if(!t)return;const r={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:be,forceKeepAttr:void 0};let i=t.length;for(;i--;){const o=t[i],{name:s,namespaceURI:a,value:l}=o,c=ct(s);let h="value"===s?l:y(l);if(r.attrName=c,r.attrValue=h,r.keepAttr=!0,r.forceKeepAttr=void 0,Ct("uponSanitizeAttribute",e,r),h=r.attrValue,!Fe||"id"!==c&&"name"!==c||(yt(s,e),h=Ue+h),Pe&&S(/((--!?|])>)|<\/(style|title)/i,h)){yt(s,e);continue}if(r.forceKeepAttr)continue;if(yt(s,e),!r.keepAttr)continue;if(!Me&&S(/\/>/i,h)){yt(s,e);continue}Re&&u([ue,de,he],(e=>{h=g(h,e," ")}));const p=ct(e.nodeName);if(At(p,c,h)){if(ne&&"object"==typeof G&&"function"==typeof G.getAttributeType)if(a);else switch(G.getAttributeType(p,c)){case"TrustedHTML":h=ne.createHTML(h);break;case"TrustedScriptURL":h=ne.createScriptURL(h)}try{a?e.setAttributeNS(a,s,h):e.setAttribute(s,h),bt(e)?vt(e):d(n.removed)}catch(e){}}}Ct("afterSanitizeAttributes",e,null)},Tt=function e(t){let n=null;const r=St(t);for(Ct("beforeSanitizeShadowDOM",t,null);n=r.nextNode();)Ct("uponSanitizeShadowNode",n,null),wt(n)||(n.content instanceof l&&e(n.content),It(n));Ct("afterSanitizeShadowDOM",t,null)};return n.sanitize=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=null,o=null,s=null,a=null;if(et=!e,et&&(e="\x3c!--\x3e"),"string"!=typeof e&&!xt(e)){if("function"!=typeof e.toString)throw b("toString is not a function");if("string"!=typeof(e=e.toString()))throw b("dirty is not a string, aborting")}if(!n.isSupported)return e;if(Oe||pt(t),n.removed=[],"string"==typeof e&&(Ge=!1),Ge){if(e.nodeName){const t=ct(e.nodeName);if(!_e[t]||we[t])throw b("root node is forbidden and cannot be sanitized in-place")}}else if(e instanceof x)r=_t("\x3c!----\x3e"),o=r.ownerDocument.importNode(e,!0),o.nodeType===X.element&&"BODY"===o.nodeName||"HTML"===o.nodeName?r=o:r.appendChild(o);else{if(!Le&&!Re&&!Ne&&-1===e.indexOf("<"))return ne&&Be?ne.createHTML(e):e;if(r=_t(e),!r)return Le?null:Be?re:""}r&&De&&vt(r.firstChild);const c=St(Ge?e:r);for(;s=c.nextNode();)wt(s)||(s.content instanceof l&&Tt(s.content),It(s));if(Ge)return e;if(Le){if(ke)for(a=se.call(r.ownerDocument);r.firstChild;)a.appendChild(r.firstChild);else a=r;return(be.shadowroot||be.shadowrootmode)&&(a=le.call(i,a,!0)),a}let d=Ne?r.outerHTML:r.innerHTML;return Ne&&_e["!doctype"]&&r.ownerDocument&&r.ownerDocument.doctype&&r.ownerDocument.doctype.name&&S(J,r.ownerDocument.doctype.name)&&(d="<!DOCTYPE "+r.ownerDocument.doctype.name+">\n"+d),Re&&u([ue,de,he],(e=>{d=g(d,e," ")})),ne&&Be?ne.createHTML(d):d},n.setConfig=function(){pt(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),Oe=!0},n.clearConfig=function(){ut=null,Oe=!1},n.isValidAttribute=function(e,t,n){ut||pt({});const r=ct(e),i=ct(t);return At(r,i,n)},n.addHook=function(e,t){"function"==typeof t&&(ce[e]=ce[e]||[],h(ce[e],t))},n.removeHook=function(e){if(ce[e])return d(ce[e])},n.removeHooks=function(e){ce[e]&&(ce[e]=[])},n.removeAllHooks=function(){ce={}},n}return Z()}();const lO=[{value:"IT",label:"Italiano"},{value:"EN",label:"English"},{value:"DE",label:"Deutsch"},{value:"ES",label:"Español"},{value:"FR",label:"Français"},{value:"PT",label:"Português"},{value:"UK",label:"Українська"},{value:"RU",label:"Русский"},{value:"PL",label:"Polski"},{value:"FI",label:"Suomi"},{value:"EL",label:"Ελληνικά"},{value:"AR",label:"العربية"},{value:"ZH",label:"中文"},{value:"JA",label:"日本語"}],cO=["en","it","fr","es","de"],uO=["image/jpeg","image/png","image/jpg","image/gif","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/pdf","video/mp4","video/avi","audio/mpeg3","audio/wav","audio/mpeg","video/mpeg","model/gltf-binary"],dO="👤",hO=[{name:"text",lang:"text",mimeType:"text/plain",monacoLang:"plaintext",executable:!0},{name:"javascript/jsx",lang:"jsx",mimeType:"text/javascript",monacoLang:"javascript",executable:!0},{name:"typescript/tsx",lang:"tsx",mimeType:"text/ecmascript",monacoLang:"typescript",executable:!0},{name:"json",lang:"json",mimeType:"application/json",monacoLang:"json",executable:!0},{name:"css",lang:"scss",mimeType:"text/css",monacoLang:"css",executable:!0},{name:"html/xml",lang:"tsx",mimeType:"application/xml",monacoLang:"xml"},{name:"bash",lang:"bash",mimeType:"application/x-sh",monacoLang:"shell"},{name:"python",lang:"python",mimeType:"text/x-python",monacoLang:"python"},{name:"cpp/csharp",lang:"cpp",mimeType:"text/x-c++src",monacoLang:"cpp"},{name:"php",lang:"php",mimeType:"application/x-php",monacoLang:"php"},{name:"ruby",lang:"ruby",mimeType:"text/x-ruby",monacoLang:"ruby"},{name:"sql",lang:"sql",mimeType:"text/x-sql",monacoLang:"sql"}],pO={it:[{text:"",delayAfter:10},{text:"Cerco l'esperto più adatto",delayAfter:5},{text:"Contatto l'esperto",delayAfter:3},{text:"Spiego all'esperto la domanda",delayAfter:2},{text:"L'esperto sta preparando una risposta",delayAfter:6},{text:"Genero una risposta adatta",delayAfter:3}],en:[{text:"",delayAfter:10},{text:"I'm looking for the most suitable expert",delayAfter:5},{text:"I'm contacting the expert",delayAfter:3},{text:"I'm explaining the question to the expert",delayAfter:2},{text:"The expert is preparing an answer",delayAfter:6},{text:"I am generating a suitable answer",delayAfter:3}]},mO=4e3,fO=300;var gO={};gO=function(){"use strict";var e=/[\0-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,t=/[\0-\x1F\x7F-\x9F]/,n=/[!-#%-\*,-\/:;\?@\[-\]_\{\}\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061D-\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1B7D\u1B7E\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u2E52-\u2E5D\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD803[\uDEAD\uDF55-\uDF59\uDF86-\uDF89]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDC4B-\uDC4F\uDC5A\uDC5B\uDC5D\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDE60-\uDE6C\uDEB9\uDF3C-\uDF3E]|\uD806[\uDC3B\uDD44-\uDD46\uDDE2\uDE3F-\uDE46\uDE9A-\uDE9C\uDE9E-\uDEA2\uDF00-\uDF09]|\uD807[\uDC41-\uDC45\uDC70\uDC71\uDEF7\uDEF8\uDF43-\uDF4F\uDFFF]|\uD809[\uDC70-\uDC74]|\uD80B[\uDFF1\uDFF2]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD81B[\uDE97-\uDE9A\uDFE2]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]|\uD83A[\uDD5E\uDD5F]/,r=/[ \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/;function i(i){const o={};i=i||{},o.src_Any=e.source,o.src_Cc=t.source,o.src_Z=r.source,o.src_P=n.source,o.src_ZPCc=[o.src_Z,o.src_P,o.src_Cc].join("|"),o.src_ZCc=[o.src_Z,o.src_Cc].join("|");const s="[><|]";return o.src_pseudo_letter="(?:(?!"+s+"|"+o.src_ZPCc+")"+o.src_Any+")",o.src_ip4="(?:(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)",o.src_auth="(?:(?:(?!"+o.src_ZCc+"|[@/\\[\\]()]).)+@)?",o.src_port="(?::(?:6(?:[0-4]\\d{3}|5(?:[0-4]\\d{2}|5(?:[0-2]\\d|3[0-5])))|[1-5]?\\d{1,4}))?",o.src_host_terminator="(?=$|"+s+"|"+o.src_ZPCc+")(?!"+(i["---"]?"-(?!--)|":"-|")+"_|:\\d|\\.-|\\.(?!$|"+o.src_ZPCc+"))",o.src_path="(?:[/?#](?:(?!"+o.src_ZCc+"|"+s+"|[()[\\]{}.,\"'?!\\-;]).|\\[(?:(?!"+o.src_ZCc+"|\\]).)*\\]|\\((?:(?!"+o.src_ZCc+"|[)]).)*\\)|\\{(?:(?!"+o.src_ZCc+'|[}]).)*\\}|\\"(?:(?!'+o.src_ZCc+'|["]).)+\\"|\\\'(?:(?!'+o.src_ZCc+"|[']).)+\\'|\\'(?="+o.src_pseudo_letter+"|[-])|\\.{2,}[a-zA-Z0-9%/&]|\\.(?!"+o.src_ZCc+"|[.]|$)|"+(i["---"]?"\\-(?!--(?:[^-]|$))(?:-*)|":"\\-+|")+",(?!"+o.src_ZCc+"|$)|;(?!"+o.src_ZCc+"|$)|\\!+(?!"+o.src_ZCc+"|[!]|$)|\\?(?!"+o.src_ZCc+"|[?]|$))+|\\/)?",o.src_email_name='[\\-;:&=\\+\\$,\\.a-zA-Z0-9_][\\-;:&=\\+\\$,\\"\\.a-zA-Z0-9_]*',o.src_xn="xn--[a-z0-9\\-]{1,59}",o.src_domain_root="(?:"+o.src_xn+"|"+o.src_pseudo_letter+"{1,63})",o.src_domain="(?:"+o.src_xn+"|(?:"+o.src_pseudo_letter+")|(?:"+o.src_pseudo_letter+"(?:-|"+o.src_pseudo_letter+"){0,61}"+o.src_pseudo_letter+"))",o.src_host="(?:(?:(?:(?:"+o.src_domain+")\\.)*"+o.src_domain+"))",o.tpl_host_fuzzy="(?:"+o.src_ip4+"|(?:(?:(?:"+o.src_domain+")\\.)+(?:%TLDS%)))",o.tpl_host_no_ip_fuzzy="(?:(?:(?:"+o.src_domain+")\\.)+(?:%TLDS%))",o.src_host_strict=o.src_host+o.src_host_terminator,o.tpl_host_fuzzy_strict=o.tpl_host_fuzzy+o.src_host_terminator,o.src_host_port_strict=o.src_host+o.src_port+o.src_host_terminator,o.tpl_host_port_fuzzy_strict=o.tpl_host_fuzzy+o.src_port+o.src_host_terminator,o.tpl_host_port_no_ip_fuzzy_strict=o.tpl_host_no_ip_fuzzy+o.src_port+o.src_host_terminator,o.tpl_host_fuzzy_test="localhost|www\\.|\\.\\d{1,3}\\.|(?:\\.(?:%TLDS%)(?:"+o.src_ZPCc+"|>|$))",o.tpl_email_fuzzy="(^|"+s+'|"|\\(|'+o.src_ZCc+")("+o.src_email_name+"@"+o.tpl_host_fuzzy_strict+")",o.tpl_link_fuzzy="(^|(?![.:/\\-_@])(?:[$+<=>^`||]|"+o.src_ZPCc+"))((?![$+<=>^`||])"+o.tpl_host_port_fuzzy_strict+o.src_path+")",o.tpl_link_no_ip_fuzzy="(^|(?![.:/\\-_@])(?:[$+<=>^`||]|"+o.src_ZPCc+"))((?![$+<=>^`||])"+o.tpl_host_port_no_ip_fuzzy_strict+o.src_path+")",o}function o(e){return Array.prototype.slice.call(arguments,1).forEach((function(t){t&&Object.keys(t).forEach((function(n){e[n]=t[n]}))})),e}function s(e){return Object.prototype.toString.call(e)}function a(e){return"[object String]"===s(e)}function l(e){return"[object Object]"===s(e)}function c(e){return"[object RegExp]"===s(e)}function u(e){return"[object Function]"===s(e)}function d(e){return e.replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}const h={fuzzyLink:!0,fuzzyEmail:!0,fuzzyIP:!1};function p(e){return Object.keys(e||{}).reduce((function(e,t){return e||h.hasOwnProperty(t)}),!1)}const m={"http:":{validate:function(e,t,n){const r=e.slice(t);return n.re.http||(n.re.http=new RegExp("^\\/\\/"+n.re.src_auth+n.re.src_host_port_strict+n.re.src_path,"i")),n.re.http.test(r)?r.match(n.re.http)[0].length:0}},"https:":"http:","ftp:":"http:","//":{validate:function(e,t,n){const r=e.slice(t);return n.re.no_http||(n.re.no_http=new RegExp("^"+n.re.src_auth+"(?:localhost|(?:(?:"+n.re.src_domain+")\\.)+"+n.re.src_domain_root+")"+n.re.src_port+n.re.src_host_terminator+n.re.src_path,"i")),n.re.no_http.test(r)?t>=3&&":"===e[t-3]||t>=3&&"/"===e[t-3]?0:r.match(n.re.no_http)[0].length:0}},"mailto:":{validate:function(e,t,n){const r=e.slice(t);return n.re.mailto||(n.re.mailto=new RegExp("^"+n.re.src_email_name+"@"+n.re.src_host_strict,"i")),n.re.mailto.test(r)?r.match(n.re.mailto)[0].length:0}}},f="a[cdefgilmnoqrstuwxz]|b[abdefghijmnorstvwyz]|c[acdfghiklmnoruvwxyz]|d[ejkmoz]|e[cegrstu]|f[ijkmor]|g[abdefghilmnpqrstuwy]|h[kmnrtu]|i[delmnoqrst]|j[emop]|k[eghimnprwyz]|l[abcikrstuvy]|m[acdeghklmnopqrstuvwxyz]|n[acefgilopruz]|om|p[aefghklmnrstwy]|qa|r[eosuw]|s[abcdeghijklmnortuvxyz]|t[cdfghjklmnortvwz]|u[agksyz]|v[aceginu]|w[fs]|y[et]|z[amw]",g="biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф".split("|");function v(e){e.__index__=-1,e.__text_cache__=""}function y(e){return function(t,n){const r=t.slice(n);return e.test(r)?r.match(e)[0].length:0}}function _(){return function(e,t){t.normalize(e)}}function S(e){const t=e.re=i(e.__opts__),n=e.__tlds__.slice();function r(e){return e.replace("%TLDS%",t.src_tlds)}e.onCompile(),e.__tlds_replaced__||n.push(f),n.push(t.src_xn),t.src_tlds=n.join("|"),t.email_fuzzy=RegExp(r(t.tpl_email_fuzzy),"i"),t.link_fuzzy=RegExp(r(t.tpl_link_fuzzy),"i"),t.link_no_ip_fuzzy=RegExp(r(t.tpl_link_no_ip_fuzzy),"i"),t.host_fuzzy_test=RegExp(r(t.tpl_host_fuzzy_test),"i");const o=[];function s(e,t){throw new Error('(LinkifyIt) Invalid schema "'+e+'": '+t)}e.__compiled__={},Object.keys(e.__schemas__).forEach((function(t){const n=e.__schemas__[t];if(null===n)return;const r={validate:null,link:null};if(e.__compiled__[t]=r,l(n))return c(n.validate)?r.validate=y(n.validate):u(n.validate)?r.validate=n.validate:s(t,n),void(u(n.normalize)?r.normalize=n.normalize:n.normalize?s(t,n):r.normalize=_());a(n)?o.push(t):s(t,n)})),o.forEach((function(t){e.__compiled__[e.__schemas__[t]]&&(e.__compiled__[t].validate=e.__compiled__[e.__schemas__[t]].validate,e.__compiled__[t].normalize=e.__compiled__[e.__schemas__[t]].normalize)})),e.__compiled__[""]={validate:null,normalize:_()};const h=Object.keys(e.__compiled__).filter((function(t){return t.length>0&&e.__compiled__[t]})).map(d).join("|");e.re.schema_test=RegExp("(^|(?!_)(?:[><|]|"+t.src_ZPCc+"))("+h+")","i"),e.re.schema_search=RegExp("(^|(?!_)(?:[><|]|"+t.src_ZPCc+"))("+h+")","ig"),e.re.schema_at_start=RegExp("^"+e.re.schema_search.source,"i"),e.re.pretest=RegExp("("+e.re.schema_test.source+")|("+e.re.host_fuzzy_test.source+")|@","i"),v(e)}function b(e,t){const n=e.__index__,r=e.__last_index__,i=e.__text_cache__.slice(n,r);this.schema=e.__schema__.toLowerCase(),this.index=n+t,this.lastIndex=r+t,this.raw=i,this.text=i,this.url=i}function x(e,t){const n=new b(e,t);return e.__compiled__[n.schema].normalize(n,e),n}function C(e,t){if(!(this instanceof C))return new C(e,t);t||p(e)&&(t=e,e={}),this.__opts__=o({},h,t),this.__index__=-1,this.__last_index__=-1,this.__schema__="",this.__text_cache__="",this.__schemas__=o({},m,e),this.__compiled__={},this.__tlds__=g,this.__tlds_replaced__=!1,this.re={},S(this)}function w(e={},t={}){const n=new C(e,t);return E(n,t),{extensions:[{name:"autolink",level:"inline",start:e=>{const t=A(n,e);if(t)return t.index},tokenizer(e){if(this.lexer.state.inLink)return;const t=A(n,e);if(!t)return;let r;return 0===t.index?r=t.raw:1===t.index&&"<"===e.charAt(0)&&">"===e.charAt(t.lastIndex)&&(r=`<${t.raw}>`),r?{type:"link",raw:r,text:t.text,href:t.url,tokens:[{type:"text",raw:t.text,text:t.text}]}:void 0}}]}}function A(e,t){const n=e.match(t);if(n&&n.length)return n[0]}function E(e,t){const n=t.tlds;delete t.tlds;const r=t.tldsKeepOld;delete t.tldsKeepOld,n&&e.tlds(n,r)}return C.prototype.add=function(e,t){return this.__schemas__[e]=t,S(this),this},C.prototype.set=function(e){return this.__opts__=o(this.__opts__,e),this},C.prototype.test=function(e){if(this.__text_cache__=e,this.__index__=-1,!e.length)return!1;let t,n,r,i,o,s,a,l,c;if(this.re.schema_test.test(e))for(a=this.re.schema_search,a.lastIndex=0;null!==(t=a.exec(e));)if(i=this.testSchemaAt(e,t[2],a.lastIndex),i){this.__schema__=t[2],this.__index__=t.index+t[1].length,this.__last_index__=t.index+t[0].length+i;break}return this.__opts__.fuzzyLink&&this.__compiled__["http:"]&&(l=e.search(this.re.host_fuzzy_test),l>=0&&(this.__index__<0||l<this.__index__)&&null!==(n=e.match(this.__opts__.fuzzyIP?this.re.link_fuzzy:this.re.link_no_ip_fuzzy))&&(o=n.index+n[1].length,(this.__index__<0||o<this.__index__)&&(this.__schema__="",this.__index__=o,this.__last_index__=n.index+n[0].length))),this.__opts__.fuzzyEmail&&this.__compiled__["mailto:"]&&(c=e.indexOf("@"),c>=0&&null!==(r=e.match(this.re.email_fuzzy))&&(o=r.index+r[1].length,s=r.index+r[0].length,(this.__index__<0||o<this.__index__||o===this.__index__&&s>this.__last_index__)&&(this.__schema__="mailto:",this.__index__=o,this.__last_index__=s))),this.__index__>=0},C.prototype.pretest=function(e){return this.re.pretest.test(e)},C.prototype.testSchemaAt=function(e,t,n){return this.__compiled__[t.toLowerCase()]?this.__compiled__[t.toLowerCase()].validate(e,n,this):0},C.prototype.match=function(e){const t=[];let n=0;this.__index__>=0&&this.__text_cache__===e&&(t.push(x(this,n)),n=this.__last_index__);let r=n?e.slice(n):e;for(;this.test(r);)t.push(x(this,n)),r=r.slice(this.__last_index__),n+=this.__last_index__;return t.length?t:null},C.prototype.matchAtStart=function(e){if(this.__text_cache__=e,this.__index__=-1,!e.length)return null;const t=this.re.schema_at_start.exec(e);if(!t)return null;const n=this.testSchemaAt(e,t[2],t[0].length);return n?(this.__schema__=t[2],this.__index__=t.index+t[1].length,this.__last_index__=t.index+t[0].length+n,x(this,0)):null},C.prototype.tlds=function(e,t){return e=Array.isArray(e)?e:[e],t?(this.__tlds__=this.__tlds__.concat(e).sort().filter((function(e,t,n){return e!==n[t-1]})).reverse(),S(this),this):(this.__tlds__=e.slice(),this.__tlds_replaced__=!0,S(this),this)},C.prototype.normalize=function(e){e.schema||(e.url="http://"+e.url),"mailto:"!==e.schema||/^mailto:/i.test(e.url)||(e.url="mailto:"+e.url)},C.prototype.onCompile=function(){},w}();var vO={};vO=function(e){"use strict";const t=/^(\${1,2})(?!\$)((?:\\.|[^\\\n])*?(?:\\.|[^\\\n\$]))\1(?=[\s?!\.,:?!。,:]|$)/,n=/^(\${1,2})(?!\$)((?:\\.|[^\\\n])*?(?:\\.|[^\\\n\$]))\1/,r=/^(\${1,2})\n((?:\\[^]|[^\\])+?)\n\1(?:\n|$)/;function i(e={}){return{extensions:[s(e,o(e,!1)),a(e,o(e,!0))]}}function o(t,n){return r=>e.renderToString(r.text,{...t,displayMode:r.displayMode})+(n?"\n":"")}function s(e,r){const i=e&&e.nonStandard,o=i?n:t;return{name:"inlineKatex",level:"inline",start(e){let t,n=e;for(;n;){if(t=n.indexOf("$"),-1===t)return;if((i?t>-1:0===t||" "===n.charAt(t-1))&&n.substring(t).match(o))return t;n=n.substring(t+1).replace(/^\$+/,"")}},tokenizer(e,t){const n=e.match(o);if(n)return{type:"inlineKatex",raw:n[0],text:n[2].trim(),displayMode:2===n[1].length}},renderer:r}}function a(e,t){return{name:"blockKatex",level:"block",tokenizer(e,t){const n=e.match(r);if(n)return{type:"blockKatex",raw:n[0],text:n[2].trim(),displayMode:2===n[1].length}},renderer:t}}return i}(o("kqAxc"));const yO=(e,t,n,r)=>{if(!t.rowspan)return"";return`${`<${n}`+(t.colspan>1?` colspan=${t.colspan}`:"")+(t.rowspan>1?` rowspan=${t.rowspan}`:"")+(r?` align=${r}`:"")+">"+e}</${n}>\n`},_O=(e,t,n=[])=>{var r,i,o;const s=[...e.matchAll(/(?:[^|\\]|\\.?)+(?:\|+|$)/g)].map((e=>e[0]));(null===(r=s[0])||void 0===r?void 0:r.trim())||s.shift(),(null===(i=s[s.length-1])||void 0===i?void 0:i.trim())||s.pop();let a,l,c,u,d,h=0;for(a=0;a<s.length;a++){if(c=s[a].split(/\|+$/)[0],s[a]={rowspan:1,colspan:Math.max(s[a].length-c.length,1),text:c.trim().replace(/\\\|/g,"|")},"^"===c.slice(-1)&&n.length)for(d=0,l=0;l<n.length;l++){if(u=n[l],d===h&&u.colspan===s[a].colspan){s[a].rowSpanTarget=null!==(o=u.rowSpanTarget)&&void 0!==o?o:u,s[a].rowSpanTarget.text+=` ${s[a].text.slice(0,-1)}`,s[a].rowSpanTarget.rowspan+=1,s[a].rowspan=0;break}if(d+=u.colspan,d>h)break}h+=s[a].colspan}if(h>t)s.splice(t);else for(;h<t;)s.push({colspan:1,text:""}),h+=1;return s};sO.marked.use({async:!1,gfm:!0,pedantic:!1,renderer:{link:({href:e,title:t,text:n})=>{const r=e?yR(e):null;if(null===r)return n;let i='<a href="'+(e=r)+'"';return t&&(i+=' title="'+t+'"'),i+=' target="_blank" rel="noopener noreferrer">'+n+"</a>",i}}}),sO.marked.use(t(gO)()),sO.marked.use({extensions:[{name:"spanTable",level:"block",start(e){var t;return null===(t=e.match(/^\n *([^\n ].*\|.*)\n/))||void 0===t?void 0:t.index},tokenizer(e,t){const n=new RegExp("^ *([^\\n ].*\\|.*\\n(?: *[^\\s].*\\n)*?) {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n| {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)| {0,3}#{1,6} | {0,3}>| {4}[^\\n]| {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n| {0,3}(?:[*+-]|1[.)]) |<\\/?(?:address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)(?: +|\\n|\\/?>)|<(?:script|pre|style|textarea|!--)).*(?:\\n|$))*)\\n*|$)").exec(e);if(n){const e={type:"spanTable",header:n[1].replace(/\n$/,"").split("\n"),align:n[2].replace(/^ *|\| *$/g,"").split(/ *\| */),rows:n[3]?n[3].replace(/\n$/,"").split("\n"):[]};e.header[0]=_O(e.header[0]);const t=e.header[0].reduce(((e,t)=>e+t.colspan),0);if(t===e.align.length){let r,i,o,s;e.raw=n[0];let a=e.align.length;for(r=0;r<a;r++)/^ *-+: *$/.test(e.align[r])?e.align[r]="right":/^ *:-+: *$/.test(e.align[r])?e.align[r]="center":/^ *:-+ *$/.test(e.align[r])?e.align[r]="left":e.align[r]=null;for(a=e.header.length,r=1;r<a;r++)e.header[r]=_O(e.header[r],t,e.header[r-1]);for(a=e.rows.length,r=0;r<a;r++)e.rows[r]=_O(e.rows[r],t,e.rows[r-1]);for(a=e.header.length,i=0;i<a;i++)for(s=e.header[i],o=0;o<s.length;o++)s[o].tokens=[],this.lexer.inline(s[o].text,s[o].tokens);for(a=e.rows.length,i=0;i<a;i++)for(s=e.rows[i],o=0;o<s.length;o++)s[o].tokens=[],this.lexer.inline(s[o].text,s[o].tokens);return e}}},renderer(e){let t,n,r,i,o,s,a='<div class="memori--responsive-table-wrapper"><table class="memori--table memori--table--compact">';for(a+="<thead>",t=0;t<e.header.length;t++){r=e.header[t];let o=0;for(a+="<tr>",n=0;n<r.length;n++)i=r[n],s=this.parser.parseInline(i.tokens),a+=yO(s,i,"th",e.align[o]),o+=i.colspan;a+="</tr>"}if(a+="</thead>",e.rows.length){for(a+="<tbody>",t=0;t<e.rows.length;t++){for(r=e.rows[t],o=0,a+="<tr>",n=0;n<r.length;n++)i=r[n],s=this.parser.parseInline(i.tokens),a+=yO(s,i,"td",e.align[o]),o+=i.colspan;a+="</tr>"}a+="</tbody>"}return a+="</table></div>",a}}]});const SO=e=>{let t=e;return e.length>mO&&(t=`${e.slice(0,mO)}\n<br />...`),t.split(" ").length>fO&&(t=t.split(" ").slice(0,fO).join(" ")),t},bO=(e,n=!1,r="Reasoning...")=>{try{let i=e.trim().replaceAll(/\[([^\]]+)\]\(([^\)]+)\)/g,'<a href="$2" target="_blank" rel="noopener noreferrer">$1</a>').replaceAll(/<think>([\s\S]*?)<\/think>/g,`<details class="memori-think"><summary>${r}</summary>$1</details>`).replaceAll(/<document_attachment filename="([^"]+)" type="([^"]+)">([\s\S]*?)<\/document_attachment>/g,"").replaceAll(/```markdown([^```]+)```/g,"$1").replaceAll("($","( $").replaceAll(":$",": $").replaceAll("\frac","\\frac").replaceAll("\beta","\\beta").replaceAll("cdot","\\cdot");n&&(sO.marked.use(t(vO)({})),i=i.replace(/\\+\[(.*?)\\*\]/gs,((e,t)=>`$$${t}$$`)),i=i.replace(/\[([^[\]]+?)\]/g,((e,t)=>!/[\\+a-z0-9_{}^=\-\+\*\/]+/i.test(t)||e.startsWith("[http")||e.includes("](")?e:`$$${t}$$`)));let o=sO.marked.parse(i).toString().trim();o=t(aO).sanitize(o,{ADD_ATTR:["target"]});return{text:o.replace(/(<br>)+/g,"<br>").replace(/<p><\/p>/g,"<br>").replace(/<p><br><\/p>/g,"<br>")}}catch(t){return console.error("Error rendering message:",t),{text:e}}};var xO=({rows:e,className:n,innerClassName:r,btnClassName:i,lineHeightMultiplier:o=1.2,defaultExpanded:a=!1,expandSymbol:l=(()=>"..."),collapseSymbol:u=(e=>"it"===e?"Mostra meno":"Show less"),children:d,mode:h="rows"})=>{const{i18n:p}=Ie(),m=p.language,f=u(m),g=l(m),[v,y]=(0,c.useState)(a),[_,S]=(0,c.useState)(!1),[b,x]=(0,c.useState)(16),C=(0,c.useRef)(null);(0,c.useEffect)((()=>{if(C.current)if("rows"===h){let t=C.current.getBoundingClientRect().height,n=getComputedStyle(C.current),r=n.lineHeight,i="normal"!==r&&(null==r?void 0:r.length)?parseInt(r,10):o*parseInt(n.fontSize,10);x(i),t&&e&&t>e*i&&S(!0)}else if("characters"===h){const e=C.current.textContent||"";(e.length>mO||e.split(" ").length>fO)&&S(!0)}}),[e,h,C.current]);return(0,s.jsxs)("div",{className:t(Is)("memori-expandable",n),children:[(0,s.jsx)("div",{ref:C,className:t(Is)("memori-expandable--inner",r),style:{maxHeight:v||!_||"characters"===h?"9999px":b*(e||1)+"px"},children:(()=>{var e;if("characters"===h&&!v&&_){const t=(null===(e=C.current)||void 0===e?void 0:e.textContent)||"";return SO(t)}return d})()}),_&&!v&&(0,s.jsx)(Mm,{ghost:!0,padded:!1,className:i,onClick:()=>y(!0),children:g}),_&&v&&(0,s.jsx)(Mm,{ghost:!0,padded:!1,className:i,onClick:()=>y(!1),children:f})]})};const CO=new Map(Object.entries({TENANT_NOT_FOUND:-1,TENANT_REGISTRATION_DISABLED:-2,TENANT_MISSING_NAME:-3,TENANT_MAX_USERS_REACHED:-4,TENANT_MAX_ADMINS_REACHED:-5,TENANT_ALREADY_EXISTS:-6,TENANT_MISSING_DESCRIPTION:-7,TENANT_CANT_SET_COMPLETION_PROVIDER:-8,TENANT_INVALID_TYPE:-9,USER_NOT_CONFIRMED:-11,USER_NOT_FOUND:-12,USER_OR_PASSWORD_INVALID:-13,USER_MUST_CHANGE_PASSWORD:-14,USER_MUST_ENTER_VERIFICATION_CODE:-15,USER_MISSING_TENANT:-21,USER_MISSING_NAME:-22,USER_MISSING_PASSWORD:-23,USER_MISSING_EMAIL:-24,USER_MISSING_VERIFICATION_CODE:-25,USER_NAME_ALREADY_USED:-26,USER_PASSWORD_NOT_CONFORMING_TO_POLICY:-27,USER_EMAIL_ALREADY_USED:-28,USER_EMAIL_INVALID:-29,USER_VERIFICATION_CODE_INVALID:-30,USER_MISSING_NAME_OR_EMAIL:-31,USER_NAME_INVALID:-32,USER_HAS_ONE_OR_MORE_MEMORI:-33,USER_MISSING_NEW_PASSWORD:-34,USER_CANT_CREATE_MEMORI:-35,USER_MAX_MEMORI_REACHED:-36,USER_TOO_MANY_ATTEMPTS:-38,USER_MUST_ACCEPT_TNC_AND_PP:-39,USER_BIRTH_DATE_CANT_BE_CHANGED:-40,USER_CANT_SET_COMPLETION_PROVIDER:-41,USER_CANT_ENABLE_DEEP_THOUGHT:-42,USER_CANT_ENABLE_DCM_INTEGRATION:-43,USER_CANT_ENABLE_CHAINING_OR_BOARD_OF_EXPERTS:-44,USER_CREATION_BILLING_DENIED_PERMISSION:-46,USER_HAS_ONE_OR_MORE_COMPLETION_CONFIGS:-47,USER_CANT_BE_DELETED:-48,USER_ORDER_BY_INVALID:-49,MEMORI_NOT_FOUND:-51,MEMORI_NOT_ACCESSIBLE:-52,MEMORI_ONLY_OWNER_CAN_CHANGE_GIVER_TAG_AND_PIN:-53,SESSION_NOT_FOUND:-101,SESSION_IS_NOT_ADMINISTRATIVE:-102,SESSION_EXPIRED:-103,MEMORI_MISSING_CONFIGURATION:-201,MEMORI_CONFIGURATION_NOT_FOUND:-202,MEMORI_INVALID_PRIVACY_TYPE:-203,MEMORI_MISSING_PASSWORD:-204,MEMORI_INVALID_TOTAL_NUMBER_OF_RECOVERY_TOKENS:-205,MEMORI_INVALID_MINIMUM_NUMBER_OF_RECOVERY_TOKENS:-206,MEMORI_INVALID_VOICE_TYPE:-207,MEMORI_MISSING_NAME:-208,MEMORI_MISSING_PASSWORD_OR_RECOVERY_TOKENS:-209,MEMORI_INVALID_ID:-210,MEMORI_NAME_ALREADY_USED:-211,MEMORI_INVALID_PIN:-212,MEMORI_GIVER_TAG_PIN_CHANGE_REQUIRES_SEPARATE_OPERATION:-213,MEMORI_NO_PASSWORD_WHEN_PUBLIC:-214,MEMORI_DEEP_THOUGHT_REQUIRES_COMPLETIONS:-215,MEMORI_BOARD_OF_EXPERTS_REQUIRES_COMPLETIONS:-216,MEMORI_INVALID_COMPLETION_CONFIG:-217,MEMORI_MACRO_FUNCTIONS_REQUIRES_COMPLETIONS:-218,MEMORI_BLOCKING_DATE_MISSING_OR_WRONG:-219,MEMORI_LIST_FILTER_NOT_SPECIFIED:-220,MEMORI_TRANSFER_MISSING_DESTINATION_USER:-231,MEMORI_TRANSFER_INVALID_DESTINATION_USER_ID:-232,MEMORI_TRANSFER_DESTINATION_USER_DATA_INCONSISTENT:-233,MEMORI_TRANSFER_NOTHING_TO_DO:-234,MEMORI_CONFIGURATION_CANT_BE_CHANGED:-251,MEMORI_MISSING_NEW_PASSWORD:-252,MEMORI_SESSIONS_INVALID_DATE_FROM_FORMAT:-261,MEMORI_SESSIONS_INVALID_DATE_TO_FORMAT:-262,MEMORI_SESSION_NOT_FOUND:-263,MEMORI_SESSION_DOESNT_ACCEPT_MEDIA:-264,MEMORI_FEATURE_REQUIRES_SUBSCRIPTION:-271,INTEGRATION_NOT_FOUND:-301,INTEGRATION_INVALID_TYPE:-401,INTEGRATION_ALREADY_EXISTS:-402,INTEGRATION_MEMORI_IS_NOT_PUBLIC:-403,INTEGRATION_MISSING_INVOCATION_TEXT:-404,INTEGRATION_MISSING_DEVICE_EMAILS:-405,INTEGRATION_MEMORI_IS_EMPTY:-406,INTEGRATION_MISSING_PRIVACY_POLICY:-407,INTEGRATION_MISSING_CATEGORY:-408,INTEGRATION_MISSING_DESCRIPTION:-409,INTEGRATION_INVALID_INVOCATION_TEXT:-410,INTEGRATION_GOOGLE_NO_MORE_AVAILABLE:-411,UPLOAD_REQUIRES_MULTIPART_ENCODING:-501,UPLOAD_MISSING_CONTENT_TYPE_BOUNDARY:-502,UPLOAD_MAX_LENGTH_EXCEEDED:-503,UPLOAD_FILE_IS_EMPTY:-504,UPLOAD_INVALID_FILE_TYPE_OR_SIGNATURE:-505,UPLOAD_MISSING_FILE_NAME:-506,UPLOAD_INVALID_MEMORY_ID:-507,UPLOAD_MISSING_FILE_CONTENT:-508,ASSET_NOT_FOUND:-601,ASSET_NOT_ACCESSIBLE:-602,ASSET_MISSING_SESSION_ID:-603,ASSET_INVALID_FILE_NAME:-604,ASSET_MALWARE_SCAN_THREATS_FOUND:-605,INVITATION_NOT_FOUND:-701,INVITATION_NOT_ACCESSIBLE:-702,INVITATION_ALREADY_ACCEPTED:-703,INVITATION_ALREADY_REJECTED:-704,INVITATION_MISSING_DESTINATION_EMAIL:-705,INVITATION_DESTINATION_EMAIL_INVALID:-706,INVITATION_MISSING_TAG:-707,INVITATION_MISSING_PIN:-708,INVITATION_INVALID_PIN:-709,INVITATION_INVALID_TYPE:-710,INVITATION_MISSING_DESTINATION_NAME:-711,INVITATION_TAG_PIN_CANT_BE_CHANGED:-712,INVITATION_CANT_BE_CHANGED:-713,ACTIONLOG_INVALID_USER_ID:-801,ACTIONLOG_INVALID_DATE_FROM_FORMAT:-802,ACTIONLOG_INVALID_DATE_TO_FORMAT:-803,ACTIONLOG_INVALID_MEMORI_ID:-804,CONSUMPTIONLOG_INVALID_TYPE:-901,CONSUMPTIONLOG_INVALID_DATE_FROM_FORMAT:-902,CONSUMPTIONLOG_INVALID_DATE_TO_FORMAT:-903,CONSUMPTIONLOG_INVALID_USER_ID:-904,CONSUMPTIONLOG_INVALID_MEMORI_ID:-905,NOTIFICATIONPREFS_INVALID_CHATLOG_EXTRACTION_PERIOD:-1001,BROADCAST_NOT_ALLOWED:-1002,INVALID_NOTIFICATION_TYPE:-1003,NOTIFICATION_NOT_FOUND:-1004,INVALID_NOTIFICATION_FILTER:-1005,INVALID_NOTIFICATION_PERIOD:-1006,PROCESS_INVALID_TYPE:-1401,PROCESS_ALREADY_RUNNING:-1401,PROCESS_NOT_FOUND:-1402,IMPORTCSV_MISSING_CSV:-1502,IMPORTCSV_MISSING_SEPARATOR:-1503,IMPORTCSV_INVALID_SEPARATOR:-1504,IMPORTCSV_MISSING_HEADERS:-1505,IMPORTCSV_MISSING_TITLE_VARIANT_SEPARATOR:-1506,IMPORTCSV_INVALID_RECEIVER_ID:-1507,IMPORTCSV_INVALID_MEDIA_LINK:-1508,IMPORTCSV_INVALID_LINK_TITLE_HANDLING:-1509,IMPORTCSV_UNDETECTABLE_CHAR_ENCODING:-1521,IMPORTTXT_INVALID_GRANULARITY:-1602,IMPORTTXT_INVALID_RECEIVER_ID:-1603,IMPORTTXT_INVALID_MEDIA_LINK:-1604,IMPORTTXT_INVALID_LINK_TITLE_HANDLING:-1605,IMPORTTXT_UNDETECTABLE_CHAR_ENCODING:-1621,IMPORTTXT_IMPORT_LIMIT_EXCEEDED:-1632,IMPORTTXT_IMPORT_ON_GPT4_REQUIRES_API_KEY:-1633,IMPORTTXT_IMPORT_REQUIRES_PAYING:-1634,IMPORTTXT_BILLING_DENIED_PERMISSION:-1635,IMPORT_MISSING_ROWS:-1701,IMPORT_CANT_IMPORT_TO_SECRET_MEMORI:-1702,IMPORTMEMORI_INVALID_MEMORI_SPECS:-1711,IMPORT_MISSING_JSONL:-1712,IMPORTMEMORI_INVALID_SPECS:-1713,EXPORT_MISSING_PASSWORD:1711,EXPORTCSV_MISSING_CSV_SPECS:-1801,EXPORTCSV_MISSING_SEPARATOR:-1802,EXPORTCSV_INVALID_SEPARATOR:-1803,EXPORTCSV_MISSING_TITLE_VARIANT_SEPARATOR:-1804,EXPORTCSV_MISSING_NEW_LINE_CHAR:-1805,EXPORTCSV_INVALID_NEW_LINE_CHAR:-1806,EXPORTJSONL_MISSING_JSONL_SPECS:-1821,EXPORTJSONL_MISSING_PLATFORM:-1822,EXPORTJSONL_INVALID_PLATFORM:-1823,EXPORTJSONL_EXPORT_REQUIRES_PAYING:-1832,ANALYSIS_MISSING_QUERY:-1901,ANALYSIS_CANT_ANALYZE_SECRET_MEMORI:-1902,ANALYSIS_USER_QUERY_MATCH_REQUIRES_DEEP_THOUGHT:-1903,BADGE_ASSIGNMENT_WRONG_OR_MISSING_CREDENTIALS:-2001,BADGE_ASSIGNMENT_MISSING_REF_ID:-2002,BADGE_ASSIGNMENT_OUTCOME_NOT_FOUND:-2003,BADGE_ASSIGNMENT_MISSING_ASSERTION_URL:-2004,BADGE_ASSIGNMENT_MISSING_BADGE_URL:-2005,BADGE_ASSIGNMENT_MISSING_ISSUER_URL:-2006,BADGE_ASSIGNMENT_INVALID_URL:-2007,BADGE_ASSIGNMENT_MISSING_RECIPIENT:-2021,BADGE_ASSIGNMENT_UNKNOWN_RECIPIENT_TYPE:-2022,BADGE_ASSIGNMENT_MISSING_RECIPIENT_IDENTITY:-2023,BADGE_ASSIGNMENT_MISSING_RECIPIENT_HASH_TYPE:-2024,BADGE_ASSIGNMENT_UNKNOWN_RECIPIENT_HASH_TYPE:-2025,BADGE_ASSIGNMENT_WRONG_RECIPIENT_IDENTITY:-2026,BADGE_NOT_FOUND:-2051,OUTCOME_NO_DCM_CONFIGURED:-2071,OUTCOME_USER_BADGES_DISABLED:-2072,COMPLETION_CONFIG_MISSING_NAME:-2401,COMPLETION_CONFIG_MISSING_PROVIDER:-2402,COMPLETION_CONFIG_MISSING_ENDPOINT:-2403,COMPLETION_CONFIG_MISSING_API_KEY:-2404,COMPLETION_CONFIG_MISSING_MODEL:-2405,COMPLETION_CONFIG_NO_PURPOSE_SPECIFIED:-2406,COMPLETION_CONFIG_INVALID_NAME:-2407,COMPLETION_CONFIG_INVALID_PURPOSE:-2411,COMPLETION_CONFIG_INVALID_ENDPOINT:-2412,COMPLETION_CONFIG_INCONSISTENT_ENDPOINT:-2413,COMPLETION_CONFIG_INVALID_PROVIDER:-2414,COMPLETION_CONFIG_NOT_FOUND:-2421,COMPLETION_CONFIG_NOT_ACCESSIBLE:-2422,COMPLETION_CONFIG_NAME_RESERVED:-2441,COMPLETION_CONFIG_NAME_ALREADY_EXISTS:-2442,COMPLETION_CONFIG_VISIBILITY_CHANGE_NOT_ALLOWED:-2443,COMPLETION_CONFIG_MISSING_MANDATORY_PREFIX:-2444,COMPLETION_CONFIG_VISIBILITY_NOT_PERMITTED:-2445,COMPLETION_CONFIG_USE_AS_DEFAULT_NOT_PERMITTED:-2446,COMPLETION_CONFIG_USE_AS_DEFAULT_REQUIRES_TENANT_VISIBILITY:-2447,COMPLETION_CONFIG_CHARGEABLE_NOT_PERMITTED:-2448,COMPLETION_CONFIG_INVALID_APPLY_TO:-2449,COMPLETION_CONFIG_APPLY_TO_TENANT_NOT_ALLOWED:-2450,TRUSTED_APPLICATION_NOT_FOUND:-2501,TRUSTED_APPLICATION_NOT_ACCESSIBLE:-2502,TRUSTED_APPLICATION_NAME_REQUIRED:-2503,TRUSTED_APPLICATION_TOKEN_REQUIRED:-2504,TRUSTED_APPLICATION_NAME_ALREADY_EXISTS:-2505,TRUSTED_APPLICATION_INVALID_TOKEN:-2506}).map((([e,t])=>[t,e]))),wO=e=>{if(!e)return"error.generic";if(401===e||403===e)return"error.unauthorized";if(404===e)return"error.notFound";if(422===e)return"error.unprocessableEntity";if(500===e)return"internal server error";let t=CO.get(e);return t?`errors.${t}`:"error.generic"};c=o("85Hg2");var AO=({medium:e,className:n,preview:r=!1,showCopyButton:i=!0})=>{var o,a,l,u,d;const{t:h}=Ie();return(0,c.useEffect)((()=>{(()=>{if(document.getElementById("memori-prism-script"))return;const e=document.createElement("script");e.src="https://cdn.jsdelivr.net/npm/prismjs@1.29.0/prism.min.js",e.async=!0,e.id="memori-prism-script";const t=document.createElement("script");t.src="https://cdn.jsdelivr.net/npm/prismjs@v1.29.0/plugins/autoloader/prism-autoloader.min.js",t.async=!0,t.id="memori-prism-autoloader-script";const n=document.createElement("link");n.rel="stylesheet",n.href="https://cdn.jsdelivr.net/npm/prismjs@1.29.0/themes/prism-tomorrow.min.css",document.head.appendChild(n),document.head.appendChild(e),document.head.appendChild(t)})()}),[]),(0,c.useEffect)((()=>{"Prism"in window&&window.Prism.highlightAll&&Prism.highlightAll()}),[e.content]),(0,s.jsxs)("div",{className:"memori-snippet",children:[(0,s.jsxs)("div",{className:"memori-snippet--content",children:[(0,s.jsx)("pre",{className:t(Is)("line-numbers",n),"aria-labelledby":(null===(o=e.title)||void 0===o?void 0:o.length)?`#snippet-${e.mediumID}`:void 0,children:(0,s.jsx)("code",{className:`language-${null!==(l=null===(a=hO.find((t=>e.mimeType===t.mimeType)))||void 0===a?void 0:a.lang)&&void 0!==l?l:"text"}`,children:(null===(u=e.content)||void 0===u?void 0:u.length)&&e.content.length>200&&r?`${e.content.slice(0,200)}\n...`:`${e.content}`})}),i&&(0,s.jsx)(Mm,{padded:!1,ghost:!0,className:"memori-snippet--copy-button",title:h("copy")||"Copy",icon:(0,s.jsx)(rO,{}),onClick:()=>{var t;return navigator.clipboard.writeText(null!==(t=e.content)&&void 0!==t?t:"")}})]}),!!(null===(d=e.title)||void 0===d?void 0:d.length)&&(0,s.jsx)("p",{id:`snippet-${e.mediumID}`,className:"memori-snippet--caption",children:e.title})]})};c=o("85Hg2"),c=o("85Hg2");var EO,IO=({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:"M574 665.4a8.03 8.03 0 0 0-11.3 0L446.5 781.6c-53.8 53.8-144.6 59.5-204 0-59.5-59.5-53.8-150.2 0-204l116.2-116.2c3.1-3.1 3.1-8.2 0-11.3l-39.8-39.8a8.03 8.03 0 0 0-11.3 0L191.4 526.5c-84.6 84.6-84.6 221.5 0 306s221.5 84.6 306 0l116.2-116.2c3.1-3.1 3.1-8.2 0-11.3L574 665.4zm258.6-474c-84.6-84.6-221.5-84.6-306 0L410.3 307.6a8.03 8.03 0 0 0 0 11.3l39.7 39.7c3.1 3.1 8.2 3.1 11.3 0l116.2-116.2c53.8-53.8 144.6-59.5 204 0 59.5 59.5 53.8 150.2 0 204L665.3 562.6a8.03 8.03 0 0 0 0 11.3l39.8 39.8c3.1 3.1 8.2 3.1 11.3 0l116.2-116.2c84.5-84.6 84.5-221.5 0-306.1zM610.1 372.3a8.03 8.03 0 0 0-11.3 0L372.3 598.7a8.03 8.03 0 0 0 0 11.3l39.6 39.6c3.1 3.1 8.2 3.1 11.3 0l226.4-226.4c3.1-3.1 3.1-8.2 0-11.3l-39.5-39.6z"})}),TO={};EO=function(e){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var t=Object.assign||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};function n(e,n){var r=e.el,i=e.elStyle,o=e.elHeight,s=e.rowsLimit,a=e.rowsWrapped,l=e.options,c=e.buffer,u=c;if(a===s+1)return t({},e);var d=c,h=a,p=o;return r.innerHTML=u=c.length?""+c+l.delimiter+n+l.replaceStr:""+n+l.replaceStr,parseFloat(i.height)>parseFloat(o)&&(h++,p=i.height,h===s+1)?(r.innerHTML=u="."===d[d.length-1]&&"..."===l.replaceStr?d+"..":""+d+l.replaceStr,t({},e,{elHeight:p,rowsWrapped:h})):(r.innerHTML=u=d.length?""+d+l.delimiter+n:""+n,t({},e,{buffer:u,elHeight:p,rowsWrapped:h}))}e.disableResponsive=function(e){window.removeEventListener("resize",e)},e.ellipsis=function e(){for(var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},s={replaceStr:"...",responsive:!1,debounceDelay:250,delimiter:" "},a=t({},s,o),l=r&&(r instanceof NodeList?r:1===r.nodeType?[r]:document.querySelectorAll(r)),c=[],u=0;u<l.length;u++){var d=l[u];c[u]=d.innerHTML;var h=d.innerHTML.split(a.delimiter);d.innerHTML="";var p=window.getComputedStyle(d);h.reduce(n,{el:d,buffer:d.innerHTML,elStyle:p,elHeight:0,rowsLimit:i,rowsWrapped:0,options:a})}if(a.responsive){var m=!1,f=window.innerWidth,g=function(){if(window.innerWidth!==f){f=window.innerWidth;for(var n=0;n<l.length;n++)l[n].innerHTML=c[n];e(r,i,t({},o,{responsive:!1}))}},v=function(){clearTimeout(m),m=setTimeout(g,a.debounceDelay)};return window.addEventListener("resize",v),v}}},"function"==typeof define&&define.amd?define(["exports"],EO):EO(TO);var MO=({loading:e=!1,className:n,title:r,description:i,cover:o,hoverable:a=!1,children:l,onClick:c})=>(0,s.jsx)("div",{onClick:c,className:t(Is)("memori-card",n,{"memori-card--loading":e,"memori-card--with-cover":o,"memori-card--hoverable":a,"memori-card--pointer":!!c}),children:(0,s.jsxs)(Tm,{spinning:e,children:[o&&(0,s.jsx)("div",{className:"memori-card--cover",children:o}),(0,s.jsxs)("div",{className:"memori-card--content",children:[r&&(0,s.jsx)("h3",{className:"memori-card--title",children:r}),i&&(0,s.jsx)("p",{className:"memori-card--description",children:i}),(0,s.jsx)("div",{className:"memori-card--children",children:l})]})]})});const RO=({isChild:e=!1,item:n,baseUrl:r,onLinkPreviewInfo:i,descriptionOneLine:o=!1})=>{var a,l,u,d;const[h,p]=(0,c.useState)(null),m=(null===(a=n.url)||void 0===a?void 0:a.startsWith("http"))||!n.url||0===(null===(l=n.url)||void 0===l?void 0:l.length)?n.url:`https://${n.url}`;(0,c.useEffect)((()=>{var e,t;let o=(null===(e=n.url)||void 0===e?void 0:e.startsWith("http"))||!n.url||0===(null===(t=n.url)||void 0===t?void 0:t.length)?n.url:`https://${n.url}`;o&&o!==(null==h?void 0:h.urlKey)&&(async(e,t)=>{try{const n=await fetch(`${t||"https://aisuru.com"}/api/linkpreview/${encodeURIComponent(e)}`);return await n.json()}catch(e){return console.error("getSiteInfo",e),null}})(o,r).then((e=>{p(e?{...e,urlKey:o}:null),i&&e&&i(e)}))}),[null==n?void 0:n.url,r,i]);const f=n.title&&n.title.length>0?n.title:null==h?void 0:h.title,g=null==h?void 0:h.description,v=null==h?void 0:h.video,y=null!==(u=null==h?void 0:h.image)&&void 0!==u?u:null===(d=null==h?void 0:h.images)||void 0===d?void 0:d[0];return(0,c.useEffect)((()=>{setTimeout((()=>{(0,TO.ellipsis)(".memori-link-item--card .memori-card--description",3,{responsive:!0})}),300)}),[g,n.mediumID]),(0,s.jsx)("a",{href:m,target:"_blank",rel:"noopener noreferrer",className:t(Is)("memori-link-item--link",{"memori-link-item--link--child":e}),onClick:t=>{e||(t.preventDefault(),t.stopPropagation(),window.open(m,"_blank",`toolbar=yes,top=${.1*window.innerHeight},left=${.1*window.innerWidth},width=${.8*window.innerWidth},height=${.8*window.innerHeight}`))},children:(0,s.jsx)(MO,{hoverable:!0,className:t(Is)("memori-link-item--card",{"memori-link-item--card-description-oneline":o,"memori-link-item--card-has-image":y,"memori-link-item--card-has-video":v}),cover:v?(0,s.jsx)("iframe",{width:"100%",height:"100%",src:v,title:"Video player",frameBorder:"0",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0}):y?(0,s.jsx)("img",{className:"memori-link-item--card-cover-img",src:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMIAAADDCAYAAADQvc6UAAABRWlDQ1BJQ0MgUHJvZmlsZQAAKJFjYGASSSwoyGFhYGDIzSspCnJ3UoiIjFJgf8LAwSDCIMogwMCcmFxc4BgQ4ANUwgCjUcG3awyMIPqyLsis7PPOq3QdDFcvjV3jOD1boQVTPQrgSkktTgbSf4A4LbmgqISBgTEFyFYuLykAsTuAbJEioKOA7DkgdjqEvQHEToKwj4DVhAQ5A9k3gGyB5IxEoBmML4BsnSQk8XQkNtReEOBxcfXxUQg1Mjc0dyHgXNJBSWpFCYh2zi+oLMpMzyhRcASGUqqCZ16yno6CkYGRAQMDKMwhqj/fAIcloxgHQqxAjIHBEugw5sUIsSQpBobtQPdLciLEVJYzMPBHMDBsayhILEqEO4DxG0txmrERhM29nYGBddr//5/DGRjYNRkY/l7////39v///y4Dmn+LgeHANwDrkl1AuO+pmgAAADhlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAAqACAAQAAAABAAAAwqADAAQAAAABAAAAwwAAAAD9b/HnAAAHlklEQVR4Ae3dP3PTWBSGcbGzM6GCKqlIBRV0dHRJFarQ0eUT8LH4BnRU0NHR0UEFVdIlFRV7TzRksomPY8uykTk/zewQfKw/9znv4yvJynLv4uLiV2dBoDiBf4qP3/ARuCRABEFAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghgg0Aj8i0JO4OzsrPv69Wv+hi2qPHr0qNvf39+iI97soRIh4f3z58/u7du3SXX7Xt7Z2enevHmzfQe+oSN2apSAPj09TSrb+XKI/f379+08+A0cNRE2ANkupk+ACNPvkSPcAAEibACyXUyfABGm3yNHuAECRNgAZLuYPgEirKlHu7u7XdyytGwHAd8jjNyng4OD7vnz51dbPT8/7z58+NB9+/bt6jU/TI+AGWHEnrx48eJ/EsSmHzx40L18+fLyzxF3ZVMjEyDCiEDjMYZZS5wiPXnyZFbJaxMhQIQRGzHvWR7XCyOCXsOmiDAi1HmPMMQjDpbpEiDCiL358eNHurW/5SnWdIBbXiDCiA38/Pnzrce2YyZ4//59F3ePLNMl4PbpiL2J0L979+7yDtHDhw8vtzzvdGnEXdvUigSIsCLAWavHp/+qM0BcXMd/q25n1vF57TYBp0a3mUzilePj4+7k5KSLb6gt6ydAhPUzXnoPR0dHl79WGTNCfBnn1uvSCJdegQhLI1vvCk+fPu2ePXt2tZOYEV6/fn31dz+shwAR1sP1cqvLntbEN9MxA9xcYjsxS1jWR4AIa2Ibzx0tc44fYX/16lV6NDFLXH+YL32jwiACRBiEbf5KcXoTIsQSpzXx4N28Ja4BQoK7rgXiydbHjx/P25TaQAJEGAguWy0+2Q8PD6/Ki4R8EVl+bzBOnZY95fq9rj9zAkTI2SxdidBHqG9+skdw43borCXO/ZcJdraPWdv22uIEiLA4q7nvvCug8WTqzQveOH26fodo7g6uFe/a17W3+nFBAkRYENRdb1vkkz1CH9cPsVy/jrhr27PqMYvENYNlHAIesRiBYwRy0V+8iXP8+/fvX11Mr7L7ECueb/r48eMqm7FuI2BGWDEG8cm+7G3NEOfmdcTQw4h9/55lhm7DekRYKQPZF2ArbXTAyu4kDYB2YxUzwg0gi/41ztHnfQG26HbGel/crVrm7tNY+/1btkOEAZ2M05r4FB7r9GbAIdxaZYrHdOsgJ/wCEQY0J74TmOKnbxxT9n3FgGGWWsVdowHtjt9Nnvf7yQM2aZU/TIAIAxrw6dOnAWtZZcoEnBpNuTuObWMEiLAx1HY0ZQJEmHJ3HNvGCBBhY6jtaMoEiJB0Z29vL6ls58vxPcO8/zfrdo5qvKO+d3Fx8Wu8zf1dW4p/cPzLly/dtv9Ts/EbcvGAHhHyfBIhZ6NSiIBTo0LNNtScABFyNiqFCBChULMNNSdAhJyNSiECRCjUbEPNCRAhZ6NSiAARCjXbUHMCRMjZqBQiQIRCzTbUnAARcjYqhQgQoVCzDTUnQIScjUohAkQo1GxDzQkQIWejUogAEQo121BzAkTI2agUIkCEQs021JwAEXI2KoUIEKFQsw01J0CEnI1KIQJEKNRsQ80JECFno1KIABEKNdtQcwJEyNmoFCJAhELNNtScABFyNiqFCBChULMNNSdAhJyNSiECRCjUbEPNCRAhZ6NSiAARCjXbUHMCRMjZqBQiQIRCzTbUnAARcjYqhQgQoVCzDTUnQIScjUohAkQo1GxDzQkQIWejUogAEQo121BzAkTI2agUIkCEQs021JwAEXI2KoUIEKFQsw01J0CEnI1KIQJEKNRsQ80JECFno1KIABEKNdtQcwJEyNmoFCJAhELNNtScABFyNiqFCBChULMNNSdAhJyNSiECRCjUbEPNCRAhZ6NSiAARCjXbUHMCRMjZqBQiQIRCzTbUnAARcjYqhQgQoVCzDTUnQIScjUohAkQo1GxDzQkQIWejUogAEQo121BzAkTI2agUIkCEQs021JwAEXI2KoUIEKFQsw01J0CEnI1KIQJEKNRsQ80JECFno1KIABEKNdtQcwJEyNmoFCJAhELNNtScABFyNiqFCBChULMNNSdAhJyNSiEC/wGgKKC4YMA4TAAAAABJRU5ErkJggg==",srcSet:y.includes("data:image")?void 0:y.startsWith("https")?y:`https://${y.replace("http://","")}`,alt:n.title}):(0,s.jsx)("div",{className:"memori-link-item--card-cover-icon",children:(0,s.jsx)(IO,{className:"memori-link-item--icon"})}),title:f,description:g})})};var PO=({items:e,baseUrl:n,descriptionOneLine:r=!1,onLinkPreviewInfo:i,fromUser:o=!1})=>(0,s.jsx)(dp,{appear:!0,show:!0,as:"div",className:"memori-link-items",children:(0,s.jsx)("div",{className:t(Is)("memori-link-items--grid",{"memori-link-items--user":o,"memori-link-items--agent":!o}),children:e.map(((e,t)=>(0,s.jsx)(dp.Child,{as:"div",className:"memori-link-item",enter:"ease-out duration-500 delay-"+100*t,enterFrom:"opacity-0 scale-95",enterTo:"opacity-1 scale-100",leave:"ease-in duration-300",leaveFrom:"opacity-1 scale-100",leaveTo:"opacity-0 scale-95",children:(0,s.jsx)(RO,{item:e,baseUrl:n,descriptionOneLine:r,onLinkPreviewInfo:i})},e.mediumID)))})});c=o("85Hg2");const NO=["va bene","no grazie","si","no","sì","arrivederci","non c'entrava","non mi è piaciuto"],OO=async(e,t,n,r)=>{var i;let o=(e=>e.replaceAll(/<output.*?>(.*?)<\/output>/g,""))(e);const s=NO.indexOf(e.toLowerCase())>-1?"IT":null==n?void 0:n.toUpperCase(),a=t.toUpperCase(),l=await fetch(`${r||"https://www.aisuru.com"}/api/translate`,{cache:"no-cache",method:"POST",body:JSON.stringify({text:o,target_lang:a,source_lang:s}),headers:{Accept:"*/*","Content-Type":"application/json"}}),c=await l.json();return null===(i=null==c?void 0:c.translations)||void 0===i?void 0:i[0]};c=o("85Hg2");var DO=({src:e,poster:t,alt:n=""})=>((0,c.useEffect)((()=>{const e=document.createElement("script");return e.src="https://unpkg.com/@google/model-viewer/dist/model-viewer.min.js",e.type="module",document.head.appendChild(e),()=>{document.head.removeChild(e)}}),[]),(0,s.jsx)("div",{className:"model-viewer",children:(0,s.jsx)("model-viewer",{src:e,"ios-src":"",poster:t,alt:n,"shadow-intensity":"1","disable-zoom":!0,"camera-controls":!0,autoplay:!0})}));var LO=({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:"M854.6 288.6L639.4 73.4c-6-6-14.1-9.4-22.6-9.4H192c-17.7 0-32 14.3-32 32v832c0 17.7 14.3 32 32 32h640c17.7 0 32-14.3 32-32V311.3c0-8.5-3.4-16.7-9.4-22.7zM790.2 326H602V137.8L790.2 326zm1.8 562H232V136h302v216a42 42 0 0 0 42 42h216v494z"})});var kO=({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:"M531.3 574.4l.3-1.4c5.8-23.9 13.1-53.7 7.4-80.7-3.8-21.3-19.5-29.6-32.9-30.2-15.8-.7-29.9 8.3-33.4 21.4-6.6 24-.7 56.8 10.1 98.6-13.6 32.4-35.3 79.5-51.2 107.5-29.6 15.3-69.3 38.9-75.2 68.7-1.2 5.5.2 12.5 3.5 18.8 3.7 7 9.6 12.4 16.5 15 3 1.1 6.6 2 10.8 2 17.6 0 46.1-14.2 84.1-79.4 5.8-1.9 11.8-3.9 17.6-5.9 27.2-9.2 55.4-18.8 80.9-23.1 28.2 15.1 60.3 24.8 82.1 24.8 21.6 0 30.1-12.8 33.3-20.5 5.6-13.5 2.9-30.5-6.2-39.6-13.2-13-45.3-16.4-95.3-10.2-24.6-15-40.7-35.4-52.4-65.8zM421.6 726.3c-13.9 20.2-24.4 30.3-30.1 34.7 6.7-12.3 19.8-25.3 30.1-34.7zm87.6-235.5c5.2 8.9 4.5 35.8.5 49.4-4.9-19.9-5.6-48.1-2.7-51.4.8.1 1.5.7 2.2 2zm-1.6 120.5c10.7 18.5 24.2 34.4 39.1 46.2-21.6 4.9-41.3 13-58.9 20.2-4.2 1.7-8.3 3.4-12.3 5 13.3-24.1 24.4-51.4 32.1-71.4zm155.6 65.5c.1.2.2.5-.4.9h-.2l-.2.3c-.8.5-9 5.3-44.3-8.6 40.6-1.9 45 7.3 45.1 7.4zm191.4-388.2L639.4 73.4c-6-6-14.1-9.4-22.6-9.4H192c-17.7 0-32 14.3-32 32v832c0 17.7 14.3 32 32 32h640c17.7 0 32-14.3 32-32V311.3c0-8.5-3.4-16.7-9.4-22.7zM790.2 326H602V137.8L790.2 326zm1.8 562H232V136h302v216a42 42 0 0 0 42 42h216v494z"})});var BO=({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:"M854.6 288.6L639.4 73.4c-6-6-14.1-9.4-22.6-9.4H192c-17.7 0-32 14.3-32 32v832c0 17.7 14.3 32 32 32h640c17.7 0 32-14.3 32-32V311.3c0-8.5-3.4-16.7-9.4-22.7zM790.2 326H602V137.8L790.2 326zm1.8 562H232V136h302v216a42 42 0 0 0 42 42h216v494zM514.1 580.1l-61.8-102.4c-2.2-3.6-6.1-5.8-10.3-5.8h-38.4c-2.3 0-4.5.6-6.4 1.9-5.6 3.5-7.3 10.9-3.7 16.6l82.3 130.4-83.4 132.8a12.04 12.04 0 0 0 10.2 18.4h34.5c4.2 0 8-2.2 10.2-5.7L510 664.8l62.3 101.4c2.2 3.6 6.1 5.7 10.2 5.7H620c2.3 0 4.5-.7 6.5-1.9 5.6-3.6 7.2-11 3.6-16.6l-84-130.4 85.3-132.5a12.04 12.04 0 0 0-10.1-18.5h-35.7c-4.2 0-8.1 2.2-10.3 5.8l-61.2 102.3z"})});var zO=({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:"M854.6 288.6L639.4 73.4c-6-6-14.1-9.4-22.6-9.4H192c-17.7 0-32 14.3-32 32v832c0 17.7 14.3 32 32 32h640c17.7 0 32-14.3 32-32V311.3c0-8.5-3.4-16.7-9.4-22.7zM790.2 326H602V137.8L790.2 326zm1.8 562H232V136h302v216a42 42 0 0 0 42 42h216v494zM528.1 472h-32.2c-5.5 0-10.3 3.7-11.6 9.1L434.6 680l-46.1-198.7c-1.3-5.4-6.1-9.3-11.7-9.3h-35.4a12.02 12.02 0 0 0-11.6 15.1l74.2 276c1.4 5.2 6.2 8.9 11.6 8.9h32c5.4 0 10.2-3.6 11.6-8.9l52.8-197 52.8 197c1.4 5.2 6.2 8.9 11.6 8.9h31.8c5.4 0 10.2-3.6 11.6-8.9l74.4-276a12.04 12.04 0 0 0-11.6-15.1H647c-5.6 0-10.4 3.9-11.7 9.3l-45.8 199.1-49.8-199.3c-1.3-5.4-6.1-9.1-11.6-9.1z"})});const FO=({isChild:e=!1,item:t,sessionID:n,tenantID:r,preview:i=!1,baseURL:o,apiURL:a,onClick:l,customMediaRenderer:u})=>{var d,h;const[p,m]=(0,c.useState)(!1),[f,g]=(0,c.useState)(!1),v=RN({resourceURI:t.url,sessionID:n,tenantID:r,baseURL:o,apiURL:a}),y=null==u?void 0:u(t.mimeType);if(y)return y;const _=e=>{switch(e.mimeType){case"image/jpeg":case"image/png":case"image/jpg":case"image/gif":return S?(0,s.jsxs)("picture",{className:"memori-media-item--figure",children:[(0,s.jsx)("div",{className:"memori-media-item--rgb-item",style:{backgroundColor:e.url}}),e.title&&(0,s.jsx)("figcaption",{className:"memori-media-item--figure-caption",children:e.title})]}):(0,s.jsxs)("picture",{className:"memori-media-item--figure",children:[!i&&(0,s.jsx)("source",{srcSet:[v,e.url,e.content].join(", "),type:e.mimeType}),(0,s.jsx)("img",{alt:e.title,src:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMIAAADDCAYAAADQvc6UAAABRWlDQ1BJQ0MgUHJvZmlsZQAAKJFjYGASSSwoyGFhYGDIzSspCnJ3UoiIjFJgf8LAwSDCIMogwMCcmFxc4BgQ4ANUwgCjUcG3awyMIPqyLsis7PPOq3QdDFcvjV3jOD1boQVTPQrgSkktTgbSf4A4LbmgqISBgTEFyFYuLykAsTuAbJEioKOA7DkgdjqEvQHEToKwj4DVhAQ5A9k3gGyB5IxEoBmML4BsnSQk8XQkNtReEOBxcfXxUQg1Mjc0dyHgXNJBSWpFCYh2zi+oLMpMzyhRcASGUqqCZ16yno6CkYGRAQMDKMwhqj/fAIcloxgHQqxAjIHBEugw5sUIsSQpBobtQPdLciLEVJYzMPBHMDBsayhILEqEO4DxG0txmrERhM29nYGBddr//5/DGRjYNRkY/l7////39v///y4Dmn+LgeHANwDrkl1AuO+pmgAAADhlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAAqACAAQAAAABAAAAwqADAAQAAAABAAAAwwAAAAD9b/HnAAAHlklEQVR4Ae3dP3PTWBSGcbGzM6GCKqlIBRV0dHRJFarQ0eUT8LH4BnRU0NHR0UEFVdIlFRV7TzRksomPY8uykTk/zewQfKw/9znv4yvJynLv4uLiV2dBoDiBf4qP3/ARuCRABEFAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghgg0Aj8i0JO4OzsrPv69Wv+hi2qPHr0qNvf39+iI97soRIh4f3z58/u7du3SXX7Xt7Z2enevHmzfQe+oSN2apSAPj09TSrb+XKI/f379+08+A0cNRE2ANkupk+ACNPvkSPcAAEibACyXUyfABGm3yNHuAECRNgAZLuYPgEirKlHu7u7XdyytGwHAd8jjNyng4OD7vnz51dbPT8/7z58+NB9+/bt6jU/TI+AGWHEnrx48eJ/EsSmHzx40L18+fLyzxF3ZVMjEyDCiEDjMYZZS5wiPXnyZFbJaxMhQIQRGzHvWR7XCyOCXsOmiDAi1HmPMMQjDpbpEiDCiL358eNHurW/5SnWdIBbXiDCiA38/Pnzrce2YyZ4//59F3ePLNMl4PbpiL2J0L979+7yDtHDhw8vtzzvdGnEXdvUigSIsCLAWavHp/+qM0BcXMd/q25n1vF57TYBp0a3mUzilePj4+7k5KSLb6gt6ydAhPUzXnoPR0dHl79WGTNCfBnn1uvSCJdegQhLI1vvCk+fPu2ePXt2tZOYEV6/fn31dz+shwAR1sP1cqvLntbEN9MxA9xcYjsxS1jWR4AIa2Ibzx0tc44fYX/16lV6NDFLXH+YL32jwiACRBiEbf5KcXoTIsQSpzXx4N28Ja4BQoK7rgXiydbHjx/P25TaQAJEGAguWy0+2Q8PD6/Ki4R8EVl+bzBOnZY95fq9rj9zAkTI2SxdidBHqG9+skdw43borCXO/ZcJdraPWdv22uIEiLA4q7nvvCug8WTqzQveOH26fodo7g6uFe/a17W3+nFBAkRYENRdb1vkkz1CH9cPsVy/jrhr27PqMYvENYNlHAIesRiBYwRy0V+8iXP8+/fvX11Mr7L7ECueb/r48eMqm7FuI2BGWDEG8cm+7G3NEOfmdcTQw4h9/55lhm7DekRYKQPZF2ArbXTAyu4kDYB2YxUzwg0gi/41ztHnfQG26HbGel/crVrm7tNY+/1btkOEAZ2M05r4FB7r9GbAIdxaZYrHdOsgJ/wCEQY0J74TmOKnbxxT9n3FgGGWWsVdowHtjt9Nnvf7yQM2aZU/TIAIAxrw6dOnAWtZZcoEnBpNuTuObWMEiLAx1HY0ZQJEmHJ3HNvGCBBhY6jtaMoEiJB0Z29vL6ls58vxPcO8/zfrdo5qvKO+d3Fx8Wu8zf1dW4p/cPzLly/dtv9Ts/EbcvGAHhHyfBIhZ6NSiIBTo0LNNtScABFyNiqFCBChULMNNSdAhJyNSiECRCjUbEPNCRAhZ6NSiAARCjXbUHMCRMjZqBQiQIRCzTbUnAARcjYqhQgQoVCzDTUnQIScjUohAkQo1GxDzQkQIWejUogAEQo121BzAkTI2agUIkCEQs021JwAEXI2KoUIEKFQsw01J0CEnI1KIQJEKNRsQ80JECFno1KIABEKNdtQcwJEyNmoFCJAhELNNtScABFyNiqFCBChULMNNSdAhJyNSiECRCjUbEPNCRAhZ6NSiAARCjXbUHMCRMjZqBQiQIRCzTbUnAARcjYqhQgQoVCzDTUnQIScjUohAkQo1GxDzQkQIWejUogAEQo121BzAkTI2agUIkCEQs021JwAEXI2KoUIEKFQsw01J0CEnI1KIQJEKNRsQ80JECFno1KIABEKNdtQcwJEyNmoFCJAhELNNtScABFyNiqFCBChULMNNSdAhJyNSiECRCjUbEPNCRAhZ6NSiAARCjXbUHMCRMjZqBQiQIRCzTbUnAARcjYqhQgQoVCzDTUnQIScjUohAkQo1GxDzQkQIWejUogAEQo121BzAkTI2agUIkCEQs021JwAEXI2KoUIEKFQsw01J0CEnI1KIQJEKNRsQ80JECFno1KIABEKNdtQcwJEyNmoFCJAhELNNtScABFyNiqFCBChULMNNSdAhJyNSiEC/wGgKKC4YMA4TAAAAABJRU5ErkJggg=="}),e.title&&(0,s.jsx)("figcaption",{className:"memori-media-item--figure-caption",children:e.title})]});case"application/msword":case"application/vnd.openxmlformats-officedocument.wordprocessingml.document":return(0,s.jsx)(zO,{className:"memori-media-item--icon"});case"application/vnd.ms-excel":case"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":return(0,s.jsx)(BO,{className:"memori-media-item--icon"});case"application/pdf":return(0,s.jsx)(kO,{className:"memori-media-item--icon"});case"video/mp4":case"video/quicktime":case"video/avi":case"video/mpeg":return(0,s.jsxs)("video",{style:{width:"100%",height:"100%"},controls:!0,src:v,title:e.title,children:["video/quicktime"===e.mimeType&&(0,s.jsx)("source",{src:e.url,type:"video/mp4"}),(0,s.jsx)("source",{src:e.url,type:e.mimeType}),"Your browser does not support this video format.",(0,s.jsx)("br",{}),(0,s.jsx)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",children:"Download the video"})]});case"audio/mpeg3":case"audio/wav":case"audio/mpeg":return(0,s.jsx)("audio",{style:{width:"100%",height:"100%"},controls:!0,src:v});case"model/gltf-binary":return(0,s.jsx)(DO,{src:v,alt:"",poster:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMIAAADDCAYAAADQvc6UAAABRWlDQ1BJQ0MgUHJvZmlsZQAAKJFjYGASSSwoyGFhYGDIzSspCnJ3UoiIjFJgf8LAwSDCIMogwMCcmFxc4BgQ4ANUwgCjUcG3awyMIPqyLsis7PPOq3QdDFcvjV3jOD1boQVTPQrgSkktTgbSf4A4LbmgqISBgTEFyFYuLykAsTuAbJEioKOA7DkgdjqEvQHEToKwj4DVhAQ5A9k3gGyB5IxEoBmML4BsnSQk8XQkNtReEOBxcfXxUQg1Mjc0dyHgXNJBSWpFCYh2zi+oLMpMzyhRcASGUqqCZ16yno6CkYGRAQMDKMwhqj/fAIcloxgHQqxAjIHBEugw5sUIsSQpBobtQPdLciLEVJYzMPBHMDBsayhILEqEO4DxG0txmrERhM29nYGBddr//5/DGRjYNRkY/l7////39v///y4Dmn+LgeHANwDrkl1AuO+pmgAAADhlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAAqACAAQAAAABAAAAwqADAAQAAAABAAAAwwAAAAD9b/HnAAAHlklEQVR4Ae3dP3PTWBSGcbGzM6GCKqlIBRV0dHRJFarQ0eUT8LH4BnRU0NHR0UEFVdIlFRV7TzRksomPY8uykTk/zewQfKw/9znv4yvJynLv4uLiV2dBoDiBf4qP3/ARuCRABEFAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghgg0Aj8i0JO4OzsrPv69Wv+hi2qPHr0qNvf39+iI97soRIh4f3z58/u7du3SXX7Xt7Z2enevHmzfQe+oSN2apSAPj09TSrb+XKI/f379+08+A0cNRE2ANkupk+ACNPvkSPcAAEibACyXUyfABGm3yNHuAECRNgAZLuYPgEirKlHu7u7XdyytGwHAd8jjNyng4OD7vnz51dbPT8/7z58+NB9+/bt6jU/TI+AGWHEnrx48eJ/EsSmHzx40L18+fLyzxF3ZVMjEyDCiEDjMYZZS5wiPXnyZFbJaxMhQIQRGzHvWR7XCyOCXsOmiDAi1HmPMMQjDpbpEiDCiL358eNHurW/5SnWdIBbXiDCiA38/Pnzrce2YyZ4//59F3ePLNMl4PbpiL2J0L979+7yDtHDhw8vtzzvdGnEXdvUigSIsCLAWavHp/+qM0BcXMd/q25n1vF57TYBp0a3mUzilePj4+7k5KSLb6gt6ydAhPUzXnoPR0dHl79WGTNCfBnn1uvSCJdegQhLI1vvCk+fPu2ePXt2tZOYEV6/fn31dz+shwAR1sP1cqvLntbEN9MxA9xcYjsxS1jWR4AIa2Ibzx0tc44fYX/16lV6NDFLXH+YL32jwiACRBiEbf5KcXoTIsQSpzXx4N28Ja4BQoK7rgXiydbHjx/P25TaQAJEGAguWy0+2Q8PD6/Ki4R8EVl+bzBOnZY95fq9rj9zAkTI2SxdidBHqG9+skdw43borCXO/ZcJdraPWdv22uIEiLA4q7nvvCug8WTqzQveOH26fodo7g6uFe/a17W3+nFBAkRYENRdb1vkkz1CH9cPsVy/jrhr27PqMYvENYNlHAIesRiBYwRy0V+8iXP8+/fvX11Mr7L7ECueb/r48eMqm7FuI2BGWDEG8cm+7G3NEOfmdcTQw4h9/55lhm7DekRYKQPZF2ArbXTAyu4kDYB2YxUzwg0gi/41ztHnfQG26HbGel/crVrm7tNY+/1btkOEAZ2M05r4FB7r9GbAIdxaZYrHdOsgJ/wCEQY0J74TmOKnbxxT9n3FgGGWWsVdowHtjt9Nnvf7yQM2aZU/TIAIAxrw6dOnAWtZZcoEnBpNuTuObWMEiLAx1HY0ZQJEmHJ3HNvGCBBhY6jtaMoEiJB0Z29vL6ls58vxPcO8/zfrdo5qvKO+d3Fx8Wu8zf1dW4p/cPzLly/dtv9Ts/EbcvGAHhHyfBIhZ6NSiIBTo0LNNtScABFyNiqFCBChULMNNSdAhJyNSiECRCjUbEPNCRAhZ6NSiAARCjXbUHMCRMjZqBQiQIRCzTbUnAARcjYqhQgQoVCzDTUnQIScjUohAkQo1GxDzQkQIWejUogAEQo121BzAkTI2agUIkCEQs021JwAEXI2KoUIEKFQsw01J0CEnI1KIQJEKNRsQ80JECFno1KIABEKNdtQcwJEyNmoFCJAhELNNtScABFyNiqFCBChULMNNSdAhJyNSiECRCjUbEPNCRAhZ6NSiAARCjXbUHMCRMjZqBQiQIRCzTbUnAARcjYqhQgQoVCzDTUnQIScjUohAkQo1GxDzQkQIWejUogAEQo121BzAkTI2agUIkCEQs021JwAEXI2KoUIEKFQsw01J0CEnI1KIQJEKNRsQ80JECFno1KIABEKNdtQcwJEyNmoFCJAhELNNtScABFyNiqFCBChULMNNSdAhJyNSiECRCjUbEPNCRAhZ6NSiAARCjXbUHMCRMjZqBQiQIRCzTbUnAARcjYqhQgQoVCzDTUnQIScjUohAkQo1GxDzQkQIWejUogAEQo121BzAkTI2agUIkCEQs021JwAEXI2KoUIEKFQsw01J0CEnI1KIQJEKNRsQ80JECFno1KIABEKNdtQcwJEyNmoFCJAhELNNtScABFyNiqFCBChULMNNSdAhJyNSiEC/wGgKKC4YMA4TAAAAABJRU5ErkJggg=="});default:return(0,s.jsx)(LO,{className:"memori-media-item--icon"})}};if(!t.url&&"document"===(null==t?void 0:t.type)&&t.content)return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("a",{className:"memori-media-item--link",href:"#",onClick:e=>{e.preventDefault(),m(!0)},title:t.title,children:(0,s.jsx)(MO,{hoverable:!0,cover:_(t),title:t.title})}),(0,s.jsx)(aP,{open:p,onClose:()=>m(!1),title:t.title,className:"memori-media-item-preview--modal",width:"60%",widthMd:"70%",footer:(0,s.jsx)("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem"},children:(0,s.jsx)(Mm,{onClick:async()=>{try{await navigator.clipboard.writeText(t.content||""),g(!0),setTimeout((()=>g(!1)),2e3)}catch(e){console.error("Failed to copy content:",e)}},icon:(0,s.jsx)(rO,{}),children:f?"Copied!":"Copy Content"})}),children:(0,s.jsx)("div",{className:"memori-media-item-preview--content",children:(0,s.jsx)("div",{className:"memori-media-item-preview--text",dangerouslySetInnerHTML:{__html:gR(t.content||"")}})})})]});const S=(null===(d=t.url)||void 0===d?void 0:d.startsWith("rgb("))||(null===(h=t.url)||void 0===h?void 0:h.startsWith("rgba("));switch(t.mimeType){case"image/jpeg":case"image/png":case"image/jpg":case"image/gif":return S?(0,s.jsx)(MO,{hoverable:!0,className:"memori-media-item--card memori-media-item--image",cover:_(t)}):(0,s.jsx)("a",{className:"memori-media-item--link",href:t.url,onClick:n=>{e&&n.preventDefault(),l&&(n.preventDefault(),l(t.mediumID))},target:"_blank",rel:"noopener noreferrer",title:t.title,children:(0,s.jsx)(MO,{hoverable:!0,className:"memori-media-item--card memori-media-item--image",cover:_(t)})});case"application/msword":case"application/vnd.openxmlformats-officedocument.wordprocessingml.document":case"application/vnd.ms-excel":case"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":case"application/pdf":case"audio/mpeg3":case"audio/wav":case"audio/mpeg":default:return(0,s.jsx)("a",{className:"memori-media-item--link",href:v,target:"_blank",rel:"noopener noreferrer",title:t.title,children:(0,s.jsx)(MO,{hoverable:!0,cover:_(t),title:t.title})});case"video/mp4":case"video/quicktime":case"video/avi":case"video/mpeg":return(0,s.jsx)("a",{className:"memori-media-item--link",href:v,onClick:n=>{e&&n.preventDefault(),l&&(n.preventDefault(),l(t.mediumID))},target:"_blank",rel:"noopener noreferrer",title:t.title,children:(0,s.jsx)(MO,{hoverable:!0,cover:_(t),title:t.title})});case"model/gltf-binary":return(0,s.jsx)(MO,{hoverable:!0,cover:_(t)})}};var UO=(0,c.memo)((({items:e,sessionID:n,tenantID:r,translateTo:i,baseURL:o,apiURL:a,customMediaRenderer:l,fromUser:u=!1})=>{const[d,h]=(0,c.useState)(e),[p,m]=(0,c.useState)(),f=(0,c.useCallback)((async()=>{if(!i)return;const t=await Promise.all((null!=e?e:[]).map((async e=>{var t;if(!e.title)return e;try{const n=await OO(e.title,i);return{...e,title:null!==(t=n.text)&&void 0!==t?t:e.title}}catch(t){return console.error(t),e}})));h(t)}),[i,e]);(0,c.useEffect)((()=>{i&&f()}),[i,f]);const g=d.filter((e=>{var t;return!(null===(t=e.properties)||void 0===t?void 0:t.executable)&&!hO.map((e=>e.mimeType)).includes(e.mimeType)})).sort(((e,t)=>e.creationTimestamp>t.creationTimestamp?1:e.creationTimestamp<t.creationTimestamp?-1:0)),v=d.filter((e=>{var t;return!(null===(t=e.properties)||void 0===t?void 0:t.executable)&&hO.map((e=>e.mimeType)).includes(e.mimeType)})),y=d.filter((e=>{var t;return"text/css"===e.mimeType&&!!(null===(t=e.properties)||void 0===t?void 0:t.executable)}));return(0,s.jsxs)(dp,{appear:!0,show:!0,as:"div",className:"memori-media-items",children:[!!g.length&&(0,s.jsx)("div",{className:t(Is)("memori-media-items--grid",{"memori-media-items--user":u,"memori-media-items--agent":!u}),children:g.map(((e,t)=>(0,s.jsx)(dp.Child,{as:"div",className:"memori-media-item",enter:"ease-out duration-500 delay-"+100*t,enterFrom:"opacity-0 scale-95",enterTo:"opacity-1 scale-100",leave:"ease-in duration-300",leaveFrom:"opacity-1 scale-100",leaveTo:"opacity-0 scale-95",children:(0,s.jsx)(FO,{isChild:!0,sessionID:n,tenantID:r,baseURL:o,apiURL:a,onClick:e=>{m(d.find((t=>t.mediumID===e)))},item:{...e,title:e.title,url:e.url,content:e.content,type:"document"},customMediaRenderer:l})},e.url+"&index="+t)))}),v.map((e=>(0,s.jsx)(dp.Child,{as:"div",className:"memori-media-item--snippet",enter:"ease-out duration-500",enterFrom:"opacity-0 translate-y-1",enterTo:"opacity-1 translate-y-0",leave:"ease-in duration-300",leaveFrom:"opacity-1",leaveTo:"opacity-0",children:(0,s.jsx)(AO,{medium:e},e.mediumID)},e.mediumID))),y.map((e=>(0,s.jsx)("style",{dangerouslySetInnerHTML:{__html:e.content||""}},e.mediumID))),(null==p?void 0:p.mediumID)&&(0,s.jsx)(aP,{width:"100%",widthMd:"100%",className:"memori-media-item--modal",open:!!p,onClose:()=>m(void 0),footer:null,children:(0,s.jsx)(FO,{isChild:!0,sessionID:n,tenantID:r,baseURL:o,apiURL:a,item:{...p,title:p.title,url:p.url,content:p.content,type:"document"},customMediaRenderer:l})})]})}));var jO=(0,c.memo)((({hints:e=[],links:n=[],media:r=[],simulateUserPrompt:i=(()=>{}),sessionID:o,baseUrl:a,apiUrl:l,translateTo:u,customMediaRenderer:d,fromUser:h=!1})=>{const{t:p}=Ie(),[m,f]=(0,c.useState)(!0),[g,v]=(0,c.useState)(6);return(0,c.useEffect)((()=>{f(!0)}),[e]),(0,s.jsxs)("div",{className:"memori-media-widget",children:[(null==r?void 0:r.length)>0&&(0,s.jsx)(UO,{items:r,sessionID:o,translateTo:u,baseURL:a,apiURL:l,customMediaRenderer:d,fromUser:h}),(null==n?void 0:n.length)>0&&(0,s.jsx)(PO,{items:n,baseUrl:a,fromUser:h}),(null==e?void 0:e.length)>0&&m&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(dp,{appear:!0,show:!0,as:"ul",className:"memori-media--hints",children:e.slice(0,g).map(((e,n)=>(0,s.jsx)(dp.Child,{as:"li",enter:"ease-out duration-500",enterFrom:"opacity-0 translate-y-1",enterTo:"opacity-1 translate-y-0",leave:"ease-in duration-300",leaveFrom:"opacity-1",leaveTo:"opacity-0",children:(0,s.jsx)(Mm,{className:t(Is)("memori-media--hint"),primary:!0,onClick:()=>{i(e.originalText,e.text),f(!1)},onTouchEnd:()=>{i(e.originalText,e.text),f(!1)},children:e.text},e.text+n)},e.text+n)))}),e.length>g&&(0,s.jsx)("div",{className:"memori-hints--show-more",children:(0,s.jsx)(Mm,{className:"memori-hints--show-more-button",id:"showMoreHints",onClick:()=>v(g+6),children:p("expand")||"Expand"})})]})]})}));const GO=e=>e.endsWith("?")?e:`${e}?`;var HO=({message:e,apiURL:n,sessionID:r,visible:i=!0,initialMatches:o=[],closeDrawer:a,_TEST_loading:l=!1})=>{const{t:u}=Ie(),d=ne(n).search.searchMemory,[h,p]=(0,c.useState)(o),[m,f]=(0,c.useState)(l),g=(0,c.useCallback)((async()=>{if(f(!0),!l){try{const{matches:n,...i}=await d(r,{searchType:"Semantic",numberOfResults:3,text:e.questionAnswered,date:e.date,placeName:e.placeName,placeLatitude:e.placeLatitude,placeLongitude:e.placeLongitude,placeUncertaintyKm:e.placeUncertaintyKm,contextVars:e.contextVars,tag:e.tag,memoryTags:e.memoryTags});0!==i.resultCode?(console.error(i),t(rd).error(u(wO(i.resultCode)))):p(null!=n?n:[])}catch(e){console.error("WHYTHISANSWER/FETCH",e),p(null!=o?o:[])}f(!1)}}),[e,r]);return(0,c.useEffect)((()=>{g()}),[g,e,r]),(0,s.jsxs)(Om,{open:i,width:"80%",animated:!1,className:"memori-whythisanswer-drawer",onClose:()=>a(),title:u("whyThisAnswer"),children:[(0,s.jsx)("p",{children:u("whyThisAnswerHelper")}),e.questionAnswered&&(0,s.jsxs)("p",{className:"memori--whythisanswer-question-answered",children:[(0,s.jsxs)("strong",{children:[u("question")||"Question",":"]})," ",e.questionAnswered]}),(0,s.jsxs)(Tm,{primary:!0,spinning:m,children:[!m&&0===h.length&&(0,s.jsx)("p",{role:"info",className:"memori--whythisanswer-no-results",children:u("nothingFound")}),m&&0===h.length&&(0,s.jsxs)("ul",{className:"memori--whythisanswer-list memori--whythisanswer-skeleton",children:[(0,s.jsxs)("li",{children:[(0,s.jsxs)("div",{className:"memori--whythisanswer-title",children:[(0,s.jsx)("span",{className:"memori--whythisanswer-confidence",children:(0,s.jsx)("span",{className:"memori--whythisanswer-skeleton-text"})}),(0,s.jsx)("div",{className:"memori--whythisanswer-title-text",children:(0,s.jsx)("p",{className:"memori--whythisanswer-skeleton-text"})})]}),(0,s.jsxs)("p",{children:[(0,s.jsx)("div",{className:"memori--whythisanswer-skeleton-text"}),(0,s.jsx)("div",{className:"memori--whythisanswer-skeleton-text"}),(0,s.jsx)("div",{className:"memori--whythisanswer-skeleton-text"})]}),(0,s.jsx)("div",{className:"memori--whythisanswer-skeleton-block"})]}),(0,s.jsxs)("li",{children:[(0,s.jsxs)("div",{className:"memori--whythisanswer-title",children:[(0,s.jsx)("span",{className:"memori--whythisanswer-confidence",children:(0,s.jsx)("span",{className:"memori--whythisanswer-skeleton-text"})}),(0,s.jsxs)("div",{className:"memori--whythisanswer-title-text",children:[(0,s.jsx)("p",{className:"memori--whythisanswer-skeleton-text"}),(0,s.jsx)("p",{className:"memori--whythisanswer-skeleton-text"})]})]}),(0,s.jsxs)("p",{children:[(0,s.jsx)("div",{className:"memori--whythisanswer-skeleton-text"}),(0,s.jsx)("div",{className:"memori--whythisanswer-skeleton-text"})]}),(0,s.jsx)("div",{className:"memori--whythisanswer-skeleton-block"})]})]}),h.length>0&&(0,s.jsx)("ul",{className:"memori--whythisanswer-list",children:h.map((e=>{var t,n,r,i,o,a,l;return(0,s.jsxs)("li",{children:[(0,s.jsxs)("div",{className:"memori--whythisanswer-title",children:[(0,s.jsx)("span",{className:"memori--whythisanswer-confidence",children:e.confidenceLevel}),(0,s.jsxs)("div",{className:"memori--whythisanswer-title-text",children:[(0,s.jsx)("div",{className:"memori--whythisanswer-title-text-top-container",children:(0,s.jsx)("p",{children:(0,s.jsx)("strong",{children:GO(null!==(t=e.memory.title)&&void 0!==t?t:"")})})}),(0,s.jsx)("p",{children:null===(r=null===(n=e.memory.titleVariants)||void 0===n?void 0:n.map((e=>GO(e))))||void 0===r?void 0:r.join(" | ")}),(e.memory.receiverName||e.memory.receiverTag)&&(0,s.jsxs)("p",{className:"memori--whythisanswer-title-text-top",children:[u("receiverLabel"),": ",e.memory.receiverTag," ",e.memory.receiverName]})]})]}),e.memory.contextVars&&(0,s.jsx)("div",{className:"memori--whythisanswer-contextvars",children:Object.entries(e.memory.contextVars||{}).map((([e,t])=>(0,s.jsx)(MO,{className:"memori--whythisanswer-contextvars-card",children:(0,s.jsxs)("span",{children:[e,": ",(null==t?void 0:t.toString())||"✔️"]})},e)))}),null===(i=e.memory.answers)||void 0===i?void 0:i.map(((e,t)=>(0,s.jsx)("p",{className:"memori--whythisanswer-answer",children:(0,s.jsx)(xO,{mode:"rows",rows:3,children:e.text})},t))),(0,s.jsx)(jO,{links:null===(o=e.memory.media)||void 0===o?void 0:o.filter((e=>"text/html"===e.mimeType))}),null===(l=null===(a=e.memory.media)||void 0===a?void 0:a.filter((e=>"text/plain"===e.mimeType)))||void 0===l?void 0:l.map((e=>(0,s.jsx)(xO,{mode:"rows",rows:2,lineHeightMultiplier:2,innerClassName:"memori--whythisanswer-snippet-expandable",children:(0,s.jsx)(AO,{medium:e,showCopyButton:!1},e.mediumID)},e.mediumID)))]},e.memory.memoryID)}))})]})]})};var VO=({message:e,memori:n,tenant:r,baseUrl:i,apiUrl:o,sessionID:a,showFeedback:l,showWhyThisAnswer:u=!0,showCopyButton:d=!0,showTranslationOriginal:h=!1,simulateUserPrompt:p,showAIicon:m=!0,isFirst:f=!1,useMathFormatting:g=!1,user:v,userAvatar:y,experts:_,showFunctionCache:S=!1})=>{var b,x,C,w,A,E,I,T,M;const{t:R,i18n:P}=Ie(),N=P.language||"en",[O,D]=(0,c.useState)(!1),[L,k]=(0,c.useState)(!1),[B,z]=(0,c.useState)([]);(0,c.useEffect)((()=>{"undefined"==typeof window||window.MathJax||SR()}),[]),(0,c.useEffect)((()=>{const t=e.translatedText||e.text,n=/<document_attachment filename="([^"]+)" type="([^"]+)">([\s\S]*?)<\/document_attachment>/g,r=[];let i;for(;null!==(i=n.exec(t));){const[,e,t,n]=i;r.push({mediumID:`doc_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,url:"",mimeType:t,title:e,content:n.trim(),properties:{isDocumentAttachment:!0},type:"document"})}z(r)}),[e.text,e.translatedText]);const F=(e.translatedText||e.text).replace(/<document_attachment filename="([^"]+)" type="([^"]+)">([\s\S]*?)<\/document_attachment>/g,""),{text:U}=bO(F,g,R("reasoning")||"Reasoning..."),j=e.fromUser?SO(F):gR(fR(U)),G=null===(b=e.media)||void 0===b?void 0:b.find((e=>{var t;return"true"===(null===(t=e.properties)||void 0===t?void 0:t.functionCache)})),H=(null===(x=e.media)||void 0===x?void 0:x.filter((e=>{var t;return!(null===(t=e.properties)||void 0===t?void 0:t.isAttachedFile)})))||[],V=H.filter((e=>"text/html"!==e.mimeType&&"text/plain"!==e.mimeType)),W=H.filter((e=>"text/html"===e.mimeType));return(0,c.useLayoutEffect)((()=>{if("undefined"!=typeof window&&!e.fromUser){const e=setTimeout((()=>{if(window.MathJax&&window.MathJax.typesetPromise)try{if(document.querySelectorAll(".memori-chat--bubble-content").length>0){const e=document.querySelector(".memori-chat--history"),t=(null==e?void 0:e.scrollTop)||0,n=(null==e?void 0:e.scrollHeight)||0;window.MathJax.typesetPromise([".memori-chat--bubble-content"]).then((()=>{if(e){const r=e.scrollHeight-n;e.scrollTop=t+r}})).catch((e=>console.error("MathJax typesetting failed:",e)))}}catch(e){console.error("Error during MathJax typesetting:",e)}}),100);return()=>clearTimeout(e)}}),[F,e.fromUser,U]),(0,s.jsxs)(s.Fragment,{children:[(e.initial||f)&&(0,s.jsx)("div",{className:"memori-chat--bubble-initial"}),(0,s.jsxs)(dp,{show:!0,appear:!0,as:"div",className:t(Is)("memori-chat--bubble-container",{"memori-chat--bubble-from-user":!!e.fromUser,"memori-chat--with-addon":e.generatedByAI&&m||l&&p}),children:[!e.fromUser&&(0,s.jsx)(dp.Child,{as:"picture",className:"memori-chat--bubble-avatar",enter:"transition ease-in-out duration-300",enterFrom:"opacity-0 scale-075 "+(e.fromUser?"translate-x-15":"translate-x--15"),enterTo:"opacity-1 scale-1 translate-x-0",leave:"transition ease-in-out duration-300",leaveFrom:"opacity-1 scale-1 translate-x-0",leaveTo:"opacity-0 scale-075 "+(e.fromUser?"translate-x-15":"translate-x--15"),title:(null===(C=e.emitter)||void 0===C?void 0:C.length)&&n.enableBoardOfExperts?e.emitter:n.name,children:(0,s.jsx)("img",{className:"memori-chat--bubble-avatar-img",alt:(null===(w=e.emitter)||void 0===w?void 0:w.length)&&n.enableBoardOfExperts?e.emitter:n.name,src:(null===(A=e.emitter)||void 0===A?void 0:A.length)&&n.enableBoardOfExperts&&(null==_?void 0:_.find((t=>t.name===e.emitter)))?`${new URL(null!=o?o:"/").origin}/api/v1/memoriai/memori/avatar/${null===(E=_.find((t=>t.name===e.emitter)))||void 0===E?void 0:E.expertMemoriID}`:n.avatarURL&&n.avatarURL.length>0?RN({type:"avatar",tenantID:null==r?void 0:r.name,resourceURI:n.avatarURL,baseURL:i,apiURL:o}):RN({tenantID:null==r?void 0:r.name,type:"avatar",baseURL:i||"https://www.aisuru.com",apiURL:o}),onError:e=>{e.currentTarget.src=n.avatarURL&&n.avatarURL.length>0?RN({type:"avatar",tenantID:null==r?void 0:r.name,resourceURI:n.avatarURL,baseURL:i}):RN({tenantID:null==r?void 0:r.name,type:"avatar",baseURL:i}),e.currentTarget.onerror=null}})}),(0,s.jsxs)(dp.Child,{as:"div",className:t(Is)("memori-chat--bubble",{"memori-chat--user-bubble":!!e.fromUser,"memori-chat--with-addon":!e.fromUser&&d||e.generatedByAI&&m||l&&p,"memori-chat--ai-generated":e.generatedByAI&&m,"memori-chat--with-feedback":l}),enter:"transition ease-in-out duration-300",enterFrom:"opacity-0 scale-09 translate-x-"+(e.fromUser?"30":"-30"),enterTo:"opacity-1 scale-1 translate-x-0",leave:"transition ease-in-out duration-300",leaveFrom:"opacity-1 scale-1 translate-x-0",leaveTo:"opacity-0 scale-09 translate-x-"+(e.fromUser?"30":"-30"),children:[e.fromUser?(0,s.jsx)(xO,{className:"memori-chat--bubble-content",mode:"characters",children:(0,s.jsx)("div",{dir:"auto",className:"memori-chat--bubble-content",dangerouslySetInnerHTML:{__html:U}})}):(0,s.jsx)("div",{dir:"auto",className:"memori-chat--bubble-content",dangerouslySetInnerHTML:{__html:U}}),(!e.fromUser&&d||e.generatedByAI&&m||e.generatedByAI&&S||l&&p)&&(0,s.jsxs)("div",{className:"memori-chat--bubble-addon",children:[!e.fromUser&&d&&(0,s.jsx)(Mm,{ghost:!0,shape:"circle",title:R("copy")||"Copy",className:"memori-chat--bubble-action-icon",icon:(0,s.jsx)(rO,{"aria-label":R("copy")||"Copy"}),onClick:()=>navigator.clipboard.writeText(j)}),!e.fromUser&&d&&j!==e.text&&(0,s.jsx)(Mm,{ghost:!0,shape:"circle",title:R("copyRawCode")||"Copy raw code",className:"memori-chat--bubble-action-icon",icon:(0,s.jsx)(iO,{"aria-label":R("copyRawCode")||"Copy raw code"}),onClick:()=>navigator.clipboard.writeText(e.text)}),!e.fromUser&&S&&(null===(I=e.media)||void 0===I?void 0:I.some((e=>{var t,n;return Boolean(null===(t=e.properties)||void 0===t?void 0:t.functionCache)||"true"===(null===(n=e.properties)||void 0===n?void 0:n.functionCache)})))&&(0,s.jsx)(Mm,{ghost:!0,shape:"circle",title:"Debug",className:"memori-chat--bubble-action-icon memori-chat--bubble-action-icon--debug",icon:(0,s.jsx)(oO,{"aria-label":"Debug"}),onClick:()=>k(!0)}),l&&!!p&&(0,s.jsx)(tO,{memori:n,className:"memori-chat--bubble-feedback",dropdown:!0,onNegativeClick:e=>{e&&p(e)}}),e.generatedByAI&&m&&(0,s.jsx)(DN,{align:"left",content:R("generatedByAI")||("it"===N?"Risposta generata da IA, può talvolta generare informazioni non corrette":"Answer generated by AI, may occasionally generate incorrect informations"),className:"memori-chat--bubble-action-icon memori-chat--bubble-action-icon--ai",children:(0,s.jsx)("span",{children:(0,s.jsx)(NN,{title:R("generatedByAI")||("it"===N?"Risposta generata da IA, può talvolta generare informazioni non corrette":"Answer generated by AI, may occasionally generate incorrect informations")})})}),h&&e.translatedText&&e.translatedText!==e.text&&(0,s.jsx)(DN,{align:"left",content:`${"it"===N?"Testo originale":"Original text"}: ${e.text}`,className:"memori-chat--bubble-action-icon memori-chat--bubble-action-icon--ai",children:(0,s.jsx)("span",{children:(0,s.jsx)(ON,{"aria-label":"it"===N?"Testo originale":"Original text"})})}),!e.fromUser&&e.questionAnswered&&o&&u&&(0,s.jsx)(Mm,{ghost:!0,shape:"circle",title:R("whyThisAnswer")||void 0,className:"memori-chat--bubble-action-icon",onClick:()=>D(!0),disabled:O,icon:(0,s.jsx)(nO,{title:R("whyThisAnswer")||void 0})})]})]}),e.fromUser&&(0,s.jsx)(s.Fragment,{children:y&&"string"==typeof y||!y&&(null===(T=null==v?void 0:v.avatarURL)||void 0===T?void 0:T.length)?(0,s.jsx)(dp.Child,{as:"picture",className:"memori-chat--bubble-avatar",enter:"transition ease-in-out duration-300",enterFrom:"opacity-0 scale-075 "+(e.fromUser?"translate-x-15":"translate-x--15"),enterTo:"opacity-1 scale-1 translate-x-0",leave:"transition ease-in-out duration-300",leaveFrom:"opacity-1 scale-1 translate-x-0",leaveTo:"opacity-0 scale-075 "+(e.fromUser?"translate-x-15":"translate-x--15"),children:(0,s.jsx)("img",{className:"memori-chat--bubble-avatar-img",alt:null!==(M=null==v?void 0:v.userName)&&void 0!==M?M:"User",src:null!=y?y:null==v?void 0:v.avatarURL})}):y?(0,s.jsx)(dp.Child,{as:"div",className:"memori-chat--bubble-avatar",enter:"transition ease-in-out duration-300",enterFrom:"opacity-0 scale-075 "+(e.fromUser?"translate-x-15":"translate-x--15"),enterTo:"opacity-1 scale-1 translate-x-0",leave:"transition ease-in-out duration-300",leaveFrom:"opacity-1 scale-1 translate-x-0",leaveTo:"opacity-0 scale-075 "+(e.fromUser?"translate-x-15":"translate-x--15"),children:y}):(0,s.jsx)(dp.Child,{as:"div",className:"memori-chat--bubble-avatar",enter:"transition ease-in-out duration-300",enterFrom:"opacity-0 scale-075 "+(e.fromUser?"translate-x-15":"translate-x--15"),enterTo:"opacity-1 scale-1 translate-x-0",leave:"transition ease-in-out duration-300",leaveFrom:"opacity-1 scale-1 translate-x-0",leaveTo:"opacity-0 scale-075 "+(e.fromUser?"translate-x-15":"translate-x--15"),children:(0,s.jsx)(PN,{})})})]}),B.length>0&&(0,s.jsx)(jO,{media:B,sessionID:a,baseUrl:i,apiUrl:o,fromUser:e.fromUser}),V.length>0&&(0,s.jsx)(jO,{media:V,links:W,sessionID:a,baseUrl:i,apiUrl:o,fromUser:e.fromUser}),O&&o&&(0,s.jsx)(HO,{visible:O,message:e,closeDrawer:()=>D(!1),apiURL:o,sessionID:a}),(0,s.jsx)(aP,{title:null==G?void 0:G.title,open:L,onClose:()=>k(!1),className:"memori-chat--function-cache-modal",children:(0,s.jsx)("pre",{style:{whiteSpace:"pre-wrap",wordWrap:"break-word"},children:null==G?void 0:G.content})})]})};c=o("85Hg2"),c=o("85Hg2");var WO=({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:"M855 160.1l-189.2 23.5c-6.6.8-9.3 8.8-4.7 13.5l54.7 54.7-153.5 153.5a8.03 8.03 0 0 0 0 11.3l45.1 45.1c3.1 3.1 8.2 3.1 11.3 0l153.6-153.6 54.7 54.7a7.94 7.94 0 0 0 13.5-4.7L863.9 169a7.9 7.9 0 0 0-8.9-8.9zM416.6 562.3a8.03 8.03 0 0 0-11.3 0L251.8 715.9l-54.7-54.7a7.94 7.94 0 0 0-13.5 4.7L160.1 855c-.6 5.2 3.7 9.5 8.9 8.9l189.2-23.5c6.6-.8 9.3-8.8 4.7-13.5l-54.7-54.7 153.6-153.6c3.1-3.1 3.1-8.2 0-11.3l-45.2-45z"})});var qO=({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:"M391 240.9c-.8-6.6-8.9-9.4-13.6-4.7l-43.7 43.7L200 146.3a8.03 8.03 0 0 0-11.3 0l-42.4 42.3a8.03 8.03 0 0 0 0 11.3L280 333.6l-43.9 43.9a8.01 8.01 0 0 0 4.7 13.6L401 410c5.1.6 9.5-3.7 8.9-8.9L391 240.9zm10.1 373.2L240.8 633c-6.6.8-9.4 8.9-4.7 13.6l43.9 43.9L146.3 824a8.03 8.03 0 0 0 0 11.3l42.4 42.3c3.1 3.1 8.2 3.1 11.3 0L333.7 744l43.7 43.7A8.01 8.01 0 0 0 391 783l18.9-160.1c.6-5.1-3.7-9.4-8.8-8.8zm221.8-204.2L783.2 391c6.6-.8 9.4-8.9 4.7-13.6L744 333.6 877.7 200c3.1-3.1 3.1-8.2 0-11.3l-42.4-42.3a8.03 8.03 0 0 0-11.3 0L690.3 279.9l-43.7-43.7a8.01 8.01 0 0 0-13.6 4.7L614.1 401c-.6 5.2 3.7 9.5 8.8 8.9zM744 690.4l43.9-43.9a8.01 8.01 0 0 0-4.7-13.6L623 614c-5.1-.6-9.5 3.7-8.9 8.9L633 783.1c.8 6.6 8.9 9.4 13.6 4.7l43.7-43.7L824 877.7c3.1 3.1 8.2 3.1 11.3 0l42.4-42.3c3.1-3.1 3.1-8.2 0-11.3L744 690.4z"})});var JO=({disabled:e=!1,value:n,onChange:r,onPressEnter:i,onFocus:o,onBlur:a})=>{const{t:l}=Ie(),[u,d]=(0,c.useState)(!1);return(0,s.jsx)("div",{"data-testid":"chat-textarea",className:t(Is)("memori-chat-textarea",{"memori-chat-textarea--expanded":u,"memori-chat-textarea--disabled":e}),children:(0,s.jsxs)("div",{className:"memori-chat-textarea--inner",children:[(0,s.jsx)("textarea",{className:"memori-chat-textarea--input",disabled:e,value:n,onChange:e=>{r(e.target.value)},onKeyDownCapture:e=>{"Enter"===e.key&&!e.shiftKey&&i&&i(e)},onFocus:o,onBlur:a,maxLength:1e5}),(0,s.jsx)("div",{className:"memori-chat-textarea--expand",children:(0,s.jsx)(Mm,{className:t(Is)("memori-chat-textarea--expand-button"),onClick:()=>d(!u),padded:!1,ghost:!0,title:u?l("collapse")||"Collapse":l("expand")||"Expand",icon:u?(0,s.jsx)(qO,{}):(0,s.jsx)(WO,{})})})]})})};var KO=({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:"M931.4 498.9L94.9 79.5c-3.4-1.7-7.3-2.1-11-1.2-8.5 2.1-13.8 10.7-11.7 19.3l86.2 352.2c1.3 5.3 5.2 9.6 10.4 11.3l147.7 50.7-147.6 50.7c-5.2 1.8-9.1 6-10.3 11.3L72.2 926.5c-.9 3.7-.5 7.6 1.2 10.9 3.9 7.9 13.5 11.1 21.5 7.2l836.5-417c3.1-1.5 5.6-4.1 7.2-7.1 3.9-8 .7-17.6-7.2-21.6zM170.8 826.3l50.3-205.6 295.2-101.3c2.3-.8 4.2-2.6 5-5 1.4-4.2-.8-8.7-5-10.2L221.1 403 171 198.2l628 314.9-628.2 313.2z"})});c=o("85Hg2");var YO=({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:"M842 454c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8 0 140.3-113.7 254-254 254S258 594.3 258 454c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8 0 168.7 126.6 307.9 290 327.6V884H326.7c-13.7 0-24.7 14.3-24.7 32v36c0 4.4 2.8 8 6.2 8h407.6c3.4 0 6.2-3.6 6.2-8v-36c0-17.7-11-32-24.7-32H548V782.1c165.3-18 294-158 294-328.1zM512 624c93.9 0 170-75.2 170-168V232c0-92.8-76.1-168-170-168s-170 75.2-170 168v224c0 92.8 76.1 168 170 168zm-94-392c0-50.6 41.9-92 94-92s94 41.4 94 92v224c0 50.6-41.9 92-94 92s-94-41.4-94-92V232z"})});var XO=({listening:e,stopAudio:n,startListening:r,stopListening:i})=>{const{t:o}=Ie(),[a,l]=(0,c.useState)(),u=(0,c.useRef)(null),d=e=>{e.preventDefault(),l(o("write_and_speak.holdToSpeak")||"Hold to record"),u.current||(u.current=setTimeout((()=>{n(),l(o("write_and_speak.releaseToEndListening")||"Release to end listening"),r()}),300))},h=()=>{u.current&&(clearTimeout(u.current),u.current=null),i(),l(void 0)};return(0,c.useEffect)((()=>()=>h()),[]),(0,s.jsx)(DN,{visible:!!a,content:(0,s.jsx)("span",{children:a||o("write_and_speak.pressAndHoldToSpeak")||"Press and hold to speak"}),align:"topLeft",className:"memori-mic-btn-tooltip",children:(0,s.jsx)(Mm,{primary:!0,className:t(Is)("memori-chat-inputs--mic",{"memori-chat-inputs--mic--listening":e}),title:e?o("write_and_speak.micButtonPopoverListening")||"Listening":o("write_and_speak.micButtonPopover")||"Start listening",onMouseDown:d,onTouchStart:d,onMouseUp:h,onTouchEnd:h,shape:"circle",icon:(0,s.jsx)(YO,{})})})};c=o("85Hg2");const QO=({className:e})=>(0,s.jsxs)("svg",{className:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,s.jsx)("path",{d:"M14 2.5H6C5.60218 2.5 5.22064 2.65804 4.93934 2.93934C4.65804 3.22064 4.5 3.60218 4.5 4V20C4.5 20.3978 4.65804 20.7794 4.93934 21.0607C5.22064 21.342 5.60218 21.5 6 21.5H18C18.3978 21.5 18.7794 21.342 19.0607 21.0607C19.342 20.7794 19.5 20.3978 19.5 20V8L14 2.5Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),(0,s.jsx)("path",{d:"M14 2.5V8H19.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),(0,s.jsx)("path",{d:"M16 13H8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),(0,s.jsx)("path",{d:"M16 17H8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),(0,s.jsx)("path",{d:"M10 9H8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]});const $O=({className:e})=>(0,s.jsxs)("svg",{className:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,s.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),(0,s.jsx)("circle",{cx:"8.5",cy:"8.5",r:"1.5",fill:"currentColor"}),(0,s.jsx)("path",{d:"M21 15L16 10L5 21",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),ZO=({className:e})=>(0,s.jsxs)("svg",{className:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,s.jsx)("path",{d:"M21 15V19C21 19.5304 20.7893 20.0391 20.4142 20.4142C20.0391 20.7893 19.5304 21 19 21H5C4.46957 21 3.96086 20.7893 3.58579 20.4142C3.21071 20.0391 3 19.5304 3 19V15",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),(0,s.jsx)("path",{d:"M17 8L12 3L7 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),(0,s.jsx)("path",{d:"M12 3V15",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]});c=o("85Hg2");var eD=({open:e=!1,onClose:n,className:r,title:i,description:o,children:a,type:l="info",icon:u,closable:d=!0,duration:h=null,action:p,width:m="400px"})=>{const{t:f}=Ie();t(c).useEffect((()=>{if(h&&e){const e=setTimeout((()=>{n(!1)}),h);return()=>clearTimeout(e)}}),[h,e,n]);return(0,s.jsx)(dp,{show:e,as:t(c).Fragment,appear:!0,children:(0,s.jsxs)("div",{className:t(Is)("memori-alert",(e=>{switch(e){case"success":return"memori-alert--success";case"warning":return"memori-alert--warning";case"error":return"memori-alert--error";default:return"memori-alert--info"}})(l),r),children:[(0,s.jsx)("style",{dangerouslySetInnerHTML:{__html:`\n .memori-alert {\n --memori-alert--width: ${m};\n }\n `}}),(0,s.jsx)(dp.Child,{as:t(c).Fragment,enter:"ease-out duration-300",enterFrom:"opacity-0 translate-y-4",enterTo:"opacity-100 translate-y-0",leave:"ease-in duration-200",leaveFrom:"opacity-100 translate-y-0",leaveTo:"opacity-0 translate-y-4",children:(0,s.jsxs)("div",{className:"memori-alert--container",children:[u&&(0,s.jsx)("div",{className:"memori-alert--icon",children:u}),(0,s.jsxs)("div",{className:"memori-alert--content",children:[i&&(0,s.jsx)("div",{className:"memori-alert--title",children:i}),o&&(0,s.jsx)("div",{className:"memori-alert--description",children:o}),a]}),(0,s.jsxs)("div",{className:"memori-alert--actions",children:[p&&(0,s.jsx)("div",{className:"memori-alert--action",children:p}),d&&(0,s.jsx)(Mm,{ghost:!0,padded:!0,shape:"circle",icon:(0,s.jsx)(Rm,{}),title:f("close")||"Close",onClick:()=>n(!1),className:"memori-alert--close"})]})]})})]})})};c=o("85Hg2");const tD=10485760,nD=1e5,rD="3.11.174",iD=`https://cdnjs.cloudflare.com/ajax/libs/pdf.js/${rD}/pdf.worker.min.js`,oD=`https://cdnjs.cloudflare.com/ajax/libs/pdf.js/${rD}/pdf.min.js`;var sD=({setDocumentPreviewFiles:e,maxDocuments:n,documentPreviewFiles:r})=>{const[i,o]=(0,c.useState)(!1),[a,l]=(0,c.useState)([]),[u,d]=(0,c.useState)(null),h=(0,c.useRef)(null),p=e=>{l((t=>t.filter((t=>t.message!==e))))},m=e=>{l((t=>[...t,e])),setTimeout((()=>p(e.message)),5e3)},f=async e=>{var t;const n=(null===(t=e.name.split(".").pop())||void 0===t?void 0:t.toLowerCase())||"";try{let t=null;return"pdf"===n?t=await(async e=>{try{window.pdfjsLib||await new Promise(((e,t)=>{const n=document.createElement("script");n.src=oD,n.onload=()=>{window.pdfjsLib.GlobalWorkerOptions.workerSrc=iD,e(!0)},n.onerror=t,document.head.appendChild(n)}));const t=await e.arrayBuffer(),n=await window.pdfjsLib.getDocument({data:t}).promise;let r="";for(let e=1;e<=n.numPages;e++){const t=await n.getPage(e);r+=(await t.getTextContent()).items.filter((e=>e.str&&"string"==typeof e.str)).map((e=>e.str)).join(" ")+"\n"}return r}catch(e){throw new Error(`PDF extraction failed: ${e instanceof Error?e.message:"Unknown error"}`)}})(e):["txt","md","json","csv"].includes(n)?t=await e.text():"xlsx"===n&&(t=await(async e=>{try{window.XLSX||await new Promise(((e,t)=>{const n=document.createElement("script");n.src="https://cdn.sheetjs.com/xlsx-0.20.0/package/dist/xlsx.full.min.js",n.onload=e,n.onerror=t,document.head.appendChild(n)}));const t=await e.arrayBuffer(),n=window.XLSX.read(t,{type:"array",cellFormula:!0,cellNF:!0,cellText:!0,cellDates:!0});let r="";for(const e of n.SheetNames){const t=n.Sheets[e],i=window.XLSX.utils.sheet_to_json(t,{header:1,raw:!1}),o=i.reduce(((e,t)=>(t.forEach(((t,n)=>{const r=(t||"").toString().length;e[n]=Math.max(e[n]||0,r)})),e)),[]),s=i.map((e=>e.map(((e,t)=>(e||"").toString().padEnd(o[t]+2))).join("|").trim()));if(s.length>0){const e=o.map((e=>"-".repeat(e+2))).join("+");s.splice(1,0,e)}r+=`Sheet: ${e}\n${s.join("\n")}\n\n`}return r}catch(e){throw new Error(`XLSX extraction failed: ${e instanceof Error?e.message:"Unknown error"}`)}})(e)),t&&t.length>nD&&(m({message:`File "${e.name}" content exceeds 100000 characters and was truncated`,severity:"warning",fileId:e.name}),t=t.substring(0,nD)+"\n\n[Content truncated due to size limits]"),t}catch(t){throw new Error(`Failed to process "${e.name}": ${t instanceof Error?t.message:"Unknown error"}`)}};return(0,s.jsxs)("div",{className:"memori--document-upload-wrapper",children:[(0,s.jsx)("input",{ref:h,type:"file",accept:".pdf,.txt,.md,.json,.xlsx,.csv",className:"memori--upload-file-input",onChange:async t=>{const n=Array.from(t.target.files||[]);if(0===n.length)return;const r=n[0];if(o(!0),l([]),!(e=>{var t;const n=`.${null===(t=e.name.split(".").pop())||void 0===t?void 0:t.toLowerCase()}`,r=[".pdf",".txt",".json",".xlsx",".csv",".md"];return r.includes(n)?!(e.size>tD&&(m({message:`File "${e.name}" exceeds 10MB limit`,severity:"error",fileId:e.name}),1)):(m({message:`File type "${n}" is not supported. Please use: ${r.join(", ")}`,severity:"error",fileId:e.name}),!1)})(r))return o(!1),void(h.current&&(h.current.value=""));const i=Math.random().toString(36).substr(2,9);try{const t=await f(r);t&&e([{name:r.name,id:i,content:t,mimeType:r.type}])}catch(e){m({message:`${e instanceof Error?e.message:"Unknown error"}`,severity:"error",fileId:r.name})}o(!1),h.current&&(h.current.value="")}}),(0,s.jsx)("button",{className:t(Is)("memori-button","memori-button--circle","memori-button--icon-only","memori-share-button--button","memori--conversation-button","memori--document-upload-button",{"memori--error":a.length>0}),onClick:()=>{var e;return null===(e=h.current)||void 0===e?void 0:e.click()},disabled:i||n&&r.filter((e=>"image"!==e.type)).length>=n||!1,title:"Upload documents",children:i?(0,s.jsx)(Tm,{spinning:!0,className:"memori--upload-icon"}):(0,s.jsx)(t(c).Fragment,{children:(0,s.jsx)(QO,{className:"memori--upload-icon"})})}),(0,s.jsx)(aP,{width:"80%",widthMd:"80%",open:!!u,className:"memori--modal-preview-file",onClose:()=>d(null),closable:!0,title:null==u?void 0:u.name,children:(0,s.jsx)("div",{className:"memori--preview-content",style:{maxHeight:"70vh",overflowY:"auto",textAlign:"center",whiteSpace:"pre-wrap"},children:null==u?void 0:u.content})}),(0,s.jsx)("div",{className:"memori--error-message-container",children:a.map(((e,t)=>(0,s.jsx)(eD,{open:!0,type:e.severity,title:"Upload notification",description:e.message,onClose:()=>p(e.message),width:"350px"},`${e.message}-${t}`)))})]})};c=o("85Hg2");const aD=10485760,lD=[".jpg",".jpeg",".png"];var cD=({authToken:e="",apiUrl:n="",sessionID:r="",isMediaAccepted:i=!1,setDocumentPreviewFiles:o,documentPreviewFiles:a,onLoadingChange:l,maxImages:u=5,memoriID:d=""})=>{var h,p,m;const{t:f,i18n:g}=Ie(),v=n?ne(n):null,{backend:y,dialog:_}=v||{backend:{uploadAsset:null,uploadAssetUnlogged:null},dialog:{postMediumSelectedEvent:null,postMediumDeselectedEvent:null}},[S,b]=(0,c.useState)(!1),[x,C]=(0,c.useState)([]),[w,A]=(0,c.useState)(null),[E,I]=(0,c.useState)(null),[T,M]=(0,c.useState)(""),[R,P]=(0,c.useState)(!1),N=(0,c.useRef)(null);(0,c.useEffect)((()=>{l&&l(S)}),[S,l]);const O=e=>{C((t=>t.filter((t=>t.message!==e))))},D=e=>{C((t=>[...t,e])),setTimeout((()=>O(e.message)),5e3)},L=a.filter((e=>"image"===e.type)).length,k=()=>{P(!1),A(null),I(null),M("")};return(0,s.jsxs)("div",{className:"memori--image-upload-wrapper",children:[(0,s.jsx)("input",{ref:N,type:"file",accept:lD.join(","),className:"memori--upload-file-input",onChange:async e=>{var t;const n=Array.from(e.target.files||[]);if(0===n.length)return;if(L>=u)return void D({message:null!==(t=f("upload.maxImagesReached"))&&void 0!==t?t:`Maximum ${u} images allowed.`,severity:"error"});C([]);const r=n[0];if(!(e=>{var t;const n=`.${null===(t=e.name.split(".").pop())||void 0===t?void 0:t.toLowerCase()}`;return lD.includes(n)||e.type.startsWith("image/")?!(e.size>aD&&(D({message:`File "${e.name}" exceeds 10MB limit`,severity:"error",fileId:e.name}),1)):(D({message:`File type "${n}" is not supported. Please use: ${lD.join(", ")}`,severity:"error",fileId:e.name}),!1)})(r))return void(N.current&&(N.current.value=""));A(r),I(URL.createObjectURL(r));const i=r.name.split(".").slice(0,-1).join(".");M(i),P(!0),N.current&&(N.current.value="")},disabled:S||!i||L>=u}),(0,s.jsx)("button",{className:t(Is)("memori-button","memori-button--circle","memori-button--icon-only","memori-share-button--button","memori--conversation-button","memori--image-upload-button"),onClick:()=>{var e;return null===(e=N.current)||void 0===e?void 0:e.click()},disabled:S||!i||L>=u,children:S?(0,s.jsx)(Tm,{spinning:!0,className:"memori--upload-icon"}):(0,s.jsx)($O,{className:"memori--upload-icon"})}),(0,s.jsx)(aP,{width:"80%",widthMd:"80%",open:R&&!!w,className:"memori--modal-preview-file",onClose:k,closable:!0,title:f("upload.titleImage",{title:T}),children:(0,s.jsxs)("div",{className:"memori--preview-content",style:{maxHeight:"70vh",overflowY:"auto",textAlign:"center"},children:[E&&(0,s.jsx)("img",{src:E,alt:(null==w?void 0:w.name)||"Preview",style:{maxWidth:"100%",maxHeight:"40vh",marginBottom:"20px"}}),(0,s.jsxs)("div",{style:{maxWidth:"400px",margin:"0 auto",textAlign:"left"},children:[(0,s.jsx)("p",{style:{marginBottom:"10px",color:"#666"},children:f("upload.titleHelp")}),(0,s.jsx)("input",{value:T,onChange:e=>M(e.target.value),placeholder:null!==(h=f("upload.titlePlaceholder"))&&void 0!==h?h:"Enter image title",style:{width:"90%",marginBottom:"20px"},className:"memori--upload-title-input"}),(0,s.jsxs)("div",{style:{display:"flex",gap:"10px"},children:[(0,s.jsx)(Mm,{onClick:async()=>{var t;if(w&&T.trim()){b(!0),P(!1);try{const t=new FileReader;t.onload=async t=>{var i,s,l,c,u;const h=null===(i=t.target)||void 0===i?void 0:i.result,p=Math.random().toString(36).substr(2,9);if(n)try{let t,n;if(e&&(null==y?void 0:y.uploadAsset))n=await y.uploadAsset(w.name,h,e);else{if(!(d&&r&&(null==y?void 0:y.uploadAssetUnlogged)))throw new Error("Missing required parameters for upload");if(n=await y.uploadAssetUnlogged(w.name,h,d,r),!n)throw new Error("Upload failed")}if(t=n.asset,0!==n.resultCode)throw new Error(n.resultMessage||"Upload failed");let i,c=null;if((null==_?void 0:_.postMediumSelectedEvent)&&r&&(c=await _.postMediumSelectedEvent(r,{url:t.assetURL,mimeType:t.mimeType})),null===(s=null==c?void 0:c.currentState)||void 0===s?void 0:s.currentMedia){const e=new Set(a.map((e=>e.mediumID)));i=null===(l=c.currentState.currentMedia.find((t=>!e.has(t.mediumID))))||void 0===l?void 0:l.mediumID}o((e=>[...e,{name:T,id:p,url:t.assetURL,content:t.assetURL,type:"image",mediumID:i,mimeType:t.mimeType}]))}catch(e){D({message:null!==(c=f("upload.uploadFailed"))&&void 0!==c?c:"Upload failed",severity:"error",fileId:w.name})}else D({message:null!==(u=f("upload.apiClientNotConfigured"))&&void 0!==u?u:"API client not configured properly for media upload",severity:"warning"});b(!1)},t.onerror=()=>{var e;D({message:null!==(e=f("upload.fileReadingFailed"))&&void 0!==e?e:"File reading failed",severity:"error",fileId:w.name}),b(!1)},t.readAsDataURL(w)}catch(e){D({message:null!==(t=f("upload.uploadFailed"))&&void 0!==t?t:"Upload failed",severity:"error",fileId:w.name}),b(!1)}}},disabled:!w||!T.trim(),className:"memori-button memori-button--primary",children:null!==(p=f("confirm"))&&void 0!==p?p:"Confirm"}),(0,s.jsx)(Mm,{onClick:k,className:"memori-button memori-button--primary",children:null!==(m=f("cancel"))&&void 0!==m?m:"Cancel"})]})]})]})}),(0,s.jsx)("div",{className:"memori--error-message-container",children:x.map(((e,t)=>(0,s.jsx)(eD,{open:!0,type:e.severity,title:"Upload notification",description:e.message,onClose:()=>O(e.message),width:"350px"},`${e.message}-${t}`)))})]})};var uD=({authToken:e="",apiUrl:n="",sessionID:r="",isMediaAccepted:i=!1,setDocumentPreviewFiles:o,documentPreviewFiles:a,memoriID:l=""})=>{var u,d,h,p,m,f,g,v,y,_,S;const[b,x]=(0,c.useState)(!1),[C,w]=(0,c.useState)(!1),[A,E]=(0,c.useState)([]),{t:I,i18n:T}=Ie(),M=(0,c.useRef)(null),R=(0,c.useRef)(null),P=(0,c.useRef)(null),N=(0,c.useRef)(null),O=a.filter((e=>"image"===e.type)).length,D=5-O,L=a.filter((e=>"document"===e.type)).length,k=1-L,B=D<=0,z=k<=0,F=e=>{E((t=>t.filter((t=>t.message!==e))))},U=e=>{E((t=>[...t,e])),setTimeout((()=>F(e.message)),5e3)},j=()=>{w(!1)};(0,c.useEffect)((()=>{const e=e=>{M.current&&R.current&&!M.current.contains(e.target)&&!R.current.contains(e.target)&&j()};return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}}),[]);return(0,s.jsxs)("div",{className:"memori--unified-upload-wrapper",children:[(0,s.jsx)("button",{ref:R,className:t(Is)("memori-button","memori-button--circle","memori-button--icon-only","memori-share-button--button","memori--conversation-button","memori--unified-upload-button",{"memori--error":A.length>0}),onClick:()=>{w((e=>!e))},disabled:b,title:null!==(u=I("upload.uploadFiles"))&&void 0!==u?u:"Upload files",children:b?(0,s.jsx)(Tm,{spinning:!0,className:"memori--upload-icon"}):(0,s.jsx)(ZO,{className:"memori--upload-icon"})}),O>0&&(0,s.jsxs)("div",{className:t(Is)("memori--image-count",{"memori--image-count-full":B}),children:[O,"/",5]}),C&&(0,s.jsxs)("div",{className:"memori--upload-menu",ref:M,children:[(0,s.jsxs)("div",{className:t(Is)("memori--upload-menu-item",{"memori--upload-menu-item--disabled":z}),onClick:()=>{var e;const t=null===(e=P.current)||void 0===e?void 0:e.querySelector("button");t&&t.click(),j()},children:[(0,s.jsx)(QO,{className:"memori--upload-menu-icon"}),(0,s.jsxs)("span",{children:[null!==(d=I("upload.uploadDocument"))&&void 0!==d?d:"Upload document",L>0&&(0,s.jsx)("span",{className:"memori--upload-slots-info",children:z?` (${null!==(h=I("upload.maxReached"))&&void 0!==h?h:"Max reached"})`:` (${k} ${null!==(p=I("upload.remaining"))&&void 0!==p?p:"remaining"})`})]})]}),(0,s.jsxs)("div",{className:t(Is)("memori--upload-menu-item",{"memori--upload-menu-item--disabled":!i||B}),onClick:()=>{var e,t,n;if(!i)return U({message:null!==(e=I("upload.mediaNotAccepted"))&&void 0!==e?e:"Media uploads are not accepted",severity:"info"}),void j();if(B)return U({message:null!==(t=I("upload.maxImagesReached",{max:5}))&&void 0!==t?t:"Maximum 5 images already uploaded",severity:"warning"}),void j();const r=null===(n=N.current)||void 0===n?void 0:n.querySelector("button");r&&r.click(),j()},title:i?B?null!==(f=I("upload.maxImagesReached",{max:5}))&&void 0!==f?f:"Maximum 5 images already uploaded":1===D?null!==(g=I("upload.lastImageSlot"))&&void 0!==g?g:"Upload last image":null!==(v=I("upload.uploadImage",{remaining:D}))&&void 0!==v?v:`Upload image (${D} remaining)`:null!==(m=I("upload.mediaNotAccepted"))&&void 0!==m?m:"Media uploads not accepted",children:[(0,s.jsx)($O,{className:"memori--upload-menu-icon-image"}),(0,s.jsxs)("span",{children:[null!==(y=I("upload.uploadImage"))&&void 0!==y?y:"Upload image",O>0&&(0,s.jsx)("span",{className:"memori--upload-slots-info",children:B?` (${null!==(_=I("upload.maxReached"))&&void 0!==_?_:"Max reached"})`:` (${D} ${null!==(S=I("upload.remaining"))&&void 0!==S?S:"remaining"})`})]})]})]}),(0,s.jsx)("div",{className:"memori--hidden-uploader",ref:P,children:(0,s.jsx)(sD,{setDocumentPreviewFiles:e=>{if(0===e.length)return;const t=e[0];const n=`<document_attachment filename="${t.name.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}" type="${t.mimeType}">\n\n${t.content}\n\n</document_attachment>`,r=a.filter((e=>"image"===e.type));o([{name:t.name,id:t.id,content:n,type:"file",mimeType:t.mimeType},...r]),x(!1)},maxDocuments:1,documentPreviewFiles:a})}),(0,s.jsx)("div",{className:"memori--hidden-uploader",ref:N,children:(0,s.jsx)(cD,{authToken:e,apiUrl:n,setDocumentPreviewFiles:o,sessionID:r,documentPreviewFiles:a,isMediaAccepted:i,onLoadingChange:e=>{x(e)},maxImages:5,memoriID:l})}),(0,s.jsx)("div",{className:"memori--error-message-container",children:A.map(((e,t)=>(0,s.jsx)(eD,{open:!0,type:e.severity,title:"Upload notification",description:e.message,onClose:()=>F(e.message),width:"350px"},`${e.message}-${t}`)))})]})};c=o("85Hg2");var dD=({previewFiles:e,removeFile:t,allowRemove:n=!0,isMessagePreview:r=!1})=>{const[i,o]=(0,c.useState)(null),[a,l]=(0,c.useState)(null),u=(e,t)=>{var n,r;if("image"===t){switch(null===(n=e.split(".").pop())||void 0===n?void 0:n.toLowerCase()){case"jpg":case"jpeg":return"JPEG";case"png":return"PNG";default:return"Image"}}switch(null===(r=e.split(".").pop())||void 0===r?void 0:r.toLowerCase()){case"pdf":return"PDF";case"txt":return"Text";case"json":return"JSON";case"xlsx":return"Excel";case"csv":return"CSV";case"jpg":case"jpeg":return"JPEG";case"png":return"PNG";default:return"Document"}},d=(e,t)=>{if("image"===t)return!0;const n=/\.(jpg|jpeg|png|gif|webp|svg)$/i.test(e);return e.startsWith("http")&&(e.includes("/image/")||e.includes("/img/")||n)||n};return(0,s.jsxs)(s.Fragment,{children:[e.length>0&&(0,s.jsx)("div",{className:"memori--preview-container "+(r?"memori--message-preview":"memori--absolute-preview"),children:(0,s.jsx)("div",{className:"memori--preview-list",children:e.map((e=>(0,s.jsxs)("div",{className:"memori--preview-item "+(d(e.content,e.type)?"memori--preview-item--image":"memori--preview-item--document"),onMouseEnter:()=>l(e.id),onMouseLeave:()=>l(null),onClick:()=>o(e),children:[d(e.content,e.type)?(0,s.jsx)("div",{className:"memori--preview-thumbnail",children:(0,s.jsx)("img",{src:e.content,alt:e.name})}):(0,s.jsx)(QO,{className:"memori--preview-icon"}),(0,s.jsxs)("div",{className:"memori--preview-file-info",children:[(0,s.jsx)("span",{className:"memori--preview-filename",children:e.name}),(0,s.jsx)("span",{className:"memori--preview-filetype",children:u(e.name,e.type)})]}),n&&(0,s.jsx)(Mm,{shape:"rounded",icon:(0,s.jsx)(Rm,{}),danger:!0,className:"memori--remove-button "+(a===e.id?"visible":""),onClick:n=>{n.stopPropagation(),t(e.id,null==e?void 0:e.mediumID)}})]},e.id)))})}),(0,s.jsx)(aP,{width:"80%",widthMd:"80%",open:!!i,className:"memori--modal-preview-file",onClose:()=>o(null),closable:!0,title:null==i?void 0:i.name,children:(0,s.jsx)("div",{className:"memori--preview-content",style:{maxHeight:"70vh",overflowY:"auto",textAlign:"center",whiteSpace:i&&!d(i.content,i.type)?"pre-wrap":"normal"},children:i&&d(i.content,i.type)?(0,s.jsx)(s.Fragment,{children:(0,s.jsx)("img",{src:i.content,alt:i.name,style:{maxWidth:"100%",maxHeight:"60vh"}})}):gR((null==i?void 0:i.content)||"")})})]})};var hD=({dialogState:e,userMessage:n="",sendOnEnter:r,onChangeUserMessage:i,sendMessage:o,onTextareaFocus:a,onTextareaBlur:l,resetTranscript:u,showMicrophone:d=!1,microphoneMode:h="HOLD_TO_TALK",listening:p=!1,stopAudio:m,startListening:f,stopListening:g,showUpload:v=!1,sessionID:y,authToken:_,apiURL:S,memoriID:b})=>{const{t:x}=Ie(),[C,w]=(0,c.useState)([]),A=S?ne(S):null,{dialog:E}=A||{dialog:{postMediumDeselectedEvent:null}};return(0,s.jsxs)("fieldset",{id:"chat-fieldset",className:"memori-chat-inputs",disabled:"X2a"===(null==e?void 0:e.state)||"X3"===(null==e?void 0:e.state),children:[(0,s.jsx)(JO,{value:n,onChange:i,onPressEnter:()=>{"keypress"===r&&(null==n?void 0:n.length)>0&&(g(),o(n,C.map((e=>({mediumID:e.mediumID||"",mimeType:e.mimeType,content:e.content,title:e.name,properties:{isAttachedFile:!0},type:e.type,url:e.url})))),w([]),i(""),u())},onFocus:a,onBlur:l,disabled:["R2","R3","R4","R5","G3","X3"].includes((null==e?void 0:e.state)||"")}),v&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(dD,{previewFiles:C,removeFile:async(e,t)=>{console.log("removeFile",e),E.postMediumDeselectedEvent&&y&&t&&await E.postMediumDeselectedEvent(y,t),w((t=>t.filter((t=>t.id!==e))))}}),(0,s.jsx)(uD,{authToken:_,apiUrl:S,sessionID:y,isMediaAccepted:(null==e?void 0:e.acceptsMedia)||!1,setDocumentPreviewFiles:w,documentPreviewFiles:C,memoriID:b})]}),(0,s.jsx)(Mm,{shape:"circle",primary:!!(null==n?void 0:n.length),disabled:!n||0===n.length,className:"memori-chat-inputs--send",onClick:()=>{o(n,C.map((e=>({mediumID:e.mediumID||"",mimeType:e.mimeType,content:e.content,title:e.name,properties:{isAttachedFile:!0},type:e.type,url:e.url})))),w([]),m(),speechSynthesis.speak(new SpeechSynthesisUtterance(""))},title:x("send")||"Send",icon:(0,s.jsx)(KO,{})}),d&&"HOLD_TO_TALK"===h&&(0,s.jsx)(XO,{listening:p,startListening:f,stopListening:()=>{g(),(null==n?void 0:n.length)&&o(n)},stopAudio:m}),d&&"CONTINUOUS"===h&&(0,s.jsx)(Mm,{primary:!0,className:t(Is)("memori-chat-inputs--mic",{"memori-chat-inputs--mic--listening":p}),title:p?x("write_and_speak.micButtonPopoverListening")||"Listening":x("write_and_speak.micButtonPopover")||"Start listening",onClick:()=>{p?g():(m(),f())},shape:"circle",icon:(0,s.jsx)(YO,{})})]})};c=o("85Hg2");const pD=15,mD={en:[{delayAfter:pD,text:"Processing in progress..."},{delayAfter:pD,text:"I'm thinking..."},{delayAfter:pD,text:"Analysing the request..."},{delayAfter:pD,text:"Preparing the reply..."},{delayAfter:pD,text:"Gathering information..."},{delayAfter:pD,text:"Formulating ideas..."},{delayAfter:pD,text:"One moment please..."},{delayAfter:pD,text:"Almost ready..."},{delayAfter:pD,text:"Connecting concepts..."},{delayAfter:pD,text:"Organising ideas..."},{delayAfter:pD,text:"Evaluating options..."},{delayAfter:pD,text:"Looking for the best solution..."},{delayAfter:pD,text:"Working for you..."},{delayAfter:pD,text:"Please wait..."},{delayAfter:pD,text:"Processing data..."},{delayAfter:pD,text:"Calculating response..."},{delayAfter:pD,text:"Synthesising information..."},{delayAfter:pD,text:"Generating content..."},{delayAfter:pD,text:"Reflecting on question..."},{delayAfter:pD,text:"Refining the answer"}],it:[{delayAfter:pD,text:"Elaborazione in corso..."},{delayAfter:pD,text:"Sto pensando..."},{delayAfter:pD,text:"Analizzando la richiesta..."},{delayAfter:pD,text:"Preparando la risposta..."},{delayAfter:pD,text:"Raccogliendo informazioni..."},{delayAfter:pD,text:"Formulando idee..."},{delayAfter:pD,text:"Un momento per favore..."},{delayAfter:pD,text:"Quasi pronto..."},{delayAfter:pD,text:"Connettendo i concetti..."},{delayAfter:pD,text:"Organizzando le idee..."},{delayAfter:pD,text:"Valutando le opzioni..."},{delayAfter:pD,text:"Cercando la soluzione migliore..."},{delayAfter:pD,text:"Sto lavorando per te..."},{delayAfter:pD,text:"Attendere prego..."},{delayAfter:pD,text:"Elaborazione dati in corso..."},{delayAfter:pD,text:"Calcolando la risposta..."},{delayAfter:pD,text:"Sintetizzando informazioni..."},{delayAfter:pD,text:"Generando contenuti..."},{delayAfter:pD,text:"Sto riflettendo sulla domanda..."},{delayAfter:pD,text:"Perfezionando la risposta..."}]},fD=(e=15)=>new Array(20*e).fill(" ").join("");var gD=({useDefaultSentences:e=!1,lang:t="en",sentence:n,sentences:r})=>{var i;const[o,a]=(0,c.useState)(0),[l,u]=(0,c.useState)((null===(i=null==r?void 0:r[t])||void 0===i?void 0:i.length)?`${r[t][0].text.endsWith("...")||!r[t][0].text.length?r[t][0].text:`${r[t][0].text}...`}${fD(r[t][0].delayAfter)}`:n?`${n.endsWith("...")||!n.length?n:`${n}...`}${fD()}`:""),[d,h]=(0,c.useState)(""),[p,m]=(0,c.useState)(0);return(0,c.useEffect)((()=>{const i=setInterval((()=>{var i;m((e=>e+50));const s=l[d.length];if(void 0!==s&&l.length>0)h((e=>e+s));else if((null===(i=null==r?void 0:r[t])||void 0===i?void 0:i.length)&&o<r[t].length-1){const e=o+1,n=r[t][e];u(`${n.text.endsWith("...")||!n.text.length?n.text:`${n.text}...`}${fD(n.delayAfter)}`),h(""),a(e)}else if(!r&&!n&&(e||p>2e4)){const e=mD[t][Math.floor(Math.random()*mD[t].length)];u(`${e.text}${fD(e.delayAfter)}`),h("")}}),50);return()=>clearInterval(i)})),(0,s.jsx)("div",{className:"memori-chat--bubble",children:(0,s.jsxs)("div",{className:"memori-chat--bubble-typing",children:[(0,s.jsxs)("div",{id:"wave",children:[(0,s.jsx)("span",{className:"dot"}),(0,s.jsx)("span",{className:"dot"}),(0,s.jsx)("span",{className:"dot"})]}),l.length>0&&(0,s.jsx)("p",{children:d})]})})};var vD=(0,c.memo)((({memori:e,tenant:n,sessionID:r,baseUrl:i,apiUrl:o,translateTo:a,memoriTyping:l,typingText:u,showTypingText:d=!1,history:h=[],authToken:p,dialogState:m,simulateUserPrompt:f,showDates:g=!1,showContextPerLine:v=!1,showAIicon:y=!0,showWhyThisAnswer:_=!0,showCopyButton:S=!0,showTranslationOriginal:b=!1,preview:x=!1,instruct:C=!1,showInputs:w=!0,showMicrophone:A=!1,microphoneMode:E="HOLD_TO_TALK",sendOnEnter:I,setSendOnEnter:T,attachmentsMenuOpen:M,setAttachmentsMenuOpen:R,userMessage:P="",onChangeUserMessage:N,sendMessage:O,listening:D,setEnableFocusChatInput:L,isPlayingAudio:k,stopAudio:B,startListening:z,stopListening:F,resetTranscript:U,customMediaRenderer:j,user:G,userAvatar:H,showUpload:V=!1,experts:W,useMathFormatting:q=!1,isHistoryView:J=!1,showFunctionCache:K=!1})=>{var Y,X,Q,$,Z,ee,te;const ne=()=>{J||setTimeout((()=>{var e,t;let n=document.querySelectorAll(".memori-chat--bubble-container.memori-chat--bubble-from-user");null===(t=null===(e=n[n.length-1])||void 0===e?void 0:e.scrollIntoView)||void 0===t||t.call(e)}),200)};(0,c.useEffect)((()=>{!x&&!J&&ne()}),[h,x,J]);return(0,s.jsxs)("div",{className:t(Is)("memori-chat--wrapper",{"memori-chat-wrapper--translate":a}),id:"chat-wrapper",lang:null==a?void 0:a.toUpperCase(),"data-memori-lang":null!==($=null===(Q=null===(X=null===(Y=e.culture)||void 0===Y?void 0:Y.split("-"))||void 0===X?void 0:X[0])||void 0===Q?void 0:Q.toUpperCase())&&void 0!==$?$:"EN",children:[(0,s.jsx)("div",{className:t(Is)("memori-chat--history",{"memori-chat--history-touch":aR()}),children:(0,s.jsxs)("div",{className:t(Is)("memori-chat--content",{"memori-chat--content-touch":aR()}),children:[(0,s.jsx)("div",{className:t(Is)("memori-chat--cover"),style:{backgroundImage:`url("${RN({type:"cover",tenantID:null==n?void 0:n.name,resourceURI:e.coverURL,baseURL:i,apiURL:o})}"), url("${RN({type:"cover",tenantID:null==n?void 0:n.name,baseURL:i||"https://www.aisuru.com",apiURL:o})}")`}}),h.map(((l,u)=>{var d,p,x,C,w,A;return(0,s.jsxs)(t(c).Fragment,{children:[(0,s.jsx)(VO,{isFirst:0===u,message:l,memori:e,tenant:n,baseUrl:i,apiUrl:o,sessionID:r,simulateUserPrompt:f,showAIicon:y,showWhyThisAnswer:_,showTranslationOriginal:b,showFeedback:u===h.length-1&&!l.fromUser&&(null==m?void 0:m.acceptsFeedback),user:G,userAvatar:H,experts:W,showCopyButton:S,useMathFormatting:q,showFunctionCache:K},`chatbubble-${u}-${(null===(d=l.text)||void 0===d?void 0:d.includes("<document_attachment"))?"has-attachments":"no-attachments"}-${l.timestamp}`),g&&!!l.timestamp&&(0,s.jsx)("small",{className:"memori-chat--timestamp "+(l.fromUser?"text-right":"text-left"),children:new Intl.DateTimeFormat("it",{hour:"2-digit",minute:"2-digit",second:"2-digit"}).format(new Date(l.timestamp.endsWith("Z")?l.timestamp:`${l.timestamp}Z`))}),v&&!!Object.keys(null!==(p=l.contextVars)&&void 0!==p?p:{}).length&&(0,s.jsx)("div",{className:"memori-chat--context-vars",children:Object.keys(null!==(x=l.contextVars)&&void 0!==x?x:{}).map((e=>{var t,n,r;return"-"===(null===(t=l.contextVars)||void 0===t?void 0:t[e])?(0,s.jsx)("div",{className:"memori-chat--context-tag memori-chat--context-tag-canceled",children:(0,s.jsx)("span",{className:"memori-chat--context-tag-text",children:e})},e):"✔️"===(null===(n=l.contextVars)||void 0===n?void 0:n[e])?(0,s.jsx)("div",{className:"memori-chat--context-tag",children:(0,s.jsx)("span",{className:"memori-chat--context-tag-text",children:e})},e):(0,s.jsx)("div",{className:"memori-chat--context-tag",children:(0,s.jsxs)("span",{className:"memori-chat--context-tag-text",children:[e,": ",null===(r=l.contextVars)||void 0===r?void 0:r[e]]})},e)}))}),(0,s.jsx)(jO,{simulateUserPrompt:f,media:null===(C=null==l?void 0:l.media)||void 0===C?void 0:C.filter((e=>"text/html"!==e.mimeType&&"text/plain"!==e.mimeType)),links:null===(w=null==l?void 0:l.media)||void 0===w?void 0:w.filter((e=>"text/html"===e.mimeType)),sessionID:r,baseUrl:i,apiUrl:o,translateTo:a,customMediaRenderer:j,fromUser:l.fromUser})]},`${u}-${(null===(A=l.text)||void 0===A?void 0:A.includes("<document_attachment"))?"has-attachments":"no-attachments"}-${l.timestamp}`)})),(null==m?void 0:m.hints)&&m.hints.length>0&&!l&&(0,s.jsx)(jO,{simulateUserPrompt:f,hints:m.translatedHints?m.translatedHints:m.hints.map((e=>({text:e,originalText:e})))}),!!l&&(0,s.jsx)(gD,{useDefaultSentences:d,lang:a?"it"===a.toLowerCase()?"it":"en":"it"===(null===(te=null===(ee=null===(Z=e.culture)||void 0===Z?void 0:Z.split("-"))||void 0===ee?void 0:ee[0])||void 0===te?void 0:te.toLowerCase())?"it":"en",sentence:u,sentences:e.enableBoardOfExperts?pO:void 0},u),(0,s.jsx)("div",{id:"end-messages-ref"})]})}),w&&(0,s.jsx)(hD,{apiURL:o||"",resetTranscript:U,userMessage:P,onChangeUserMessage:N,dialogState:m,instruct:C,authToken:p,sendMessage:O,microphoneMode:E,sendOnEnter:I,setSendOnEnter:T,sessionID:r,showUpload:V,attachmentsMenuOpen:M,setAttachmentsMenuOpen:R,onTextareaFocus:()=>{var e,t,n,r;F();const i=aR();i&&L(!0),i&&window.innerWidth<=768&&(null===(t=null===(e=document.getElementById("chat-wrapper"))||void 0===e?void 0:e.classList)||void 0===t||t.add("chat-focused"),null===(r=null===(n=document.querySelector(".memori.memori-widget"))||void 0===n?void 0:n.classList)||void 0===r||r.add("chat-focused"),setTimeout((()=>{ne()}),300))},onTextareaBlur:()=>{var e,t,n,r,i;(null===(t=null===(e=document.getElementById("chat-wrapper"))||void 0===e?void 0:e.classList)||void 0===t?void 0:t.contains("chat-focused"))&&(null===(n=document.getElementById("chat-wrapper"))||void 0===n||n.classList.remove("chat-focused"),null===(i=null===(r=document.querySelector(".memori.memori-widget"))||void 0===r?void 0:r.classList)||void 0===i||i.remove("chat-focused"),ne())},startListening:z,stopListening:F,stopAudio:B,listening:D,isPlayingAudio:k,showMicrophone:A,memoriID:null==e?void 0:e.memoriID})]})}));c=o("85Hg2");var yD=({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,color:"currentColor",children:(0,s.jsx)("path",{fill:"currentColor",d:"M464 720a48 48 0 1096 0 48 48 0 10-96 0zm16-304v184c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V416c0-4.4-3.6-8-8-8h-48c-4.4 0-8 3.6-8 8zm475.7 440l-416-720c-6.2-10.7-16.9-16-27.7-16s-21.6 5.3-27.7 16l-416 720C56 877.4 71.4 904 96 904h832c24.6 0 40-26.6 27.7-48zm-783.5-27.9L512 239.9l339.8 588.2H172.2z"})});var _D=({memoriName:e,blockedUntil:t,notEnoughCredits:n=!1,showGiverInfo:r=!1,showTitle:i=!1,marginLeft:o=!1})=>{const{t:a}=Ie(),l=new Date(t||Date.now());return n||l>new Date(Date.now())?(0,s.jsx)(DN,{className:"blocked-memori-badge--tooltip",content:n?(0,s.jsx)(s.Fragment,{children:a("notEnoughCredits")}):(0,s.jsxs)(s.Fragment,{children:[!r&&a("memoriBlockedAnon",{name:e,date:new Intl.DateTimeFormat("it",{day:"numeric",month:"long",year:"numeric"}).format(l)}),r&&a("memoriBlockedUntil",{date:new Intl.DateTimeFormat("it",{day:"numeric",month:"long",year:"numeric"}).format(l)}),r&&` ${a("memoriBlockedReasonExceedChats")}`,r&&(0,s.jsx)("br",{}),r&&`\n${a("memoriBlockedGiverHelper")}`]}),children:(0,s.jsxs)("div",{className:"blocked-memori-badge--wrapper",children:[(0,s.jsx)("div",{className:"blocked-memori-badge "+(o?" margin-left":""),children:(0,s.jsx)(yD,{className:"blocked-memori-badge--icon"})}),i&&(0,s.jsx)("span",{className:"blocked-memori-badge--title",children:a("memoriBlockedTitle")})]})}):null};var SD=({className:e,title:t})=>(0,s.jsx)("svg",{...t?{}:{"aria-hidden":"true"},focusable:"false",role:"img",xmlns:"http://www.w3.org/2000/svg",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",width:"20",height:"16",viewBox:"0 0 640 512",className:e,"aria-label":t,children:(0,s.jsx)("path",{d:"M211.2 96a64 64 0 10-128 0 64 64 0 10128 0zM32 256c0 17.7 14.3 32 32 32h85.6c10.1-39.4 38.6-71.5 75.8-86.6-9.7-6-21.2-9.4-33.4-9.4H96c-35.3 0-64 28.7-64 64zm461.6 32H576c17.7 0 32-14.3 32-32 0-35.3-28.7-64-64-64h-96c-11.7 0-22.7 3.1-32.1 8.6 38.1 14.8 67.4 47.3 77.7 87.4zm-102.4-61.6c-6.9-1.6-14.2-2.4-21.6-2.4h-96c-8.5 0-16.7 1.1-24.5 3.1-30.8 8.1-55.6 31.1-66.1 60.9-3.5 10-5.5 20.8-5.5 32 0 17.7 14.3 32 32 32h224c17.7 0 32-14.3 32-32 0-11.2-1.9-22-5.5-32-10.8-30.7-36.8-54.2-68.9-61.6zM563.2 96a64 64 0 10-128 0 64 64 0 10128 0zm-241.6 96a80 80 0 100-160 80 80 0 100 160zM32 416c-17.7 0-32 14.3-32 32s14.3 32 32 32h576c17.7 0 32-14.3 32-32s-14.3-32-32-32H32z"})});var bD=({className:e,title:t})=>(0,s.jsxs)("svg",{...t?{}:{"aria-hidden":"true"},focusable:"false",role:"img",xmlns:"http://www.w3.org/2000/svg",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"3",width:"20",height:"20",viewBox:"0 0 48 48",className:e,"aria-label":t,children:[(0,s.jsx)("path",{d:"M30.106 48v-2.745a2.213 2.213 0 012.213-2.212h6.11a2.392 2.392 0 002.326-2.466v-3.223a1.834 1.834 0 01.459-1.145 2.912 2.912 0 00.712-1.926l-.007-.667a1.016 1.016 0 01.651-.952h1.067a1.363 1.363 0 001.051-.456 1.304 1.304 0 00.19-1.395 67.032 67.032 0 01-3.037-7.51 4.767 4.767 0 01-.217-1.507l-.002-4.994a14.513 14.513 0 00-.552-3.963l-.006-.022a13.959 13.959 0 00-3.137-5.702q-.479-.516-1.006-1.003a17.67 17.67 0 00-.677-.623A18.303 18.303 0 0024.194 1a19.617 19.617 0 00-12.539 4.489 17.555 17.555 0 00-3.945 21.69C9.945 31.507 11.694 38.622 12.14 46v2",strokeMiterlimit:10}),(0,s.jsx)("path",{d:"M27.917 12L31.417 12"}),(0,s.jsx)("path",{d:"M27.917 26L31.417 26"}),(0,s.jsx)("path",{d:"M29.667 12L29.667 26"}),(0,s.jsx)("path",{d:"M23.992 26L19.904 12 19.226 12 15.159 26"}),(0,s.jsx)("path",{d:"M16.854 21.133L22.276 21.133"})]});c=o("85Hg2");var xD=({className:e,title:t})=>(0,s.jsx)("svg",{width:"800px",height:"800px",viewBox:"0 0 24 24",fill:"none",...t?{}:{"aria-hidden":"true"},xmlns:"http://www.w3.org/2000/svg",className:e,"aria-label":t,color:"currentColor",children:(0,s.jsx)("path",{d:"M12 16H12.01M12 8V12M12 21C16.9706 21 21 16.9706 21 12C21 7.02944 16.9706 3 12 3C7.02944 3 3 7.02944 3 12C3 16.9706 7.02944 21 12 21Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})});var CD=({className:e,title:t})=>(0,s.jsxs)("svg",{width:"800px",height:"800px",viewBox:"0 0 24 24",fill:"none",...t?{}:{"aria-hidden":"true"},xmlns:"http://www.w3.org/2000/svg",className:e,"aria-label":t,children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"1.5"}),(0,s.jsx)("path",{d:"M12 17V11",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),(0,s.jsx)("circle",{cx:"1",cy:"1",r:"1",transform:"matrix(1 0 0 -1 11 9)",fill:"currentColor"})]});const wD={OpenAI:{statusUrl:"https://status.openai.com/api/v2/summary.json",statusPage:"https://status.openai.com/",apiComponentName:["Chat","Completions (legacy)"]},Mistral:{statusUrl:"https://status.mistral-data.com/api/v2/summary.json",statusPage:"https://status.mistral-data.com/",apiComponentName:["Mistral"]},Anthropic:{statusUrl:"https://status.anthropic.com/api/v2/summary.json",statusPage:"https://status.anthropic.com/",apiComponentName:["api.anthropic.com"]}};var AD=({forceStatus:e,provider:t="Anthropic"})=>{const{t:n}=Ie(),[r,i]=(0,c.useState)(null!=e?e:"operational"),[o,a]=(0,c.useState)(!1),l=wD[t],u=(0,c.useCallback)((async()=>l?(async e=>{try{const t=await fetch(e.statusUrl);if(!t.ok)return console.warn(`Status API returned ${t.status}`),"operational";const n=await t.json();if(n.incidents&&Array.isArray(n.incidents)&&n.incidents.length>0){const e=n.incidents.filter((e=>!["resolved","completed","postmortem"].includes(e.status.toLowerCase())));if(e.length>0){const t=e.some((e=>"critical"===e.impact||"major"===e.impact)),n=e.some((e=>"moderate"===e.impact));return t?"major_outage":n?"partial_outage":"degraded_performance"}}if(n.components){if(e.apiComponentName){const t=Array.isArray(e.apiComponentName)?e.apiComponentName:[e.apiComponentName];for(const e of t){const t=n.components.find((t=>t.name===e));if(t&&"operational"!==t.status)return t.status}}if(n.components.some((e=>"operational"!==e.status)))return"degraded_performance"}if(n.status&&"none"!==n.status.indicator){if("critical"===n.status.indicator)return"major_outage";if("major"===n.status.indicator)return"partial_outage";if("minor"===n.status.indicator)return"degraded_performance"}return"operational"}catch(e){return console.error("Error fetching provider status:",e),"operational"}})(l):"operational"),[l]);if((0,c.useEffect)((()=>{let t=!0;const n=new AbortController;return(async()=>{if(!e){a(!0);try{const e=await u();t&&i(e)}catch(e){console.error("Failed to check status:",e),t&&i("operational")}finally{t&&a(!1)}}})(),()=>{t=!1,n.abort()}}),[e,u]),o)return(0,s.jsx)("div",{className:"memori--completion-provider-status--loading",children:(0,s.jsx)(Tm,{spinning:!0})});if(!r||"operational"===r)return null;const{Icon:d,message:h,className:p}=(()=>{switch(r){case"major_outage":return{Icon:xD,message:n("completionProviderMajorOutage",{provider:null!=t?t:n("completionProviderFallbackName"),fallback:n("completionProviderDown",{provider:null!=t?t:n("completionProviderFallbackName")})}),className:"memori--completion-provider-status--icon-error"};case"partial_outage":return{Icon:yD,message:n("completionProviderPartialOutage",{provider:null!=t?t:n("completionProviderFallbackName"),fallback:n("completionProviderDown",{provider:null!=t?t:n("completionProviderFallbackName")})}),className:"memori--completion-provider-status--icon-warning"};default:return{Icon:CD,message:n("completionProviderDegraded",{provider:null!=t?t:n("completionProviderFallbackName"),fallback:n("completionProviderDown",{provider:null!=t?t:n("completionProviderFallbackName")})}),className:"memori--completion-provider-status--icon-info"}}})();return(0,s.jsx)(DN,{className:"memori--completion-provider-status--tooltip",align:"right",content:(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{children:h}),(null==l?void 0:l.statusPage)&&(0,s.jsx)("p",{children:(0,s.jsx)("a",{href:l.statusPage,rel:"noopener noreferrer",target:"_blank",children:n("completionProviderCheckStatusPage")})})]}),children:(0,s.jsx)(d,{className:`memori--completion-provider-status--icon ${p}`})})};var ED=({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 ID=({memori:e,tenant:t,language:n,userLang:r,setUserLang:i,baseUrl:o,apiUrl:a,position:l,openPositionDrawer:u,instruct:d=!1,hasInitialSession:h=!1,clickedStart:p,onClickStart:m,initializeTTS:f,_TEST_forceProviderStatus:g,isUserLoggedIn:v=!1,user:y,showLogin:_=!1,setShowLoginDrawer:S,notEnoughCredits:b=!1,isMultilanguageEnabled:x})=>{var C,w;const{t:A,i18n:E}=Ie(),[I,T]=(0,c.useState)(e.description),[M,R]=(0,c.useState)(!0);return(0,c.useEffect)((()=>{var t,r,i,s,a,l;(null!==(r=null===(t=E.language)||void 0===t?void 0:t.toUpperCase())&&void 0!==r?r:"IT")===(null!==(i=null==n?void 0:n.toUpperCase())&&void 0!==i?i:"IT")&&I===e.description||!(null===(s=e.description)||void 0===s?void 0:s.length)||OO(e.description,null!==(l=null===(a=E.language)||void 0===a?void 0:a.toUpperCase())&&void 0!==l?l:"IT",n,o).then((e=>{T(e.text)})).catch(console.error)}),[E.language,n,e.description,o]),(0,s.jsxs)("div",{className:"memori--start-panel",children:[(0,s.jsxs)("div",{className:"memori--cover",style:{backgroundImage:`url("${RN({type:"cover",tenantID:null==t?void 0:t.name,resourceURI:e.coverURL,baseURL:o,apiURL:a})}"), url("${RN({type:"cover",tenantID:null==t?void 0:t.name,baseURL:o,apiURL:a})}")`},children:[!!e.enableCompletions&&!e.enableBoardOfExperts&&(0,s.jsx)("div",{className:"memori--completions-enabled",children:(0,s.jsx)(DN,{align:"left",content:A("completionsEnabled"),children:(0,s.jsx)("span",{"aria-label":A("completionsEnabled")||"Completions",children:(0,s.jsx)(NN,{})})})}),!!e.enableBoardOfExperts&&(0,s.jsx)("div",{className:"memori--board-of-experts",children:(0,s.jsx)(DN,{align:"left",content:A("boardOfExperts"),children:(0,s.jsx)("span",{"aria-label":A("boardOfExperts")||"Board of Experts",children:(0,s.jsx)(SD,{})})})}),!!e.nsfw&&(0,s.jsx)("div",{className:"memori--nsfw",children:(0,s.jsx)(DN,{align:"left",content:A("nsfw"),children:(0,s.jsx)("span",{title:A("nsfw")||"NSFW",children:"🔞"})})})]}),(0,s.jsxs)("picture",{className:"memori--avatar",children:[(0,s.jsx)("source",{src:null!==(C=e.avatarURL)&&void 0!==C?C:RN({type:"avatar",tenantID:null==t?void 0:t.name,resourceURI:e.avatarURL,baseURL:o,apiURL:a})}),(0,s.jsx)("img",{alt:e.name,src:e.avatarURL&&e.avatarURL.length>0?RN({type:"avatar",tenantID:null==t?void 0:t.name,resourceURI:e.avatarURL,baseURL:o,apiURL:a}):RN({type:"avatar",tenantID:null==t?void 0:t.name,baseURL:o,apiURL:a})})]}),(0,s.jsx)("h2",{className:"memori--title",children:e.name}),e.needsPosition&&!l&&(0,s.jsxs)("div",{className:"memori--needsPosition",children:[(0,s.jsx)("p",{children:A("write_and_speak.requirePositionHelp",{name:e.name})}),(0,s.jsx)(Mm,{primary:!0,onClick:()=>u(),className:"memori--start-button",icon:(0,s.jsx)(ED,{}),children:A("widget.position")})]}),(e.needsPosition&&l||!e.needsPosition)&&!!e.requireLoginToken&&!v&&(0,s.jsxs)("div",{className:"memori--needsLogin",children:[(0,s.jsx)("p",{children:A("write_and_speak.requirePositionHelp",{name:e.name})}),(0,s.jsx)(Mm,{primary:!0,onClick:()=>S(!0),className:"memori--start-button",icon:(0,s.jsx)(PN,{}),children:A("login.login")||"Login"})]}),(e.needsPosition&&l||!e.needsPosition)&&(!e.requireLoginToken||e.requireLoginToken&&v)&&(0,s.jsxs)("div",{className:"memori--description",children:[(0,s.jsxs)("p",{children:[(0,s.jsx)("span",{className:"memori--description-text",children:I&&M?I:e.description}),I!==e.description&&(0,s.jsx)(Mm,{ghost:!0,className:"memori--translation-toggle",icon:(0,s.jsx)(ON,{}),onClick:()=>{R((e=>!e))},children:A(M?"showOriginalText":"showTranslatedText")})]}),x&&!d&&(0,s.jsxs)("div",{className:"memori--language-chooser",children:[(0,s.jsx)("label",{id:"user-lang-pref-label",htmlFor:"user-lang-pref",children:A("write_and_speak.iWantToTalkToIn",{name:e.name})}),(0,s.jsx)("select",{id:"user-lang-pref",className:"memori-select--button",value:(null!=r?r:E.language).toUpperCase(),"aria-labelledby":"user-lang-pref-label",onChange:e=>{i(e.target.value)},children:lO.map((e=>(0,s.jsx)("option",{value:e.value,"aria-label":e.label,children:e.label},e.value)))})]}),(0,s.jsxs)("div",{className:"memori--start-privacy-explanation-container",children:[(0,s.jsx)("p",{className:"memori--start-privacy-explanation",children:A("write_and_speak.pagePrivacyExplanation")}),(0,s.jsx)(DN,{align:"right",content:(0,s.jsxs)("div",{className:"memori--privacy-tooltip-content",children:[(0,s.jsxs)("p",{children:[" ",A("write_and_speak.pagePrivacyExplanationList.allConversations")]}),(0,s.jsxs)("ul",{className:"memori--privacy-tooltip-content-list",children:[(0,s.jsx)("li",{children:A("write_and_speak.pagePrivacyExplanationList.anonymousUser")}),(0,s.jsx)("li",{children:A("write_and_speak.pagePrivacyExplanationList.registeredUser")})]}),(0,s.jsx)("p",{children:A("write_and_speak.pagePrivacyExplanationList.authorUsesInfo")}),(0,s.jsx)("a",{href:"https://memori.ai/en/privacy-policy",target:"_blank",rel:"noopener noreferrer",children:A("privacyPolicy")})]}),children:(0,s.jsx)(nO,{className:"memori--start-privacy-explanation-icon"})})]}),(0,s.jsx)(Mm,{primary:!0,disabled:!!e.blockedUntil&&!e.isGiver||b,loading:p,onClick:e=>{try{window.speechSynthesis.speak(new SpeechSynthesisUtterance(""))}catch(e){console.error(e)}f&&f(),m&&m()},className:"memori--start-button",children:A("write_and_speak."+(d?"instructButton":h?"resumeButton":"tryMeButton"))}),(0,s.jsx)(AD,{provider:null===(w=null==e?void 0:e.completionConfigForQuestionAnswering)||void 0===w?void 0:w.provider,forceStatus:g}),(0,s.jsx)("p",{className:"memori--start-description",children:A(d?"write_and_speak.pageInstructExplanation":"write_and_speak.pageTryMeExplanation")}),(e.blockedUntil||b)&&(0,s.jsx)(_D,{memoriName:e.name,blockedUntil:e.blockedUntil,notEnoughCredits:b,showGiverInfo:e.isGiver,showTitle:!0,marginLeft:!0}),!!e.enableDeepThought&&!d&&(0,s.jsxs)("div",{className:"memori--deep-thought-disclaimer",children:[(0,s.jsx)(DN,{align:"left",content:A("deepThoughtHelper"),children:(0,s.jsx)(bD,{})}),(0,s.jsx)("h2",{children:v&&(null==y?void 0:y.pAndCUAccepted)?A("deepThoughtDisclaimerTitle"):A("deepThought")}),v&&!(null==y?void 0:y.pAndCUAccepted)&&(0,s.jsx)("p",{children:A("deepThoughtPreDisclaimerNotAllowed")}),!v&&(0,s.jsx)("p",{children:A("deepThoughtPreDisclaimerUnlogged")}),!v&&_&&(0,s.jsx)("p",{children:(0,s.jsx)(Mm,{outlined:!0,padded:!1,onClick:()=>S(!0),children:A("login.login")||"Login"})}),(0,s.jsx)("p",{className:"memori--deep-thought-disclaimer-text",children:A("deepThoughtDisclaimer")})]})]})]})},TD=(c=o("85Hg2"),c=o("85Hg2"),re=o("hcaHr"),{}),MD={};(MD=function(e,t){if(null==e)return{};var n,r,i={},o=Object.keys(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||(i[n]=e[n]);return i}).__esModule=!0,MD.default=MD,(TD=function(e,t){if(null==e)return{};var n,r,i=MD(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}).__esModule=!0,TD.default=TD;c=o("85Hg2");var RD=["forwardedRef"];function PD(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 ND(e){for(var n=1;n<arguments.length;n++){var r=null!=arguments[n]?arguments[n]:{};n%2?PD(Object(r),!0).forEach((function(n){t(ie)(e,n,r[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):PD(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}class OD extends c.Component{constructor(){super(...arguments),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0}}componentDidCatch(e,t){console.error("Uncaught error:",e,t)}render(){return this.state.hasError?this.props.fallback?this.props.fallback:(0,s.jsxs)("div",{style:{background:"rgba(255, 255, 255, 0.4)",color:"#000",padding:"2rem",borderRadius:"10px"},children:[(0,s.jsx)("h2",{children:this.props.t("error.generic")}),(0,s.jsx)(Mm,{primary:!0,onClick:()=>this.setState({hasError:!1}),children:this.props.t("error.tryAgain")||"Try again"})]}):this.props.children}}var DD=function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(r){function i(i){var o=i.forwardedRef,s=t(TD)(i,RD),a=Ie(e,ND(ND({},s),{},{keyPrefix:n.keyPrefix})),l=t(re)(a,3),u=l[0],d=l[1],h=l[2],p=ND(ND({},s),{},{t:u,i18n:d,tReady:h});return n.withRef&&o?p.ref=o:!n.withRef&&o&&(p.forwardedRef=o),(0,c.createElement)(r,p)}i.displayName="withI18nextTranslation(".concat(Ce(r),")"),i.WrappedComponent=r;return n.withRef?(0,c.forwardRef)((function(e,t){return(0,c.createElement)(i,Object.assign({},e,{forwardedRef:t}))})):i}}(["common"])(OD);var LD=({avatar:e,speaking:n=!1})=>(0,s.jsxs)("div",{className:t(Is)("memori-blob",{"memori-blob--speaking":n}),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 kD=({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 BD=({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 zD=({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"})}),FD=(c=o("85Hg2"),c=o("85Hg2"),c=o("85Hg2"),{});Object.defineProperty(FD,"__esModule",{value:!0});c=o("85Hg2");function UD(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 s=r(t);function a(){var n=r(t);if(!o(s,n)){var i=s;e(s=n,i)}}return n.add(a),function(){return n.delete(a)}}(e,r,o):(n.add(e),function(){return n.delete(e)})},destroy:function(){return n.clear()}};return t=e(r,i,o),o}var jD="undefined"==typeof window||!window.navigator||/ServerSideRendering|^Deno\//.test(window.navigator.userAgent)?c.useEffect:c.useLayoutEffect;FD.default=function(e){var t="function"==typeof e?UD(e):e,n=function(e,n){void 0===e&&(e=t.getState),void 0===n&&(n=Object.is);var r,i=c.useReducer((function(e){return e+1}),0)[1],o=t.getState(),s=c.useRef(o),a=c.useRef(e),l=c.useRef(n),u=c.useRef(!1),d=c.useRef();void 0===d.current&&(d.current=e(o));var h=!1;(s.current!==o||a.current!==e||l.current!==n||u.current)&&(r=e(o),h=!n(d.current,r)),jD((function(){h&&(d.current=r),s.current=o,a.current=e,l.current=n,u.current=!1}));var p=c.useRef(o);jD((function(){var e=function(){try{var e=t.getState(),n=a.current(e);l.current(d.current,n)||(s.current=e,d.current=n,i())}catch(e){u.current=!0,i()}},n=t.subscribe(e);return t.getState()!==p.current&&e(),n}),[]);var m=h?r:d.current;return c.useDebugValue(m),m};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 GD;GD=o("YtP34");var HD,VD=o("kMsGZ");HD=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 s=o[i];if(!e(t[s],n[s]))return!1}return!0}return t!=t&&n!=n};const WD=[];function qD(e,n,r,i=0,o=!1){for(const e of n)if(t(HD)(r,e.args)){if(o)return;if(e.error)throw e.error;if(e.response)return e.response;throw e.promise}const s={args:r,promise:e(...r).then((e=>s.response=null==e||e)).catch((e=>s.error=null!=e?e:"unknown error")).then((()=>{i>0&&setTimeout((()=>{const e=n.indexOf(s);-1!==e&&n.splice(e,1)}),i)}))};if(n.push(s),!o)throw s.promise}function JD(e,...n){if(void 0===n||0===n.length)e.splice(0,e.length);else{const r=e.find((e=>t(HD)(n,e.args)));if(r){const t=e.indexOf(r);-1!==t&&e.splice(t,1)}}}function KD(e,...t){return qD(e,WD,t,KD.lifespan)}KD.lifespan=0,KD.clear=(...e)=>JD(WD,...e),KD.preload=(e,...t)=>{qD(e,WD,t,KD.lifespan,!0)},KD.peek=(...e)=>{var n;return null==(n=WD.find((n=>t(HD)(e,n.args))))?void 0:n.response};var YD,XD=function(e){return function(t){e.forEach((function(e){"function"==typeof e?e(t):null!=e&&(e.current=t)}))}};c=o("85Hg2");function QD(e,t,n){var r,i,o,s,a;function l(){var c=Date.now()-s;c<t&&c>=0?r=setTimeout(l,t-c):(r=null,n||(a=e.apply(o,i),o=i=null))}null==t&&(t=100);var c=function(){o=this,i=arguments,s=Date.now();var c=n&&!r;return r||(r=setTimeout(l,t)),c&&(a=e.apply(o,i),o=i=null),a};return c.clear=function(){r&&(clearTimeout(r),r=null)},c.flush=function(){r&&(a=e.apply(o,i),o=i=null,clearTimeout(r),r=null)},c}function $D(e){let{debounce:n,scroll:r,polyfill:i,offsetSize:o}=void 0===e?{debounce:0,scroll:!1,offsetSize:!1}:e;const s=i||("undefined"==typeof window?class{}:window.ResizeObserver);if(!s)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[a,l]=(0,c.useState)({left:0,top:0,width:0,height:0,bottom:0,right:0,x:0,y:0}),u=(0,c.useRef)({element:null,scrollContainers:null,resizeObserver:null,lastBounds:a}),d=n?"number"==typeof n?n:n.scroll:null,h=n?"number"==typeof n?n:n.resize:null,p=(0,c.useRef)(!1);(0,c.useEffect)((()=>(p.current=!0,()=>{p.current=!1})));const[m,f,g]=(0,c.useMemo)((()=>{const e=()=>{if(!u.current.element)return;const{left:e,top:t,width:n,height:r,bottom:i,right:s,x:a,y:c}=u.current.element.getBoundingClientRect(),d={left:e,top:t,width:n,height:r,bottom:i,right:s,x:a,y:c};u.current.element instanceof HTMLElement&&o&&(d.height=u.current.element.offsetHeight,d.width=u.current.element.offsetWidth),Object.freeze(d),p.current&&!tL(u.current.lastBounds,d)&&l(u.current.lastBounds=d)};return[e,h?t(YD)(e,h):e,d?t(YD)(e,d):e]}),[l,o,d,h]);function v(){u.current.scrollContainers&&(u.current.scrollContainers.forEach((e=>e.removeEventListener("scroll",g,!0))),u.current.scrollContainers=null),u.current.resizeObserver&&(u.current.resizeObserver.disconnect(),u.current.resizeObserver=null)}function y(){u.current.element&&(u.current.resizeObserver=new s(g),u.current.resizeObserver.observe(u.current.element),r&&u.current.scrollContainers&&u.current.scrollContainers.forEach((e=>e.addEventListener("scroll",g,{capture:!0,passive:!0}))))}var _,S,b;return _=g,S=Boolean(r),(0,c.useEffect)((()=>{if(S){const e=_;return window.addEventListener("scroll",e,{capture:!0,passive:!0}),()=>{window.removeEventListener("scroll",e,!0)}}}),[_,S]),b=f,(0,c.useEffect)((()=>{const e=b;return window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}}),[b]),(0,c.useEffect)((()=>{v(),y()}),[r,g,f]),(0,c.useEffect)((()=>v),[]),[e=>{e&&e!==u.current.element&&(v(),u.current.element=e,u.current.scrollContainers=ZD(e),y())},a,m]}function ZD(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,...ZD(e.parentElement)]}QD.debounce=QD,YD=QD;const eL=["x","y","top","bottom","left","right","width","height"],tL=(e,t)=>eL.every((n=>e[n]===t[n]));const nL={obj:e=>e===Object(e)&&!nL.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(nL.str(e)||nL.num(e)||nL.obj(e))return e===t;if(nL.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!nL.und(n)||e===t}};function rL(e){return(e.eventObject||e.object).uuid+"/"+e.index+e.instanceId}function iL(e,t,n,r){const i=n.get(t);i&&(n.delete(t),0===n.size&&(e.delete(r),i.target.releasePointerCapture(r)))}function oL(e){const t=new af.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(rL(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 s=>{const{onPointerMissed:a,internal:l}=e.getState();!function(t){var n;const r=e.getState(),{raycaster:i,mouse:o,camera:s,size:a}=r,{offsetX:l,offsetY:c}=null!=(n=null==i.computeOffsets?void 0:i.computeOffsets(t,r))?n:t,{width:u,height:d}=a;o.set(l/u*2-1,-c/d*2+1),i.setFromCamera(o,s)}(s),l.lastEvent.current=s;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,s=[],a=t?t(i.interaction):i.interaction;let l=r.intersectObjects(a,!0).filter((e=>{const t=rL(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&&s.push({...e,eventObject:t}),t=t.parent}}return s}(c?n:void 0),s),h=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))}(s):0;"onPointerDown"===o&&(l.initialClick=[s.offsetX,s.offsetY],l.initialHits=d.map((e=>e.eventObject))),u&&!d.length&&h<=2&&(i(s,l.interaction),a&&a(s)),c&&r(d),function(n,i,o,s){const{raycaster:a,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 h=e=>{var n,r;return null!=(n=null==(r=u.capturedMap.get(e))?void 0:r.has(t.eventObject))&&n},p=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)},m=e=>{const n=u.capturedMap.get(e);n&&iL(u.capturedMap,t.eventObject,n,e)};let f={};for(let e in i){let t=i[e];"function"!=typeof t&&(f[e]=t)}let g={...t,...f,spaceX:l.x,spaceY:l.y,intersections:n,stopped:d.stopped,delta:o,unprojectedPoint:e,ray:a.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:h,setPointerCapture:p,releasePointerCapture:m},currentTarget:{hasPointerCapture:h,setPointerCapture:p,releasePointerCapture:m},sourceEvent:i,nativeEvent:i};if(s(g),!0===d.stopped)break}}}(d,s,h,(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=rL(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(s,l.interaction.filter((e=>!l.initialHits.includes(e)))),n(e)):u&&l.initialHits.includes(t)&&i(s,l.interaction.filter((e=>!l.initialHits.includes(e))))}}))}}}}const sL=e=>e&&!!e.getState,aL=(e,t)=>{var n,r;return{root:sL(e)?e:null!=(n=null==(r=e.__r3f)?void 0:r.root)?n:t.__r3f.root,container:sL(e)?e.getState().scene:e}},lL="__default",cL={};let uL={};function dL(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 hL=e=>e&&e.isOrthographicCamera;function pL(e){return Array.isArray(e)?Math.min(Math.max(e[0],window.devicePixelRatio),e[1]):e}const mL=c.createContext(null);let fL,gL=[],vL=[],yL=[];function _L(e,t){for(fL=0;fL<e.length;fL++)e[fL](t)}function SL(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),fL=0;fL<t.internal.subscribers.length;fL++)t.internal.subscribers[fL].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 bL(e){const{handlePointer:t}=oL(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 xL="undefined"!=typeof window?c.useLayoutEffect:c.useEffect;function CL({set:e}){return xL((()=>(e(new Promise((()=>null))),()=>e(!1))),[]),null}class wL extends c.Component{constructor(...e){super(...e),this.state={error:!1}}componentDidCatch(e){this.props.set(e)}render(){return this.state.error?null:this.props.children}}wL.getDerivedStateFromError=()=>({error:!0});const AL=c.forwardRef((function({children:e,fallback:n,tabIndex:r,resize:i,id:o,style:s,className:a,events:l,...u},d){const[h,{width:p,height:m}]=$D({scroll:!0,debounce:{scroll:50,resize:0},...i}),f=c.useRef(null),[g,v]=c.useState(!1),[y,_]=c.useState(!1);if(g)throw g;if(y)throw y;return xL((()=>{p>0&&m>0&&function(e,n,{gl:r,size:i,mode:o=OL[1],events:s,onCreated:a,...l}={}){var u,d,h,p,m;i||(i={width:null!=(d=null==(h=n.parentElement)?void 0:h.clientWidth)?d:0,height:null!=(p=null==(m=n.parentElement)?void 0:m.clientHeight)?p:0});let f=NL.get(n),g=null==f?void 0:f.fiber,v=null==f?void 0:f.store,y=null==(u=v)?void 0:u.getState();if(g&&y){void 0===l.dpr||nL.equ(y.viewport.dpr,pL(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&&(FL(n),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 af.WebGLRenderer({powerPreference:"high-performance",canvas:t,antialias:!0,alpha:!0,...e});i.outputEncoding=af.sRGBEncoding,i.toneMapping=af.ACESFilmicToneMapping,e&&BL(i,e);return i})(r,n);l.vr&&(e.xr.enabled=!0,e.setAnimationLoop((e=>LL(e,!0)))),v=((e,n,r,i)=>{const{gl:o,size:s,shadows:a=!1,linear:l=!1,flat:u=!1,vr:d=!1,orthographic:h=!1,frameloop:p="always",dpr:m=1,performance:f,clock:g=new af.Clock,raycaster:v,camera:y,onPointerMissed:_}=i;a&&(o.shadowMap.enabled=!0,"object"==typeof a?Object.assign(o.shadowMap,a):o.shadowMap.type=af.PCFSoftShadowMap),l&&(o.outputEncoding=af.LinearEncoding),u&&(o.toneMapping=af.NoToneMapping),"never"===p&&(g.stop(),g.elapsedTime=0);const S=t(FD)(((t,s)=>{const a=new af.Raycaster,{params:S,...b}=v||{};e(a,{enabled:!0,...b,params:{...a.params,...S}});const x=y instanceof af.Camera,C=x?y:h?new af.OrthographicCamera(0,0,0,0,.1,1e3):new af.PerspectiveCamera(75,0,.1,1e3);x||(C.position.z=5,y&&e(C,y),null!=y&&y.rotation||C.lookAt(0,0,0));const w=pL(m),A=new af.Vector3,E=new af.Vector3,I=new af.Vector3;function T(e=s().camera,t=E,n=s().size){const{width:r,height:i}=n,o=r/i;t instanceof af.Vector3?I.copy(t):I.set(...t);const a=e.getWorldPosition(A).distanceTo(I);if(hL(e))return{width:r/e.zoom,height:i/e.zoom,factor:1,distance:a,aspect:o};{const t=e.fov*Math.PI/180,n=2*Math.tan(t/2)*a,s=n*(r/i);return{width:s,height:n,factor:r/s,distance:a,aspect:o}}}let M;const R=e=>t((t=>({performance:{...t.performance,current:e}})));return{gl:o,set:t,get:s,invalidate:()=>n(s()),advance:(e,t)=>r(e,t,s()),linear:l,flat:u,scene:dL(new af.Scene),camera:C,controls:null,raycaster:a,clock:g,mouse:new af.Vector2,vr:d,frameloop:p,onPointerMissed:_,performance:{current:1,min:.5,max:1,debounce:200,...f,regress:()=>{const e=s();M&&clearTimeout(M),e.performance.current!==e.performance.min&&R(e.performance.min),M=setTimeout((()=>R(s().performance.max)),e.performance.debounce)}},size:{width:0,height:0},viewport:{initialDpr:w,dpr:w,width:0,height:0,aspect:0,distance:0,factor:0,getCurrentViewport:T},setSize:(e,n)=>{const r={width:e,height:n};t((e=>({size:r,viewport:{...e.viewport,...T(C,E,r)}})))},setDpr:e=>t((t=>({viewport:{...t.viewport,dpr:pL(e)}}))),setFrameloop:(e="always")=>t((()=>({frameloop:e}))),events:{connected:!1},internal:{active:!1,priority:0,frames:0,lastProps:i,lastEvent:c.createRef(),interaction:[],hovered:new Map,subscribers:[],initialClick:[0,0],initialHits:[],capturedMap:new Map,subscribe:(e,n=0)=>(t((({internal:t})=>({internal:{...t,priority:t.priority+(n>0?1:0),subscribers:[...t.subscribers,{ref:e,priority:n}].sort(((e,t)=>e.priority-t.priority))}}))),()=>{t((({internal:t})=>({internal:{...t,priority:t.priority-(n>0?1:0),subscribers:t.subscribers.filter((t=>t.ref!==e))}})))})}}})),b=S.getState();let x=b.size,C=b.viewport.dpr;return S.subscribe((()=>{const{camera:e,size:t,viewport:n,internal:r}=S.getState();t===x&&n.dpr===C||(e.manual||r.lastProps.camera instanceof af.Camera||(hL(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),x=t,C=n.dpr)})),s&&b.setSize(s.width,s.height),S.subscribe((e=>n(e))),S})(BL,DL,LL,{gl:e,size:i,...l});const a=v.getState();g=kL.createContainer(v,OL.indexOf(o),!1,null),NL.set(n,{fiber:g,store:v}),s&&a.set({events:s(v)})}if(v&&g)return kL.updateContainer(c.createElement(zL,{store:v,element:e,onCreated:a,target:n}),g,null,(()=>{})),v;throw"Error creating root!"}(c.createElement(wL,{set:_},c.createElement(c.Suspense,{fallback:c.createElement(CL,{set:v})},e)),f.current,{...u,size:{width:p,height:m},events:l||bL})}),[p,m,e]),xL((()=>{const e=f.current;return()=>FL(e)}),[]),c.createElement("div",{ref:h,id:o,className:a,tabIndex:r,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden",...s}},c.createElement("canvas",{ref:XD([f,d]),style:{display:"block"}},n))}));function EL(){const e=c.useContext(mL);if(!e)throw"R3F hooks can only be used within the Canvas component!";return e}function IL(e=(e=>e),t){return EL()(e,t)}function TL(e,t=0){const n=EL().getState().internal.subscribe,r=c.useRef(e);return c.useLayoutEffect((()=>{r.current=e}),[e]),c.useLayoutEffect((()=>n(r,t)),[t,n]),null}function ML(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 RL(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,ML(e.scene)),n(e)}),t,(t=>r(`Could not load ${e}: ${t.message}`))))))))}}function PL(e,t,n,r){const i=Array.isArray(t)?t:[t],o=KD(RL(n,r),e,...i);return Array.isArray(t)?o:o[0]}PL.preload=function(e,t,n){const r=Array.isArray(t)?t:[t];return KD.preload(RL(n),e,...r)},PL.clear=function(e,t){const n=Array.isArray(t)?t:[t];return KD.clear(e,...n)};const NL=new Map,OL=["legacy","blocking","concurrent"],{invalidate:DL,advance:LL}=function(e){let t,n=!1;function r(i){if(n=!0,t=0,_L(gL,i),e.forEach((e=>{const n=e.store.getState();n.internal.active&&("always"===n.frameloop||n.internal.frames>0)&&(t+=SL(i,n))})),_L(vL,i),t>0)return requestAnimationFrame(r);_L(yL,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&&_L(gL,t),r?SL(t,r):e.forEach((e=>SL(t,e.store.getState()))),n&&_L(vL,t)}}}(NL),{reconciler:kL,applyProps:BL}=function(e){function n(e,{children:t,key:n,ref:r,...i},{children:o,key:s,ref:a,...l}={},c=!1){var u;const d=null!=(u=null==e?void 0:e.__r3f)?u:{},h=Object.entries(i),p=[];if(c){const e=Object.keys(l);for(let t=0;t<e.length;t++)i.hasOwnProperty(e[t])||h.unshift([e[t],lL+"remove"])}h.forEach((([t,n])=>{var r;if(null!=(r=e.__r3f)&&r.primitive&&"object"===t)return;if(function(e,t){return!(!nL.arr(e)||!nL.equ(e,t))||e===t}(n,l[t]))return;if(/^on(Pointer|Click|DoubleClick|ContextMenu|Wheel)/.test(t))return p.push([t,n,!0,[]]);let i=[];t.includes("-")&&(i=t.split("-")),p.push([t,n,!1,i])}));const m={...i};return d.memoizedProps&&d.memoizedProps.args&&(m.args=d.memoizedProps.args),d.memoizedProps&&d.memoizedProps.attach&&(m.attach=d.memoizedProps.attach),{accumulative:c,memoized:m,changes:p}}function r(e,t){var r,s,a;const l=null!=(r=null==e?void 0:e.__r3f)?r:{},c=l.root,u=null!=(s=null==c||null==c.getState?void 0:c.getState())?s:{},{memoized:d,changes:h}=(p=t)&&p.memoized&&p.changes?t:n(e,t);var p;const m=l.eventCount;if(e.__r3f&&(e.__r3f.memoizedProps=d),h.forEach((([t,n,r,o])=>{var s;let a=e,c=a[t];if(o.length&&(c=o.reduce(((e,t)=>e[t]),e),!c||!c.set)){const[n,...r]=o.reverse();a=r.reverse().reduce(((e,t)=>e[t]),e),t=n}if(n===lL+"remove")if(c&&c.constructor)n=new c.constructor(d.args);else if(a.constructor){const e=new a.constructor(a.__r3f.memoizedProps.args);n=e[c],e.dispose&&e.dispose()}else n=0;const h=(null==u||null==(s=u.gl)?void 0:s.outputEncoding)===af.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 af.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 af.Color;!e&&c.setScalar?c.setScalar(n):c instanceof af.Layers&&n instanceof af.Layers?c.mask=n.mask:c.set(n),!h&&e&&c.convertSRGBToLinear()}}else a[t]=n,!h&&a[t]instanceof af.Texture&&(a[t].encoding=af.sRGBEncoding);i(e)})),l.parent&&u.internal&&e.raycast&&m!==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 h.length&&null!=(a=e.__r3f)&&a.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 s(e,{args:t=[],...n},i,o,s){let a,l=`${e[0].toUpperCase()}${e.slice(1)}`;if(!sL(i)&&s){const e=t=>t.return?e(t.return):t.stateNode&&t.stateNode.containerInfo;i=e(s)}if(!i||!sL(i))throw`No valid root for ${l}!`;if("primitive"===e){if(void 0===n.object)throw"Primitives without 'object' are invalid!";a=dL(n.object,{root:i,primitive:!0})}else{const e=uL[l]||af[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!";a=dL(new e(...t),{root:i,memoizedProps:{args:0===t.length?null:t}})}return"attachFns"in n||(l.endsWith("Geometry")?n={attach:"geometry",...n}:l.endsWith("Material")&&(n={attach:"material",...n})),r(a,n),a}function a(e,t){let n=!1;if(t){if(t.attachArray)nL.arr(e[t.attachArray])||(e[t.attachArray]=[]),e[t.attachArray].push(t);else if(t.attachObject)nL.obj(e[t.attachObject[0]])||(e[t.attachObject[0]]={}),e[t.attachObject[0]][t.attachObject[1]]=t;else if(t.attach&&!nL.fun(t.attach))e[t.attach]=t;else if(nL.arr(t.attachFns)){const[n]=t.attachFns;nL.str(n)&&nL.fun(e[n])?e[n](t):nL.fun(n)&&n(t,e)}else t.isObject3D&&e.isObject3D&&(e.add(t),n=!0);n||e.__r3f.objects.push(t),t.__r3f||dL(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];nL.arr(r)||(e[t.attachArray]=[]),r.splice(r.indexOf(n),0,t)}else{if(t.attachObject||t.attach&&!nL.fun(t.attach))return a(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||dL(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&&!nL.fun(t.attach)&&e[t.attach]===t)e[t.attach]=null;else if(nL.arr(t.attachFns)){const[,n]=t.attachFns;nL.str(n)&&nL.fun(e[n])?e[n](t):nL.fun(n)&&n(t,e)}else if(t.isObject3D&&e.isObject3D){var s;e.remove(t),null!=(s=t.__r3f)&&s.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)=>{iL(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 a;if(!l)c(null==(a=t.__r3f)?void 0:a.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,VD.unstable_runWithPriority)(VD.unstable_IdlePriority,(()=>{try{t.dispose()}catch(e){}})),i(e)}}return{reconciler:t(GD)({now:VD.unstable_now,createInstance:s,removeChild:u,appendChild:a,appendInitialChild:a,insertBefore:l,warnsIfNotActing:!0,supportsMutation:!0,isPrimaryRenderer:!1,scheduleTimeout:nL.fun(setTimeout)?setTimeout:void 0,cancelTimeout:nL.fun(clearTimeout)?clearTimeout:void 0,setTimeout:nL.fun(setTimeout)?setTimeout:void 0,clearTimeout:nL.fun(clearTimeout)?clearTimeout:void 0,noTimeout:-1,appendChildToContainer:(e,t)=>{const{container:n,root:r}=aL(e,t);n.__r3f.root=r,a(n,t)},removeChildFromContainer:(e,t)=>u(aL(e,t).container,t),insertInContainerBefore:(e,t,n)=>l(aL(e,t).container,t,n),prepareUpdate(e,t,r,i){if(e.__r3f.primitive&&i.object&&i.object!==e)return[!0];{const{args:t=[],children:o,...s}=i,{args:l=[],children:c,...u}=r;if(!Array.isArray(t))throw"The args prop must be an array!";if(t.some(((e,t)=>e!==l[t])))return[!0];const d=n(e,s,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&&a(t,e)}return null}},commitUpdate(e,[t,n],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=s(t,n,e.__r3f.root);"primitive"!==t&&e.children&&(e.children.forEach((e=>a(l,e))),e.children=[]),e.__r3f.objects.forEach((e=>a(l,e))),e.__r3f.objects=[],u(o,e),a(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):r(e,n)},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=>cL,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){dL(e)},resetAfterCommit(){},shouldSetTextContent:()=>!1,clearContainer:()=>!1}),applyProps:r}}();function zL({store:e,element:t,onCreated:n,target:r}){return c.useEffect((()=>{const t=e.getState();t.set((e=>({internal:{...e.internal,active:!0}}))),null==t.events.connect||t.events.connect(r),n&&n(t)}),[]),c.createElement(mL.Provider,{value:e},t)}function FL(e,t){const n=NL.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),kL.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(),function(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]}}(i),NL.delete(e),t&&t(e)}),500)}))}}kL.act;function UL(){return UL=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},UL.apply(this,arguments)}kL.injectIntoDevTools({bundleType:0,rendererPackageName:"@react-three/fiber",version:"17.0.2"});c=o("85Hg2");function jL(e){return jL="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},jL(e)}function GL(e,t){if("object"!==jL(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!==jL(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function HL(e){var t=GL(e,"string");return"symbol"===jL(t)?t:String(t)}function VL(e,t,n){return(t=HL(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const WL=(e,t)=>(e%t+t)%t;class qL extends yy{constructor(e,t){super(),VL(this,"object",void 0),VL(this,"domElement",void 0),VL(this,"enabled",!0),VL(this,"target",new u_),VL(this,"minDistance",0),VL(this,"maxDistance",1/0),VL(this,"minZoom",0),VL(this,"maxZoom",1/0),VL(this,"minPolarAngle",0),VL(this,"maxPolarAngle",Math.PI),VL(this,"minAzimuthAngle",-1/0),VL(this,"maxAzimuthAngle",1/0),VL(this,"enableDamping",!1),VL(this,"dampingFactor",.05),VL(this,"enableZoom",!0),VL(this,"zoomSpeed",1),VL(this,"enableRotate",!0),VL(this,"rotateSpeed",1),VL(this,"enablePan",!0),VL(this,"panSpeed",1),VL(this,"screenSpacePanning",!0),VL(this,"keyPanSpeed",7),VL(this,"autoRotate",!1),VL(this,"autoRotateSpeed",2),VL(this,"reverseOrbit",!1),VL(this,"keys",{LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"}),VL(this,"mouseButtons",{LEFT:cf.ROTATE,MIDDLE:cf.DOLLY,RIGHT:cf.PAN}),VL(this,"touches",{ONE:uf.ROTATE,TWO:uf.DOLLY_PAN}),VL(this,"target0",void 0),VL(this,"position0",void 0),VL(this,"zoom0",void 0),VL(this,"_domElementKeyEvents",null),VL(this,"getPolarAngle",void 0),VL(this,"getAzimuthalAngle",void 0),VL(this,"setPolarAngle",void 0),VL(this,"setAzimuthalAngle",void 0),VL(this,"getDistance",void 0),VL(this,"listenToKeyEvents",void 0),VL(this,"saveState",void 0),VL(this,"reset",void 0),VL(this,"update",void 0),VL(this,"connect",void 0),VL(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 _b?this.object.zoom:1,this.getPolarAngle=()=>c.phi,this.getAzimuthalAngle=()=>c.theta,this.setPolarAngle=e=>{let t=WL(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=WL(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 _b?n.object.zoom:1},this.reset=()=>{n.target.copy(n.target0),n.object.position.copy(n.position0),n.object instanceof _b&&(n.object.zoom=n.zoom0,n.object.updateProjectionMatrix()),n.dispatchEvent(r),n.update(),a=s.NONE},this.update=(()=>{const t=new u_,i=(new c_).setFromUnitVectors(e.up,new u_(0,1,0)),o=i.clone().invert(),m=new u_,f=new c_,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&&a===s.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(h,n.dampingFactor):n.target.add(h),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,h.multiplyScalar(1-n.dampingFactor)):(u.set(0,0,0),h.set(0,0,0)),d=1,!!(p||m.distanceToSquared(n.object.position)>l||8*(1-f.dot(n.object.quaternion))>l)&&(n.dispatchEvent(r),m.copy(n.object.position),f.copy(n.object.quaternion),p=!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",J),n.domElement.addEventListener("pointerdown",j),n.domElement.addEventListener("pointercancel",V),n.domElement.addEventListener("wheel",W)},this.dispose=()=>{var e,t,r,i,o,s;null===(e=n.domElement)||void 0===e||e.removeEventListener("contextmenu",J),null===(t=n.domElement)||void 0===t||t.removeEventListener("pointerdown",j),null===(r=n.domElement)||void 0===r||r.removeEventListener("pointercancel",V),null===(i=n.domElement)||void 0===i||i.removeEventListener("wheel",W),null===(o=n.domElement)||void 0===o||o.ownerDocument.removeEventListener("pointermove",G),null===(s=n.domElement)||void 0===s||s.ownerDocument.removeEventListener("pointerup",H),null!==n._domElementKeyEvents&&n._domElementKeyEvents.removeEventListener("keydown",q)};const n=this,r={type:"change"},i={type:"start"},o={type:"end"},s={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let a=s.NONE;const l=1e-6,c=new XT,u=new XT;let d=1;const h=new u_;let p=!1;const m=new Oy,f=new Oy,g=new Oy,v=new Oy,y=new Oy,_=new Oy,S=new Oy,b=new Oy,x=new Oy,C=[],w={};function A(){return Math.pow(.95,n.zoomSpeed)}function E(e){n.reverseOrbit?u.theta+=e:u.theta-=e}function I(e){n.reverseOrbit?u.phi+=e:u.phi-=e}const T=(()=>{const e=new u_;return function(t,n){e.setFromMatrixColumn(n,0),e.multiplyScalar(-t),h.add(e)}})(),M=(()=>{const e=new u_;return function(t,r){!0===n.screenSpacePanning?e.setFromMatrixColumn(r,1):(e.setFromMatrixColumn(r,0),e.crossVectors(n.object.up,e)),e.multiplyScalar(t),h.add(e)}})(),R=(()=>{const e=new u_;return function(t,r){const i=n.domElement;if(i&&n.object instanceof _b&&n.object.isPerspectiveCamera){const o=n.object.position;e.copy(o).sub(n.target);let s=e.length();s*=Math.tan(n.object.fov/2*Math.PI/180),T(2*t*s/i.clientHeight,n.object.matrix),M(2*r*s/i.clientHeight,n.object.matrix)}else i&&n.object instanceof Hb&&n.object.isOrthographicCamera?(T(t*(n.object.right-n.object.left)/n.object.zoom/i.clientWidth,n.object.matrix),M(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 P(e){n.object instanceof _b&&n.object.isPerspectiveCamera?d/=e:n.object instanceof Hb&&n.object.isOrthographicCamera?(n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom*e)),n.object.updateProjectionMatrix(),p=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function N(e){n.object instanceof _b&&n.object.isPerspectiveCamera?d*=e:n.object instanceof Hb&&n.object.isOrthographicCamera?(n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/e)),n.object.updateProjectionMatrix(),p=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function O(e){m.set(e.clientX,e.clientY)}function D(e){v.set(e.clientX,e.clientY)}function L(){if(1==C.length)m.set(C[0].pageX,C[0].pageY);else{const e=.5*(C[0].pageX+C[1].pageX),t=.5*(C[0].pageY+C[1].pageY);m.set(e,t)}}function k(){if(1==C.length)v.set(C[0].pageX,C[0].pageY);else{const e=.5*(C[0].pageX+C[1].pageX),t=.5*(C[0].pageY+C[1].pageY);v.set(e,t)}}function B(){const e=C[0].pageX-C[1].pageX,t=C[0].pageY-C[1].pageY,n=Math.sqrt(e*e+t*t);S.set(0,n)}function z(e){if(1==C.length)f.set(e.pageX,e.pageY);else{const t=X(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);f.set(n,r)}g.subVectors(f,m).multiplyScalar(n.rotateSpeed);const t=n.domElement;t&&(E(2*Math.PI*g.x/t.clientHeight),I(2*Math.PI*g.y/t.clientHeight)),m.copy(f)}function F(e){if(1==C.length)y.set(e.pageX,e.pageY);else{const t=X(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);y.set(n,r)}_.subVectors(y,v).multiplyScalar(n.panSpeed),R(_.x,_.y),v.copy(y)}function U(e){const t=X(e),r=e.pageX-t.x,i=e.pageY-t.y,o=Math.sqrt(r*r+i*i);b.set(0,o),x.set(0,Math.pow(b.y/S.y,n.zoomSpeed)),P(x.y),S.copy(b)}function j(e){if(!1!==n.enabled){var t,r;if(0===C.length)null===(t=n.domElement)||void 0===t||t.ownerDocument.addEventListener("pointermove",G),null===(r=n.domElement)||void 0===r||r.ownerDocument.addEventListener("pointerup",H);!function(e){C.push(e)}(e),"touch"===e.pointerType?function(e){switch(Y(e),C.length){case 1:switch(n.touches.ONE){case uf.ROTATE:if(!1===n.enableRotate)return;L(),a=s.TOUCH_ROTATE;break;case uf.PAN:if(!1===n.enablePan)return;k(),a=s.TOUCH_PAN;break;default:a=s.NONE}break;case 2:switch(n.touches.TWO){case uf.DOLLY_PAN:if(!1===n.enableZoom&&!1===n.enablePan)return;n.enableZoom&&B(),n.enablePan&&k(),a=s.TOUCH_DOLLY_PAN;break;case uf.DOLLY_ROTATE:if(!1===n.enableZoom&&!1===n.enableRotate)return;n.enableZoom&&B(),n.enableRotate&&L(),a=s.TOUCH_DOLLY_ROTATE;break;default:a=s.NONE}break;default:a=s.NONE}a!==s.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 cf.DOLLY:if(!1===n.enableZoom)return;!function(e){S.set(e.clientX,e.clientY)}(e),a=s.DOLLY;break;case cf.ROTATE:if(e.ctrlKey||e.metaKey||e.shiftKey){if(!1===n.enablePan)return;D(e),a=s.PAN}else{if(!1===n.enableRotate)return;O(e),a=s.ROTATE}break;case cf.PAN:if(e.ctrlKey||e.metaKey||e.shiftKey){if(!1===n.enableRotate)return;O(e),a=s.ROTATE}else{if(!1===n.enablePan)return;D(e),a=s.PAN}break;default:a=s.NONE}a!==s.NONE&&n.dispatchEvent(i)}(e)}}function G(e){!1!==n.enabled&&("touch"===e.pointerType?function(e){switch(Y(e),a){case s.TOUCH_ROTATE:if(!1===n.enableRotate)return;z(e),n.update();break;case s.TOUCH_PAN:if(!1===n.enablePan)return;F(e),n.update();break;case s.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 s.TOUCH_DOLLY_ROTATE:if(!1===n.enableZoom&&!1===n.enableRotate)return;!function(e){n.enableZoom&&U(e),n.enableRotate&&z(e)}(e),n.update();break;default:a=s.NONE}}(e):function(e){if(!1===n.enabled)return;switch(a){case s.ROTATE:if(!1===n.enableRotate)return;!function(e){f.set(e.clientX,e.clientY),g.subVectors(f,m).multiplyScalar(n.rotateSpeed);const t=n.domElement;t&&(E(2*Math.PI*g.x/t.clientHeight),I(2*Math.PI*g.y/t.clientHeight)),m.copy(f),n.update()}(e);break;case s.DOLLY:if(!1===n.enableZoom)return;!function(e){b.set(e.clientX,e.clientY),x.subVectors(b,S),x.y>0?P(A()):x.y<0&&N(A()),S.copy(b),n.update()}(e);break;case s.PAN:if(!1===n.enablePan)return;!function(e){y.set(e.clientX,e.clientY),_.subVectors(y,v).multiplyScalar(n.panSpeed),R(_.x,_.y),v.copy(y),n.update()}(e)}}(e))}function H(e){var t,r,i;(K(e),0===C.length)&&(null===(t=n.domElement)||void 0===t||t.releasePointerCapture(e.pointerId),null===(r=n.domElement)||void 0===r||r.ownerDocument.removeEventListener("pointermove",G),null===(i=n.domElement)||void 0===i||i.ownerDocument.removeEventListener("pointerup",H));n.dispatchEvent(o),a=s.NONE}function V(e){K(e)}function W(e){!1===n.enabled||!1===n.enableZoom||a!==s.NONE&&a!==s.ROTATE||(e.preventDefault(),n.dispatchEvent(i),function(e){e.deltaY<0?N(A()):e.deltaY>0&&P(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:R(0,n.keyPanSpeed),t=!0;break;case n.keys.BOTTOM:R(0,-n.keyPanSpeed),t=!0;break;case n.keys.LEFT:R(n.keyPanSpeed,0),t=!0;break;case n.keys.RIGHT:R(-n.keyPanSpeed,0),t=!0}t&&(e.preventDefault(),n.update())}(e)}function J(e){!1!==n.enabled&&e.preventDefault()}function K(e){delete w[e.pointerId];for(let t=0;t<C.length;t++)if(C[t].pointerId==e.pointerId)return void C.splice(t,1)}function Y(e){let t=w[e.pointerId];void 0===t&&(t=new Oy,w[e.pointerId]=t),t.set(e.pageX,e.pageY)}function X(e){const t=e.pointerId===C[0].pointerId?C[1]:C[0];return w[t.pointerId]}void 0!==t&&this.connect(t),this.update()}}const JL=c.forwardRef((({makeDefault:e,camera:t,regress:n,domElement:r,enableDamping:i=!0,onChange:o,onStart:s,onEnd:a,...l},u)=>{const d=IL((e=>e.invalidate)),h=IL((e=>e.camera)),p=IL((e=>e.gl)),m=IL((e=>e.events)),f=IL((e=>e.set)),g=IL((e=>e.get)),v=IL((e=>e.performance)),y=t||h,_=r||m.connected||p.domElement,S=c.useMemo((()=>new qL(y)),[y]);return TL((()=>{S.enabled&&S.update()})),c.useEffect((()=>(S.connect(_),()=>{S.dispose()})),[_,n,S,d]),c.useEffect((()=>{const e=e=>{d(),n&&v.regress(),o&&o(e)};return S.addEventListener("change",e),s&&S.addEventListener("start",s),a&&S.addEventListener("end",a),()=>{s&&S.removeEventListener("start",s),a&&S.removeEventListener("end",a),S.removeEventListener("change",e)}}),[o,s,a]),c.useEffect((()=>{if(e){const e=g().controls;return f({controls:S}),()=>f({controls:e})}}),[e,S]),c.createElement("primitive",UL({ref:u,object:S,enableDamping:i},l))}));const KL=(c=o("85Hg2")).forwardRef((({makeDefault:e,...t},n)=>{const r=IL((({set:e})=>e)),i=IL((({camera:e})=>e)),o=IL((({size:e})=>e)),s=c.useRef();return c.useLayoutEffect((()=>{const{current:e}=s;e&&!t.manual&&(e.aspect=o.width/o.height,e.updateProjectionMatrix())}),[o,t]),c.useLayoutEffect((()=>{if(e&&s.current){const e=i;return r((()=>({camera:s.current}))),()=>r((()=>({camera:e})))}}),[i,s,e,r]),c.createElement("perspectiveCamera",UL({ref:XD([s,n])},t))}));c=o("85Hg2"),c=o("85Hg2");const YL=new WeakMap;class XL extends CI{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 EI(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(YL.has(e)){const t=YL.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,s=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 s.catch((()=>!0)).then((()=>{r&&i&&this._releaseTask(r,i)})),YL.set(e,{key:n,promise:s}),s}_createGeometry(e){const t=new JS;e.index&&t.setIndex(new MS(e.index.array,1));for(let n=0;n<e.attributes.length;n++){const r=e.attributes[n],i=r.name,o=r.array,s=r.itemSize;t.setAttribute(i,new MS(o,s))}return t}_loadLibrary(e,t){const n=new EI(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=QL.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 QL(){let e,t;function n(e,t,n,r,i,o){const s=o.num_components(),a=n.num_points()*s,l=a*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,a).slice();return e._free(u),{name:r,array:d,itemSize:s}}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,s=new t.Decoder,a=new t.DecoderBuffer;a.Init(new Int8Array(r),r.byteLength);try{const e=function(e,t,r,i){const o=i.attributeIDs,s=i.attributeTypes;let a,l;const c=t.GetEncodedGeometryType(r);if(c===e.TRIANGULAR_MESH)a=new e.Mesh,l=t.DecodeBufferToMesh(r,a);else{if(c!==e.POINT_CLOUD)throw new Error("THREE.DRACOLoader: Unexpected geometry type.");a=new e.PointCloud,l=t.DecodeBufferToPointCloud(r,a)}if(!l.ok()||0===a.ptr)throw new Error("THREE.DRACOLoader: Decoding failed: "+l.error_msg());const u={index:null,attributes:[]};for(const r in o){const l=self[s[r]];let c,d;if(i.useUniqueIDs)d=o[r],c=t.GetAttributeByUniqueId(a,d);else{if(d=t.GetAttributeId(a,e[o[r]]),-1===d)continue;c=t.GetAttribute(a,d)}u.attributes.push(n(e,t,a,r,l,c))}c===e.TRIANGULAR_MESH&&(u.index=function(e,t,n){const r=n.num_faces(),i=3*r,o=4*i,s=e._malloc(o);t.GetTrianglesUInt32Array(n,o,s);const a=new Uint32Array(e.HEAPF32.buffer,s,i).slice();return e._free(s),{array:a,itemSize:1}}(e,t,a));return e.destroy(a),u}(t,s,a,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(a),t.destroy(s)}}))}}}let $L;const ZL=()=>{if($L)return $L;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,s){const a=n.exports.sbrk,l=r+3&-4,c=a(l*i),u=a(o.length),d=new Uint8Array(n.exports.memory.buffer);d.set(o,u);const h=e(c,r,i,u,o.length);if(0===h&&s&&s(c,l,i),t.set(d.subarray(c,c+r*i)),a(c-a(0)),0!==h)throw new Error(`Malformed buffer data: ${h}`)}const s={0:"",1:"meshopt_decodeFilterOct",2:"meshopt_decodeFilterQuat",3:"meshopt_decodeFilterExp",NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},a={0:"meshopt_decodeVertexBuffer",1:"meshopt_decodeIndexBuffer",2:"meshopt_decodeIndexSequence",ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return $L={ready:i,supported:!0,decodeVertexBuffer(e,t,r,i,a){o(n.exports.meshopt_decodeVertexBuffer,e,t,r,i,n.exports[s[a]])},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[a[l]],e,t,r,i,n.exports[s[c]])}},$L};class ek extends CI{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register((function(e){return new sk(e)})),this.register((function(e){return new pk(e)})),this.register((function(e){return new mk(e)})),this.register((function(e){return new lk(e)})),this.register((function(e){return new ck(e)})),this.register((function(e){return new uk(e)})),this.register((function(e){return new dk(e)})),this.register((function(e){return new ok(e)})),this.register((function(e){return new hk(e)})),this.register((function(e){return new ak(e)})),this.register((function(e){return new rk(e)})),this.register((function(e){return new fk(e)}))}load(e,t,n,r){const i=this;let o;o=""!==this.resourcePath?this.resourcePath:""!==this.path?this.path:ZI.extractUrlBase(e),this.manager.itemStart(e);const s=function(t){r?r(t):console.error(t),i.manager.itemError(e),i.manager.itemEnd(e)},a=new EI(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,(function(n){try{i.parse(n,o,(function(n){t(n),i.manager.itemEnd(e)}),s)}catch(e){s(e)}}),n,s)}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={},s={};if("string"==typeof e)i=e;else{if(ZI.decodeText(new Uint8Array(e,0,4))===gk){try{o[nk.KHR_BINARY_GLTF]=new _k(e)}catch(e){return void(r&&r(e))}i=o[nk.KHR_BINARY_GLTF].content}else i=ZI.decodeText(new Uint8Array(e))}const a=JSON.parse(i);if(void 0===a.asset||a.asset.version[0]<2)return void(r&&r(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));const l=new Qk(a,{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);s[t.name]=t,o[t.name]=!0}if(a.extensionsUsed)for(let e=0;e<a.extensionsUsed.length;++e){const t=a.extensionsUsed[e],n=a.extensionsRequired||[];switch(t){case nk.KHR_MATERIALS_UNLIT:o[t]=new ik;break;case nk.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:o[t]=new Ck;break;case nk.KHR_DRACO_MESH_COMPRESSION:o[t]=new Sk(a,this.dracoLoader);break;case nk.KHR_TEXTURE_TRANSFORM:o[t]=new bk;break;case nk.KHR_MESH_QUANTIZATION:o[t]=new wk;break;default:n.indexOf(t)>=0&&void 0===s[t]&&console.warn('THREE.GLTFLoader: Unknown extension "'+t+'".')}}l.setExtensions(o),l.setPlugins(s),l.parse(n,r)}parseAsync(e,t){const n=this;return new Promise((function(r,i){n.parse(e,t,r,i)}))}}function tk(){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 nk={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 rk{constructor(e){this.parser=e,this.name=nk.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 s;const a=new Yy(16777215);void 0!==o.color&&a.fromArray(o.color);const l=void 0!==o.range?o.range:0;switch(o.type){case"directional":s=new JI(a),s.target.position.set(0,0,-1),s.add(s.target);break;case"point":s=new WI(a),s.distance=l;break;case"spot":s=new UI(a),s.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,s.angle=o.spot.outerConeAngle,s.penumbra=1-o.spot.innerConeAngle/o.spot.outerConeAngle,s.target.position.set(0,0,-1),s.add(s.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+o.type)}return s.position.set(0,0,0),s.decay=2,void 0!==o.intensity&&(s.intensity=o.intensity),s.name=t.createUniqueName(o.name||"light_"+e),r=Promise.resolve(s),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 ik{constructor(){this.name=nk.KHR_MATERIALS_UNLIT}getMaterialType(){return ES}extendParams(e,t,n){const r=[];e.color=new Yy(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,kv))}return Promise.all(r)}}class ok{constructor(e){this.parser=e,this.name=nk.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 sk{constructor(e){this.parser=e,this.name=nk.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?qE: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 Oy(e,e)}return Promise.all(i)}}class ak{constructor(e){this.parser=e,this.name=nk.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?qE: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 lk{constructor(e){this.parser=e,this.name=nk.KHR_MATERIALS_SHEEN}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?qE: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 Yy(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,kv)),void 0!==o.sheenRoughnessTexture&&i.push(n.assignTexture(t,"sheenRoughnessMap",o.sheenRoughnessTexture)),Promise.all(i)}}class ck{constructor(e){this.parser=e,this.name=nk.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?qE: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 uk{constructor(e){this.parser=e,this.name=nk.KHR_MATERIALS_VOLUME}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?qE: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 s=o.attenuationColor||[1,1,1];return t.attenuationColor=new Yy(s[0],s[1],s[2]),Promise.all(i)}}class dk{constructor(e){this.parser=e,this.name=nk.KHR_MATERIALS_IOR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?qE: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 hk{constructor(e){this.parser=e,this.name=nk.KHR_MATERIALS_SPECULAR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?qE: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 s=o.specularColorFactor||[1,1,1];return t.specularColor=new Yy(s[0],s[1],s[2]),void 0!==o.specularColorTexture&&i.push(n.assignTexture(t,"specularColorMap",o.specularColorTexture,kv)),Promise.all(i)}}class pk{constructor(e){this.parser=e,this.name=nk.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 mk{constructor(e){this.parser=e,this.name=nk.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],s=r.images[o.source];let a=n.textureLoader;if(s.uri){const e=n.options.manager.getHandler(s.uri);null!==e&&(a=e)}return this.detectSupport().then((function(i){if(i)return n.loadTextureImage(e,o.source,a);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 fk{constructor(e){this.name=nk.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,s=e.byteStride,a=new Uint8Array(t,n,r);return i.decodeGltfBufferAsync?i.decodeGltfBufferAsync(o,s,a,e.mode,e.filter).then((function(e){return e.buffer})):i.ready.then((function(){const t=new ArrayBuffer(o*s);return i.decodeGltfBuffer(new Uint8Array(t),o,s,a,e.mode,e.filter),t}))}))}return null}}const gk="glTF",vk=1313821514,yk=5130562;class _k{constructor(e){this.name=nk.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,12);if(this.header={magic:ZI.decodeText(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==gk)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===vk){const n=new Uint8Array(e,12+i,t);this.content=ZI.decodeText(n)}else if(n===yk){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 Sk{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=nk.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,s={},a={},l={};for(const e in o){const t=Fk[e]||e.toLowerCase();s[t]=o[e]}for(const t in e.attributes){const r=Fk[t]||t.toLowerCase();if(void 0!==o[t]){const i=n.accessors[e.attributes[t]],o=Lk[i.componentType];l[r]=o.name,a[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=a[t];void 0!==r&&(n.normalized=r)}t(e)}),s,l)}))}))}}class bk{constructor(){this.name=nk.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 xk extends WE{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"),s={specular:{value:(new Yy).setHex(16777215)},glossiness:{value:1},specularMap:{value:null},glossinessMap:{value:null}};this._extraUniforms=s,this.onBeforeCompile=function(e){for(const t in s)e.uniforms[t]=s[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 s.specular.value},set:function(e){s.specular.value=e}},specularMap:{get:function(){return s.specularMap.value},set:function(e){s.specularMap.value=e,e?this.defines.USE_SPECULARMAP="":delete this.defines.USE_SPECULARMAP}},glossiness:{get:function(){return s.glossiness.value},set:function(e){s.glossiness.value=e}},glossinessMap:{get:function(){return s.glossinessMap.value},set:function(e){s.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 Ck{constructor(){this.name=nk.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 xk}extendParams(e,t,n){const r=t.extensions[this.name];e.color=new Yy(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,kv)),e.emissive=new Yy(0,0,0),e.glossiness=void 0!==r.glossinessFactor?r.glossinessFactor:1,e.specular=new Yy(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,kv))}return Promise.all(i)}createMaterial(e){const t=new xk(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=Fv,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 wk{constructor(){this.name=nk.KHR_MESH_QUANTIZATION}}class Ak extends sI{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,s=this.valueSize,a=2*s,l=3*s,c=r-t,u=(n-t)/c,d=u*u,h=d*u,p=e*l,m=p-l,f=-2*h+3*d,g=h-d,v=1-f,y=g-d+u;for(let e=0;e!==s;e++){const t=o[m+e+s],n=o[m+e+a]*c,r=o[p+e+s],l=o[p+e]*c;i[e]=v*t+y*n+f*r+g*l}return i}}const Ek=new c_;class Ik extends Ak{interpolate_(e,t,n,r){const i=super.interpolate_(e,t,n,r);return Ek.fromArray(i).normalize().toArray(i),i}}const Tk=0,Mk=1,Rk=2,Pk=3,Nk=4,Ok=5,Dk=6,Lk={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},kk={9728:gg,9729:bg,9984:vg,9985:xg,9986:_g,9987:wg},Bk={33071:mg,33648:fg,10497:pg},zk={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Fk={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},Uk={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},jk={CUBICSPLINE:void 0,LINEAR:Av,STEP:wv},Gk="OPAQUE",Hk="MASK",Vk="BLEND";function Wk(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 qk(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 Jk(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 Kk(e){const t=e.extensions&&e.extensions[nk.KHR_DRACO_MESH_COMPRESSION];let n;return n=t?"draco:"+t.bufferView+":"+t.indices+":"+Yk(t.attributes):e.indices+":"+Yk(e.attributes)+":"+e.mode,n}function Yk(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 Xk(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 Qk{constructor(e={},t={}){var n,r;this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new tk,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,s="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&&s<98?this.textureLoader=new NI(this.options.manager):this.textureLoader=new sT(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new EI(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:{}};Wk(i,o,r),qk(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[nk.KHR_BINARY_GLTF].body);const r=this.options;return new Promise((function(e,i){n.load(ZI.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=zk[r.type],s=Lk[r.componentType],a=s.BYTES_PER_ELEMENT,l=a*o,c=r.byteOffset||0,u=void 0!==r.bufferView?n.bufferViews[r.bufferView].byteStride:void 0,d=!0===r.normalized;let h,p;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||(h=new s(i,e*u,r.count*u/a),l=new pw(h,u/a),t.cache.add(n,l)),p=new fw(l,o,c%u/a,d)}else h=null===i?new s(r.count*o):new s(i,c,r.count*o),p=new MS(h,o,d);if(void 0!==r.sparse){const t=zk.SCALAR,n=Lk[r.sparse.indices.componentType],a=r.sparse.indices.byteOffset||0,l=r.sparse.values.byteOffset||0,c=new n(e[1],a,r.sparse.count*t),u=new s(e[2],l,r.sparse.count*o);null!==i&&(p=new MS(p.array.slice(),p.itemSize,p.normalized));for(let e=0,t=c.length;e<t;e++){const t=c[e];if(p.setX(t,u[e*o]),o>=2&&p.setY(t,u[e*o+1]),o>=3&&p.setZ(t,u[e*o+2]),o>=4&&p.setW(t,u[e*o+3]),o>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return p}))}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],s=i.images[t],a=(s.uri||s.bufferView)+":"+o.sampler;if(this.textureCache[a])return this.textureCache[a];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=kk[n.magFilter]||bg,t.minFilter=kk[n.minFilter]||wg,t.wrapS=Bk[n.wrapS]||pg,t.wrapT=Bk[n.wrapT]||pg,r.associations.set(t,{textures:e}),t})).catch((function(){return null}));return this.textureCache[a]=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 s=i.uri||"",a=!1;if(void 0!==i.bufferView)s=this.getDependency("bufferView",i.bufferView).then((function(e){a=!0;const t=new Blob([e],{type:i.mimeType});return s=o.createObjectURL(t),s}));else if(void 0===i.uri)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const l=Promise.resolve(s).then((function(e){return new Promise((function(n,i){let o=n;!0===t.isImageBitmapLoader&&(o=function(e){const t=new t_(e);t.needsUpdate=!0,n(t)}),t.load(ZI.resolveURL(e,r.path),o,void 0,i)}))})).then((function(e){var t;return!0===a&&o.revokeObjectURL(s),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",s),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[nk.KHR_TEXTURE_TRANSFORM]){const e=void 0!==n.extensions?n.extensions[nk.KHR_TEXTURE_TRANSFORM]:void 0;if(e){const t=i.associations.get(o);o=i.extensions[nk.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 cA,AS.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 $w,AS.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 WE}loadMaterial(e){const t=this,n=this.json,r=this.extensions,i=n.materials[e];let o;const s={},a=i.extensions||{},l=[];if(a[nk.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]){const e=r[nk.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS];o=e.getMaterialType(),l.push(e.extendParams(s,i,t))}else if(a[nk.KHR_MATERIALS_UNLIT]){const e=r[nk.KHR_MATERIALS_UNLIT];o=e.getMaterialType(),l.push(e.extendParams(s,i,t))}else{const n=i.pbrMetallicRoughness||{};if(s.color=new Yy(1,1,1),s.opacity=1,Array.isArray(n.baseColorFactor)){const e=n.baseColorFactor;s.color.fromArray(e),s.opacity=e[3]}void 0!==n.baseColorTexture&&l.push(t.assignTexture(s,"map",n.baseColorTexture,kv)),s.metalness=void 0!==n.metallicFactor?n.metallicFactor:1,s.roughness=void 0!==n.roughnessFactor?n.roughnessFactor:1,void 0!==n.metallicRoughnessTexture&&(l.push(t.assignTexture(s,"metalnessMap",n.metallicRoughnessTexture)),l.push(t.assignTexture(s,"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,s)}))))}!0===i.doubleSided&&(s.side=bf);const c=i.alphaMode||Gk;if(c===Vk?(s.transparent=!0,s.depthWrite=!1):(s.transparent=!1,c===Hk&&(s.alphaTest=void 0!==i.alphaCutoff?i.alphaCutoff:.5)),void 0!==i.normalTexture&&o!==ES&&(l.push(t.assignTexture(s,"normalMap",i.normalTexture)),s.normalScale=new Oy(1,1),void 0!==i.normalTexture.scale)){const e=i.normalTexture.scale;s.normalScale.set(e,e)}return void 0!==i.occlusionTexture&&o!==ES&&(l.push(t.assignTexture(s,"aoMap",i.occlusionTexture)),void 0!==i.occlusionTexture.strength&&(s.aoMapIntensity=i.occlusionTexture.strength)),void 0!==i.emissiveFactor&&o!==ES&&(s.emissive=(new Yy).fromArray(i.emissiveFactor)),void 0!==i.emissiveTexture&&o!==ES&&l.push(t.assignTexture(s,"emissiveMap",i.emissiveTexture,kv)),Promise.all(l).then((function(){let n;return n=o===xk?r[nk.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].createMaterial(s):new o(s),i.name&&(n.name=i.name),qk(n,i),t.associations.set(n,{materials:e}),i.extensions&&Wk(r,n,i),n}))}createUniqueName(e){const t=BT.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[nk.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then((function(n){return Zk(n,e,t)}))}const o=[];for(let n=0,s=e.length;n<s;n++){const s=e[n],a=Kk(s),l=r[a];if(l)o.push(l.promise);else{let e;e=s.extensions&&s.extensions[nk.KHR_DRACO_MESH_COMPRESSION]?i(s):Zk(new JS,s,t),r[a]={primitive:s,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,s=[];for(let e=0,t=o.length;e<t;e++){const t=void 0===o[e].material?(void 0===(a=this.cache).DefaultMaterial&&(a.DefaultMaterial=new WE({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:_f})),a.DefaultMaterial):this.getDependency("material",o[e].material);s.push(t)}var a;return s.push(t.loadGeometries(o)),Promise.all(s).then((function(n){const s=n.slice(0,n.length-1),a=n[n.length-1],l=[];for(let n=0,c=a.length;n<c;n++){const c=a[n],u=o[n];let d;const h=s[n];if(u.mode===Nk||u.mode===Ok||u.mode===Dk||void 0===u.mode)d=!0===i.isSkinnedMesh?new Uw(c,h):new db(c,h),!0!==d.isSkinnedMesh||d.geometry.attributes.skinWeight.normalized||d.normalizeSkinWeights(),u.mode===Ok?d.geometry=eB(d.geometry,Ov):u.mode===Dk&&(d.geometry=eB(d.geometry,Dv));else if(u.mode===Mk)d=new aA(c,h);else if(u.mode===Pk)d=new iA(c,h);else if(u.mode===Rk)d=new lA(c,h);else{if(u.mode!==Tk)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+u.mode);d=new mA(c,h)}Object.keys(d.geometry.morphAttributes).length>0&&Jk(d,i),d.name=t.createUniqueName(i.name||"mesh_"+e),qk(d,i),u.extensions&&Wk(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 tw;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 _b(Ny.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):"orthographic"===n.type&&(t=new Hb(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),qk(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=[],s=[];for(let e=0,a=t.channels.length;e<a;e++){const a=t.channels[e],l=t.samplers[a.sampler],c=a.target,u=c.node,d=void 0!==t.parameters?t.parameters[l.input]:l.input,h=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",h)),o.push(l),s.push(c)}return Promise.all([Promise.all(n),Promise.all(r),Promise.all(i),Promise.all(o),Promise.all(s)]).then((function(n){const r=n[0],i=n[1],o=n[2],s=n[3],a=n[4],l=[];for(let e=0,t=r.length;e<t;e++){const t=r[e],n=i[e],c=o[e],u=s[e],d=a[e];if(void 0===t)continue;let h;switch(t.updateMatrix(),Uk[d.path]){case Uk.weights:h=pI;break;case Uk.rotation:h=fI;break;default:h=vI}const p=t.name?t.name:t.uuid,m=void 0!==u.interpolation?jk[u.interpolation]:Av,f=[];Uk[d.path]===Uk.weights?t.traverse((function(e){e.morphTargetInfluences&&f.push(e.name?e.name:e.uuid)})):f.push(p);let g=c.array;if(c.normalized){const e=Xk(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=f.length;e<t;e++){const t=new h(f[e]+"."+Uk[d.path],n.array,g,m);"CUBICSPLINE"===u.interpolation&&(t.createInterpolant=function(e){return new(this instanceof fI?Ik:Ak)(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 yI(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 s;if(s=!0===i.isBone?new jw:t.length>1?new tw:1===t.length?t[0]:new hS,s!==t[0])for(let e=0,n=t.length;e<n;e++)s.add(t[e]);if(i.name&&(s.userData.name=i.name,s.name=o),qk(s,i),i.extensions&&Wk(n,s,i),void 0!==i.matrix){const e=new j_;e.fromArray(i.matrix),s.applyMatrix4(e)}else void 0!==i.translation&&s.position.fromArray(i.translation),void 0!==i.rotation&&s.quaternion.fromArray(i.rotation),void 0!==i.scale&&s.scale.fromArray(i.scale);return r.associations.has(s)||r.associations.set(s,{}),r.associations.get(s).nodes=e,s}))}loadScene(e){const t=this.json,n=this.extensions,r=this.json.scenes[e],i=this,o=new tw;r.name&&(o.name=i.createUniqueName(r.name)),qk(o,r),r.extensions&&Wk(n,o,r);const s=r.nodes||[],a=[];for(let e=0,n=s.length;e<n;e++)a.push($k(s[e],o,t,i));return Promise.all(a).then((function(){return i.associations=(e=>{const t=new Map;for(const[e,n]of i.associations)(e instanceof AS||e instanceof t_)&&t.set(e,n);return e.traverse((e=>{const n=i.associations.get(e);null!=n&&t.set(e,n)})),t})(o),o}))}}function $k(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 j_;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 Ww(r,i),e.matrixWorld)})),e}))})).then((function(e){t.add(e);const o=[];if(i.children){const t=i.children;for(let i=0,s=t.length;i<s;i++){const s=t[i];o.push($k(s,e,n,r))}}return Promise.all(o)}))}function Zk(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=Fk[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 qk(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 u_(t[0],t[1],t[2]),new u_(o[0],o[1],o[2])),e.normalized){const t=Xk(Lk[e.componentType]);i.min.multiplyScalar(t),i.max.multiplyScalar(t)}}const o=t.targets;if(void 0!==o){const e=new u_,t=new u_;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,s=r.max;if(void 0!==o&&void 0!==s){if(t.setX(Math.max(Math.abs(o[0]),Math.abs(s[0]))),t.setY(Math.max(Math.abs(o[1]),Math.abs(s[1]))),t.setZ(Math.max(Math.abs(o[2]),Math.abs(s[2]))),r.normalized){const e=Xk(Lk[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 s=new N_;i.getCenter(s.center),s.radius=i.min.distanceTo(i.max)/2,e.boundingSphere=s}(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 s=[],a=[],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;s.push(t)}if(i){const t=void 0!==u.NORMAL?n.getDependency("accessor",u.NORMAL):e.attributes.normal;a.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(s),Promise.all(a),Promise.all(l)]).then((function(t){const n=t[0],s=t[1],a=t[2];return r&&(e.morphAttributes.position=n),i&&(e.morphAttributes.normal=s),o&&(e.morphAttributes.color=a),e.morphTargetsRelative=!0,e}))}(e,t.targets,n):e}))}function eB(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===Dv)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 tB=null;function nB(e,t,n){return r=>{n&&n(r),e&&(tB||(tB=new XL),tB.setDecoderPath("string"==typeof e?e:"https://www.gstatic.com/draco/versioned/decoders/1.4.3/"),r.setDRACOLoader(tB)),t&&r.setMeshoptDecoder(ZL())}}function rB(e,t=!0,n=!0,r){return PL(ek,e,nB(t,n,r))}rB.preload=(e,t=!0,n=!0,r)=>PL.preload(ek,e,nB(t,n,r)),rB.clear=e=>PL.clear(ek,e);c=o("85Hg2");function iB(e,t){const n=c.useRef(),[r]=c.useState((()=>t?t instanceof hS?{current:t}:t:n)),[i]=c.useState((()=>new jT(void 0))),o=c.useRef({}),[s]=c.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 TL(((e,t)=>i.update(t))),c.useEffect((()=>{const e=r.current;return()=>{o.current={},Object.values(s.actions).forEach((t=>{e&&i.uncacheAction(t,e)}))}}),[e]),s}const oB=new u_(0,-1,0),sB=new Q_(.175,0,0),aB=new u_(0,-1.45,0),lB=[{italian:"Gioia",english:"Joy"},{italian:"Rabbia",english:"Anger"},{italian:"Sorpresa",english:"Surprise"},{italian:"Tristezza",english:"Sadness"},{italian:"Timore",english:"Fear"}],cB=[{emotion:{italian:"Rabbia",english:"Anger"},blendShapes:{browDownLeft:.5,browDownRight:.5,browOuterUpLeft:.5,browOuterUpRight:.5,mouthSmile:-.2}},{emotion:{italian:"Timore",english:"Fear"},blendShapes:{browOuterUpLeft:-.5,browOuterUpRight:-.5,eyeWideLeft:-.5,eyeWideRight:-.5}},{emotion:{italian:"Tristezza",english:"Sadness"},blendShapes:{browDownLeft:-.5,browDownRight:-.5,eyeSquintLeft:.5,eyeSquintRight:.5,mouthSmile:-.6}},{emotion:{italian:"Sorpresa",english:"Surprise"},blendShapes:{browInnerUp:.5,browOuterUpLeft:.5,browOuterUpRight:.5,eyeWideLeft:.5,eyeWideRight:.5}},{emotion:{italian:"Gioia",english:"Joy"},blendShapes:{browDownLeft:.5,browDownRight:.5,browInnerUp:.5,mouthSmile:.8}}],uB={MALE:"https://assets.memori.ai/api/v2/asset/2c5e88a4-cf62-408b-9ef0-518b099dfcb2.glb",FEMALE:"https://assets.memori.ai/api/v2/asset/2adc934b-24b2-45bd-94ad-ffec58d3cb32.glb"},dB={minInterval:1e3,maxInterval:5e3,blinkDuration:150};class hB{constructor(e,t,n){this.currentEmotionValues={},this.previousEmotionKeys=new Set,this.isRPM=!1,this.rpmBlendShapes=cB,this.customGlbMapping=lB,this.headMesh=e,this.isRPM="GBNL__Head"!==e.name,t&&(this.rpmBlendShapes=t),n&&(this.customGlbMapping=n)}processChatEmission(e,t){var n,r;const i=this.getDefaultEmotionMorphTargets();if(t||!e)return i;if(!(null==e?void 0:e.includes('<output class="memori-emotion">')))return i;const o=null===(r=null===(n=null==e?void 0:e.split('<output class="memori-emotion">')[1])||void 0===n?void 0:n.split("</output>")[0])||void 0===r?void 0:r.trim();return o?this.processEmotion(o):i}processEmotion(e){const t=this.getDefaultEmotionMorphTargets();if(this.isRPM){const n=this.rpmBlendShapes.find((t=>t.emotion.italian.toLowerCase()===e.toLowerCase()||t.emotion.english.toLowerCase()===e.toLowerCase()));if(n)return{...t,...n.blendShapes}}else{const n=this.customGlbMapping.find((t=>t.italian.toLowerCase()===e.toLowerCase()||t.english.toLowerCase()===e.toLowerCase()));if(n)return{...t,[n.english]:1}}return console.log("[MorphTargetController] No emotion found:",e),t}getDefaultEmotionMorphTargets(){if(this.isRPM){const e=new Set;return this.rpmBlendShapes.forEach((t=>{Object.keys(t.blendShapes).forEach((t=>e.add(t)))})),Array.from(e).reduce(((e,t)=>({...e,[t]:0})),{})}return this.customGlbMapping.reduce(((e,t)=>({...e,[t.english]:0})),{})}updateMorphTargets(e,t,n,r,i,o){if(!this.headMesh.morphTargetDictionary||!this.headMesh.morphTargetInfluences)return void console.error("[MorphTargetController] Missing morphTargetDictionary or morphTargetInfluences");const s=this.processChatEmission(t,n),a=this.calculateBlinkValue(e,o,i),l=new Set(Object.keys(s));Object.entries(this.headMesh.morphTargetDictionary).forEach((([e,t])=>{if("number"!=typeof t)return;let n=0;if(l.has(e)){const t=s[e],r=this.currentEmotionValues[e]||0,i=Ny.lerp(r,3*t,.3);this.currentEmotionValues[e]=i,n+=i}if(r&&e===r.name&&(n+=r.weight),"eyesClosed"===e&&i&&(n+=a),n=Ny.clamp(n,0,1),this.headMesh.morphTargetInfluences){const e=Ny.lerp(this.headMesh.morphTargetInfluences[t]||0,n,.5);this.headMesh.morphTargetInfluences[t]=e}})),this.previousEmotionKeys=l}calculateBlinkValue(e,t,n){if(!n)return 0;let r=0;if(e>=t.nextBlinkTime&&!t.isBlinking&&(t.isBlinking=!0,t.blinkStartTime=e,t.lastBlinkTime=e,t.nextBlinkTime=e+Math.random()*(dB.maxInterval-dB.minInterval)+dB.minInterval),t.isBlinking){const n=(e-t.blinkStartTime)/dB.blinkDuration;n<=.5?r=2*n:n<=1?r=2-2*n:(t.isBlinking=!1,r=0)}return r}}class pB{constructor(e=oB.clone(),t=aB.clone(),n=.6){this.defaultPosition=e,this.zoomedPosition=t,this.currentScale=new u_(1,1,1),this.targetScale=new u_(1,1,1),this.currentPosition=e.clone(),this.basePosition=e.clone(),this.initialCameraPosition=new u_(0,0,n)}mapHeightToScale(e,t){return t?Ny.lerp(1.4,2.1,e/100):Ny.lerp(.5,1.5,e/100)}mapDepthToCamera(e,t){const n=this.initialCameraPosition.z;return Ny.lerp(n,n+3,e/100)}updateHeight(e,t){const n=this.mapHeightToScale(e,t);this.targetScale.set(n,n,n)}updateDepth(e,t){return this.mapDepthToCamera(e,t)}updateBasePosition(e){const t=e?this.zoomedPosition:this.defaultPosition;this.basePosition.copy(t),this.currentPosition.copy(t)}updateScale(e){return this.currentScale.lerp(this.targetScale,e),this.currentScale}getPosition(){return this.currentPosition}reset(){this.currentScale.set(1,1,1),this.targetScale.set(1,1,1),this.currentPosition.copy(this.defaultPosition),this.basePosition.copy(this.defaultPosition)}}class mB{constructor(){this.mixer=null,this.actions={},this.animations=new Map,this.currentAnimation=null,this.currentSequence=null,this.sequenceIndex=0,this.isTransitioning=!1,this.timeScale=1,this.fadeInDuration=.8,this.fadeOutDuration=.8,this.avatarType="CUSTOM_GLB",this.eventListeners={start:[],complete:[],loop:[],transition:[],error:[]},this.initialized=!1,this.idleRotationCount=0,this.currentIdleAnimation=null,this.idleRotationLimit=5,this.lastAnimationTime=null}async initialize(e,t,n=[],r="CUSTOM_GLB"){if(this.initialized||this.mixer)return void console.warn("[AvatarAnimator] Already initialized, ignoring duplicate initialization");this.mixer=new jT(e),this.avatarType=r,this.actions={},this.registerClipsDirectly(n),Object.entries(t).forEach((([e,t])=>{this.actions[e]||(this.actions[e]=t,this.registerAnimation(e,t))})),this.setupMixerEvents();const i=["Idle1","Idle2","Idle3","Idle4","Idle5"];let o=!1;for(const e of i)if(this.actions[e])try{const t=this.actions[e];t.reset(),t.setEffectiveTimeScale(1),t.setEffectiveWeight(1),t.setLoop(1/0,1/0),t.play(),this.currentAnimation=e,this.currentIdleAnimation=e,this.idleRotationCount=0,o=!0;break}catch(t){console.error(`Error starting ${e}:`,t)}o||console.warn("[AvatarAnimator] Could not start any idle animation directly"),this.initialized=!0}registerClipsDirectly(e){this.mixer&&e.forEach((e=>{var t;const n=null===(t=this.mixer)||void 0===t?void 0:t.clipAction(e);n?(this.actions[e.name]=n,this.registerAnimation(e.name,n)):console.warn(`[AvatarAnimator] Failed to create action for clip: ${e.name}`)}))}registerAnimations(e,t=[]){const n=new Set;t.forEach((e=>n.add(e.name))),Object.keys(e).forEach((e=>n.add(e))),t.forEach((e=>{if(this.mixer){const t=this.mixer.clipAction(e);this.actions[e.name]=t,this.registerAnimation(e.name,t)}})),Object.entries(e).forEach((([e,t])=>{this.actions[e]||(this.actions[e]=t,this.registerAnimation(e,t))}));this.getAnimationsByCategory("IDLE"),this.getAnimationsByCategory("LOADING"),this.getAnimationsByCategory("ACTION")}registerAnimation(e,t){const n=t.getClip().duration;let r="ACTION",i=1,o=!1;const s=e.toLowerCase();s.includes("idle")?(r="IDLE",i=0,o=!0):(s.includes("loading")||s.includes("wait"))&&(r="LOADING",i=0,o=!0),this.animations.set(e,{name:e,category:r,duration:n,canLoop:o,defaultLoopCount:i})}play(e,t={}){var n,r,i,o;try{if(!this.initialized||!this.mixer)return void console.warn(`[AvatarAnimator] Cannot play ${e} - not initialized`);const s=this.actions[e];if(!s){if(console.warn(`[AvatarAnimator] Animation not found: ${e}`),!1!==t.fallbackToIdle){const e=Object.keys(this.actions)[0];e&&this.play(e,{...t,fallbackToIdle:!1})}return}const a=this.getAnimationInfo(e);if(!a)return console.warn(`[AvatarAnimator] Animation info not found: ${e}`),void(!1!==t.fallbackToIdle&&this.idle());if(this.currentAnimation===e&&!this.isTransitioning&&void 0===t.loopCount)return;if(this.isTransitioning&&this.currentAnimation){const e=this.actions[this.currentAnimation];e&&e.fadeOut(.1)}const l=null!==(n=t.fadeInDuration)&&void 0!==n?n:this.fadeInDuration,c=null!==(r=t.fadeOutDuration)&&void 0!==r?r:this.fadeOutDuration,u=null!==(i=t.loopCount)&&void 0!==i?i:a.defaultLoopCount,d=null!==(o=t.timeScale)&&void 0!==o?o:this.timeScale;if("IDLE"===a.category&&(this.currentIdleAnimation=e,this.idleRotationCount=0),this.emit("transition",{from:this.currentAnimation,to:e}),this.currentAnimation){const t=this.actions[this.currentAnimation];t&&(this.currentAnimation===e?t.stop():t.fadeOut(c))}s.reset(),s.fadeIn(l),s.timeScale=d,s.enabled=!0,0===u?s.setLoop(1/0,1/0):(s.setLoop(u>1?u:bv,u>1?u:1),s.clampWhenFinished=!0),s.play(),this.currentAnimation=e,this.isTransitioning=!0;const h=1e3*Math.max(l,c);setTimeout((()=>{this.isTransitioning=!1}),h),this.emit("start",{animation:e,category:a.category,loopCount:u})}catch(n){if(console.error(`[AvatarAnimator] Error in play method for ${e}:`,n),!1!==t.fallbackToIdle)try{this.idle()}catch(e){console.error("[AvatarAnimator] Failed to recover with idle animation:",e)}}}execute(e){if(this.initialized)try{let t;const n=e.match(/\[loop=(\d+)\]/);if(n&&(t=parseInt(n[1],10),e=e.replace(n[0],"").trim()),e.includes("->")){const n=e.split("->").map((e=>e.trim()));this.playSequence(n,{loopCount:t})}else this.play(e,{loopCount:t})}catch(t){console.error("[AvatarAnimator] Error executing animation command:",t),this.emit("error",{error:t,command:e}),this.idle()}else console.warn("[AvatarAnimator] Cannot execute - not initialized")}processChatEmission(e,t){if(!this.initialized)return void console.warn("[AvatarAnimator] Cannot process chat emission - not initialized");const n="LOADING"===this.getAnimationCategory();if(t){if(n)return;return void this.loading()}if(!e){if("IDLE"===this.getAnimationCategory())return;return void this.idle(n?{fadeInDuration:1.2,fadeOutDuration:1}:void 0)}const r=e.match(/<output class="animation-sequence">(.*?)<\/output>/),i=e.match(/<output class="animation">(.*?)(\[loop=(\d+)\])?<\/output>/),o=e.match(/<output class="memori-emotion">(.*?)<\/output>/),s=this.calculateTransitionOptions();if(r&&r[1]){const e=r[1].trim();if(this.currentSequence&&this.currentSequence.join("->")===e&&this.sequenceIndex<this.currentSequence.length)return;this.executeWithTransition(e,s)}else{if(i&&i[1]){const e=i[1].trim();let t;return i[3]&&(t=parseInt(i[3],10)),void this.play(e,{...s,loopCount:t})}if(o&&o[1]){const e=o[1].trim();console.log("[AvatarAnimator] Processing emotion:",e);let t=[];if(lB.find((t=>t.english===e))){console.log("[AvatarAnimator] Found emotion in English mapping");let n=lB.filter((t=>t.english===e));console.log("[AvatarAnimator] Matching emotions:",n),t=this.getAllAnimationNames().filter((e=>n.some((t=>e.toLowerCase().startsWith(t.italian.toLowerCase())))))}else console.log("[AvatarAnimator] Using generalized emotion matching approach"),t=this.getAllAnimationNames().filter((t=>t.toLowerCase().startsWith(e.toLowerCase())));if(console.log("[AvatarAnimator] Found matching animations:",t),t.length>0){const e=t[Math.floor(Math.random()*t.length)];return console.log("[AvatarAnimator] Selected animation to play:",e),void this.play(e,s)}console.log("[AvatarAnimator] No matching animations found for emotion:",e)}"IDLE"!==this.getAnimationCategory()&&this.idle(s)}}calculateTransitionOptions(){var e,t;const n={fadeInDuration:this.fadeInDuration,fadeOutDuration:this.fadeOutDuration,timeScale:this.timeScale},r=(this.getAnimationCategory(),this.currentAnimation?this.actions[this.currentAnimation]:null);if(n.fadeOutDuration=.8,n.fadeInDuration=.8,r){const i=r.getClip(),o=r.time/i.duration;o>.75?n.fadeOutDuration=Math.max(.4,.8*(null!==(e=n.fadeOutDuration)&&void 0!==e?e:.8)):o<.25&&(n.fadeInDuration=Math.max(.4,.8*(null!==(t=n.fadeInDuration)&&void 0!==t?t:.8)))}return n}executeWithTransition(e,t={}){if(this.initialized)try{let n;const r=e.match(/\[loop=(\d+)\]/);if(r&&(n=parseInt(r[1],10),e=e.replace(r[0],"").trim()),e.includes("->")){const r=e.split("->").map((e=>e.trim())),i={...t,loopCount:n||1};this.playSequence(r,i)}else this.play(e,{...t,loopCount:n})}catch(t){console.error("[AvatarAnimator] Error executing animation command:",t),this.emit("error",{error:t,command:e}),this.idle()}else console.warn("[AvatarAnimator] Cannot execute - not initialized")}idle(e={}){var t,n,r,i,o,s,a,l,c;const u=this.getAnimationsByCategory("IDLE");if(u.length>0){let i=u;"IDLE"===this.getAnimationCategory()&&(i=u.filter((e=>e.name!==this.currentAnimation)),0===i.length&&(i=u));const o=i[Math.floor(Math.random()*i.length)].name,s={fadeInDuration:null!==(t=e.fadeInDuration)&&void 0!==t?t:.7,fadeOutDuration:null!==(n=e.fadeOutDuration)&&void 0!==n?n:.7,timeScale:null!==(r=e.timeScale)&&void 0!==r?r:.9,loopCount:0,...e};return s.loopCount=0,this.play(o,s),this.currentIdleAnimation=o,void(this.idleRotationCount=0)}{console.warn("[AvatarAnimator] No idle animations available, checking fallback options");const t=Array.from(this.animations.values()).filter((e=>e.canLoop)).map((e=>e.name));if(t.length>0){const n=t[Math.floor(Math.random()*t.length)];this.play(n,{loopCount:0,fadeInDuration:null!==(i=e.fadeInDuration)&&void 0!==i?i:.7,fadeOutDuration:null!==(o=e.fadeOutDuration)&&void 0!==o?o:.7,timeScale:null!==(s=e.timeScale)&&void 0!==s?s:.9}),this.currentIdleAnimation=n,this.idleRotationCount=0}else if(Object.keys(this.actions).length>0){const t=Object.keys(this.actions)[0];this.play(t,{loopCount:0,fadeInDuration:null!==(a=e.fadeInDuration)&&void 0!==a?a:.7,fadeOutDuration:null!==(l=e.fadeOutDuration)&&void 0!==l?l:.7,timeScale:null!==(c=e.timeScale)&&void 0!==c?c:.9}),this.currentIdleAnimation=t,this.idleRotationCount=0}}}loading(e={}){var t,n,r;const i=this.getRandomAnimation("LOADING");if(i){const o={loopCount:0,fadeInDuration:null!==(t=e.fadeInDuration)&&void 0!==t?t:.8,fadeOutDuration:null!==(n=e.fadeOutDuration)&&void 0!==n?n:.8,timeScale:null!==(r=e.timeScale)&&void 0!==r?r:this.timeScale,...e};o.loopCount=0,this.play(i,o)}else console.warn("[AvatarAnimator] No loading animations available, using idle instead"),this.idle(e)}playSequence(e,t={}){var n;if(!e||0===e.length)return void console.warn("[AvatarAnimator] Empty animation sequence provided");e.length>5&&(console.warn(`[AvatarAnimator] Sequence too long (${e.length}), limiting to 5 animations`),e=e.slice(0,5));const r=e.filter((e=>this.actions[e]));if(0===r.length)return console.error("[AvatarAnimator] No valid animations in sequence, defaulting to idle"),void this.idle();if(this.isTransitioning)return void setTimeout((()=>{this.playSequence(e,t)}),100);this.currentSequence=[...r],this.sequenceIndex=0;const i={fadeInDuration:.6,fadeOutDuration:.6,loopCount:1,timeScale:null!==(n=t.timeScale)&&void 0!==n?n:this.timeScale},o=r[0];this.play(o,i)}forceIdle(){const e=this.getAnimationsByCategory("IDLE");if(e.length>0){const t=e[0].name;this.play(t,{loopCount:0,fadeInDuration:.8,fadeOutDuration:.8}),this.currentIdleAnimation=t,this.idleRotationCount=0}else console.error("[AvatarAnimator] No idle animations available for forced transition")}update(e){if(!this.initialized||!this.mixer)return;const t=Math.min(e,.1);if(this.mixer.update(t),!this.isTransitioning){if(this.currentSequence&&this.currentAnimation){const e=this.actions[this.currentAnimation];if(e){const t=e.getClip().duration;if(e.time/t>.85&&!this.isTransitioning)if(this.sequenceIndex<this.currentSequence.length-1){this.sequenceIndex++;const e=this.currentSequence[this.sequenceIndex];this.play(e,{fadeInDuration:.5,fadeOutDuration:.5,loopCount:1})}else this.currentSequence=null,this.sequenceIndex=0,this.idle({fadeInDuration:.7,fadeOutDuration:.7})}}if(this.currentAnimation&&this.currentIdleAnimation&&"IDLE"===this.getAnimationCategory()){const e=this.actions[this.currentAnimation];if(e){const t=e.getClip().duration,n=e.time%t;(this.lastAnimationTime||0)>n+.1&&(this.idleRotationCount++,this.idleRotationCount>=this.idleRotationLimit&&(this.idleRotationCount=0,this.idle({fadeInDuration:.6,fadeOutDuration:.6}))),this.lastAnimationTime=n}}}}isAnimationPlaying(e){if(!this.actions[e])return!1;const t=this.actions[e];return t.isRunning()&&t.getEffectiveWeight()>.1}setupMixerEvents(){this.mixer?(this.mixer.addEventListener("loop",(e=>{const t=e.action;t&&this.currentAnimation&&t===this.actions[this.currentAnimation]&&this.emit("loop",{animation:this.currentAnimation})})),this.mixer.addEventListener("finished",(e=>{const t=e.action;if(t&&this.currentAnimation&&t===this.actions[this.currentAnimation]){if(this.isTransitioning)return;this.emit("complete",{animation:this.currentAnimation}),setTimeout((()=>{var e;this.currentSequence&&this.sequenceIndex<this.currentSequence.length-1?(this.sequenceIndex++,this.play(this.currentSequence[this.sequenceIndex],{fadeInDuration:.5,fadeOutDuration:.5,loopCount:1})):this.currentSequence&&this.sequenceIndex>=this.currentSequence.length-1?(this.currentSequence=null,this.sequenceIndex=0,this.idle({fadeInDuration:.7,fadeOutDuration:.7})):this.currentAnimation&&"IDLE"!==(null===(e=this.getAnimationInfo(this.currentAnimation))||void 0===e?void 0:e.category)&&this.idle({fadeInDuration:.7,fadeOutDuration:.7})}),50)}}))):console.warn("[AvatarAnimator] Cannot setup mixer events - mixer not initialized")}handleSequenceProgressionIfNeeded(){if(!this.currentSequence||!this.currentAnimation||this.sequenceIndex>=this.currentSequence.length-1)return;const e=this.actions[this.currentAnimation];if(!e)return;const t=e.getClip().duration;if(e.time/t>.9&&!this.isTransitioning)if(this.sequenceIndex++,this.sequenceIndex<this.currentSequence.length){const e=this.currentSequence[this.sequenceIndex];this.play(e,{fadeInDuration:.3,fadeOutDuration:.3,loopCount:1})}else this.currentSequence=null,this.sequenceIndex=0,this.idle()}handleIdleRotationIfNeeded(){if(!this.currentAnimation||!this.currentIdleAnimation||"IDLE"!==this.getAnimationCategory())return;const e=this.actions[this.currentAnimation];if(!e)return;const t=e.getClip().duration,n=e.time%t;(this.lastAnimationTime||0)>n+.1&&(this.idleRotationCount++,this.idleRotationCount>=this.idleRotationLimit&&(this.idleRotationCount=0,this.idle())),this.lastAnimationTime=n}setTimeScale(e){if(this.timeScale=e,this.currentAnimation){const t=this.actions[this.currentAnimation];t&&(t.timeScale=e)}}getRandomAnimation(e,t=[]){const n=Array.from(this.animations.values()).filter((n=>n.category===e&&!t.includes(n.name)));if(0===n.length)return null;return n[Math.floor(Math.random()*n.length)].name}getAnimationInfo(e){return this.animations.get(e)||null}getAnimationCategory(){var e;return this.currentAnimation&&(null===(e=this.getAnimationInfo(this.currentAnimation))||void 0===e?void 0:e.category)||null}on(e,t){this.eventListeners[e]&&this.eventListeners[e].push(t)}off(e,t){this.eventListeners[e]&&(this.eventListeners[e]=this.eventListeners[e].filter((e=>e!==t)))}emit(e,t){this.eventListeners[e]&&this.eventListeners[e].forEach((n=>{try{n(t)}catch(t){console.error(`Error in ${e} event handler:`,t)}}))}getCurrentAnimationName(){return this.currentAnimation}getAvatarType(){return this.avatarType}isInitialized(){return this.initialized}getAllAnimationNames(){return Array.from(this.animations.keys())}getAnimationsByCategory(e){return Array.from(this.animations.values()).filter((t=>t.category===e))}}c=o("85Hg2");const fB={uniforms:{tDiffuse:{value:null},h:{value:1/512}},vertexShader:"\n varying vec2 vUv;\n\n void main() {\n\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }\n ",fragmentShader:"\n uniform sampler2D tDiffuse;\n uniform float h;\n\n varying vec2 vUv;\n\n void main() {\n\n \tvec4 sum = vec4( 0.0 );\n\n \tsum += texture2D( tDiffuse, vec2( vUv.x - 4.0 * h, vUv.y ) ) * 0.051;\n \tsum += texture2D( tDiffuse, vec2( vUv.x - 3.0 * h, vUv.y ) ) * 0.0918;\n \tsum += texture2D( tDiffuse, vec2( vUv.x - 2.0 * h, vUv.y ) ) * 0.12245;\n \tsum += texture2D( tDiffuse, vec2( vUv.x - 1.0 * h, vUv.y ) ) * 0.1531;\n \tsum += texture2D( tDiffuse, vec2( vUv.x, vUv.y ) ) * 0.1633;\n \tsum += texture2D( tDiffuse, vec2( vUv.x + 1.0 * h, vUv.y ) ) * 0.1531;\n \tsum += texture2D( tDiffuse, vec2( vUv.x + 2.0 * h, vUv.y ) ) * 0.12245;\n \tsum += texture2D( tDiffuse, vec2( vUv.x + 3.0 * h, vUv.y ) ) * 0.0918;\n \tsum += texture2D( tDiffuse, vec2( vUv.x + 4.0 * h, vUv.y ) ) * 0.051;\n\n \tgl_FragColor = sum;\n\n }\n "},gB={uniforms:{tDiffuse:{value:null},v:{value:1/512}},vertexShader:"\n varying vec2 vUv;\n\n void main() {\n\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }\n ",fragmentShader:"\n\n uniform sampler2D tDiffuse;\n uniform float v;\n\n varying vec2 vUv;\n\n void main() {\n\n vec4 sum = vec4( 0.0 );\n\n sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 4.0 * v ) ) * 0.051;\n sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 3.0 * v ) ) * 0.0918;\n sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 2.0 * v ) ) * 0.12245;\n sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 1.0 * v ) ) * 0.1531;\n sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y ) ) * 0.1633;\n sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 1.0 * v ) ) * 0.1531;\n sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 2.0 * v ) ) * 0.12245;\n sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 3.0 * v ) ) * 0.0918;\n sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 4.0 * v ) ) * 0.051;\n\n gl_FragColor = sum;\n\n }\n "},vB=c.forwardRef((({scale:e,frames:t=1/0,opacity:n=1,width:r=1,height:i=1,blur:o=1,far:s=10,resolution:a=256,smooth:l=!0,color:u="#000000",...d},h)=>{const p=IL((({scene:e})=>e)),m=IL((({gl:e})=>e)),f=c.useRef(null);r*=Array.isArray(e)?e[0]:e||1,i*=Array.isArray(e)?e[1]:e||1;const[g,v,y,_,S,b,x]=c.useMemo((()=>{const e=new r_(a,a),t=new r_(a,a);t.texture.generateMipmaps=e.texture.generateMipmaps=!1;const n=new $M(r,i).rotateX(Math.PI/2),o=new db(n),s=new KC;s.depthTest=s.depthWrite=!1,s.onBeforeCompile=e=>{e.uniforms={...e.uniforms,ucolor:{value:new Yy(u).convertSRGBToLinear()}},e.fragmentShader=e.fragmentShader.replace("void main() {","uniform vec3 ucolor;\n void main() {\n "),e.fragmentShader=e.fragmentShader.replace("vec4( vec3( 1.0 - fragCoordZ ), opacity );","vec4( ucolor, ( 1.0 - fragCoordZ ) * 1.0 );")};const l=new vb(fB),c=new vb(gB);return c.depthTest=l.depthTest=!1,[e,n,s,o,l,c,t]}),[a,r,i,e]),C=c.useCallback((e=>{_.visible=!0,_.material=S,S.uniforms.tDiffuse.value=g.texture,S.uniforms.h.value=1*e/256,m.setRenderTarget(x),m.render(_,f.current),_.material=b,b.uniforms.tDiffuse.value=x.texture,b.uniforms.v.value=1*e/256,m.setRenderTarget(g),m.render(_,f.current),_.visible=!1}),[]);let w=0;return TL((()=>{if(f.current&&(t===1/0||w<t)){const e=p.background;p.background=null;const t=p.overrideMaterial;p.overrideMaterial=y,m.setRenderTarget(g),m.render(p,f.current),p.overrideMaterial=t,C(o),l&&C(.4*o),m.setRenderTarget(null),p.background=e,w++}})),c.createElement("group",UL({"rotation-x":Math.PI/2},d,{ref:h}),c.createElement("mesh",{geometry:v,scale:[1,-1,1],rotation:[-Math.PI/2,0,0]},c.createElement("meshBasicMaterial",{map:g.texture,transparent:!0,opacity:n})),c.createElement("orthographicCamera",{ref:f,args:[-r/2,r/2,i/2,-i/2,0,s]}))}));var yB=({animator:e,avatarPosition:t})=>{const n=(()=>{var t,n,r,i,o;const s={width:10,height:10,blur:2.5,scale:10,far:5,resolution:1024,color:"#000000"};return e?(null===(t=e.getCurrentAnimationName())||void 0===t?void 0:t.startsWith("Loading"))?{...s,opacity:.85,blur:3,width:12,height:12}:(null===(n=e.getCurrentAnimationName())||void 0===n?void 0:n.includes("Gioia"))||(null===(r=e.getCurrentAnimationName())||void 0===r?void 0:r.includes("Joy"))?{...s,opacity:.9,blur:2,width:11,height:11}:(null===(i=e.getCurrentAnimationName())||void 0===i?void 0:i.includes("Rabbia"))||(null===(o=e.getCurrentAnimationName())||void 0===o?void 0:o.includes("Anger"))?{...s,opacity:.95,blur:1.8,width:12,height:12}:{...s,opacity:.9,blur:2.2}:{...s,opacity:0}})();return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(vB,{opacity:n.opacity,scale:n.scale,blur:n.blur,far:n.far,resolution:n.resolution,color:n.color,frames:1/0,position:[0,t.y,0]}),(0,s.jsx)(vB,{opacity:1,width:5,height:5,blur:1,far:2,resolution:1024,color:"#000000",position:[0,-.98,0]})]})};c=o("85Hg2");const _B=(e,t,n=.05)=>e*(1-n)+t*n,SB=(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,bB=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))};c=o("85Hg2");const xB=Math.PI/180;let CB,wB=!1;const AB=new Oy(0,0),EB=new Oy(0,0),IB=()=>{CB=setTimeout((()=>{wB=!0}),1e3)},TB=()=>{clearTimeout(CB),wB=!1};function MB(e,t){const{gl:n}=IL();(0,c.useEffect)((()=>{if(e)return n.domElement.addEventListener("mouseleave",IB),n.domElement.addEventListener("mouseenter",TB),()=>{n.domElement.removeEventListener("mouseleave",IB),n.domElement.removeEventListener("mouseenter",TB)}}),[n.domElement,e]),TL((n=>{if(!e||!(null==t?void 0:t.Neck)||!(null==t?void 0:t.Head))return;const r=Math.abs(n.camera.rotation.z);!wB&&r<.2?(AB.x=SB(n.mouse.y,-1,1,5*xB,-5*xB),AB.y=SB(n.mouse.x,-1,1,-10*xB,10*xB)):AB.set(0,0),EB.x=_B(EB.x,AB.x),EB.y=_B(EB.y,AB.y),t.Neck.rotation.x=EB.x+.1,t.Neck.rotation.y=EB.y,t.Head.rotation.x=2*EB.x,t.Head.rotation.y=2*EB.y}))}const RB=(0,c.memo)((function({url:e,sex:t,eyeBlink:n,updateCurrentViseme:r,avatarHeight:i=50,avatarDepth:o=0,onCameraZChange:a,chatEmission:l,loading:u,setAnimatorRef:d}){const{scene:h,animations:p}=rB(e),{animations:m}=rB(uB[t]),f=(0,c.useMemo)((()=>{let e=!1;return h.traverse((t=>{t instanceof Uw&&("GBNL__Head"===t.name||"Wolf3D_Avatar"===t.name||"Wolf3D_Avatar006_1"===t.name)&&(e=!0)})),e}),[h]),g=(0,c.useMemo)((()=>f?[...p,...m]:p),[p,m,f]),{actions:v}=iB(g,h),y=(0,c.useRef)(null),_=(0,c.useRef)(null),S=(0,c.useRef)(null),b=(0,c.useRef)(!1),x=(0,c.useRef)(oB.clone()),C=(0,c.useRef)(0),[w,A]=(0,c.useState)(!1),E=(0,c.useRef)({isBlinking:!1,lastBlinkTime:0,nextBlinkTime:0,blinkStartTime:0});(0,c.useEffect)((()=>{if(!h)return;let e=null;h.traverse((t=>{if(t instanceof Uw){if("Wolf3D_Avatar"===t.name||"Wolf3D_Avatar006_1"===t.name)return A(!0),console.log("RPM avatar detected"),void(e=t);if("GBNL__Head"===t.name)e=t;else{if(t.morphTargetDictionary&&Object.keys(t.morphTargetDictionary).length>0){const n=Object.keys(t.morphTargetDictionary||{}),r=n.some((e=>e.toLowerCase().includes("viseme"))),i=n.some((e=>{const t=e.toLowerCase();return t.includes("mouth")||t.includes("eye")||t.includes("jaw")||t.includes("smile")}));(r||i)&&(console.log("🎭 Custom avatar detected:",{name:t.name,morphTargets:n,visemeCount:n.filter((e=>e.toLowerCase().includes("viseme"))).length}),e=t)}}}})),e?y.current||(y.current=new hB(e)):console.warn("⚠️ No suitable avatar mesh found")}),[h]),(0,c.useEffect)((()=>(_.current||(_.current=new pB(oB)),()=>{})),[]),(0,c.useEffect)((()=>{_.current&&_.current.updateHeight(i,!1)}),[i]),(0,c.useEffect)((()=>{if(_.current&&a){const e=_.current.updateDepth(o,!1);a(e)}}),[o,a]),(0,c.useEffect)((()=>{if(!h||!v||b.current)return;console.log("Initializing animator"),S.current||(S.current=new mB);const e=S.current;return(async()=>{try{if(e.isInitialized())return void console.log("Animator already initialized, skipping initialization");await e.initialize(h,v,g,w?"RPM":"CUSTOM_GLB"),console.log("AvatarAnimator initialized with",Object.keys(v).length,"animations"),d&&d(e),b.current=!0,e.setTimeScale(.8)}catch(e){console.error("Error initializing AvatarAnimator:",e)}})(),()=>{S.current&&b.current&&(console.log("Cleaning up animator"),"mixer"in S.current&&S.current.mixer&&S.current.mixer.stopAllAction(),d&&d(null),b.current=!1)}}),[h,v,g,t,d]),TL((0,c.useCallback)(((e,t)=>{const i=1e3*e.clock.elapsedTime;if(S.current&&b.current&&S.current.update(t),y.current){const e=r(i/1e3);y.current.updateMorphTargets(i,l,u,e,n,E.current)}if(h&&_.current){const e=_.current.updateScale(.1);if(h.scale.copy(e),i-C.current>=1){const e=_.current.getPosition();e.setX(Number(e.x.toFixed(6))),e.setY(Number(e.y.toFixed(6))),e.setZ(Number(e.z.toFixed(6))),x.current.copy(e),C.current=i}}}),[h,r,l,u,n]));const I=(0,c.useMemo)((()=>{var e;return(null===(e=_.current)||void 0===e?void 0:e.getPosition())||oB.clone()}),[]);return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(yB,{animator:S.current,avatarPosition:I}),(0,s.jsx)("group",{position:I,rotation:sB,children:(0,s.jsx)("primitive",{object:h})})]})})),PB=(0,c.memo)((function({url:e,updateCurrentViseme:t,eyeBlink:n=!1,avatarHeight:r=50,avatarDepth:i=0,headMovement:o=!1,onLoaded:a,onCameraZChange:l,chatEmission:u,loading:d=!1}){var h;const{scene:p}=rB(e),{nodes:m,materials:f}=(g=p,c.useMemo((()=>ML(g)),[g]));var g;const{camera:v}=IL(),y=(0,c.useRef)(null),_=(0,c.useRef)(null);(0,c.useRef)(v.position.z),MB(o,m);const S=(0,c.useRef)({isBlinking:!1,lastBlinkTime:0,nextBlinkTime:0,blinkStartTime:0}),b=(0,c.useMemo)((()=>{let e;return null==p||p.traverse((t=>{t instanceof Uw&&("GBNL__Head"===t.name||"Wolf3D_Avatar"===t.name||"Wolf3D_Avatar006_1"===t.name)&&(e=t)})),e}),[p]);(0,c.useEffect)((()=>(_.current||(_.current=new pB(oB,aB)),b&&(y.current=new hB(b)),bR(f),null==a||a(),bB(m),()=>{Object.values(f).forEach((e=>e.dispose())),Object.values(m).filter(xR).forEach((e=>e.geometry.dispose()))})),[f,m,e,a,p,b]),(0,c.useEffect)((()=>{_.current&&_.current.updateHeight(r,!0)}),[r]),(0,c.useEffect)((()=>{if(_.current&&l){const e=_.current.updateDepth(i,!0);l(e)}}),[i,l]),TL((e=>{const r=1e3*e.clock.elapsedTime;if(y.current){const e=t(r/1e3);y.current.updateMorphTargets(r,u,d,e,n,S.current)}if(p&&_.current){const e=_.current.updateScale(.1);p.scale.copy(e)}}));const x=(null===(h=_.current)||void 0===h?void 0:h.getPosition())||oB;return(0,s.jsx)("group",{position:x,children:(0,s.jsx)("primitive",{object:p})})})),NB=({chatEmission:e,url:t,sex:n,eyeBlink:r,halfBody:i,loading:o,avatarHeight:a=50,avatarDepth:l=-50,updateCurrentViseme:u,setCameraZ:d,headMovement:h,showControls:p})=>{const m=(0,c.useRef)(null),f=(0,c.useCallback)((e=>{e!==m.current&&(console.log("[AvatarView] Animator reference updated"),m.current=e)}),[]);(0,c.useEffect)((()=>{if(m.current)try{m.current.processChatEmission(e,o)}catch(e){console.error("Error processing chat emission:",e)}}),[o,e]);const g=(0,c.useCallback)((()=>({url:t,onCameraZChange:d,updateCurrentViseme:u,avatarHeight:a,avatarDepth:l,setAnimatorRef:f})),[t,d,u,a,l,f]);return(0,s.jsxs)(s.Fragment,{children:[i?(0,s.jsx)(PB,{...g(),eyeBlink:r,headMovement:h}):(0,s.jsx)(RB,{...g(),sex:n,eyeBlink:r,chatEmission:e,loading:o}),p&&m.current&&(0,s.jsx)("div",{className:"animation-controls"})]})};(0,c.memo)(NB),c=o("85Hg2");const OB={muteSpeaker:"@memori:muteSpeaker",microphoneMode:"@memori:microphoneMode",continuousSpeechTimeout:"@memori:continuousSpeechTimeout",birthDate:"@memori:birthDate",controlsPosition:"@memori:controlsPosition",hideEmissions:"@memori:hideEmissions",loginToken:"@memori:loginToken",location:"@memori:location"},DB=(e,t)=>{var n;try{const r=window.localStorage.getItem(null!==(n=OB[e])&&void 0!==n?n:e);if(!r)return t;try{return JSON.parse(r)}catch(e){return r}}catch(e){return console.error("error",e),t}},LB=(e,t)=>{var n;try{window.localStorage.setItem(null!==(n=OB[e])&&void 0!==n?n:e,t.toString())}catch(e){console.error("error",e)}},kB=e=>{var t;try{window.localStorage.removeItem(null!==(t=OB[e])&&void 0!==t?t:e)}catch(e){console.error("error",e)}};c=o("85Hg2"),c=o("85Hg2");var BB=(e=>(e[e.Open=0]="Open",e[e.Closed=1]="Closed",e))(BB||{}),zB=(e=>(e[e.Single=0]="Single",e[e.Multi=1]="Multi",e))(zB||{}),FB=(e=>(e[e.Pointer=0]="Pointer",e[e.Other=1]="Other",e))(FB||{}),UB=(e=>(e[e.OpenListbox=0]="OpenListbox",e[e.CloseListbox=1]="CloseListbox",e[e.SetDisabled=2]="SetDisabled",e[e.SetOrientation=3]="SetOrientation",e[e.GoToOption=4]="GoToOption",e[e.Search=5]="Search",e[e.ClearSearch=6]="ClearSearch",e[e.RegisterOption=7]="RegisterOption",e[e.UnregisterOption=8]="UnregisterOption",e))(UB||{});function jB(e,t=(e=>e)){let n=null!==e.activeOptionIndex?e.options[e.activeOptionIndex]:null,r=Op(t(e.options.slice()),(e=>e.dataRef.current.domRef.current)),i=n?r.indexOf(n):null;return-1===i&&(i=null),{options:r,activeOptionIndex:i}}let GB={1:e=>e.disabled||1===e.listboxState?e:{...e,activeOptionIndex:null,listboxState:1},0(e){if(e.disabled||0===e.listboxState)return e;let t=e.activeOptionIndex,{value:n,mode:r,compare:i}=e.propsRef.current,o=e.options.findIndex((e=>{let t=e.dataRef.current.value;return vh(r,{1:()=>n.some((e=>i(e,t))),0:()=>i(n,t)})}));return-1!==o&&(t=o),{...e,listboxState:0,activeOptionIndex:t}},2:(e,t)=>e.disabled===t.disabled?e:{...e,disabled:t.disabled},3:(e,t)=>e.orientation===t.orientation?e:{...e,orientation:t.orientation},4(e,t){var n;if(e.disabled||1===e.listboxState)return e;let r=jB(e),i=MR(t,{resolveItems:()=>r.options,resolveActiveIndex:()=>r.activeOptionIndex,resolveId:e=>e.id,resolveDisabled:e=>e.dataRef.current.disabled});return{...e,...r,searchQuery:"",activeOptionIndex:i,activationTrigger:null!=(n=t.trigger)?n:1}},5:(e,t)=>{if(e.disabled||1===e.listboxState)return e;let n=""!==e.searchQuery?0:1,r=e.searchQuery+t.value.toLowerCase(),i=(null!==e.activeOptionIndex?e.options.slice(e.activeOptionIndex+n).concat(e.options.slice(0,e.activeOptionIndex+n)):e.options).find((e=>{var t;return!e.dataRef.current.disabled&&(null==(t=e.dataRef.current.textValue)?void 0:t.startsWith(r))})),o=i?e.options.indexOf(i):-1;return-1===o||o===e.activeOptionIndex?{...e,searchQuery:r}:{...e,searchQuery:r,activeOptionIndex:o,activationTrigger:1}},6:e=>e.disabled||1===e.listboxState||""===e.searchQuery?e:{...e,searchQuery:""},7:(e,t)=>{let n={id:t.id,dataRef:t.dataRef},r=jB(e,(e=>[...e,n]));if(null===e.activeOptionIndex){let{value:i,mode:o,compare:s}=e.propsRef.current,a=t.dataRef.current.value;vh(o,{1:()=>i.some((e=>s(e,a))),0:()=>s(i,a)})&&(r.activeOptionIndex=r.options.indexOf(n))}return{...e,...r}},8:(e,t)=>{let n=jB(e,(e=>{let n=e.findIndex((e=>e.id===t.id));return-1!==n&&e.splice(n,1),e}));return{...e,...n,activationTrigger:1}}},HB=(0,c.createContext)(null);function VB(e){let t=(0,c.useContext)(HB);if(null===t){let t=new Error(`<${e} /> is missing a parent <Listbox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(t,VB),t}return t}function WB(e,t){return vh(t.type,GB,e,t)}HB.displayName="ListboxContext";let qB=c.Fragment,JB=wh((function(e,n){let{value:r,defaultValue:i,name:o,onChange:s,by:a=((e,t)=>e===t),disabled:l=!1,horizontal:u=!1,multiple:d=!1,...h}=e;const p=u?"horizontal":"vertical";let m=Uh(n),[f,g]=DR(r,s,i),v=(0,c.useReducer)(WB,{listboxState:1,propsRef:{current:{value:f,onChange:g,mode:d?1:0,compare:Bh("string"==typeof a?(e,t)=>{let n=a;return(null==e?void 0:e[n])===(null==t?void 0:t[n])}:a)}},labelRef:(0,c.createRef)(),buttonRef:(0,c.createRef)(),optionsRef:(0,c.createRef)(),disabled:l,orientation:p,options:[],searchQuery:"",activeOptionIndex:null,activationTrigger:1}),[{listboxState:y,propsRef:_,optionsRef:S,buttonRef:b},x]=v;_.current.value=f,_.current.mode=d?1:0,Nh((()=>{_.current.onChange=e=>vh(_.current.mode,{0:()=>g(e),1(){let t=_.current.value.slice(),{compare:n}=_.current,r=t.findIndex((t=>n(t,e)));return-1===r?t.push(e):t.splice(r,1),g(t)}})}),[g,_]),Nh((()=>x({type:2,disabled:l})),[l]),Nh((()=>x({type:3,orientation:p})),[p]),hm([b,S],((e,t)=>{var n;x({type:1}),Mp(t,Tp.Loose)||(e.preventDefault(),null==(n=b.current)||n.focus())}),0===y);let C=(0,c.useMemo)((()=>({open:0===y,disabled:l,value:f})),[y,l,f]),w={ref:m};return t(c).createElement(HB.Provider,{value:v},t(c).createElement(Rh,{value:vh(y,{0:Th.Open,1:Th.Closed})},null!=o&&null!=f&&RR({[o]:f}).map((([e,n])=>t(c).createElement(Sp,{features:_p.Hidden,...Ah({key:e,as:"input",type:"hidden",hidden:!0,readOnly:!0,name:e,value:n})}))),bh({ourProps:w,theirProps:h,slot:C,defaultTag:qB,name:"Listbox"})))})),KB=wh((function(e,t){var n;let[r,i]=VB("Listbox.Button"),o=Uh(r.buttonRef,t),s=`headlessui-listbox-button-${yp()}`,a=Yh(),l=Bh((e=>{switch(e.key){case pp.Space:case pp.Enter:case pp.ArrowDown:e.preventDefault(),i({type:0}),a.nextFrame((()=>{r.propsRef.current.value||i({type:4,focus:TR.First})}));break;case pp.ArrowUp:e.preventDefault(),i({type:0}),a.nextFrame((()=>{r.propsRef.current.value||i({type:4,focus:TR.Last})}))}})),u=Bh((e=>{if(e.key===pp.Space)e.preventDefault()})),d=Bh((e=>{if(mp(e.currentTarget))return e.preventDefault();0===r.listboxState?(i({type:1}),a.nextFrame((()=>{var e;return null==(e=r.buttonRef.current)?void 0:e.focus({preventScroll:!0})}))):(e.preventDefault(),i({type:0}))})),h=wR((()=>{if(r.labelRef.current)return[r.labelRef.current.id,s].join(" ")}),[r.labelRef.current,s]),p=(0,c.useMemo)((()=>({open:0===r.listboxState,disabled:r.disabled,value:r.propsRef.current.value})),[r]),m=e;return bh({ourProps:{ref:o,id:s,type:ER(e,r.buttonRef),"aria-haspopup":!0,"aria-controls":null==(n=r.optionsRef.current)?void 0:n.id,"aria-expanded":r.disabled?void 0:0===r.listboxState,"aria-labelledby":h,disabled:r.disabled,onKeyDown:l,onKeyUp:u,onClick:d},theirProps:m,slot:p,defaultTag:"button",name:"Listbox.Button"})})),YB=wh((function(e,t){let[n]=VB("Listbox.Label"),r=`headlessui-listbox-label-${yp()}`;return bh({ourProps:{ref:Uh(n.labelRef,t),id:r,onClick:Bh((()=>{var e;return null==(e=n.buttonRef.current)?void 0:e.focus({preventScroll:!0})}))},theirProps:e,slot:(0,c.useMemo)((()=>({open:0===n.listboxState,disabled:n.disabled})),[n]),defaultTag:"label",name:"Listbox.Label"})})),XB=_h.RenderStrategy|_h.Static,QB=wh((function(e,t){var n;let[r,i]=VB("Listbox.Options"),o=Uh(r.optionsRef,t),s=`headlessui-listbox-options-${yp()}`,a=Yh(),l=Yh(),u=Mh(),d=null!==u?u===Th.Open:0===r.listboxState;(0,c.useEffect)((()=>{var e;let t=r.optionsRef.current;!t||0===r.listboxState&&t!==(null==(e=bp(t))?void 0:e.activeElement)&&t.focus({preventScroll:!0})}),[r.listboxState,r.optionsRef]);let h=Bh((e=>{switch(l.dispose(),e.key){case pp.Space:if(""!==r.searchQuery)return e.preventDefault(),e.stopPropagation(),i({type:5,value:e.key});case pp.Enter:if(e.preventDefault(),e.stopPropagation(),null!==r.activeOptionIndex){let{dataRef:e}=r.options[r.activeOptionIndex];r.propsRef.current.onChange(e.current.value)}0===r.propsRef.current.mode&&(i({type:1}),Hh().nextFrame((()=>{var e;return null==(e=r.buttonRef.current)?void 0:e.focus({preventScroll:!0})})));break;case vh(r.orientation,{vertical:pp.ArrowDown,horizontal:pp.ArrowRight}):return e.preventDefault(),e.stopPropagation(),i({type:4,focus:TR.Next});case vh(r.orientation,{vertical:pp.ArrowUp,horizontal:pp.ArrowLeft}):return e.preventDefault(),e.stopPropagation(),i({type:4,focus:TR.Previous});case pp.Home:case pp.PageUp:return e.preventDefault(),e.stopPropagation(),i({type:4,focus:TR.First});case pp.End:case pp.PageDown:return e.preventDefault(),e.stopPropagation(),i({type:4,focus:TR.Last});case pp.Escape:return e.preventDefault(),e.stopPropagation(),i({type:1}),a.nextFrame((()=>{var e;return null==(e=r.buttonRef.current)?void 0:e.focus({preventScroll:!0})}));case pp.Tab:e.preventDefault(),e.stopPropagation();break;default:1===e.key.length&&(i({type:5,value:e.key}),l.setTimeout((()=>i({type:6})),350))}})),p=wR((()=>{var e,t,n;return null!=(n=null==(e=r.labelRef.current)?void 0:e.id)?n:null==(t=r.buttonRef.current)?void 0:t.id}),[r.labelRef.current,r.buttonRef.current]),m=(0,c.useMemo)((()=>({open:0===r.listboxState})),[r]),f=e;return bh({ourProps:{"aria-activedescendant":null===r.activeOptionIndex||null==(n=r.options[r.activeOptionIndex])?void 0:n.id,"aria-multiselectable":1===r.propsRef.current.mode||void 0,"aria-labelledby":p,"aria-orientation":r.orientation,id:s,onKeyDown:h,role:"listbox",tabIndex:0,ref:o},theirProps:f,slot:m,defaultTag:"ul",features:XB,visible:d,name:"Listbox.Options"})})),$B=wh((function(e,t){let{disabled:n=!1,value:r,...i}=e,[o,s]=VB("Listbox.Option"),a=`headlessui-listbox-option-${yp()}`,l=null!==o.activeOptionIndex&&o.options[o.activeOptionIndex].id===a,{value:u,compare:d}=o.propsRef.current,h=vh(o.propsRef.current.mode,{1:()=>u.some((e=>d(e,r))),0:()=>d(u,r)}),p=(0,c.useRef)(null),m=Uh(t,p);Nh((()=>{if(0!==o.listboxState||!l||0===o.activationTrigger)return;let e=Hh();return e.requestAnimationFrame((()=>{var e,t;null==(t=null==(e=p.current)?void 0:e.scrollIntoView)||t.call(e,{block:"nearest"})})),e.dispose}),[p,l,o.listboxState,o.activationTrigger,o.activeOptionIndex]);let f=(0,c.useRef)({disabled:n,value:r,domRef:p});Nh((()=>{f.current.disabled=n}),[f,n]),Nh((()=>{f.current.value=r}),[f,r]),Nh((()=>{var e,t;f.current.textValue=null==(t=null==(e=p.current)?void 0:e.textContent)?void 0:t.toLowerCase()}),[f,p]);let g=Bh((()=>o.propsRef.current.onChange(r)));Nh((()=>(s({type:7,id:a,dataRef:f}),()=>s({type:8,id:a}))),[f,a]);let v=Bh((e=>{if(n)return e.preventDefault();g(),0===o.propsRef.current.mode&&(s({type:1}),Hh().nextFrame((()=>{var e;return null==(e=o.buttonRef.current)?void 0:e.focus({preventScroll:!0})})))})),y=Bh((()=>{if(n)return s({type:4,focus:TR.Nothing});s({type:4,focus:TR.Specific,id:a})})),_=Bh((()=>{n||l||s({type:4,focus:TR.Specific,id:a,trigger:0})})),S=Bh((()=>{n||!l||s({type:4,focus:TR.Nothing})})),b=(0,c.useMemo)((()=>({active:l,selected:h,disabled:n})),[l,h,n]);return bh({ourProps:{id:a,ref:m,role:"option",tabIndex:!0===n?void 0:-1,"aria-disabled":!0===n||void 0,"aria-selected":h,disabled:void 0,onClick:v,onFocus:y,onPointerMove:_,onMouseMove:_,onPointerLeave:S,onMouseLeave:S},theirProps:i,slot:b,defaultTag:"li",name:"Listbox.Option"})})),ZB=Object.assign(JB,{Button:KB,Label:YB,Options:QB,Option:$B});var ez=({min:e=0,max:n=100,step:r=1,defaultValue:i=50,label:o,onChange:a,disabled:l=!1})=>{const[u,d]=(0,c.useState)(i),[h,p]=(0,c.useState)(!1),m=(0,c.useRef)(null),f=(u-e)/(n-e)*100,g=[];for(let t=e;t<=n;t+=(n-e)/4)g.push(Math.round(t));const v=t=>{if(!m.current)return u;const i=m.current.getBoundingClientRect(),o=t-i.left,s=i.width,a=Math.max(0,Math.min(100,o/s*100)),l=Math.round(a/100*(n-e)+e),c=Math.round(l/r)*r;return Math.min(Math.max(c,e),n)},y=e=>{if(l)return;p(!0);const t=v(e);d(t),null==a||a(t)},_=e=>{if(!h||l)return;const t=v(e);d(t),null==a||a(t)};return(0,c.useEffect)((()=>{const e=e=>{h&&(e.preventDefault(),_(e.touches[0].clientX))},t=e=>{_(e.clientX)},n=()=>{p(!1)};return h&&(window.addEventListener("touchmove",e,{passive:!1}),window.addEventListener("mousemove",t),window.addEventListener("touchend",n),window.addEventListener("mouseup",n)),()=>{window.removeEventListener("touchmove",e),window.removeEventListener("mousemove",t),window.removeEventListener("touchend",n),window.removeEventListener("mouseup",n)}}),[h]),(0,c.useEffect)((()=>{d(i)}),[i]),(0,s.jsxs)("div",{className:t(Is)("memori--slider-container",{"memori--slider-disabled":l}),style:{"--percentage":`${f}%`},children:[(0,s.jsxs)("div",{className:"memori--slider-header",children:[o&&(0,s.jsx)("div",{className:"memori--slider-label",children:o}),(0,s.jsx)("div",{className:"memori--slider-value",children:u})]}),(0,s.jsxs)("div",{ref:m,className:"memori--slider-track-container",onMouseDown:e=>y(e.clientX),onTouchStart:e=>y(e.touches[0].clientX),children:[(0,s.jsx)("div",{className:"memori--slider-track",children:(0,s.jsx)("div",{className:"memori--slider-track-fill"})}),(0,s.jsx)("div",{className:"memori--slider-marks",children:g.map((e=>(0,s.jsxs)("div",{className:"memori--slider-mark",children:[(0,s.jsx)("div",{className:"memori--slider-mark-line"}),(0,s.jsx)("span",{className:"memori--slider-mark-value",children:e})]},e)))}),(0,s.jsx)(ZB,{value:u,onChange:d,disabled:l,children:(0,s.jsx)("div",{className:"memori--slider-thumb",role:"slider","aria-valuemin":e,"aria-valuemax":n,"aria-valuenow":u,tabIndex:l?-1:0})})]})]})};var tz=({avatarHeight:e,avatarDepth:t,setAvatarHeight:n,setAvatarDepth:r,halfBody:i,setEnablePositionControls:o})=>{const a=i?{height:80,depth:50}:{height:25,depth:25},l=i?{height:55,depth:10}:{height:15,depth:5},u=i?{height:100,depth:80}:{height:65,depth:100},d=(0,c.useRef)({height:e,depth:t,zoomed:!1,normal:!1,far:!1}),{t:h}=Ie();return(0,c.useEffect)((()=>{d.current.height=e,d.current.depth=t}),[e,t]),(0,c.useEffect)((()=>{const e=e=>{if("-"===e.key||"_"===e.key&&d.current.depth<100){const e=Math.min(d.current.depth+10,100);r(e),LB("avatarDepth",e)}else if(("+"===e.key||"="===e.key)&&d.current.depth>-100){const e=Math.max(d.current.depth-10,-100);r(e),LB("avatarDepth",e)}};return window.addEventListener("keydown",e),()=>{window.removeEventListener("keydown",e)}}),[r]),(0,c.useEffect)((()=>{const e=e=>{if("ArrowUp"===e.key&&d.current.height<100){const e=d.current.height+5;n(e),LB("avatarHeight",e)}},t=e=>{if("ArrowDown"===e.key&&d.current.height>0){const e=d.current.height-5;n(e),LB("avatarHeight",e)}};return window.addEventListener("keydown",e),window.addEventListener("keydown",t),()=>{window.removeEventListener("keydown",e),window.removeEventListener("keydown",t)}}),[n]),(0,s.jsxs)("div",{className:"memori--position-controls",children:[(0,s.jsx)("div",{className:"memori--position-controls-close",children:(0,s.jsx)(Mm,{ghost:!0,icon:(0,s.jsx)(Rm,{}),outlined:!0,danger:!0,shape:"circle",className:"memori--position-controls-close-button",onClick:()=>{o(!1)}})}),(0,s.jsx)(ez,{defaultValue:d.current.height,min:.5,max:100,label:h("write_and_speak.height"),step:1,onChange:e=>{n(e),LB("avatarHeight",e)}}),(0,s.jsx)(ez,{defaultValue:d.current.depth,min:.5,max:100,step:5,label:h("write_and_speak.depth"),onChange:e=>{r(e),LB("avatarDepth",e)}}),(0,s.jsxs)("div",{className:"memori--preset-buttons",children:[(0,s.jsx)(Mm,{outlined:!0,isActive:e===(i?l.height:a.height)&&t===(i?l.depth:a.depth),onClick:()=>{n(l.height),r(l.depth),LB("avatarHeight",l.height),LB("avatarDepth",l.depth)},children:h("write_and_speak.zoomed")}),(0,s.jsx)(Mm,{outlined:!0,isActive:e===(i?a.height:l.height)&&t===(i?a.depth:l.depth),onClick:()=>{n(a.height),r(a.depth),LB("avatarHeight",a.height),LB("avatarDepth",a.depth)},children:h("write_and_speak.normal")}),(0,s.jsx)(Mm,{outlined:!0,isActive:e===(i?u.height:a.height)&&t===(i?u.depth:a.depth),onClick:()=>{n(u.height),r(u.depth),LB("avatarHeight",u.height),LB("avatarDepth",u.depth)},children:h("write_and_speak.far")})]})]})};let nz=0;const rz=t(FD)((e=>(xI.onStart=(t,n,r)=>{e({active:!0,item:t,loaded:n,total:r,progress:(n-nz)/(r-nz)*100})},xI.onLoad=()=>{e({active:!1})},xI.onError=t=>e((e=>({errors:[...e.errors,t]}))),xI.onProgress=(t,n,r)=>{n===r&&(nz=r),e({active:!0,item:t,loaded:n,total:r,progress:(n-nz)/(r-nz)*100||100})},{errors:[],active:!1,progress:0,item:"",loaded:0,total:0})));c=o("85Hg2");const iz=new u_,oz=new u_,sz=new u_;function az(e,t,n){const r=iz.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 lz=e=>Math.abs(e)<1e-10?0:e;function cz(e,t,n=""){let r="matrix3d(";for(let n=0;16!==n;n++)r+=lz(t[n]*e.elements[n])+(15!==n?",":")");return n+r}const uz=(dz=[1,-1,1,1,1,-1,1,1,1,-1,1,1,1,-1,1,1],e=>cz(e,dz));var dz;const hz=(e,t)=>{return cz(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},pz=c.forwardRef((({children:e,eps:t=.001,style:n,className:r,prepend:i,center:o,fullscreen:s,portal:l,distanceFactor:u,sprite:d=!1,transform:h=!1,occlude:p,onOcclude:m,zIndexRange:f=[16777271,0],calculatePosition:g=az,as:v="div",wrapperClass:y,pointerEvents:_="auto",...S},b)=>{var x;const C=IL((({gl:e})=>e)),w=IL((({camera:e})=>e)),A=IL((({scene:e})=>e)),E=IL((({size:e})=>e)),I=IL((({raycaster:e})=>e)),[T]=c.useState((()=>document.createElement(v))),M=c.useRef(null),R=c.useRef(0),P=c.useRef([0,0]),N=c.useRef(null),O=c.useRef(null),D=null!==(x=null==l?void 0:l.current)&&void 0!==x?x:C.domElement.parentNode;c.useEffect((()=>{if(M.current){if(A.updateMatrixWorld(),h)T.style.cssText="position:absolute;top:0;left:0;pointer-events:none;overflow:hidden;";else{const e=g(M.current,w,E);T.style.cssText=`position:absolute;top:0;left:0;transform:translate3d(${e[0]}px,${e[1]}px,0);transform-origin:0 0;`}return D&&(i?D.prepend(T):D.appendChild(T)),()=>{D&&D.removeChild(T),a.unmountComponentAtNode(T)}}}),[D,h]),c.useLayoutEffect((()=>{y&&(T.className=y)}),[y]);const L=c.useMemo((()=>h?{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",...s&&{top:-E.height/2,left:-E.width/2,width:E.width,height:E.height},...n}),[n,o,s,E,h]),k=c.useMemo((()=>({position:"absolute",pointerEvents:_})),[_]);c.useLayoutEffect((()=>{h?a.render(c.createElement("div",{ref:N,style:L},c.createElement("div",{ref:O,style:k},c.createElement("div",{ref:b,className:r,style:n,children:e}))),T):a.render(c.createElement("div",{ref:b,style:L,className:r,children:e}),T)}));const B=c.useRef(!0);return TL((()=>{if(M.current){w.updateMatrixWorld(),M.current.updateWorldMatrix(!0,!1);const e=h?P.current:g(M.current,w,E);if(h||Math.abs(R.current-w.zoom)>t||Math.abs(P.current[0]-e[0])>t||Math.abs(P.current[1]-e[1])>t){const t=function(e,t){const n=iz.setFromMatrixPosition(e.matrixWorld),r=oz.setFromMatrixPosition(t.matrixWorld),i=n.sub(r),o=t.getWorldDirection(sz);return i.angleTo(o)>Math.PI/2}(M.current,w);let n=!1;"boolean"==typeof p?!0===p&&(n=[A]):Array.isArray(p)&&(n=p.map((e=>e.current)));const r=B.current;if(n){const e=function(e,t,n,r){const i=iz.setFromMatrixPosition(e.matrixWorld),o=i.clone();o.project(t),n.setFromCamera(o,t);const s=n.intersectObjects(r,!0);if(s.length){const e=s[0].distance;return i.distanceTo(n.ray.origin)<e}return!0}(M.current,w,I,n);B.current=e&&!t}else B.current=!t;if(r!==B.current&&(m?m(!B.current):T.style.display=B.current?"block":"none"),T.style.zIndex=`${function(e,t,n){if(t instanceof _b||t instanceof Hb){const r=iz.setFromMatrixPosition(e.matrixWorld),i=oz.setFromMatrixPosition(t.matrixWorld),o=r.distanceTo(i),s=(n[1]-n[0])/(t.far-t.near),a=n[1]-s*t.far;return Math.round(s*o+a)}}(M.current,w,f)}`,h){const[e,t]=[E.width/2,E.height/2],n=w.projectionMatrix.elements[5]*t,{isOrthographicCamera:r,top:i,left:o,bottom:s,right:a}=w,l=uz(w.matrixWorldInverse),c=r?`scale(${n})translate(${lz(-(a+o)/2)}px,${lz((i+s)/2)}px)`:`translateZ(${n}px)`;let h=M.current.matrixWorld;d&&(h=w.matrixWorldInverse.clone().transpose().copyPosition(h).scale(M.current.scale),h.elements[3]=h.elements[7]=h.elements[11]=0,h.elements[15]=1),T.style.width=E.width+"px",T.style.height=E.height+"px",T.style.perspective=r?"":`${n}px`,N.current&&O.current&&(N.current.style.transform=`${c}${l}translate(${e}px,${t}px)`,O.current.style.transform=hz(h,1/((u||10)/400)))}else{const t=void 0===u?1:function(e,t){if(t instanceof Hb)return t.zoom;if(t instanceof _b){const n=iz.setFromMatrixPosition(e.matrixWorld),r=oz.setFromMatrixPosition(t.matrixWorld),i=t.fov*Math.PI/180,o=n.distanceTo(r);return 1/(2*Math.tan(i/2)*o)}return 1}(M.current,w)*u;T.style.transform=`translate3d(${e[0]}px,${e[1]}px,0) scale(${t})`}P.current=e,R.current=w.zoom}}})),c.createElement("group",UL({},S,{ref:M}))}));var mz=({fallbackImg:e})=>{const{progress:t}=rz();return(0,s.jsx)(pz,{center:!0,className:"avatar-loader",children:(0,s.jsx)(Tm,{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"]})})})};c=o("85Hg2");const fz=e=>{return t=Object.entries(e).filter((([e,t])=>void 0!==t)),Object.assign({},...t.map((([e,t])=>({[e]:t}))));var t},gz=Object.freeze({fillLightAngle:Math.PI/3,backLightAngle:Math.PI/8,keyLightAngle:Math.PI/2,silhouetteLightAngle:1.25*Math.PI,keyLightPosition:new u_(.75,1.75,.75),liftLightPosition:new u_(.25,1.5,2),dirLightPosition:new u_(-.75,2.5,-1),silhouetteLightPosition:new u_(-1.25,.25,-1.25),defaultProps:{keyLightIntensity:1.2,keyLightColor:"#FFF5EB",fillLightIntensity:2.5,fillLightColor:"#A4C4FF",fillLightPosition:new u_(-.6,1.7,-.4),backLightIntensity:4,backLightColor:"#FFD4A8",backLightPosition:new u_(.6,1.7,-1),lightTarget:new u_(0,1.65,0)}});var vz=e=>{const{keyLightIntensity:t,keyLightColor:n,fillLightIntensity:r,fillLightColor:i,fillLightPosition:o,backLightIntensity:a,backLightColor:l,backLightPosition:u,lightTarget:d}=Object.assign(gz.defaultProps,fz(e)),{scene:h}=IL(),[p]=(0,c.useState)({head:new hS,shoe:new hS});return(0,c.useEffect)((()=>(p.head.position.copy(d),p.shoe.position.set(0,.1,0),h.add(p.head),h.add(p.shoe),()=>{h.remove(p.head),h.remove(p.shoe)})),[h,p,d]),(0,s.jsxs)("group",{children:[(0,s.jsx)("spotLight",{position:o,target:p.head,angle:gz.fillLightAngle,color:i,intensity:r,castShadow:!0,"shadow-bias":-1e-4,penumbra:.2}),(0,s.jsx)("spotLight",{position:u,target:p.head,angle:gz.backLightAngle,color:l,intensity:a,castShadow:!0,"shadow-bias":-1e-4,penumbra:.2}),(0,s.jsx)("spotLight",{position:gz.keyLightPosition,target:p.head,angle:gz.keyLightAngle,color:n,intensity:t,penumbra:.3,castShadow:!0}),(0,s.jsx)("spotLight",{position:gz.liftLightPosition,target:p.shoe,angle:gz.keyLightAngle,color:n,intensity:.3*t,penumbra:.4}),(0,s.jsx)("spotLight",{position:gz.silhouetteLightPosition,target:p.head,angle:gz.silhouetteLightAngle,color:n,intensity:.3*t,penumbra:.3}),(0,s.jsx)("ambientLight",{intensity:.2,color:"#FFF8EF"})]})};const yz={halfBody:{width:"100%",height:"100%",minHeight:"500px",backgroundColor:"white",borderRadius:"100%"},fullBody:{width:"500px",height:"500px",backgroundColor:"white"}},_z=(e,t)=>({fov:t?44:40,position:[0,0,e?.6:3],target:[0,0,0]});function Sz({url:e,sex:t,style:n,rotateAvatar:r,eyeBlink:i,headMovement:o,speaking:a,fallback:l,fallbackImg:u,halfBody:d=!0,loading:h,showControls:p=!1,isZoomed:m,chatEmission:f,updateCurrentViseme:g,enablePositionControls:v,setEnablePositionControls:y,isTotem:_=!1}){const[S,b]=(0,c.useState)((()=>_z(d,m||!1).position[2])),[x,C]=(0,c.useState)((()=>{if(_){return DB("avatarHeight",50)}return d?80:m?16:65})()),[w,A]=(0,c.useState)((()=>{if(_){return DB("avatarDepth",50)}return d?50:m?5:100})());return(0,s.jsxs)(s.Fragment,{children:[v&&(0,s.jsx)(tz,{avatarHeight:x,avatarDepth:w,halfBody:d,setAvatarHeight:C,setAvatarDepth:A,setEnablePositionControls:y}),(0,s.jsxs)(AL,{style:n||yz.fullBody,shadows:!0,dpr:[1,2],gl:{antialias:!0,alpha:!0,powerPreference:"high-performance",stencil:!1},children:[(0,s.jsx)(KL,{makeDefault:!0,position:[0,0,S],fov:_z(d,m||!1).fov,near:.1,far:1e3}),r&&(0,s.jsx)(JL,{enablePan:!1,enableZoom:!1,target:[0,0,0],enableDamping:!0,dampingFactor:.05}),(0,s.jsxs)(c.Suspense,{fallback:l||(0,s.jsx)(mz,{fallbackImg:u}),children:[(0,s.jsx)(vz,{}),(0,s.jsx)(NB,{url:e,sex:t,showControls:p,loading:h||!1,eyeBlink:i||!1,headMovement:o||!1,speaking:a||!1,halfBody:d,chatEmission:f,updateCurrentViseme:g,setCameraZ:b,avatarHeight:x,avatarDepth:w})]})]})]})}const bz=(0,(c=o("85Hg2")).createContext)(void 0),xz={0:"viseme_sil",1:"viseme_PP",2:"viseme_FF",3:"viseme_TH",4:"viseme_DD",5:"viseme_kk",6:"viseme_CH",7:"viseme_SS",8:"viseme_nn",9:"viseme_RR",10:"viseme_aa",11:"viseme_E",12:"viseme_I",13:"viseme_O",14:"viseme_U",15:"viseme_kk",16:"viseme_CH",17:"viseme_SS",18:"viseme_TH",19:"viseme_RR",20:"viseme_kk",21:"viseme_PP"},{DEFAULT_VISEME_DURATION:Cz,VISEME_OVERLAP:wz,SMOOTHING_FACTOR:Az,LOG_INTERVAL:Ez,PRELOAD:Iz,WEIGHT_MULTIPLIER:Tz}={DEFAULT_VISEME_DURATION:.12,VISEME_OVERLAP:.02,SMOOTHING_FACTOR:.4,LOG_INTERVAL:60,PRELOAD:.2,WEIGHT_MULTIPLIER:.8},Mz=(e,t)=>e.endTime<t-wz,Rz=e=>Math.sin(Math.PI*Math.min(e,1))*Tz,Pz=(e,t)=>e+(t-e)*Az,Nz=({children:e})=>{const t=(0,c.useRef)([]),n=(0,c.useRef)(null),r=(0,c.useRef)(null),[i,o]=(0,c.useState)(!1),[a,l]=(0,c.useState)("idle"),u=(0,c.useRef)(null),d=(0,c.useRef)(0),h=(0,c.useRef)(null),p=(0,c.useCallback)((e=>{n.current=e,e.onstatechange=()=>{switch(e.state){case"running":l("active");break;case"suspended":l("paused");break;case"closed":l("finished"),g()}}}),[]),m=(0,c.useCallback)(((e,n)=>{if("finished"===a)return;const r=xz[e]||"viseme_sil",i=n/1e7;null===h.current&&(h.current=i);const o=i-(h.current||0),s={name:r,weight:0,startTime:o,endTime:o+Cz};t.current.push(s),"idle"===a&&l("preparing")}),[a]),f=(0,c.useCallback)((e=>{e&&(n.current=e,r.current=e.currentTime,d.current=0,o(!0),l("active"))}),[]),g=(0,c.useCallback)((()=>{o(!1),l("finished"),r.current=null,u.current=null,d.current=0,n.current=null}),[]),v=(0,c.useCallback)((e=>{if(!i||!n.current)return null;const o=n.current.currentTime-(r.current||0)+Iz;t.current=t.current.filter((e=>!Mz(e,o)));const s=t.current.find((e=>e.startTime<=o&&e.endTime>o-wz));if(s){const e=(o-s.startTime)/(s.endTime-s.startTime),t=Rz(e),n=u.current?Pz(u.current.weight,t):t,r={...s,weight:n};return u.current=r,r}if(u.current){const e=u.current.weight*(1-Az);u.current={...u.current,weight:e}}return u.current=null,null}),[i]),y=(0,c.useCallback)((()=>{t.current=[],u.current=null,r.current=null,h.current=null,d.current=0,l("idle")}),[a]),_=(0,c.useCallback)((e=>{g(),y(),f(e)}),[g,y,f,a]),S=(0,c.useMemo)((()=>({addViseme:m,updateCurrentViseme:v,startProcessing:f,stopProcessing:g,resetAndStartProcessing:_,resetVisemeQueue:y,isProcessing:i,setAudioContext:p})),[m,v,f,g,_,y,i,p]);return(0,s.jsx)(bz.Provider,{value:S,children:e})},Oz=()=>{const e=(0,c.useContext)(bz);if(!e)throw new Error("useVisemeContext must be used within a VisemeProvider");return e};var Dz=(0,c.memo)((({memori:e,integration:n,integrationConfig:r,tenant:i,instruct:o=!1,avatar3dVisible:a=!1,setAvatar3dVisible:l,hasUserActivatedSpeak:u=!1,isPlayingAudio:d=!1,loading:h=!1,baseUrl:p,apiUrl:m,animation:f,isZoomed:g=!1,chatProps:v,avatarType:y=null,enablePositionControls:_,setEnablePositionControls:S,isTotem:b=!1})=>{const{t:x}=Ie(),[C,w]=(0,c.useState)(!1),{stopProcessing:A,updateCurrentViseme:E,resetVisemeQueue:I}=Oz();(0,c.useEffect)((()=>{w(!0)}),[]);const T=()=>{if("userAvatar"===(null==r?void 0:r.avatar)&&e.avatarURL&&e.avatarURL.length>0)return RN({type:"avatar",tenantID:null==i?void 0:i.name,resourceURI:e.avatarURL,baseURL:p,apiURL:m})},M=()=>{var t;return C?"readyplayerme"===(null==r?void 0:r.avatar)||"readyplayerme-full"===(null==r?void 0:r.avatar)||"customrpm"===(null==r?void 0:r.avatar)?(0,s.jsx)(DD,{fallback:(0,s.jsx)("div",{className:"memori--blob-container",children:C&&(0,s.jsx)(LD,{speaking:d,avatar:T()})}),children:(0,s.jsx)(Sz,{enablePositionControls:_,updateCurrentViseme:E,url:r.avatarURL,sex:"FEMALE"===e.voiceType?"FEMALE":"MALE",fallbackImg:T(),headMovement:!0,eyeBlink:!0,animation:f,halfBody:"readyplayerme"===r.avatar,speaking:d,loading:h,style:P(),stopProcessing:A,resetVisemeQueue:I,isZoomed:g,isTotem:b,chatEmission:null===(t=null==v?void 0:v.dialogState)||void 0===t?void 0:t.emission,setEnablePositionControls:S})}):"customglb"===(null==r?void 0:r.avatar)?(0,s.jsx)(DO,{poster:T()||"",src:r.avatarURL,alt:""}):null:null},R=()=>(0,s.jsx)("div",{className:"memori--avatar-toggle",children:(0,s.jsx)(Mm,{ghost:!0,onClick:()=>l(!a),icon:a?(0,s.jsx)(BD,{}):(0,s.jsx)(kD,{}),children:(0,s.jsx)("span",{className:"memori--avatar-toggle-text",children:x(a?"hide":"show")})})}),P=()=>"readyplayerme"===(null==r?void 0:r.avatar)?{width:"100%",height:"100%",backgroundColor:"none",boxShadow:"none"}:{width:"100%",height:"100%",backgroundColor:"none"};return(0,s.jsxs)(s.Fragment,{children:[("readyplayerme"===(null==r?void 0:r.avatar)||"readyplayerme-full"===(null==r?void 0:r.avatar)||"customglb"===(null==r?void 0:r.avatar)||"customrpm"===(null==r?void 0:r.avatar))&&(null==r?void 0:r.avatarURL)&&y&&"blob"!==y?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:t(Is)("memori--avatar-wrapper",`memori--avatar-${(null==r?void 0:r.avatar)||"default"}`,{hidden:!a}),children:M()}),R()]}):(0,s.jsx)("div",{className:"memori--blob-container",children:C&&(0,s.jsx)(LD,{speaking:d,avatar:T()})}),(()=>{if(!o||u||!e.isGiver||!(null==i?void 0:i.name))return null;const t=`https://${i.name}/${"it-IT"===e.culture?"it":"en"}/${e.ownerUserName}/${e.name}/integrations${(null==n?void 0:n.integrationID)?`?integration=${n.integrationID}&openAvatarModal=true`:""}`;return(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:t,children:(0,s.jsx)(DN,{content:x("widgetgoToIntegrationsToCustomizeAvatar"),children:(0,s.jsx)("span",{className:"memori-button--icon",children:(0,s.jsx)(zD,{})})})})})})()]})}),((e,t)=>JSON.stringify(e)===JSON.stringify(t)));c=o("85Hg2");var Lz=({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 kz=({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"})});var Bz=({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"})});c=o("85Hg2");var zz=({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 Fz=({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 Uz=({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 jz=({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 Gz=({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 Hz=({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 Vz=({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 Wz,qz=({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"})}),Jz=(c=o("85Hg2"),Object.defineProperty),Kz=Object.getOwnPropertySymbols,Yz=Object.prototype.hasOwnProperty,Xz=Object.prototype.propertyIsEnumerable,Qz=(e,t,n)=>t in e?Jz(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,$z=(e,t)=>{for(var n in t||(t={}))Yz.call(t,n)&&Qz(e,n,t[n]);if(Kz)for(var n of Kz(t))Xz.call(t,n)&&Qz(e,n,t[n]);return e},Zz=(e,t)=>{var n={};for(var r in e)Yz.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&Kz)for(var r of Kz(e))t.indexOf(r)<0&&Xz.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 s=[];for(let e=0;e<this.size;e++)s.push(!1);for(let e=0;e<this.size;e++)this.modules.push(s.slice()),this.isFunction.push(s.slice());this.drawFunctionPatterns();const a=this.addEccAndInterleave(r);if(this.drawCodewords(a),-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,s=40,l=-1,c=!0){if(!(t.MIN_VERSION<=i&&i<=s&&s<=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=a.getTotalBits(e,u);if(i<=r){d=i;break}if(u>=s)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 h=[];for(const t of e){r(t.mode.modeBits,4,h),r(t.numChars,t.mode.numCharCountBits(u),h);for(const e of t.getData())h.push(e)}o(h.length==d);const p=8*t.getNumDataCodewords(u,n);o(h.length<=p),r(0,Math.min(4,p-h.length),h),r(0,(8-h.length%8)%8,h),o(h.length%8==0);for(let e=236;h.length<p;e^=253)r(e,8,h);let m=[];for(;8*m.length<h.length;)m.push(0);return h.forEach(((e,t)=>m[t>>>3]|=e<<7-(7&t))),new t(u,n,m,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,s=t+n;0<=o&&o<this.size&&0<=s&&s<this.size&&this.setFunctionModule(o,s,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],s=t.ECC_CODEWORDS_PER_BLOCK[r.ordinal][n],a=Math.floor(t.getNumRawDataModules(n)/8),l=i-a%i,c=Math.floor(a/i);let u=[];const d=t.reedSolomonComputeDivisor(s);for(let n=0,r=0;n<i;n++){let i=e.slice(r,r+c-s+(n<l?0:1));r+=i.length;const o=t.reedSolomonComputeRemainder(i,d);n<l&&i.push(0),u.push(i.concat(o))}let h=[];for(let e=0;e<u[0].length;e++)u.forEach(((t,n)=>{(e!=c-s||n>=l)&&h.push(t[e])}));return o(h.length==a),h}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 s=t-o,a=0==(t+1&2)?this.size-1-r:r;!this.isFunction[a][s]&&n<8*e.length&&(this.modules[a][s]=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 s=0;s<this.size;s++)this.modules[n][s]==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][s],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 s=0;s<this.size;s++)this.modules[s][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[s][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 s=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 s(s.Mode.BYTE,e.length,t)}static makeNumeric(e){if(!s.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 s(s.Mode.NUMERIC,e.length,t)}static makeAlphanumeric(e){if(!s.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*s.ALPHANUMERIC_CHARSET.indexOf(e.charAt(t));i+=s.ALPHANUMERIC_CHARSET.indexOf(e.charAt(t+1)),r(i,11,n)}return t<e.length&&r(s.ALPHANUMERIC_CHARSET.indexOf(e.charAt(t)),6,n),new s(s.Mode.ALPHANUMERIC,e.length,n)}static makeSegments(e){return""==e?[]:s.isNumeric(e)?[s.makeNumeric(e)]:s.isAlphanumeric(e)?[s.makeAlphanumeric(e)]:[s.makeBytes(s.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 s(s.Mode.ECI,0,t)}static isNumeric(e){return s.NUMERIC_REGEX.test(e)}static isAlphanumeric(e){return s.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 a=s;a.NUMERIC_REGEX=/^[0-9]*$/,a.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,a.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:",e.QrSegment=a})(Wz||(Wz={})),(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={}))})(Wz||(Wz={})),(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={}))})(Wz||(Wz={}));var eF=Wz,tF={L:eF.QrCode.Ecc.LOW,M:eF.QrCode.Ecc.MEDIUM,Q:eF.QrCode.Ecc.QUARTILE,H:eF.QrCode.Ecc.HIGH},nF=128,rF="L",iF="#FFFFFF",oF="#000000",sF=!1;
|
|
246
246
|
/**
|
|
247
247
|
* @license qrcode.react
|
|
248
248
|
* Copyright (c) Paul O'Shannessy
|