@memori.ai/memori-webcomponent 8.1.20 → 8.1.21

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.
@@ -235,7 +235,7 @@ to {
235
235
  * SPDX-License-Identifier: MIT
236
236
  */
237
237
  const Ic="144",Mc={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},Cc={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Nc=0,Oc=1,Rc=2,Lc=3,Pc=0,Dc=1,kc=2,Bc=3,Fc=0,Uc=1,zc=2,Gc=0,jc=1,Hc=2,Vc=3,Wc=4,qc=5,$c=100,Yc=101,Jc=102,Zc=103,Xc=104,Kc=200,Qc=201,eu=202,tu=203,nu=204,iu=205,ru=206,ou=207,au=208,su=209,lu=210,cu=0,uu=1,du=2,hu=3,pu=4,mu=5,fu=6,gu=7,vu=0,yu=1,_u=2,bu=0,xu=1,wu=2,Su=3,Eu=4,Au=5,Tu=300,Iu=301,Mu=302,Cu=303,Nu=304,Ou=306,Ru=1e3,Lu=1001,Pu=1002,Du=1003,ku=1004,Bu=1004,Fu=1005,Uu=1005,zu=1006,Gu=1007,ju=1007,Hu=1008,Vu=1008,Wu=1009,qu=1010,$u=1011,Yu=1012,Ju=1013,Zu=1014,Xu=1015,Ku=1016,Qu=1017,ed=1018,td=1020,nd=1021,id=1022,rd=1023,od=1024,ad=1025,sd=1026,ld=1027,cd=1028,ud=1029,dd=1030,hd=1031,pd=1033,md=33776,fd=33777,gd=33778,vd=33779,yd=35840,_d=35841,bd=35842,xd=35843,wd=36196,Sd=37492,Ed=37496,Ad=37808,Td=37809,Id=37810,Md=37811,Cd=37812,Nd=37813,Od=37814,Rd=37815,Ld=37816,Pd=37817,Dd=37818,kd=37819,Bd=37820,Fd=37821,Ud=36492,zd=2200,Gd=2201,jd=2202,Hd=2300,Vd=2301,Wd=2302,qd=2400,$d=2401,Yd=2402,Jd=2500,Zd=2501,Xd=0,Kd=1,Qd=2,eh=3e3,th=3001,nh=3200,ih=3201,rh=0,oh=1,ah="",sh="srgb",lh="srgb-linear",ch=0,uh=7680,dh=7681,hh=7682,ph=7683,mh=34055,fh=34056,gh=5386,vh=512,yh=513,_h=514,bh=515,xh=516,wh=517,Sh=518,Eh=519,Ah=35044,Th=35048,Ih=35040,Mh=35045,Ch=35049,Nh=35041,Oh=35046,Rh=35050,Lh=35042,Ph="100",Dh="300 es",kh=1035;class Bh{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,i=n.length;t<i;t++)n[t].call(this,e);e.target=null}}}const Fh=["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 Uh=1234567;const zh=Math.PI/180,Gh=180/Math.PI;function jh(){const e=4294967295*Math.random()|0,t=4294967295*Math.random()|0,n=4294967295*Math.random()|0,i=4294967295*Math.random()|0;return(Fh[255&e]+Fh[e>>8&255]+Fh[e>>16&255]+Fh[e>>24&255]+"-"+Fh[255&t]+Fh[t>>8&255]+"-"+Fh[t>>16&15|64]+Fh[t>>24&255]+"-"+Fh[63&n|128]+Fh[n>>8&255]+"-"+Fh[n>>16&255]+Fh[n>>24&255]+Fh[255&i]+Fh[i>>8&255]+Fh[i>>16&255]+Fh[i>>24&255]).toLowerCase()}function Hh(e,t,n){return Math.max(t,Math.min(n,e))}function Vh(e,t){return(e%t+t)%t}function Wh(e,t,n){return(1-n)*e+n*t}function qh(e){return 0==(e&e-1)&&0!==e}function $h(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function Yh(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function Jh(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 Zh(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 Xh=Object.freeze({__proto__:null,DEG2RAD:zh,RAD2DEG:Gh,generateUUID:jh,clamp:Hh,euclideanModulo:Vh,mapLinear:function(e,t,n,i,r){return i+(e-t)*(r-i)/(n-t)},inverseLerp:function(e,t,n){return e!==t?(n-e)/(t-e):0},lerp:Wh,damp:function(e,t,n,i){return Wh(e,t,1-Math.exp(-n*i))},pingpong:function(e,t=1){return t-Math.abs(Vh(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&&(Uh=e);let t=Uh+=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*zh},radToDeg:function(e){return e*Gh},isPowerOfTwo:qh,ceilPowerOfTwo:$h,floorPowerOfTwo:Yh,setQuaternionFromProperEuler:function(e,t,n,i,r){const o=Math.cos,a=Math.sin,s=o(n/2),l=a(n/2),c=o((t+i)/2),u=a((t+i)/2),d=o((t-i)/2),h=a((t-i)/2),p=o((i-t)/2),m=a((i-t)/2);switch(r){case"XYX":e.set(s*u,l*d,l*h,s*c);break;case"YZY":e.set(l*h,s*u,l*d,s*c);break;case"ZXZ":e.set(l*d,l*h,s*u,s*c);break;case"XZX":e.set(s*u,l*m,l*p,s*c);break;case"YXY":e.set(l*p,s*u,l*m,s*c);break;case"ZYZ":e.set(l*m,l*p,s*u,s*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}},normalize:Zh,denormalize:Jh});class Kh{constructor(e=0,t=0){Kh.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),i=Math.sin(t),r=this.x-e.x,o=this.y-e.y;return this.x=r*n-o*i+e.x,this.y=r*i+o*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Qh{constructor(){Qh.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1]}set(e,t,n,i,r,o,a,s,l){const c=this.elements;return c[0]=e,c[1]=i,c[2]=a,c[3]=t,c[4]=r,c[5]=s,c[6]=n,c[7]=o,c[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,r=this.elements,o=n[0],a=n[3],s=n[6],l=n[1],c=n[4],u=n[7],d=n[2],h=n[5],p=n[8],m=i[0],f=i[3],g=i[6],v=i[1],y=i[4],_=i[7],b=i[2],x=i[5],w=i[8];return r[0]=o*m+a*v+s*b,r[3]=o*f+a*y+s*x,r[6]=o*g+a*_+s*w,r[1]=l*m+c*v+u*b,r[4]=l*f+c*y+u*x,r[7]=l*g+c*_+u*w,r[2]=d*m+h*v+p*b,r[5]=d*f+h*y+p*x,r[8]=d*g+h*_+p*w,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],o=e[4],a=e[5],s=e[6],l=e[7],c=e[8];return t*o*c-t*a*l-n*r*c+n*a*s+i*r*l-i*o*s}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],o=e[4],a=e[5],s=e[6],l=e[7],c=e[8],u=c*o-a*l,d=a*s-c*r,h=l*r-o*s,p=t*u+n*d+i*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]=(i*l-c*n)*m,e[2]=(a*n-i*o)*m,e[3]=d*m,e[4]=(c*t-i*s)*m,e[5]=(i*r-a*t)*m,e[6]=h*m,e[7]=(n*s-l*t)*m,e[8]=(o*t-n*r)*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,i,r,o,a){const s=Math.cos(r),l=Math.sin(r);return this.set(n*s,n*l,-n*(s*o+l*a)+o+e,-i*l,i*s,-i*(-l*o+s*a)+a+t,0,0,1),this}scale(e,t){const n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=t,n[4]*=t,n[7]*=t,this}rotate(e){const t=Math.cos(e),n=Math.sin(e),i=this.elements,r=i[0],o=i[3],a=i[6],s=i[1],l=i[4],c=i[7];return i[0]=t*r+n*s,i[3]=t*o+n*l,i[6]=t*a+n*c,i[1]=-n*r+t*s,i[4]=-n*o+t*l,i[7]=-n*a+t*c,this}translate(e,t){const n=this.elements;return n[0]+=e*n[2],n[3]+=e*n[5],n[6]+=e*n[8],n[1]+=t*n[2],n[4]+=t*n[5],n[7]+=t*n[8],this}equals(e){const t=this.elements,n=e.elements;for(let e=0;e<9;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return(new this.constructor).fromArray(this.elements)}}function ep(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}const tp={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:Uint8ClampedArray,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};function np(e,t){return new tp[e](t)}function ip(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function rp(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}function op(e){return e<.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}const ap={[sh]:{[lh]:rp},[lh]:{[sh]:op}},sp={legacyMode:!0,get workingColorSpace(){return lh},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(ap[t]&&void 0!==ap[t][n]){const i=ap[t][n];return e.r=i(e.r),e.g=i(e.g),e.b=i(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)}},lp={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},cp={r:0,g:0,b:0},up={h:0,s:0,l:0},dp={h:0,s:0,l:0};function hp(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 pp(e,t){return t.r=e.r,t.g=e.g,t.b=e.b,t}class mp{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=sh){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,sp.toWorkingColorSpace(this,t),this}setRGB(e,t,n,i=lh){return this.r=e,this.g=t,this.b=n,sp.toWorkingColorSpace(this,i),this}setHSL(e,t,n,i=lh){if(e=Vh(e,1),t=Hh(t,0,1),n=Hh(n,0,1),0===t)this.r=this.g=this.b=n;else{const i=n<=.5?n*(1+t):n+t-n*t,r=2*n-i;this.r=hp(r,i,e+1/3),this.g=hp(r,i,e),this.b=hp(r,i,e-1/3)}return sp.toWorkingColorSpace(this,i),this}setStyle(e,t=sh){function n(t){void 0!==t&&parseFloat(t)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(e)){let e;const r=i[1],o=i[2];switch(r){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,sp.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,sp.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 i=parseFloat(e[1])/360,r=parseFloat(e[2])/100,o=parseFloat(e[3])/100;return n(e[4]),this.setHSL(i,r,o,t)}}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const e=i[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,sp.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,sp.toWorkingColorSpace(this,t),this}return e&&e.length>0?this.setColorName(e,t):this}setColorName(e,t=sh){const n=lp[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=rp(e.r),this.g=rp(e.g),this.b=rp(e.b),this}copyLinearToSRGB(e){return this.r=op(e.r),this.g=op(e.g),this.b=op(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=sh){return sp.fromWorkingColorSpace(pp(this,cp),e),Hh(255*cp.r,0,255)<<16^Hh(255*cp.g,0,255)<<8^Hh(255*cp.b,0,255)<<0}getHexString(e=sh){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=lh){sp.fromWorkingColorSpace(pp(this,cp),t);const n=cp.r,i=cp.g,r=cp.b,o=Math.max(n,i,r),a=Math.min(n,i,r);let s,l;const c=(a+o)/2;if(a===o)s=0,l=0;else{const e=o-a;switch(l=c<=.5?e/(o+a):e/(2-o-a),o){case n:s=(i-r)/e+(i<r?6:0);break;case i:s=(r-n)/e+2;break;case r:s=(n-i)/e+4}s/=6}return e.h=s,e.s=l,e.l=c,e}getRGB(e,t=lh){return sp.fromWorkingColorSpace(pp(this,cp),t),e.r=cp.r,e.g=cp.g,e.b=cp.b,e}getStyle(e=sh){return sp.fromWorkingColorSpace(pp(this,cp),e),e!==sh?`color(${e} ${cp.r} ${cp.g} ${cp.b})`:`rgb(${255*cp.r|0},${255*cp.g|0},${255*cp.b|0})`}offsetHSL(e,t,n){return this.getHSL(up),up.h+=e,up.s+=t,up.l+=n,this.setHSL(up.h,up.s,up.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(up),e.getHSL(dp);const n=Wh(up.h,dp.h,t),i=Wh(up.s,dp.s,t),r=Wh(up.l,dp.l,t);return this.setHSL(n,i,r),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 fp;mp.NAMES=lp;class gp{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===fp&&(fp=ip("canvas")),fp.width=e.width,fp.height=e.height;const n=fp.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=fp}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=ip("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const i=n.getImageData(0,0,e.width,e.height),r=i.data;for(let e=0;e<r.length;e++)r[e]=255*rp(r[e]/255);return n.putImageData(i,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*rp(t[e]/255)):t[e]=rp(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 vp{constructor(e=null){this.isSource=!0,this.uuid=jh(),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:""},i=this.data;if(null!==i){let e;if(Array.isArray(i)){e=[];for(let t=0,n=i.length;t<n;t++)i[t].isDataTexture?e.push(yp(i[t].image)):e.push(yp(i[t]))}else e=yp(i);n.url=e}return t||(e.images[this.uuid]=n),n}}function yp(e){return"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap?gp.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 _p=0;class bp extends Bh{constructor(e=bp.DEFAULT_IMAGE,t=bp.DEFAULT_MAPPING,n=Lu,i=Lu,r=zu,o=Hu,a=rd,s=Wu,l=1,c=eh){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:_p++}),this.uuid=jh(),this.name="",this.source=new vp(e),this.mipmaps=[],this.mapping=t,this.wrapS=n,this.wrapT=i,this.magFilter=r,this.minFilter=o,this.anisotropy=l,this.format=a,this.internalFormat=null,this.type=s,this.offset=new Kh(0,0),this.repeat=new Kh(1,1),this.center=new Kh(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Qh,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!==Tu)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Ru:e.x=e.x-Math.floor(e.x);break;case Lu:e.x=e.x<0?0:1;break;case Pu: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 Ru:e.y=e.y-Math.floor(e.y);break;case Lu:e.y=e.y<0?0:1;break;case Pu: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)}}bp.DEFAULT_IMAGE=null,bp.DEFAULT_MAPPING=Tu;class xp{constructor(e=0,t=0,n=0,i=1){xp.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=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,i=this.z,r=this.w,o=e.elements;return this.x=o[0]*t+o[4]*n+o[8]*i+o[12]*r,this.y=o[1]*t+o[5]*n+o[9]*i+o[13]*r,this.z=o[2]*t+o[6]*n+o[10]*i+o[14]*r,this.w=o[3]*t+o[7]*n+o[11]*i+o[15]*r,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,i,r;const o=.01,a=.1,s=e.elements,l=s[0],c=s[4],u=s[8],d=s[1],h=s[5],p=s[9],m=s[2],f=s[6],g=s[10];if(Math.abs(c-d)<o&&Math.abs(u-m)<o&&Math.abs(p-f)<o){if(Math.abs(c+d)<a&&Math.abs(u+m)<a&&Math.abs(p+f)<a&&Math.abs(l+h+g-3)<a)return this.set(1,0,0,0),this;t=Math.PI;const e=(l+1)/2,s=(h+1)/2,v=(g+1)/2,y=(c+d)/4,_=(u+m)/4,b=(p+f)/4;return e>s&&e>v?e<o?(n=0,i=.707106781,r=.707106781):(n=Math.sqrt(e),i=y/n,r=_/n):s>v?s<o?(n=.707106781,i=0,r=.707106781):(i=Math.sqrt(s),n=y/i,r=b/i):v<o?(n=.707106781,i=.707106781,r=0):(r=Math.sqrt(v),n=_/r,i=b/r),this.set(n,i,r,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 wp extends Bh{constructor(e,t,n={}){super(),this.isWebGLRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new xp(0,0,e,t),this.scissorTest=!1,this.viewport=new xp(0,0,e,t);const i={width:e,height:t,depth:1};this.texture=new bp(i,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:zu,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 vp(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 Sp extends bp{constructor(e=null,t=1,n=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=Du,this.minFilter=Du,this.wrapR=Lu,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Ep extends wp{constructor(e,t,n){super(e,t),this.isWebGLArrayRenderTarget=!0,this.depth=n,this.texture=new Sp(null,e,t,n),this.texture.isRenderTargetTexture=!0}}class Ap extends bp{constructor(e=null,t=1,n=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=Du,this.minFilter=Du,this.wrapR=Lu,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Tp extends wp{constructor(e,t,n){super(e,t),this.isWebGL3DRenderTarget=!0,this.depth=n,this.texture=new Ap(null,e,t,n),this.texture.isRenderTargetTexture=!0}}class Ip extends wp{constructor(e,t,n,i={}){super(e,t,i),this.isWebGLMultipleRenderTargets=!0;const r=this.texture;this.texture=[];for(let e=0;e<n;e++)this.texture[e]=r.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 i=0,r=this.texture.length;i<r;i++)this.texture[i].image.width=e,this.texture[i].image.height=t,this.texture[i].image.depth=n;this.dispose()}return this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t),this}copy(e){this.dispose(),this.width=e.width,this.height=e.height,this.depth=e.depth,this.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 Mp{constructor(e=0,t=0,n=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=i}static slerpFlat(e,t,n,i,r,o,a){let s=n[i+0],l=n[i+1],c=n[i+2],u=n[i+3];const d=r[o+0],h=r[o+1],p=r[o+2],m=r[o+3];if(0===a)return e[t+0]=s,e[t+1]=l,e[t+2]=c,void(e[t+3]=u);if(1===a)return e[t+0]=d,e[t+1]=h,e[t+2]=p,void(e[t+3]=m);if(u!==m||s!==d||l!==h||c!==p){let e=1-a;const t=s*d+l*h+c*p+u*m,n=t>=0?1:-1,i=1-t*t;if(i>Number.EPSILON){const r=Math.sqrt(i),o=Math.atan2(r,t*n);e=Math.sin(e*o)/r,a=Math.sin(a*o)/r}const r=a*n;if(s=s*e+d*r,l=l*e+h*r,c=c*e+p*r,u=u*e+m*r,e===1-a){const e=1/Math.sqrt(s*s+l*l+c*c+u*u);s*=e,l*=e,c*=e,u*=e}}e[t]=s,e[t+1]=l,e[t+2]=c,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,i,r,o){const a=n[i],s=n[i+1],l=n[i+2],c=n[i+3],u=r[o],d=r[o+1],h=r[o+2],p=r[o+3];return e[t]=a*p+c*u+s*h-l*d,e[t+1]=s*p+c*d+l*u-a*h,e[t+2]=l*p+c*h+a*d-s*u,e[t+3]=c*p-a*u-s*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,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t){const n=e._x,i=e._y,r=e._z,o=e._order,a=Math.cos,s=Math.sin,l=a(n/2),c=a(i/2),u=a(r/2),d=s(n/2),h=s(i/2),p=s(r/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,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],i=t[4],r=t[8],o=t[1],a=t[5],s=t[9],l=t[2],c=t[6],u=t[10],d=n+a+u;if(d>0){const e=.5/Math.sqrt(d+1);this._w=.25/e,this._x=(c-s)*e,this._y=(r-l)*e,this._z=(o-i)*e}else if(n>a&&n>u){const e=2*Math.sqrt(1+n-a-u);this._w=(c-s)/e,this._x=.25*e,this._y=(i+o)/e,this._z=(r+l)/e}else if(a>u){const e=2*Math.sqrt(1+a-n-u);this._w=(r-l)/e,this._x=(i+o)/e,this._y=.25*e,this._z=(s+c)/e}else{const e=2*Math.sqrt(1+u-n-a);this._w=(o-i)/e,this._x=(r+l)/e,this._y=(s+c)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<Number.EPSILON?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Hh(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(0===n)return this;const i=Math.min(1,t/n);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return 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,i=e._y,r=e._z,o=e._w,a=t._x,s=t._y,l=t._z,c=t._w;return this._x=n*c+o*a+i*l-r*s,this._y=i*c+o*s+r*a-n*l,this._z=r*c+o*l+n*s-i*a,this._w=o*c-n*a-i*s-r*l,this._onChangeCallback(),this}slerp(e,t){if(0===t)return this;if(1===t)return this.copy(e);const n=this._x,i=this._y,r=this._z,o=this._w;let a=o*e._w+n*e._x+i*e._y+r*e._z;if(a<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),a>=1)return this._w=o,this._x=n,this._y=i,this._z=r,this;const s=1-a*a;if(s<=Number.EPSILON){const e=1-t;return this._w=e*o+t*this._w,this._x=e*n+t*this._x,this._y=e*i+t*this._y,this._z=e*r+t*this._z,this.normalize(),this._onChangeCallback(),this}const l=Math.sqrt(s),c=Math.atan2(l,a),u=Math.sin((1-t)*c)/l,d=Math.sin(t*c)/l;return this._w=o*u+this._w*d,this._x=n*u+this._x*d,this._y=i*u+this._y*d,this._z=r*u+this._z*d,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=Math.random(),t=Math.sqrt(1-e),n=Math.sqrt(e),i=2*Math.PI*Math.random(),r=2*Math.PI*Math.random();return this.set(t*Math.cos(i),n*Math.sin(r),n*Math.cos(r),t*Math.sin(i))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class Cp{constructor(e=0,t=0,n=0){Cp.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(Op.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Op.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*i,this.y=r[1]*t+r[4]*n+r[7]*i,this.z=r[2]*t+r[5]*n+r[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,r=e.elements,o=1/(r[3]*t+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*i+r[12])*o,this.y=(r[1]*t+r[5]*n+r[9]*i+r[13])*o,this.z=(r[2]*t+r[6]*n+r[10]*i+r[14])*o,this}applyQuaternion(e){const t=this.x,n=this.y,i=this.z,r=e.x,o=e.y,a=e.z,s=e.w,l=s*t+o*i-a*n,c=s*n+a*t-r*i,u=s*i+r*n-o*t,d=-r*t-o*n-a*i;return this.x=l*s+d*-r+c*-a-u*-o,this.y=c*s+d*-o+u*-r-l*-a,this.z=u*s+d*-a+l*-o-c*-r,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i,this.y=r[1]*t+r[5]*n+r[9]*i,this.z=r[2]*t+r[6]*n+r[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,i=e.y,r=e.z,o=t.x,a=t.y,s=t.z;return this.x=i*s-r*a,this.y=r*o-n*s,this.z=n*a-i*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 Np.copy(this).projectOnVector(e),this.sub(Np)}reflect(e){return this.sub(Np.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(Hh(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,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 Np=new Cp,Op=new Mp;class Rp{constructor(e=new Cp(1/0,1/0,1/0),t=new Cp(-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,i=1/0,r=-1/0,o=-1/0,a=-1/0;for(let s=0,l=e.length;s<l;s+=3){const l=e[s],c=e[s+1],u=e[s+2];l<t&&(t=l),c<n&&(n=c),u<i&&(i=u),l>r&&(r=l),c>o&&(o=c),u>a&&(a=u)}return this.min.set(t,n,i),this.max.set(r,o,a),this}setFromBufferAttribute(e){let t=1/0,n=1/0,i=1/0,r=-1/0,o=-1/0,a=-1/0;for(let s=0,l=e.count;s<l;s++){const l=e.getX(s),c=e.getY(s),u=e.getZ(s);l<t&&(t=l),c<n&&(n=c),u<i&&(i=u),l>r&&(r=l),c>o&&(o=c),u>a&&(a=u)}return this.min.set(t,n,i),this.max.set(r,o,a),this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=Pp.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,i=t.count;n<i;n++)Pp.fromBufferAttribute(t,n).applyMatrix4(e.matrixWorld),this.expandByPoint(Pp)}else null===n.boundingBox&&n.computeBoundingBox(),Dp.copy(n.boundingBox),Dp.applyMatrix4(e.matrixWorld),this.union(Dp);const i=e.children;for(let e=0,n=i.length;e<n;e++)this.expandByObject(i[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,Pp),Pp.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(jp),Hp.subVectors(this.max,jp),kp.subVectors(e.a,jp),Bp.subVectors(e.b,jp),Fp.subVectors(e.c,jp),Up.subVectors(Bp,kp),zp.subVectors(Fp,Bp),Gp.subVectors(kp,Fp);let t=[0,-Up.z,Up.y,0,-zp.z,zp.y,0,-Gp.z,Gp.y,Up.z,0,-Up.x,zp.z,0,-zp.x,Gp.z,0,-Gp.x,-Up.y,Up.x,0,-zp.y,zp.x,0,-Gp.y,Gp.x,0];return!!qp(t,kp,Bp,Fp,Hp)&&(t=[1,0,0,0,1,0,0,0,1],!!qp(t,kp,Bp,Fp,Hp)&&(Vp.crossVectors(Up,zp),t=[Vp.x,Vp.y,Vp.z],qp(t,kp,Bp,Fp,Hp)))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return Pp.copy(e).clamp(this.min,this.max).sub(e).length()}getBoundingSphere(e){return this.getCenter(e.center),e.radius=.5*this.getSize(Pp).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()||(Lp[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Lp[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Lp[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Lp[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Lp[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Lp[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Lp[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Lp[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Lp)),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 Lp=[new Cp,new Cp,new Cp,new Cp,new Cp,new Cp,new Cp,new Cp],Pp=new Cp,Dp=new Rp,kp=new Cp,Bp=new Cp,Fp=new Cp,Up=new Cp,zp=new Cp,Gp=new Cp,jp=new Cp,Hp=new Cp,Vp=new Cp,Wp=new Cp;function qp(e,t,n,i,r){for(let o=0,a=e.length-3;o<=a;o+=3){Wp.fromArray(e,o);const a=r.x*Math.abs(Wp.x)+r.y*Math.abs(Wp.y)+r.z*Math.abs(Wp.z),s=t.dot(Wp),l=n.dot(Wp),c=i.dot(Wp);if(Math.max(-Math.max(s,l,c),Math.min(s,l,c))>a)return!1}return!0}const $p=new Rp,Yp=new Cp,Jp=new Cp,Zp=new Cp;class Xp{constructor(e=new Cp,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):$p.setFromPoints(e).getCenter(n);let i=0;for(let t=0,r=e.length;t<r;t++)i=Math.max(i,n.distanceToSquared(e[t]));return this.radius=Math.sqrt(i),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){const n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){Zp.subVectors(e,this.center);const t=Zp.lengthSq();if(t>this.radius*this.radius){const e=Math.sqrt(t),n=.5*(e-this.radius);this.center.add(Zp.multiplyScalar(n/e)),this.radius+=n}return this}union(e){return!0===this.center.equals(e.center)?Jp.set(0,0,1).multiplyScalar(e.radius):Jp.subVectors(e.center,this.center).normalize().multiplyScalar(e.radius),this.expandByPoint(Yp.copy(e.center).add(Jp)),this.expandByPoint(Yp.copy(e.center).sub(Jp)),this}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return(new this.constructor).copy(this)}}const Kp=new Cp,Qp=new Cp,em=new Cp,tm=new Cp,nm=new Cp,im=new Cp,rm=new Cp;class om{constructor(e=new Cp,t=new Cp(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,Kp)),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=Kp.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Kp.copy(this.direction).multiplyScalar(t).add(this.origin),Kp.distanceToSquared(e))}distanceSqToSegment(e,t,n,i){Qp.copy(e).add(t).multiplyScalar(.5),em.copy(t).sub(e).normalize(),tm.copy(this.origin).sub(Qp);const r=.5*e.distanceTo(t),o=-this.direction.dot(em),a=tm.dot(this.direction),s=-tm.dot(em),l=tm.lengthSq(),c=Math.abs(1-o*o);let u,d,h,p;if(c>0)if(u=o*s-a,d=o*a-s,p=r*c,u>=0)if(d>=-p)if(d<=p){const e=1/c;u*=e,d*=e,h=u*(u+o*d+2*a)+d*(o*u+d+2*s)+l}else d=r,u=Math.max(0,-(o*d+a)),h=-u*u+d*(d+2*s)+l;else d=-r,u=Math.max(0,-(o*d+a)),h=-u*u+d*(d+2*s)+l;else d<=-p?(u=Math.max(0,-(-o*r+a)),d=u>0?-r:Math.min(Math.max(-r,-s),r),h=-u*u+d*(d+2*s)+l):d<=p?(u=0,d=Math.min(Math.max(-r,-s),r),h=d*(d+2*s)+l):(u=Math.max(0,-(o*r+a)),d=u>0?r:Math.min(Math.max(-r,-s),r),h=-u*u+d*(d+2*s)+l);else d=o>0?-r:r,u=Math.max(0,-(o*d+a)),h=-u*u+d*(d+2*s)+l;return n&&n.copy(this.direction).multiplyScalar(u).add(this.origin),i&&i.copy(em).multiplyScalar(d).add(Qp),h}intersectSphere(e,t){Kp.subVectors(e.center,this.origin);const n=Kp.dot(this.direction),i=Kp.dot(Kp)-n*n,r=e.radius*e.radius;if(i>r)return null;const o=Math.sqrt(r-i),a=n-o,s=n+o;return a<0&&s<0?null:a<0?this.at(s,t):this.at(a,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(0===t)return 0===e.distanceToPoint(this.origin)?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return null===n?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);if(0===t)return!0;return e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,i,r,o,a,s;const l=1/this.direction.x,c=1/this.direction.y,u=1/this.direction.z,d=this.origin;return l>=0?(n=(e.min.x-d.x)*l,i=(e.max.x-d.x)*l):(n=(e.max.x-d.x)*l,i=(e.min.x-d.x)*l),c>=0?(r=(e.min.y-d.y)*c,o=(e.max.y-d.y)*c):(r=(e.max.y-d.y)*c,o=(e.min.y-d.y)*c),n>o||r>i?null:((r>n||n!=n)&&(n=r),(o<i||i!=i)&&(i=o),u>=0?(a=(e.min.z-d.z)*u,s=(e.max.z-d.z)*u):(a=(e.max.z-d.z)*u,s=(e.min.z-d.z)*u),n>s||a>i?null:((a>n||n!=n)&&(n=a),(s<i||i!=i)&&(i=s),i<0?null:this.at(n>=0?n:i,t)))}intersectsBox(e){return null!==this.intersectBox(e,Kp)}intersectTriangle(e,t,n,i,r){nm.subVectors(t,e),im.subVectors(n,e),rm.crossVectors(nm,im);let o,a=this.direction.dot(rm);if(a>0){if(i)return null;o=1}else{if(!(a<0))return null;o=-1,a=-a}tm.subVectors(this.origin,e);const s=o*this.direction.dot(im.crossVectors(tm,im));if(s<0)return null;const l=o*this.direction.dot(nm.cross(tm));if(l<0)return null;if(s+l>a)return null;const c=-o*tm.dot(rm);return c<0?null:this.at(c/a,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return(new this.constructor).copy(this)}}class am{constructor(){am.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,i,r,o,a,s,l,c,u,d,h,p,m,f){const g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=i,g[1]=r,g[5]=o,g[9]=a,g[13]=s,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 am).fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,n=e.elements,i=1/sm.setFromMatrixColumn(e,0).length(),r=1/sm.setFromMatrixColumn(e,1).length(),o=1/sm.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=0,t[8]=n[8]*o,t[9]=n[9]*o,t[10]=n[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,i=e.y,r=e.z,o=Math.cos(n),a=Math.sin(n),s=Math.cos(i),l=Math.sin(i),c=Math.cos(r),u=Math.sin(r);if("XYZ"===e.order){const e=o*c,n=o*u,i=a*c,r=a*u;t[0]=s*c,t[4]=-s*u,t[8]=l,t[1]=n+i*l,t[5]=e-r*l,t[9]=-a*s,t[2]=r-e*l,t[6]=i+n*l,t[10]=o*s}else if("YXZ"===e.order){const e=s*c,n=s*u,i=l*c,r=l*u;t[0]=e+r*a,t[4]=i*a-n,t[8]=o*l,t[1]=o*u,t[5]=o*c,t[9]=-a,t[2]=n*a-i,t[6]=r+e*a,t[10]=o*s}else if("ZXY"===e.order){const e=s*c,n=s*u,i=l*c,r=l*u;t[0]=e-r*a,t[4]=-o*u,t[8]=i+n*a,t[1]=n+i*a,t[5]=o*c,t[9]=r-e*a,t[2]=-o*l,t[6]=a,t[10]=o*s}else if("ZYX"===e.order){const e=o*c,n=o*u,i=a*c,r=a*u;t[0]=s*c,t[4]=i*l-n,t[8]=e*l+r,t[1]=s*u,t[5]=r*l+e,t[9]=n*l-i,t[2]=-l,t[6]=a*s,t[10]=o*s}else if("YZX"===e.order){const e=o*s,n=o*l,i=a*s,r=a*l;t[0]=s*c,t[4]=r-e*u,t[8]=i*u+n,t[1]=u,t[5]=o*c,t[9]=-a*c,t[2]=-l*c,t[6]=n*u+i,t[10]=e-r*u}else if("XZY"===e.order){const e=o*s,n=o*l,i=a*s,r=a*l;t[0]=s*c,t[4]=-u,t[8]=l*c,t[1]=e*u+r,t[5]=o*c,t[9]=n*u-i,t[2]=i*u-n,t[6]=a*c,t[10]=r*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(cm,e,um)}lookAt(e,t,n){const i=this.elements;return pm.subVectors(e,t),0===pm.lengthSq()&&(pm.z=1),pm.normalize(),dm.crossVectors(n,pm),0===dm.lengthSq()&&(1===Math.abs(n.z)?pm.x+=1e-4:pm.z+=1e-4,pm.normalize(),dm.crossVectors(n,pm)),dm.normalize(),hm.crossVectors(pm,dm),i[0]=dm.x,i[4]=hm.x,i[8]=pm.x,i[1]=dm.y,i[5]=hm.y,i[9]=pm.y,i[2]=dm.z,i[6]=hm.z,i[10]=pm.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,r=this.elements,o=n[0],a=n[4],s=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],b=n[15],x=i[0],w=i[4],S=i[8],E=i[12],A=i[1],T=i[5],I=i[9],M=i[13],C=i[2],N=i[6],O=i[10],R=i[14],L=i[3],P=i[7],D=i[11],k=i[15];return r[0]=o*x+a*A+s*C+l*L,r[4]=o*w+a*T+s*N+l*P,r[8]=o*S+a*I+s*O+l*D,r[12]=o*E+a*M+s*R+l*k,r[1]=c*x+u*A+d*C+h*L,r[5]=c*w+u*T+d*N+h*P,r[9]=c*S+u*I+d*O+h*D,r[13]=c*E+u*M+d*R+h*k,r[2]=p*x+m*A+f*C+g*L,r[6]=p*w+m*T+f*N+g*P,r[10]=p*S+m*I+f*O+g*D,r[14]=p*E+m*M+f*R+g*k,r[3]=v*x+y*A+_*C+b*L,r[7]=v*w+y*T+_*N+b*P,r[11]=v*S+y*I+_*O+b*D,r[15]=v*E+y*M+_*R+b*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],i=e[8],r=e[12],o=e[1],a=e[5],s=e[9],l=e[13],c=e[2],u=e[6],d=e[10],h=e[14];return e[3]*(+r*s*u-i*l*u-r*a*d+n*l*d+i*a*h-n*s*h)+e[7]*(+t*s*h-t*l*d+r*o*d-i*o*h+i*l*c-r*s*c)+e[11]*(+t*l*u-t*a*h-r*o*u+n*o*h+r*a*c-n*l*c)+e[15]*(-i*a*c-t*s*u+t*a*d+i*o*u-n*o*d+n*s*c)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],o=e[4],a=e[5],s=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*s*h-a*f*h-u*s*g+a*d*g,y=p*d*l-c*f*l-p*s*h+o*f*h+c*s*g-o*d*g,_=c*m*l-p*u*l+p*a*h-o*m*h-c*a*g+o*u*g,b=p*u*s-c*m*s-p*a*d+o*m*d+c*a*f-o*u*f,x=t*v+n*y+i*_+r*b;if(0===x)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const w=1/x;return e[0]=v*w,e[1]=(m*d*r-u*f*r-m*i*h+n*f*h+u*i*g-n*d*g)*w,e[2]=(a*f*r-m*s*r+m*i*l-n*f*l-a*i*g+n*s*g)*w,e[3]=(u*s*r-a*d*r-u*i*l+n*d*l+a*i*h-n*s*h)*w,e[4]=y*w,e[5]=(c*f*r-p*d*r+p*i*h-t*f*h-c*i*g+t*d*g)*w,e[6]=(p*s*r-o*f*r-p*i*l+t*f*l+o*i*g-t*s*g)*w,e[7]=(o*d*r-c*s*r+c*i*l-t*d*l-o*i*h+t*s*h)*w,e[8]=_*w,e[9]=(p*u*r-c*m*r-p*n*h+t*m*h+c*n*g-t*u*g)*w,e[10]=(o*m*r-p*a*r+p*n*l-t*m*l-o*n*g+t*a*g)*w,e[11]=(c*a*r-o*u*r-c*n*l+t*u*l+o*n*h-t*a*h)*w,e[12]=b*w,e[13]=(c*m*i-p*u*i+p*n*d-t*m*d-c*n*f+t*u*f)*w,e[14]=(p*a*i-o*m*i-p*n*s+t*m*s+o*n*f-t*a*f)*w,e[15]=(o*u*i-c*a*i+c*n*s-t*u*s-o*n*d+t*a*d)*w,this}scale(e){const t=this.elements,n=e.x,i=e.y,r=e.z;return t[0]*=n,t[4]*=i,t[8]*=r,t[1]*=n,t[5]*=i,t[9]*=r,t[2]*=n,t[6]*=i,t[10]*=r,t[3]*=n,t[7]*=i,t[11]*=r,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){return this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),i=Math.sin(t),r=1-n,o=e.x,a=e.y,s=e.z,l=r*o,c=r*a;return this.set(l*o+n,l*a-i*s,l*s+i*a,0,l*a+i*s,c*a+n,c*s-i*o,0,l*s-i*a,c*s+i*o,r*s*s+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,r,o){return this.set(1,n,r,0,e,1,o,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){const i=this.elements,r=t._x,o=t._y,a=t._z,s=t._w,l=r+r,c=o+o,u=a+a,d=r*l,h=r*c,p=r*u,m=o*c,f=o*u,g=a*u,v=s*l,y=s*c,_=s*u,b=n.x,x=n.y,w=n.z;return i[0]=(1-(m+g))*b,i[1]=(h+_)*b,i[2]=(p-y)*b,i[3]=0,i[4]=(h-_)*x,i[5]=(1-(d+g))*x,i[6]=(f+v)*x,i[7]=0,i[8]=(p+y)*w,i[9]=(f-v)*w,i[10]=(1-(d+m))*w,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){const i=this.elements;let r=sm.set(i[0],i[1],i[2]).length();const o=sm.set(i[4],i[5],i[6]).length(),a=sm.set(i[8],i[9],i[10]).length();this.determinant()<0&&(r=-r),e.x=i[12],e.y=i[13],e.z=i[14],lm.copy(this);const s=1/r,l=1/o,c=1/a;return lm.elements[0]*=s,lm.elements[1]*=s,lm.elements[2]*=s,lm.elements[4]*=l,lm.elements[5]*=l,lm.elements[6]*=l,lm.elements[8]*=c,lm.elements[9]*=c,lm.elements[10]*=c,t.setFromRotationMatrix(lm),n.x=r,n.y=o,n.z=a,this}makePerspective(e,t,n,i,r,o){const a=this.elements,s=2*r/(t-e),l=2*r/(n-i),c=(t+e)/(t-e),u=(n+i)/(n-i),d=-(o+r)/(o-r),h=-2*o*r/(o-r);return a[0]=s,a[4]=0,a[8]=c,a[12]=0,a[1]=0,a[5]=l,a[9]=u,a[13]=0,a[2]=0,a[6]=0,a[10]=d,a[14]=h,a[3]=0,a[7]=0,a[11]=-1,a[15]=0,this}makeOrthographic(e,t,n,i,r,o){const a=this.elements,s=1/(t-e),l=1/(n-i),c=1/(o-r),u=(t+e)*s,d=(n+i)*l,h=(o+r)*c;return a[0]=2*s,a[4]=0,a[8]=0,a[12]=-u,a[1]=0,a[5]=2*l,a[9]=0,a[13]=-d,a[2]=0,a[6]=0,a[10]=-2*c,a[14]=-h,a[3]=0,a[7]=0,a[11]=0,a[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let e=0;e<16;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}const sm=new Cp,lm=new am,cm=new Cp(0,0,0),um=new Cp(1,1,1),dm=new Cp,hm=new Cp,pm=new Cp,mm=new am,fm=new Mp;class gm{constructor(e=0,t=0,n=0,i=gm.DefaultOrder){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const i=e.elements,r=i[0],o=i[4],a=i[8],s=i[1],l=i[5],c=i[9],u=i[2],d=i[6],h=i[10];switch(t){case"XYZ":this._y=Math.asin(Hh(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-c,h),this._z=Math.atan2(-o,r)):(this._x=Math.atan2(d,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Hh(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(a,h),this._z=Math.atan2(s,l)):(this._y=Math.atan2(-u,r),this._z=0);break;case"ZXY":this._x=Math.asin(Hh(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(s,r));break;case"ZYX":this._y=Math.asin(-Hh(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,h),this._z=Math.atan2(s,r)):(this._x=0,this._z=Math.atan2(-o,l));break;case"YZX":this._z=Math.asin(Hh(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-c,l),this._y=Math.atan2(-u,r)):(this._x=0,this._y=Math.atan2(a,h));break;case"XZY":this._z=Math.asin(-Hh(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(d,l),this._y=Math.atan2(a,r)):(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 mm.makeRotationFromQuaternion(e),this.setFromRotationMatrix(mm,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return fm.setFromEuler(this),this.setFromQuaternion(fm,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")}}gm.DefaultOrder="XYZ",gm.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"];class vm{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 ym=0;const _m=new Cp,bm=new Mp,xm=new am,wm=new Cp,Sm=new Cp,Em=new Cp,Am=new Mp,Tm=new Cp(1,0,0),Im=new Cp(0,1,0),Mm=new Cp(0,0,1),Cm={type:"added"},Nm={type:"removed"};class Om extends Bh{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:ym++}),this.uuid=jh(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Om.DefaultUp.clone();const e=new Cp,t=new gm,n=new Mp,i=new Cp(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:i},modelViewMatrix:{value:new am},normalMatrix:{value:new Qh}}),this.matrix=new am,this.matrixWorld=new am,this.matrixAutoUpdate=Om.DefaultMatrixAutoUpdate,this.matrixWorldNeedsUpdate=!1,this.matrixWorldAutoUpdate=Om.DefaultMatrixWorldAutoUpdate,this.layers=new vm,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 bm.setFromAxisAngle(e,t),this.quaternion.multiply(bm),this}rotateOnWorldAxis(e,t){return bm.setFromAxisAngle(e,t),this.quaternion.premultiply(bm),this}rotateX(e){return this.rotateOnAxis(Tm,e)}rotateY(e){return this.rotateOnAxis(Im,e)}rotateZ(e){return this.rotateOnAxis(Mm,e)}translateOnAxis(e,t){return _m.copy(e).applyQuaternion(this.quaternion),this.position.add(_m.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Tm,e)}translateY(e){return this.translateOnAxis(Im,e)}translateZ(e){return this.translateOnAxis(Mm,e)}localToWorld(e){return e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return e.applyMatrix4(xm.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?wm.copy(e):wm.set(e,t,n);const i=this.parent;this.updateWorldMatrix(!0,!1),Sm.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?xm.lookAt(Sm,wm,this.up):xm.lookAt(wm,Sm,this.up),this.quaternion.setFromRotationMatrix(xm),i&&(xm.extractRotation(i.matrixWorld),bm.setFromRotationMatrix(xm),this.quaternion.premultiply(bm.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(Cm)):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(Nm)),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(Nm)}return this.children.length=0,this}attach(e){return this.updateWorldMatrix(!0,!1),xm.copy(this.matrixWorld).invert(),null!==e.parent&&(e.parent.updateWorldMatrix(!0,!1),xm.multiply(e.parent.matrixWorld)),e.applyMatrix4(xm),this.add(e),e.updateWorldMatrix(!1,!0),this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,i=this.children.length;n<i;n++){const i=this.children[n].getObjectByProperty(e,t);if(void 0!==i)return i}}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Sm,e,Em),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Sm,Am,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverse(e)}traverseVisible(e){if(!1===this.visible)return;e(this);const t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverseVisible(e)}traverseAncestors(e){const t=this.parent;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,i=t.length;n<i;n++){const i=t[n];!0!==i.matrixWorldAutoUpdate&&!0!==e||i.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 i={};function r(t,n){return void 0===t[n.uuid]&&(t[n.uuid]=n.toJSON(e)),n.uuid}if(i.uuid=this.uuid,i.type=this.type,""!==this.name&&(i.name=this.name),!0===this.castShadow&&(i.castShadow=!0),!0===this.receiveShadow&&(i.receiveShadow=!0),!1===this.visible&&(i.visible=!1),!1===this.frustumCulled&&(i.frustumCulled=!1),0!==this.renderOrder&&(i.renderOrder=this.renderOrder),"{}"!==JSON.stringify(this.userData)&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),!1===this.matrixAutoUpdate&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(i.instanceColor=this.instanceColor.toJSON())),this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&!0!==this.environment.isRenderTargetTexture&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(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,i=n.length;t<i;t++){const i=n[t];r(e.shapes,i)}else r(e.shapes,n)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),void 0!==this.skeleton&&(r(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),void 0!==this.material)if(Array.isArray(this.material)){const t=[];for(let n=0,i=this.material.length;n<i;n++)t.push(r(e.materials,this.material[n]));i.material=t}else i.material=r(e.materials,this.material);if(this.children.length>0){i.children=[];for(let t=0;t<this.children.length;t++)i.children.push(this.children[t].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let t=0;t<this.animations.length;t++){const n=this.animations[t];i.animations.push(r(e.animations,n))}}if(t){const t=o(e.geometries),i=o(e.materials),r=o(e.textures),a=o(e.images),s=o(e.shapes),l=o(e.skeletons),c=o(e.animations),u=o(e.nodes);t.length>0&&(n.geometries=t),i.length>0&&(n.materials=i),r.length>0&&(n.textures=r),a.length>0&&(n.images=a),s.length>0&&(n.shapes=s),l.length>0&&(n.skeletons=l),c.length>0&&(n.animations=c),u.length>0&&(n.nodes=u)}return n.object=i,n;function o(e){const t=[];for(const n in e){const i=e[n];delete i.metadata,t.push(i)}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}}Om.DefaultUp=new Cp(0,1,0),Om.DefaultMatrixAutoUpdate=!0,Om.DefaultMatrixWorldAutoUpdate=!0;const Rm=new Cp,Lm=new Cp,Pm=new Cp,Dm=new Cp,km=new Cp,Bm=new Cp,Fm=new Cp,Um=new Cp,zm=new Cp,Gm=new Cp;class jm{constructor(e=new Cp,t=new Cp,n=new Cp){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,i){i.subVectors(n,t),Rm.subVectors(e,t),i.cross(Rm);const r=i.lengthSq();return r>0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(e,t,n,i,r){Rm.subVectors(i,t),Lm.subVectors(n,t),Pm.subVectors(e,t);const o=Rm.dot(Rm),a=Rm.dot(Lm),s=Rm.dot(Pm),l=Lm.dot(Lm),c=Lm.dot(Pm),u=o*l-a*a;if(0===u)return r.set(-2,-1,-1);const d=1/u,h=(l*s-a*c)*d,p=(o*c-a*s)*d;return r.set(1-h-p,p,h)}static containsPoint(e,t,n,i){return this.getBarycoord(e,t,n,i,Dm),Dm.x>=0&&Dm.y>=0&&Dm.x+Dm.y<=1}static getUV(e,t,n,i,r,o,a,s){return this.getBarycoord(e,t,n,i,Dm),s.set(0,0),s.addScaledVector(r,Dm.x),s.addScaledVector(o,Dm.y),s.addScaledVector(a,Dm.z),s}static isFrontFacing(e,t,n,i){return Rm.subVectors(n,t),Lm.subVectors(e,t),Rm.cross(Lm).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),this}clone(){return(new this.constructor).copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Rm.subVectors(this.c,this.b),Lm.subVectors(this.a,this.b),.5*Rm.cross(Lm).length()}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return jm.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return jm.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,n,i,r){return jm.getUV(e,this.a,this.b,this.c,t,n,i,r)}containsPoint(e){return jm.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return jm.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,i=this.b,r=this.c;let o,a;km.subVectors(i,n),Bm.subVectors(r,n),Um.subVectors(e,n);const s=km.dot(Um),l=Bm.dot(Um);if(s<=0&&l<=0)return t.copy(n);zm.subVectors(e,i);const c=km.dot(zm),u=Bm.dot(zm);if(c>=0&&u<=c)return t.copy(i);const d=s*u-c*l;if(d<=0&&s>=0&&c<=0)return o=s/(s-c),t.copy(n).addScaledVector(km,o);Gm.subVectors(e,r);const h=km.dot(Gm),p=Bm.dot(Gm);if(p>=0&&h<=p)return t.copy(r);const m=h*l-s*p;if(m<=0&&l>=0&&p<=0)return a=l/(l-p),t.copy(n).addScaledVector(Bm,a);const f=c*p-h*u;if(f<=0&&u-c>=0&&h-p>=0)return Fm.subVectors(r,i),a=(u-c)/(u-c+(h-p)),t.copy(i).addScaledVector(Fm,a);const g=1/(f+m+d);return o=m*g,a=d*g,t.copy(n).addScaledVector(km,o).addScaledVector(Bm,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}let Hm=0;class Vm extends Bh{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Hm++}),this.uuid=jh(),this.name="",this.type="Material",this.blending=jc,this.side=Fc,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.blendSrc=nu,this.blendDst=iu,this.blendEquation=$c,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=hu,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Eh,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=uh,this.stencilZFail=uh,this.stencilZPass=uh,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 i=this[t];void 0!==i?i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.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 i(e){const t=[];for(const n in e){const i=e[n];delete i.metadata,t.push(i)}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!==jc&&(n.blending=this.blending),this.side!==Fc&&(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=i(e.textures),r=i(e.images);t.length>0&&(n.textures=t),r.length>0&&(n.images=r)}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 i=0;i!==e;++i)n[i]=t[i].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 Wm extends Vm{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new mp(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=vu,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 qm=new Cp,$m=new Kh;class Ym{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=Ah,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 i=0,r=this.itemSize;i<r;i++)this.array[e+i]=t.array[n+i];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++)$m.fromBufferAttribute(this,t),$m.applyMatrix3(e),this.setXY(t,$m.x,$m.y);else if(3===this.itemSize)for(let t=0,n=this.count;t<n;t++)qm.fromBufferAttribute(this,t),qm.applyMatrix3(e),this.setXYZ(t,qm.x,qm.y,qm.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)qm.fromBufferAttribute(this,t),qm.applyMatrix4(e),this.setXYZ(t,qm.x,qm.y,qm.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)qm.fromBufferAttribute(this,t),qm.applyNormalMatrix(e),this.setXYZ(t,qm.x,qm.y,qm.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)qm.fromBufferAttribute(this,t),qm.transformDirection(e),this.setXYZ(t,qm.x,qm.y,qm.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=Jh(t,this.array)),t}setX(e,t){return this.normalized&&(t=Zh(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=Jh(t,this.array)),t}setY(e,t){return this.normalized&&(t=Zh(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=Jh(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Zh(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=Jh(t,this.array)),t}setW(e,t){return this.normalized&&(t=Zh(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=Zh(t,this.array),n=Zh(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,i){return e*=this.itemSize,this.normalized&&(t=Zh(t,this.array),n=Zh(n,this.array),i=Zh(i,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this}setXYZW(e,t,n,i,r){return e*=this.itemSize,this.normalized&&(t=Zh(t,this.array),n=Zh(n,this.array),i=Zh(i,this.array),r=Zh(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this.array[e+3]=r,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return""!==this.name&&(e.name=this.name),this.usage!==Ah&&(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 Jm extends Ym{constructor(e,t,n){super(new Int8Array(e),t,n)}}class Zm extends Ym{constructor(e,t,n){super(new Uint8Array(e),t,n)}}class Xm extends Ym{constructor(e,t,n){super(new Uint8ClampedArray(e),t,n)}}class Km extends Ym{constructor(e,t,n){super(new Int16Array(e),t,n)}}class Qm extends Ym{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class ef extends Ym{constructor(e,t,n){super(new Int32Array(e),t,n)}}class tf extends Ym{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class nf extends Ym{constructor(e,t,n){super(new Uint16Array(e),t,n),this.isFloat16BufferAttribute=!0}}class rf extends Ym{constructor(e,t,n){super(new Float32Array(e),t,n)}}class of extends Ym{constructor(e,t,n){super(new Float64Array(e),t,n)}}let af=0;const sf=new am,lf=new Om,cf=new Cp,uf=new Rp,df=new Rp,hf=new Cp;class pf extends Bh{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:af++}),this.uuid=jh(),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(ep(e)?tf:Qm)(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 Qh).getNormalMatrix(e);n.applyNormalMatrix(t),n.needsUpdate=!0}const i=this.attributes.tangent;return void 0!==i&&(i.transformDirection(e),i.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}applyQuaternion(e){return sf.makeRotationFromQuaternion(e),this.applyMatrix4(sf),this}rotateX(e){return sf.makeRotationX(e),this.applyMatrix4(sf),this}rotateY(e){return sf.makeRotationY(e),this.applyMatrix4(sf),this}rotateZ(e){return sf.makeRotationZ(e),this.applyMatrix4(sf),this}translate(e,t,n){return sf.makeTranslation(e,t,n),this.applyMatrix4(sf),this}scale(e,t,n){return sf.makeScale(e,t,n),this.applyMatrix4(sf),this}lookAt(e){return lf.lookAt(e),lf.updateMatrix(),this.applyMatrix4(lf.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(cf).negate(),this.translate(cf.x,cf.y,cf.z),this}setFromPoints(e){const t=[];for(let n=0,i=e.length;n<i;n++){const i=e[n];t.push(i.x,i.y,i.z||0)}return this.setAttribute("position",new rf(t,3)),this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new Rp);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 Cp(-1/0,-1/0,-1/0),new Cp(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];uf.setFromBufferAttribute(n),this.morphTargetsRelative?(hf.addVectors(this.boundingBox.min,uf.min),this.boundingBox.expandByPoint(hf),hf.addVectors(this.boundingBox.max,uf.max),this.boundingBox.expandByPoint(hf)):(this.boundingBox.expandByPoint(uf.min),this.boundingBox.expandByPoint(uf.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 Xp);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 Cp,1/0);if(e){const n=this.boundingSphere.center;if(uf.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){const n=t[e];df.setFromBufferAttribute(n),this.morphTargetsRelative?(hf.addVectors(uf.min,df.min),uf.expandByPoint(hf),hf.addVectors(uf.max,df.max),uf.expandByPoint(hf)):(uf.expandByPoint(df.min),uf.expandByPoint(df.max))}uf.getCenter(n);let i=0;for(let t=0,r=e.count;t<r;t++)hf.fromBufferAttribute(e,t),i=Math.max(i,n.distanceToSquared(hf));if(t)for(let r=0,o=t.length;r<o;r++){const o=t[r],a=this.morphTargetsRelative;for(let t=0,r=o.count;t<r;t++)hf.fromBufferAttribute(o,t),a&&(cf.fromBufferAttribute(e,t),hf.add(cf)),i=Math.max(i,n.distanceToSquared(hf))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(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,i=t.position.array,r=t.normal.array,o=t.uv.array,a=i.length/3;!1===this.hasAttribute("tangent")&&this.setAttribute("tangent",new Ym(new Float32Array(4*a),4));const s=this.getAttribute("tangent").array,l=[],c=[];for(let e=0;e<a;e++)l[e]=new Cp,c[e]=new Cp;const u=new Cp,d=new Cp,h=new Cp,p=new Kh,m=new Kh,f=new Kh,g=new Cp,v=new Cp;function y(e,t,n){u.fromArray(i,3*e),d.fromArray(i,3*t),h.fromArray(i,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 r=1/(m.x*f.y-f.x*m.y);isFinite(r)&&(g.copy(d).multiplyScalar(f.y).addScaledVector(h,-m.y).multiplyScalar(r),v.copy(h).multiplyScalar(m.x).addScaledVector(d,-f.x).multiplyScalar(r),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],i=t.start;for(let e=i,r=i+t.count;e<r;e+=3)y(n[e+0],n[e+1],n[e+2])}const b=new Cp,x=new Cp,w=new Cp,S=new Cp;function E(e){w.fromArray(r,3*e),S.copy(w);const t=l[e];b.copy(t),b.sub(w.multiplyScalar(w.dot(t))).normalize(),x.crossVectors(S,t);const n=x.dot(c[e])<0?-1:1;s[4*e]=b.x,s[4*e+1]=b.y,s[4*e+2]=b.z,s[4*e+3]=n}for(let e=0,t=_.length;e<t;++e){const t=_[e],i=t.start;for(let e=i,r=i+t.count;e<r;e+=3)E(n[e+0]),E(n[e+1]),E(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 Ym(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 i=new Cp,r=new Cp,o=new Cp,a=new Cp,s=new Cp,l=new Cp,c=new Cp,u=new Cp;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);i.fromBufferAttribute(t,h),r.fromBufferAttribute(t,p),o.fromBufferAttribute(t,m),c.subVectors(o,r),u.subVectors(i,r),c.cross(u),a.fromBufferAttribute(n,h),s.fromBufferAttribute(n,p),l.fromBufferAttribute(n,m),a.add(c),s.add(c),l.add(c),n.setXYZ(h,a.x,a.y,a.z),n.setXYZ(p,s.x,s.y,s.z),n.setXYZ(m,l.x,l.y,l.z)}else for(let e=0,a=t.count;e<a;e+=3)i.fromBufferAttribute(t,e+0),r.fromBufferAttribute(t,e+1),o.fromBufferAttribute(t,e+2),c.subVectors(o,r),u.subVectors(i,r),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++)hf.fromBufferAttribute(e,t),hf.normalize(),e.setXYZ(t,hf.x,hf.y,hf.z)}toNonIndexed(){function e(e,t){const n=e.array,i=e.itemSize,r=e.normalized,o=new n.constructor(t.length*i);let a=0,s=0;for(let r=0,l=t.length;r<l;r++){a=e.isInterleavedBufferAttribute?t[r]*e.data.stride+e.offset:t[r]*i;for(let e=0;e<i;e++)o[s++]=n[a++]}return new Ym(o,i,r)}if(null===this.index)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new pf,n=this.index.array,i=this.attributes;for(const r in i){const o=e(i[r],n);t.setAttribute(r,o)}const r=this.morphAttributes;for(const i in r){const o=[],a=r[i];for(let t=0,i=a.length;t<i;t++){const i=e(a[t],n);o.push(i)}t.morphAttributes[i]=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 i=n[t];e.data.attributes[t]=i.toJSON(e.data)}const i={};let r=!1;for(const t in this.morphAttributes){const n=this.morphAttributes[t],o=[];for(let t=0,i=n.length;t<i;t++){const i=n[t];o.push(i.toJSON(e.data))}o.length>0&&(i[t]=o,r=!0)}r&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));const a=this.boundingSphere;return null!==a&&(e.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),e}clone(){return(new this.constructor).copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;null!==n&&this.setIndex(n.clone(t));const i=e.attributes;for(const e in i){const n=i[e];this.setAttribute(e,n.clone(t))}const r=e.morphAttributes;for(const e in r){const n=[],i=r[e];for(let e=0,r=i.length;e<r;e++)n.push(i[e].clone(t));this.morphAttributes[e]=n}this.morphTargetsRelative=e.morphTargetsRelative;const o=e.groups;for(let e=0,t=o.length;e<t;e++){const t=o[e];this.addGroup(t.start,t.count,t.materialIndex)}const a=e.boundingBox;null!==a&&(this.boundingBox=a.clone());const s=e.boundingSphere;return null!==s&&(this.boundingSphere=s.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,void 0!==e.parameters&&(this.parameters=Object.assign({},e.parameters)),this}dispose(){this.dispatchEvent({type:"dispose"})}}const mf=new am,ff=new om,gf=new Xp,vf=new Cp,yf=new Cp,_f=new Cp,bf=new Cp,xf=new Cp,wf=new Cp,Sf=new Cp,Ef=new Cp,Af=new Cp,Tf=new Kh,If=new Kh,Mf=new Kh,Cf=new Cp,Nf=new Cp;class Of extends Om{constructor(e=new pf,t=new Wm){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,i=this.material,r=this.matrixWorld;if(void 0===i)return;if(null===n.boundingSphere&&n.computeBoundingSphere(),gf.copy(n.boundingSphere),gf.applyMatrix4(r),!1===e.ray.intersectsSphere(gf))return;if(mf.copy(r).invert(),ff.copy(e.ray).applyMatrix4(mf),null!==n.boundingBox&&!1===ff.intersectsBox(n.boundingBox))return;let o;const a=n.index,s=n.attributes.position,l=n.morphAttributes.position,c=n.morphTargetsRelative,u=n.attributes.uv,d=n.attributes.uv2,h=n.groups,p=n.drawRange;if(null!==a)if(Array.isArray(i))for(let n=0,r=h.length;n<r;n++){const r=h[n],m=i[r.materialIndex];for(let n=Math.max(r.start,p.start),i=Math.min(a.count,Math.min(r.start+r.count,p.start+p.count));n<i;n+=3){const i=a.getX(n),h=a.getX(n+1),p=a.getX(n+2);o=Rf(this,m,e,ff,s,l,c,u,d,i,h,p),o&&(o.faceIndex=Math.floor(n/3),o.face.materialIndex=r.materialIndex,t.push(o))}}else{for(let n=Math.max(0,p.start),r=Math.min(a.count,p.start+p.count);n<r;n+=3){const r=a.getX(n),h=a.getX(n+1),p=a.getX(n+2);o=Rf(this,i,e,ff,s,l,c,u,d,r,h,p),o&&(o.faceIndex=Math.floor(n/3),t.push(o))}}else if(void 0!==s)if(Array.isArray(i))for(let n=0,r=h.length;n<r;n++){const r=h[n],a=i[r.materialIndex];for(let n=Math.max(r.start,p.start),i=Math.min(s.count,Math.min(r.start+r.count,p.start+p.count));n<i;n+=3){o=Rf(this,a,e,ff,s,l,c,u,d,n,n+1,n+2),o&&(o.faceIndex=Math.floor(n/3),o.face.materialIndex=r.materialIndex,t.push(o))}}else{for(let n=Math.max(0,p.start),r=Math.min(s.count,p.start+p.count);n<r;n+=3){o=Rf(this,i,e,ff,s,l,c,u,d,n,n+1,n+2),o&&(o.faceIndex=Math.floor(n/3),t.push(o))}}}}function Rf(e,t,n,i,r,o,a,s,l,c,u,d){vf.fromBufferAttribute(r,c),yf.fromBufferAttribute(r,u),_f.fromBufferAttribute(r,d);const h=e.morphTargetInfluences;if(o&&h){Sf.set(0,0,0),Ef.set(0,0,0),Af.set(0,0,0);for(let e=0,t=o.length;e<t;e++){const t=h[e],n=o[e];0!==t&&(bf.fromBufferAttribute(n,c),xf.fromBufferAttribute(n,u),wf.fromBufferAttribute(n,d),a?(Sf.addScaledVector(bf,t),Ef.addScaledVector(xf,t),Af.addScaledVector(wf,t)):(Sf.addScaledVector(bf.sub(vf),t),Ef.addScaledVector(xf.sub(yf),t),Af.addScaledVector(wf.sub(_f),t)))}vf.add(Sf),yf.add(Ef),_f.add(Af)}e.isSkinnedMesh&&(e.boneTransform(c,vf),e.boneTransform(u,yf),e.boneTransform(d,_f));const p=function(e,t,n,i,r,o,a,s){let l;if(l=t.side===Uc?i.intersectTriangle(a,o,r,!0,s):i.intersectTriangle(r,o,a,t.side!==zc,s),null===l)return null;Nf.copy(s),Nf.applyMatrix4(e.matrixWorld);const c=n.ray.origin.distanceTo(Nf);return c<n.near||c>n.far?null:{distance:c,point:Nf.clone(),object:e}}(e,t,n,i,vf,yf,_f,Cf);if(p){s&&(Tf.fromBufferAttribute(s,c),If.fromBufferAttribute(s,u),Mf.fromBufferAttribute(s,d),p.uv=jm.getUV(Cf,vf,yf,_f,Tf,If,Mf,new Kh)),l&&(Tf.fromBufferAttribute(l,c),If.fromBufferAttribute(l,u),Mf.fromBufferAttribute(l,d),p.uv2=jm.getUV(Cf,vf,yf,_f,Tf,If,Mf,new Kh));const e={a:c,b:u,c:d,normal:new Cp,materialIndex:0};jm.getNormal(vf,yf,_f,e.normal),p.face=e}return p}class Lf extends pf{constructor(e=1,t=1,n=1,i=1,r=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:r,depthSegments:o};const a=this;i=Math.floor(i),r=Math.floor(r),o=Math.floor(o);const s=[],l=[],c=[],u=[];let d=0,h=0;function p(e,t,n,i,r,o,p,m,f,g,v){const y=o/f,_=p/g,b=o/2,x=p/2,w=m/2,S=f+1,E=g+1;let A=0,T=0;const I=new Cp;for(let o=0;o<E;o++){const a=o*_-x;for(let s=0;s<S;s++){const d=s*y-b;I[e]=d*i,I[t]=a*r,I[n]=w,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(s/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+S*e,i=d+t+S*(e+1),r=d+(t+1)+S*(e+1),o=d+(t+1)+S*e;s.push(n,i,o),s.push(i,r,o),T+=6}a.addGroup(h,T,v),h+=T,d+=A}p("z","y","x",-1,-1,n,t,e,o,r,0),p("z","y","x",1,-1,n,t,-e,o,r,1),p("x","z","y",1,1,e,n,t,i,o,2),p("x","z","y",1,-1,e,n,-t,i,o,3),p("x","y","z",1,-1,e,t,n,i,r,4),p("x","y","z",-1,-1,e,t,-n,i,r,5),this.setIndex(s),this.setAttribute("position",new rf(l,3)),this.setAttribute("normal",new rf(c,3)),this.setAttribute("uv",new rf(u,2))}static fromJSON(e){return new Lf(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function Pf(e){const t={};for(const n in e){t[n]={};for(const i in e[n]){const r=e[n][i];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?t[n][i]=r.clone():Array.isArray(r)?t[n][i]=r.slice():t[n][i]=r}}return t}function Df(e){const t={};for(let n=0;n<e.length;n++){const i=Pf(e[n]);for(const e in i)t[e]=i[e]}return t}const kf={clone:Pf,merge:Df};class Bf extends Vm{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=Pf(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 i=this.uniforms[n].value;i&&i.isTexture?t.uniforms[n]={type:"t",value:i.toJSON(e).uuid}:i&&i.isColor?t.uniforms[n]={type:"c",value:i.getHex()}:i&&i.isVector2?t.uniforms[n]={type:"v2",value:i.toArray()}:i&&i.isVector3?t.uniforms[n]={type:"v3",value:i.toArray()}:i&&i.isVector4?t.uniforms[n]={type:"v4",value:i.toArray()}:i&&i.isMatrix3?t.uniforms[n]={type:"m3",value:i.toArray()}:i&&i.isMatrix4?t.uniforms[n]={type:"m4",value:i.toArray()}:t.uniforms[n]={value:i}}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 Ff extends Om{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new am,this.projectionMatrix=new am,this.projectionMatrixInverse=new am}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 Uf extends Ff{constructor(e=50,t=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=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*Gh*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(.5*zh*this.fov);return.5*this.getFilmHeight()/e}getEffectiveFOV(){return 2*Gh*Math.atan(Math.tan(.5*zh*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,t,n,i,r,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=i,this.view.width=r,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*zh*this.fov)/this.zoom,n=2*t,i=this.aspect*n,r=-.5*i;const o=this.view;if(null!==this.view&&this.view.enabled){const e=o.fullWidth,a=o.fullHeight;r+=o.offsetX*i/e,t-=o.offsetY*n/a,i*=o.width/e,n*=o.height/a}const a=this.filmOffset;0!==a&&(r+=e*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+i,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 zf=90;class Gf extends Om{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n;const i=new Uf(zf,1,e,t);i.layers=this.layers,i.up.set(0,-1,0),i.lookAt(new Cp(1,0,0)),this.add(i);const r=new Uf(zf,1,e,t);r.layers=this.layers,r.up.set(0,-1,0),r.lookAt(new Cp(-1,0,0)),this.add(r);const o=new Uf(zf,1,e,t);o.layers=this.layers,o.up.set(0,0,1),o.lookAt(new Cp(0,1,0)),this.add(o);const a=new Uf(zf,1,e,t);a.layers=this.layers,a.up.set(0,0,-1),a.lookAt(new Cp(0,-1,0)),this.add(a);const s=new Uf(zf,1,e,t);s.layers=this.layers,s.up.set(0,-1,0),s.lookAt(new Cp(0,0,1)),this.add(s);const l=new Uf(zf,1,e,t);l.layers=this.layers,l.up.set(0,-1,0),l.lookAt(new Cp(0,0,-1)),this.add(l)}update(e,t){null===this.parent&&this.updateMatrixWorld();const n=this.renderTarget,[i,r,o,a,s,l]=this.children,c=e.getRenderTarget(),u=e.toneMapping,d=e.xr.enabled;e.toneMapping=bu,e.xr.enabled=!1;const h=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0),e.render(t,i),e.setRenderTarget(n,1),e.render(t,r),e.setRenderTarget(n,2),e.render(t,o),e.setRenderTarget(n,3),e.render(t,a),e.setRenderTarget(n,4),e.render(t,s),n.texture.generateMipmaps=h,e.setRenderTarget(n,5),e.render(t,l),e.setRenderTarget(c),e.toneMapping=u,e.xr.enabled=d,n.texture.needsPMREMUpdate=!0}}class jf extends bp{constructor(e,t,n,i,r,o,a,s,l,c){super(e=void 0!==e?e:[],t=void 0!==t?t:Iu,n,i,r,o,a,s,l,c),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class Hf extends wp{constructor(e,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},i=[n,n,n,n,n,n];this.texture=new jf(i,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:zu}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"},i=new Lf(5,5,5),r=new Bf({name:"CubemapFromEquirect",uniforms:Pf(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Uc,blending:Gc});r.uniforms.tEquirect.value=t;const o=new Of(i,r),a=t.minFilter;t.minFilter===Hu&&(t.minFilter=zu);return new Gf(1,10,this).update(e,o),t.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(e,t,n,i){const r=e.getRenderTarget();for(let r=0;r<6;r++)e.setRenderTarget(this,r),e.clear(t,n,i);e.setRenderTarget(r)}}const Vf=new Cp,Wf=new Cp,qf=new Qh;class $f{constructor(e=new Cp(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,i){return this.normal.set(e,t,n),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const i=Vf.subVectors(n,t).cross(Wf.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(this.normal).multiplyScalar(-this.distanceToPoint(e)).add(e)}intersectLine(e,t){const n=e.delta(Vf),i=this.normal.dot(n);if(0===i)return 0===this.distanceToPoint(e.start)?t.copy(e.start):null;const r=-(e.start.dot(this.normal)+this.constant)/i;return r<0||r>1?null:t.copy(n).multiplyScalar(r).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||qf.getNormalMatrix(e),i=this.coplanarPoint(Vf).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return(new this.constructor).copy(this)}}const Yf=new Xp,Jf=new Cp;class Zf{constructor(e=new $f,t=new $f,n=new $f,i=new $f,r=new $f,o=new $f){this.planes=[e,t,n,i,r,o]}set(e,t,n,i,r,o){const a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(n),a[3].copy(i),a[4].copy(r),a[5].copy(o),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e){const t=this.planes,n=e.elements,i=n[0],r=n[1],o=n[2],a=n[3],s=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(a-i,u-s,m-d,y-f).normalize(),t[1].setComponents(a+i,u+s,m+d,y+f).normalize(),t[2].setComponents(a+r,u+l,m+h,y+g).normalize(),t[3].setComponents(a-r,u-l,m-h,y-g).normalize(),t[4].setComponents(a-o,u-c,m-p,y-v).normalize(),t[5].setComponents(a+o,u+c,m+p,y+v).normalize(),this}intersectsObject(e){const t=e.geometry;return null===t.boundingSphere&&t.computeBoundingSphere(),Yf.copy(t.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(Yf)}intersectsSprite(e){return Yf.center.set(0,0,0),Yf.radius=.7071067811865476,Yf.applyMatrix4(e.matrixWorld),this.intersectsSphere(Yf)}intersectsSphere(e){const t=this.planes,n=e.center,i=-e.radius;for(let e=0;e<6;e++){if(t[e].distanceToPoint(n)<i)return!1}return!0}intersectsBox(e){const t=this.planes;for(let n=0;n<6;n++){const i=t[n];if(Jf.x=i.normal.x>0?e.max.x:e.min.x,Jf.y=i.normal.y>0?e.max.y:e.min.y,Jf.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(Jf)<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 Xf(){let e=null,t=!1,n=null,i=null;function r(t,o){n(t,o),i=e.requestAnimationFrame(r)}return{start:function(){!0!==t&&null!==n&&(i=e.requestAnimationFrame(r),t=!0)},stop:function(){e.cancelAnimationFrame(i),t=!1},setAnimationLoop:function(e){n=e},setContext:function(t){e=t}}}function Kf(e,t){const n=t.isWebGL2,i=new WeakMap;return{get:function(e){return e.isInterleavedBufferAttribute&&(e=e.data),i.get(e)},remove:function(t){t.isInterleavedBufferAttribute&&(t=t.data);const n=i.get(t);n&&(e.deleteBuffer(n.buffer),i.delete(t))},update:function(t,r){if(t.isGLBufferAttribute){const e=i.get(t);return void((!e||e.version<t.version)&&i.set(t,{buffer:t.buffer,type:t.type,bytesPerElement:t.elementSize,version:t.version}))}t.isInterleavedBufferAttribute&&(t=t.data);const o=i.get(t);void 0===o?i.set(t,function(t,i){const r=t.array,o=t.usage,a=e.createBuffer();let s;if(e.bindBuffer(i,a),e.bufferData(i,r,o),t.onUploadCallback(),r instanceof Float32Array)s=5126;else if(r instanceof Uint16Array)if(t.isFloat16BufferAttribute){if(!n)throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");s=5131}else s=5123;else if(r instanceof Int16Array)s=5122;else if(r instanceof Uint32Array)s=5125;else if(r instanceof Int32Array)s=5124;else if(r instanceof Int8Array)s=5120;else if(r instanceof Uint8Array)s=5121;else{if(!(r instanceof Uint8ClampedArray))throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+r);s=5121}return{buffer:a,type:s,bytesPerElement:r.BYTES_PER_ELEMENT,version:t.version}}(t,r)):o.version<t.version&&(!function(t,i,r){const o=i.array,a=i.updateRange;e.bindBuffer(r,t),-1===a.count?e.bufferSubData(r,0,o):(n?e.bufferSubData(r,a.offset*o.BYTES_PER_ELEMENT,o,a.offset,a.count):e.bufferSubData(r,a.offset*o.BYTES_PER_ELEMENT,o.subarray(a.offset,a.offset+a.count)),a.count=-1)}(o.buffer,t,r),o.version=t.version)}}}class Qf extends pf{constructor(e=1,t=1,n=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:i};const r=e/2,o=t/2,a=Math.floor(n),s=Math.floor(i),l=a+1,c=s+1,u=e/a,d=t/s,h=[],p=[],m=[],f=[];for(let e=0;e<c;e++){const t=e*d-o;for(let n=0;n<l;n++){const i=n*u-r;p.push(i,-t,0),m.push(0,0,1),f.push(n/a),f.push(1-e/s)}}for(let e=0;e<s;e++)for(let t=0;t<a;t++){const n=t+l*e,i=t+l*(e+1),r=t+1+l*(e+1),o=t+1+l*e;h.push(n,i,o),h.push(i,r,o)}this.setIndex(h),this.setAttribute("position",new rf(p,3)),this.setAttribute("normal",new rf(m,3)),this.setAttribute("uv",new rf(f,2))}static fromJSON(e){return new Qf(e.width,e.height,e.widthSegments,e.heightSegments)}}const eg={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}"},tg={common:{diffuse:{value:new mp(16777215)},opacity:{value:1},map:{value:null},uvTransform:{value:new Qh},uv2Transform:{value:new Qh},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 Kh(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 mp(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 mp(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new Qh}},sprite:{diffuse:{value:new mp(16777215)},opacity:{value:1},center:{value:new Kh(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new Qh}}},ng={basic:{uniforms:Df([tg.common,tg.specularmap,tg.envmap,tg.aomap,tg.lightmap,tg.fog]),vertexShader:eg.meshbasic_vert,fragmentShader:eg.meshbasic_frag},lambert:{uniforms:Df([tg.common,tg.specularmap,tg.envmap,tg.aomap,tg.lightmap,tg.emissivemap,tg.bumpmap,tg.normalmap,tg.displacementmap,tg.fog,tg.lights,{emissive:{value:new mp(0)}}]),vertexShader:eg.meshlambert_vert,fragmentShader:eg.meshlambert_frag},phong:{uniforms:Df([tg.common,tg.specularmap,tg.envmap,tg.aomap,tg.lightmap,tg.emissivemap,tg.bumpmap,tg.normalmap,tg.displacementmap,tg.fog,tg.lights,{emissive:{value:new mp(0)},specular:{value:new mp(1118481)},shininess:{value:30}}]),vertexShader:eg.meshphong_vert,fragmentShader:eg.meshphong_frag},standard:{uniforms:Df([tg.common,tg.envmap,tg.aomap,tg.lightmap,tg.emissivemap,tg.bumpmap,tg.normalmap,tg.displacementmap,tg.roughnessmap,tg.metalnessmap,tg.fog,tg.lights,{emissive:{value:new mp(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:eg.meshphysical_vert,fragmentShader:eg.meshphysical_frag},toon:{uniforms:Df([tg.common,tg.aomap,tg.lightmap,tg.emissivemap,tg.bumpmap,tg.normalmap,tg.displacementmap,tg.gradientmap,tg.fog,tg.lights,{emissive:{value:new mp(0)}}]),vertexShader:eg.meshtoon_vert,fragmentShader:eg.meshtoon_frag},matcap:{uniforms:Df([tg.common,tg.bumpmap,tg.normalmap,tg.displacementmap,tg.fog,{matcap:{value:null}}]),vertexShader:eg.meshmatcap_vert,fragmentShader:eg.meshmatcap_frag},points:{uniforms:Df([tg.points,tg.fog]),vertexShader:eg.points_vert,fragmentShader:eg.points_frag},dashed:{uniforms:Df([tg.common,tg.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:eg.linedashed_vert,fragmentShader:eg.linedashed_frag},depth:{uniforms:Df([tg.common,tg.displacementmap]),vertexShader:eg.depth_vert,fragmentShader:eg.depth_frag},normal:{uniforms:Df([tg.common,tg.bumpmap,tg.normalmap,tg.displacementmap,{opacity:{value:1}}]),vertexShader:eg.meshnormal_vert,fragmentShader:eg.meshnormal_frag},sprite:{uniforms:Df([tg.sprite,tg.fog]),vertexShader:eg.sprite_vert,fragmentShader:eg.sprite_frag},background:{uniforms:{uvTransform:{value:new Qh},t2D:{value:null}},vertexShader:eg.background_vert,fragmentShader:eg.background_frag},cube:{uniforms:Df([tg.envmap,{opacity:{value:1}}]),vertexShader:eg.cube_vert,fragmentShader:eg.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:eg.equirect_vert,fragmentShader:eg.equirect_frag},distanceRGBA:{uniforms:Df([tg.common,tg.displacementmap,{referencePosition:{value:new Cp},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:eg.distanceRGBA_vert,fragmentShader:eg.distanceRGBA_frag},shadow:{uniforms:Df([tg.lights,tg.fog,{color:{value:new mp(0)},opacity:{value:1}}]),vertexShader:eg.shadow_vert,fragmentShader:eg.shadow_frag}};function ig(e,t,n,i,r,o){const a=new mp(0);let s,l,c=!0===r?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 a},setClearColor:function(e,t=1){a.set(e),c=t,p(a,c)},getClearAlpha:function(){return c},setClearAlpha:function(e){c=e,p(a,c)},render:function(n,r){let o=!1,m=!0===r.isScene?r.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(a,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===Ou)?(void 0===l&&(l=new Of(new Lf(1,1,1),new Bf({name:"BackgroundCubeMaterial",uniforms:Pf(ng.cube.uniforms),vertexShader:ng.cube.vertexShader,fragmentShader:ng.cube.fragmentShader,side:Uc,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}}),i.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===s&&(s=new Of(new Qf(2,2),new Bf({name:"BackgroundMaterial",uniforms:Pf(ng.background.uniforms),vertexShader:ng.background.vertexShader,fragmentShader:ng.background.fragmentShader,side:Fc,depthTest:!1,depthWrite:!1,fog:!1})),s.geometry.deleteAttribute("normal"),Object.defineProperty(s.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(s)),s.material.uniforms.t2D.value=m,!0===m.matrixAutoUpdate&&m.updateMatrix(),s.material.uniforms.uvTransform.value.copy(m.matrix),u===m&&d===m.version&&h===e.toneMapping||(s.material.needsUpdate=!0,u=m,d=m.version,h=e.toneMapping),s.layers.enableAll(),n.unshift(s,s.geometry,s.material,0,0,null))}}}function rg(e,t,n,i){const r=e.getParameter(34921),o=i.isWebGL2?null:t.get("OES_vertex_array_object"),a=i.isWebGL2||null!==o,s={},l=p(null);let c=l,u=!1;function d(t){return i.isWebGL2?e.bindVertexArray(t):o.bindVertexArrayOES(t)}function h(t){return i.isWebGL2?e.deleteVertexArray(t):o.deleteVertexArrayOES(t)}function p(e){const t=[],n=[],i=[];for(let e=0;e<r;e++)t[e]=0,n[e]=0,i[e]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:t,enabledAttributes:n,attributeDivisors:i,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,r){const o=c.newAttributes,a=c.enabledAttributes,s=c.attributeDivisors;if(o[n]=1,0===a[n]&&(e.enableVertexAttribArray(n),a[n]=1),s[n]!==r){(i.isWebGL2?e:t.get("ANGLE_instanced_arrays"))[i.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](n,r),s[n]=r}}function v(){const t=c.newAttributes,n=c.enabledAttributes;for(let i=0,r=n.length;i<r;i++)n[i]!==t[i]&&(e.disableVertexAttribArray(i),n[i]=0)}function y(t,n,r,o,a,s){!0!==i.isWebGL2||5124!==r&&5125!==r?e.vertexAttribPointer(t,n,r,o,a,s):e.vertexAttribIPointer(t,n,r,a,s)}function _(){b(),u=!0,c!==l&&(c=l,d(c.object))}function b(){l.geometry=null,l.program=null,l.wireframe=!1}return{setup:function(r,l,h,_,b){let x=!1;if(a){const t=function(t,n,r){const a=!0===r.wireframe;let l=s[t.id];void 0===l&&(l={},s[t.id]=l);let c=l[n.id];void 0===c&&(c={},l[n.id]=c);let u=c[a];void 0===u&&(u=p(i.isWebGL2?e.createVertexArray():o.createVertexArrayOES()),c[a]=u);return u}(_,h,l);c!==t&&(c=t,d(c.object)),x=function(e,t,n,i){const r=c.attributes,o=t.attributes;let a=0;const s=n.getAttributes();for(const t in s){if(s[t].location>=0){const n=r[t];let i=o[t];if(void 0===i&&("instanceMatrix"===t&&e.instanceMatrix&&(i=e.instanceMatrix),"instanceColor"===t&&e.instanceColor&&(i=e.instanceColor)),void 0===n)return!0;if(n.attribute!==i)return!0;if(i&&n.data!==i.data)return!0;a++}}return c.attributesNum!==a||c.index!==i}(r,_,h,b),x&&function(e,t,n,i){const r={},o=t.attributes;let a=0;const s=n.getAttributes();for(const t in s){if(s[t].location>=0){let n=o[t];void 0===n&&("instanceMatrix"===t&&e.instanceMatrix&&(n=e.instanceMatrix),"instanceColor"===t&&e.instanceColor&&(n=e.instanceColor));const i={};i.attribute=n,n&&n.data&&(i.data=n.data),r[t]=i,a++}}c.attributes=r,c.attributesNum=a,c.index=i}(r,_,h,b)}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,x=!0)}null!==b&&n.update(b,34963),(x||u)&&(u=!1,function(r,o,a,s){if(!1===i.isWebGL2&&(r.isInstancedMesh||s.isInstancedBufferGeometry)&&null===t.get("ANGLE_instanced_arrays"))return;m();const l=s.attributes,c=a.getAttributes(),u=o.defaultAttributeValues;for(const t in c){const i=c[t];if(i.location>=0){let o=l[t];if(void 0===o&&("instanceMatrix"===t&&r.instanceMatrix&&(o=r.instanceMatrix),"instanceColor"===t&&r.instanceColor&&(o=r.instanceColor)),void 0!==o){const t=o.normalized,a=o.itemSize,l=n.get(o);if(void 0===l)continue;const c=l.buffer,u=l.type,d=l.bytesPerElement;if(o.isInterleavedBufferAttribute){const n=o.data,l=n.stride,h=o.offset;if(n.isInstancedInterleavedBuffer){for(let e=0;e<i.locationSize;e++)g(i.location+e,n.meshPerAttribute);!0!==r.isInstancedMesh&&void 0===s._maxInstanceCount&&(s._maxInstanceCount=n.meshPerAttribute*n.count)}else for(let e=0;e<i.locationSize;e++)f(i.location+e);e.bindBuffer(34962,c);for(let e=0;e<i.locationSize;e++)y(i.location+e,a/i.locationSize,u,t,l*d,(h+a/i.locationSize*e)*d)}else{if(o.isInstancedBufferAttribute){for(let e=0;e<i.locationSize;e++)g(i.location+e,o.meshPerAttribute);!0!==r.isInstancedMesh&&void 0===s._maxInstanceCount&&(s._maxInstanceCount=o.meshPerAttribute*o.count)}else for(let e=0;e<i.locationSize;e++)f(i.location+e);e.bindBuffer(34962,c);for(let e=0;e<i.locationSize;e++)y(i.location+e,a/i.locationSize,u,t,a*d,a/i.locationSize*e*d)}}else if(void 0!==u){const n=u[t];if(void 0!==n)switch(n.length){case 2:e.vertexAttrib2fv(i.location,n);break;case 3:e.vertexAttrib3fv(i.location,n);break;case 4:e.vertexAttrib4fv(i.location,n);break;default:e.vertexAttrib1fv(i.location,n)}}}}v()}(r,l,h,_),null!==b&&e.bindBuffer(34963,n.get(b).buffer))},reset:_,resetDefaultState:b,dispose:function(){_();for(const e in s){const t=s[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 s[e]}},releaseStatesOfGeometry:function(e){if(void 0===s[e.id])return;const t=s[e.id];for(const e in t){const n=t[e];for(const e in n)h(n[e].object),delete n[e];delete t[e]}delete s[e.id]},releaseStatesOfProgram:function(e){for(const t in s){const n=s[t];if(void 0===n[e.id])continue;const i=n[e.id];for(const e in i)h(i[e].object),delete i[e];delete n[e.id]}},initAttributes:m,enableAttribute:f,disableUnusedAttributes:v}}function og(e,t,n,i){const r=i.isWebGL2;let o;this.setMode=function(e){o=e},this.render=function(t,i){e.drawArrays(o,t,i),n.update(i,o,1)},this.renderInstances=function(i,a,s){if(0===s)return;let l,c;if(r)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,i,a,s),n.update(a,o,s)}}function ag(e,t,n){let i;function r(t){if("highp"===t){if(e.getShaderPrecisionFormat(35633,36338).precision>0&&e.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";t="mediump"}return"mediump"===t&&e.getShaderPrecisionFormat(35633,36337).precision>0&&e.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}const o="undefined"!=typeof WebGL2RenderingContext&&e instanceof WebGL2RenderingContext||"undefined"!=typeof WebGL2ComputeRenderingContext&&e instanceof WebGL2ComputeRenderingContext;let a=void 0!==n.precision?n.precision:"highp";const s=r(a);s!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",s,"instead."),a=s);const l=o||t.has("WEBGL_draw_buffers"),c=!0===n.logarithmicDepthBuffer,u=e.getParameter(34930),d=e.getParameter(35660),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!==i)return i;if(!0===t.has("EXT_texture_filter_anisotropic")){const n=t.get("EXT_texture_filter_anisotropic");i=e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i},getMaxPrecision:r,precision:a,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 sg(e){const t=this;let n=null,i=0,r=!1,o=!1;const a=new $f,s=new Qh,l={value:null,needsUpdate:!1};function c(){l.value!==n&&(l.value=n,l.needsUpdate=i>0),t.numPlanes=i,t.numIntersection=0}function u(e,n,i,r){const o=null!==e?e.length:0;let c=null;if(0!==o){if(c=l.value,!0!==r||null===c){const t=i+4*o,r=n.matrixWorldInverse;s.getNormalMatrix(r),(null===c||c.length<t)&&(c=new Float32Array(t));for(let t=0,n=i;t!==o;++t,n+=4)a.copy(e[t]).applyMatrix4(r,s),a.normal.toArray(c,n),c[n+3]=a.constant}l.value=c,l.needsUpdate=!0}return t.numPlanes=o,t.numIntersection=0,c}this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(e,t,o){const a=0!==e.length||t||0!==i||r;return r=t,n=u(e,o,0),i=e.length,a},this.beginShadows=function(){o=!0,u(null)},this.endShadows=function(){o=!1,c()},this.setState=function(t,a,s){const d=t.clippingPlanes,h=t.clipIntersection,p=t.clipShadows,m=e.get(t);if(!r||null===d||0===d.length||o&&!p)o?u(null):c();else{const e=o?0:i,t=4*e;let r=m.clippingState||null;l.value=r,r=u(d,a,t,s);for(let e=0;e!==t;++e)r[e]=n[e];m.clippingState=r,this.numIntersection=h?this.numPlanes:0,this.numPlanes+=e}}}function lg(e){let t=new WeakMap;function n(e,t){return t===Cu?e.mapping=Iu:t===Nu&&(e.mapping=Mu),e}function i(e){const n=e.target;n.removeEventListener("dispose",i);const r=t.get(n);void 0!==r&&(t.delete(n),r.dispose())}return{get:function(r){if(r&&r.isTexture&&!1===r.isRenderTargetTexture){const o=r.mapping;if(o===Cu||o===Nu){if(t.has(r)){return n(t.get(r).texture,r.mapping)}{const o=r.image;if(o&&o.height>0){const a=new Hf(o.height/2);return a.fromEquirectangularTexture(e,r),t.set(r,a),r.addEventListener("dispose",i),n(a.texture,r.mapping)}return null}}}return r},dispose:function(){t=new WeakMap}}}ng.physical={uniforms:Df([ng.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new Kh(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 mp(0)},sheenColorMap:{value:null},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},transmission:{value:0},transmissionMap:{value:null},transmissionSamplerSize:{value:new Kh},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},attenuationDistance:{value:0},attenuationColor:{value:new mp(0)},specularIntensity:{value:1},specularIntensityMap:{value:null},specularColor:{value:new mp(1,1,1)},specularColorMap:{value:null}}]),vertexShader:eg.meshphysical_vert,fragmentShader:eg.meshphysical_frag};class cg extends Ff{constructor(e=-1,t=1,n=1,i=-1,r=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=i,this.near=r,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,i,r,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=i,this.view.width=r,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,i=(this.top+this.bottom)/2;let r=n-e,o=n+e,a=i+t,s=i-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;r+=e*this.view.offsetX,o=r+e*this.view.width,a-=t*this.view.offsetY,s=a-t*this.view.height}this.projectionMatrix.makeOrthographic(r,o,a,s,this.near,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,null!==this.view&&(t.object.view=Object.assign({},this.view)),t}}const ug=[.125,.215,.35,.446,.526,.582],dg=20,hg=new cg,pg=new mp;let mg=null;const fg=(1+Math.sqrt(5))/2,gg=1/fg,vg=[new Cp(1,1,1),new Cp(-1,1,1),new Cp(1,1,-1),new Cp(-1,1,-1),new Cp(0,fg,gg),new Cp(0,fg,-gg),new Cp(gg,0,fg),new Cp(-gg,0,fg),new Cp(fg,gg,0),new Cp(-fg,gg,0)];class yg{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,i=100){mg=this._renderer.getRenderTarget(),this._setSize(256);const r=this._allocateTargets();return r.depthBuffer=!0,this._sceneToCubeUV(e,n,i,r),t>0&&this._blur(r,0,0,t),this._applyPMREM(r),this._cleanup(r),r}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=wg(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=xg(),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(mg),e.scissorTest=!1,bg(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===Iu||e.mapping===Mu?this._setSize(0===e.image.length?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),mg=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:zu,minFilter:zu,generateMipmaps:!1,type:Ku,format:rd,encoding:eh,depthBuffer:!1},i=_g(e,t,n);if(null===this._pingPongRenderTarget||this._pingPongRenderTarget.width!==e){null!==this._pingPongRenderTarget&&this._dispose(),this._pingPongRenderTarget=_g(e,t,n);const{_lodMax:i}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=function(e){const t=[],n=[],i=[];let r=e;const o=e-4+1+ug.length;for(let a=0;a<o;a++){const o=Math.pow(2,r);n.push(o);let s=1/o;a>e-4?s=ug[a-e+4-1]:0===a&&(s=0),i.push(s);const l=1/(o-2),c=-l,u=1+l,d=[c,c,u,c,u,u,c,c,u,u,c,u],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,i=[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(i,m*p*e),y.set(d,f*p*e);const r=[e,e,e,e,e,e];_.set(r,g*p*e)}const b=new pf;b.setAttribute("position",new Ym(v,m)),b.setAttribute("uv",new Ym(y,f)),b.setAttribute("faceIndex",new Ym(_,g)),t.push(b),r>4&&r--}return{lodPlanes:t,sizeLods:n,sigmas:i}}(i)),this._blurMaterial=function(e,t,n){const i=new Float32Array(dg),r=new Cp(0,1,0),o=new Bf({name:"SphericalGaussianBlur",defines:{n:dg,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:Sg(),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:Gc,depthTest:!1,depthWrite:!1});return o}(i,e,t)}return i}_compileMaterial(e){const t=new Of(this._lodPlanes[0],e);this._renderer.compile(t,hg)}_sceneToCubeUV(e,t,n,i){const r=new Uf(90,1,t,n),o=[1,-1,1,1,1,1],a=[1,1,1,-1,-1,-1],s=this._renderer,l=s.autoClear,c=s.toneMapping;s.getClearColor(pg),s.toneMapping=bu,s.autoClear=!1;const u=new Wm({name:"PMREM.Background",side:Uc,depthWrite:!1,depthTest:!1}),d=new Of(new Lf,u);let h=!1;const p=e.background;p?p.isColor&&(u.color.copy(p),e.background=null,h=!0):(u.color.copy(pg),h=!0);for(let t=0;t<6;t++){const n=t%3;0===n?(r.up.set(0,o[t],0),r.lookAt(a[t],0,0)):1===n?(r.up.set(0,0,o[t]),r.lookAt(0,a[t],0)):(r.up.set(0,o[t],0),r.lookAt(0,0,a[t]));const l=this._cubeSize;bg(i,n*l,t>2?l:0,l,l),s.setRenderTarget(i),h&&s.render(d,r),s.render(e,r)}d.geometry.dispose(),d.material.dispose(),s.toneMapping=c,s.autoClear=l,e.background=p}_textureToCubeUV(e,t){const n=this._renderer,i=e.mapping===Iu||e.mapping===Mu;i?(null===this._cubemapMaterial&&(this._cubemapMaterial=wg()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===e.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=xg());const r=i?this._cubemapMaterial:this._equirectMaterial,o=new Of(this._lodPlanes[0],r);r.uniforms.envMap.value=e;const a=this._cubeSize;bg(t,0,0,3*a,2*a),n.setRenderTarget(t),n.render(o,hg)}_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]),i=vg[(t-1)%vg.length];this._blur(e,t-1,t,n,i)}t.autoClear=n}_blur(e,t,n,i,r){const o=this._pingPongRenderTarget;this._halfBlur(e,o,t,n,i,"latitudinal",r),this._halfBlur(o,e,n,n,i,"longitudinal",r)}_halfBlur(e,t,n,i,r,o,a){const s=this._renderer,l=this._blurMaterial;"latitudinal"!==o&&"longitudinal"!==o&&console.error("blur direction must be either latitudinal or longitudinal!");const c=new Of(this._lodPlanes[i],l),u=l.uniforms,d=this._sizeLods[n]-1,h=isFinite(r)?Math.PI/(2*d):2*Math.PI/39,p=r/h,m=isFinite(r)?1+Math.floor(3*p):dg;m>dg&&console.warn(`sigmaRadians, ${r}, 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<dg;++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,a&&(u.poleAxis.value=a);const{_lodMax:v}=this;u.dTheta.value=h,u.mipInt.value=v-n;const y=this._sizeLods[i];bg(t,3*y*(i>v-4?i-v+4:0),4*(this._cubeSize-y),3*y,2*y),s.setRenderTarget(t),s.render(c,hg)}}function _g(e,t,n){const i=new wp(e,t,n);return i.texture.mapping=Ou,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function bg(e,t,n,i,r){e.viewport.set(t,n,i,r),e.scissor.set(t,n,i,r)}function xg(){return new Bf({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Sg(),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:Gc,depthTest:!1,depthWrite:!1})}function wg(){return new Bf({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Sg(),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:Gc,depthTest:!1,depthWrite:!1})}function Sg(){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 Eg(e){let t=new WeakMap,n=null;function i(e){const n=e.target;n.removeEventListener("dispose",i);const r=t.get(n);void 0!==r&&(t.delete(n),r.dispose())}return{get:function(r){if(r&&r.isTexture){const o=r.mapping,a=o===Cu||o===Nu,s=o===Iu||o===Mu;if(a||s){if(r.isRenderTargetTexture&&!0===r.needsPMREMUpdate){r.needsPMREMUpdate=!1;let i=t.get(r);return null===n&&(n=new yg(e)),i=a?n.fromEquirectangular(r,i):n.fromCubemap(r,i),t.set(r,i),i.texture}if(t.has(r))return t.get(r).texture;{const o=r.image;if(a&&o&&o.height>0||s&&o&&function(e){let t=0;const n=6;for(let i=0;i<n;i++)void 0!==e[i]&&t++;return t===n}(o)){null===n&&(n=new yg(e));const o=a?n.fromEquirectangular(r):n.fromCubemap(r);return t.set(r,o),r.addEventListener("dispose",i),o.texture}return null}}}return r},dispose:function(){t=new WeakMap,null!==n&&(n.dispose(),n=null)}}}function Ag(e){const t={};function n(n){if(void 0!==t[n])return t[n];let i;switch(n){case"WEBGL_depth_texture":i=e.getExtension("WEBGL_depth_texture")||e.getExtension("MOZ_WEBGL_depth_texture")||e.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":i=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":i=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":i=e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:i=e.getExtension(n)}return t[n]=i,i}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 Tg(e,t,n,i){const r={},o=new WeakMap;function a(e){const s=e.target;null!==s.index&&t.remove(s.index);for(const e in s.attributes)t.remove(s.attributes[e]);s.removeEventListener("dispose",a),delete r[s.id];const l=o.get(s);l&&(t.remove(l),o.delete(s)),i.releaseStatesOfGeometry(s),!0===s.isInstancedBufferGeometry&&delete s._maxInstanceCount,n.memory.geometries--}function s(e){const n=[],i=e.index,r=e.attributes.position;let a=0;if(null!==i){const e=i.array;a=i.version;for(let t=0,i=e.length;t<i;t+=3){const i=e[t+0],r=e[t+1],o=e[t+2];n.push(i,r,r,o,o,i)}}else{const e=r.array;a=r.version;for(let t=0,i=e.length/3-1;t<i;t+=3){const e=t+0,i=t+1,r=t+2;n.push(e,i,i,r,r,e)}}const s=new(ep(n)?tf:Qm)(n,1);s.version=a;const l=o.get(e);l&&t.remove(l),o.set(e,s)}return{get:function(e,t){return!0===r[t.id]||(t.addEventListener("dispose",a),r[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 i=e.morphAttributes;for(const e in i){const n=i[e];for(let e=0,i=n.length;e<i;e++)t.update(n[e],34962)}},getWireframeAttribute:function(e){const t=o.get(e);if(t){const n=e.index;null!==n&&t.version<n.version&&s(e)}else s(e);return o.get(e)}}}function Ig(e,t,n,i){const r=i.isWebGL2;let o,a,s;this.setMode=function(e){o=e},this.setIndex=function(e){a=e.type,s=e.bytesPerElement},this.render=function(t,i){e.drawElements(o,i,a,t*s),n.update(i,o,1)},this.renderInstances=function(i,l,c){if(0===c)return;let u,d;if(r)u=e,d="drawElementsInstanced";else if(u=t.get("ANGLE_instanced_arrays"),d="drawElementsInstancedANGLE",null===u)return void console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");u[d](o,l,a,i*s,c),n.update(l,o,c)}}function Mg(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,i){switch(t.calls++,n){case 4:t.triangles+=i*(e/3);break;case 1:t.lines+=i*(e/2);break;case 3:t.lines+=i*(e-1);break;case 2:t.lines+=i*e;break;case 0:t.points+=i*e;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",n)}}}}function Cg(e,t){return e[0]-t[0]}function Ng(e,t){return Math.abs(t[1])-Math.abs(e[1])}function Og(e,t,n){const i={},r=new Float32Array(8),o=new WeakMap,a=new xp,s=[];for(let e=0;e<8;e++)s[e]=[e,0];return{update:function(l,c,u,d){const h=l.morphTargetInfluences;if(!0===t.isWebGL2){const i=c.morphAttributes.position||c.morphAttributes.normal||c.morphAttributes.color,r=void 0!==i?i.length:0;let s=o.get(c);if(void 0===s||s.count!==r){void 0!==s&&s.texture.dispose();const e=void 0!==c.morphAttributes.position,n=void 0!==c.morphAttributes.normal,i=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===i&&(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*r),g=new Sp(f,p,m,r);g.type=Xu,g.needsUpdate=!0;const v=4*h;for(let t=0;t<r;t++){const r=l[t],o=u[t],s=d[t],c=p*m*4*t;for(let t=0;t<r.count;t++){const l=t*v;!0===e&&(a.fromBufferAttribute(r,t),f[c+l+0]=a.x,f[c+l+1]=a.y,f[c+l+2]=a.z,f[c+l+3]=0),!0===n&&(a.fromBufferAttribute(o,t),f[c+l+4]=a.x,f[c+l+5]=a.y,f[c+l+6]=a.z,f[c+l+7]=0),!0===i&&(a.fromBufferAttribute(s,t),f[c+l+8]=a.x,f[c+l+9]=a.y,f[c+l+10]=a.z,f[c+l+11]=4===s.itemSize?a.w:1)}}s={count:r,texture:g,size:new Kh(p,m)},o.set(c,s),c.addEventListener("dispose",(function e(){g.dispose(),o.delete(c),c.removeEventListener("dispose",e)}))}let l=0;for(let e=0;e<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",s.texture,n),d.getUniforms().setValue(e,"morphTargetsTextureSize",s.size)}else{const t=void 0===h?0:h.length;let n=i[c.id];if(void 0===n||n.length!==t){n=[];for(let e=0;e<t;e++)n[e]=[e,0];i[c.id]=n}for(let e=0;e<t;e++){const t=n[e];t[0]=e,t[1]=h[e]}n.sort(Ng);for(let e=0;e<8;e++)e<t&&n[e][1]?(s[e][0]=n[e][0],s[e][1]=n[e][1]):(s[e][0]=Number.MAX_SAFE_INTEGER,s[e][1]=0);s.sort(Cg);const o=c.morphAttributes.position,a=c.morphAttributes.normal;let l=0;for(let e=0;e<8;e++){const t=s[e],n=t[0],i=t[1];n!==Number.MAX_SAFE_INTEGER&&i?(o&&c.getAttribute("morphTarget"+e)!==o[n]&&c.setAttribute("morphTarget"+e,o[n]),a&&c.getAttribute("morphNormal"+e)!==a[n]&&c.setAttribute("morphNormal"+e,a[n]),r[e]=i,l+=i):(o&&!0===c.hasAttribute("morphTarget"+e)&&c.deleteAttribute("morphTarget"+e),a&&!0===c.hasAttribute("morphNormal"+e)&&c.deleteAttribute("morphNormal"+e),r[e]=0)}const u=c.morphTargetsRelative?1:1-l;d.getUniforms().setValue(e,"morphTargetBaseInfluence",u),d.getUniforms().setValue(e,"morphTargetInfluences",r)}}}}function Rg(e,t,n,i){let r=new WeakMap;function o(e){const t=e.target;t.removeEventListener("dispose",o),n.remove(t.instanceMatrix),null!==t.instanceColor&&n.remove(t.instanceColor)}return{update:function(e){const a=i.render.frame,s=e.geometry,l=t.get(e,s);return r.get(l)!==a&&(t.update(l),r.set(l,a)),e.isInstancedMesh&&(!1===e.hasEventListener("dispose",o)&&e.addEventListener("dispose",o),n.update(e.instanceMatrix,34962),null!==e.instanceColor&&n.update(e.instanceColor,34962)),l},dispose:function(){r=new WeakMap}}}const Lg=new bp,Pg=new Sp,Dg=new Ap,kg=new jf,Bg=[],Fg=[],Ug=new Float32Array(16),zg=new Float32Array(9),Gg=new Float32Array(4);function jg(e,t,n){const i=e[0];if(i<=0||i>0)return e;const r=t*n;let o=Bg[r];if(void 0===o&&(o=new Float32Array(r),Bg[r]=o),0!==t){i.toArray(o,0);for(let i=1,r=0;i!==t;++i)r+=n,e[i].toArray(o,r)}return o}function Hg(e,t){if(e.length!==t.length)return!1;for(let n=0,i=e.length;n<i;n++)if(e[n]!==t[n])return!1;return!0}function Vg(e,t){for(let n=0,i=t.length;n<i;n++)e[n]=t[n]}function Wg(e,t){let n=Fg[t];void 0===n&&(n=new Int32Array(t),Fg[t]=n);for(let i=0;i!==t;++i)n[i]=e.allocateTextureUnit();return n}function qg(e,t){const n=this.cache;n[0]!==t&&(e.uniform1f(this.addr,t),n[0]=t)}function $g(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(Hg(n,t))return;e.uniform2fv(this.addr,t),Vg(n,t)}}function Yg(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(Hg(n,t))return;e.uniform3fv(this.addr,t),Vg(n,t)}}function Jg(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(Hg(n,t))return;e.uniform4fv(this.addr,t),Vg(n,t)}}function Zg(e,t){const n=this.cache,i=t.elements;if(void 0===i){if(Hg(n,t))return;e.uniformMatrix2fv(this.addr,!1,t),Vg(n,t)}else{if(Hg(n,i))return;Gg.set(i),e.uniformMatrix2fv(this.addr,!1,Gg),Vg(n,i)}}function Xg(e,t){const n=this.cache,i=t.elements;if(void 0===i){if(Hg(n,t))return;e.uniformMatrix3fv(this.addr,!1,t),Vg(n,t)}else{if(Hg(n,i))return;zg.set(i),e.uniformMatrix3fv(this.addr,!1,zg),Vg(n,i)}}function Kg(e,t){const n=this.cache,i=t.elements;if(void 0===i){if(Hg(n,t))return;e.uniformMatrix4fv(this.addr,!1,t),Vg(n,t)}else{if(Hg(n,i))return;Ug.set(i),e.uniformMatrix4fv(this.addr,!1,Ug),Vg(n,i)}}function Qg(e,t){const n=this.cache;n[0]!==t&&(e.uniform1i(this.addr,t),n[0]=t)}function ev(e,t){const n=this.cache;Hg(n,t)||(e.uniform2iv(this.addr,t),Vg(n,t))}function tv(e,t){const n=this.cache;Hg(n,t)||(e.uniform3iv(this.addr,t),Vg(n,t))}function nv(e,t){const n=this.cache;Hg(n,t)||(e.uniform4iv(this.addr,t),Vg(n,t))}function iv(e,t){const n=this.cache;n[0]!==t&&(e.uniform1ui(this.addr,t),n[0]=t)}function rv(e,t){const n=this.cache;Hg(n,t)||(e.uniform2uiv(this.addr,t),Vg(n,t))}function ov(e,t){const n=this.cache;Hg(n,t)||(e.uniform3uiv(this.addr,t),Vg(n,t))}function av(e,t){const n=this.cache;Hg(n,t)||(e.uniform4uiv(this.addr,t),Vg(n,t))}function sv(e,t,n){const i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(e.uniform1i(this.addr,r),i[0]=r),n.setTexture2D(t||Lg,r)}function lv(e,t,n){const i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(e.uniform1i(this.addr,r),i[0]=r),n.setTexture3D(t||Dg,r)}function cv(e,t,n){const i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(e.uniform1i(this.addr,r),i[0]=r),n.setTextureCube(t||kg,r)}function uv(e,t,n){const i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(e.uniform1i(this.addr,r),i[0]=r),n.setTexture2DArray(t||Pg,r)}function dv(e,t){e.uniform1fv(this.addr,t)}function hv(e,t){const n=jg(t,this.size,2);e.uniform2fv(this.addr,n)}function pv(e,t){const n=jg(t,this.size,3);e.uniform3fv(this.addr,n)}function mv(e,t){const n=jg(t,this.size,4);e.uniform4fv(this.addr,n)}function fv(e,t){const n=jg(t,this.size,4);e.uniformMatrix2fv(this.addr,!1,n)}function gv(e,t){const n=jg(t,this.size,9);e.uniformMatrix3fv(this.addr,!1,n)}function vv(e,t){const n=jg(t,this.size,16);e.uniformMatrix4fv(this.addr,!1,n)}function yv(e,t){e.uniform1iv(this.addr,t)}function _v(e,t){e.uniform2iv(this.addr,t)}function bv(e,t){e.uniform3iv(this.addr,t)}function xv(e,t){e.uniform4iv(this.addr,t)}function wv(e,t){e.uniform1uiv(this.addr,t)}function Sv(e,t){e.uniform2uiv(this.addr,t)}function Ev(e,t){e.uniform3uiv(this.addr,t)}function Av(e,t){e.uniform4uiv(this.addr,t)}function Tv(e,t,n){const i=t.length,r=Wg(n,i);e.uniform1iv(this.addr,r);for(let e=0;e!==i;++e)n.setTexture2D(t[e]||Lg,r[e])}function Iv(e,t,n){const i=t.length,r=Wg(n,i);e.uniform1iv(this.addr,r);for(let e=0;e!==i;++e)n.setTexture3D(t[e]||Dg,r[e])}function Mv(e,t,n){const i=t.length,r=Wg(n,i);e.uniform1iv(this.addr,r);for(let e=0;e!==i;++e)n.setTextureCube(t[e]||kg,r[e])}function Cv(e,t,n){const i=t.length,r=Wg(n,i);e.uniform1iv(this.addr,r);for(let e=0;e!==i;++e)n.setTexture2DArray(t[e]||Pg,r[e])}class Nv{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.setValue=function(e){switch(e){case 5126:return qg;case 35664:return $g;case 35665:return Yg;case 35666:return Jg;case 35674:return Zg;case 35675:return Xg;case 35676:return Kg;case 5124:case 35670:return Qg;case 35667:case 35671:return ev;case 35668:case 35672:return tv;case 35669:case 35673:return nv;case 5125:return iv;case 36294:return rv;case 36295:return ov;case 36296:return av;case 35678:case 36198:case 36298:case 36306:case 35682:return sv;case 35679:case 36299:case 36307:return lv;case 35680:case 36300:case 36308:case 36293:return cv;case 36289:case 36303:case 36311:case 36292:return uv}}(t.type)}}class Ov{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 dv;case 35664:return hv;case 35665:return pv;case 35666:return mv;case 35674:return fv;case 35675:return gv;case 35676:return vv;case 5124:case 35670:return yv;case 35667:case 35671:return _v;case 35668:case 35672:return bv;case 35669:case 35673:return xv;case 5125:return wv;case 36294:return Sv;case 36295:return Ev;case 36296:return Av;case 35678:case 36198:case 36298:case 36306:case 35682:return Tv;case 35679:case 36299:case 36307:return Iv;case 35680:case 36300:case 36308:case 36293:return Mv;case 36289:case 36303:case 36311:case 36292:return Cv}}(t.type)}}class Rv{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){const i=this.seq;for(let r=0,o=i.length;r!==o;++r){const o=i[r];o.setValue(e,t[o.id],n)}}}const Lv=/(\w+)(\])?(\[|\.)?/g;function Pv(e,t){e.seq.push(t),e.map[t.id]=t}function Dv(e,t,n){const i=e.name,r=i.length;for(Lv.lastIndex=0;;){const o=Lv.exec(i),a=Lv.lastIndex;let s=o[1];const l="]"===o[2],c=o[3];if(l&&(s|=0),void 0===c||"["===c&&a+2===r){Pv(n,void 0===c?new Nv(s,e,t):new Ov(s,e,t));break}{let e=n.map[s];void 0===e&&(e=new Rv(s),Pv(n,e)),n=e}}}class kv{constructor(e,t){this.seq=[],this.map={};const n=e.getProgramParameter(t,35718);for(let i=0;i<n;++i){const n=e.getActiveUniform(t,i);Dv(n,e.getUniformLocation(t,n.name),this)}}setValue(e,t,n,i){const r=this.map[t];void 0!==r&&r.setValue(e,n,i)}setOptional(e,t,n){const i=t[n];void 0!==i&&this.setValue(e,n,i)}static upload(e,t,n,i){for(let r=0,o=t.length;r!==o;++r){const o=t[r],a=n[o.id];!1!==a.needsUpdate&&o.setValue(e,a.value,i)}}static seqWithValue(e,t){const n=[];for(let i=0,r=e.length;i!==r;++i){const r=e[i];r.id in t&&n.push(r)}return n}}function Bv(e,t,n){const i=e.createShader(t);return e.shaderSource(i,n),e.compileShader(i),i}let Fv=0;function Uv(e,t,n){const i=e.getShaderParameter(t,35713),r=e.getShaderInfoLog(t).trim();if(i&&""===r)return"";const o=/ERROR: 0:(\d+)/.exec(r);if(o){const i=parseInt(o[1]);return n.toUpperCase()+"\n\n"+r+"\n\n"+function(e,t){const n=e.split("\n"),i=[],r=Math.max(t-6,0),o=Math.min(t+6,n.length);for(let e=r;e<o;e++){const r=e+1;i.push(`${r===t?">":" "} ${r}: ${n[e]}`)}return i.join("\n")}(e.getShaderSource(t),i)}return r}function zv(e,t){const n=function(e){switch(e){case eh:return["Linear","( value )"];case th: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 Gv(e,t){let n;switch(t){case xu:n="Linear";break;case wu:n="Reinhard";break;case Su:n="OptimizedCineon";break;case Eu:n="ACESFilmic";break;case Au:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),n="Linear"}return"vec3 "+e+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}function jv(e){return""!==e}function Hv(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 Vv(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}const Wv=/^[ \t]*#include +<([\w\d./]+)>/gm;function qv(e){return e.replace(Wv,$v)}function $v(e,t){const n=eg[t];if(void 0===n)throw new Error("Can not resolve #include <"+t+">");return qv(n)}const Yv=/#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 Jv(e){return e.replace(Yv,Zv)}function Zv(e,t,n,i){let r="";for(let e=parseInt(t);e<parseInt(n);e++)r+=i.replace(/\[\s*i\s*\]/g,"[ "+e+" ]").replace(/UNROLLED_LOOP_INDEX/g,e);return r}function Xv(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 Kv(e,t,n,i){const r=e.getContext(),o=n.defines;let a=n.vertexShader,s=n.fragmentShader;const l=function(e){let t="SHADOWMAP_TYPE_BASIC";return e.shadowMapType===Dc?t="SHADOWMAP_TYPE_PCF":e.shadowMapType===kc?t="SHADOWMAP_TYPE_PCF_SOFT":e.shadowMapType===Bc&&(t="SHADOWMAP_TYPE_VSM"),t}(n),c=function(e){let t="ENVMAP_TYPE_CUBE";if(e.envMap)switch(e.envMapMode){case Iu:case Mu:t="ENVMAP_TYPE_CUBE";break;case Ou:t="ENVMAP_TYPE_CUBE_UV"}return t}(n),u=function(e){let t="ENVMAP_MODE_REFLECTION";e.envMap&&e.envMapMode===Mu&&(t="ENVMAP_MODE_REFRACTION");return t}(n),d=function(e){let t="ENVMAP_BLENDING_NONE";if(e.envMap)switch(e.combine){case vu:t="ENVMAP_BLENDING_MULTIPLY";break;case yu:t="ENVMAP_BLENDING_MIX";break;case _u: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,i=1/t;return{texelWidth:1/(3*Math.max(Math.pow(2,n),112)),texelHeight:i,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(jv).join("\n")}(n),m=function(e){const t=[];for(const n in e){const i=e[n];!1!==i&&t.push("#define "+n+" "+i)}return t.join("\n")}(o),f=r.createProgram();let g,v,y=n.glslVersion?"#version "+n.glslVersion+"\n":"";n.isRawShaderMaterial?(g=[m].filter(jv).join("\n"),g.length>0&&(g+="\n"),v=[p,m].filter(jv).join("\n"),v.length>0&&(v+="\n")):(g=[Xv(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(jv).join("\n"),v=[p,Xv(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!==bu?"#define TONE_MAPPING":"",n.toneMapping!==bu?eg.tonemapping_pars_fragment:"",n.toneMapping!==bu?Gv("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",eg.encodings_pars_fragment,zv("linearToOutputTexel",n.outputEncoding),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(jv).join("\n")),a=qv(a),a=Hv(a,n),a=Vv(a,n),s=qv(s),s=Hv(s,n),s=Vv(s,n),a=Jv(a),s=Jv(s),n.isWebGL2&&!0!==n.isRawShaderMaterial&&(y="#version 300 es\n",g=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+g,v=["#define varying in",n.glslVersion===Dh?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===Dh?"":"#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+s,b=Bv(r,35633,y+g+a),x=Bv(r,35632,_);if(r.attachShader(f,b),r.attachShader(f,x),void 0!==n.index0AttributeName?r.bindAttribLocation(f,0,n.index0AttributeName):!0===n.morphTargets&&r.bindAttribLocation(f,0,"position"),r.linkProgram(f),e.debug.checkShaderErrors){const e=r.getProgramInfoLog(f).trim(),t=r.getShaderInfoLog(b).trim(),n=r.getShaderInfoLog(x).trim();let i=!0,o=!0;if(!1===r.getProgramParameter(f,35714)){i=!1;const t=Uv(r,b,"vertex"),n=Uv(r,x,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.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:i,programLog:e,vertexShader:{log:t,prefix:g},fragmentShader:{log:n,prefix:v}})}let w,S;return r.deleteShader(b),r.deleteShader(x),this.getUniforms=function(){return void 0===w&&(w=new kv(r,f)),w},this.getAttributes=function(){return void 0===S&&(S=function(e,t){const n={},i=e.getProgramParameter(t,35721);for(let r=0;r<i;r++){const i=e.getActiveAttrib(t,r),o=i.name;let a=1;35674===i.type&&(a=2),35675===i.type&&(a=3),35676===i.type&&(a=4),n[o]={type:i.type,location:e.getAttribLocation(t,o),locationSize:a}}return n}(r,f)),S},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(f),this.program=void 0},this.name=n.shaderName,this.id=Fv++,this.cacheKey=t,this.usedTimes=1,this.program=f,this.vertexShader=b,this.fragmentShader=x,this}let Qv=0;class ey{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,n=e.fragmentShader,i=this._getShaderStage(t),r=this._getShaderStage(n),o=this._getShaderCacheForMaterial(e);return!1===o.has(i)&&(o.add(i),i.usedTimes++),!1===o.has(r)&&(o.add(r),r.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 ty(e),t.set(e,n)),n}}class ty{constructor(e){this.id=Qv++,this.code=e,this.usedTimes=0}}function ny(e,t,n,i,r,o,a){const s=new vm,l=new ey,c=[],u=r.isWebGL2,d=r.logarithmicDepthBuffer,h=r.vertexTextures;let p=r.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,s,c,f,g){const v=f.fog,y=g.geometry,_=o.isMeshStandardMaterial?f.environment:null,b=(o.isMeshStandardMaterial?n:t).get(o.envMap||_),x=b&&b.mapping===Ou?b.image.height:null,w=m[o.type];null!==o.precision&&(p=r.getMaxPrecision(o.precision),p!==o.precision&&console.warn("THREE.WebGLProgram.getParameters:",o.precision,"not supported, using",p,"instead."));const S=y.morphAttributes.position||y.morphAttributes.normal||y.morphAttributes.color,E=void 0!==S?S.length:0;let A,T,I,M,C=0;if(void 0!==y.morphAttributes.position&&(C=1),void 0!==y.morphAttributes.normal&&(C=2),void 0!==y.morphAttributes.color&&(C=3),w){const e=ng[w];A=e.vertexShader,T=e.fragmentShader}else A=o.vertexShader,T=o.fragmentShader,l.update(o),I=l.getVertexShaderID(o),M=l.getFragmentShaderID(o);const N=e.getRenderTarget(),O=o.alphaTest>0,R=o.clearcoat>0,L=o.iridescence>0;return{isWebGL2:u,shaderID:w,shaderName:o.type,vertexShader:A,fragmentShader:T,defines:o.defines,customVertexShaderID:I,customFragmentShaderID:M,isRawShaderMaterial:!0===o.isRawShaderMaterial,glslVersion:o.glslVersion,precision:p,instancing:!0===g.isInstancedMesh,instancingColor:!0===g.isInstancedMesh&&null!==g.instanceColor,supportsVertexTextures:h,outputEncoding:null===N?e.outputEncoding:!0===N.isXRRenderTarget?N.texture.encoding:eh,map:!!o.map,matcap:!!o.matcap,envMap:!!b,envMapMode:b&&b.mapping,envMapCubeUVHeight:x,lightMap:!!o.lightMap,aoMap:!!o.aoMap,emissiveMap:!!o.emissiveMap,bumpMap:!!o.bumpMap,normalMap:!!o.normalMap,objectSpaceNormalMap:o.normalMapType===oh,tangentSpaceNormalMap:o.normalMapType===rh,decodeVideoTexture:!!o.map&&!0===o.map.isVideoTexture&&o.map.encoding===th,clearcoat:R,clearcoatMap:R&&!!o.clearcoatMap,clearcoatRoughnessMap:R&&!!o.clearcoatRoughnessMap,clearcoatNormalMap:R&&!!o.clearcoatNormalMap,iridescence:L,iridescenceMap:L&&!!o.iridescenceMap,iridescenceThicknessMap:L&&!!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===jc,alphaMap:!!o.alphaMap,alphaTest:O,gradientMap:!!o.gradientMap,sheen:o.sheen>0,sheenColorMap:!!o.sheenColorMap,sheenRoughnessMap:!!o.sheenRoughnessMap,transmission:o.transmission>0,transmissionMap:!!o.transmissionMap,thicknessMap:!!o.thicknessMap,combine:o.combine,vertexTangents:!!o.normalMap&&!!y.attributes.tangent,vertexColors:o.vertexColors,vertexAlphas:!0===o.vertexColors&&!!y.attributes.color&&4===y.attributes.color.itemSize,vertexUvs:!!(o.map||o.bumpMap||o.normalMap||o.specularMap||o.alphaMap||o.emissiveMap||o.roughnessMap||o.metalnessMap||o.clearcoatMap||o.clearcoatRoughnessMap||o.clearcoatNormalMap||o.iridescenceMap||o.iridescenceThicknessMap||o.displacementMap||o.transmissionMap||o.thicknessMap||o.specularIntensityMap||o.specularColorMap||o.sheenColorMap||o.sheenRoughnessMap),uvsVertexOnly:!(o.map||o.bumpMap||o.normalMap||o.specularMap||o.alphaMap||o.emissiveMap||o.roughnessMap||o.metalnessMap||o.clearcoatNormalMap||o.iridescenceMap||o.iridescenceThicknessMap||o.transmission>0||o.transmissionMap||o.thicknessMap||o.specularIntensityMap||o.specularColorMap||o.sheen>0||o.sheenColorMap||o.sheenRoughnessMap||!o.displacementMap),fog:!!v,useFog:!0===o.fog,fogExp2:v&&v.isFogExp2,flatShading:!!o.flatShading,sizeAttenuation:o.sizeAttenuation,logarithmicDepthBuffer:d,skinning:!0===g.isSkinnedMesh,morphTargets:void 0!==y.morphAttributes.position,morphNormals:void 0!==y.morphAttributes.normal,morphColors:void 0!==y.morphAttributes.color,morphTargetsCount:E,morphTextureStride:C,numDirLights:s.directional.length,numPointLights:s.point.length,numSpotLights:s.spot.length,numSpotLightMaps:s.spotLightMap.length,numRectAreaLights:s.rectArea.length,numHemiLights:s.hemi.length,numDirLightShadows:s.directionalShadowMap.length,numPointLightShadows:s.pointShadowMap.length,numSpotLightShadows:s.spotShadowMap.length,numSpotLightShadowsWithMaps:s.numSpotLightShadowsWithMaps,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:o.dithering,shadowMapEnabled:e.shadowMap.enabled&&c.length>0,shadowMapType:e.shadowMap.type,toneMapping:o.toneMapped?e.toneMapping:bu,physicallyCorrectLights:e.physicallyCorrectLights,premultipliedAlpha:o.premultipliedAlpha,doubleSided:o.side===zc,flipSided:o.side===Uc,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||i.has("EXT_frag_depth"),rendererExtensionDrawBuffers:u||i.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:u||i.has("EXT_shader_texture_lod"),customProgramCacheKey:o.customProgramCacheKey()}},getProgramCacheKey:function(t){const n=[];if(t.shaderID?n.push(t.shaderID):(n.push(t.customVertexShaderID),n.push(t.customFragmentShaderID)),void 0!==t.defines)for(const e in t.defines)n.push(e),n.push(t.defines[e]);return!1===t.isRawShaderMaterial&&(!function(e,t){e.push(t.precision),e.push(t.outputEncoding),e.push(t.envMapMode),e.push(t.envMapCubeUVHeight),e.push(t.combine),e.push(t.vertexUvs),e.push(t.fogExp2),e.push(t.sizeAttenuation),e.push(t.morphTargetsCount),e.push(t.morphAttributeCount),e.push(t.numDirLights),e.push(t.numPointLights),e.push(t.numSpotLights),e.push(t.numSpotLightMaps),e.push(t.numHemiLights),e.push(t.numRectAreaLights),e.push(t.numDirLightShadows),e.push(t.numPointLightShadows),e.push(t.numSpotLightShadows),e.push(t.numSpotLightShadowsWithMaps),e.push(t.shadowMapType),e.push(t.toneMapping),e.push(t.numClippingPlanes),e.push(t.numClipIntersection),e.push(t.depthPacking)}(n,t),function(e,t){s.disableAll(),t.isWebGL2&&s.enable(0);t.supportsVertexTextures&&s.enable(1);t.instancing&&s.enable(2);t.instancingColor&&s.enable(3);t.map&&s.enable(4);t.matcap&&s.enable(5);t.envMap&&s.enable(6);t.lightMap&&s.enable(7);t.aoMap&&s.enable(8);t.emissiveMap&&s.enable(9);t.bumpMap&&s.enable(10);t.normalMap&&s.enable(11);t.objectSpaceNormalMap&&s.enable(12);t.tangentSpaceNormalMap&&s.enable(13);t.clearcoat&&s.enable(14);t.clearcoatMap&&s.enable(15);t.clearcoatRoughnessMap&&s.enable(16);t.clearcoatNormalMap&&s.enable(17);t.iridescence&&s.enable(18);t.iridescenceMap&&s.enable(19);t.iridescenceThicknessMap&&s.enable(20);t.displacementMap&&s.enable(21);t.specularMap&&s.enable(22);t.roughnessMap&&s.enable(23);t.metalnessMap&&s.enable(24);t.gradientMap&&s.enable(25);t.alphaMap&&s.enable(26);t.alphaTest&&s.enable(27);t.vertexColors&&s.enable(28);t.vertexAlphas&&s.enable(29);t.vertexUvs&&s.enable(30);t.vertexTangents&&s.enable(31);t.uvsVertexOnly&&s.enable(32);e.push(s.mask),s.disableAll(),t.fog&&s.enable(0);t.useFog&&s.enable(1);t.flatShading&&s.enable(2);t.logarithmicDepthBuffer&&s.enable(3);t.skinning&&s.enable(4);t.morphTargets&&s.enable(5);t.morphNormals&&s.enable(6);t.morphColors&&s.enable(7);t.premultipliedAlpha&&s.enable(8);t.shadowMapEnabled&&s.enable(9);t.physicallyCorrectLights&&s.enable(10);t.doubleSided&&s.enable(11);t.flipSided&&s.enable(12);t.useDepthPacking&&s.enable(13);t.dithering&&s.enable(14);t.specularIntensityMap&&s.enable(15);t.specularColorMap&&s.enable(16);t.transmission&&s.enable(17);t.transmissionMap&&s.enable(18);t.thicknessMap&&s.enable(19);t.sheen&&s.enable(20);t.sheenColorMap&&s.enable(21);t.sheenRoughnessMap&&s.enable(22);t.decodeVideoTexture&&s.enable(23);t.opaque&&s.enable(24);e.push(s.mask)}(n,t),n.push(e.outputEncoding)),n.push(t.customProgramCacheKey),n.join()},getUniforms:function(e){const t=m[e.type];let n;if(t){const e=ng[t];n=kf.clone(e.uniforms)}else n=e.uniforms;return n},acquireProgram:function(t,n){let i;for(let e=0,t=c.length;e<t;e++){const t=c[e];if(t.cacheKey===n){i=t,++i.usedTimes;break}}return void 0===i&&(i=new Kv(e,n,t,o),c.push(i)),i},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 iy(){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,i){e.get(t)[n]=i},dispose:function(){e=new WeakMap}}}function ry(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 oy(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 ay(){const e=[];let t=0;const n=[],i=[],r=[];function o(n,i,r,o,a,s){let l=e[t];return void 0===l?(l={id:n.id,object:n,geometry:i,material:r,groupOrder:o,renderOrder:n.renderOrder,z:a,group:s},e[t]=l):(l.id=n.id,l.object=n,l.geometry=i,l.material=r,l.groupOrder=o,l.renderOrder=n.renderOrder,l.z=a,l.group=s),t++,l}return{opaque:n,transmissive:i,transparent:r,init:function(){t=0,n.length=0,i.length=0,r.length=0},push:function(e,t,a,s,l,c){const u=o(e,t,a,s,l,c);a.transmission>0?i.push(u):!0===a.transparent?r.push(u):n.push(u)},unshift:function(e,t,a,s,l,c){const u=o(e,t,a,s,l,c);a.transmission>0?i.unshift(u):!0===a.transparent?r.unshift(u):n.unshift(u)},finish:function(){for(let n=t,i=e.length;n<i;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||ry),i.length>1&&i.sort(t||oy),r.length>1&&r.sort(t||oy)}}}function sy(){let e=new WeakMap;return{get:function(t,n){const i=e.get(t);let r;return void 0===i?(r=new ay,e.set(t,[r])):n>=i.length?(r=new ay,i.push(r)):r=i[n],r},dispose:function(){e=new WeakMap}}}function ly(){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 Cp,color:new mp};break;case"SpotLight":n={position:new Cp,direction:new Cp,color:new mp,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new Cp,color:new mp,distance:0,decay:0};break;case"HemisphereLight":n={direction:new Cp,skyColor:new mp,groundColor:new mp};break;case"RectAreaLight":n={color:new mp,position:new Cp,halfWidth:new Cp,halfHeight:new Cp}}return e[t.id]=n,n}}}let cy=0;function uy(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function dy(e,t){const n=new ly,i=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 Kh};break;case"PointLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Kh,shadowCameraNear:1,shadowCameraFar:1e3}}return e[t.id]=n,n}}}(),r={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++)r.probe.push(new Cp);const o=new Cp,a=new am,s=new am;return{setup:function(o,a){let s=0,l=0,c=0;for(let e=0;e<9;e++)r.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(uy);const b=!0!==a?Math.PI:1;for(let e=0,t=o.length;e<t;e++){const t=o[e],a=t.color,x=t.intensity,w=t.distance,S=t.shadow&&t.shadow.map?t.shadow.map.texture:null;if(t.isAmbientLight)s+=a.r*x*b,l+=a.g*x*b,c+=a.b*x*b;else if(t.isLightProbe)for(let e=0;e<9;e++)r.probe[e].addScaledVector(t.sh.coefficients[e],x);else if(t.isDirectionalLight){const e=n.get(t);if(e.color.copy(t.color).multiplyScalar(t.intensity*b),t.castShadow){const e=t.shadow,n=i.get(t);n.shadowBias=e.bias,n.shadowNormalBias=e.normalBias,n.shadowRadius=e.radius,n.shadowMapSize=e.mapSize,r.directionalShadow[u]=n,r.directionalShadowMap[u]=S,r.directionalShadowMatrix[u]=t.shadow.matrix,f++}r.directional[u]=e,u++}else if(t.isSpotLight){const e=n.get(t);e.position.setFromMatrixPosition(t.matrixWorld),e.color.copy(a).multiplyScalar(x*b),e.distance=w,e.coneCos=Math.cos(t.angle),e.penumbraCos=Math.cos(t.angle*(1-t.penumbra)),e.decay=t.decay,r.spot[h]=e;const o=t.shadow;if(t.map&&(r.spotLightMap[y]=t.map,y++,o.updateMatrices(t),t.castShadow&&_++),r.spotLightMatrix[h]=o.matrix,t.castShadow){const e=i.get(t);e.shadowBias=o.bias,e.shadowNormalBias=o.normalBias,e.shadowRadius=o.radius,e.shadowMapSize=o.mapSize,r.spotShadow[h]=e,r.spotShadowMap[h]=S,v++}h++}else if(t.isRectAreaLight){const e=n.get(t);e.color.copy(a).multiplyScalar(x),e.halfWidth.set(.5*t.width,0,0),e.halfHeight.set(0,.5*t.height,0),r.rectArea[p]=e,p++}else if(t.isPointLight){const e=n.get(t);if(e.color.copy(t.color).multiplyScalar(t.intensity*b),e.distance=t.distance,e.decay=t.decay,t.castShadow){const e=t.shadow,n=i.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,r.pointShadow[d]=n,r.pointShadowMap[d]=S,r.pointShadowMatrix[d]=t.shadow.matrix,g++}r.point[d]=e,d++}else if(t.isHemisphereLight){const e=n.get(t);e.skyColor.copy(t.color).multiplyScalar(x*b),e.groundColor.copy(t.groundColor).multiplyScalar(x*b),r.hemi[m]=e,m++}}p>0&&(t.isWebGL2||!0===e.has("OES_texture_float_linear")?(r.rectAreaLTC1=tg.LTC_FLOAT_1,r.rectAreaLTC2=tg.LTC_FLOAT_2):!0===e.has("OES_texture_half_float_linear")?(r.rectAreaLTC1=tg.LTC_HALF_1,r.rectAreaLTC2=tg.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),r.ambient[0]=s,r.ambient[1]=l,r.ambient[2]=c;const x=r.hash;x.directionalLength===u&&x.pointLength===d&&x.spotLength===h&&x.rectAreaLength===p&&x.hemiLength===m&&x.numDirectionalShadows===f&&x.numPointShadows===g&&x.numSpotShadows===v&&x.numSpotMaps===y||(r.directional.length=u,r.spot.length=h,r.rectArea.length=p,r.point.length=d,r.hemi.length=m,r.directionalShadow.length=f,r.directionalShadowMap.length=f,r.pointShadow.length=g,r.pointShadowMap.length=g,r.spotShadow.length=v,r.spotShadowMap.length=v,r.directionalShadowMatrix.length=f,r.pointShadowMatrix.length=g,r.spotLightMatrix.length=v+y-_,r.spotLightMap.length=y,r.numSpotLightShadowsWithMaps=_,x.directionalLength=u,x.pointLength=d,x.spotLength=h,x.rectAreaLength=p,x.hemiLength=m,x.numDirectionalShadows=f,x.numPointShadows=g,x.numSpotShadows=v,x.numSpotMaps=y,r.version=cy++)},setupView:function(e,t){let n=0,i=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=r.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=r.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=r.rectArea[c];e.position.setFromMatrixPosition(h.matrixWorld),e.position.applyMatrix4(d),s.identity(),a.copy(h.matrixWorld),a.premultiply(d),s.extractRotation(a),e.halfWidth.set(.5*h.width,0,0),e.halfHeight.set(0,.5*h.height,0),e.halfWidth.applyMatrix4(s),e.halfHeight.applyMatrix4(s),c++}else if(h.isPointLight){const e=r.point[i];e.position.setFromMatrixPosition(h.matrixWorld),e.position.applyMatrix4(d),i++}else if(h.isHemisphereLight){const e=r.hemi[u];e.direction.setFromMatrixPosition(h.matrixWorld),e.direction.transformDirection(d),u++}}},state:r}}function hy(e,t){const n=new dy(e,t),i=[],r=[];return{init:function(){i.length=0,r.length=0},state:{lightsArray:i,shadowsArray:r,lights:n},setupLights:function(e){n.setup(i,e)},setupLightsView:function(e){n.setupView(i,e)},pushLight:function(e){i.push(e)},pushShadow:function(e){r.push(e)}}}function py(e,t){let n=new WeakMap;return{get:function(i,r=0){const o=n.get(i);let a;return void 0===o?(a=new hy(e,t),n.set(i,[a])):r>=o.length?(a=new hy(e,t),o.push(a)):a=o[r],a},dispose:function(){n=new WeakMap}}}class my extends Vm{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=nh,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 fy extends Vm{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.referencePosition=new Cp,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 gy(e,t,n){let i=new Zf;const r=new Kh,o=new Kh,a=new xp,s=new my({depthPacking:ih}),l=new fy,c={},u=n.maxTextureSize,d={0:Uc,1:Fc,2:zc},h=new Bf({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Kh},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 pf;m.setAttribute("position",new Ym(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const f=new Of(m,h),g=this;function v(n,i){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 wp(r.x,r.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(i,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(i,null,o,p,f,null)}function y(t,n,i,r,o,a){let u=null;const h=!0===i.isPointLight?t.customDistanceMaterial:t.customDepthMaterial;if(u=void 0!==h?h:!0===i.isPointLight?l:s,e.localClippingEnabled&&!0===n.clipShadows&&Array.isArray(n.clippingPlanes)&&0!==n.clippingPlanes.length||n.displacementMap&&0!==n.displacementScale||n.alphaMap&&n.alphaTest>0){const e=u.uuid,t=n.uuid;let i=c[e];void 0===i&&(i={},c[e]=i);let r=i[t];void 0===r&&(r=u.clone(),i[t]=r),u=r}return u.visible=n.visible,u.wireframe=n.wireframe,u.side=a===Bc?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===i.isPointLight&&!0===u.isMeshDistanceMaterial&&(u.referencePosition.setFromMatrixPosition(i.matrixWorld),u.nearDistance=r,u.farDistance=o),u}function _(n,r,o,a,s){if(!1===n.visible)return;if(n.layers.test(r.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&s===Bc)&&(!n.frustumCulled||i.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(o.matrixWorldInverse,n.matrixWorld);const i=t.update(n),r=n.material;if(Array.isArray(r)){const t=i.groups;for(let l=0,c=t.length;l<c;l++){const c=t[l],u=r[c.materialIndex];if(u&&u.visible){const t=y(n,u,a,o.near,o.far,s);e.renderBufferDirect(o,null,i,t,n,c)}}}else if(r.visible){const t=y(n,r,a,o.near,o.far,s);e.renderBufferDirect(o,null,i,t,n,null)}}const l=n.children;for(let e=0,t=l.length;e<t;e++)_(l[e],r,o,a,s)}this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Dc,this.render=function(t,n,s){if(!1===g.enabled)return;if(!1===g.autoUpdate&&!1===g.needsUpdate)return;if(0===t.length)return;const l=e.getRenderTarget(),c=e.getActiveCubeFace(),d=e.getActiveMipmapLevel(),h=e.state;h.setBlending(Gc),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;r.copy(d.mapSize);const p=d.getFrameExtents();if(r.multiply(p),o.copy(d.mapSize),(r.x>u||r.y>u)&&(r.x>u&&(o.x=Math.floor(u/p.x),r.x=o.x*p.x,d.mapSize.x=o.x),r.y>u&&(o.y=Math.floor(u/p.y),r.y=o.y*p.y,d.mapSize.y=o.y)),null===d.map){const e=this.type!==Bc?{minFilter:Du,magFilter:Du}:{};d.map=new wp(r.x,r.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);a.set(o.x*t.x,o.y*t.y,o.x*t.z,o.y*t.w),h.viewport(a),d.updateMatrices(c,e),i=d.getFrustum(),_(n,s,d.camera,c,this.type)}!0!==d.isPointLightShadow&&this.type===Bc&&v(d,s),d.needsUpdate=!1}g.needsUpdate=!1,e.setRenderTarget(l,c,d)}}function vy(e,t,n){const i=n.isWebGL2;const r=new function(){let t=!1;const n=new xp;let i=null;const r=new xp(0,0,0,0);return{setMask:function(n){i===n||t||(e.colorMask(n,n,n,n),i=n)},setLocked:function(e){t=e},setClear:function(t,i,o,a,s){!0===s&&(t*=a,i*=a,o*=a),n.set(t,i,o,a),!1===r.equals(n)&&(e.clearColor(t,i,o,a),r.copy(n))},reset:function(){t=!1,i=null,r.set(-1,0,0,0)}}},o=new function(){let t=!1,n=null,i=null,r=null;return{setTest:function(e){e?z(2929):G(2929)},setMask:function(i){n===i||t||(e.depthMask(i),n=i)},setFunc:function(t){if(i!==t){if(t)switch(t){case cu:e.depthFunc(512);break;case uu:e.depthFunc(519);break;case du:e.depthFunc(513);break;case hu:e.depthFunc(515);break;case pu:e.depthFunc(514);break;case mu:e.depthFunc(518);break;case fu:e.depthFunc(516);break;case gu:e.depthFunc(517);break;default:e.depthFunc(515)}else e.depthFunc(515);i=t}},setLocked:function(e){t=e},setClear:function(t){r!==t&&(e.clearDepth(t),r=t)},reset:function(){t=!1,n=null,i=null,r=null}}},a=new function(){let t=!1,n=null,i=null,r=null,o=null,a=null,s=null,l=null,c=null;return{setTest:function(e){t||(e?z(2960):G(2960))},setMask:function(i){n===i||t||(e.stencilMask(i),n=i)},setFunc:function(t,n,a){i===t&&r===n&&o===a||(e.stencilFunc(t,n,a),i=t,r=n,o=a)},setOp:function(t,n,i){a===t&&s===n&&l===i||(e.stencilOp(t,n,i),a=t,s=n,l=i)},setLocked:function(e){t=e},setClear:function(t){c!==t&&(e.clearStencil(t),c=t)},reset:function(){t=!1,n=null,i=null,r=null,o=null,a=null,s=null,l=null,c=null}}},s=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,b=null,x=null,w=!1,S=null,E=null,A=null,T=null,I=null;const M=e.getParameter(35661);let C=!1,N=0;const O=e.getParameter(7938);-1!==O.indexOf("WebGL")?(N=parseFloat(/^WebGL (\d)/.exec(O)[1]),C=N>=1):-1!==O.indexOf("OpenGL ES")&&(N=parseFloat(/^OpenGL ES (\d)/.exec(O)[1]),C=N>=2);let R=null,L={};const P=e.getParameter(3088),D=e.getParameter(2978),k=(new xp).fromArray(P),B=(new xp).fromArray(D);function F(t,n,i){const r=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<i;t++)e.texImage2D(n+t,0,6408,1,1,0,6408,5121,r);return o}const U={};function z(t){!0!==c[t]&&(e.enable(t),c[t]=!0)}function G(t){!1!==c[t]&&(e.disable(t),c[t]=!1)}U[3553]=F(3553,3553,1),U[34067]=F(34067,34069,6),r.setClear(0,0,0,1),o.setClear(1),a.setClear(0),z(2929),o.setFunc(hu),W(!1),q(Oc),z(2884),V(Gc);const j={[$c]:32774,[Yc]:32778,[Jc]:32779};if(i)j[Zc]=32775,j[Xc]=32776;else{const e=t.get("EXT_blend_minmax");null!==e&&(j[Zc]=e.MIN_EXT,j[Xc]=e.MAX_EXT)}const H={[Kc]:0,[Qc]:1,[eu]:768,[nu]:770,[lu]:776,[au]:774,[ru]:772,[tu]:769,[iu]:771,[su]:775,[ou]:773};function V(t,n,i,r,o,a,s,l){if(t!==Gc){if(!1===m&&(z(3042),m=!0),t===qc)o=o||n,a=a||i,s=s||r,n===g&&o===_||(e.blendEquationSeparate(j[n],j[o]),g=n,_=o),i===v&&r===y&&a===b&&s===x||(e.blendFuncSeparate(H[i],H[r],H[a],H[s]),v=i,y=r,b=a,x=s),f=t,w=null;else if(t!==f||l!==w){if(g===$c&&_===$c||(e.blendEquation(32774),g=$c,_=$c),l)switch(t){case jc:e.blendFuncSeparate(1,771,1,771);break;case Hc:e.blendFunc(1,1);break;case Vc:e.blendFuncSeparate(0,769,0,1);break;case Wc:e.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",t)}else switch(t){case jc:e.blendFuncSeparate(770,771,1,771);break;case Hc:e.blendFunc(770,1);break;case Vc:e.blendFuncSeparate(0,769,0,1);break;case Wc:e.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",t)}v=null,y=null,b=null,x=null,f=t,w=l}}else!0===m&&(G(3042),m=!1)}function W(t){S!==t&&(t?e.frontFace(2304):e.frontFace(2305),S=t)}function q(t){t!==Nc?(z(2884),t!==E&&(t===Oc?e.cullFace(1029):t===Rc?e.cullFace(1028):e.cullFace(1032))):G(2884),E=t}function $(t,n,i){t?(z(32823),T===n&&I===i||(e.polygonOffset(n,i),T=n,I=i)):G(32823)}function Y(t){void 0===t&&(t=33984+M-1),R!==t&&(e.activeTexture(t),R=t)}return{buffers:{color:r,depth:o,stencil:a},enable:z,disable:G,bindFramebuffer:function(t,n){return u[t]!==n&&(e.bindFramebuffer(t,n),u[t]=n,i&&(36009===t&&(u[36160]=n),36160===t&&(u[36009]=n)),!0)},drawBuffers:function(i,r){let o=h,a=!1;if(i)if(o=d.get(r),void 0===o&&(o=[],d.set(r,o)),i.isWebGLMultipleRenderTargets){const e=i.texture;if(o.length!==e.length||36064!==o[0]){for(let t=0,n=e.length;t<n;t++)o[t]=36064+t;o.length=e.length,a=!0}}else 36064!==o[0]&&(o[0]=36064,a=!0);else 1029!==o[0]&&(o[0]=1029,a=!0);a&&(n.isWebGL2?e.drawBuffers(o):t.get("WEBGL_draw_buffers").drawBuffersWEBGL(o))},useProgram:function(t){return p!==t&&(e.useProgram(t),p=t,!0)},setBlending:V,setMaterial:function(e,t){e.side===zc?G(2884):z(2884);let n=e.side===Uc;t&&(n=!n),W(n),e.blending===jc&&!1===e.transparent?V(Gc):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),r.setMask(e.colorWrite);const i=e.stencilWrite;a.setTest(i),i&&(a.setMask(e.stencilWriteMask),a.setFunc(e.stencilFunc,e.stencilRef,e.stencilFuncMask),a.setOp(e.stencilFail,e.stencilZFail,e.stencilZPass)),$(e.polygonOffset,e.polygonOffsetFactor,e.polygonOffsetUnits),!0===e.alphaToCoverage?z(32926):G(32926)},setFlipSided:W,setCullFace:q,setLineWidth:function(t){t!==A&&(C&&e.lineWidth(t),A=t)},setPolygonOffset:$,setScissorTest:function(e){e?z(3089):G(3089)},activeTexture:Y,bindTexture:function(t,n){null===R&&Y();let i=L[R];void 0===i&&(i={type:void 0,texture:void 0},L[R]=i),i.type===t&&i.texture===n||(e.bindTexture(t,n||U[t]),i.type=t,i.texture=n)},unbindTexture:function(){const t=L[R];void 0!==t&&void 0!==t.type&&(e.bindTexture(t.type,null),t.type=void 0,t.texture=void 0)},compressedTexImage2D:function(){try{e.compressedTexImage2D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texImage2D:function(){try{e.texImage2D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texImage3D:function(){try{e.texImage3D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},updateUBOMapping:function(t,n){let i=l.get(n);void 0===i&&(i=new WeakMap,l.set(n,i));let r=i.get(t);void 0===r&&(r=e.getUniformBlockIndex(n,t.name),i.set(t,r))},uniformBlockBinding:function(t,n){const i=l.get(n).get(t);s.get(t)!==i&&(e.uniformBlockBinding(n,i,t.__bindingPointIndex),s.set(t,i))},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===i&&(e.bindFramebuffer(36009,null),e.bindFramebuffer(36008,null)),e.useProgram(null),e.lineWidth(1),e.scissor(0,0,e.canvas.width,e.canvas.height),e.viewport(0,0,e.canvas.width,e.canvas.height),c={},R=null,L={},u={},d=new WeakMap,h=[],p=null,m=!1,f=null,g=null,v=null,y=null,_=null,b=null,x=null,w=!1,S=null,E=null,A=null,T=null,I=null,k.set(0,0,e.canvas.width,e.canvas.height),B.set(0,0,e.canvas.width,e.canvas.height),r.reset(),o.reset(),a.reset()}}}function yy(e,t,n,i,r,o,a){const s=r.isWebGL2,l=r.maxTextures,c=r.maxCubemapSize,u=r.maxTextureSize,d=r.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):ip("canvas")}function _(e,t,n,i){let r=1;if((e.width>i||e.height>i)&&(r=i/Math.max(e.width,e.height)),r<1||!0===t){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){const i=t?Yh:Math.floor,o=i(r*e.width),a=i(r*e.height);void 0===f&&(f=y(o,a));const s=n?y(o,a):f;s.width=o,s.height=a;return s.getContext("2d").drawImage(e,0,0,o,a),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+e.width+"x"+e.height+") to ("+o+"x"+a+")."),s}return"data"in e&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+e.width+"x"+e.height+")."),e}return e}function b(e){return qh(e.width)&&qh(e.height)}function x(e,t){return e.generateMipmaps&&t&&e.minFilter!==Du&&e.minFilter!==zu}function w(t){e.generateMipmap(t)}function S(n,i,r,o,a=!1){if(!1===s)return i;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=i;return 6403===i&&(5126===r&&(l=33326),5131===r&&(l=33325),5121===r&&(l=33321)),33319===i&&(5126===r&&(l=33328),5131===r&&(l=33327),5121===r&&(l=33323)),6408===i&&(5126===r&&(l=34836),5131===r&&(l=34842),5121===r&&(l=o===th&&!1===a?35907:32856),32819===r&&(l=32854),32820===r&&(l=32855)),33325!==l&&33326!==l&&33327!==l&&33328!==l&&34842!==l&&34836!==l||t.get("EXT_color_buffer_float"),l}function E(e,t,n){return!0===x(e,n)||e.isFramebufferTexture&&e.minFilter!==Du&&e.minFilter!==zu?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===Du||e===ku||e===Fu?9728:9729}function T(e){const t=e.target;t.removeEventListener("dispose",T),function(e){const t=i.get(e);if(void 0===t.__webglInit)return;const n=e.source,r=g.get(n);if(r){const i=r[t.__cacheKey];i.usedTimes--,0===i.usedTimes&&M(e),0===Object.keys(r).length&&g.delete(n)}i.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,r=i.get(t),o=i.get(n);void 0!==o.__webglTexture&&(e.deleteTexture(o.__webglTexture),a.memory.textures--);t.depthTexture&&t.depthTexture.dispose();if(t.isWebGLCubeRenderTarget)for(let t=0;t<6;t++)e.deleteFramebuffer(r.__webglFramebuffer[t]),r.__webglDepthbuffer&&e.deleteRenderbuffer(r.__webglDepthbuffer[t]);else{if(e.deleteFramebuffer(r.__webglFramebuffer),r.__webglDepthbuffer&&e.deleteRenderbuffer(r.__webglDepthbuffer),r.__webglMultisampledFramebuffer&&e.deleteFramebuffer(r.__webglMultisampledFramebuffer),r.__webglColorRenderbuffer)for(let t=0;t<r.__webglColorRenderbuffer.length;t++)r.__webglColorRenderbuffer[t]&&e.deleteRenderbuffer(r.__webglColorRenderbuffer[t]);r.__webglDepthRenderbuffer&&e.deleteRenderbuffer(r.__webglDepthRenderbuffer)}if(t.isWebGLMultipleRenderTargets)for(let t=0,r=n.length;t<r;t++){const r=i.get(n[t]);r.__webglTexture&&(e.deleteTexture(r.__webglTexture),a.memory.textures--),i.remove(n[t])}i.remove(n),i.remove(t)}(n)}function M(t){const n=i.get(t);e.deleteTexture(n.__webglTexture);const r=t.source;delete g.get(r)[n.__cacheKey],a.memory.textures--}let C=0;function N(e,t){const r=i.get(e);if(e.isVideoTexture&&function(e){const t=a.render.frame;m.get(e)!==t&&(m.set(e,t),e.update())}(e),!1===e.isRenderTargetTexture&&e.version>0&&r.__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 D(r,e,t);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}n.activeTexture(33984+t),n.bindTexture(3553,r.__webglTexture)}const O={[Ru]:10497,[Lu]:33071,[Pu]:33648},R={[Du]:9728,[ku]:9984,[Fu]:9986,[zu]:9729,[Gu]:9985,[Hu]:9987};function L(n,o,a){if(a?(e.texParameteri(n,10242,O[o.wrapS]),e.texParameteri(n,10243,O[o.wrapT]),32879!==n&&35866!==n||e.texParameteri(n,32882,O[o.wrapR]),e.texParameteri(n,10240,R[o.magFilter]),e.texParameteri(n,10241,R[o.minFilter])):(e.texParameteri(n,10242,33071),e.texParameteri(n,10243,33071),32879!==n&&35866!==n||e.texParameteri(n,32882,33071),o.wrapS===Lu&&o.wrapT===Lu||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!==Du&&o.minFilter!==zu&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),!0===t.has("EXT_texture_filter_anisotropic")){const a=t.get("EXT_texture_filter_anisotropic");if(o.type===Xu&&!1===t.has("OES_texture_float_linear"))return;if(!1===s&&o.type===Ku&&!1===t.has("OES_texture_half_float_linear"))return;(o.anisotropy>1||i.get(o).__currentAnisotropy)&&(e.texParameterf(n,a.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(o.anisotropy,r.getMaxAnisotropy())),i.get(o).__currentAnisotropy=o.anisotropy)}}function P(t,n){let i=!1;void 0===t.__webglInit&&(t.__webglInit=!0,n.addEventListener("dispose",T));const r=n.source;let o=g.get(r);void 0===o&&(o={},g.set(r,o));const s=function(e){const t=[];return t.push(e.wrapS),t.push(e.wrapT),t.push(e.magFilter),t.push(e.minFilter),t.push(e.anisotropy),t.push(e.internalFormat),t.push(e.format),t.push(e.type),t.push(e.generateMipmaps),t.push(e.premultiplyAlpha),t.push(e.flipY),t.push(e.unpackAlignment),t.push(e.encoding),t.join()}(n);if(s!==t.__cacheKey){void 0===o[s]&&(o[s]={texture:e.createTexture(),usedTimes:0},a.memory.textures++,i=!0),o[s].usedTimes++;const r=o[t.__cacheKey];void 0!==r&&(o[t.__cacheKey].usedTimes--,0===r.usedTimes&&M(n)),t.__cacheKey=s,t.__webglTexture=o[s].texture}return i}function D(t,i,r){let a=3553;i.isDataArrayTexture&&(a=35866),i.isData3DTexture&&(a=32879);const l=P(t,i),c=i.source;if(n.activeTexture(33984+r),n.bindTexture(a,t.__webglTexture),c.version!==c.__currentVersion||!0===l){e.pixelStorei(37440,i.flipY),e.pixelStorei(37441,i.premultiplyAlpha),e.pixelStorei(3317,i.unpackAlignment),e.pixelStorei(37443,0);const t=function(e){return!s&&(e.wrapS!==Lu||e.wrapT!==Lu||e.minFilter!==Du&&e.minFilter!==zu)}(i)&&!1===b(i.image);let r=_(i.image,t,!1,u);r=G(i,r);const d=b(r)||s,h=o.convert(i.format,i.encoding);let p,m=o.convert(i.type),f=S(i.internalFormat,h,m,i.encoding,i.isVideoTexture);L(a,i,d);const g=i.mipmaps,v=s&&!0!==i.isVideoTexture,y=void 0===c.__currentVersion||!0===l,A=E(i,r,d);if(i.isDepthTexture)f=6402,s?f=i.type===Xu?36012:i.type===Zu?33190:i.type===td?35056:33189:i.type===Xu&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),i.format===sd&&6402===f&&i.type!==Yu&&i.type!==Zu&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),i.type=Zu,m=o.convert(i.type)),i.format===ld&&6402===f&&(f=34041,i.type!==td&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),i.type=td,m=o.convert(i.type))),y&&(v?n.texStorage2D(3553,1,f,r.width,r.height):n.texImage2D(3553,0,f,r.width,r.height,0,h,m,null));else if(i.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);i.generateMipmaps=!1}else v?(y&&n.texStorage2D(3553,A,f,r.width,r.height),n.texSubImage2D(3553,0,0,0,r.width,r.height,h,m,r.data)):n.texImage2D(3553,0,f,r.width,r.height,0,h,m,r.data);else if(i.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],i.format!==rd?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(i.isDataArrayTexture)v?(y&&n.texStorage3D(35866,A,f,r.width,r.height,r.depth),n.texSubImage3D(35866,0,0,0,0,r.width,r.height,r.depth,h,m,r.data)):n.texImage3D(35866,0,f,r.width,r.height,r.depth,0,h,m,r.data);else if(i.isData3DTexture)v?(y&&n.texStorage3D(32879,A,f,r.width,r.height,r.depth),n.texSubImage3D(32879,0,0,0,0,r.width,r.height,r.depth,h,m,r.data)):n.texImage3D(32879,0,f,r.width,r.height,r.depth,0,h,m,r.data);else if(i.isFramebufferTexture){if(y)if(v)n.texStorage2D(3553,A,f,r.width,r.height);else{let e=r.width,t=r.height;for(let i=0;i<A;i++)n.texImage2D(3553,i,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);i.generateMipmaps=!1}else v?(y&&n.texStorage2D(3553,A,f,r.width,r.height),n.texSubImage2D(3553,0,0,0,h,m,r)):n.texImage2D(3553,0,f,h,m,r);x(i,d)&&w(a),c.__currentVersion=c.version,i.onUpdate&&i.onUpdate(i)}t.__version=i.version}function k(t,r,a,s,l){const c=o.convert(a.format,a.encoding),u=o.convert(a.type),d=S(a.internalFormat,c,u,a.encoding);i.get(r).__hasExternalTextures||(32879===l||35866===l?n.texImage3D(l,0,d,r.width,r.height,r.depth,0,c,u,null):n.texImage2D(l,0,d,r.width,r.height,0,c,u,null)),n.bindFramebuffer(36160,t),z(r)?h.framebufferTexture2DMultisampleEXT(36160,s,l,i.get(a).__webglTexture,0,U(r)):e.framebufferTexture2D(36160,s,l,i.get(a).__webglTexture,0),n.bindFramebuffer(36160,null)}function B(t,n,i){if(e.bindRenderbuffer(36161,t),n.depthBuffer&&!n.stencilBuffer){let r=33189;if(i||z(n)){const t=n.depthTexture;t&&t.isDepthTexture&&(t.type===Xu?r=36012:t.type===Zu&&(r=33190));const i=U(n);z(n)?h.renderbufferStorageMultisampleEXT(36161,i,r,n.width,n.height):e.renderbufferStorageMultisample(36161,i,r,n.width,n.height)}else e.renderbufferStorage(36161,r,n.width,n.height);e.framebufferRenderbuffer(36160,36096,36161,t)}else if(n.depthBuffer&&n.stencilBuffer){const r=U(n);i&&!1===z(n)?e.renderbufferStorageMultisample(36161,r,35056,n.width,n.height):z(n)?h.renderbufferStorageMultisampleEXT(36161,r,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 r=0;r<t.length;r++){const a=t[r],s=o.convert(a.format,a.encoding),l=o.convert(a.type),c=S(a.internalFormat,s,l,a.encoding),u=U(n);i&&!1===z(n)?e.renderbufferStorageMultisample(36161,u,c,n.width,n.height):z(n)?h.renderbufferStorageMultisampleEXT(36161,u,c,n.width,n.height):e.renderbufferStorage(36161,c,n.width,n.height)}}e.bindRenderbuffer(36161,null)}function F(t){const r=i.get(t),o=!0===t.isWebGLCubeRenderTarget;if(t.depthTexture&&!r.__autoAllocateDepthBuffer){if(o)throw new Error("target.depthTexture not supported in Cube render targets");!function(t,r){if(r&&r.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(36160,t),!r.depthTexture||!r.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");i.get(r.depthTexture).__webglTexture&&r.depthTexture.image.width===r.width&&r.depthTexture.image.height===r.height||(r.depthTexture.image.width=r.width,r.depthTexture.image.height=r.height,r.depthTexture.needsUpdate=!0),N(r.depthTexture,0);const o=i.get(r.depthTexture).__webglTexture,a=U(r);if(r.depthTexture.format===sd)z(r)?h.framebufferTexture2DMultisampleEXT(36160,36096,3553,o,0,a):e.framebufferTexture2D(36160,36096,3553,o,0);else{if(r.depthTexture.format!==ld)throw new Error("Unknown depthTexture format");z(r)?h.framebufferTexture2DMultisampleEXT(36160,33306,3553,o,0,a):e.framebufferTexture2D(36160,33306,3553,o,0)}}(r.__webglFramebuffer,t)}else if(o){r.__webglDepthbuffer=[];for(let i=0;i<6;i++)n.bindFramebuffer(36160,r.__webglFramebuffer[i]),r.__webglDepthbuffer[i]=e.createRenderbuffer(),B(r.__webglDepthbuffer[i],t,!1)}else n.bindFramebuffer(36160,r.__webglFramebuffer),r.__webglDepthbuffer=e.createRenderbuffer(),B(r.__webglDepthbuffer,t,!1);n.bindFramebuffer(36160,null)}function U(e){return Math.min(d,e.samples)}function z(e){const n=i.get(e);return s&&e.samples>0&&!0===t.has("WEBGL_multisampled_render_to_texture")&&!1!==n.__useRenderToTexture}function G(e,n){const i=e.encoding,r=e.format,o=e.type;return!0===e.isCompressedTexture||!0===e.isVideoTexture||e.format===kh||i!==eh&&(i===th?!1===s?!0===t.has("EXT_sRGB")&&r===rd?(e.format=kh,e.minFilter=zu,e.generateMipmaps=!1):n=gp.sRGBToLinear(n):r===rd&&o===Wu||console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",i)),n}this.allocateTextureUnit=function(){const e=C;return e>=l&&console.warn("THREE.WebGLTextures: Trying to use "+e+" texture units while this GPU supports only "+l),C+=1,e},this.resetTextureUnits=function(){C=0},this.setTexture2D=N,this.setTexture2DArray=function(e,t){const r=i.get(e);e.version>0&&r.__version!==e.version?D(r,e,t):(n.activeTexture(33984+t),n.bindTexture(35866,r.__webglTexture))},this.setTexture3D=function(e,t){const r=i.get(e);e.version>0&&r.__version!==e.version?D(r,e,t):(n.activeTexture(33984+t),n.bindTexture(32879,r.__webglTexture))},this.setTextureCube=function(t,r){const a=i.get(t);t.version>0&&a.__version!==t.version?function(t,i,r){if(6!==i.image.length)return;const a=P(t,i),l=i.source;if(n.activeTexture(33984+r),n.bindTexture(34067,t.__webglTexture),l.version!==l.__currentVersion||!0===a){e.pixelStorei(37440,i.flipY),e.pixelStorei(37441,i.premultiplyAlpha),e.pixelStorei(3317,i.unpackAlignment),e.pixelStorei(37443,0);const t=i.isCompressedTexture||i.image[0].isCompressedTexture,r=i.image[0]&&i.image[0].isDataTexture,u=[];for(let e=0;e<6;e++)u[e]=t||r?r?i.image[e].image:i.image[e]:_(i.image[e],!1,!0,c),u[e]=G(i,u[e]);const d=u[0],h=b(d)||s,p=o.convert(i.format,i.encoding),m=o.convert(i.type),f=S(i.internalFormat,p,m,i.encoding),g=s&&!0!==i.isVideoTexture,v=void 0===l.__currentVersion||!0===a;let y,A=E(i,d,h);if(L(34067,i,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 r=y[t];i.format!==rd?null!==p?g?n.compressedTexSubImage2D(34069+e,t,0,0,r.width,r.height,p,r.data):n.compressedTexImage2D(34069+e,t,f,r.width,r.height,0,r.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):g?n.texSubImage2D(34069+e,t,0,0,r.width,r.height,p,m,r.data):n.texImage2D(34069+e,t,f,r.width,r.height,0,p,m,r.data)}}}else{y=i.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(r){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 i=y[t].image[e].image;g?n.texSubImage2D(34069+e,t+1,0,0,i.width,i.height,p,m,i.data):n.texImage2D(34069+e,t+1,f,i.width,i.height,0,p,m,i.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 i=y[t];g?n.texSubImage2D(34069+e,t+1,0,0,p,m,i.image[e]):n.texImage2D(34069+e,t+1,f,p,m,i.image[e])}}}x(i,h)&&w(34067),l.__currentVersion=l.version,i.onUpdate&&i.onUpdate(i)}t.__version=i.version}(a,t,r):(n.activeTexture(33984+r),n.bindTexture(34067,a.__webglTexture))},this.rebindTextures=function(e,t,n){const r=i.get(e);void 0!==t&&k(r.__webglFramebuffer,e,e.texture,36064,3553),void 0!==n&&F(e)},this.setupRenderTarget=function(t){const l=t.texture,c=i.get(t),u=i.get(l);t.addEventListener("dispose",I),!0!==t.isWebGLMultipleRenderTargets&&(void 0===u.__webglTexture&&(u.__webglTexture=e.createTexture()),u.__version=l.version,a.memory.textures++);const d=!0===t.isWebGLCubeRenderTarget,h=!0===t.isWebGLMultipleRenderTargets,p=b(t)||s;if(d){c.__webglFramebuffer=[];for(let t=0;t<6;t++)c.__webglFramebuffer[t]=e.createFramebuffer()}else{if(c.__webglFramebuffer=e.createFramebuffer(),h)if(r.drawBuffers){const n=t.texture;for(let t=0,r=n.length;t<r;t++){const r=i.get(n[t]);void 0===r.__webglTexture&&(r.__webglTexture=e.createTexture(),a.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(s&&t.samples>0&&!1===z(t)){const i=h?l:[l];c.__webglMultisampledFramebuffer=e.createFramebuffer(),c.__webglColorRenderbuffer=[],n.bindFramebuffer(36160,c.__webglMultisampledFramebuffer);for(let n=0;n<i.length;n++){const r=i[n];c.__webglColorRenderbuffer[n]=e.createRenderbuffer(),e.bindRenderbuffer(36161,c.__webglColorRenderbuffer[n]);const a=o.convert(r.format,r.encoding),s=o.convert(r.type),l=S(r.internalFormat,a,s,r.encoding),u=U(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),L(34067,l,p);for(let e=0;e<6;e++)k(c.__webglFramebuffer[e],t,l,36064,34069+e);x(l,p)&&w(34067),n.unbindTexture()}else if(h){const e=t.texture;for(let r=0,o=e.length;r<o;r++){const o=e[r],a=i.get(o);n.bindTexture(3553,a.__webglTexture),L(3553,o,p),k(c.__webglFramebuffer,t,o,36064+r,3553),x(o,p)&&w(3553)}n.unbindTexture()}else{let e=3553;(t.isWebGL3DRenderTarget||t.isWebGLArrayRenderTarget)&&(s?e=t.isWebGL3DRenderTarget?32879:35866:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),n.bindTexture(e,u.__webglTexture),L(e,l,p),k(c.__webglFramebuffer,t,l,36064,e),x(l,p)&&w(e),n.unbindTexture()}t.depthBuffer&&F(t)},this.updateRenderTargetMipmap=function(e){const t=b(e)||s,r=!0===e.isWebGLMultipleRenderTargets?e.texture:[e.texture];for(let o=0,a=r.length;o<a;o++){const a=r[o];if(x(a,t)){const t=e.isWebGLCubeRenderTarget?34067:3553,r=i.get(a).__webglTexture;n.bindTexture(t,r),w(t),n.unbindTexture()}}},this.updateMultisampleRenderTarget=function(t){if(s&&t.samples>0&&!1===z(t)){const r=t.isWebGLMultipleRenderTargets?t.texture:[t.texture],o=t.width,a=t.height;let s=16384;const l=[],c=t.stencilBuffer?33306:36096,u=i.get(t),d=!0===t.isWebGLMultipleRenderTargets;if(d)for(let t=0;t<r.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<r.length;n++){l.push(36064+n),t.depthBuffer&&l.push(c);const h=void 0!==u.__ignoreDepthValues&&u.__ignoreDepthValues;if(!1===h&&(t.depthBuffer&&(s|=256),t.stencilBuffer&&(s|=1024)),d&&e.framebufferRenderbuffer(36008,36064,36161,u.__webglColorRenderbuffer[n]),!0===h&&(e.invalidateFramebuffer(36008,[c]),e.invalidateFramebuffer(36009,[c])),d){const t=i.get(r[n]).__webglTexture;e.framebufferTexture2D(36009,36064,3553,t,0)}e.blitFramebuffer(0,0,o,a,0,0,o,a,s,9728),p&&e.invalidateFramebuffer(36008,l)}if(n.bindFramebuffer(36008,null),n.bindFramebuffer(36009,null),d)for(let t=0;t<r.length;t++){n.bindFramebuffer(36160,u.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(36160,36064+t,36161,u.__webglColorRenderbuffer[t]);const o=i.get(r[t]).__webglTexture;n.bindFramebuffer(36160,u.__webglFramebuffer),e.framebufferTexture2D(36009,36064+t,3553,o,0)}n.bindFramebuffer(36009,u.__webglMultisampledFramebuffer)}},this.setupDepthRenderbuffer=F,this.setupFrameBufferTexture=k,this.useMultisampledRTT=z}function _y(e,t,n){const i=n.isWebGL2;return{convert:function(n,r=null){let o;if(n===Wu)return 5121;if(n===Qu)return 32819;if(n===ed)return 32820;if(n===qu)return 5120;if(n===$u)return 5122;if(n===Yu)return 5123;if(n===Ju)return 5124;if(n===Zu)return 5125;if(n===Xu)return 5126;if(n===Ku)return i?5131:(o=t.get("OES_texture_half_float"),null!==o?o.HALF_FLOAT_OES:null);if(n===nd)return 6406;if(n===rd)return 6408;if(n===od)return 6409;if(n===ad)return 6410;if(n===sd)return 6402;if(n===ld)return 34041;if(n===cd)return 6403;if(n===id)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===kh)return o=t.get("EXT_sRGB"),null!==o?o.SRGB_ALPHA_EXT:null;if(n===ud)return 36244;if(n===dd)return 33319;if(n===hd)return 33320;if(n===pd)return 36249;if(n===md||n===fd||n===gd||n===vd)if(r===th){if(o=t.get("WEBGL_compressed_texture_s3tc_srgb"),null===o)return null;if(n===md)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===fd)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===gd)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===vd)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else{if(o=t.get("WEBGL_compressed_texture_s3tc"),null===o)return null;if(n===md)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===fd)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===gd)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===vd)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(n===yd||n===_d||n===bd||n===xd){if(o=t.get("WEBGL_compressed_texture_pvrtc"),null===o)return null;if(n===yd)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===_d)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===bd)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===xd)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(n===wd)return o=t.get("WEBGL_compressed_texture_etc1"),null!==o?o.COMPRESSED_RGB_ETC1_WEBGL:null;if(n===Sd||n===Ed){if(o=t.get("WEBGL_compressed_texture_etc"),null===o)return null;if(n===Sd)return r===th?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(n===Ed)return r===th?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC}if(n===Ad||n===Td||n===Id||n===Md||n===Cd||n===Nd||n===Od||n===Rd||n===Ld||n===Pd||n===Dd||n===kd||n===Bd||n===Fd){if(o=t.get("WEBGL_compressed_texture_astc"),null===o)return null;if(n===Ad)return r===th?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Td)return r===th?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===Id)return r===th?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===Md)return r===th?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Cd)return r===th?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===Nd)return r===th?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===Od)return r===th?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===Rd)return r===th?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===Ld)return r===th?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===Pd)return r===th?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===Dd)return r===th?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===kd)return r===th?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Bd)return r===th?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===Fd)return r===th?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}if(n===Ud){if(o=t.get("EXT_texture_compression_bptc"),null===o)return null;if(n===Ud)return r===th?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT}return n===td?i?34042:(o=t.get("WEBGL_depth_texture"),null!==o?o.UNSIGNED_INT_24_8_WEBGL:null):void 0!==e[n]?e[n]:null}}}class by extends Uf{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class xy extends Om{constructor(){super(),this.isGroup=!0,this.type="Group"}}const wy={type:"move"};class Sy{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return null===this._hand&&(this._hand=new xy,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 xy,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Cp,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Cp),this._targetRay}getGripSpace(){return null===this._grip&&(this._grip=new xy,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Cp,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Cp),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 i=null,r=null,o=null;const a=this._targetRay,s=this._grip,l=this._hand;if(e&&"visible-blurred"!==t.session.visibilityState){if(l&&e.hand){o=!0;for(const i of e.hand.values()){const e=t.getJointPose(i,n);if(void 0===l.joints[i.jointName]){const e=new xy;e.matrixAutoUpdate=!1,e.visible=!1,l.joints[i.jointName]=e,l.add(e)}const r=l.joints[i.jointName];null!==e&&(r.matrix.fromArray(e.transform.matrix),r.matrix.decompose(r.position,r.rotation,r.scale),r.jointRadius=e.radius),r.visible=null!==e}const i=l.joints["index-finger-tip"],r=l.joints["thumb-tip"],a=i.position.distanceTo(r.position),s=.02,c=.005;l.inputState.pinching&&a>s+c?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&a<=s-c&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else null!==s&&e.gripSpace&&(r=t.getPose(e.gripSpace,n),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));null!==a&&(i=t.getPose(e.targetRaySpace,n),null===i&&null!==r&&(i=r),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,this.dispatchEvent(wy)))}return null!==a&&(a.visible=null!==i),null!==s&&(s.visible=null!==r),null!==l&&(l.visible=null!==o),this}}class Ey extends bp{constructor(e,t,n,i,r,o,a,s,l,c){if((c=void 0!==c?c:sd)!==sd&&c!==ld)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===n&&c===sd&&(n=Zu),void 0===n&&c===ld&&(n=td),super(null,i,r,o,a,s,c,n,l),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=void 0!==a?a:Du,this.minFilter=void 0!==s?s:Du,this.flipY=!1,this.generateMipmaps=!1}}class Ay extends Bh{constructor(e,t){super();const n=this;let i=null,r=1,o=null,a="local-floor",s=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 Uf;y.layers.enable(1),y.viewport=new xp;const _=new Uf;_.layers.enable(2),_.viewport=new xp;const b=[y,_],x=new by;x.layers.enable(1),x.layers.enable(2);let w=null,S=null;function E(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(){i.removeEventListener("select",E),i.removeEventListener("selectstart",E),i.removeEventListener("selectend",E),i.removeEventListener("squeeze",E),i.removeEventListener("squeezestart",E),i.removeEventListener("squeezeend",E),i.removeEventListener("end",A),i.removeEventListener("inputsourceschange",T);for(let e=0;e<g.length;e++){const t=v[e];null!==t&&(v[e]=null,g[e].disconnect(t))}w=null,S=null,e.setRenderTarget(m),d=null,u=null,c=null,i=null,f=null,O.stop(),n.isPresenting=!1,n.dispatchEvent({type:"sessionend"})}function T(e){for(let t=0;t<e.removed.length;t++){const n=e.removed[t],i=v.indexOf(n);i>=0&&(v[i]=null,g[i].dispatchEvent({type:"disconnected",data:n}))}for(let t=0;t<e.added.length;t++){const n=e.added[t];let i=v.indexOf(n);if(-1===i){for(let e=0;e<g.length;e++){if(e>=v.length){v.push(n),i=e;break}if(null===v[e]){v[e]=n,i=e;break}}if(-1===i)break}const r=g[i];r&&r.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 Sy,g[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=g[e];return void 0===t&&(t=new Sy,g[e]=t),t.getGripSpace()},this.getHand=function(e){let t=g[e];return void 0===t&&(t=new Sy,g[e]=t),t.getHandSpace()},this.setFramebufferScaleFactor=function(e){r=e,!0===n.isPresenting&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(e){a=e,!0===n.isPresenting&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return s||o},this.setReferenceSpace=function(e){s=e},this.getBaseLayer=function(){return null!==u?u:d},this.getBinding=function(){return c},this.getFrame=function(){return h},this.getSession=function(){return i},this.setSession=async function(l){if(i=l,null!==i){if(m=e.getRenderTarget(),i.addEventListener("select",E),i.addEventListener("selectstart",E),i.addEventListener("selectend",E),i.addEventListener("squeeze",E),i.addEventListener("squeezestart",E),i.addEventListener("squeezeend",E),i.addEventListener("end",A),i.addEventListener("inputsourceschange",T),!0!==p.xrCompatible&&await t.makeXRCompatible(),void 0===i.renderState.layers||!1===e.capabilities.isWebGL2){const n={antialias:void 0!==i.renderState.layers||p.antialias,alpha:p.alpha,depth:p.depth,stencil:p.stencil,framebufferScaleFactor:r};d=new XRWebGLLayer(i,t,n),i.updateRenderState({baseLayer:d}),f=new wp(d.framebufferWidth,d.framebufferHeight,{format:rd,type:Wu,encoding:e.outputEncoding,stencilBuffer:p.stencil})}else{let n=null,o=null,a=null;p.depth&&(a=p.stencil?35056:33190,n=p.stencil?ld:sd,o=p.stencil?td:Zu);const s={colorFormat:32856,depthFormat:a,scaleFactor:r};c=new XRWebGLBinding(i,t),u=c.createProjectionLayer(s),i.updateRenderState({layers:[u]}),f=new wp(u.textureWidth,u.textureHeight,{format:rd,type:Wu,depthTexture:new Ey(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),s=null,o=await i.requestReferenceSpace(a),O.setContext(i),O.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}};const I=new Cp,M=new Cp;function C(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===i)return;x.near=_.near=y.near=e.near,x.far=_.far=y.far=e.far,w===x.near&&S===x.far||(i.updateRenderState({depthNear:x.near,depthFar:x.far}),w=x.near,S=x.far);const t=e.parent,n=x.cameras;C(x,t);for(let e=0;e<n.length;e++)C(n[e],t);x.matrixWorld.decompose(x.position,x.quaternion,x.scale),e.matrix.copy(x.matrix),e.matrix.decompose(e.position,e.quaternion,e.scale);const r=e.children;for(let e=0,t=r.length;e<t;e++)r[e].updateMatrixWorld(!0);2===n.length?function(e,t,n){I.setFromMatrixPosition(t.matrixWorld),M.setFromMatrixPosition(n.matrixWorld);const i=I.distanceTo(M),r=t.projectionMatrix.elements,o=n.projectionMatrix.elements,a=r[14]/(r[10]-1),s=r[14]/(r[10]+1),l=(r[9]+1)/r[5],c=(r[9]-1)/r[5],u=(r[8]-1)/r[0],d=(o[8]+1)/o[0],h=a*u,p=a*d,m=i/(-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=a+m,v=s+m,y=h-f,_=p+(i-f),b=l*s/v*g,x=c*s/v*g;e.projectionMatrix.makePerspective(y,_,b,x,g,v)}(x,y,_):x.projectionMatrix.copy(y.projectionMatrix)},this.getCamera=function(){return x},this.getFoveation=function(){return null!==u?u.fixedFoveation:null!==d?d.fixedFoveation:void 0},this.setFoveation=function(e){null!==u&&(u.fixedFoveation=e),null!==d&&void 0!==d.fixedFoveation&&(d.fixedFoveation=e)};let N=null;const O=new Xf;O.setAnimationLoop((function(t,n){if(l=n.getViewerPose(s||o),h=n,null!==l){const t=l.views;null!==d&&(e.setRenderTargetFramebuffer(f,d.framebuffer),e.setRenderTarget(f));let n=!1;t.length!==x.cameras.length&&(x.cameras.length=0,n=!0);for(let i=0;i<t.length;i++){const r=t[i];let o=null;if(null!==d)o=d.getViewport(r);else{const t=c.getViewSubImage(u,r);o=t.viewport,0===i&&(e.setRenderTargetTextures(f,t.colorTexture,u.ignoreDepthValues?void 0:t.depthStencilTexture),e.setRenderTarget(f))}let a=b[i];void 0===a&&(a=new Uf,a.layers.enable(i),a.viewport=new xp,b[i]=a),a.matrix.fromArray(r.transform.matrix),a.projectionMatrix.fromArray(r.projectionMatrix),a.viewport.set(o.x,o.y,o.width,o.height),0===i&&x.matrix.copy(a.matrix),!0===n&&x.cameras.push(a)}}for(let e=0;e<g.length;e++){const t=v[e],i=g[e];null!==t&&void 0!==i&&i.update(t,n,s||o)}N&&N(t,n),h=null})),this.setAnimationLoop=function(e){N=e},this.dispose=function(){}}}function Ty(e,t){function n(n,i){n.opacity.value=i.opacity,i.color&&n.diffuse.value.copy(i.color),i.emissive&&n.emissive.value.copy(i.emissive).multiplyScalar(i.emissiveIntensity),i.map&&(n.map.value=i.map),i.alphaMap&&(n.alphaMap.value=i.alphaMap),i.bumpMap&&(n.bumpMap.value=i.bumpMap,n.bumpScale.value=i.bumpScale,i.side===Uc&&(n.bumpScale.value*=-1)),i.displacementMap&&(n.displacementMap.value=i.displacementMap,n.displacementScale.value=i.displacementScale,n.displacementBias.value=i.displacementBias),i.emissiveMap&&(n.emissiveMap.value=i.emissiveMap),i.normalMap&&(n.normalMap.value=i.normalMap,n.normalScale.value.copy(i.normalScale),i.side===Uc&&n.normalScale.value.negate()),i.specularMap&&(n.specularMap.value=i.specularMap),i.alphaTest>0&&(n.alphaTest.value=i.alphaTest);const r=t.get(i).envMap;if(r&&(n.envMap.value=r,n.flipEnvMap.value=r.isCubeTexture&&!1===r.isRenderTargetTexture?-1:1,n.reflectivity.value=i.reflectivity,n.ior.value=i.ior,n.refractionRatio.value=i.refractionRatio),i.lightMap){n.lightMap.value=i.lightMap;const t=!0!==e.physicallyCorrectLights?Math.PI:1;n.lightMapIntensity.value=i.lightMapIntensity*t}let o,a;i.aoMap&&(n.aoMap.value=i.aoMap,n.aoMapIntensity.value=i.aoMapIntensity),i.map?o=i.map:i.specularMap?o=i.specularMap:i.displacementMap?o=i.displacementMap:i.normalMap?o=i.normalMap:i.bumpMap?o=i.bumpMap:i.roughnessMap?o=i.roughnessMap:i.metalnessMap?o=i.metalnessMap:i.alphaMap?o=i.alphaMap:i.emissiveMap?o=i.emissiveMap:i.clearcoatMap?o=i.clearcoatMap:i.clearcoatNormalMap?o=i.clearcoatNormalMap:i.clearcoatRoughnessMap?o=i.clearcoatRoughnessMap:i.iridescenceMap?o=i.iridescenceMap:i.iridescenceThicknessMap?o=i.iridescenceThicknessMap:i.specularIntensityMap?o=i.specularIntensityMap:i.specularColorMap?o=i.specularColorMap:i.transmissionMap?o=i.transmissionMap:i.thicknessMap?o=i.thicknessMap:i.sheenColorMap?o=i.sheenColorMap:i.sheenRoughnessMap&&(o=i.sheenRoughnessMap),void 0!==o&&(o.isWebGLRenderTarget&&(o=o.texture),!0===o.matrixAutoUpdate&&o.updateMatrix(),n.uvTransform.value.copy(o.matrix)),i.aoMap?a=i.aoMap:i.lightMap&&(a=i.lightMap),void 0!==a&&(a.isWebGLRenderTarget&&(a=a.texture),!0===a.matrixAutoUpdate&&a.updateMatrix(),n.uv2Transform.value.copy(a.matrix))}return{refreshFogUniforms:function(e,t){e.fogColor.value.copy(t.color),t.isFog?(e.fogNear.value=t.near,e.fogFar.value=t.far):t.isFogExp2&&(e.fogDensity.value=t.density)},refreshMaterialUniforms:function(e,i,r,o,a){i.isMeshBasicMaterial||i.isMeshLambertMaterial?n(e,i):i.isMeshToonMaterial?(n(e,i),function(e,t){t.gradientMap&&(e.gradientMap.value=t.gradientMap)}(e,i)):i.isMeshPhongMaterial?(n(e,i),function(e,t){e.specular.value.copy(t.specular),e.shininess.value=Math.max(t.shininess,1e-4)}(e,i)):i.isMeshStandardMaterial?(n(e,i),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 i=t.get(n).envMap;i&&(e.envMapIntensity.value=n.envMapIntensity)}(e,i),i.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===Uc&&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,i,a)):i.isMeshMatcapMaterial?(n(e,i),function(e,t){t.matcap&&(e.matcap.value=t.matcap)}(e,i)):i.isMeshDepthMaterial?n(e,i):i.isMeshDistanceMaterial?(n(e,i),function(e,t){e.referencePosition.value.copy(t.referencePosition),e.nearDistance.value=t.nearDistance,e.farDistance.value=t.farDistance}(e,i)):i.isMeshNormalMaterial?n(e,i):i.isLineBasicMaterial?(function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity}(e,i),i.isLineDashedMaterial&&function(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}(e,i)):i.isPointsMaterial?function(e,t,n,i){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.size.value=t.size*n,e.scale.value=.5*i,t.map&&(e.map.value=t.map);t.alphaMap&&(e.alphaMap.value=t.alphaMap);t.alphaTest>0&&(e.alphaTest.value=t.alphaTest);let r;t.map?r=t.map:t.alphaMap&&(r=t.alphaMap);void 0!==r&&(!0===r.matrixAutoUpdate&&r.updateMatrix(),e.uvTransform.value.copy(r.matrix))}(e,i,r,o):i.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,i):i.isShadowMaterial?(e.color.value.copy(i.color),e.opacity.value=i.opacity):i.isShaderMaterial&&(i.uniformsNeedUpdate=!1)}}}function Iy(e,t,n,i){let r={},o={},a=[];const s=n.isWebGL2?e.getParameter(35375):0;function l(e,t,n){const i=e.value;if(void 0===n[t])return n[t]="number"==typeof i?i:i.clone(),!0;if("number"==typeof i){if(n[t]!==i)return n[t]=i,!0}else{const e=n[t];if(!1===e.equals(i))return e.copy(i),!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 i=a.indexOf(n.__bindingPointIndex);a.splice(i,1),e.deleteBuffer(r[n.id]),delete r[n.id],delete o[n.id]}return{bind:function(e,t){const n=t.program;i.uniformBlockBinding(e,n)},update:function(n,d){let h=r[n.id];void 0===h&&(!function(e){const t=e.uniforms;let n=0;const i=16;let r=0;for(let e=0,o=t.length;e<o;e++){const o=t[e],a=c(o);if(o.__data=new Float32Array(a.storage/Float32Array.BYTES_PER_ELEMENT),o.__offset=n,e>0){r=n%i;0!==r&&i-r-a.boundary<0&&(n+=i-r,o.__offset=n)}n+=a.storage}r=n%i,r>0&&(n+=i-r);e.__size=n,e.__cache={}}(n),h=function(t){const n=function(){for(let e=0;e<s;e++)if(-1===a.indexOf(e))return a.push(e),e;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}();t.__bindingPointIndex=n;const i=e.createBuffer(),r=t.__size,o=t.usage;return e.bindBuffer(35345,i),e.bufferData(35345,r,o),e.bindBuffer(35345,null),e.bindBufferBase(35345,n,i),i}(n),r[n.id]=h,n.addEventListener("dispose",u));const p=d.program;i.updateUBOMapping(n,p);const m=t.render.frame;o[n.id]!==m&&(!function(t){const n=r[t.id],i=t.uniforms,o=t.__cache;e.bindBuffer(35345,n);for(let t=0,n=i.length;t<n;t++){const n=i[t];if(!0===l(n,t,o)){const t=n.value,i=n.__offset;"number"==typeof t?(n.__data[0]=t,e.bufferSubData(35345,i,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,i,n.__data))}}e.bindBuffer(35345,null)}(n),o[n.id]=m)},dispose:function(){for(const t in r)e.deleteBuffer(r[t]);a=[],r={},o={}}}}function My(e={}){this.isWebGLRenderer=!0;const t=void 0!==e.canvas?e.canvas:function(){const e=ip("canvas");return e.style.display="block",e}(),n=void 0!==e.context?e.context:null,i=void 0===e.depth||e.depth,r=void 0===e.stencil||e.stencil,o=void 0!==e.antialias&&e.antialias,a=void 0===e.premultipliedAlpha||e.premultipliedAlpha,s=void 0!==e.preserveDrawingBuffer&&e.preserveDrawingBuffer,l=void 0!==e.powerPreference?e.powerPreference:"default",c=void 0!==e.failIfMajorPerformanceCaveat&&e.failIfMajorPerformanceCaveat;let u;u=null!==n?n.getContextAttributes().alpha:void 0!==e.alpha&&e.alpha;let d=null,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=eh,this.physicallyCorrectLights=!1,this.toneMapping=bu,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,b=-1,x=null;const w=new xp,S=new xp;let E=null,A=t.width,T=t.height,I=1,M=null,C=null;const N=new xp(0,0,A,T),O=new xp(0,0,A,T);let R=!1;const L=new Zf;let P=!1,D=!1,k=null;const B=new am,F=new Kh,U=new Cp,z={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function G(){return null===_?I:1}let j,H,V,W,q,$,Y,J,Z,X,K,Q,ee,te,ne,ie,re,oe,ae,se,le,ce,ue,de,he=n;function pe(e,n){for(let i=0;i<e.length;i++){const r=e[i],o=t.getContext(r,n);if(null!==o)return o}return null}try{const e={alpha:!0,depth:i,stencil:r,antialias:o,premultipliedAlpha:a,preserveDrawingBuffer:s,powerPreference:l,failIfMajorPerformanceCaveat:c};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Ic}`),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(){j=new Ag(he),H=new ag(he,j,e),j.init(H),ce=new _y(he,j,H),V=new vy(he,j,H),W=new Mg,q=new iy,$=new yy(he,j,V,q,H,ce,W),Y=new lg(f),J=new Eg(f),Z=new Kf(he,H),ue=new rg(he,j,Z,H),X=new Tg(he,Z,W,ue),K=new Rg(he,X,Z,W),ae=new Og(he,H,$),ie=new sg(q),Q=new ny(f,Y,J,j,H,ue,ie),ee=new Ty(f,q),te=new sy,ne=new py(j,H),oe=new ig(f,Y,V,K,u,a),re=new gy(f,K,H),de=new Iy(he,W,H,V),se=new og(he,j,W,H),le=new Ig(he,j,W,H),W.programs=Q.programs,f.capabilities=H,f.extensions=j,f.properties=q,f.renderLists=te,f.shadowMap=re,f.state=V,f.info=W}me();const fe=new Ay(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=re.enabled,n=re.autoUpdate,i=re.needsUpdate,r=re.type;me(),W.autoReset=e,re.enabled=t,re.autoUpdate=n,re.needsUpdate=i,re.type=r}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){Q.releaseProgram(e)})),e.isShaderMaterial&&Q.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=j.get("WEBGL_lose_context");e&&e.loseContext()},this.forceContextRestore=function(){const e=j.get("WEBGL_lose_context");e&&e.restoreContext()},this.getPixelRatio=function(){return I},this.setPixelRatio=function(e){void 0!==e&&(I=e,this.setSize(A,T,!1))},this.getSize=function(e){return e.set(A,T)},this.setSize=function(e,n,i){fe.isPresenting?console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting."):(A=e,T=n,t.width=Math.floor(e*I),t.height=Math.floor(n*I),!1!==i&&(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,T*I).floor()},this.setDrawingBufferSize=function(e,n,i){A=e,T=n,I=i,t.width=Math.floor(e*i),t.height=Math.floor(n*i),this.setViewport(0,0,e,n)},this.getCurrentViewport=function(e){return e.copy(w)},this.getViewport=function(e){return e.copy(N)},this.setViewport=function(e,t,n,i){e.isVector4?N.set(e.x,e.y,e.z,e.w):N.set(e,t,n,i),V.viewport(w.copy(N).multiplyScalar(I).floor())},this.getScissor=function(e){return e.copy(O)},this.setScissor=function(e,t,n,i){e.isVector4?O.set(e.x,e.y,e.z,e.w):O.set(e,t,n,i),V.scissor(S.copy(O).multiplyScalar(I).floor())},this.getScissorTest=function(){return R},this.setScissorTest=function(e){V.setScissorTest(R=e)},this.setOpaqueSort=function(e){M=e},this.setTransparentSort=function(e){C=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 i=0;e&&(i|=16384),t&&(i|=256),n&&(i|=1024),he.clear(i)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",ge,!1),t.removeEventListener("webglcontextrestored",ve,!1),t.removeEventListener("webglcontextcreationerror",ye,!1),te.dispose(),ne.dispose(),q.dispose(),Y.dispose(),J.dispose(),K.dispose(),ue.dispose(),de.dispose(),Q.dispose(),fe.dispose(),fe.removeEventListener("sessionstart",xe),fe.removeEventListener("sessionend",we),k&&(k.dispose(),k=null),Se.stop()},this.renderBufferDirect=function(e,t,n,i,r,o){null===t&&(t=z);const a=r.isMesh&&r.matrixWorld.determinant()<0,s=function(e,t,n,i,r){!0!==t.isScene&&(t=z);$.resetTextureUnits();const o=t.fog,a=i.isMeshStandardMaterial?t.environment:null,s=null===_?f.outputEncoding:!0===_.isXRRenderTarget?_.texture.encoding:eh,l=(i.isMeshStandardMaterial?J:Y).get(i.envMap||a),c=!0===i.vertexColors&&!!n.attributes.color&&4===n.attributes.color.itemSize,u=!!i.normalMap&&!!n.attributes.tangent,d=!!n.morphAttributes.position,p=!!n.morphAttributes.normal,m=!!n.morphAttributes.color,g=i.toneMapped?f.toneMapping:bu,v=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,y=void 0!==v?v.length:0,w=q.get(i),S=h.state.lights;if(!0===P&&(!0===D||e!==x)){const t=e===x&&i.id===b;ie.setState(i,e,t)}let E=!1;i.version===w.__version?w.needsLights&&w.lightsStateVersion!==S.state.version||w.outputEncoding!==s||r.isInstancedMesh&&!1===w.instancing?E=!0:r.isInstancedMesh||!0!==w.instancing?r.isSkinnedMesh&&!1===w.skinning?E=!0:r.isSkinnedMesh||!0!==w.skinning?w.envMap!==l||!0===i.fog&&w.fog!==o?E=!0:void 0===w.numClippingPlanes||w.numClippingPlanes===ie.numPlanes&&w.numIntersection===ie.numIntersection?(w.vertexAlphas!==c||w.vertexTangents!==u||w.morphTargets!==d||w.morphNormals!==p||w.morphColors!==m||w.toneMapping!==g||!0===H.isWebGL2&&w.morphTargetsCount!==y)&&(E=!0):E=!0:E=!0:E=!0:(E=!0,w.__version=i.version);let A=w.currentProgram;!0===E&&(A=Me(i,t,r));let M=!1,C=!1,N=!1;const O=A.getUniforms(),R=w.uniforms;V.useProgram(A.program)&&(M=!0,C=!0,N=!0);i.id!==b&&(b=i.id,C=!0);if(M||x!==e){if(O.setValue(he,"projectionMatrix",e.projectionMatrix),H.logarithmicDepthBuffer&&O.setValue(he,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),x!==e&&(x=e,C=!0,N=!0),i.isShaderMaterial||i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshStandardMaterial||i.envMap){const t=O.map.cameraPosition;void 0!==t&&t.setValue(he,U.setFromMatrixPosition(e.matrixWorld))}(i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial)&&O.setValue(he,"isOrthographic",!0===e.isOrthographicCamera),(i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial||i.isShadowMaterial||r.isSkinnedMesh)&&O.setValue(he,"viewMatrix",e.matrixWorldInverse)}if(r.isSkinnedMesh){O.setOptional(he,r,"bindMatrix"),O.setOptional(he,r,"bindMatrixInverse");const e=r.skeleton;e&&(H.floatVertexTextures?(null===e.boneTexture&&e.computeBoneTexture(),O.setValue(he,"boneTexture",e.boneTexture,$),O.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 L=n.morphAttributes;(void 0!==L.position||void 0!==L.normal||void 0!==L.color&&!0===H.isWebGL2)&&ae.update(r,n,i,A);(C||w.receiveShadow!==r.receiveShadow)&&(w.receiveShadow=r.receiveShadow,O.setValue(he,"receiveShadow",r.receiveShadow));i.isMeshGouraudMaterial&&null!==i.envMap&&(R.envMap.value=l,R.flipEnvMap.value=l.isCubeTexture&&!1===l.isRenderTargetTexture?-1:1);C&&(O.setValue(he,"toneMappingExposure",f.toneMappingExposure),w.needsLights&&(F=N,(B=R).ambientLightColor.needsUpdate=F,B.lightProbe.needsUpdate=F,B.directionalLights.needsUpdate=F,B.directionalLightShadows.needsUpdate=F,B.pointLights.needsUpdate=F,B.pointLightShadows.needsUpdate=F,B.spotLights.needsUpdate=F,B.spotLightShadows.needsUpdate=F,B.rectAreaLights.needsUpdate=F,B.hemisphereLights.needsUpdate=F),o&&!0===i.fog&&ee.refreshFogUniforms(R,o),ee.refreshMaterialUniforms(R,i,I,T,k),kv.upload(he,w.uniformsList,R,$));var B,F;i.isShaderMaterial&&!0===i.uniformsNeedUpdate&&(kv.upload(he,w.uniformsList,R,$),i.uniformsNeedUpdate=!1);i.isSpriteMaterial&&O.setValue(he,"center",r.center);if(O.setValue(he,"modelViewMatrix",r.modelViewMatrix),O.setValue(he,"normalMatrix",r.normalMatrix),O.setValue(he,"modelMatrix",r.matrixWorld),i.isShaderMaterial||i.isRawShaderMaterial){const e=i.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,i,r);V.setMaterial(i,a);let l=n.index;const c=n.attributes.position;if(null===l){if(void 0===c||0===c.count)return}else if(0===l.count)return;let u,d=1;!0===i.wireframe&&(l=X.getWireframeAttribute(n),d=2),ue.setup(r,i,s,n,l);let p=se;null!==l&&(u=Z.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,w=null!==o?o.count*d:1/0,S=Math.max(g,y),E=Math.min(m,g+v,y+w)-1,A=Math.max(0,E-S+1);if(0!==A){if(r.isMesh)!0===i.wireframe?(V.setLineWidth(i.wireframeLinewidth*G()),p.setMode(1)):p.setMode(4);else if(r.isLine){let e=i.linewidth;void 0===e&&(e=1),V.setLineWidth(e*G()),r.isLineSegments?p.setMode(1):r.isLineLoop?p.setMode(2):p.setMode(3)}else r.isPoints?p.setMode(0):r.isSprite&&p.setMode(4);if(r.isInstancedMesh)p.renderInstances(S,A,r.count);else if(n.isInstancedBufferGeometry){const e=Math.min(n.instanceCount,n._maxInstanceCount);p.renderInstances(S,A,e)}else p.render(S,A)}},this.compile=function(e,t){function n(e,t,n){!0===e.transparent&&e.side===zc?(e.side=Uc,e.needsUpdate=!0,Me(e,t,n),e.side=Fc,e.needsUpdate=!0,Me(e,t,n),e.side=zc):Me(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 i=t.material;if(i)if(Array.isArray(i))for(let r=0;r<i.length;r++){n(i[r],e,t)}else n(i,e,t)})),m.pop(),h=null};let be=null;function xe(){Se.stop()}function we(){Se.start()}const Se=new Xf;function Ee(e,t,n,i){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||L.intersectsSprite(e)){i&&U.setFromMatrixPosition(e.matrixWorld).applyMatrix4(B);const t=K.update(e),r=e.material;r.visible&&d.push(e,t,r,n,U.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||L.intersectsObject(e))){i&&U.setFromMatrixPosition(e.matrixWorld).applyMatrix4(B);const t=K.update(e),r=e.material;if(Array.isArray(r)){const i=t.groups;for(let o=0,a=i.length;o<a;o++){const a=i[o],s=r[a.materialIndex];s&&s.visible&&d.push(e,t,s,n,U.z,a)}}else r.visible&&d.push(e,t,r,n,U.z,null)}const r=e.children;for(let e=0,o=r.length;e<o;e++)Ee(r[e],t,n,i)}function Ae(e,t,n,i){const r=e.opaque,a=e.transmissive,s=e.transparent;h.setupLightsView(n),a.length>0&&function(e,t,n){const i=H.isWebGL2;null===k&&(k=new wp(1,1,{generateMipmaps:!0,type:j.has("EXT_color_buffer_half_float")?Ku:Wu,minFilter:Hu,samples:i&&!0===o?4:0}));f.getDrawingBufferSize(F),i?k.setSize(F.x,F.y):k.setSize(Yh(F.x),Yh(F.y));const r=f.getRenderTarget();f.setRenderTarget(k),f.clear();const a=f.toneMapping;f.toneMapping=bu,Te(e,t,n),f.toneMapping=a,$.updateMultisampleRenderTarget(k),$.updateRenderTargetMipmap(k),f.setRenderTarget(r)}(r,t,n),i&&V.viewport(w.copy(i)),r.length>0&&Te(r,t,n),a.length>0&&Te(a,t,n),s.length>0&&Te(s,t,n),V.buffers.depth.setTest(!0),V.buffers.depth.setMask(!0),V.buffers.color.setMask(!0),V.setPolygonOffset(!1)}function Te(e,t,n){const i=!0===t.isScene?t.overrideMaterial:null;for(let r=0,o=e.length;r<o;r++){const o=e[r],a=o.object,s=o.geometry,l=null===i?o.material:i,c=o.group;a.layers.test(n.layers)&&Ie(a,t,n,s,l,c)}}function Ie(e,t,n,i,r,o){e.onBeforeRender(f,t,n,i,r,o),e.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix),r.onBeforeRender(f,t,n,i,e,o),!0===r.transparent&&r.side===zc?(r.side=Uc,r.needsUpdate=!0,f.renderBufferDirect(n,t,i,r,e,o),r.side=Fc,r.needsUpdate=!0,f.renderBufferDirect(n,t,i,r,e,o),r.side=zc):f.renderBufferDirect(n,t,i,r,e,o),e.onAfterRender(f,t,n,i,r,o)}function Me(e,t,n){!0!==t.isScene&&(t=z);const i=q.get(e),r=h.state.lights,o=h.state.shadowsArray,a=r.state.version,s=Q.getParameters(e,r.state,o,t,n),l=Q.getProgramCacheKey(s);let c=i.programs;i.environment=e.isMeshStandardMaterial?t.environment:null,i.fog=t.fog,i.envMap=(e.isMeshStandardMaterial?J:Y).get(e.envMap||i.environment),void 0===c&&(e.addEventListener("dispose",_e),c=new Map,i.programs=c);let u=c.get(l);if(void 0!==u){if(i.currentProgram===u&&i.lightsStateVersion===a)return Ce(e,s),u}else s.uniforms=Q.getUniforms(e),e.onBuild(n,s,f),e.onBeforeCompile(s,f),u=Q.acquireProgram(s,l),c.set(l,u),i.uniforms=s.uniforms;const d=i.uniforms;(e.isShaderMaterial||e.isRawShaderMaterial)&&!0!==e.clipping||(d.clippingPlanes=ie.uniform),Ce(e,s),i.needsLights=function(e){return e.isMeshLambertMaterial||e.isMeshToonMaterial||e.isMeshPhongMaterial||e.isMeshStandardMaterial||e.isShadowMaterial||e.isShaderMaterial&&!0===e.lights}(e),i.lightsStateVersion=a,i.needsLights&&(d.ambientLightColor.value=r.state.ambient,d.lightProbe.value=r.state.probe,d.directionalLights.value=r.state.directional,d.directionalLightShadows.value=r.state.directionalShadow,d.spotLights.value=r.state.spot,d.spotLightShadows.value=r.state.spotShadow,d.rectAreaLights.value=r.state.rectArea,d.ltc_1.value=r.state.rectAreaLTC1,d.ltc_2.value=r.state.rectAreaLTC2,d.pointLights.value=r.state.point,d.pointLightShadows.value=r.state.pointShadow,d.hemisphereLights.value=r.state.hemi,d.directionalShadowMap.value=r.state.directionalShadowMap,d.directionalShadowMatrix.value=r.state.directionalShadowMatrix,d.spotShadowMap.value=r.state.spotShadowMap,d.spotLightMatrix.value=r.state.spotLightMatrix,d.spotLightMap.value=r.state.spotLightMap,d.pointShadowMap.value=r.state.pointShadowMap,d.pointShadowMatrix.value=r.state.pointShadowMatrix);const p=u.getUniforms(),m=kv.seqWithValue(p.seq,d);return i.currentProgram=u,i.uniformsList=m,u}function Ce(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}Se.setAnimationLoop((function(e){be&&be(e)})),"undefined"!=typeof self&&Se.setContext(self),this.setAnimationLoop=function(e){be=e,fe.setAnimationLoop(e),null===e?Se.stop():Se.start()},fe.addEventListener("sessionstart",xe),fe.addEventListener("sessionend",we),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),L.setFromProjectionMatrix(B),D=this.localClippingEnabled,P=ie.init(this.clippingPlanes,D,t),d=te.get(e,p.length),d.init(),p.push(d),Ee(e,t,0,f.sortObjects),d.finish(),!0===f.sortObjects&&d.sort(M,C),!0===P&&ie.beginShadows();const n=h.state.shadowsArray;if(re.render(n,e,t),!0===P&&ie.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,i=n.length;t<i;t++){const i=n[t];Ae(d,e,i,i.viewport)}}else Ae(d,e,t);null!==_&&($.updateMultisampleRenderTarget(_),$.updateRenderTargetMipmap(_)),!0===e.isScene&&e.onAfterRender(f,e,t),ue.resetDefaultState(),b=-1,x=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 i=q.get(e);i.__hasExternalTextures=!0,i.__hasExternalTextures&&(i.__autoAllocateDepthBuffer=void 0===n,i.__autoAllocateDepthBuffer||!0===j.has("WEBGL_multisampled_render_to_texture")&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),i.__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 i=!0;if(e){const t=q.get(e);void 0!==t.__useDefaultFramebuffer?(V.bindFramebuffer(36160,null),i=!1):void 0===t.__webglFramebuffer?$.setupRenderTarget(e):t.__hasExternalTextures&&$.rebindTextures(e,q.get(e.texture).__webglTexture,q.get(e.depthTexture).__webglTexture)}let r=null,o=!1,a=!1;if(e){const n=e.texture;(n.isData3DTexture||n.isDataArrayTexture)&&(a=!0);const i=q.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(r=i[t],o=!0):r=H.isWebGL2&&e.samples>0&&!1===$.useMultisampledRTT(e)?q.get(e).__webglMultisampledFramebuffer:i,w.copy(e.viewport),S.copy(e.scissor),E=e.scissorTest}else w.copy(N).multiplyScalar(I).floor(),S.copy(O).multiplyScalar(I).floor(),E=R;if(V.bindFramebuffer(36160,r)&&H.drawBuffers&&i&&V.drawBuffers(e,r),V.viewport(w),V.scissor(S),V.setScissorTest(E),o){const i=q.get(e.texture);he.framebufferTexture2D(36160,36064,34069+t,i.__webglTexture,n)}else if(a){const i=q.get(e.texture),r=t||0;he.framebufferTextureLayer(36160,36064,i.__webglTexture,n||0,r)}b=-1},this.readRenderTargetPixels=function(e,t,n,i,r,o,a){if(!e||!e.isWebGLRenderTarget)return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let s=q.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==a&&(s=s[a]),s){V.bindFramebuffer(36160,s);try{const a=e.texture,s=a.format,l=a.type;if(s!==rd&&ce.convert(s)!==he.getParameter(35739))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");const c=l===Ku&&(j.has("EXT_color_buffer_half_float")||H.isWebGL2&&j.has("EXT_color_buffer_float"));if(!(l===Wu||ce.convert(l)===he.getParameter(35738)||l===Xu&&(H.isWebGL2||j.has("OES_texture_float")||j.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-i&&n>=0&&n<=e.height-r&&he.readPixels(t,n,i,r,ce.convert(s),ce.convert(l),o)}finally{const e=null!==_?q.get(_).__webglFramebuffer:null;V.bindFramebuffer(36160,e)}}},this.copyFramebufferToTexture=function(e,t,n=0){const i=Math.pow(2,-n),r=Math.floor(t.image.width*i),o=Math.floor(t.image.height*i);$.setTexture2D(t,0),he.copyTexSubImage2D(3553,n,0,0,e.x,e.y,r,o),V.unbindTexture()},this.copyTextureToTexture=function(e,t,n,i=0){const r=t.image.width,o=t.image.height,a=ce.convert(n.format),s=ce.convert(n.type);$.setTexture2D(n,0),he.pixelStorei(37440,n.flipY),he.pixelStorei(37441,n.premultiplyAlpha),he.pixelStorei(3317,n.unpackAlignment),t.isDataTexture?he.texSubImage2D(3553,i,e.x,e.y,r,o,a,s,t.image.data):t.isCompressedTexture?he.compressedTexSubImage2D(3553,i,e.x,e.y,t.mipmaps[0].width,t.mipmaps[0].height,a,t.mipmaps[0].data):he.texSubImage2D(3553,i,e.x,e.y,a,s,t.image),0===i&&n.generateMipmaps&&he.generateMipmap(3553),V.unbindTexture()},this.copyTextureToTexture3D=function(e,t,n,i,r=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,a=e.max.y-e.min.y+1,s=e.max.z-e.min.z+1,l=ce.convert(i.format),c=ce.convert(i.type);let u;if(i.isData3DTexture)$.setTexture3D(i,0),u=32879;else{if(!i.isDataArrayTexture)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");$.setTexture2DArray(i,0),u=35866}he.pixelStorei(37440,i.flipY),he.pixelStorei(37441,i.premultiplyAlpha),he.pixelStorei(3317,i.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,r,t.x,t.y,t.z,o,a,s,l,c,v.data):n.isCompressedTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),he.compressedTexSubImage3D(u,r,t.x,t.y,t.z,o,a,s,l,v.data)):he.texSubImage3D(u,r,t.x,t.y,t.z,o,a,s,l,c,v),he.pixelStorei(3314,d),he.pixelStorei(32878,h),he.pixelStorei(3316,p),he.pixelStorei(3315,m),he.pixelStorei(32877,g),0===r&&i.generateMipmaps&&he.generateMipmap(u),V.unbindTexture()},this.initTexture=function(e){e.isCubeTexture?$.setTextureCube(e,0):e.isData3DTexture?$.setTexture3D(e,0):e.isDataArrayTexture?$.setTexture2DArray(e,0):$.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 Cy extends My{}Cy.prototype.isWebGL1Renderer=!0;class Ny{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new mp(e),this.density=t}clone(){return new Ny(this.color,this.density)}toJSON(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}}class Oy{constructor(e,t=1,n=1e3){this.isFog=!0,this.name="",this.color=new mp(e),this.near=t,this.far=n}clone(){return new Oy(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}}class Ry extends Om{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 Ly{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=void 0!==e?e.length/t:0,this.usage=Ah,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=jh()}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 i=0,r=this.stride;i<r;i++)this.array[e+i]=t.array[n+i];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=jh()),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=jh()),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 Py=new Cp;class Dy{constructor(e,t,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=!0===i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)Py.fromBufferAttribute(this,t),Py.applyMatrix4(e),this.setXYZ(t,Py.x,Py.y,Py.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Py.fromBufferAttribute(this,t),Py.applyNormalMatrix(e),this.setXYZ(t,Py.x,Py.y,Py.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Py.fromBufferAttribute(this,t),Py.transformDirection(e),this.setXYZ(t,Py.x,Py.y,Py.z);return this}setX(e,t){return this.normalized&&(t=Zh(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=Zh(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=Zh(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=Zh(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=Jh(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=Jh(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=Jh(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=Jh(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=Zh(t,this.array),n=Zh(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=Zh(t,this.array),n=Zh(n,this.array),i=Zh(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this}setXYZW(e,t,n,i,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=Zh(t,this.array),n=Zh(n,this.array),i=Zh(i,this.array),r=Zh(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this.data.array[e+3]=r,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 Ym(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 Dy(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 ky extends Vm{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new mp(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 By;const Fy=new Cp,Uy=new Cp,zy=new Cp,Gy=new Kh,jy=new Kh,Hy=new am,Vy=new Cp,Wy=new Cp,qy=new Cp,$y=new Kh,Yy=new Kh,Jy=new Kh;class Zy extends Om{constructor(e){if(super(),this.isSprite=!0,this.type="Sprite",void 0===By){By=new pf;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 Ly(e,5);By.setIndex([0,1,2,0,2,3]),By.setAttribute("position",new Dy(t,3,0,!1)),By.setAttribute("uv",new Dy(t,2,3,!1))}this.geometry=By,this.material=void 0!==e?e:new ky,this.center=new Kh(.5,.5)}raycast(e,t){null===e.camera&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Uy.setFromMatrixScale(this.matrixWorld),Hy.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),zy.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&!1===this.material.sizeAttenuation&&Uy.multiplyScalar(-zy.z);const n=this.material.rotation;let i,r;0!==n&&(r=Math.cos(n),i=Math.sin(n));const o=this.center;Xy(Vy.set(-.5,-.5,0),zy,o,Uy,i,r),Xy(Wy.set(.5,-.5,0),zy,o,Uy,i,r),Xy(qy.set(.5,.5,0),zy,o,Uy,i,r),$y.set(0,0),Yy.set(1,0),Jy.set(1,1);let a=e.ray.intersectTriangle(Vy,Wy,qy,!1,Fy);if(null===a&&(Xy(Wy.set(-.5,.5,0),zy,o,Uy,i,r),Yy.set(0,1),a=e.ray.intersectTriangle(Vy,qy,Wy,!1,Fy),null===a))return;const s=e.ray.origin.distanceTo(Fy);s<e.near||s>e.far||t.push({distance:s,point:Fy.clone(),uv:jm.getUV(Fy,Vy,Wy,qy,$y,Yy,Jy,new Kh),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 Xy(e,t,n,i,r,o){Gy.subVectors(e,n).addScalar(.5).multiply(i),void 0!==r?(jy.x=o*Gy.x-r*Gy.y,jy.y=r*Gy.x+o*Gy.y):jy.copy(Gy),e.copy(t),e.x+=jy.x,e.y+=jy.y,e.applyMatrix4(Hy)}const Ky=new Cp,Qy=new Cp;class e_ extends Om{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 i;for(i=0;i<n.length&&!(t<n[i].distance);i++);return n.splice(i,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,i;for(n=1,i=t.length;n<i&&!(e<t[n].distance);n++);return t[n-1].object}return null}raycast(e,t){if(this.levels.length>0){Ky.setFromMatrixPosition(this.matrixWorld);const n=e.ray.origin.distanceTo(Ky);this.getObjectForDistance(n).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){Ky.setFromMatrixPosition(e.matrixWorld),Qy.setFromMatrixPosition(this.matrixWorld);const n=Ky.distanceTo(Qy)/e.zoom;let i,r;for(t[0].object.visible=!0,i=1,r=t.length;i<r&&n>=t[i].distance;i++)t[i-1].object.visible=!1,t[i].object.visible=!0;for(this._currentLevel=i-1;i<r;i++)t[i].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,i=n.length;e<i;e++){const i=n[e];t.object.levels.push({object:i.object.uuid,distance:i.distance})}return t}}const t_=new Cp,n_=new xp,i_=new xp,r_=new Cp,o_=new am;class a_ extends Of{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new am,this.bindMatrixInverse=new am}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 xp,t=this.geometry.attributes.skinWeight;for(let n=0,i=t.count;n<i;n++){e.fromBufferAttribute(t,n);const i=1/e.manhattanLength();i!==1/0?e.multiplyScalar(i):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,i=this.geometry;n_.fromBufferAttribute(i.attributes.skinIndex,e),i_.fromBufferAttribute(i.attributes.skinWeight,e),t_.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let e=0;e<4;e++){const i=i_.getComponent(e);if(0!==i){const r=n_.getComponent(e);o_.multiplyMatrices(n.bones[r].matrixWorld,n.boneInverses[r]),t.addScaledVector(r_.copy(t_).applyMatrix4(o_),i)}}return t.applyMatrix4(this.bindMatrixInverse)}}class s_ extends Om{constructor(){super(),this.isBone=!0,this.type="Bone"}}class l_ extends bp{constructor(e=null,t=1,n=1,i,r,o,a,s,l=Du,c=Du,u,d){super(null,o,a,s,l,c,i,r,u,d),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const c_=new am,u_=new am;class d_{constructor(e=[],t=[]){this.uuid=jh(),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 am)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const t=new am;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,i=this.boneTexture;for(let i=0,r=e.length;i<r;i++){const r=e[i]?e[i].matrixWorld:u_;c_.multiplyMatrices(r,t[i]),c_.toArray(n,16*i)}null!==i&&(i.needsUpdate=!0)}clone(){return new d_(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(4*this.bones.length);e=$h(e),e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const n=new l_(t,e,e,rd,Xu);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,i=e.bones.length;n<i;n++){const i=e.bones[n];let r=t[i];void 0===r&&(console.warn("THREE.Skeleton: No bone found with UUID:",i),r=new s_),this.bones.push(r),this.boneInverses.push((new am).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 i=0,r=t.length;i<r;i++){const r=t[i];e.bones.push(r.uuid);const o=n[i];e.boneInverses.push(o.toArray())}return e}}class h_ extends Ym{constructor(e,t,n,i=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}const p_=new am,m_=new am,f_=[],g_=new Of;class v_ extends Of{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new h_(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,i=this.count;if(g_.geometry=this.geometry,g_.material=this.material,void 0!==g_.material)for(let r=0;r<i;r++){this.getMatrixAt(r,p_),m_.multiplyMatrices(n,p_),g_.matrixWorld=m_,g_.raycast(e,f_);for(let e=0,n=f_.length;e<n;e++){const n=f_[e];n.instanceId=r,n.object=this,t.push(n)}f_.length=0}}setColorAt(e,t){null===this.instanceColor&&(this.instanceColor=new h_(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 y_ extends Vm{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new mp(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 __=new Cp,b_=new Cp,x_=new am,w_=new om,S_=new Xp;class E_ extends Om{constructor(e=new pf,t=new y_){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,i=t.count;e<i;e++)__.fromBufferAttribute(t,e-1),b_.fromBufferAttribute(t,e),n[e]=n[e-1],n[e]+=__.distanceTo(b_);e.setAttribute("lineDistance",new rf(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const n=this.geometry,i=this.matrixWorld,r=e.params.Line.threshold,o=n.drawRange;if(null===n.boundingSphere&&n.computeBoundingSphere(),S_.copy(n.boundingSphere),S_.applyMatrix4(i),S_.radius+=r,!1===e.ray.intersectsSphere(S_))return;x_.copy(i).invert(),w_.copy(e.ray).applyMatrix4(x_);const a=r/((this.scale.x+this.scale.y+this.scale.z)/3),s=a*a,l=new Cp,c=new Cp,u=new Cp,d=new Cp,h=this.isLineSegments?2:1,p=n.index,m=n.attributes.position;if(null!==p){for(let n=Math.max(0,o.start),i=Math.min(p.count,o.start+o.count)-1;n<i;n+=h){const i=p.getX(n),r=p.getX(n+1);l.fromBufferAttribute(m,i),c.fromBufferAttribute(m,r);if(w_.distanceSqToSegment(l,c,d,u)>s)continue;d.applyMatrix4(this.matrixWorld);const o=e.ray.origin.distanceTo(d);o<e.near||o>e.far||t.push({distance:o,point:u.clone().applyMatrix4(this.matrixWorld),index:n,face:null,faceIndex:null,object:this})}}else{for(let n=Math.max(0,o.start),i=Math.min(m.count,o.start+o.count)-1;n<i;n+=h){l.fromBufferAttribute(m,n),c.fromBufferAttribute(m,n+1);if(w_.distanceSqToSegment(l,c,d,u)>s)continue;d.applyMatrix4(this.matrixWorld);const i=e.ray.origin.distanceTo(d);i<e.near||i>e.far||t.push({distance:i,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 A_=new Cp,T_=new Cp;class I_ extends E_{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,i=t.count;e<i;e+=2)A_.fromBufferAttribute(t,e),T_.fromBufferAttribute(t,e+1),n[e]=0===e?0:n[e-1],n[e+1]=n[e]+A_.distanceTo(T_);e.setAttribute("lineDistance",new rf(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class M_ extends E_{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class C_ extends Vm{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new mp(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 N_=new am,O_=new om,R_=new Xp,L_=new Cp;class P_ extends Om{constructor(e=new pf,t=new C_){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=e.material,this.geometry=e.geometry,this}raycast(e,t){const n=this.geometry,i=this.matrixWorld,r=e.params.Points.threshold,o=n.drawRange;if(null===n.boundingSphere&&n.computeBoundingSphere(),R_.copy(n.boundingSphere),R_.applyMatrix4(i),R_.radius+=r,!1===e.ray.intersectsSphere(R_))return;N_.copy(i).invert(),O_.copy(e.ray).applyMatrix4(N_);const a=r/((this.scale.x+this.scale.y+this.scale.z)/3),s=a*a,l=n.index,c=n.attributes.position;if(null!==l){for(let n=Math.max(0,o.start),r=Math.min(l.count,o.start+o.count);n<r;n++){const r=l.getX(n);L_.fromBufferAttribute(c,r),D_(L_,r,s,i,e,t,this)}}else{for(let n=Math.max(0,o.start),r=Math.min(c.count,o.start+o.count);n<r;n++)L_.fromBufferAttribute(c,n),D_(L_,n,s,i,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 D_(e,t,n,i,r,o,a){const s=O_.distanceSqToPoint(e);if(s<n){const n=new Cp;O_.closestPointToPoint(e,n),n.applyMatrix4(i);const l=r.ray.origin.distanceTo(n);if(l<r.near||l>r.far)return;o.push({distance:l,distanceToRay:Math.sqrt(s),point:n,index:t,face:null,object:a})}}class k_ extends bp{constructor(e,t,n,i,r,o,a,s,l){super(e,t,n,i,r,o,a,s,l),this.isVideoTexture=!0,this.minFilter=void 0!==o?o:zu,this.magFilter=void 0!==r?r:zu,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 B_ extends bp{constructor(e,t,n){super({width:e,height:t}),this.isFramebufferTexture=!0,this.format=n,this.magFilter=Du,this.minFilter=Du,this.generateMipmaps=!1,this.needsUpdate=!0}}class F_ extends bp{constructor(e,t,n,i,r,o,a,s,l,c,u,d){super(null,o,a,s,l,c,i,r,u,d),this.isCompressedTexture=!0,this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class U_ extends bp{constructor(e,t,n,i,r,o,a,s,l){super(e,t,n,i,r,o,a,s,l),this.isCanvasTexture=!0,this.needsUpdate=!0}}class z_{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){const n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let n,i=this.getPoint(0),r=0;t.push(0);for(let o=1;o<=e;o++)n=this.getPoint(o/e),r+=n.distanceTo(i),t.push(r),i=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const n=this.getLengths();let i=0;const r=n.length;let o;o=t||e*n[r-1];let a,s=0,l=r-1;for(;s<=l;)if(i=Math.floor(s+(l-s)/2),a=n[i]-o,a<0)s=i+1;else{if(!(a>0)){l=i;break}l=i-1}if(i=l,n[i]===o)return i/(r-1);const c=n[i];return(i+(o-c)/(n[i+1]-c))/(r-1)}getTangent(e,t){const n=1e-4;let i=e-n,r=e+n;i<0&&(i=0),r>1&&(r=1);const o=this.getPoint(i),a=this.getPoint(r),s=t||(o.isVector2?new Kh:new Cp);return s.copy(a).sub(o).normalize(),s}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t){const n=new Cp,i=[],r=[],o=[],a=new Cp,s=new am;for(let t=0;t<=e;t++){const n=t/e;i[t]=this.getTangentAt(n,new Cp)}r[0]=new Cp,o[0]=new Cp;let l=Number.MAX_VALUE;const c=Math.abs(i[0].x),u=Math.abs(i[0].y),d=Math.abs(i[0].z);c<=l&&(l=c,n.set(1,0,0)),u<=l&&(l=u,n.set(0,1,0)),d<=l&&n.set(0,0,1),a.crossVectors(i[0],n).normalize(),r[0].crossVectors(i[0],a),o[0].crossVectors(i[0],r[0]);for(let t=1;t<=e;t++){if(r[t]=r[t-1].clone(),o[t]=o[t-1].clone(),a.crossVectors(i[t-1],i[t]),a.length()>Number.EPSILON){a.normalize();const e=Math.acos(Hh(i[t-1].dot(i[t]),-1,1));r[t].applyMatrix4(s.makeRotationAxis(a,e))}o[t].crossVectors(i[t],r[t])}if(!0===t){let t=Math.acos(Hh(r[0].dot(r[e]),-1,1));t/=e,i[0].dot(a.crossVectors(r[0],r[e]))>0&&(t=-t);for(let n=1;n<=e;n++)r[n].applyMatrix4(s.makeRotationAxis(i[n],t*n)),o[n].crossVectors(i[n],r[n])}return{tangents:i,normals:r,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 G_ extends z_{constructor(e=0,t=0,n=1,i=1,r=0,o=2*Math.PI,a=!1,s=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=i,this.aStartAngle=r,this.aEndAngle=o,this.aClockwise=a,this.aRotation=s}getPoint(e,t){const n=t||new Kh,i=2*Math.PI;let r=this.aEndAngle-this.aStartAngle;const o=Math.abs(r)<Number.EPSILON;for(;r<0;)r+=i;for(;r>i;)r-=i;r<Number.EPSILON&&(r=o?0:i),!0!==this.aClockwise||o||(r===i?r=-i:r-=i);const a=this.aStartAngle+e*r;let s=this.aX+this.xRadius*Math.cos(a),l=this.aY+this.yRadius*Math.sin(a);if(0!==this.aRotation){const e=Math.cos(this.aRotation),t=Math.sin(this.aRotation),n=s-this.aX,i=l-this.aY;s=n*e-i*t+this.aX,l=n*t+i*e+this.aY}return n.set(s,l)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){const e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}}class j_ extends G_{constructor(e,t,n,i,r,o){super(e,t,n,n,i,r,o),this.isArcCurve=!0,this.type="ArcCurve"}}function H_(){let e=0,t=0,n=0,i=0;function r(r,o,a,s){e=r,t=a,n=-3*r+3*o-2*a-s,i=2*r-2*o+a+s}return{initCatmullRom:function(e,t,n,i,o){r(t,n,o*(n-e),o*(i-t))},initNonuniformCatmullRom:function(e,t,n,i,o,a,s){let l=(t-e)/o-(n-e)/(o+a)+(n-t)/a,c=(n-t)/a-(i-t)/(a+s)+(i-n)/s;l*=a,c*=a,r(t,n,l,c)},calc:function(r){const o=r*r;return e+t*r+n*o+i*(o*r)}}}const V_=new Cp,W_=new H_,q_=new H_,$_=new H_;class Y_ extends z_{constructor(e=[],t=!1,n="centripetal",i=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=n,this.tension=i}getPoint(e,t=new Cp){const n=t,i=this.points,r=i.length,o=(r-(this.closed?0:1))*e;let a,s,l=Math.floor(o),c=o-l;this.closed?l+=l>0?0:(Math.floor(Math.abs(l)/r)+1)*r:0===c&&l===r-1&&(l=r-2,c=1),this.closed||l>0?a=i[(l-1)%r]:(V_.subVectors(i[0],i[1]).add(i[0]),a=V_);const u=i[l%r],d=i[(l+1)%r];if(this.closed||l+2<r?s=i[(l+2)%r]:(V_.subVectors(i[r-1],i[r-2]).add(i[r-1]),s=V_),"centripetal"===this.curveType||"chordal"===this.curveType){const e="chordal"===this.curveType?.5:.25;let t=Math.pow(a.distanceToSquared(u),e),n=Math.pow(u.distanceToSquared(d),e),i=Math.pow(d.distanceToSquared(s),e);n<1e-4&&(n=1),t<1e-4&&(t=n),i<1e-4&&(i=n),W_.initNonuniformCatmullRom(a.x,u.x,d.x,s.x,t,n,i),q_.initNonuniformCatmullRom(a.y,u.y,d.y,s.y,t,n,i),$_.initNonuniformCatmullRom(a.z,u.z,d.z,s.z,t,n,i)}else"catmullrom"===this.curveType&&(W_.initCatmullRom(a.x,u.x,d.x,s.x,this.tension),q_.initCatmullRom(a.y,u.y,d.y,s.y,this.tension),$_.initCatmullRom(a.z,u.z,d.z,s.z,this.tension));return n.set(W_.calc(c),q_.calc(c),$_.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 Cp).fromArray(n))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}}function J_(e,t,n,i,r){const o=.5*(i-t),a=.5*(r-n),s=e*e;return(2*n-2*i+o+a)*(e*s)+(-3*n+3*i-2*o-a)*s+o*e+n}function Z_(e,t,n,i){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,i)}function X_(e,t,n,i,r){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,i)+function(e,t){return e*e*e*t}(e,r)}class K_ extends z_{constructor(e=new Kh,t=new Kh,n=new Kh,i=new Kh){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=n,this.v3=i}getPoint(e,t=new Kh){const n=t,i=this.v0,r=this.v1,o=this.v2,a=this.v3;return n.set(X_(e,i.x,r.x,o.x,a.x),X_(e,i.y,r.y,o.y,a.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class Q_ extends z_{constructor(e=new Cp,t=new Cp,n=new Cp,i=new Cp){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=n,this.v3=i}getPoint(e,t=new Cp){const n=t,i=this.v0,r=this.v1,o=this.v2,a=this.v3;return n.set(X_(e,i.x,r.x,o.x,a.x),X_(e,i.y,r.y,o.y,a.y),X_(e,i.z,r.z,o.z,a.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class eb extends z_{constructor(e=new Kh,t=new Kh){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new Kh){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 Kh;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 tb extends z_{constructor(e=new Cp,t=new Cp){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new Cp){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 nb extends z_{constructor(e=new Kh,t=new Kh,n=new Kh){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new Kh){const n=t,i=this.v0,r=this.v1,o=this.v2;return n.set(Z_(e,i.x,r.x,o.x),Z_(e,i.y,r.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 ib extends z_{constructor(e=new Cp,t=new Cp,n=new Cp){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new Cp){const n=t,i=this.v0,r=this.v1,o=this.v2;return n.set(Z_(e,i.x,r.x,o.x),Z_(e,i.y,r.y,o.y),Z_(e,i.z,r.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 rb extends z_{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new Kh){const n=t,i=this.points,r=(i.length-1)*e,o=Math.floor(r),a=r-o,s=i[0===o?o:o-1],l=i[o],c=i[o>i.length-2?i.length-1:o+1],u=i[o>i.length-3?i.length-1:o+2];return n.set(J_(a,s.x,l.x,c.x,u.x),J_(a,s.y,l.y,c.y,u.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const n=e.points[t];this.points.push(n.clone())}return this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){const n=this.points[t];e.points.push(n.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const n=e.points[t];this.points.push((new Kh).fromArray(n))}return this}}var ob=Object.freeze({__proto__:null,ArcCurve:j_,CatmullRomCurve3:Y_,CubicBezierCurve:K_,CubicBezierCurve3:Q_,EllipseCurve:G_,LineCurve:eb,LineCurve3:tb,QuadraticBezierCurve:nb,QuadraticBezierCurve3:ib,SplineCurve:rb});class ab extends z_{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 eb(t,e))}getPoint(e,t){const n=e*this.getLength(),i=this.getCurveLengths();let r=0;for(;r<i.length;){if(i[r]>=n){const e=i[r]-n,o=this.curves[r],a=o.getLength(),s=0===a?0:1-e/a;return o.getPointAt(s,t)}r++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let n=0,i=this.curves.length;n<i;n++)t+=this.curves[n].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){const t=[];let n;for(let i=0,r=this.curves;i<r.length;i++){const o=r[i],a=o.isEllipseCurve?2*e:o.isLineCurve||o.isLineCurve3?1:o.isSplineCurve?e*o.points.length:e,s=o.getPoints(a);for(let e=0;e<s.length;e++){const i=s[e];n&&n.equals(i)||(t.push(i),n=i)}}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 ob[n.type]).fromJSON(n))}return this}}class sb extends ab{constructor(e){super(),this.type="Path",this.currentPoint=new Kh,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 eb(this.currentPoint.clone(),new Kh(e,t));return this.curves.push(n),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,n,i){const r=new nb(this.currentPoint.clone(),new Kh(e,t),new Kh(n,i));return this.curves.push(r),this.currentPoint.set(n,i),this}bezierCurveTo(e,t,n,i,r,o){const a=new K_(this.currentPoint.clone(),new Kh(e,t),new Kh(n,i),new Kh(r,o));return this.curves.push(a),this.currentPoint.set(r,o),this}splineThru(e){const t=[this.currentPoint.clone()].concat(e),n=new rb(t);return this.curves.push(n),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,n,i,r,o){const a=this.currentPoint.x,s=this.currentPoint.y;return this.absarc(e+a,t+s,n,i,r,o),this}absarc(e,t,n,i,r,o){return this.absellipse(e,t,n,n,i,r,o),this}ellipse(e,t,n,i,r,o,a,s){const l=this.currentPoint.x,c=this.currentPoint.y;return this.absellipse(e+l,t+c,n,i,r,o,a,s),this}absellipse(e,t,n,i,r,o,a,s){const l=new G_(e,t,n,i,r,o,a,s);if(this.curves.length>0){const e=l.getPoint(0);e.equals(this.currentPoint)||this.lineTo(e.x,e.y)}this.curves.push(l);const c=l.getPoint(1);return this.currentPoint.copy(c),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class lb extends pf{constructor(e=[new Kh(0,-.5),new Kh(.5,0),new Kh(0,.5)],t=12,n=0,i=2*Math.PI){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:n,phiLength:i},t=Math.floor(t),i=Hh(i,0,2*Math.PI);const r=[],o=[],a=[],s=[],l=[],c=1/t,u=new Cp,d=new Kh,h=new Cp,p=new Cp,m=new Cp;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(),s.push(h.x,h.y,h.z);break;case e.length-1:s.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(),s.push(h.x,h.y,h.z),m.copy(p)}for(let r=0;r<=t;r++){const h=n+r*c*i,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=r/t,d.y=n/(e.length-1),a.push(d.x,d.y);const i=s[3*n+0]*p,c=s[3*n+1],h=s[3*n+0]*m;l.push(i,c,h)}}for(let n=0;n<t;n++)for(let t=0;t<e.length-1;t++){const i=t+n*e.length,o=i,a=i+e.length,s=i+e.length+1,l=i+1;r.push(o,a,l),r.push(s,l,a)}this.setIndex(r),this.setAttribute("position",new rf(o,3)),this.setAttribute("uv",new rf(a,2)),this.setAttribute("normal",new rf(l,3))}static fromJSON(e){return new lb(e.points,e.segments,e.phiStart,e.phiLength)}}class cb extends lb{constructor(e=1,t=1,n=4,i=8){const r=new sb;r.absarc(0,-t/2,e,1.5*Math.PI,0),r.absarc(0,t/2,e,0,.5*Math.PI),super(r.getPoints(n),i),this.type="CapsuleGeometry",this.parameters={radius:e,height:t,capSegments:n,radialSegments:i}}static fromJSON(e){return new cb(e.radius,e.length,e.capSegments,e.radialSegments)}}class ub extends pf{constructor(e=1,t=8,n=0,i=2*Math.PI){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:i},t=Math.max(3,t);const r=[],o=[],a=[],s=[],l=new Cp,c=new Kh;o.push(0,0,0),a.push(0,0,1),s.push(.5,.5);for(let r=0,u=3;r<=t;r++,u+=3){const d=n+r/t*i;l.x=e*Math.cos(d),l.y=e*Math.sin(d),o.push(l.x,l.y,l.z),a.push(0,0,1),c.x=(o[u]/e+1)/2,c.y=(o[u+1]/e+1)/2,s.push(c.x,c.y)}for(let e=1;e<=t;e++)r.push(e,e+1,0);this.setIndex(r),this.setAttribute("position",new rf(o,3)),this.setAttribute("normal",new rf(a,3)),this.setAttribute("uv",new rf(s,2))}static fromJSON(e){return new ub(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class db extends pf{constructor(e=1,t=1,n=1,i=8,r=1,o=!1,a=0,s=2*Math.PI){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:i,heightSegments:r,openEnded:o,thetaStart:a,thetaLength:s};const l=this;i=Math.floor(i),r=Math.floor(r);const c=[],u=[],d=[],h=[];let p=0;const m=[],f=n/2;let g=0;function v(n){const r=p,o=new Kh,m=new Cp;let v=0;const y=!0===n?e:t,_=!0===n?1:-1;for(let e=1;e<=i;e++)u.push(0,f*_,0),d.push(0,_,0),h.push(.5,.5),p++;const b=p;for(let e=0;e<=i;e++){const t=e/i*s+a,n=Math.cos(t),r=Math.sin(t);m.x=y*r,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*r*_+.5,h.push(o.x,o.y),p++}for(let e=0;e<i;e++){const t=r+e,i=b+e;!0===n?c.push(i,i+1,t):c.push(i+1,i,t),v+=3}l.addGroup(g,v,!0===n?1:2),g+=v}!function(){const o=new Cp,v=new Cp;let y=0;const _=(t-e)/n;for(let l=0;l<=r;l++){const c=[],g=l/r,y=g*(t-e)+e;for(let e=0;e<=i;e++){const t=e/i,r=t*s+a,l=Math.sin(r),m=Math.cos(r);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<i;e++)for(let t=0;t<r;t++){const n=m[t][e],i=m[t+1][e],r=m[t+1][e+1],o=m[t][e+1];c.push(n,i,o),c.push(i,r,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 rf(u,3)),this.setAttribute("normal",new rf(d,3)),this.setAttribute("uv",new rf(h,2))}static fromJSON(e){return new db(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class hb extends db{constructor(e=1,t=1,n=8,i=1,r=!1,o=0,a=2*Math.PI){super(0,e,t,n,i,r,o,a),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:i,openEnded:r,thetaStart:o,thetaLength:a}}static fromJSON(e){return new hb(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class pb extends pf{constructor(e=[],t=[],n=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:n,detail:i};const r=[],o=[];function a(e,t,n,i){const r=i+1,o=[];for(let i=0;i<=r;i++){o[i]=[];const a=e.clone().lerp(n,i/r),s=t.clone().lerp(n,i/r),l=r-i;for(let e=0;e<=l;e++)o[i][e]=0===e&&i===r?a:a.clone().lerp(s,e/l)}for(let e=0;e<r;e++)for(let t=0;t<2*(r-e)-1;t++){const n=Math.floor(t/2);t%2==0?(s(o[e][n+1]),s(o[e+1][n]),s(o[e][n])):(s(o[e][n+1]),s(o[e+1][n+1]),s(o[e+1][n]))}}function s(e){r.push(e.x,e.y,e.z)}function l(t,n){const i=3*t;n.x=e[i+0],n.y=e[i+1],n.z=e[i+2]}function c(e,t,n,i){i<0&&1===e.x&&(o[t]=e.x-1),0===n.x&&0===n.z&&(o[t]=i/2/Math.PI+.5)}function u(e){return Math.atan2(e.z,-e.x)}!function(e){const n=new Cp,i=new Cp,r=new Cp;for(let o=0;o<t.length;o+=3)l(t[o+0],n),l(t[o+1],i),l(t[o+2],r),a(n,i,r,e)}(i),function(e){const t=new Cp;for(let n=0;n<r.length;n+=3)t.x=r[n+0],t.y=r[n+1],t.z=r[n+2],t.normalize().multiplyScalar(e),r[n+0]=t.x,r[n+1]=t.y,r[n+2]=t.z}(n),function(){const e=new Cp;for(let n=0;n<r.length;n+=3){e.x=r[n+0],e.y=r[n+1],e.z=r[n+2];const i=u(e)/2/Math.PI+.5,a=(t=e,Math.atan2(-t.y,Math.sqrt(t.x*t.x+t.z*t.z))/Math.PI+.5);o.push(i,1-a)}var t;(function(){const e=new Cp,t=new Cp,n=new Cp,i=new Cp,a=new Kh,s=new Kh,l=new Kh;for(let d=0,h=0;d<r.length;d+=9,h+=6){e.set(r[d+0],r[d+1],r[d+2]),t.set(r[d+3],r[d+4],r[d+5]),n.set(r[d+6],r[d+7],r[d+8]),a.set(o[h+0],o[h+1]),s.set(o[h+2],o[h+3]),l.set(o[h+4],o[h+5]),i.copy(e).add(t).add(n).divideScalar(3);const p=u(i);c(a,h+0,e,p),c(s,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],i=o[e+4],r=Math.max(t,n,i),a=Math.min(t,n,i);r>.9&&a<.1&&(t<.2&&(o[e+0]+=1),n<.2&&(o[e+2]+=1),i<.2&&(o[e+4]+=1))}}()}(),this.setAttribute("position",new rf(r,3)),this.setAttribute("normal",new rf(r.slice(),3)),this.setAttribute("uv",new rf(o,2)),0===i?this.computeVertexNormals():this.normalizeNormals()}static fromJSON(e){return new pb(e.vertices,e.indices,e.radius,e.details)}}class mb extends pb{constructor(e=1,t=0){const n=(1+Math.sqrt(5))/2,i=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,-i,-n,0,-i,n,0,i,-n,0,i,n,-i,-n,0,-i,n,0,i,-n,0,i,n,0,-n,0,-i,n,0,-i,-n,0,i,n,0,i],[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 mb(e.radius,e.detail)}}const fb=new Cp,gb=new Cp,vb=new Cp,yb=new jm;class _b extends pf{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},null!==e){const n=4,i=Math.pow(10,n),r=Math.cos(zh*t),o=e.getIndex(),a=e.getAttribute("position"),s=o?o.count:a.count,l=[0,0,0],c=["a","b","c"],u=new Array(3),d={},h=[];for(let e=0;e<s;e+=3){o?(l[0]=o.getX(e),l[1]=o.getX(e+1),l[2]=o.getX(e+2)):(l[0]=e,l[1]=e+1,l[2]=e+2);const{a:t,b:n,c:s}=yb;if(t.fromBufferAttribute(a,l[0]),n.fromBufferAttribute(a,l[1]),s.fromBufferAttribute(a,l[2]),yb.getNormal(vb),u[0]=`${Math.round(t.x*i)},${Math.round(t.y*i)},${Math.round(t.z*i)}`,u[1]=`${Math.round(n.x*i)},${Math.round(n.y*i)},${Math.round(n.z*i)}`,u[2]=`${Math.round(s.x*i)},${Math.round(s.y*i)},${Math.round(s.z*i)}`,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],i=u[t],o=yb[c[e]],a=yb[c[t]],s=`${n}_${i}`,p=`${i}_${n}`;p in d&&d[p]?(vb.dot(d[p].normal)<=r&&(h.push(o.x,o.y,o.z),h.push(a.x,a.y,a.z)),d[p]=null):s in d||(d[s]={index0:l[e],index1:l[t],normal:vb.clone()})}}for(const e in d)if(d[e]){const{index0:t,index1:n}=d[e];fb.fromBufferAttribute(a,t),gb.fromBufferAttribute(a,n),h.push(fb.x,fb.y,fb.z),h.push(gb.x,gb.y,gb.z)}this.setAttribute("position",new rf(h,3))}}}class bb extends sb{constructor(e){super(e),this.uuid=jh(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let n=0,i=this.holes.length;n<i;n++)t[n]=this.holes[n].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){const 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 sb).fromJSON(n))}return this}}const xb=function(e,t,n=2){const i=t&&t.length,r=i?t[0]*n:e.length;let o=wb(e,0,r,n,!0);const a=[];if(!o||o.next===o.prev)return a;let s,l,c,u,d,h,p;if(i&&(o=function(e,t,n,i){const r=[];let o,a,s,l,c;for(o=0,a=t.length;o<a;o++)s=t[o]*i,l=o<a-1?t[o+1]*i:e.length,c=wb(e,s,l,i,!1),c===c.next&&(c.steiner=!0),r.push(Lb(c));for(r.sort(Cb),o=0;o<r.length;o++)Nb(r[o],n),n=Sb(n,n.next);return n}(e,t,o,n)),e.length>80*n){s=c=e[0],l=u=e[1];for(let t=n;t<r;t+=n)d=e[t],h=e[t+1],d<s&&(s=d),h<l&&(l=h),d>c&&(c=d),h>u&&(u=h);p=Math.max(c-s,u-l),p=0!==p?1/p:0}return Eb(o,a,n,s,l,p),a};function wb(e,t,n,i,r){let o,a;if(r===function(e,t,n,i){let r=0;for(let o=t,a=n-i;o<n;o+=i)r+=(e[a]-e[o])*(e[o+1]+e[a+1]),a=o;return r}(e,t,n,i)>0)for(o=t;o<n;o+=i)a=Hb(o,e[o],e[o+1],a);else for(o=n-i;o>=t;o-=i)a=Hb(o,e[o],e[o+1],a);return a&&Bb(a,a.next)&&(Vb(a),a=a.next),a}function Sb(e,t){if(!e)return e;t||(t=e);let n,i=e;do{if(n=!1,i.steiner||!Bb(i,i.next)&&0!==kb(i.prev,i,i.next))i=i.next;else{if(Vb(i),i=t=i.prev,i===i.next)break;n=!0}}while(n||i!==t);return t}function Eb(e,t,n,i,r,o,a){if(!e)return;!a&&o&&function(e,t,n,i){let r=e;do{null===r.z&&(r.z=Rb(r.x,r.y,t,n,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,function(e){let t,n,i,r,o,a,s,l,c=1;do{for(n=e,e=null,o=null,a=0;n;){for(a++,i=n,s=0,t=0;t<c&&(s++,i=i.nextZ,i);t++);for(l=c;s>0||l>0&&i;)0!==s&&(0===l||!i||n.z<=i.z)?(r=n,n=n.nextZ,s--):(r=i,i=i.nextZ,l--),o?o.nextZ=r:e=r,r.prevZ=o,o=r;n=i}o.nextZ=null,c*=2}while(a>1)}(r)}(e,i,r,o);let s,l,c=e;for(;e.prev!==e.next;)if(s=e.prev,l=e.next,o?Tb(e,i,r,o):Ab(e))t.push(s.i/n),t.push(e.i/n),t.push(l.i/n),Vb(e),e=l.next,c=l.next;else if((e=l)===c){a?1===a?Eb(e=Ib(Sb(e),t,n),t,n,i,r,o,2):2===a&&Mb(e,t,n,i,r,o):Eb(Sb(e),t,n,i,r,o,1);break}}function Ab(e){const t=e.prev,n=e,i=e.next;if(kb(t,n,i)>=0)return!1;let r=e.next.next;for(;r!==e.prev;){if(Pb(t.x,t.y,n.x,n.y,i.x,i.y,r.x,r.y)&&kb(r.prev,r,r.next)>=0)return!1;r=r.next}return!0}function Tb(e,t,n,i){const r=e.prev,o=e,a=e.next;if(kb(r,o,a)>=0)return!1;const s=r.x<o.x?r.x<a.x?r.x:a.x:o.x<a.x?o.x:a.x,l=r.y<o.y?r.y<a.y?r.y:a.y:o.y<a.y?o.y:a.y,c=r.x>o.x?r.x>a.x?r.x:a.x:o.x>a.x?o.x:a.x,u=r.y>o.y?r.y>a.y?r.y:a.y:o.y>a.y?o.y:a.y,d=Rb(s,l,t,n,i),h=Rb(c,u,t,n,i);let p=e.prevZ,m=e.nextZ;for(;p&&p.z>=d&&m&&m.z<=h;){if(p!==e.prev&&p!==e.next&&Pb(r.x,r.y,o.x,o.y,a.x,a.y,p.x,p.y)&&kb(p.prev,p,p.next)>=0)return!1;if(p=p.prevZ,m!==e.prev&&m!==e.next&&Pb(r.x,r.y,o.x,o.y,a.x,a.y,m.x,m.y)&&kb(m.prev,m,m.next)>=0)return!1;m=m.nextZ}for(;p&&p.z>=d;){if(p!==e.prev&&p!==e.next&&Pb(r.x,r.y,o.x,o.y,a.x,a.y,p.x,p.y)&&kb(p.prev,p,p.next)>=0)return!1;p=p.prevZ}for(;m&&m.z<=h;){if(m!==e.prev&&m!==e.next&&Pb(r.x,r.y,o.x,o.y,a.x,a.y,m.x,m.y)&&kb(m.prev,m,m.next)>=0)return!1;m=m.nextZ}return!0}function Ib(e,t,n){let i=e;do{const r=i.prev,o=i.next.next;!Bb(r,o)&&Fb(r,i,i.next,o)&&Gb(r,o)&&Gb(o,r)&&(t.push(r.i/n),t.push(i.i/n),t.push(o.i/n),Vb(i),Vb(i.next),i=e=o),i=i.next}while(i!==e);return Sb(i)}function Mb(e,t,n,i,r,o){let a=e;do{let e=a.next.next;for(;e!==a.prev;){if(a.i!==e.i&&Db(a,e)){let s=jb(a,e);return a=Sb(a,a.next),s=Sb(s,s.next),Eb(a,t,n,i,r,o),void Eb(s,t,n,i,r,o)}e=e.next}a=a.next}while(a!==e)}function Cb(e,t){return e.x-t.x}function Nb(e,t){if(t=function(e,t){let n=t;const i=e.x,r=e.y;let o,a=-1/0;do{if(r<=n.y&&r>=n.next.y&&n.next.y!==n.y){const e=n.x+(r-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(e<=i&&e>a){if(a=e,e===i){if(r===n.y)return n;if(r===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(i===a)return o;const s=o,l=o.x,c=o.y;let u,d=1/0;n=o;do{i>=n.x&&n.x>=l&&i!==n.x&&Pb(r<c?i:a,r,l,c,r<c?a:i,r,n.x,n.y)&&(u=Math.abs(r-n.y)/(i-n.x),Gb(n,e)&&(u<d||u===d&&(n.x>o.x||n.x===o.x&&Ob(o,n)))&&(o=n,d=u)),n=n.next}while(n!==s);return o}(e,t),t){const n=jb(t,e);Sb(t,t.next),Sb(n,n.next)}}function Ob(e,t){return kb(e.prev,e,t.prev)<0&&kb(t.next,e,e.next)<0}function Rb(e,t,n,i,r){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-n)*r)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-i)*r)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function Lb(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 Pb(e,t,n,i,r,o,a,s){return(r-a)*(t-s)-(e-a)*(o-s)>=0&&(e-a)*(i-s)-(n-a)*(t-s)>=0&&(n-a)*(o-s)-(r-a)*(i-s)>=0}function Db(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&&Fb(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}(e,t)&&(Gb(e,t)&&Gb(t,e)&&function(e,t){let n=e,i=!1;const r=(e.x+t.x)/2,o=(e.y+t.y)/2;do{n.y>o!=n.next.y>o&&n.next.y!==n.y&&r<(n.next.x-n.x)*(o-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next}while(n!==e);return i}(e,t)&&(kb(e.prev,e,t.prev)||kb(e,t.prev,t))||Bb(e,t)&&kb(e.prev,e,e.next)>0&&kb(t.prev,t,t.next)>0)}function kb(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function Bb(e,t){return e.x===t.x&&e.y===t.y}function Fb(e,t,n,i){const r=zb(kb(e,t,n)),o=zb(kb(e,t,i)),a=zb(kb(n,i,e)),s=zb(kb(n,i,t));return r!==o&&a!==s||(!(0!==r||!Ub(e,n,t))||(!(0!==o||!Ub(e,i,t))||(!(0!==a||!Ub(n,e,i))||!(0!==s||!Ub(n,t,i)))))}function Ub(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 zb(e){return e>0?1:e<0?-1:0}function Gb(e,t){return kb(e.prev,e,e.next)<0?kb(e,t,e.next)>=0&&kb(e,e.prev,t)>=0:kb(e,t,e.prev)<0||kb(e,e.next,t)<0}function jb(e,t){const n=new Wb(e.i,e.x,e.y),i=new Wb(t.i,t.x,t.y),r=e.next,o=t.prev;return e.next=t,t.prev=e,n.next=r,r.prev=n,i.next=n,n.prev=i,o.next=i,i.prev=o,i}function Hb(e,t,n,i){const r=new Wb(e,t,n);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function Vb(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 Wb(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 qb{static area(e){const t=e.length;let n=0;for(let i=t-1,r=0;r<t;i=r++)n+=e[i].x*e[r].y-e[r].x*e[i].y;return.5*n}static isClockWise(e){return qb.area(e)<0}static triangulateShape(e,t){const n=[],i=[],r=[];$b(e),Yb(n,e);let o=e.length;t.forEach($b);for(let e=0;e<t.length;e++)i.push(o),o+=t[e].length,Yb(n,t[e]);const a=xb(n,i);for(let e=0;e<a.length;e+=3)r.push(a.slice(e,e+3));return r}}function $b(e){const t=e.length;t>2&&e[t-1].equals(e[0])&&e.pop()}function Yb(e,t){for(let n=0;n<t.length;n++)e.push(t[n].x),e.push(t[n].y)}class Jb extends pf{constructor(e=new bb([new Kh(.5,.5),new Kh(-.5,.5),new Kh(-.5,-.5),new Kh(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];const n=this,i=[],r=[];for(let t=0,n=e.length;t<n;t++){o(e[t])}function o(e){const o=[],a=void 0!==t.curveSegments?t.curveSegments:12,s=void 0!==t.steps?t.steps:1,l=void 0!==t.depth?t.depth:1;let c=void 0===t.bevelEnabled||t.bevelEnabled,u=void 0!==t.bevelThickness?t.bevelThickness:.2,d=void 0!==t.bevelSize?t.bevelSize:u-.1,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:Zb;let g,v,y,_,b,x=!1;m&&(g=m.getSpacedPoints(s),x=!0,c=!1,v=m.computeFrenetFrames(s,!1),y=new Cp,_=new Cp,b=new Cp),c||(p=0,u=0,d=0,h=0);const w=e.extractPoints(a);let S=w.shape;const E=w.holes;if(!qb.isClockWise(S)){S=S.reverse();for(let e=0,t=E.length;e<t;e++){const t=E[e];qb.isClockWise(t)&&(E[e]=t.reverse())}}const A=qb.triangulateShape(S,E),T=S;for(let e=0,t=E.length;e<t;e++){const t=E[e];S=S.concat(t)}function I(e,t,n){return t||console.error("THREE.ExtrudeGeometry: vec does not exist"),t.clone().multiplyScalar(n).add(e)}const M=S.length,C=A.length;function N(e,t,n){let i,r,o;const a=e.x-t.x,s=e.y-t.y,l=n.x-e.x,c=n.y-e.y,u=a*a+s*s,d=a*c-s*l;if(Math.abs(d)>Number.EPSILON){const d=Math.sqrt(u),h=Math.sqrt(l*l+c*c),p=t.x-s/d,m=t.y+a/d,f=((n.x-c/h-p)*c-(n.y+l/h-m)*l)/(a*c-s*l);i=p+a*f-e.x,r=m+s*f-e.y;const g=i*i+r*r;if(g<=2)return new Kh(i,r);o=Math.sqrt(g/2)}else{let e=!1;a>Number.EPSILON?l>Number.EPSILON&&(e=!0):a<-Number.EPSILON?l<-Number.EPSILON&&(e=!0):Math.sign(s)===Math.sign(c)&&(e=!0),e?(i=-s,r=a,o=Math.sqrt(u)):(i=a,r=s,o=Math.sqrt(u/2))}return new Kh(i/o,r/o)}const O=[];for(let e=0,t=T.length,n=t-1,i=e+1;e<t;e++,n++,i++)n===t&&(n=0),i===t&&(i=0),O[e]=N(T[e],T[n],T[i]);const R=[];let L,P=O.concat();for(let e=0,t=E.length;e<t;e++){const t=E[e];L=[];for(let e=0,n=t.length,i=n-1,r=e+1;e<n;e++,i++,r++)i===n&&(i=0),r===n&&(r=0),L[e]=N(t[e],t[i],t[r]);R.push(L),P=P.concat(L)}for(let e=0;e<p;e++){const t=e/p,n=u*Math.cos(t*Math.PI/2),i=d*Math.sin(t*Math.PI/2)+h;for(let e=0,t=T.length;e<t;e++){const t=I(T[e],O[e],i);B(t.x,t.y,-n)}for(let e=0,t=E.length;e<t;e++){const t=E[e];L=R[e];for(let e=0,r=t.length;e<r;e++){const r=I(t[e],L[e],i);B(r.x,r.y,-n)}}}const D=d+h;for(let e=0;e<M;e++){const t=c?I(S[e],P[e],D):S[e];x?(_.copy(v.normals[0]).multiplyScalar(t.x),y.copy(v.binormals[0]).multiplyScalar(t.y),b.copy(g[0]).add(_).add(y),B(b.x,b.y,b.z)):B(t.x,t.y,0)}for(let e=1;e<=s;e++)for(let t=0;t<M;t++){const n=c?I(S[t],P[t],D):S[t];x?(_.copy(v.normals[e]).multiplyScalar(n.x),y.copy(v.binormals[e]).multiplyScalar(n.y),b.copy(g[e]).add(_).add(y),B(b.x,b.y,b.z)):B(n.x,n.y,l/s*e)}for(let e=p-1;e>=0;e--){const t=e/p,n=u*Math.cos(t*Math.PI/2),i=d*Math.sin(t*Math.PI/2)+h;for(let e=0,t=T.length;e<t;e++){const t=I(T[e],O[e],i);B(t.x,t.y,l+n)}for(let e=0,t=E.length;e<t;e++){const t=E[e];L=R[e];for(let e=0,r=t.length;e<r;e++){const r=I(t[e],L[e],i);x?B(r.x,r.y+g[s-1].y,g[s-1].x+n):B(r.x,r.y,l+n)}}}function k(e,t){let n=e.length;for(;--n>=0;){const i=n;let r=n-1;r<0&&(r=e.length-1);for(let e=0,n=s+2*p;e<n;e++){const n=M*e,o=M*(e+1);U(t+i+n,t+r+n,t+r+o,t+i+o)}}}function B(e,t,n){o.push(e),o.push(t),o.push(n)}function F(e,t,r){z(e),z(t),z(r);const o=i.length/3,a=f.generateTopUV(n,i,o-3,o-2,o-1);G(a[0]),G(a[1]),G(a[2])}function U(e,t,r,o){z(e),z(t),z(o),z(t),z(r),z(o);const a=i.length/3,s=f.generateSideWallUV(n,i,a-6,a-3,a-2,a-1);G(s[0]),G(s[1]),G(s[3]),G(s[1]),G(s[2]),G(s[3])}function z(e){i.push(o[3*e+0]),i.push(o[3*e+1]),i.push(o[3*e+2])}function G(e){r.push(e.x),r.push(e.y)}!function(){const e=i.length/3;if(c){let e=0,t=M*e;for(let e=0;e<C;e++){const n=A[e];F(n[2]+t,n[1]+t,n[0]+t)}e=s+2*p,t=M*e;for(let e=0;e<C;e++){const n=A[e];F(n[0]+t,n[1]+t,n[2]+t)}}else{for(let e=0;e<C;e++){const t=A[e];F(t[2],t[1],t[0])}for(let e=0;e<C;e++){const t=A[e];F(t[0]+M*s,t[1]+M*s,t[2]+M*s)}}n.addGroup(e,i.length/3-e,0)}(),function(){const e=i.length/3;let t=0;k(T,t),t+=T.length;for(let e=0,n=E.length;e<n;e++){const n=E[e];k(n,t),t+=n.length}n.addGroup(e,i.length/3-e,1)}()}this.setAttribute("position",new rf(i,3)),this.setAttribute("uv",new rf(r,2)),this.computeVertexNormals()}toJSON(){const e=super.toJSON();return function(e,t,n){if(n.shapes=[],Array.isArray(e))for(let t=0,i=e.length;t<i;t++){const i=e[t];n.shapes.push(i.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 i=0,r=e.shapes.length;i<r;i++){const r=t[e.shapes[i]];n.push(r)}const i=e.options.extrudePath;return void 0!==i&&(e.options.extrudePath=(new ob[i.type]).fromJSON(i)),new Jb(n,e.options)}}const Zb={generateTopUV:function(e,t,n,i,r){const o=t[3*n],a=t[3*n+1],s=t[3*i],l=t[3*i+1],c=t[3*r],u=t[3*r+1];return[new Kh(o,a),new Kh(s,l),new Kh(c,u)]},generateSideWallUV:function(e,t,n,i,r,o){const a=t[3*n],s=t[3*n+1],l=t[3*n+2],c=t[3*i],u=t[3*i+1],d=t[3*i+2],h=t[3*r],p=t[3*r+1],m=t[3*r+2],f=t[3*o],g=t[3*o+1],v=t[3*o+2];return Math.abs(s-u)<Math.abs(a-c)?[new Kh(a,1-l),new Kh(c,1-d),new Kh(h,1-m),new Kh(f,1-v)]:[new Kh(s,1-l),new Kh(u,1-d),new Kh(p,1-m),new Kh(g,1-v)]}};class Xb extends pb{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 Xb(e.radius,e.detail)}}class Kb extends pb{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 Kb(e.radius,e.detail)}}class Qb extends pf{constructor(e=.5,t=1,n=8,i=1,r=0,o=2*Math.PI){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:n,phiSegments:i,thetaStart:r,thetaLength:o},n=Math.max(3,n);const a=[],s=[],l=[],c=[];let u=e;const d=(t-e)/(i=Math.max(1,i)),h=new Cp,p=new Kh;for(let e=0;e<=i;e++){for(let e=0;e<=n;e++){const i=r+e/n*o;h.x=u*Math.cos(i),h.y=u*Math.sin(i),s.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<i;e++){const t=e*(n+1);for(let e=0;e<n;e++){const i=e+t,r=i,o=i+n+1,s=i+n+2,l=i+1;a.push(r,o,l),a.push(o,s,l)}}this.setIndex(a),this.setAttribute("position",new rf(s,3)),this.setAttribute("normal",new rf(l,3)),this.setAttribute("uv",new rf(c,2))}static fromJSON(e){return new Qb(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}}class ex extends pf{constructor(e=new bb([new Kh(0,.5),new Kh(-.5,-.5),new Kh(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};const n=[],i=[],r=[],o=[];let a=0,s=0;if(!1===Array.isArray(e))l(e);else for(let t=0;t<e.length;t++)l(e[t]),this.addGroup(a,s,t),a+=s,s=0;function l(e){const a=i.length/3,l=e.extractPoints(t);let c=l.shape;const u=l.holes;!1===qb.isClockWise(c)&&(c=c.reverse());for(let e=0,t=u.length;e<t;e++){const t=u[e];!0===qb.isClockWise(t)&&(u[e]=t.reverse())}const d=qb.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];i.push(t.x,t.y,0),r.push(0,0,1),o.push(t.x,t.y)}for(let e=0,t=d.length;e<t;e++){const t=d[e],i=t[0]+a,r=t[1]+a,o=t[2]+a;n.push(i,r,o),s+=3}}this.setIndex(n),this.setAttribute("position",new rf(i,3)),this.setAttribute("normal",new rf(r,3)),this.setAttribute("uv",new rf(o,2))}toJSON(){const e=super.toJSON();return function(e,t){if(t.shapes=[],Array.isArray(e))for(let n=0,i=e.length;n<i;n++){const i=e[n];t.shapes.push(i.uuid)}else t.shapes.push(e.uuid);return t}(this.parameters.shapes,e)}static fromJSON(e,t){const n=[];for(let i=0,r=e.shapes.length;i<r;i++){const r=t[e.shapes[i]];n.push(r)}return new ex(n,e.curveSegments)}}class tx extends pf{constructor(e=1,t=32,n=16,i=0,r=2*Math.PI,o=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:i,phiLength:r,thetaStart:o,thetaLength:a},t=Math.max(3,Math.floor(t)),n=Math.max(2,Math.floor(n));const s=Math.min(o+a,Math.PI);let l=0;const c=[],u=new Cp,d=new Cp,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&&s==Math.PI&&(y=-.5/t);for(let n=0;n<=t;n++){const s=n/t;u.x=-e*Math.cos(i+s*r)*Math.sin(o+v*a),u.y=e*Math.cos(o+v*a),u.z=e*Math.sin(i+s*r)*Math.sin(o+v*a),p.push(u.x,u.y,u.z),d.copy(u).normalize(),m.push(d.x,d.y,d.z),f.push(s+y,1-v),g.push(l++)}c.push(g)}for(let e=0;e<n;e++)for(let i=0;i<t;i++){const t=c[e][i+1],r=c[e][i],a=c[e+1][i],l=c[e+1][i+1];(0!==e||o>0)&&h.push(t,r,l),(e!==n-1||s<Math.PI)&&h.push(r,a,l)}this.setIndex(h),this.setAttribute("position",new rf(p,3)),this.setAttribute("normal",new rf(m,3)),this.setAttribute("uv",new rf(f,2))}static fromJSON(e){return new tx(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class nx extends pb{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 nx(e.radius,e.detail)}}class ix extends pf{constructor(e=1,t=.4,n=8,i=6,r=2*Math.PI){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:n,tubularSegments:i,arc:r},n=Math.floor(n),i=Math.floor(i);const o=[],a=[],s=[],l=[],c=new Cp,u=new Cp,d=new Cp;for(let o=0;o<=n;o++)for(let h=0;h<=i;h++){const p=h/i*r,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),a.push(u.x,u.y,u.z),c.x=e*Math.cos(p),c.y=e*Math.sin(p),d.subVectors(u,c).normalize(),s.push(d.x,d.y,d.z),l.push(h/i),l.push(o/n)}for(let e=1;e<=n;e++)for(let t=1;t<=i;t++){const n=(i+1)*e+t-1,r=(i+1)*(e-1)+t-1,a=(i+1)*(e-1)+t,s=(i+1)*e+t;o.push(n,r,s),o.push(r,a,s)}this.setIndex(o),this.setAttribute("position",new rf(a,3)),this.setAttribute("normal",new rf(s,3)),this.setAttribute("uv",new rf(l,2))}static fromJSON(e){return new ix(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}class rx extends pf{constructor(e=1,t=.4,n=64,i=8,r=2,o=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:n,radialSegments:i,p:r,q:o},n=Math.floor(n),i=Math.floor(i);const a=[],s=[],l=[],c=[],u=new Cp,d=new Cp,h=new Cp,p=new Cp,m=new Cp,f=new Cp,g=new Cp;for(let a=0;a<=n;++a){const y=a/n*r*Math.PI*2;v(y,r,o,e,h),v(y+.01,r,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<=i;++e){const r=e/i*Math.PI*2,o=-t*Math.cos(r),p=t*Math.sin(r);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),s.push(u.x,u.y,u.z),d.subVectors(u,h).normalize(),l.push(d.x,d.y,d.z),c.push(a/n),c.push(e/i)}}for(let e=1;e<=n;e++)for(let t=1;t<=i;t++){const n=(i+1)*(e-1)+(t-1),r=(i+1)*e+(t-1),o=(i+1)*e+t,s=(i+1)*(e-1)+t;a.push(n,r,s),a.push(r,o,s)}function v(e,t,n,i,r){const o=Math.cos(e),a=Math.sin(e),s=n/t*e,l=Math.cos(s);r.x=i*(2+l)*.5*o,r.y=i*(2+l)*a*.5,r.z=i*Math.sin(s)*.5}this.setIndex(a),this.setAttribute("position",new rf(s,3)),this.setAttribute("normal",new rf(l,3)),this.setAttribute("uv",new rf(c,2))}static fromJSON(e){return new rx(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}}class ox extends pf{constructor(e=new ib(new Cp(-1,-1,0),new Cp(-1,1,0),new Cp(1,1,0)),t=64,n=1,i=8,r=!1){super(),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:n,radialSegments:i,closed:r};const o=e.computeFrenetFrames(t,r);this.tangents=o.tangents,this.normals=o.normals,this.binormals=o.binormals;const a=new Cp,s=new Cp,l=new Kh;let c=new Cp;const u=[],d=[],h=[],p=[];function m(r){c=e.getPointAt(r/t,c);const l=o.normals[r],h=o.binormals[r];for(let e=0;e<=i;e++){const t=e/i*Math.PI*2,r=Math.sin(t),o=-Math.cos(t);s.x=o*l.x+r*h.x,s.y=o*l.y+r*h.y,s.z=o*l.z+r*h.z,s.normalize(),d.push(s.x,s.y,s.z),a.x=c.x+n*s.x,a.y=c.y+n*s.y,a.z=c.z+n*s.z,u.push(a.x,a.y,a.z)}}!function(){for(let e=0;e<t;e++)m(e);m(!1===r?t:0),function(){for(let e=0;e<=t;e++)for(let n=0;n<=i;n++)l.x=e/t,l.y=n/i,h.push(l.x,l.y)}(),function(){for(let e=1;e<=t;e++)for(let t=1;t<=i;t++){const n=(i+1)*(e-1)+(t-1),r=(i+1)*e+(t-1),o=(i+1)*e+t,a=(i+1)*(e-1)+t;p.push(n,r,a),p.push(r,o,a)}}()}(),this.setIndex(p),this.setAttribute("position",new rf(u,3)),this.setAttribute("normal",new rf(d,3)),this.setAttribute("uv",new rf(h,2))}toJSON(){const e=super.toJSON();return e.path=this.parameters.path.toJSON(),e}static fromJSON(e){return new ox((new ob[e.path.type]).fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}}class ax extends pf{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},null!==e){const t=[],n=new Set,i=new Cp,r=new Cp;if(null!==e.index){const o=e.attributes.position,a=e.index;let s=e.groups;0===s.length&&(s=[{start:0,count:a.count,materialIndex:0}]);for(let e=0,l=s.length;e<l;++e){const l=s[e],c=l.start;for(let e=c,s=c+l.count;e<s;e+=3)for(let s=0;s<3;s++){const l=a.getX(e+s),c=a.getX(e+(s+1)%3);i.fromBufferAttribute(o,l),r.fromBufferAttribute(o,c),!0===sx(i,r,n)&&(t.push(i.x,i.y,i.z),t.push(r.x,r.y,r.z))}}}else{const o=e.attributes.position;for(let e=0,a=o.count/3;e<a;e++)for(let a=0;a<3;a++){const s=3*e+a,l=3*e+(a+1)%3;i.fromBufferAttribute(o,s),r.fromBufferAttribute(o,l),!0===sx(i,r,n)&&(t.push(i.x,i.y,i.z),t.push(r.x,r.y,r.z))}}this.setAttribute("position",new rf(t,3))}}}function sx(e,t,n){const i=`${e.x},${e.y},${e.z}-${t.x},${t.y},${t.z}`,r=`${t.x},${t.y},${t.z}-${e.x},${e.y},${e.z}`;return!0!==n.has(i)&&!0!==n.has(r)&&(n.add(i),n.add(r),!0)}var lx=Object.freeze({__proto__:null,BoxGeometry:Lf,CapsuleGeometry:cb,CircleGeometry:ub,ConeGeometry:hb,CylinderGeometry:db,DodecahedronGeometry:mb,EdgesGeometry:_b,ExtrudeGeometry:Jb,IcosahedronGeometry:Xb,LatheGeometry:lb,OctahedronGeometry:Kb,PlaneGeometry:Qf,PolyhedronGeometry:pb,RingGeometry:Qb,ShapeGeometry:ex,SphereGeometry:tx,TetrahedronGeometry:nx,TorusGeometry:ix,TorusKnotGeometry:rx,TubeGeometry:ox,WireframeGeometry:ax});class cx extends Vm{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new mp(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 ux extends Bf{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class dx extends Vm{constructor(e){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new mp(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 mp(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=rh,this.normalScale=new Kh(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 hx extends dx{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 Kh(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Hh(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 mp(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 mp(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new mp(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 px extends Vm{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new mp(16777215),this.specular=new mp(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new mp(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=rh,this.normalScale=new Kh(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=vu,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 mx extends Vm{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new mp(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new mp(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=rh,this.normalScale=new Kh(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 fx extends Vm{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=rh,this.normalScale=new Kh(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 gx extends Vm{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new mp(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new mp(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=rh,this.normalScale=new Kh(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=vu,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 vx extends Vm{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new mp(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=rh,this.normalScale=new Kh(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 yx extends y_{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 _x(e,t,n){return xx(e)?new e.constructor(e.subarray(t,void 0!==n?n:e.length)):e.slice(t,n)}function bx(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 xx(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function wx(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 Sx(e,t,n){const i=e.length,r=new e.constructor(i);for(let o=0,a=0;a!==i;++o){const i=n[o]*t;for(let n=0;n!==t;++n)r[a++]=e[i+n]}return r}function Ex(e,t,n,i){let r=1,o=e[0];for(;void 0!==o&&void 0===o[i];)o=e[r++];if(void 0===o)return;let a=o[i];if(void 0!==a)if(Array.isArray(a))do{a=o[i],void 0!==a&&(t.push(o.time),n.push.apply(n,a)),o=e[r++]}while(void 0!==o);else if(void 0!==a.toArray)do{a=o[i],void 0!==a&&(t.push(o.time),a.toArray(n,n.length)),o=e[r++]}while(void 0!==o);else do{a=o[i],void 0!==a&&(t.push(o.time),n.push(a)),o=e[r++]}while(void 0!==o)}var Ax=Object.freeze({__proto__:null,arraySlice:_x,convertArray:bx,isTypedArray:xx,getKeyframeOrder:wx,sortedArray:Sx,flattenJSON:Ex,subclip:function(e,t,n,i,r=30){const o=e.clone();o.name=t;const a=[];for(let e=0;e<o.tracks.length;++e){const t=o.tracks[e],s=t.getValueSize(),l=[],c=[];for(let e=0;e<t.times.length;++e){const o=t.times[e]*r;if(!(o<n||o>=i)){l.push(t.times[e]);for(let n=0;n<s;++n)c.push(t.values[e*s+n])}}0!==l.length&&(t.times=bx(l,t.times.constructor),t.values=bx(c,t.values.constructor),a.push(t))}o.tracks=a;let s=1/0;for(let e=0;e<o.tracks.length;++e)s>o.tracks[e].times[0]&&(s=o.tracks[e].times[0]);for(let e=0;e<o.tracks.length;++e)o.tracks[e].shift(-1*s);return o.resetDuration(),o},makeClipAdditive:function(e,t=0,n=e,i=30){i<=0&&(i=30);const r=n.tracks.length,o=t/i;for(let t=0;t<r;++t){const i=n.tracks[t],r=i.ValueTypeName;if("bool"===r||"string"===r)continue;const a=e.tracks.find((function(e){return e.name===i.name&&e.ValueTypeName===r}));if(void 0===a)continue;let s=0;const l=i.getValueSize();i.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(s=l/3);let c=0;const u=a.getValueSize();a.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(c=u/3);const d=i.times.length-1;let h;if(o<=i.times[0]){const e=s,t=l-s;h=_x(i.values,e,t)}else if(o>=i.times[d]){const e=d*l+s,t=e+l-s;h=_x(i.values,e,t)}else{const e=i.createInterpolant(),t=s,n=l-s;e.evaluate(o),h=_x(e.resultBuffer,t,n)}if("quaternion"===r){(new Mp).fromArray(h).normalize().conjugate().toArray(h)}const p=a.times.length;for(let e=0;e<p;++e){const t=e*u+c;if("quaternion"===r)Mp.multiplyQuaternionsFlat(a.values,t,h,0,a.values,t);else{const e=u-2*c;for(let n=0;n<e;++n)a.values[t+n]-=h[n]}}}return e.blendMode=Zd,e}});class Tx{constructor(e,t,n,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=void 0!==i?i:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let n=this._cachedIndex,i=t[n],r=t[n-1];e:{t:{let o;n:{i:if(!(e<i)){for(let o=n+2;;){if(void 0===i){if(e<r)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===o)break;if(r=i,i=t[++n],e<i)break t}o=t.length;break n}if(e>=r)break e;{const a=t[1];e<a&&(n=2,r=a);for(let o=n-2;;){if(void 0===r)return this._cachedIndex=0,this.copySampleValue_(0);if(n===o)break;if(i=r,r=t[--n-1],e>=r)break t}o=n,n=0}}for(;n<o;){const i=n+o>>>1;e<t[i]?o=i:n=i+1}if(i=t[n],r=t[n-1],void 0===r)return this._cachedIndex=0,this.copySampleValue_(0);if(void 0===i)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,r,i)}return this.interpolate_(n,r,e,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i;for(let e=0;e!==i;++e)t[e]=n[r+e];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class Ix extends Tx{constructor(e,t,n,i){super(e,t,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:qd,endingEnd:qd}}intervalChanged_(e,t,n){const i=this.parameterPositions;let r=e-2,o=e+1,a=i[r],s=i[o];if(void 0===a)switch(this.getSettings_().endingStart){case $d:r=e,a=2*t-n;break;case Yd:r=i.length-2,a=t+i[r]-i[r+1];break;default:r=e,a=n}if(void 0===s)switch(this.getSettings_().endingEnd){case $d:o=e,s=2*n-t;break;case Yd:o=1,s=n+i[1]-i[0];break;default:o=e-1,s=t}const l=.5*(n-t),c=this.valueSize;this._weightPrev=l/(t-a),this._weightNext=l/(s-n),this._offsetPrev=r*c,this._offsetNext=o*c}interpolate_(e,t,n,i){const r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,s=e*a,l=s-a,c=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,h=this._weightNext,p=(n-t)/(i-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!==a;++e)r[e]=g*o[c+e]+v*o[l+e]+y*o[s+e]+_*o[u+e];return r}}class Mx extends Tx{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,s=e*a,l=s-a,c=(n-t)/(i-t),u=1-c;for(let e=0;e!==a;++e)r[e]=o[l+e]*u+o[s+e]*c;return r}}class Cx extends Tx{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e){return this.copySampleValue_(e-1)}}class Nx{constructor(e,t,n,i){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=bx(t,this.TimeBufferType),this.values=bx(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:bx(e.times,Array),values:bx(e.values,Array)};const t=e.getInterpolation();t!==e.DefaultInterpolation&&(n.interpolation=t)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new Cx(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Mx(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new Ix(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case Hd:t=this.InterpolantFactoryMethodDiscrete;break;case Vd:t=this.InterpolantFactoryMethodLinear;break;case Wd: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 Hd;case this.InterpolantFactoryMethodLinear:return Vd;case this.InterpolantFactoryMethodSmooth:return Wd}}getValueSize(){return this.values.length/this.times.length}shift(e){if(0!==e){const t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]+=e}return this}scale(e){if(1!==e){const t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]*=e}return this}trim(e,t){const n=this.times,i=n.length;let r=0,o=i-1;for(;r!==i&&n[r]<e;)++r;for(;-1!==o&&n[o]>t;)--o;if(++o,0!==r||o!==i){r>=o&&(o=Math.max(o,1),r=o-1);const e=this.getValueSize();this.times=_x(n,r,o),this.values=_x(this.values,r*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,i=this.values,r=n.length;0===r&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let t=0;t!==r;t++){const i=n[t];if("number"==typeof i&&isNaN(i)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,t,i),e=!1;break}if(null!==o&&o>i){console.error("THREE.KeyframeTrack: Out of order keys.",this,t,i,o),e=!1;break}o=i}if(void 0!==i&&xx(i))for(let t=0,n=i.length;t!==n;++t){const n=i[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=_x(this.times),t=_x(this.values),n=this.getValueSize(),i=this.getInterpolation()===Wd,r=e.length-1;let o=1;for(let a=1;a<r;++a){let r=!1;const s=e[a];if(s!==e[a+1]&&(1!==a||s!==e[0]))if(i)r=!0;else{const e=a*n,i=e-n,o=e+n;for(let a=0;a!==n;++a){const n=t[e+a];if(n!==t[i+a]||n!==t[o+a]){r=!0;break}}}if(r){if(a!==o){e[o]=e[a];const i=a*n,r=o*n;for(let e=0;e!==n;++e)t[r+e]=t[i+e]}++o}}if(r>0){e[o]=e[r];for(let e=r*n,i=o*n,a=0;a!==n;++a)t[i+a]=t[e+a];++o}return o!==e.length?(this.times=_x(e,0,o),this.values=_x(t,0,o*n)):(this.times=e,this.values=t),this}clone(){const e=_x(this.times,0),t=_x(this.values,0),n=new(0,this.constructor)(this.name,e,t);return n.createInterpolant=this.createInterpolant,n}}Nx.prototype.TimeBufferType=Float32Array,Nx.prototype.ValueBufferType=Float32Array,Nx.prototype.DefaultInterpolation=Vd;class Ox extends Nx{}Ox.prototype.ValueTypeName="bool",Ox.prototype.ValueBufferType=Array,Ox.prototype.DefaultInterpolation=Hd,Ox.prototype.InterpolantFactoryMethodLinear=void 0,Ox.prototype.InterpolantFactoryMethodSmooth=void 0;class Rx extends Nx{}Rx.prototype.ValueTypeName="color";class Lx extends Nx{}Lx.prototype.ValueTypeName="number";class Px extends Tx{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,s=(n-t)/(i-t);let l=e*a;for(let e=l+a;l!==e;l+=4)Mp.slerpFlat(r,0,o,l-a,o,l,s);return r}}class Dx extends Nx{InterpolantFactoryMethodLinear(e){return new Px(this.times,this.values,this.getValueSize(),e)}}Dx.prototype.ValueTypeName="quaternion",Dx.prototype.DefaultInterpolation=Vd,Dx.prototype.InterpolantFactoryMethodSmooth=void 0;class kx extends Nx{}kx.prototype.ValueTypeName="string",kx.prototype.ValueBufferType=Array,kx.prototype.DefaultInterpolation=Hd,kx.prototype.InterpolantFactoryMethodLinear=void 0,kx.prototype.InterpolantFactoryMethodSmooth=void 0;class Bx extends Nx{}Bx.prototype.ValueTypeName="vector";class Fx{constructor(e,t=-1,n,i=Jd){this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=jh(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,i=1/(e.fps||1);for(let e=0,r=n.length;e!==r;++e)t.push(Ux(n[e]).scale(i));const r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r}static toJSON(e){const t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let e=0,i=n.length;e!==i;++e)t.push(Nx.toJSON(n[e]));return i}static CreateFromMorphTargetSequence(e,t,n,i){const r=t.length,o=[];for(let e=0;e<r;e++){let a=[],s=[];a.push((e+r-1)%r,e,(e+1)%r),s.push(0,1,0);const l=wx(a);a=Sx(a,1,l),s=Sx(s,1,l),i||0!==a[0]||(a.push(r),s.push(s[0])),o.push(new Lx(".morphTargetInfluences["+t[e].name+"]",a,s).scale(1/n))}return new this(e,-1,o)}static findByName(e,t){let n=e;if(!Array.isArray(e)){const t=e;n=t.geometry&&t.geometry.animations||t.animations}for(let e=0;e<n.length;e++)if(n[e].name===t)return n[e];return null}static CreateClipsFromMorphTargetSequences(e,t,n){const i={},r=/^([\w-]*?)([\d]+)$/;for(let t=0,n=e.length;t<n;t++){const n=e[t],o=n.name.match(r);if(o&&o.length>1){const e=o[1];let t=i[e];t||(i[e]=t=[]),t.push(n)}}const o=[];for(const e in i)o.push(this.CreateFromMorphTargetSequence(e,i[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,i,r){if(0!==n.length){const o=[],a=[];Ex(n,o,a,i),0!==o.length&&r.push(new e(t,o,a))}},i=[],r=e.name||"default",o=e.fps||30,a=e.blendMode;let s=e.length||-1;const l=e.hierarchy||[];for(let e=0;e<l.length;e++){const r=l[e].keys;if(r&&0!==r.length)if(r[0].morphTargets){const e={};let t;for(t=0;t<r.length;t++)if(r[t].morphTargets)for(let n=0;n<r[t].morphTargets.length;n++)e[r[t].morphTargets[n]]=-1;for(const n in e){const e=[],o=[];for(let i=0;i!==r[t].morphTargets.length;++i){const i=r[t];e.push(i.time),o.push(i.morphTarget===n?1:0)}i.push(new Lx(".morphTargetInfluence["+n+"]",e,o))}s=e.length*o}else{const o=".bones["+t[e].name+"]";n(Bx,o+".position",r,"pos",i),n(Dx,o+".quaternion",r,"rot",i),n(Bx,o+".scale",r,"scl",i)}}if(0===i.length)return null;return new this(r,s,i,a)}resetDuration(){let e=0;for(let t=0,n=this.tracks.length;t!==n;++t){const n=this.tracks[t];e=Math.max(e,n.times[n.times.length-1])}return this.duration=e,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}function Ux(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 Lx;case"vector":case"vector2":case"vector3":case"vector4":return Bx;case"color":return Rx;case"quaternion":return Dx;case"bool":case"boolean":return Ox;case"string":return kx}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}(e.type);if(void 0===e.times){const t=[],n=[];Ex(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 zx={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 Gx{constructor(e,t,n){const i=this;let r,o=!1,a=0,s=0;const l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(e){s++,!1===o&&void 0!==i.onStart&&i.onStart(e,a,s),o=!0},this.itemEnd=function(e){a++,void 0!==i.onProgress&&i.onProgress(e,a,s),a===s&&(o=!1,void 0!==i.onLoad&&i.onLoad())},this.itemError=function(e){void 0!==i.onError&&i.onError(e)},this.resolveURL=function(e){return r?r(e):e},this.setURLModifier=function(e){return r=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],i=l[t+1];if(n.global&&(n.lastIndex=0),n.test(e))return i}return null}}}const jx=new Gx;class Hx{constructor(e){this.manager=void 0!==e?e:jx,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const n=this;return new Promise((function(i,r){n.load(e,i,t,r)}))}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}}const Vx={};class Wx extends Error{constructor(e,t){super(e),this.response=t}}class qx extends Hx{constructor(e){super(e)}load(e,t,n,i){void 0===e&&(e=""),void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);const r=zx.get(e);if(void 0!==r)return this.manager.itemStart(e),setTimeout((()=>{t&&t(r),this.manager.itemEnd(e)}),0),r;if(void 0!==Vx[e])return void Vx[e].push({onLoad:t,onProgress:n,onError:i});Vx[e]=[],Vx[e].push({onLoad:t,onProgress:n,onError:i});const o=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,s=this.responseType;fetch(o).then((t=>{if(200===t.status||0===t.status){if(0===t.status&&console.warn("THREE.FileLoader: HTTP Status 0 received."),"undefined"==typeof ReadableStream||void 0===t.body||void 0===t.body.getReader)return t;const n=Vx[e],i=t.body.getReader(),r=t.headers.get("Content-Length"),o=r?parseInt(r):0,a=0!==o;let s=0;const l=new ReadableStream({start(e){!function t(){i.read().then((({done:i,value:r})=>{if(i)e.close();else{s+=r.byteLength;const i=new ProgressEvent("progress",{lengthComputable:a,loaded:s,total:o});for(let e=0,t=n.length;e<t;e++){const t=n[e];t.onProgress&&t.onProgress(i)}e.enqueue(r),t()}}))}()}});return new Response(l)}throw new Wx(`fetch for "${t.url}" responded with ${t.status}: ${t.statusText}`,t)})).then((e=>{switch(s){case"arraybuffer":return e.arrayBuffer();case"blob":return e.blob();case"document":return e.text().then((e=>(new DOMParser).parseFromString(e,a)));case"json":return e.json();default:if(void 0===a)return e.text();{const t=/charset="?([^;"\s]*)"?/i.exec(a),n=t&&t[1]?t[1].toLowerCase():void 0,i=new TextDecoder(n);return e.arrayBuffer().then((e=>i.decode(e)))}}})).then((t=>{zx.add(e,t);const n=Vx[e];delete Vx[e];for(let e=0,i=n.length;e<i;e++){const i=n[e];i.onLoad&&i.onLoad(t)}})).catch((t=>{const n=Vx[e];if(void 0===n)throw this.manager.itemError(e),t;delete Vx[e];for(let e=0,i=n.length;e<i;e++){const i=n[e];i.onError&&i.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 $x extends Hx{constructor(e){super(e)}load(e,t,n,i){const r=this,o=new qx(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,(function(n){try{t(r.parse(JSON.parse(n)))}catch(t){i?i(t):console.error(t),r.manager.itemError(e)}}),n,i)}parse(e){const t=[];for(let n=0;n<e.length;n++){const i=Fx.parse(e[n]);t.push(i)}return t}}class Yx extends Hx{constructor(e){super(e)}load(e,t,n,i){const r=this,o=[],a=new F_,s=new qx(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(r.withCredentials);let l=0;function c(c){s.load(e[c],(function(e){const n=r.parse(e,!0);o[c]={width:n.width,height:n.height,format:n.format,mipmaps:n.mipmaps},l+=1,6===l&&(1===n.mipmapCount&&(a.minFilter=zu),a.image=o,a.format=n.format,a.needsUpdate=!0,t&&t(a))}),n,i)}if(Array.isArray(e))for(let t=0,n=e.length;t<n;++t)c(t);else s.load(e,(function(e){const n=r.parse(e,!0);if(n.isCubemap){const e=n.mipmaps.length/n.mipmapCount;for(let t=0;t<e;t++){o[t]={mipmaps:[]};for(let e=0;e<n.mipmapCount;e++)o[t].mipmaps.push(n.mipmaps[t*n.mipmapCount+e]),o[t].format=n.format,o[t].width=n.width,o[t].height=n.height}a.image=o}else a.image.width=n.width,a.image.height=n.height,a.mipmaps=n.mipmaps;1===n.mipmapCount&&(a.minFilter=zu),a.format=n.format,a.needsUpdate=!0,t&&t(a)}),n,i);return a}}class Jx extends Hx{constructor(e){super(e)}load(e,t,n,i){void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,o=zx.get(e);if(void 0!==o)return r.manager.itemStart(e),setTimeout((function(){t&&t(o),r.manager.itemEnd(e)}),0),o;const a=ip("img");function s(){c(),zx.add(e,this),t&&t(this),r.manager.itemEnd(e)}function l(t){c(),i&&i(t),r.manager.itemError(e),r.manager.itemEnd(e)}function c(){a.removeEventListener("load",s,!1),a.removeEventListener("error",l,!1)}return a.addEventListener("load",s,!1),a.addEventListener("error",l,!1),"data:"!==e.slice(0,5)&&void 0!==this.crossOrigin&&(a.crossOrigin=this.crossOrigin),r.manager.itemStart(e),a.src=e,a}}class Zx extends Hx{constructor(e){super(e)}load(e,t,n,i){const r=new jf,o=new Jx(this.manager);o.setCrossOrigin(this.crossOrigin),o.setPath(this.path);let a=0;function s(n){o.load(e[n],(function(e){r.images[n]=e,a++,6===a&&(r.needsUpdate=!0,t&&t(r))}),void 0,i)}for(let t=0;t<e.length;++t)s(t);return r}}class Xx extends Hx{constructor(e){super(e)}load(e,t,n,i){const r=this,o=new l_,a=new qx(this.manager);return a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setPath(this.path),a.setWithCredentials(r.withCredentials),a.load(e,(function(e){const n=r.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:Lu,o.wrapT=void 0!==n.wrapT?n.wrapT:Lu,o.magFilter=void 0!==n.magFilter?n.magFilter:zu,o.minFilter=void 0!==n.minFilter?n.minFilter:zu,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=Hu),1===n.mipmapCount&&(o.minFilter=zu),void 0!==n.generateMipmaps&&(o.generateMipmaps=n.generateMipmaps),o.needsUpdate=!0,t&&t(o,n))}),n,i),o}}class Kx extends Hx{constructor(e){super(e)}load(e,t,n,i){const r=new bp,o=new Jx(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(e,(function(e){r.image=e,r.needsUpdate=!0,void 0!==t&&t(r)}),n,i),r}}class Qx extends Om{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new mp(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 ew extends Qx{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Om.DefaultUp),this.updateMatrix(),this.groundColor=new mp(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}}const tw=new am,nw=new Cp,iw=new Cp;class rw{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Kh(512,512),this.map=null,this.mapPass=null,this.matrix=new am,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Zf,this._frameExtents=new Kh(1,1),this._viewportCount=1,this._viewports=[new xp(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;nw.setFromMatrixPosition(e.matrixWorld),t.position.copy(nw),iw.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(iw),t.updateMatrixWorld(),tw.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(tw),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 ow extends rw{constructor(){super(new Uf(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){const t=this.camera,n=2*Gh*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height,r=e.distance||t.far;n===t.fov&&i===t.aspect&&r===t.far||(t.fov=n,t.aspect=i,t.far=r,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class aw extends Qx{constructor(e,t,n=0,i=Math.PI/3,r=0,o=1){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Om.DefaultUp),this.updateMatrix(),this.target=new Om,this.distance=n,this.angle=i,this.penumbra=r,this.decay=o,this.map=null,this.shadow=new ow}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 sw=new am,lw=new Cp,cw=new Cp;class uw extends rw{constructor(){super(new Uf(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new Kh(4,2),this._viewportCount=6,this._viewports=[new xp(2,1,1,1),new xp(0,1,1,1),new xp(3,1,1,1),new xp(1,1,1,1),new xp(3,0,1,1),new xp(1,0,1,1)],this._cubeDirections=[new Cp(1,0,0),new Cp(-1,0,0),new Cp(0,0,1),new Cp(0,0,-1),new Cp(0,1,0),new Cp(0,-1,0)],this._cubeUps=[new Cp(0,1,0),new Cp(0,1,0),new Cp(0,1,0),new Cp(0,1,0),new Cp(0,0,1),new Cp(0,0,-1)]}updateMatrices(e,t=0){const n=this.camera,i=this.matrix,r=e.distance||n.far;r!==n.far&&(n.far=r,n.updateProjectionMatrix()),lw.setFromMatrixPosition(e.matrixWorld),n.position.copy(lw),cw.copy(n.position),cw.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(cw),n.updateMatrixWorld(),i.makeTranslation(-lw.x,-lw.y,-lw.z),sw.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(sw)}}class dw extends Qx{constructor(e,t,n=0,i=1){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new uw}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 hw extends rw{constructor(){super(new cg(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class pw extends Qx{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Om.DefaultUp),this.updateMatrix(),this.target=new Om,this.shadow=new hw}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class mw extends Qx{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class fw extends Qx{constructor(e,t,n=10,i=10){super(e,t),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=n,this.height=i}get power(){return this.intensity*this.width*this.height*Math.PI}set power(e){this.intensity=e/(this.width*this.height*Math.PI)}copy(e){return super.copy(e),this.width=e.width,this.height=e.height,this}toJSON(e){const t=super.toJSON(e);return t.object.width=this.width,t.object.height=this.height,t}}class gw{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new Cp)}set(e){for(let t=0;t<9;t++)this.coefficients[t].copy(e[t]);return this}zero(){for(let e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this}getAt(e,t){const n=e.x,i=e.y,r=e.z,o=this.coefficients;return t.copy(o[0]).multiplyScalar(.282095),t.addScaledVector(o[1],.488603*i),t.addScaledVector(o[2],.488603*r),t.addScaledVector(o[3],.488603*n),t.addScaledVector(o[4],n*i*1.092548),t.addScaledVector(o[5],i*r*1.092548),t.addScaledVector(o[6],.315392*(3*r*r-1)),t.addScaledVector(o[7],n*r*1.092548),t.addScaledVector(o[8],.546274*(n*n-i*i)),t}getIrradianceAt(e,t){const n=e.x,i=e.y,r=e.z,o=this.coefficients;return t.copy(o[0]).multiplyScalar(.886227),t.addScaledVector(o[1],1.023328*i),t.addScaledVector(o[2],1.023328*r),t.addScaledVector(o[3],1.023328*n),t.addScaledVector(o[4],.858086*n*i),t.addScaledVector(o[5],.858086*i*r),t.addScaledVector(o[6],.743125*r*r-.247708),t.addScaledVector(o[7],.858086*n*r),t.addScaledVector(o[8],.429043*(n*n-i*i)),t}add(e){for(let t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}addScaledSH(e,t){for(let n=0;n<9;n++)this.coefficients[n].addScaledVector(e.coefficients[n],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let n=0;n<9;n++)this.coefficients[n].lerp(e.coefficients[n],t);return this}equals(e){for(let t=0;t<9;t++)if(!this.coefficients[t].equals(e.coefficients[t]))return!1;return!0}copy(e){return this.set(e.coefficients)}clone(){return(new this.constructor).copy(this)}fromArray(e,t=0){const n=this.coefficients;for(let i=0;i<9;i++)n[i].fromArray(e,t+3*i);return this}toArray(e=[],t=0){const n=this.coefficients;for(let i=0;i<9;i++)n[i].toArray(e,t+3*i);return e}static getBasisAt(e,t){const n=e.x,i=e.y,r=e.z;t[0]=.282095,t[1]=.488603*i,t[2]=.488603*r,t[3]=.488603*n,t[4]=1.092548*n*i,t[5]=1.092548*i*r,t[6]=.315392*(3*r*r-1),t[7]=1.092548*n*r,t[8]=.546274*(n*n-i*i)}}class vw extends Qx{constructor(e=new gw,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 yw extends Hx{constructor(e){super(e),this.textures={}}load(e,t,n,i){const r=this,o=new qx(r.manager);o.setPath(r.path),o.setRequestHeader(r.requestHeader),o.setWithCredentials(r.withCredentials),o.load(e,(function(n){try{t(r.parse(JSON.parse(n)))}catch(t){i?i(t):console.error(t),r.manager.itemError(e)}}),n,i)}parse(e){const t=this.textures;function n(e){return void 0===t[e]&&console.warn("THREE.MaterialLoader: Undefined texture",e),t[e]}const i=yw.createMaterialFromType(e.type);if(void 0!==e.uuid&&(i.uuid=e.uuid),void 0!==e.name&&(i.name=e.name),void 0!==e.color&&void 0!==i.color&&i.color.setHex(e.color),void 0!==e.roughness&&(i.roughness=e.roughness),void 0!==e.metalness&&(i.metalness=e.metalness),void 0!==e.sheen&&(i.sheen=e.sheen),void 0!==e.sheenColor&&(i.sheenColor=(new mp).setHex(e.sheenColor)),void 0!==e.sheenRoughness&&(i.sheenRoughness=e.sheenRoughness),void 0!==e.emissive&&void 0!==i.emissive&&i.emissive.setHex(e.emissive),void 0!==e.specular&&void 0!==i.specular&&i.specular.setHex(e.specular),void 0!==e.specularIntensity&&(i.specularIntensity=e.specularIntensity),void 0!==e.specularColor&&void 0!==i.specularColor&&i.specularColor.setHex(e.specularColor),void 0!==e.shininess&&(i.shininess=e.shininess),void 0!==e.clearcoat&&(i.clearcoat=e.clearcoat),void 0!==e.clearcoatRoughness&&(i.clearcoatRoughness=e.clearcoatRoughness),void 0!==e.iridescence&&(i.iridescence=e.iridescence),void 0!==e.iridescenceIOR&&(i.iridescenceIOR=e.iridescenceIOR),void 0!==e.iridescenceThicknessRange&&(i.iridescenceThicknessRange=e.iridescenceThicknessRange),void 0!==e.transmission&&(i.transmission=e.transmission),void 0!==e.thickness&&(i.thickness=e.thickness),void 0!==e.attenuationDistance&&(i.attenuationDistance=e.attenuationDistance),void 0!==e.attenuationColor&&void 0!==i.attenuationColor&&i.attenuationColor.setHex(e.attenuationColor),void 0!==e.fog&&(i.fog=e.fog),void 0!==e.flatShading&&(i.flatShading=e.flatShading),void 0!==e.blending&&(i.blending=e.blending),void 0!==e.combine&&(i.combine=e.combine),void 0!==e.side&&(i.side=e.side),void 0!==e.shadowSide&&(i.shadowSide=e.shadowSide),void 0!==e.opacity&&(i.opacity=e.opacity),void 0!==e.transparent&&(i.transparent=e.transparent),void 0!==e.alphaTest&&(i.alphaTest=e.alphaTest),void 0!==e.depthTest&&(i.depthTest=e.depthTest),void 0!==e.depthWrite&&(i.depthWrite=e.depthWrite),void 0!==e.colorWrite&&(i.colorWrite=e.colorWrite),void 0!==e.stencilWrite&&(i.stencilWrite=e.stencilWrite),void 0!==e.stencilWriteMask&&(i.stencilWriteMask=e.stencilWriteMask),void 0!==e.stencilFunc&&(i.stencilFunc=e.stencilFunc),void 0!==e.stencilRef&&(i.stencilRef=e.stencilRef),void 0!==e.stencilFuncMask&&(i.stencilFuncMask=e.stencilFuncMask),void 0!==e.stencilFail&&(i.stencilFail=e.stencilFail),void 0!==e.stencilZFail&&(i.stencilZFail=e.stencilZFail),void 0!==e.stencilZPass&&(i.stencilZPass=e.stencilZPass),void 0!==e.wireframe&&(i.wireframe=e.wireframe),void 0!==e.wireframeLinewidth&&(i.wireframeLinewidth=e.wireframeLinewidth),void 0!==e.wireframeLinecap&&(i.wireframeLinecap=e.wireframeLinecap),void 0!==e.wireframeLinejoin&&(i.wireframeLinejoin=e.wireframeLinejoin),void 0!==e.rotation&&(i.rotation=e.rotation),1!==e.linewidth&&(i.linewidth=e.linewidth),void 0!==e.dashSize&&(i.dashSize=e.dashSize),void 0!==e.gapSize&&(i.gapSize=e.gapSize),void 0!==e.scale&&(i.scale=e.scale),void 0!==e.polygonOffset&&(i.polygonOffset=e.polygonOffset),void 0!==e.polygonOffsetFactor&&(i.polygonOffsetFactor=e.polygonOffsetFactor),void 0!==e.polygonOffsetUnits&&(i.polygonOffsetUnits=e.polygonOffsetUnits),void 0!==e.dithering&&(i.dithering=e.dithering),void 0!==e.alphaToCoverage&&(i.alphaToCoverage=e.alphaToCoverage),void 0!==e.premultipliedAlpha&&(i.premultipliedAlpha=e.premultipliedAlpha),void 0!==e.visible&&(i.visible=e.visible),void 0!==e.toneMapped&&(i.toneMapped=e.toneMapped),void 0!==e.userData&&(i.userData=e.userData),void 0!==e.vertexColors&&("number"==typeof e.vertexColors?i.vertexColors=e.vertexColors>0:i.vertexColors=e.vertexColors),void 0!==e.uniforms)for(const t in e.uniforms){const r=e.uniforms[t];switch(i.uniforms[t]={},r.type){case"t":i.uniforms[t].value=n(r.value);break;case"c":i.uniforms[t].value=(new mp).setHex(r.value);break;case"v2":i.uniforms[t].value=(new Kh).fromArray(r.value);break;case"v3":i.uniforms[t].value=(new Cp).fromArray(r.value);break;case"v4":i.uniforms[t].value=(new xp).fromArray(r.value);break;case"m3":i.uniforms[t].value=(new Qh).fromArray(r.value);break;case"m4":i.uniforms[t].value=(new am).fromArray(r.value);break;default:i.uniforms[t].value=r.value}}if(void 0!==e.defines&&(i.defines=e.defines),void 0!==e.vertexShader&&(i.vertexShader=e.vertexShader),void 0!==e.fragmentShader&&(i.fragmentShader=e.fragmentShader),void 0!==e.glslVersion&&(i.glslVersion=e.glslVersion),void 0!==e.extensions)for(const t in e.extensions)i.extensions[t]=e.extensions[t];if(void 0!==e.size&&(i.size=e.size),void 0!==e.sizeAttenuation&&(i.sizeAttenuation=e.sizeAttenuation),void 0!==e.map&&(i.map=n(e.map)),void 0!==e.matcap&&(i.matcap=n(e.matcap)),void 0!==e.alphaMap&&(i.alphaMap=n(e.alphaMap)),void 0!==e.bumpMap&&(i.bumpMap=n(e.bumpMap)),void 0!==e.bumpScale&&(i.bumpScale=e.bumpScale),void 0!==e.normalMap&&(i.normalMap=n(e.normalMap)),void 0!==e.normalMapType&&(i.normalMapType=e.normalMapType),void 0!==e.normalScale){let t=e.normalScale;!1===Array.isArray(t)&&(t=[t,t]),i.normalScale=(new Kh).fromArray(t)}return void 0!==e.displacementMap&&(i.displacementMap=n(e.displacementMap)),void 0!==e.displacementScale&&(i.displacementScale=e.displacementScale),void 0!==e.displacementBias&&(i.displacementBias=e.displacementBias),void 0!==e.roughnessMap&&(i.roughnessMap=n(e.roughnessMap)),void 0!==e.metalnessMap&&(i.metalnessMap=n(e.metalnessMap)),void 0!==e.emissiveMap&&(i.emissiveMap=n(e.emissiveMap)),void 0!==e.emissiveIntensity&&(i.emissiveIntensity=e.emissiveIntensity),void 0!==e.specularMap&&(i.specularMap=n(e.specularMap)),void 0!==e.specularIntensityMap&&(i.specularIntensityMap=n(e.specularIntensityMap)),void 0!==e.specularColorMap&&(i.specularColorMap=n(e.specularColorMap)),void 0!==e.envMap&&(i.envMap=n(e.envMap)),void 0!==e.envMapIntensity&&(i.envMapIntensity=e.envMapIntensity),void 0!==e.reflectivity&&(i.reflectivity=e.reflectivity),void 0!==e.refractionRatio&&(i.refractionRatio=e.refractionRatio),void 0!==e.lightMap&&(i.lightMap=n(e.lightMap)),void 0!==e.lightMapIntensity&&(i.lightMapIntensity=e.lightMapIntensity),void 0!==e.aoMap&&(i.aoMap=n(e.aoMap)),void 0!==e.aoMapIntensity&&(i.aoMapIntensity=e.aoMapIntensity),void 0!==e.gradientMap&&(i.gradientMap=n(e.gradientMap)),void 0!==e.clearcoatMap&&(i.clearcoatMap=n(e.clearcoatMap)),void 0!==e.clearcoatRoughnessMap&&(i.clearcoatRoughnessMap=n(e.clearcoatRoughnessMap)),void 0!==e.clearcoatNormalMap&&(i.clearcoatNormalMap=n(e.clearcoatNormalMap)),void 0!==e.clearcoatNormalScale&&(i.clearcoatNormalScale=(new Kh).fromArray(e.clearcoatNormalScale)),void 0!==e.iridescenceMap&&(i.iridescenceMap=n(e.iridescenceMap)),void 0!==e.iridescenceThicknessMap&&(i.iridescenceThicknessMap=n(e.iridescenceThicknessMap)),void 0!==e.transmissionMap&&(i.transmissionMap=n(e.transmissionMap)),void 0!==e.thicknessMap&&(i.thicknessMap=n(e.thicknessMap)),void 0!==e.sheenColorMap&&(i.sheenColorMap=n(e.sheenColorMap)),void 0!==e.sheenRoughnessMap&&(i.sheenRoughnessMap=n(e.sheenRoughnessMap)),i}setTextures(e){return this.textures=e,this}static createMaterialFromType(e){return new{ShadowMaterial:cx,SpriteMaterial:ky,RawShaderMaterial:ux,ShaderMaterial:Bf,PointsMaterial:C_,MeshPhysicalMaterial:hx,MeshStandardMaterial:dx,MeshPhongMaterial:px,MeshToonMaterial:mx,MeshNormalMaterial:fx,MeshLambertMaterial:gx,MeshDepthMaterial:my,MeshDistanceMaterial:fy,MeshBasicMaterial:Wm,MeshMatcapMaterial:vx,LineDashedMaterial:yx,LineBasicMaterial:y_,Material:Vm}[e]}}class _w{static decodeText(e){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);let t="";for(let n=0,i=e.length;n<i;n++)t+=String.fromCharCode(e[n]);try{return decodeURIComponent(escape(t))}catch(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 bw extends pf{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 xw extends Hx{constructor(e){super(e)}load(e,t,n,i){const r=this,o=new qx(r.manager);o.setPath(r.path),o.setRequestHeader(r.requestHeader),o.setWithCredentials(r.withCredentials),o.load(e,(function(n){try{t(r.parse(JSON.parse(n)))}catch(t){i?i(t):console.error(t),r.manager.itemError(e)}}),n,i)}parse(e){const t={},n={};function i(e,i){if(void 0!==t[i])return t[i];const r=e.interleavedBuffers[i],o=function(e,t){if(void 0!==n[t])return n[t];const i=e.arrayBuffers,r=i[t],o=new Uint32Array(r).buffer;return n[t]=o,o}(e,r.buffer),a=np(r.type,o),s=new Ly(a,r.stride);return s.uuid=r.uuid,t[i]=s,s}const r=e.isInstancedBufferGeometry?new bw:new pf,o=e.data.index;if(void 0!==o){const e=np(o.type,o.array);r.setIndex(new Ym(e,1))}const a=e.data.attributes;for(const t in a){const n=a[t];let o;if(n.isInterleavedBufferAttribute){const t=i(e.data,n.data);o=new Dy(t,n.itemSize,n.offset,n.normalized)}else{const e=np(n.type,n.array);o=new(n.isInstancedBufferAttribute?h_:Ym)(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),r.setAttribute(t,o)}const s=e.data.morphAttributes;if(s)for(const t in s){const n=s[t],o=[];for(let t=0,r=n.length;t<r;t++){const r=n[t];let a;if(r.isInterleavedBufferAttribute){const t=i(e.data,r.data);a=new Dy(t,r.itemSize,r.offset,r.normalized)}else{const e=np(r.type,r.array);a=new Ym(e,r.itemSize,r.normalized)}void 0!==r.name&&(a.name=r.name),o.push(a)}r.morphAttributes[t]=o}e.data.morphTargetsRelative&&(r.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];r.addGroup(t.start,t.count,t.materialIndex)}const c=e.data.boundingSphere;if(void 0!==c){const e=new Cp;void 0!==c.center&&e.fromArray(c.center),r.boundingSphere=new Xp(e,c.radius)}return e.name&&(r.name=e.name),e.userData&&(r.userData=e.userData),r}}class ww extends Hx{constructor(e){super(e)}load(e,t,n,i){const r=this,o=""===this.path?_w.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||o;const a=new qx(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,(function(n){let o=null;try{o=JSON.parse(n)}catch(t){return void 0!==i&&i(t),void console.error("THREE:ObjectLoader: Can't parse "+e+".",t.message)}const a=o.metadata;void 0!==a&&void 0!==a.type&&"geometry"!==a.type.toLowerCase()?r.parse(o,t):console.error("THREE.ObjectLoader: Can't load "+e)}),n,i)}async loadAsync(e,t){const n=""===this.path?_w.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||n;const i=new qx(this.manager);i.setPath(this.path),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials);const r=await i.loadAsync(e,t),o=JSON.parse(r),a=o.metadata;if(void 0===a||void 0===a.type||"geometry"===a.type.toLowerCase())throw new Error("THREE.ObjectLoader: Can't load "+e);return await this.parseAsync(o)}parse(e,t){const n=this.parseAnimations(e.animations),i=this.parseShapes(e.shapes),r=this.parseGeometries(e.geometries,i),o=this.parseImages(e.images,(function(){void 0!==t&&t(l)})),a=this.parseTextures(e.textures,o),s=this.parseMaterials(e.materials,a),l=this.parseObject(e.object,r,s,a,n),c=this.parseSkeletons(e.skeletons,l);if(this.bindSkeletons(l,c),void 0!==t){let e=!1;for(const t in o)if(o[t].data instanceof HTMLImageElement){e=!0;break}!1===e&&t(l)}return l}async parseAsync(e){const t=this.parseAnimations(e.animations),n=this.parseShapes(e.shapes),i=this.parseGeometries(e.geometries,n),r=await this.parseImagesAsync(e.images),o=this.parseTextures(e.textures,r),a=this.parseMaterials(e.materials,o),s=this.parseObject(e.object,i,a,o,t),l=this.parseSkeletons(e.skeletons,s);return this.bindSkeletons(s,l),s}parseShapes(e){const t={};if(void 0!==e)for(let n=0,i=e.length;n<i;n++){const i=(new bb).fromJSON(e[n]);t[i.uuid]=i}return t}parseSkeletons(e,t){const n={},i={};if(t.traverse((function(e){e.isBone&&(i[e.uuid]=e)})),void 0!==e)for(let t=0,r=e.length;t<r;t++){const r=(new d_).fromJSON(e[t],i);n[r.uuid]=r}return n}parseGeometries(e,t){const n={};if(void 0!==e){const i=new xw;for(let r=0,o=e.length;r<o;r++){let o;const a=e[r];switch(a.type){case"BufferGeometry":case"InstancedBufferGeometry":o=i.parse(a);break;default:a.type in lx?o=lx[a.type].fromJSON(a,t):console.warn(`THREE.ObjectLoader: Unsupported geometry type "${a.type}"`)}o.uuid=a.uuid,void 0!==a.name&&(o.name=a.name),!0===o.isBufferGeometry&&void 0!==a.userData&&(o.userData=a.userData),n[a.uuid]=o}}return n}parseMaterials(e,t){const n={},i={};if(void 0!==e){const r=new yw;r.setTextures(t);for(let t=0,o=e.length;t<o;t++){const o=e[t];void 0===n[o.uuid]&&(n[o.uuid]=r.parse(o)),i[o.uuid]=n[o.uuid]}}return i}parseAnimations(e){const t={};if(void 0!==e)for(let n=0;n<e.length;n++){const i=e[n],r=Fx.parse(i);t[r.uuid]=r}return t}parseImages(e,t){const n=this,i={};let r;function o(e){if("string"==typeof e){const t=e;return function(e){return n.manager.itemStart(e),r.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:np(e.type,e.data),width:e.width,height:e.height}:null}if(void 0!==e&&e.length>0){const n=new Gx(t);r=new Jx(n),r.setCrossOrigin(this.crossOrigin);for(let t=0,n=e.length;t<n;t++){const n=e[t],r=n.url;if(Array.isArray(r)){const e=[];for(let t=0,n=r.length;t<n;t++){const n=o(r[t]);null!==n&&(n instanceof HTMLImageElement?e.push(n):e.push(new l_(n.data,n.width,n.height)))}i[n.uuid]=new vp(e)}else{const e=o(n.url);i[n.uuid]=new vp(e)}}}return i}async parseImagesAsync(e){const t=this,n={};let i;async function r(e){if("string"==typeof e){const n=e,r=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(n)?n:t.resourcePath+n;return await i.loadAsync(r)}return e.data?{data:np(e.type,e.data),width:e.width,height:e.height}:null}if(void 0!==e&&e.length>0){i=new Jx(this.manager),i.setCrossOrigin(this.crossOrigin);for(let t=0,i=e.length;t<i;t++){const i=e[t],o=i.url;if(Array.isArray(o)){const e=[];for(let t=0,n=o.length;t<n;t++){const n=o[t],i=await r(n);null!==i&&(i instanceof HTMLImageElement?e.push(i):e.push(new l_(i.data,i.width,i.height)))}n[i.uuid]=new vp(e)}else{const e=await r(i.url);n[i.uuid]=new vp(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 i={};if(void 0!==e)for(let r=0,o=e.length;r<o;r++){const o=e[r];void 0===o.image&&console.warn('THREE.ObjectLoader: No "image" specified for',o.uuid),void 0===t[o.image]&&console.warn("THREE.ObjectLoader: Undefined image",o.image);const a=t[o.image],s=a.data;let l;Array.isArray(s)?(l=new jf,6===s.length&&(l.needsUpdate=!0)):(l=s&&s.data?new l_:new bp,s&&(l.needsUpdate=!0)),l.source=a,l.uuid=o.uuid,void 0!==o.name&&(l.name=o.name),void 0!==o.mapping&&(l.mapping=n(o.mapping,Sw)),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],Ew),l.wrapT=n(o.wrap[1],Ew)),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,Aw)),void 0!==o.magFilter&&(l.magFilter=n(o.magFilter,Aw)),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),i[o.uuid]=l}return i}parseObject(e,t,n,i,r){let o,a,s;function l(e){return void 0===t[e]&&console.warn("THREE.ObjectLoader: Undefined geometry",e),t[e]}function c(e){if(void 0!==e){if(Array.isArray(e)){const t=[];for(let i=0,r=e.length;i<r;i++){const r=e[i];void 0===n[r]&&console.warn("THREE.ObjectLoader: Undefined material",r),t.push(n[r])}return t}return void 0===n[e]&&console.warn("THREE.ObjectLoader: Undefined material",e),n[e]}}function u(e){return void 0===i[e]&&console.warn("THREE.ObjectLoader: Undefined texture",e),i[e]}switch(e.type){case"Scene":o=new Ry,void 0!==e.background&&(Number.isInteger(e.background)?o.background=new mp(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 Oy(e.fog.color,e.fog.near,e.fog.far):"FogExp2"===e.fog.type&&(o.fog=new Ny(e.fog.color,e.fog.density)));break;case"PerspectiveCamera":o=new Uf(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 cg(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 mw(e.color,e.intensity);break;case"DirectionalLight":o=new pw(e.color,e.intensity);break;case"PointLight":o=new dw(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":o=new fw(e.color,e.intensity,e.width,e.height);break;case"SpotLight":o=new aw(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay);break;case"HemisphereLight":o=new ew(e.color,e.groundColor,e.intensity);break;case"LightProbe":o=(new vw).fromJSON(e);break;case"SkinnedMesh":a=l(e.geometry),s=c(e.material),o=new a_(a,s),void 0!==e.bindMode&&(o.bindMode=e.bindMode),void 0!==e.bindMatrix&&o.bindMatrix.fromArray(e.bindMatrix),void 0!==e.skeleton&&(o.skeleton=e.skeleton);break;case"Mesh":a=l(e.geometry),s=c(e.material),o=new Of(a,s);break;case"InstancedMesh":a=l(e.geometry),s=c(e.material);const t=e.count,n=e.instanceMatrix,i=e.instanceColor;o=new v_(a,s,t),o.instanceMatrix=new h_(new Float32Array(n.array),16),void 0!==i&&(o.instanceColor=new h_(new Float32Array(i.array),i.itemSize));break;case"LOD":o=new e_;break;case"Line":o=new E_(l(e.geometry),c(e.material));break;case"LineLoop":o=new M_(l(e.geometry),c(e.material));break;case"LineSegments":o=new I_(l(e.geometry),c(e.material));break;case"PointCloud":case"Points":o=new P_(l(e.geometry),c(e.material));break;case"Sprite":o=new Zy(c(e.material));break;case"Group":o=new xy;break;case"Bone":o=new s_;break;default:o=new Om}if(o.uuid=e.uuid,void 0!==e.name&&(o.name=e.name),void 0!==e.matrix?(o.matrix.fromArray(e.matrix),void 0!==e.matrixAutoUpdate&&(o.matrixAutoUpdate=e.matrixAutoUpdate),o.matrixAutoUpdate&&o.matrix.decompose(o.position,o.quaternion,o.scale)):(void 0!==e.position&&o.position.fromArray(e.position),void 0!==e.rotation&&o.rotation.fromArray(e.rotation),void 0!==e.quaternion&&o.quaternion.fromArray(e.quaternion),void 0!==e.scale&&o.scale.fromArray(e.scale)),void 0!==e.castShadow&&(o.castShadow=e.castShadow),void 0!==e.receiveShadow&&(o.receiveShadow=e.receiveShadow),e.shadow&&(void 0!==e.shadow.bias&&(o.shadow.bias=e.shadow.bias),void 0!==e.shadow.normalBias&&(o.shadow.normalBias=e.shadow.normalBias),void 0!==e.shadow.radius&&(o.shadow.radius=e.shadow.radius),void 0!==e.shadow.mapSize&&o.shadow.mapSize.fromArray(e.shadow.mapSize),void 0!==e.shadow.camera&&(o.shadow.camera=this.parseObject(e.shadow.camera))),void 0!==e.visible&&(o.visible=e.visible),void 0!==e.frustumCulled&&(o.frustumCulled=e.frustumCulled),void 0!==e.renderOrder&&(o.renderOrder=e.renderOrder),void 0!==e.userData&&(o.userData=e.userData),void 0!==e.layers&&(o.layers.mask=e.layers),void 0!==e.children){const a=e.children;for(let e=0;e<a.length;e++)o.add(this.parseObject(a[e],t,n,i,r))}if(void 0!==e.animations){const t=e.animations;for(let e=0;e<t.length;e++){const n=t[e];o.animations.push(r[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],i=o.getObjectByProperty("uuid",n.object);void 0!==i&&o.addLevel(i,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 Sw={UVMapping:Tu,CubeReflectionMapping:Iu,CubeRefractionMapping:Mu,EquirectangularReflectionMapping:Cu,EquirectangularRefractionMapping:Nu,CubeUVReflectionMapping:Ou},Ew={RepeatWrapping:Ru,ClampToEdgeWrapping:Lu,MirroredRepeatWrapping:Pu},Aw={NearestFilter:Du,NearestMipmapNearestFilter:ku,NearestMipmapLinearFilter:Fu,LinearFilter:zu,LinearMipmapNearestFilter:Gu,LinearMipmapLinearFilter:Hu};class Tw extends Hx{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,i){void 0===e&&(e=""),void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,o=zx.get(e);if(void 0!==o)return r.manager.itemStart(e),setTimeout((function(){t&&t(o),r.manager.itemEnd(e)}),0),o;const a={};a.credentials="anonymous"===this.crossOrigin?"same-origin":"include",a.headers=this.requestHeader,fetch(e,a).then((function(e){return e.blob()})).then((function(e){return createImageBitmap(e,Object.assign(r.options,{colorSpaceConversion:"none"}))})).then((function(n){zx.add(e,n),t&&t(n),r.manager.itemEnd(e)})).catch((function(t){i&&i(t),r.manager.itemError(e),r.manager.itemEnd(e)})),r.manager.itemStart(e)}}let Iw;const Mw={getContext:function(){return void 0===Iw&&(Iw=new(window.AudioContext||window.webkitAudioContext)),Iw},setContext:function(e){Iw=e}};class Cw extends Hx{constructor(e){super(e)}load(e,t,n,i){const r=this,o=new qx(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);Mw.getContext().decodeAudioData(e,(function(e){t(e)}))}catch(t){i?i(t):console.error(t),r.manager.itemError(e)}}),n,i)}}class Nw extends vw{constructor(e,t,n=1){super(void 0,n),this.isHemisphereLightProbe=!0;const i=(new mp).set(e),r=(new mp).set(t),o=new Cp(i.r,i.g,i.b),a=new Cp(r.r,r.g,r.b),s=Math.sqrt(Math.PI),l=s*Math.sqrt(.75);this.sh.coefficients[0].copy(o).add(a).multiplyScalar(s),this.sh.coefficients[1].copy(o).sub(a).multiplyScalar(l)}}class Ow extends vw{constructor(e,t=1){super(void 0,t),this.isAmbientLightProbe=!0;const n=(new mp).set(e);this.sh.coefficients[0].set(n.r,n.g,n.b).multiplyScalar(2*Math.sqrt(Math.PI))}}const Rw=new am,Lw=new am,Pw=new am;class Dw{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new Uf,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new Uf,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,Pw.copy(e.projectionMatrix);const n=t.eyeSep/2,i=n*t.near/t.focus,r=t.near*Math.tan(zh*t.fov*.5)/t.zoom;let o,a;Lw.elements[12]=-n,Rw.elements[12]=n,o=-r*t.aspect+i,a=r*t.aspect+i,Pw.elements[0]=2*t.near/(a-o),Pw.elements[8]=(a+o)/(a-o),this.cameraL.projectionMatrix.copy(Pw),o=-r*t.aspect-i,a=r*t.aspect-i,Pw.elements[0]=2*t.near/(a-o),Pw.elements[8]=(a+o)/(a-o),this.cameraR.projectionMatrix.copy(Pw)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(Lw),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(Rw)}}class kw{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=Bw(),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=Bw();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}function Bw(){return("undefined"==typeof performance?Date:performance).now()}const Fw=new Cp,Uw=new Mp,zw=new Cp,Gw=new Cp;class jw extends Om{constructor(){super(),this.type="AudioListener",this.context=Mw.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new kw}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(Fw,Uw,zw),Gw.set(0,0,-1).applyQuaternion(Uw),t.positionX){const e=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(Fw.x,e),t.positionY.linearRampToValueAtTime(Fw.y,e),t.positionZ.linearRampToValueAtTime(Fw.z,e),t.forwardX.linearRampToValueAtTime(Gw.x,e),t.forwardY.linearRampToValueAtTime(Gw.y,e),t.forwardZ.linearRampToValueAtTime(Gw.z,e),t.upX.linearRampToValueAtTime(n.x,e),t.upY.linearRampToValueAtTime(n.y,e),t.upZ.linearRampToValueAtTime(n.z,e)}else t.setPosition(Fw.x,Fw.y,Fw.z),t.setOrientation(Gw.x,Gw.y,Gw.z,n.x,n.y,n.z)}}class Hw extends Om{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 Vw=new Cp,Ww=new Mp,qw=new Cp,$w=new Cp;class Yw extends Hw{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(Vw,Ww,qw),$w.set(0,0,1).applyQuaternion(Ww);const t=this.panner;if(t.positionX){const e=this.context.currentTime+this.listener.timeDelta;t.positionX.linearRampToValueAtTime(Vw.x,e),t.positionY.linearRampToValueAtTime(Vw.y,e),t.positionZ.linearRampToValueAtTime(Vw.z,e),t.orientationX.linearRampToValueAtTime($w.x,e),t.orientationY.linearRampToValueAtTime($w.y,e),t.orientationZ.linearRampToValueAtTime($w.z,e)}else t.setPosition(Vw.x,Vw.y,Vw.z),t.setOrientation($w.x,$w.y,$w.z)}}class Jw{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 Zw{constructor(e,t,n){let i,r,o;switch(this.binding=e,this.valueSize=n,t){case"quaternion":i=this._slerp,r=this._slerpAdditive,o=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(6*n),this._workIndex=5;break;case"string":case"bool":i=this._select,r=this._select,o=this._setAdditiveIdentityOther,this.buffer=new Array(5*n);break;default:i=this._lerp,r=this._lerpAdditive,o=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(5*n)}this._mixBufferRegion=i,this._mixBufferRegionAdditive=r,this._setIdentity=o,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){const n=this.buffer,i=this.valueSize,r=e*i+i;let o=this.cumulativeWeight;if(0===o){for(let e=0;e!==i;++e)n[r+e]=n[e];o=t}else{o+=t;const e=t/o;this._mixBufferRegion(n,r,0,e,i)}this.cumulativeWeight=o}accumulateAdditive(e){const t=this.buffer,n=this.valueSize,i=n*this._addIndex;0===this.cumulativeWeightAdditive&&this._setIdentity(),this._mixBufferRegionAdditive(t,i,0,e,n),this.cumulativeWeightAdditive+=e}apply(e){const t=this.valueSize,n=this.buffer,i=e*t+t,r=this.cumulativeWeight,o=this.cumulativeWeightAdditive,a=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,r<1){const e=t*this._origIndex;this._mixBufferRegion(n,i,e,1-r,t)}o>0&&this._mixBufferRegionAdditive(n,i,this._addIndex*t,1,t);for(let e=t,r=t+t;e!==r;++e)if(n[e]!==n[e+t]){a.setValue(n,i);break}}saveOriginalState(){const e=this.binding,t=this.buffer,n=this.valueSize,i=n*this._origIndex;e.getValue(t,i);for(let e=n,r=i;e!==r;++e)t[e]=t[i+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,i,r){if(i>=.5)for(let i=0;i!==r;++i)e[t+i]=e[n+i]}_slerp(e,t,n,i){Mp.slerpFlat(e,t,e,t,e,n,i)}_slerpAdditive(e,t,n,i,r){const o=this._workIndex*r;Mp.multiplyQuaternionsFlat(e,o,e,t,e,n),Mp.slerpFlat(e,t,e,t,e,o,i)}_lerp(e,t,n,i,r){const o=1-i;for(let a=0;a!==r;++a){const r=t+a;e[r]=e[r]*o+e[n+a]*i}}_lerpAdditive(e,t,n,i,r){for(let o=0;o!==r;++o){const r=t+o;e[r]=e[r]+e[n+o]*i}}}const Xw="\\[\\]\\.:\\/",Kw=new RegExp("["+Xw+"]","g"),Qw="[^"+Xw+"]",eS="[^"+Xw.replace("\\.","")+"]",tS=new RegExp("^"+/((?:WC+[\/:])*)/.source.replace("WC",Qw)+/(WCOD+)?/.source.replace("WCOD",eS)+/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Qw)+/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Qw)+"$"),nS=["material","materials","bones","map"];class iS{constructor(e,t,n){this.path=t,this.parsedPath=n||iS.parseTrackName(t),this.node=iS.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 iS.Composite(e,t,n):new iS(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(Kw,"")}static parseTrackName(e){const t=tS.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]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(void 0!==i&&-1!==i){const e=n.nodeName.substring(i+1);-1!==nS.indexOf(e)&&(n.nodeName=n.nodeName.substring(0,i),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 i=0;i<e.length;i++){const r=e[i];if(r.name===t||r.uuid===t)return r;const o=n(r.children);if(o)return o}return null},i=n(e.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)e[t++]=n[i]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node;const t=this.parsedPath,n=t.objectName,i=t.propertyName;let r=t.propertyIndex;if(e||(e=iS.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 i=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===i){i=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!==i){if(void 0===e[i])return void console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);e=e[i]}}const o=e[i];if(void 0===o){const n=t.nodeName;return void console.error("THREE.PropertyBinding: Trying to update property for track: "+n+"."+i+" but it wasn't found.",e)}let a=this.Versioning.None;this.targetObject=e,void 0!==e.needsUpdate?a=this.Versioning.NeedsUpdate:void 0!==e.matrixWorldNeedsUpdate&&(a=this.Versioning.MatrixWorldNeedsUpdate);let s=this.BindingType.Direct;if(void 0!==r){if("morphTargetInfluences"===i){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[r]&&(r=e.morphTargetDictionary[r])}s=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=r}else void 0!==o.fromArray&&void 0!==o.toArray?(s=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(s=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=i;this.getValue=this.GetterByBindingType[s],this.setValue=this.SetterByBindingTypeAndVersioning[s][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}iS.Composite=class{constructor(e,t,n){const i=n||iS.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();const n=this._targetGroup.nCachedObjects_,i=this._bindings[n];void 0!==i&&i.getValue(e,t)}setValue(e,t){const n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,r=n.length;i!==r;++i)n[i].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}},iS.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},iS.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},iS.prototype.GetterByBindingType=[iS.prototype._getValue_direct,iS.prototype._getValue_array,iS.prototype._getValue_arrayElement,iS.prototype._getValue_toArray],iS.prototype.SetterByBindingTypeAndVersioning=[[iS.prototype._setValue_direct,iS.prototype._setValue_direct_setNeedsUpdate,iS.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[iS.prototype._setValue_array,iS.prototype._setValue_array_setNeedsUpdate,iS.prototype._setValue_array_setMatrixWorldNeedsUpdate],[iS.prototype._setValue_arrayElement,iS.prototype._setValue_arrayElement_setNeedsUpdate,iS.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[iS.prototype._setValue_fromArray,iS.prototype._setValue_fromArray_setNeedsUpdate,iS.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class rS{constructor(){this.isAnimationObjectGroup=!0,this.uuid=jh(),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,i=this._parsedPaths,r=this._bindings,o=r.length;let a,s=e.length,l=this.nCachedObjects_;for(let c=0,u=arguments.length;c!==u;++c){const u=arguments[c],d=u.uuid;let h=t[d];if(void 0===h){h=s++,t[d]=h,e.push(u);for(let e=0,t=o;e!==t;++e)r[e].push(new iS(u,n[e],i[e]))}else if(h<l){a=e[h];const s=--l,c=e[s];t[c.uuid]=h,e[h]=c,t[d]=s,e[s]=u;for(let e=0,t=o;e!==t;++e){const t=r[e],o=t[s];let a=t[h];t[h]=o,void 0===a&&(a=new iS(u,n[e],i[e])),t[s]=a}}else e[h]!==a&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=l}remove(){const e=this._objects,t=this._indicesByUUID,n=this._bindings,i=n.length;let r=this.nCachedObjects_;for(let o=0,a=arguments.length;o!==a;++o){const a=arguments[o],s=a.uuid,l=t[s];if(void 0!==l&&l>=r){const o=r++,c=e[o];t[c.uuid]=l,e[l]=c,t[s]=o,e[o]=a;for(let e=0,t=i;e!==t;++e){const t=n[e],i=t[o],r=t[l];t[l]=i,t[o]=r}}}this.nCachedObjects_=r}uncache(){const e=this._objects,t=this._indicesByUUID,n=this._bindings,i=n.length;let r=this.nCachedObjects_,o=e.length;for(let a=0,s=arguments.length;a!==s;++a){const s=arguments[a].uuid,l=t[s];if(void 0!==l)if(delete t[s],l<r){const a=--r,s=e[a],c=--o,u=e[c];t[s.uuid]=l,e[l]=s,t[u.uuid]=a,e[a]=u,e.pop();for(let e=0,t=i;e!==t;++e){const t=n[e],i=t[a],r=t[c];t[l]=i,t[a]=r,t.pop()}}else{const r=--o,a=e[r];r>0&&(t[a.uuid]=l),e[l]=a,e.pop();for(let e=0,t=i;e!==t;++e){const t=n[e];t[l]=t[r],t.pop()}}}this.nCachedObjects_=r}subscribe_(e,t){const n=this._bindingsIndicesByPath;let i=n[e];const r=this._bindings;if(void 0!==i)return r[i];const o=this._paths,a=this._parsedPaths,s=this._objects,l=s.length,c=this.nCachedObjects_,u=new Array(l);i=r.length,n[e]=i,o.push(e),a.push(t),r.push(u);for(let n=c,i=s.length;n!==i;++n){const i=s[n];u[n]=new iS(i,e,t)}return u}unsubscribe_(e){const t=this._bindingsIndicesByPath,n=t[e];if(void 0!==n){const i=this._paths,r=this._parsedPaths,o=this._bindings,a=o.length-1,s=o[a];t[e[a]]=n,o[n]=s,o.pop(),r[n]=r[a],r.pop(),i[n]=i[a],i.pop()}}}class oS{constructor(e,t,n=null,i=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=i;const r=t.tracks,o=r.length,a=new Array(o),s={endingStart:qd,endingEnd:qd};for(let e=0;e!==o;++e){const t=r[e].createInterpolant(null);a[e]=t,t.settings=s}this._interpolantSettings=s,this._interpolants=a,this._propertyBindings=new Array(o),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=Gd,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,i=e._clip.duration,r=i/n,o=n/i;e.warp(1,r,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 i=this._mixer,r=i.time,o=this.timeScale;let a=this._timeScaleInterpolant;null===a&&(a=i._lendControlInterpolant(),this._timeScaleInterpolant=a);const s=a.parameterPositions,l=a.sampleValues;return s[0]=r,s[1]=r+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,i){if(!this.enabled)return void this._updateWeight(e);const r=this._startTime;if(null!==r){const i=(e-r)*n;i<0||0===n?t=0:(this._startTime=null,t=n*i)}t*=this._updateTimeScale(e);const o=this._updateTime(t),a=this._updateWeight(e);if(a>0){const e=this._interpolants,t=this._propertyBindings;if(this.blendMode===Zd)for(let n=0,i=e.length;n!==i;++n)e[n].evaluate(o),t[n].accumulateAdditive(a);else for(let n=0,r=e.length;n!==r;++n)e[n].evaluate(o),t[n].accumulate(i,a)}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const n=this._weightInterpolant;if(null!==n){const i=n.evaluate(e)[0];t*=i,e>n.parameterPositions[1]&&(this.stopFading(),0===i&&(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 i=this.time+e,r=this._loopCount;const o=n===jd;if(0===e)return-1===r?i:o&&1==(1&r)?t-i:i;if(n===zd){-1===r&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(i>=t)i=t;else{if(!(i<0)){this.time=i;break e}i=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(-1===r&&(e>=0?(r=0,this._setEndings(!0,0===this.repetitions,o)):this._setEndings(0===this.repetitions,!0,o)),i>=t||i<0){const n=Math.floor(i/t);i-=t*n,r+=Math.abs(n);const a=this.repetitions-r;if(a<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=e>0?t:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(1===a){const t=e<0;this._setEndings(t,!t,o)}else this._setEndings(!1,!1,o);this._loopCount=r,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:n})}}else this.time=i;if(o&&1==(1&r))return t-i}return i}_setEndings(e,t,n){const i=this._interpolantSettings;n?(i.endingStart=$d,i.endingEnd=$d):(i.endingStart=e?this.zeroSlopeAtStart?$d:qd:Yd,i.endingEnd=t?this.zeroSlopeAtEnd?$d:qd:Yd)}_scheduleFading(e,t,n){const i=this._mixer,r=i.time;let o=this._weightInterpolant;null===o&&(o=i._lendControlInterpolant(),this._weightInterpolant=o);const a=o.parameterPositions,s=o.sampleValues;return a[0]=r,s[0]=t,a[1]=r+e,s[1]=n,this}}const aS=new Float32Array(1);class sS extends Bh{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const n=e._localRoot||this._root,i=e._clip.tracks,r=i.length,o=e._propertyBindings,a=e._interpolants,s=n.uuid,l=this._bindingsByRootAndName;let c=l[s];void 0===c&&(c={},l[s]=c);for(let e=0;e!==r;++e){const r=i[e],l=r.name;let u=c[l];if(void 0!==u)++u.referenceCount,o[e]=u;else{if(u=o[e],void 0!==u){null===u._cacheIndex&&(++u.referenceCount,this._addInactiveBinding(u,s,l));continue}const i=t&&t._propertyBindings[e].binding.parsedPath;u=new Zw(iS.create(n,l,i),r.ValueTypeName,r.getValueSize()),++u.referenceCount,this._addInactiveBinding(u,s,l),o[e]=u}a[e].resultBuffer=u.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(null===e._cacheIndex){const t=(e._localRoot||this._root).uuid,n=e._clip.uuid,i=this._actionsByClip[n];this._bindAction(e,i&&i.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 i=this._actions,r=this._actionsByClip;let o=r[t];if(void 0===o)o={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,r[t]=o;else{const t=o.knownActions;e._byClipCacheIndex=t.length,t.push(e)}e._cacheIndex=i.length,i.push(e),o.actionByRoot[n]=e}_removeInactiveAction(e){const t=this._actions,n=t[t.length-1],i=e._cacheIndex;n._cacheIndex=i,t[i]=n,t.pop(),e._cacheIndex=null;const r=e._clip.uuid,o=this._actionsByClip,a=o[r],s=a.knownActions,l=s[s.length-1],c=e._byClipCacheIndex;l._byClipCacheIndex=c,s[c]=l,s.pop(),e._byClipCacheIndex=null;delete a.actionByRoot[(e._localRoot||this._root).uuid],0===s.length&&delete o[r],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,i=this._nActiveActions++,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_takeBackAction(e){const t=this._actions,n=e._cacheIndex,i=--this._nActiveActions,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_addInactiveBinding(e,t,n){const i=this._bindingsByRootAndName,r=this._bindings;let o=i[t];void 0===o&&(o={},i[t]=o),o[n]=e,e._cacheIndex=r.length,r.push(e)}_removeInactiveBinding(e){const t=this._bindings,n=e.binding,i=n.rootNode.uuid,r=n.path,o=this._bindingsByRootAndName,a=o[i],s=t[t.length-1],l=e._cacheIndex;s._cacheIndex=l,t[l]=s,t.pop(),delete a[r],0===Object.keys(a).length&&delete o[i]}_lendBinding(e){const t=this._bindings,n=e._cacheIndex,i=this._nActiveBindings++,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_takeBackBinding(e){const t=this._bindings,n=e._cacheIndex,i=--this._nActiveBindings,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_lendControlInterpolant(){const e=this._controlInterpolants,t=this._nActiveControlInterpolants++;let n=e[t];return void 0===n&&(n=new Mx(new Float32Array(2),new Float32Array(2),1,aS),n.__cacheIndex=t,e[t]=n),n}_takeBackControlInterpolant(e){const t=this._controlInterpolants,n=e.__cacheIndex,i=--this._nActiveControlInterpolants,r=t[i];e.__cacheIndex=i,t[i]=e,r.__cacheIndex=n,t[n]=r}clipAction(e,t,n){const i=t||this._root,r=i.uuid;let o="string"==typeof e?Fx.findByName(i,e):e;const a=null!==o?o.uuid:e,s=this._actionsByClip[a];let l=null;if(void 0===n&&(n=null!==o?o.blendMode:Jd),void 0!==s){const e=s.actionByRoot[r];if(void 0!==e&&e.blendMode===n)return e;l=s.knownActions[0],null===o&&(o=l._clip)}if(null===o)return null;const c=new oS(this,o,t,n);return this._bindAction(c,l),this._addInactiveAction(c,a,r),c}existingAction(e,t){const n=t||this._root,i=n.uuid,r="string"==typeof e?Fx.findByName(n,e):e,o=r?r.uuid:e,a=this._actionsByClip[o];return void 0!==a&&a.actionByRoot[i]||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,i=this.time+=e,r=Math.sign(e),o=this._accuIndex^=1;for(let a=0;a!==n;++a){t[a]._update(i,e,r,o)}const a=this._bindings,s=this._nActiveBindings;for(let e=0;e!==s;++e)a[e].apply(o);return this}setTime(e){this.time=0;for(let e=0;e<this._actions.length;e++)this._actions[e].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){const t=this._actions,n=e.uuid,i=this._actionsByClip,r=i[n];if(void 0!==r){const e=r.knownActions;for(let n=0,i=e.length;n!==i;++n){const i=e[n];this._deactivateAction(i);const r=i._cacheIndex,o=t[t.length-1];i._cacheIndex=null,i._byClipCacheIndex=null,o._cacheIndex=r,t[r]=o,t.pop(),this._removeInactiveBindingsForAction(i)}delete i[n]}}uncacheRoot(e){const t=e.uuid,n=this._actionsByClip;for(const e in n){const i=n[e].actionByRoot[t];void 0!==i&&(this._deactivateAction(i),this._removeInactiveAction(i))}const i=this._bindingsByRootAndName[t];if(void 0!==i)for(const e in i){const t=i[e];t.restoreOriginalState(),this._removeInactiveBinding(t)}}uncacheAction(e,t){const n=this.existingAction(e,t);null!==n&&(this._deactivateAction(n),this._removeInactiveAction(n))}}class lS{constructor(e){this.value=e}clone(){return new lS(void 0===this.value.clone?this.value:this.value.clone())}}let cS=0;class uS extends Bh{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:cS++}),this.name="",this.usage=Ah,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 dS extends Ly{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 hS{constructor(e,t,n,i,r){this.isGLBufferAttribute=!0,this.buffer=e,this.type=t,this.itemSize=n,this.elementSize=i,this.count=r,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 pS{constructor(e,t,n=0,i=1/0){this.ray=new om(e,t),this.near=n,this.far=i,this.camera=null,this.layers=new vm,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 fS(e,this,n,t),n.sort(mS),n}intersectObjects(e,t=!0,n=[]){for(let i=0,r=e.length;i<r;i++)fS(e[i],this,n,t);return n.sort(mS),n}}function mS(e,t){return e.distance-t.distance}function fS(e,t,n,i){if(e.layers.test(t.layers)&&e.raycast(t,n),!0===i){const i=e.children;for(let e=0,r=i.length;e<r;e++)fS(i[e],t,n,!0)}}class gS{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(Hh(t/this.radius,-1,1))),this}clone(){return(new this.constructor).copy(this)}}class vS{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 yS=new Kh;class _S{constructor(e=new Kh(1/0,1/0),t=new Kh(-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=yS.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 yS.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 bS=new Cp,xS=new Cp;class wS{constructor(e=new Cp,t=new Cp){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){bS.subVectors(e,this.start),xS.subVectors(this.end,this.start);const n=xS.dot(xS);let i=xS.dot(bS)/n;return t&&(i=Hh(i,0,1)),i}closestPointToPoint(e,t,n){const i=this.closestPointToPointParameter(e,t);return this.delta(n).multiplyScalar(i).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return(new this.constructor).copy(this)}}const SS=new Cp;class ES extends Om{constructor(e,t){super(),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t;const n=new pf,i=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let e=0,t=1,n=32;e<n;e++,t++){const r=e/n*Math.PI*2,o=t/n*Math.PI*2;i.push(Math.cos(r),Math.sin(r),1,Math.cos(o),Math.sin(o),1)}n.setAttribute("position",new rf(i,3));const r=new y_({fog:!1,toneMapped:!1});this.cone=new I_(n,r),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),SS.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(SS),void 0!==this.color?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}}const AS=new Cp,TS=new am,IS=new am;class MS extends I_{constructor(e){const t=CS(e),n=new pf,i=[],r=[],o=new mp(0,0,1),a=new mp(0,1,0);for(let e=0;e<t.length;e++){const n=t[e];n.parent&&n.parent.isBone&&(i.push(0,0,0),i.push(0,0,0),r.push(o.r,o.g,o.b),r.push(a.r,a.g,a.b))}n.setAttribute("position",new rf(i,3)),n.setAttribute("color",new rf(r,3));super(n,new y_({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,i=n.getAttribute("position");IS.copy(this.root.matrixWorld).invert();for(let e=0,n=0;e<t.length;e++){const r=t[e];r.parent&&r.parent.isBone&&(TS.multiplyMatrices(IS,r.matrixWorld),AS.setFromMatrixPosition(TS),i.setXYZ(n,AS.x,AS.y,AS.z),TS.multiplyMatrices(IS,r.parent.matrixWorld),AS.setFromMatrixPosition(TS),i.setXYZ(n+1,AS.x,AS.y,AS.z),n+=2)}n.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}}function CS(e){const t=[];!0===e.isBone&&t.push(e);for(let n=0;n<e.children.length;n++)t.push.apply(t,CS(e.children[n]));return t}class NS extends Of{constructor(e,t,n){super(new tx(t,4,2),new Wm({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 OS=new Cp,RS=new mp,LS=new mp;class PS extends Om{constructor(e,t,n){super(),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n;const i=new Kb(t);i.rotateY(.5*Math.PI),this.material=new Wm({wireframe:!0,fog:!1,toneMapped:!1}),void 0===this.color&&(this.material.vertexColors=!0);const r=i.getAttribute("position"),o=new Float32Array(3*r.count);i.setAttribute("color",new Ym(o,3)),this.add(new Of(i,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");RS.copy(this.light.color),LS.copy(this.light.groundColor);for(let e=0,n=t.count;e<n;e++){const i=e<n/2?RS:LS;t.setXYZ(e,i.r,i.g,i.b)}t.needsUpdate=!0}e.lookAt(OS.setFromMatrixPosition(this.light.matrixWorld).negate())}}class DS extends I_{constructor(e=10,t=10,n=4473924,i=8947848){n=new mp(n),i=new mp(i);const r=t/2,o=e/t,a=e/2,s=[],l=[];for(let e=0,c=0,u=-a;e<=t;e++,u+=o){s.push(-a,0,u,a,0,u),s.push(u,0,-a,u,0,a);const t=e===r?n:i;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 pf;c.setAttribute("position",new rf(s,3)),c.setAttribute("color",new rf(l,3));super(c,new y_({vertexColors:!0,toneMapped:!1})),this.type="GridHelper"}}class kS extends I_{constructor(e=10,t=16,n=8,i=64,r=4473924,o=8947848){r=new mp(r),o=new mp(o);const a=[],s=[];if(t>1)for(let n=0;n<t;n++){const i=n/t*(2*Math.PI),l=Math.sin(i)*e,c=Math.cos(i)*e;a.push(0,0,0),a.push(l,0,c);const u=1&n?r:o;s.push(u.r,u.g,u.b),s.push(u.r,u.g,u.b)}for(let t=0;t<n;t++){const l=1&t?r:o,c=e-e/n*t;for(let e=0;e<i;e++){let t=e/i*(2*Math.PI),n=Math.sin(t)*c,r=Math.cos(t)*c;a.push(n,0,r),s.push(l.r,l.g,l.b),t=(e+1)/i*(2*Math.PI),n=Math.sin(t)*c,r=Math.cos(t)*c,a.push(n,0,r),s.push(l.r,l.g,l.b)}}const l=new pf;l.setAttribute("position",new rf(a,3)),l.setAttribute("color",new rf(s,3));super(l,new y_({vertexColors:!0,toneMapped:!1})),this.type="PolarGridHelper"}}const BS=new Cp,FS=new Cp,US=new Cp;class zS extends Om{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 i=new pf;i.setAttribute("position",new rf([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));const r=new y_({fog:!1,toneMapped:!1});this.lightPlane=new E_(i,r),this.add(this.lightPlane),i=new pf,i.setAttribute("position",new rf([0,0,0,0,0,1],3)),this.targetLine=new E_(i,r),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){BS.setFromMatrixPosition(this.light.matrixWorld),FS.setFromMatrixPosition(this.light.target.matrixWorld),US.subVectors(FS,BS),this.lightPlane.lookAt(FS),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(FS),this.targetLine.scale.z=US.length()}}const GS=new Cp,jS=new Ff;class HS extends I_{constructor(e){const t=new pf,n=new y_({color:16777215,vertexColors:!0,toneMapped:!1}),i=[],r=[],o={};function a(e,t){s(e),s(t)}function s(e){i.push(0,0,0),r.push(0,0,0),void 0===o[e]&&(o[e]=[]),o[e].push(i.length/3-1)}a("n1","n2"),a("n2","n4"),a("n4","n3"),a("n3","n1"),a("f1","f2"),a("f2","f4"),a("f4","f3"),a("f3","f1"),a("n1","f1"),a("n2","f2"),a("n3","f3"),a("n4","f4"),a("p","n1"),a("p","n2"),a("p","n3"),a("p","n4"),a("u1","u2"),a("u2","u3"),a("u3","u1"),a("c","t"),a("p","c"),a("cn1","cn2"),a("cn3","cn4"),a("cf1","cf2"),a("cf3","cf4"),t.setAttribute("position",new rf(i,3)),t.setAttribute("color",new rf(r,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 mp(16755200),c=new mp(16711680),u=new mp(43775),d=new mp(16777215),h=new mp(3355443);this.setColors(l,c,u,d,h)}setColors(e,t,n,i,r){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,i.r,i.g,i.b),o.setXYZ(39,i.r,i.g,i.b),o.setXYZ(40,r.r,r.g,r.b),o.setXYZ(41,r.r,r.g,r.b),o.setXYZ(42,r.r,r.g,r.b),o.setXYZ(43,r.r,r.g,r.b),o.setXYZ(44,r.r,r.g,r.b),o.setXYZ(45,r.r,r.g,r.b),o.setXYZ(46,r.r,r.g,r.b),o.setXYZ(47,r.r,r.g,r.b),o.setXYZ(48,r.r,r.g,r.b),o.setXYZ(49,r.r,r.g,r.b),o.needsUpdate=!0}update(){const e=this.geometry,t=this.pointMap;jS.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),VS("c",t,e,jS,0,0,-1),VS("t",t,e,jS,0,0,1),VS("n1",t,e,jS,-1,-1,-1),VS("n2",t,e,jS,1,-1,-1),VS("n3",t,e,jS,-1,1,-1),VS("n4",t,e,jS,1,1,-1),VS("f1",t,e,jS,-1,-1,1),VS("f2",t,e,jS,1,-1,1),VS("f3",t,e,jS,-1,1,1),VS("f4",t,e,jS,1,1,1),VS("u1",t,e,jS,.7,1.1,-1),VS("u2",t,e,jS,-.7,1.1,-1),VS("u3",t,e,jS,0,2,-1),VS("cf1",t,e,jS,-1,0,1),VS("cf2",t,e,jS,1,0,1),VS("cf3",t,e,jS,0,-1,1),VS("cf4",t,e,jS,0,1,1),VS("cn1",t,e,jS,-1,0,-1),VS("cn2",t,e,jS,1,0,-1),VS("cn3",t,e,jS,0,-1,-1),VS("cn4",t,e,jS,0,1,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}}function VS(e,t,n,i,r,o,a){GS.set(r,o,a).unproject(i);const s=t[e];if(void 0!==s){const e=n.getAttribute("position");for(let t=0,n=s.length;t<n;t++)e.setXYZ(s[t],GS.x,GS.y,GS.z)}}const WS=new Rp;class qS extends I_{constructor(e,t=16776960){const n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),i=new Float32Array(24),r=new pf;r.setIndex(new Ym(n,1)),r.setAttribute("position",new Ym(i,3)),super(r,new y_({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&&WS.setFromObject(this.object),WS.isEmpty())return;const t=WS.min,n=WS.max,i=this.geometry.attributes.position,r=i.array;r[0]=n.x,r[1]=n.y,r[2]=n.z,r[3]=t.x,r[4]=n.y,r[5]=n.z,r[6]=t.x,r[7]=t.y,r[8]=n.z,r[9]=n.x,r[10]=t.y,r[11]=n.z,r[12]=n.x,r[13]=n.y,r[14]=t.z,r[15]=t.x,r[16]=n.y,r[17]=t.z,r[18]=t.x,r[19]=t.y,r[20]=t.z,r[21]=n.x,r[22]=t.y,r[23]=t.z,i.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(e){return this.object=e,this.update(),this}copy(e,t){return super.copy(e,t),this.object=e.object,this}}class $S extends I_{constructor(e,t=16776960){const n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),i=new pf;i.setIndex(new Ym(n,1)),i.setAttribute("position",new rf([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(i,new y_({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 YS extends E_{constructor(e,t=1,n=16776960){const i=n,r=new pf;r.setAttribute("position",new rf([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)),r.computeBoundingSphere(),super(r,new y_({color:i,toneMapped:!1})),this.type="PlaneHelper",this.plane=e,this.size=t;const o=new pf;o.setAttribute("position",new rf([1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],3)),o.computeBoundingSphere(),this.add(new Of(o,new Wm({color:i,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(e){this.position.set(0,0,0),this.scale.set(.5*this.size,.5*this.size,1),this.lookAt(this.plane.normal),this.translateZ(-this.plane.constant),super.updateMatrixWorld(e)}}const JS=new Cp;let ZS,XS;class KS extends Om{constructor(e=new Cp(0,0,1),t=new Cp(0,0,0),n=1,i=16776960,r=.2*n,o=.2*r){super(),this.type="ArrowHelper",void 0===ZS&&(ZS=new pf,ZS.setAttribute("position",new rf([0,0,0,0,1,0],3)),XS=new db(0,.5,1,5,1),XS.translate(0,-.5,0)),this.position.copy(t),this.line=new E_(ZS,new y_({color:i,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new Of(XS,new Wm({color:i,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(e),this.setLength(n,r,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{JS.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(JS,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 QS extends I_{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 pf;n.setAttribute("position",new rf(t,3)),n.setAttribute("color",new rf([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],3));super(n,new y_({vertexColors:!0,toneMapped:!1})),this.type="AxesHelper"}setColors(e,t,n){const i=new mp,r=this.geometry.attributes.color.array;return i.set(e),i.toArray(r,0),i.toArray(r,3),i.set(t),i.toArray(r,6),i.toArray(r,9),i.set(n),i.toArray(r,12),i.toArray(r,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class eE{constructor(){this.type="ShapePath",this.color=new mp,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new sb,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,n,i){return this.currentPath.quadraticCurveTo(e,t,n,i),this}bezierCurveTo(e,t,n,i,r,o){return this.currentPath.bezierCurveTo(e,t,n,i,r,o),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(e,t){const n=t.length;let i=!1;for(let r=n-1,o=0;o<n;r=o++){let n=t[r],a=t[o],s=a.x-n.x,l=a.y-n.y;if(Math.abs(l)>Number.EPSILON){if(l<0&&(n=t[o],s=-s,a=t[r],l=-l),e.y<n.y||e.y>a.y)continue;if(e.y===n.y){if(e.x===n.x)return!0}else{const t=l*(e.x-n.x)-s*(e.y-n.y);if(0===t)return!0;if(t<0)continue;i=!i}}else{if(e.y!==n.y)continue;if(a.x<=e.x&&e.x<=n.x||n.x<=e.x&&e.x<=a.x)return!0}}return i}const n=qb.isClockWise,i=this.subPaths;if(0===i.length)return[];let r,o,a;const s=[];if(1===i.length)return o=i[0],a=new bb,a.curves=o.curves,s.push(a),s;let l=!n(i[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,a=i.length;t<a;t++)o=i[t],d=o.getPoints(),r=n(d),r=e?!r:r,r?(!l&&u[m]&&m++,u[m]={s:new bb,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,i=e.length;n<i;n++){const i=e[n],r=new bb;r.curves=i.curves,t.push(r)}return t}(i);if(u.length>1){let e=!1,n=0;for(let e=0,t=u.length;e<t;e++)c[e]=[];for(let i=0,r=u.length;i<r;i++){const r=p[i];for(let o=0;o<r.length;o++){const a=r[o];let s=!0;for(let r=0;r<u.length;r++)t(a.p,u[r].p)&&(i!==r&&n++,s?(s=!1,c[r].push(a)):e=!0);s&&c[i].push(a)}}n>0&&!1===e&&(p=c)}for(let e=0,t=u.length;e<t;e++){a=u[e].s,s.push(a),h=p[e];for(let e=0,t=h.length;e<t;e++)a.holes.push(h[e].h)}return s}}const tE=nE();function nE(){const e=new ArrayBuffer(4),t=new Float32Array(e),n=new Uint32Array(e),i=new Uint32Array(512),r=new Uint32Array(512);for(let e=0;e<256;++e){const t=e-127;t<-27?(i[e]=0,i[256|e]=32768,r[e]=24,r[256|e]=24):t<-14?(i[e]=1024>>-t-14,i[256|e]=1024>>-t-14|32768,r[e]=-t-1,r[256|e]=-t-1):t<=15?(i[e]=t+15<<10,i[256|e]=t+15<<10|32768,r[e]=13,r[256|e]=13):t<128?(i[e]=31744,i[256|e]=64512,r[e]=24,r[256|e]=24):(i[e]=31744,i[256|e]=64512,r[e]=13,r[256|e]=13)}const o=new Uint32Array(2048),a=new Uint32Array(64),s=new Uint32Array(64);for(let e=1;e<1024;++e){let t=e<<13,n=0;for(;0==(8388608&t);)t<<=1,n-=8388608;t&=-8388609,n+=947912704,o[e]=t|n}for(let e=1024;e<2048;++e)o[e]=939524096+(e-1024<<13);for(let e=1;e<31;++e)a[e]=e<<23;a[31]=1199570944,a[32]=2147483648;for(let e=33;e<63;++e)a[e]=2147483648+(e-32<<23);a[63]=3347054592;for(let e=1;e<64;++e)32!==e&&(s[e]=1024);return{floatView:t,uint32View:n,baseTable:i,shiftTable:r,mantissaTable:o,exponentTable:a,offsetTable:s}}var iE=Object.freeze({__proto__:null,toHalfFloat:function(e){Math.abs(e)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),e=Hh(e,-65504,65504),tE.floatView[0]=e;const t=tE.uint32View[0],n=t>>23&511;return tE.baseTable[n]+((8388607&t)>>tE.shiftTable[n])},fromHalfFloat:function(e){const t=e>>10;return tE.uint32View[0]=tE.mantissaTable[tE.offsetTable[t]+(1023&e)]+tE.exponentTable[t],tE.floatView[0]}});function rE(){console.error("THREE.ImmediateRenderObject has been removed.")}class oE extends wp{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 aE extends Sp{constructor(e,t,n,i){console.warn("THREE.DataTexture2DArray has been renamed to DataArrayTexture."),super(e,t,n,i)}}class sE extends Ap{constructor(e,t,n,i){console.warn("THREE.DataTexture3D has been renamed to Data3DTexture."),super(e,t,n,i)}}class lE extends Lf{constructor(e,t,n,i,r,o){console.warn("THREE.BoxBufferGeometry has been renamed to THREE.BoxGeometry."),super(e,t,n,i,r,o)}}class cE extends cb{constructor(e,t,n,i){console.warn("THREE.CapsuleBufferGeometry has been renamed to THREE.CapsuleGeometry."),super(e,t,n,i)}}class uE extends ub{constructor(e,t,n,i){console.warn("THREE.CircleBufferGeometry has been renamed to THREE.CircleGeometry."),super(e,t,n,i)}}class dE extends hb{constructor(e,t,n,i,r,o,a){console.warn("THREE.ConeBufferGeometry has been renamed to THREE.ConeGeometry."),super(e,t,n,i,r,o,a)}}class hE extends db{constructor(e,t,n,i,r,o,a,s){console.warn("THREE.CylinderBufferGeometry has been renamed to THREE.CylinderGeometry."),super(e,t,n,i,r,o,a,s)}}class pE extends mb{constructor(e,t){console.warn("THREE.DodecahedronBufferGeometry has been renamed to THREE.DodecahedronGeometry."),super(e,t)}}class mE extends Jb{constructor(e,t){console.warn("THREE.ExtrudeBufferGeometry has been renamed to THREE.ExtrudeGeometry."),super(e,t)}}class fE extends Xb{constructor(e,t){console.warn("THREE.IcosahedronBufferGeometry has been renamed to THREE.IcosahedronGeometry."),super(e,t)}}class gE extends lb{constructor(e,t,n,i){console.warn("THREE.LatheBufferGeometry has been renamed to THREE.LatheGeometry."),super(e,t,n,i)}}class vE extends Kb{constructor(e,t){console.warn("THREE.OctahedronBufferGeometry has been renamed to THREE.OctahedronGeometry."),super(e,t)}}class yE extends Qf{constructor(e,t,n,i){console.warn("THREE.PlaneBufferGeometry has been renamed to THREE.PlaneGeometry."),super(e,t,n,i)}}class _E extends pb{constructor(e,t,n,i){console.warn("THREE.PolyhedronBufferGeometry has been renamed to THREE.PolyhedronGeometry."),super(e,t,n,i)}}class bE extends Qb{constructor(e,t,n,i,r,o){console.warn("THREE.RingBufferGeometry has been renamed to THREE.RingGeometry."),super(e,t,n,i,r,o)}}class xE extends ex{constructor(e,t){console.warn("THREE.ShapeBufferGeometry has been renamed to THREE.ShapeGeometry."),super(e,t)}}class wE extends tx{constructor(e,t,n,i,r,o,a){console.warn("THREE.SphereBufferGeometry has been renamed to THREE.SphereGeometry."),super(e,t,n,i,r,o,a)}}class SE extends nx{constructor(e,t){console.warn("THREE.TetrahedronBufferGeometry has been renamed to THREE.TetrahedronGeometry."),super(e,t)}}class EE extends ix{constructor(e,t,n,i,r){console.warn("THREE.TorusBufferGeometry has been renamed to THREE.TorusGeometry."),super(e,t,n,i,r)}}class AE extends rx{constructor(e,t,n,i,r,o){console.warn("THREE.TorusKnotBufferGeometry has been renamed to THREE.TorusKnotGeometry."),super(e,t,n,i,r,o)}}class TE extends ox{constructor(e,t,n,i,r){console.warn("THREE.TubeBufferGeometry has been renamed to THREE.TubeGeometry."),super(e,t,n,i,r)}}"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Ic}})),"undefined"!=typeof window&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Ic);const IE=()=>{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},ME=()=>{if("undefined"==typeof navigator)return!1;const e=navigator.userAgent,t=e.includes("Safari")&&!e.includes("Chrome"),n="WebKit"in window&&!("Chrome"in window);return t||n},CE=()=>{if("undefined"==typeof navigator)return!1;const e=navigator.userAgent;return e.includes("Safari")&&!e.includes("Chrome")&&/iPad|iPhone|iPod/.test(e)},NE=/^\w+([.-]?[+]?\w+)*@\w+([.-]?\w+)*(\.\w{2,})+$/;function OE(e,t){const n=(0,c.useRef)(),i=(0,c.useRef)(null);return(0,c.useEffect)((()=>(i.current=e,()=>{i.current=null})),[e]),(0,c.useEffect)((()=>()=>{clearTimeout(n.current)}),[]),(0,c.useMemo)((()=>(...e)=>{clearTimeout(n.current),n.current=window.setTimeout((()=>{i.current&&i.current(...e)}),t)}),[t])}const RE=e=>e.slice(0,e.length/2).trim().toLowerCase()===e.slice(e.length/2+1).trim().toLowerCase()?e.slice(0,e.length/2):e,LE=e=>e.replaceAll(/[^\p{L}\p{N}\p{P}\p{Z}^$\n]/gu,"").trim(),PE=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(),DE=e=>e.replace(/<document_attachment filename="([^"]+)" type="([^"]+)">([\s\S]*?)<\/document_attachment>/g,"$3"),kE=e=>{const t=/<output.*?<\/output>/gs;if(!t.test(e))return e;const n=e.replace(t,"");return kE(n)},BE=e=>{const t=/<think.*?<\/think>/gs;if(!t.test(e))return e;return e.replace(t,"")},FE=e=>{const t=document.createElement("div");return t.innerHTML=e,t.textContent||""},UE=e=>{const t=document.createElement("textarea");return t.textContent=e,t.innerHTML};function zE(e){try{e=encodeURI(e).replace(/%25/g,"%")}catch(e){return null}return e}const GE={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"}},jE=()=>{window.MathJax=GE,(()=>{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 HE(e){Object.values(e).forEach((e=>{e instanceof dx&&(e.roughness=.8,e.metalness=.1,e.shadowSide=2,e.map&&(e.map.anisotropy=16))}))}function VE(e){return!0===e.isSkinnedMesh}const WE=(e,t=!1)=>{try{return JSON.parse(e)}catch(n){return t?e:null}};c=o("85Hg2"),c=o("85Hg2");function qE(e,t){let[n,i]=(0,c.useState)(e),r=es(e);return Ka((()=>i(r.current)),[r,i,...t]),n}c=o("85Hg2");function $E(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 YE(e,t){let[n,i]=(0,c.useState)((()=>$E(e)));return Ka((()=>{i($E(e))}),[e.type,e.as]),Ka((()=>{n||!t.current||t.current instanceof HTMLButtonElement&&!t.current.hasAttribute("type")&&i("button")}),[n,t]),n}c=o("85Hg2");function JE({container:e,accept:t,walk:n,enabled:i=!0}){let r=(0,c.useRef)(t),o=(0,c.useRef)(n);(0,c.useEffect)((()=>{r.current=t,o.current=n}),[t,n]),Ka((()=>{if(!e||!i)return;let t=Gs(e);if(!t)return;let n=r.current,a=o.current,s=Object.assign((e=>n(e)),{acceptNode:n}),l=t.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,s,!1);for(;l.nextNode();)a(l.currentNode)}),[e,i,r,o])}var ZE=(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))(ZE||{});function XE(e,t){let n=t.resolveItems();if(n.length<=0)return null;let i=t.resolveActiveIndex(),r=null!=i?i:-1,o=(()=>{switch(e.focus){case 0:return n.findIndex((e=>!t.resolveDisabled(e)));case 1:{let e=n.slice().reverse().findIndex(((e,n,i)=>!(-1!==r&&i.length-n-1>=r)&&!t.resolveDisabled(e)));return-1===e?e:n.length-1-e}case 2:return n.findIndex(((e,n)=>!(n<=r)&&!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?i:o}function KE(e={},t=null,n=[]){for(let[i,r]of Object.entries(e))eA(n,QE(t,i),r);return n}function QE(e,t){return e?e+"["+t+"]":t}function eA(e,t,n){if(Array.isArray(n))for(let[i,r]of n.entries())eA(e,QE(t,i.toString()),r);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,""]):KE(n,t,e)}function tA(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 nA(e,t,n){let[i,r]=(0,c.useState)(n),o=void 0!==e,a=(0,c.useRef)(o),s=(0,c.useRef)(!1),l=(0,c.useRef)(!1);return!o||a.current||s.current?!o&&a.current&&!l.current&&(l.current=!0,a.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.")):(s.current=!0,a.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:i,is((e=>(o||r(e),null==t?void 0:t(e))))]}var iA=(e=>(e[e.Open=0]="Open",e[e.Closed=1]="Closed",e))(iA||{}),rA=(e=>(e[e.Single=0]="Single",e[e.Multi=1]="Multi",e))(rA||{}),oA=(e=>(e[e.Pointer=0]="Pointer",e[e.Other=1]="Other",e))(oA||{}),aA=(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))(aA||{});function sA(e,t=(e=>e)){let n=null!==e.activeOptionIndex?e.options[e.activeOptionIndex]:null,i=Qs(t(e.options.slice()),(e=>e.dataRef.current.domRef.current)),r=n?i.indexOf(n):null;return-1===r&&(r=null),{options:i,activeOptionIndex:r}}let lA={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,i=e.options.findIndex((e=>n(e.dataRef.current.value)));return-1!==i&&(t=i),{...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 i=sA(e);if(null===i.activeOptionIndex){let e=i.options.findIndex((e=>!e.dataRef.current.disabled));-1!==e&&(i.activeOptionIndex=e)}let r=XE(t,{resolveItems:()=>i.options,resolveActiveIndex:()=>i.activeOptionIndex,resolveId:e=>e.id,resolveDisabled:e=>e.dataRef.current.disabled});return{...e,...i,activeOptionIndex:r,activationTrigger:null!=(n=t.trigger)?n:1}},3:(e,t)=>{let n={id:t.id,dataRef:t.dataRef},i=sA(e,(e=>[...e,n]));null===e.activeOptionIndex&&e.dataRef.current.isSelected(t.dataRef.current.value)&&(i.activeOptionIndex=i.options.indexOf(n));let r={...e,...i,activationTrigger:1};return e.dataRef.current.__demoMode&&void 0===e.dataRef.current.value&&(r.activeOptionIndex=0),r},4:(e,t)=>{let n=sA(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})},cA=(0,c.createContext)(null);function uA(e){let t=(0,c.useContext)(cA);if(null===t){let t=new Error(`<${e} /> is missing a parent <Combobox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(t,uA),t}return t}cA.displayName="ComboboxActionsContext";let dA=(0,c.createContext)(null);function hA(e){let t=(0,c.useContext)(dA);if(null===t){let t=new Error(`<${e} /> is missing a parent <Combobox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(t,hA),t}return t}function pA(e,t){return Ba(t.type,lA,e,t)}dA.displayName="ComboboxDataContext";let mA=c.Fragment;let fA=Va((function(e,n){let{value:i,defaultValue:r,onChange:o,name:a,by:s=((e,t)=>e===t),disabled:l=!1,__demoMode:u=!1,nullable:d=!1,multiple:h=!1,...p}=e,[m,f]=nA(i,o,r),[g,v]=(0,c.useReducer)(pA,{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}),b=(0,c.useRef)(null),x=(0,c.useRef)(null),w=(0,c.useRef)(null),S=(0,c.useRef)(null),E=is("string"==typeof s?(e,t)=>{let n=s;return(null==e?void 0:e[n])===(null==t?void 0:t[n])}:s),A=(0,c.useCallback)((e=>Ba(T.mode,{1:()=>m.some((t=>E(t,e))),0:()=>E(m,e)})),[m]),T=(0,c.useMemo)((()=>({...g,optionsPropsRef:_,labelRef:b,inputRef:x,buttonRef:w,optionsRef:S,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:E,isSelected:A,nullable:d,__demoMode:u})),[m,l,h,d,u,g]);Ka((()=>{g.dataRef.current=T}),[T]),Rl([T.buttonRef,T.inputRef,T.optionsRef],(()=>v({type:1})),0===T.comboboxState);let I=(0,c.useMemo)((()=>({open:0===T.comboboxState,disabled:l,activeIndex:T.activeOptionIndex,activeOption:null===T.activeOptionIndex?null:T.options[T.activeOptionIndex].dataRef.current.value,value:m})),[T,l,m]),M=is((e=>{let t=T.options.find((t=>t.id===e));!t||D(t.dataRef.current.value)})),C=is((()=>{if(null!==T.activeOptionIndex){let{dataRef:e,id:t}=T.options[T.activeOptionIndex];D(e.current.value),v({type:2,focus:ZE.Specific,id:t})}})),N=is((()=>{v({type:0}),y.current=!0})),O=is((()=>{v({type:1}),y.current=!1})),R=is(((e,t,n)=>(y.current=!1,e===ZE.Specific?v({type:2,focus:ZE.Specific,id:t,trigger:n}):v({type:2,focus:e,trigger:n})))),L=is(((e,t)=>(v({type:3,id:e,dataRef:t}),()=>v({type:4,id:e})))),P=is((e=>(v({type:5,id:e}),()=>v({type:5,id:null})))),D=is((e=>Ba(T.mode,{0:()=>null==f?void 0:f(e),1(){let t=T.value.slice(),n=t.findIndex((t=>E(t,e)));return-1===n?t.push(e):t.splice(n,1),null==f?void 0:f(t)}}))),k=(0,c.useMemo)((()=>({onChange:D,registerOption:L,registerLabel:P,goToOption:R,closeCombobox:O,openCombobox:N,selectActiveOption:C,selectOption:M})),[]),B=null===n?{}:{ref:n};return t(c).createElement(cA.Provider,{value:k},t(c).createElement(dA.Provider,{value:T},t(c).createElement(Za,{value:Ba(T.comboboxState,{0:Ya.Open,1:Ya.Closed})},null!=a&&null!=m&&KE({[a]:m}).map((([e,n])=>t(c).createElement(zs,{features:Us.Hidden,...Wa({key:e,as:"input",type:"hidden",hidden:!0,readOnly:!0,name:e,value:n})}))),Ga({ourProps:B,theirProps:p,slot:I,defaultTag:mA,name:"Combobox"}))))})),gA=Va((function(e,t){var n,i;let{value:r,onChange:o,displayValue:a,type:s="text",...l}=e,u=hA("Combobox.Input"),d=uA("Combobox.Input"),h=as(u.inputRef,t),p=`headlessui-combobox-input-${Fs()}`,m=fs(),f=!1;sl((([e,t],[n,i])=>{!u.inputRef.current||(0===i&&1===t?function(e){var t;let n=u.inputRef.current;if(!n||n.value===e)return;let i=Object.getOwnPropertyDescriptor(n.constructor.prototype,"value");null==(t=null==i?void 0:i.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 a?null!=(e=a(u.value))?e:"":"string"==typeof u.value?u.value:""}),[u.value]),u.comboboxState]);let g=(0,c.useRef)(!1),v=is((()=>{g.current=!0})),y=is((()=>{setTimeout((()=>{g.current=!1}))})),_=is((e=>{switch(e.key){case Ls.Backspace:case Ls.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(ZE.Nothing))}));break;case Ls.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 Ls.ArrowDown:return e.preventDefault(),e.stopPropagation(),Ba(u.comboboxState,{0:()=>{d.goToOption(ZE.Next)},1:()=>{d.openCombobox()}});case Ls.ArrowUp:return e.preventDefault(),e.stopPropagation(),Ba(u.comboboxState,{0:()=>{d.goToOption(ZE.Previous)},1:()=>{d.openCombobox(),m.nextFrame((()=>{u.value||d.goToOption(ZE.Last)}))}});case Ls.Home:case Ls.PageUp:return e.preventDefault(),e.stopPropagation(),d.goToOption(ZE.First);case Ls.End:case Ls.PageDown:return e.preventDefault(),e.stopPropagation(),d.goToOption(ZE.Last);case Ls.Escape:return 0!==u.comboboxState?void 0:(e.preventDefault(),u.optionsRef.current&&!u.optionsPropsRef.current.static&&e.stopPropagation(),d.closeCombobox());case Ls.Tab:if(0!==u.comboboxState)return;0===u.mode&&d.selectActiveOption(),d.closeCombobox()}})),b=is((e=>{f||d.openCombobox(),null==o||o(e)})),x=qE((()=>{if(u.labelId)return[u.labelId].join(" ")}),[u.labelId]),w=(0,c.useMemo)((()=>({open:0===u.comboboxState,disabled:u.disabled})),[u]);return Ga({ourProps:{ref:h,id:p,role:"combobox",type:s,"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==(i=u.options[u.activeOptionIndex])?void 0:i.id,"aria-multiselectable":1===u.mode||void 0,"aria-labelledby":x,disabled:u.disabled,onCompositionStart:v,onCompositionEnd:y,onKeyDown:_,onChange:b},theirProps:l,slot:w,defaultTag:"input",name:"Combobox.Input"})})),vA=Va((function(e,t){var n;let i=hA("Combobox.Button"),r=uA("Combobox.Button"),o=as(i.buttonRef,t),a=`headlessui-combobox-button-${Fs()}`,s=fs(),l=is((e=>{switch(e.key){case Ls.ArrowDown:return e.preventDefault(),e.stopPropagation(),1===i.comboboxState&&r.openCombobox(),s.nextFrame((()=>{var e;return null==(e=i.inputRef.current)?void 0:e.focus({preventScroll:!0})}));case Ls.ArrowUp:return e.preventDefault(),e.stopPropagation(),1===i.comboboxState&&(r.openCombobox(),s.nextFrame((()=>{i.value||r.goToOption(ZE.Last)}))),s.nextFrame((()=>{var e;return null==(e=i.inputRef.current)?void 0:e.focus({preventScroll:!0})}));case Ls.Escape:return 0!==i.comboboxState?void 0:(e.preventDefault(),i.optionsRef.current&&!i.optionsPropsRef.current.static&&e.stopPropagation(),r.closeCombobox(),s.nextFrame((()=>{var e;return null==(e=i.inputRef.current)?void 0:e.focus({preventScroll:!0})})));default:return}})),u=is((e=>{if(Ps(e.currentTarget))return e.preventDefault();0===i.comboboxState?r.closeCombobox():(e.preventDefault(),r.openCombobox()),s.nextFrame((()=>{var e;return null==(e=i.inputRef.current)?void 0:e.focus({preventScroll:!0})}))})),d=qE((()=>{if(i.labelId)return[i.labelId,a].join(" ")}),[i.labelId,a]),h=(0,c.useMemo)((()=>({open:0===i.comboboxState,disabled:i.disabled,value:i.value})),[i]),p=e;return Ga({ourProps:{ref:o,id:a,type:YE(e,i.buttonRef),tabIndex:-1,"aria-haspopup":!0,"aria-controls":null==(n=i.optionsRef.current)?void 0:n.id,"aria-expanded":i.disabled?void 0:0===i.comboboxState,"aria-labelledby":d,disabled:i.disabled,onClick:u,onKeyDown:l},theirProps:p,slot:h,defaultTag:"button",name:"Combobox.Button"})})),yA=Va((function(e,t){let n=hA("Combobox.Label"),i=`headlessui-combobox-label-${Fs()}`,r=uA("Combobox.Label"),o=as(n.labelRef,t);Ka((()=>r.registerLabel(i)),[i]);let a=is((()=>{var e;return null==(e=n.inputRef.current)?void 0:e.focus({preventScroll:!0})})),s=(0,c.useMemo)((()=>({open:0===n.comboboxState,disabled:n.disabled})),[n]);return Ga({ourProps:{ref:o,id:i,onClick:a},theirProps:e,slot:s,defaultTag:"label",name:"Combobox.Label"})})),_A=Ua.RenderStrategy|Ua.Static,bA=Va((function(e,t){var n;let{hold:i=!1,...r}=e,o=hA("Combobox.Options"),a=as(o.optionsRef,t),s=`headlessui-combobox-options-${Fs()}`,l=Ja(),u=null!==l?l===Ya.Open:0===o.comboboxState;Ka((()=>{var t;o.optionsPropsRef.current.static=null!=(t=e.static)&&t}),[o.optionsPropsRef,e.static]),Ka((()=>{o.optionsPropsRef.current.hold=i}),[o.optionsPropsRef,i]),JE({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=qE((()=>{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 Ga({ourProps:{"aria-activedescendant":null===o.activeOptionIndex||null==(n=o.options[o.activeOptionIndex])?void 0:n.id,"aria-labelledby":d,role:"listbox",id:s,ref:a},theirProps:r,slot:h,defaultTag:"ul",features:_A,visible:u,name:"Combobox.Options"})})),xA=Va((function(e,t){var n,i;let{disabled:r=!1,value:o,...a}=e,s=hA("Combobox.Option"),l=uA("Combobox.Option"),u=`headlessui-combobox-option-${Fs()}`,d=null!==s.activeOptionIndex&&s.options[s.activeOptionIndex].id===u,h=s.isSelected(o),p=(0,c.useRef)(null),m=es({disabled:r,value:o,domRef:p,textValue:null==(i=null==(n=p.current)?void 0:n.textContent)?void 0:i.toLowerCase()}),f=as(t,p),g=is((()=>l.selectOption(u)));Ka((()=>l.registerOption(u,m)),[m,u]);let v=(0,c.useRef)(!s.__demoMode);Ka((()=>{if(!s.__demoMode)return;let e=cs();return e.requestAnimationFrame((()=>{v.current=!0})),e.dispose}),[]),Ka((()=>{if(0!==s.comboboxState||!d||!v.current||0===s.activationTrigger)return;let e=cs();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,s.comboboxState,s.activationTrigger,s.activeOptionIndex]);let y=is((e=>{if(r)return e.preventDefault();g(),0===s.mode&&l.closeCombobox()})),_=is((()=>{if(r)return l.goToOption(ZE.Nothing);l.goToOption(ZE.Specific,u)})),b=is((()=>{r||d||l.goToOption(ZE.Specific,u,0)})),x=is((()=>{r||!d||s.optionsPropsRef.current.hold||l.goToOption(ZE.Nothing)})),w=(0,c.useMemo)((()=>({active:d,selected:h,disabled:r})),[d,h,r]);return Ga({ourProps:{id:u,ref:f,role:"option",tabIndex:!0===r?void 0:-1,"aria-disabled":!0===r||void 0,"aria-selected":h,disabled:void 0,onClick:y,onFocus:_,onPointerMove:b,onMouseMove:b,onPointerLeave:x,onMouseLeave:x},theirProps:a,slot:w,defaultTag:"li",name:"Combobox.Option"})})),wA=Object.assign(fA,{Input:gA,Button:vA,Label:yA,Options:bA,Option:xA});const SA=({center:e,size:n})=>{const i=oc();return(0,c.useEffect)((()=>{const r=new(t(ac).Circle)(e,n),o=i.layerContainer||i.map;return o.addLayer(r),()=>{o.removeLayer(r)}})),null},EA=({center:e,uncertainty:t})=>{const[n,i]=(0,c.useState)(!1),r=Ac(),o=(0,c.useCallback)((()=>{let n=void 0!==t?Math.round(Math.log2(1e7/t)):r.getZoom();r.setView(e,n)}),[e,t,r]);return(0,c.useEffect)((()=>{n||(o(),i(!0))}),[]),(0,c.useEffect)((()=>{o()}),[e,t,o]),null};let AA=t(ac).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(ac).Marker.prototype.options.icon=AA;const TA=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 IA=({venue:e,setVenue:n,showUncertainty:i=!1,showGpsButton:r=!0,saveAndClose:o})=>{var s,l,u;const{t:d}=Ve(),[h,p]=(0,c.useState)(!1),[m,f]=(0,c.useState)(!1),[g,v]=(0,c.useState)(!1),[y,_]=(0,c.useState)(""),[b,x]=(0,c.useState)([]),w=OE((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();x(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,a.jsxs)("fieldset",{className:"memori--venue-widget",children:[(0,a.jsx)("legend",{className:"sr-only",children:"Venue"}),(0,a.jsxs)("div",{className:"memori--venue-widget__form-item",children:[(0,a.jsx)("div",{className:"memori--venue-widget__geosuggest",children:m?(0,a.jsx)("p",{children:d("write_and_speak.updatingPosition")}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"memori--venue-widget-search",children:(0,a.jsxs)(wA,{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=>{const t=TA(e);n({latitude:e.lat,longitude:e.lon,placeName:t,uncertainty:(null==e?void 0:e.boundingbox)?tc(e.boundingbox):2})},children:[(0,a.jsx)(wA.Input,{className:"memori--venue-widget-search--input",displayValue:e=>e?TA(e):"",placeholder:d("searchVenue"),onChange:e=>{return t=e.target.value,_(t),void w(t);var t}}),(g||b.length>0||0===b.length&&""!==y)&&(0,a.jsx)(Os,{as:c.Fragment,leave:"transition ease-in duration-100",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:(0,a.jsx)(wA.Options,{className:"memori--venue-widget-search--options",children:g?(0,a.jsx)(Yl,{spinning:!0,children:(0,a.jsxs)("div",{className:"memori--venue-widget-search--option memori--venue-widget-search--option-centered",children:[d("loading"),"..."]})}):0===b.length&&""!==y?(0,a.jsx)("div",{className:"memori--venue-widget-search--option memori--venue-widget-search--option-centered",children:d("nothingFound")}):null==b?void 0:b.map((e=>(0,a.jsx)(wA.Option,{as:c.Fragment,value:e,children:({active:n,selected:i})=>(0,a.jsx)("li",{className:t(We)("memori--venue-widget-search--option",{"memori--venue-widget-search--option-active":n,"memori--venue-widget-search--option-selected":i}),children:e.display_name})},e.place_id)))})})]})}),r&&(0,a.jsx)(Jl,{className:"memori--venue-widget__gps-button",primary:!0,loading:m,onClick:()=>{f(!0),(async()=>{f(!0),navigator.geolocation.getCurrentPosition((async e=>{let i={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`),r=await t.json(),a=TA(r);i={latitude:e.coords.latitude,longitude:e.coords.longitude,placeName:a,uncertainty:e.coords.accuracy/1e3},n(i)}catch(e){let r=e;console.error("[POSITION ERROR]",r),(null==r?void 0:r.message)&&t(So).error(r.message),n(i)}finally{o&&o(i)}f(!1)}),(e=>{console.error("[POSITION ERROR]",e),t(So).error(e.message),f(!1)}))})()},children:d("write_and_speak.useMyPosition")})]})}),(0,a.jsx)("div",{children:(0,a.jsx)(Jl,{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")})}),i&&(0,a.jsxs)("label",{className:"memori--venue-widget__select-label",children:[(0,a.jsxs)("span",{children:[d("uncertain"),": "]}),(0,a.jsxs)("select",{className:"memori-select--button memori--venue-widget__uncertainty",value:parseFloat((null!==(s=null==e?void 0:e.uncertainty)&&void 0!==s?s: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,a.jsxs)("option",{value:e.uncertainty,children:[e.uncertainty," Km"]}),(0,a.jsx)("option",{value:0,children:d("exactPosition")}),(0,a.jsx)("option",{value:1,children:"1 km"}),(0,a.jsx)("option",{value:2,children:"2 km"}),(0,a.jsx)("option",{value:5,children:"5 km"}),(0,a.jsx)("option",{value:10,children:"10 km"}),(0,a.jsx)("option",{value:20,children:"20 km"}),(0,a.jsx)("option",{value:50,children:"50 km"}),(0,a.jsx)("option",{value:100,children:"100 km"})]})]})]}),(0,a.jsxs)("div",{className:"memori--venue-widget__form-item",children:[(null==e?void 0:e.placeName)&&"Position"!==e.placeName&&(0,a.jsxs)("p",{className:"memori--venue--widget__place-name",children:[(0,a.jsx)("strong",{children:d("venue")}),": ",e.placeName]}),(0,a.jsx)("div",{className:"memori--venue-widget__map",children:h&&(0,a.jsxs)(cc,{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,a.jsx)(Ec,{attribution:'© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',url:"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"}),(0,a.jsx)(EA,{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,a.jsx)(xc,{position:[e.latitude,e.longitude],icon:AA,children:(0,a.jsx)(wc,{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,a.jsx)(SA,{center:[e.latitude,e.longitude],size:1e3*e.uncertainty})]})})]})]})};var MA=({memori:e,open:t,onClose:n,venue:i,setVenue:r})=>{const{t:o}=Ve();return(0,a.jsxs)(Ql,{className:"memori-position-drawer",open:t,onClose:()=>n(i),title:o("widget.position")||"Position",animated:!1,children:[(0,a.jsx)("p",{children:o("write_and_speak.requirePositionHelp",{name:e.name})}),(0,a.jsx)(IA,{venue:i,setVenue:r,showUncertainty:!1,saveAndClose:e=>{r(e),n(e)}})]})};c=o("85Hg2"),c=o("85Hg2");var CA=({open:e=!1,onClose:n,className:i,title:r,description:o,children:s,footer:l,loading:u=!1,closable:d=!0,width:h="100%",widthMd:p="100%"})=>{const{t:m}=Ve();return(0,a.jsx)(Os,{appear:!0,show:e,as:t(c).Fragment,children:(0,a.jsxs)(ql,{open:e,onClose:n,className:t(We)("memori-modal",i),children:[(0,a.jsx)(Os.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,a.jsx)("div",{className:"memori-modal--backdrop"})}),(0,a.jsx)("div",{className:"memori-modal--container",children:(0,a.jsx)("div",{className:"memori-modal--container-scrollable",children:(0,a.jsx)(Os.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,a.jsxs)(ql.Panel,{className:"memori-modal--panel",children:[(0,a.jsx)("style",{dangerouslySetInnerHTML:{__html:`\n .memori-modal--panel {\n --memori-modal--width: ${h};\n --memori-modal--width-md: ${p};\n }\n `}}),d&&(0,a.jsx)("div",{className:"memori-modal--close",children:(0,a.jsx)(Jl,{ghost:!0,padded:!0,shape:"circle",icon:(0,a.jsx)(Zl,{}),title:m("close")||"Close",onClick:()=>n(!1)})}),(0,a.jsxs)(Yl,{spinning:u,children:[r&&(0,a.jsx)(ql.Title,{className:"memori-modal--title",children:r}),o&&(0,a.jsx)(ql.Description,{className:"memori-modal--description",children:o}),s,l&&(0,a.jsx)("div",{className:"memori-modal--footer",children:l})]})]})})})})]})})},NA=(c=o("85Hg2"),e=>"checkbox"===e.type),OA=e=>e instanceof Date,RA=e=>null==e;const LA=e=>"object"==typeof e;var PA=e=>!RA(e)&&!Array.isArray(e)&&LA(e)&&!OA(e),DA=e=>PA(e)&&e.target?NA(e.target)?e.target.checked:e.target.value:e,kA=(e,t)=>e.has((e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e)(t)),BA=e=>Array.isArray(e)?e.filter(Boolean):[],FA=e=>void 0===e,UA=(e,t,n)=>{if(!t||!PA(e))return n;const i=BA(t.split(/[,[\].]+?/)).reduce(((e,t)=>RA(e)?e:e[t]),e);return FA(i)||i===e?FA(e[t])?n:e[t]:i};const zA="blur",GA="focusout",jA="onBlur",HA="onChange",VA="onSubmit",WA="onTouched",qA="all",$A="max",YA="min",JA="maxLength",ZA="minLength",XA="pattern",KA="required",QA="validate";t(c).createContext(null);var eT=(e,t,n,i=!0)=>{const r={defaultValues:t._defaultValues};for(const o in e)Object.defineProperty(r,o,{get:()=>{const r=o;return t._proxyFormState[r]!==qA&&(t._proxyFormState[r]=!i||qA),n&&(n[r]=!0),e[r]}});return r},tT=e=>PA(e)&&!Object.keys(e).length,nT=(e,t,n)=>{const{name:i,...r}=e;return tT(r)||Object.keys(r).length>=Object.keys(t).length||Object.keys(r).find((e=>t[e]===(!n||qA)))},iT=e=>Array.isArray(e)?e:[e];function rT(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 oT=e=>"string"==typeof e,aT=(e,t,n,i)=>oT(e)?(i&&t.watch.add(e),UA(n,e)):Array.isArray(e)?e.map((e=>(i&&t.watch.add(e),UA(n,e)))):(t.watchAll=!!i,n),sT="undefined"!=typeof window&&void 0!==window.HTMLElement&&"undefined"!=typeof document;function lT(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(sT&&(e instanceof Blob||e instanceof FileList)||!n&&!PA(e))return e;if(t=n?[]:{},Array.isArray(e)||(e=>{const t=e.constructor&&e.constructor.prototype;return PA(t)&&t.hasOwnProperty("isPrototypeOf")})(e))for(const n in e)t[n]=lT(e[n]);else t=e}return t}var cT=(e,t,n,i,r)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[i]:r||!0}}:{},uT=e=>/^\w*$/.test(e),dT=e=>BA(e.replace(/["|']|\]/g,"").split(/\.|\[/));function hT(e,t,n){let i=-1;const r=uT(t)?[t]:dT(t),o=r.length,a=o-1;for(;++i<o;){const t=r[i];let o=n;if(i!==a){const n=e[t];o=PA(n)||Array.isArray(n)?n:isNaN(+r[i+1])?{}:[]}e[t]=o,e=e[t]}return e}const pT=(e,t,n)=>{for(const i of n||Object.keys(e)){const n=UA(e,i);if(n){const{_f:e,...i}=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 PA(i)&&pT(i,t)}}};var mT=(e,t,n)=>!n&&(t.watchAll||t.watch.has(e)||[...t.watch].some((t=>e.startsWith(t)&&/^\.\w+/.test(e.slice(t.length))))),fT=(e,t,n)=>{const i=BA(UA(e,n));return hT(i,"root",t[n]),hT(e,n,i),e},gT=e=>"boolean"==typeof e,vT=e=>"file"===e.type,yT=e=>"function"==typeof e,_T=e=>oT(e)||t(c).isValidElement(e),bT=e=>"radio"===e.type,xT=e=>e instanceof RegExp;const wT={value:!1,isValid:!1},ST={value:!0,isValid:!0};var ET=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&&!FA(e[0].attributes.value)?FA(e[0].value)||""===e[0].value?ST:{value:e[0].value,isValid:!0}:ST:wT}return wT};const AT={isValid:!1,value:null};var TT=e=>Array.isArray(e)?e.reduce(((e,t)=>t&&t.checked&&!t.disabled?{isValid:!0,value:t.value}:e),AT):AT;function IT(e,t,n="validate"){if(_T(e)||Array.isArray(e)&&e.every(_T)||gT(e)&&!e)return{type:n,message:_T(e)?e:"",ref:t}}var MT=e=>PA(e)&&!xT(e)?e:{value:e,message:""},CT=async(e,t,n,i,r)=>{const{ref:o,refs:a,required:s,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=a?a[0]:o,_=e=>{i&&y.reportValidity&&(y.setCustomValidity(gT(e)?"":e||""),y.reportValidity())},b={},x=bT(o),w=NA(o),S=x||w,E=(f||vT(o))&&!o.value||""===t||Array.isArray(t)&&!t.length,A=cT.bind(null,m,n,b),T=(e,t,n,i=JA,r=ZA)=>{const a=e?t:n;b[m]={type:e?i:r,message:a,ref:o,...A(e?i:r,a)}};if(r?!Array.isArray(t)||!t.length:s&&(!S&&(E||RA(t))||gT(t)&&!t||w&&!ET(a).isValid||x&&!TT(a).isValid)){const{value:e,message:t}=_T(s)?{value:!!s,message:s}:MT(s);if(e&&(b[m]={type:KA,message:t,ref:y,...A(KA,t)},!n))return _(t),b}if(!(E||RA(u)&&RA(d))){let e,i;const r=MT(d),a=MT(u);if(RA(t)||isNaN(t)){const n=o.valueAsDate||new Date(t),s=e=>new Date((new Date).toDateString()+" "+e),l="time"==o.type,c="week"==o.type;oT(r.value)&&t&&(e=l?s(t)>s(r.value):c?t>r.value:n>new Date(r.value)),oT(a.value)&&t&&(i=l?s(t)<s(a.value):c?t<a.value:n<new Date(a.value))}else{const n=o.valueAsNumber||(t?+t:t);RA(r.value)||(e=n>r.value),RA(a.value)||(i=n<a.value)}if((e||i)&&(T(!!e,r.message,a.message,$A,YA),!n))return _(b[m].message),b}if((l||c)&&!E&&(oT(t)||r&&Array.isArray(t))){const e=MT(l),i=MT(c),r=!RA(e.value)&&t.length>e.value,o=!RA(i.value)&&t.length<i.value;if((r||o)&&(T(r,e.message,i.message),!n))return _(b[m].message),b}if(h&&!E&&oT(t)){const{value:e,message:i}=MT(h);if(xT(e)&&!t.match(e)&&(b[m]={type:XA,message:i,ref:o,...A(XA,i)},!n))return _(i),b}if(p)if(yT(p)){const e=IT(await p(t),y);if(e&&(b[m]={...e,...A(QA,e.message)},!n))return _(e.message),b}else if(PA(p)){let e={};for(const i in p){if(!tT(e)&&!n)break;const r=IT(await p[i](t),y,i);r&&(e={...r,...A(i,r.message)},_(r.message),n&&(b[m]=e))}if(!tT(e)&&(b[m]={ref:y,...e},!n))return b}return _(!0),b};var NT=e=>({isOnSubmit:!e||e===VA,isOnBlur:e===jA,isOnChange:e===HA,isOnAll:e===qA,isOnTouch:e===WA});function OT(e){for(const t in e)if(!FA(e[t]))return!1;return!0}function RT(e,t){const n=uT(t)?[t]:dT(t),i=1==n.length?e:function(e,t){const n=t.slice(0,-1).length;let i=0;for(;i<n;)e=FA(e)?i++:e[t[i++]];return e}(e,n),r=n[n.length-1];let o;i&&delete i[r];for(let t=0;t<n.slice(0,-1).length;t++){let i,r=-1;const a=n.slice(0,-(t+1)),s=a.length-1;for(t>0&&(o=e);++r<a.length;){const t=a[r];i=i?i[t]:e[t],s===r&&(PA(i)&&tT(i)||Array.isArray(i)&&OT(i))&&(o?delete o[t]:delete e[t]),o=i}}return e}function LT(){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 PT=e=>RA(e)||!LA(e);function DT(e,t){if(PT(e)||PT(t))return e===t;if(OA(e)&&OA(t))return e.getTime()===t.getTime();const n=Object.keys(e),i=Object.keys(t);if(n.length!==i.length)return!1;for(const r of n){const n=e[r];if(!i.includes(r))return!1;if("ref"!==r){const e=t[r];if(OA(n)&&OA(e)||PA(n)&&PA(e)||Array.isArray(n)&&Array.isArray(e)?!DT(n,e):n!==e)return!1}}return!0}var kT=e=>{const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},BT=e=>"select-multiple"===e.type,FT=e=>kT(e)&&e.isConnected,UT=e=>{for(const t in e)if(yT(e[t]))return!0;return!1};function zT(e,t={}){const n=Array.isArray(e);if(PA(e)||n)for(const n in e)Array.isArray(e[n])||PA(e[n])&&!UT(e[n])?(t[n]=Array.isArray(e[n])?[]:{},zT(e[n],t[n])):RA(e[n])||(t[n]=!0);return t}function GT(e,t,n){const i=Array.isArray(e);if(PA(e)||i)for(const i in e)Array.isArray(e[i])||PA(e[i])&&!UT(e[i])?FA(t)||PT(n[i])?n[i]=Array.isArray(e[i])?zT(e[i],[]):{...zT(e[i])}:GT(e[i],RA(t)?{}:t[i],n[i]):DT(e[i],t[i])?delete n[i]:n[i]=!0;return n}var jT=(e,t)=>GT(e,t,zT(t)),HT=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:i})=>FA(e)?e:t?""===e?NaN:e?+e:e:n&&oT(e)?new Date(e):i?i(e):e;function VT(e){const t=e.ref;if(!(e.refs?e.refs.every((e=>e.disabled)):t.disabled))return vT(t)?t.files:bT(t)?TT(e.refs).value:BT(t)?[...t.selectedOptions].map((({value:e})=>e)):NA(t)?ET(e.refs).value:HT(FA(t.value)?e.ref.value:t.value,e)}var WT=e=>FA(e)?e:xT(e)?e.source:PA(e)?xT(e.value)?e.value.source:e.value:e;function qT(e,t,n){const i=UA(e,n);if(i||uT(n))return{error:i,name:n};const r=n.split(".");for(;r.length;){const i=r.join("."),o=UA(t,i),a=UA(e,i);if(o&&!Array.isArray(o)&&n!==i)return{name:n};if(a&&a.type)return{name:i,error:a};r.pop()}return{name:n}}const $T={mode:VA,reValidateMode:HA,shouldFocusError:!0};function YT(e={}){let t,n={...$T,...e},i={submitCount:0,isDirty:!1,isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},errors:{}},r={},o=lT(n.defaultValues)||{},a=n.shouldUnregister?{}:lT(o),s={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:LT(),array:LT(),state:LT()},p=NT(n.mode),m=NT(n.reValidateMode),f=n.criteriaMode===qA,g=async()=>{let e=!1;return d.isValid&&(e=n.resolver?tT((await b()).errors):await x(r,!0),e!==i.isValid&&(i.isValid=e,h.state.next({isValid:e}))),e},v=(e,t,n,i)=>{const l=UA(r,e);if(l){const r=UA(a,e,FA(n)?UA(o,e):n);FA(r)||i&&i.defaultChecked||t?hT(a,e,t?r:VT(l._f)):E(e,r),s.mount&&g()}},y=(e,t,n,r,a)=>{let s=!1,l=!1;const c={name:e};if(d.isDirty&&(l=i.isDirty,i.isDirty=c.isDirty=w(),s=l!==c.isDirty),d.dirtyFields&&(!n||r)){l=UA(i.dirtyFields,e);const n=DT(UA(o,e),t);n?RT(i.dirtyFields,e):hT(i.dirtyFields,e,!0),c.dirtyFields=i.dirtyFields,s=s||l!==!n}if(n){const t=UA(i.touchedFields,e);t||(hT(i.touchedFields,e,n),c.touchedFields=i.touchedFields,s=s||d.touchedFields&&t!==n)}return s&&a&&h.state.next(c),s?c:{}},_=(n,r,o,a)=>{const s=UA(i.errors,n),l=d.isValid&&gT(r)&&i.isValid!==r;var p;if(e.delayError&&o?(p=()=>((e,t)=>{hT(i.errors,e,t),h.state.next({errors:i.errors})})(n,o),t=e=>{clearTimeout(c),c=window.setTimeout(p,e)},t(e.delayError)):(clearTimeout(c),t=null,o?hT(i.errors,n,o):RT(i.errors,n)),(o?!DT(s,o):s)||!tT(a)||l){const e={...a,...l&&gT(r)?{isValid:r}:{},errors:i.errors,name:n};i={...i,...e},h.state.next(e)}u[n]--,d.isValidating&&!Object.values(u).some((e=>e))&&(h.state.next({isValidating:!1}),u={})},b=async e=>n.resolver?await n.resolver({...a},n.context,((e,t,n,i)=>{const r={};for(const n of e){const e=UA(t,n);e&&hT(r,n,e._f)}return{criteriaMode:n,names:[...e],fields:r,shouldUseNativeValidation:i}})(e||l.mount,r,n.criteriaMode,n.shouldUseNativeValidation)):{},x=async(e,t,r={valid:!0})=>{for(const o in e){const s=e[o];if(s){const{_f:e,...o}=s;if(e){const o=l.array.has(e.name),c=await CT(s,UA(a,e.name),f,n.shouldUseNativeValidation,o);if(c[e.name]&&(r.valid=!1,t))break;!t&&(UA(c,e.name)?o?fT(i.errors,c,e.name):hT(i.errors,e.name,c[e.name]):RT(i.errors,e.name))}o&&await x(o,t,r)}}return r.valid},w=(e,t)=>(e&&t&&hT(a,e,t),!DT(C(),o)),S=(e,t,n)=>aT(e,l,{...s.mount?a:FA(t)?o:oT(e)?{[e]:t}:t},n),E=(e,t,n={})=>{const i=UA(r,e);let o=t;if(i){const n=i._f;n&&(!n.disabled&&hT(a,e,HT(t,n)),o=sT&&kT(n.ref)&&RA(t)?"":t,BT(n.ref)?[...n.ref.options].forEach((e=>e.selected=o.includes(e.value))):n.refs?NA(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)):vT(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&&M(e)},A=(e,t,n)=>{for(const i in t){const o=t[i],a=`${e}.${i}`,s=UA(r,a);!l.array.has(e)&&PT(o)&&(!s||s._f)||OA(o)?E(a,o,n):A(a,o,n)}},T=(e,t,n={})=>{const s=UA(r,e),c=l.array.has(e),u=lT(t);hT(a,e,u),c?(h.array.next({name:e,values:a}),(d.isDirty||d.dirtyFields)&&n.shouldDirty&&(i.dirtyFields=jT(o,a),h.state.next({name:e,dirtyFields:i.dirtyFields,isDirty:w(e,u)}))):!s||s._f||RA(u)?E(e,u,n):A(e,u,n),mT(e,l)&&h.state.next({}),h.watch.next({name:e})},I=async e=>{const o=e.target;let s=o.name;const c=UA(r,s);if(c){let x,w;const S=o.type?VT(c._f):DA(e),E=e.type===zA||e.type===GA,A=!((v=c._f).mount&&(v.required||v.min||v.max||v.maxLength||v.minLength||v.pattern||v.validate)||n.resolver||UA(i.errors,s)||c._f.deps)||((e,t,n,i,r)=>!r.isOnAll&&(!n&&r.isOnTouch?!(t||e):(n?i.isOnBlur:r.isOnBlur)?!e:!(n?i.isOnChange:r.isOnChange)||e))(E,UA(i.touchedFields,s),i.isSubmitted,m,p),T=mT(s,l,E);hT(a,s,S),E?(c._f.onBlur&&c._f.onBlur(e),t&&t(0)):c._f.onChange&&c._f.onChange(e);const I=y(s,S,E,!1),C=!tT(I)||T;if(!E&&h.watch.next({name:s,type:e.type}),A)return d.isValid&&g(),C&&h.state.next({name:s,...T?{}:I});if(!E&&T&&h.state.next({}),u[s]=u[s]?u[s]+1:1,h.state.next({isValidating:!0}),n.resolver){const{errors:e}=await b([s]),t=qT(i.errors,r,s),n=qT(e,r,t.name||s);x=n.error,s=n.name,w=tT(e)}else x=(await CT(c,UA(a,s),f,n.shouldUseNativeValidation))[s],g();c._f.deps&&M(c._f.deps),_(s,w,x,I)}var v},M=async(e,t={})=>{let o,a;const s=iT(e);if(h.state.next({isValidating:!0}),n.resolver){const t=await(async e=>{const{errors:t}=await b();if(e)for(const n of e){const e=UA(t,n);e?hT(i.errors,n,e):RT(i.errors,n)}else i.errors=t;return t})(FA(e)?e:s);o=tT(t),a=e?!s.some((e=>UA(t,e))):o}else e?(a=(await Promise.all(s.map((async e=>{const t=UA(r,e);return await x(t&&t._f?{[e]:t}:t)})))).every(Boolean),(a||i.isValid)&&g()):a=o=await x(r);return h.state.next({...!oT(e)||d.isValid&&o!==i.isValid?{}:{name:e},...n.resolver||!e?{isValid:o}:{},errors:i.errors,isValidating:!1}),t.shouldFocus&&!a&&pT(r,(e=>e&&UA(i.errors,e)),e?s:l.mount),a},C=e=>{const t={...o,...s.mount?a:{}};return FA(e)?t:oT(e)?UA(t,e):e.map((e=>UA(t,e)))},N=(e,t)=>({invalid:!!UA((t||i).errors,e),isDirty:!!UA((t||i).dirtyFields,e),isTouched:!!UA((t||i).touchedFields,e),error:UA((t||i).errors,e)}),O=(e,t={})=>{for(const s of e?iT(e):l.mount)l.mount.delete(s),l.array.delete(s),UA(r,s)&&(t.keepValue||(RT(r,s),RT(a,s)),!t.keepError&&RT(i.errors,s),!t.keepDirty&&RT(i.dirtyFields,s),!t.keepTouched&&RT(i.touchedFields,s),!n.shouldUnregister&&!t.keepDefaultValue&&RT(o,s));h.watch.next({}),h.state.next({...i,...t.keepDirty?{isDirty:w()}:{}}),!t.keepIsValid&&g()},R=(e,t={})=>{let i=UA(r,e);const c=gT(t.disabled);return hT(r,e,{...i||{},_f:{...i&&i._f?i._f:{ref:{name:e}},name:e,mount:!0,...t}}),l.mount.add(e),i?c&&hT(a,e,t.disabled?void 0:UA(a,e,VT(i._f))):v(e,!0,t.value),{...c?{disabled:t.disabled}:{},...n.shouldUseNativeValidation?{required:!!t.required,min:WT(t.min),max:WT(t.max),minLength:WT(t.minLength),maxLength:WT(t.maxLength),pattern:WT(t.pattern)}:{},name:e,onChange:I,onBlur:I,ref:a=>{if(a){R(e,t),i=UA(r,e);const n=FA(a.value)&&a.querySelectorAll&&a.querySelectorAll("input,select,textarea")[0]||a,s=(e=>bT(e)||NA(e))(n),l=i._f.refs||[];if(s?l.find((e=>e===n)):n===i._f.ref)return;hT(r,e,{_f:{...i._f,...s?{refs:[...l.filter(FT),n,...Array.isArray(UA(o,e))?[{}]:[]],ref:{type:n.type,name:e}}:{ref:n}}}),v(e,!1,void 0,n)}else i=UA(r,e,{}),i._f&&(i._f.mount=!1),(n.shouldUnregister||t.shouldUnregister)&&(!kA(l.array,e)||!s.action)&&l.unMount.add(e)}}},L=()=>n.shouldFocusError&&pT(r,(e=>e&&UA(i.errors,e)),l.mount);return{control:{register:R,unregister:O,getFieldState:N,_executeSchema:b,_focusError:L,_getWatch:S,_getDirty:w,_updateValid:g,_removeUnmounted:()=>{for(const e of l.unMount){const t=UA(r,e);t&&(t._f.refs?t._f.refs.every((e=>!FT(e))):!FT(t._f.ref))&&O(e)}l.unMount=new Set},_updateFieldArray:(e,t=[],n,l,c=!0,u=!0)=>{if(l&&n){if(s.action=!0,u&&Array.isArray(UA(r,e))){const t=n(UA(r,e),l.argA,l.argB);c&&hT(r,e,t)}if(u&&Array.isArray(UA(i.errors,e))){const t=n(UA(i.errors,e),l.argA,l.argB);c&&hT(i.errors,e,t),((e,t)=>{!BA(UA(e,t)).length&&RT(e,t)})(i.errors,e)}if(d.touchedFields&&u&&Array.isArray(UA(i.touchedFields,e))){const t=n(UA(i.touchedFields,e),l.argA,l.argB);c&&hT(i.touchedFields,e,t)}d.dirtyFields&&(i.dirtyFields=jT(o,a)),h.state.next({isDirty:w(e,t),dirtyFields:i.dirtyFields,errors:i.errors,isValid:i.isValid})}else hT(a,e,t)},_getFieldArray:t=>BA(UA(s.mount?a:o,t,e.shouldUnregister?UA(o,t,[]):[])),_subjects:h,_proxyFormState:d,get _fields(){return r},get _formValues(){return a},get _stateFlags(){return s},set _stateFlags(e){s=e},get _defaultValues(){return o},get _names(){return l},set _names(e){l=e},get _formState(){return i},set _formState(e){i=e},get _options(){return n},set _options(e){n={...n,...e}}},trigger:M,register:R,handleSubmit:(e,t)=>async o=>{o&&(o.preventDefault&&o.preventDefault(),o.persist&&o.persist());let s=!0,l=lT(a);h.state.next({isSubmitting:!0});try{if(n.resolver){const{errors:e,values:t}=await b();i.errors=e,l=t}else await x(r);tT(i.errors)?(h.state.next({errors:{},isSubmitting:!0}),await e(l,o)):(t&&await t({...i.errors},o),L())}catch(e){throw s=!1,e}finally{i.isSubmitted=!0,h.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:tT(i.errors)&&s,submitCount:i.submitCount+1,errors:i.errors})}},watch:(e,t)=>yT(e)?h.watch.subscribe({next:n=>e(S(void 0,t),n)}):S(e,t,!0),setValue:T,getValues:C,reset:(t,n)=>((t,n={})=>{const c=t||o,u=lT(c),p=t&&!tT(t)?u:o;if(n.keepDefaultValues||(o=c),!n.keepValues){if(n.keepDirtyValues)for(const e of l.mount)UA(i.dirtyFields,e)?hT(p,e,UA(a,e)):T(e,UA(p,e));else{if(sT&&FA(t))for(const e of l.mount){const t=UA(r,e);if(t&&t._f){const e=Array.isArray(t._f.refs)?t._f.refs[0]:t._f.ref;if(kT(e)){const t=e.closest("form");if(t){t.reset();break}}}}r={}}a=e.shouldUnregister?n.keepDefaultValues?lT(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:""},s.mount=!d.isValid||!!n.keepIsValid,s.watch=!!e.shouldUnregister,h.state.next({submitCount:n.keepSubmitCount?i.submitCount:0,isDirty:n.keepDirty||n.keepDirtyValues?i.isDirty:!(!n.keepDefaultValues||DT(t,o)),isSubmitted:!!n.keepIsSubmitted&&i.isSubmitted,dirtyFields:n.keepDirty||n.keepDirtyValues?i.dirtyFields:n.keepDefaultValues&&t?jT(o,t):{},touchedFields:n.keepTouched?i.touchedFields:{},errors:n.keepErrors?i.errors:{},isSubmitting:!1,isSubmitSuccessful:!1})})(yT(t)?t(a):t,n),resetField:(e,t={})=>{UA(r,e)&&(FA(t.defaultValue)?T(e,UA(o,e)):(T(e,t.defaultValue),hT(o,e,t.defaultValue)),t.keepTouched||RT(i.touchedFields,e),t.keepDirty||(RT(i.dirtyFields,e),i.isDirty=t.defaultValue?w(e,UA(o,e)):w()),t.keepError||(RT(i.errors,e),d.isValid&&g()),h.state.next({...i}))},clearErrors:e=>{e?iT(e).forEach((e=>RT(i.errors,e))):i.errors={},h.state.next({errors:i.errors})},unregister:O,setError:(e,t,n)=>{const o=(UA(r,e,{_f:{}})._f||{}).ref;hT(i.errors,e,{...t,ref:o}),h.state.next({name:e,errors:i.errors,isValid:!1}),n&&n.shouldFocus&&o&&o.focus&&o.focus()},setFocus:(e,t={})=>{const n=UA(r,e),i=n&&n._f;if(i){const e=i.refs?i.refs[0]:i.ref;e.focus&&(e.focus(),t.shouldSelect&&e.select())}},getFieldState:N}}function JT(e={}){const n=t(c).useRef(),[i,r]=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={...YT(e),formState:i});const o=n.current.control;return o._options=e,rT({subject:o._subjects.state,callback:t(c).useCallback((e=>{nT(e,o._proxyFormState,!0)&&(o._formState={...o._formState,...e},r({...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((()=>{i.submitCount&&o._focusError()}),[o,i.submitCount]),n.current.formState=eT(i,o),n.current}var ZT=({className:e,title:t})=>(0,a.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,a.jsx)("path",{d:"M482 152h60q8 0 8 8v704q0 8-8 8h-60q-8 0-8-8V160q0-8 8-8z"}),(0,a.jsx)("path",{d:"M176 474h672q8 0 8 8v60q0 8-8 8H176q-8 0-8-8v-60q0-8 8-8z"})]});var XT=({pwdOrTokens:e,setPwdOrTokens:t,onFinish:n,minimumNumberOfRecoveryTokens:i=1,showTokens:r=!0,openModal:o=!1,withModal:s=!1})=>{var l,u,d;const{t:h}=Ve(),{register:p,handleSubmit:m,formState:{errors:f},setError:g}=JT(),[v,y]=(0,c.useState)(1),[_,b]=(0,c.useState)(!!e),[x,w]=(0,c.useState)(!1),S=(0,a.jsxs)("form",{name:"memoriAuth",onSubmit:m((t=>{var r,o,a;const s="password"===e&&!(null===(r=t.password)||void 0===r?void 0:r.length),l="tokens"===e&&(((null===(o=null==t?void 0:t.tokens)||void 0===o?void 0:o.length)||0)<i||!(null===(a=null==t?void 0:t.tokens)||void 0===a?void 0:a.every((e=>e.length))));s?g("password",{type:"required",message:h("auth.passwordRequired")||"Password required"}):l?g("tokens",{type:"minLength",message:h("auth.tokens")||"Tokens"}):n&&(w(!0),n(t).then((()=>{b(!1)})).catch((()=>{"password"===e?g("password",{type:"auth",message:h("auth.invalidCredentials")||"Invalid credentials"}):"tokens"===e&&g("tokens",{type:"auth",message:h("auth.invalidCredentials")||"Invalid credentials"})})).finally((()=>{w(!1)})))})),className:"memori-auth-widget--form",children:[("password"===e||!r)&&(0,a.jsxs)("fieldset",{className:"memori-auth-widget--password-fieldset",children:[(0,a.jsxs)("label",{children:["Password:"," ",(0,a.jsx)("input",{className:"memori-auth-widget--input",required:!0,type:"password",placeholder:"Password",...p("password",{required:!0})})]}),r&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("hr",{}),(0,a.jsx)(Jl,{outlined:!0,onClick:()=>t("tokens"),children:h("auth.useRecoveryTokens")||"Recovery tokens"})]})]}),"tokens"===e&&r&&(0,a.jsxs)("fieldset",{className:"memori-auth-widget--tokens-fieldset",name:"tokens",children:[(0,a.jsxs)("legend",{children:[h("auth.tokens"),": "]}),(E=v,Array.from({length:E},((e,t)=>t))).map((e=>(0,a.jsx)("label",{className:"memori-auth-widget--token",children:(0,a.jsx)("input",{type:"password",className:"memori-auth-widget--input",placeholder:"Recovery token",required:!0,autoComplete:"off",...p(`tokens.${e}`,{required:!0})})},e))),(0,a.jsx)(Jl,{onClick:()=>y((e=>e+1)),className:"memori-auth-widget--token-add",icon:(0,a.jsx)(ZT,{}),children:h("auth.addToken")||"Add token"}),(0,a.jsx)("hr",{}),(0,a.jsx)(Jl,{outlined:!0,onClick:()=>t("password"),children:h("auth.usePassword")||"Password"})]}),"minLength"===(null===(l=f.tokens)||void 0===l?void 0:l.type)&&(0,a.jsxs)("div",{className:"memori-auth-widget--error",children:[h("auth.atLeast")||"At least"," ",i]}),"auth"===(null===(u=f.password)||void 0===u?void 0:u.type)&&(0,a.jsx)("div",{className:"memori-auth-widget--error",children:f.password.message}),"auth"===(null===(d=f.tokens)||void 0===d?void 0:d.type)&&(0,a.jsx)("div",{className:"memori-auth-widget--error",children:f.tokens.message}),(0,a.jsx)(Jl,{htmlType:"submit",primary:!0,className:"memori-auth-widget--submit",loading:x,children:h("confirm")||"Submit"})]});var E;return s?(0,a.jsx)(CA,{open:o||_,title:h("auth.title")||"Authentication",onClose:()=>t(null),closable:!1,children:S}):S};c=o("85Hg2");const KT=({type:e,resourceURI:t,sessionID:n,baseURL:i="",apiURL:r=""})=>{let o="cover"===e?`${i}/images/memoriCover.png`:`${i}/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==r?void 0:r.replace(/v2/,"v1"))||""}/CloudAsset/${t.replace("cloud://","")}`:t.startsWith("guid://")?`${(null==r?void 0:r.replace(/v2/,"v1"))||""}/GuidAsset/${t.replace("guid://","")}`:t||o:o}catch(e){return t||o}};c=o("85Hg2");var QT=({className:e,title:t})=>(0,a.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,a.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 eI=({className:e,title:t})=>(0,a.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,a.jsxs)("g",{fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd",children:[(0,a.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,a.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,a.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 tI=({className:e,title:t})=>(0,a.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,a.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,a.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 nI=({content:e,className:n,align:i="right",disabled:r=!1,visible:o=!1,children:s})=>(0,a.jsxs)("div",{className:t(We)("memori-tooltip",`memori-tooltip--align-${i}`,n,{"memori-tooltip--disabled":r,"memori-tooltip--visible":o}),children:[(0,a.jsx)("div",{className:"memori-tooltip--content",children:e}),(0,a.jsx)("div",{className:"memori-tooltip--trigger",children:s})]}),iI=(c=o("85Hg2"),c=o("85Hg2"),(e=>(e[e.Open=0]="Open",e[e.Closed=1]="Closed",e))(iI||{})),rI=(e=>(e[e.Pointer=0]="Pointer",e[e.Other=1]="Other",e))(rI||{}),oI=(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))(oI||{});function aI(e,t=(e=>e)){let n=null!==e.activeItemIndex?e.items[e.activeItemIndex]:null,i=Qs(t(e.items.slice()),(e=>e.dataRef.current.domRef.current)),r=n?i.indexOf(n):null;return-1===r&&(r=null),{items:i,activeItemIndex:r}}let sI={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 i=aI(e),r=XE(t,{resolveItems:()=>i.items,resolveActiveIndex:()=>i.activeItemIndex,resolveId:e=>e.id,resolveDisabled:e=>e.dataRef.current.disabled});return{...e,...i,searchQuery:"",activeItemIndex:r,activationTrigger:null!=(n=t.trigger)?n:1}},3:(e,t)=>{let n=""!==e.searchQuery?0:1,i=e.searchQuery+t.value.toLowerCase(),r=(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(i))&&!e.dataRef.current.disabled})),o=r?e.items.indexOf(r):-1;return-1===o||o===e.activeItemIndex?{...e,searchQuery:i}:{...e,searchQuery:i,activeItemIndex:o,activationTrigger:1}},4:e=>""===e.searchQuery?e:{...e,searchQuery:"",searchActiveItemIndex:null},5:(e,t)=>{let n=aI(e,(e=>[...e,{id:t.id,dataRef:t.dataRef}]));return{...e,...n}},6:(e,t)=>{let n=aI(e,(e=>{let n=e.findIndex((e=>e.id===t.id));return-1!==n&&e.splice(n,1),e}));return{...e,...n,activationTrigger:1}}},lI=(0,c.createContext)(null);function cI(e){let t=(0,c.useContext)(lI);if(null===t){let t=new Error(`<${e} /> is missing a parent <Menu /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(t,cI),t}return t}function uI(e,t){return Ba(t.type,sI,e,t)}lI.displayName="MenuContext";let dI=c.Fragment,hI=Va((function(e,n){let i=(0,c.useReducer)(uI,{menuState:1,buttonRef:(0,c.createRef)(),itemsRef:(0,c.createRef)(),items:[],searchQuery:"",activeItemIndex:null,activationTrigger:1}),[{menuState:r,itemsRef:o,buttonRef:a},s]=i,l=as(n);Rl([a,o],((e,t)=>{var n;s({type:1}),Js(t,Ys.Loose)||(e.preventDefault(),null==(n=a.current)||n.focus())}),0===r);let u=is((()=>{s({type:1})})),d=(0,c.useMemo)((()=>({open:0===r,close:u})),[r,u]),h=e,p={ref:l};return t(c).createElement(lI.Provider,{value:i},t(c).createElement(Za,{value:Ba(r,{0:Ya.Open,1:Ya.Closed})},Ga({ourProps:p,theirProps:h,slot:d,defaultTag:dI,name:"Menu"})))})),pI=Va((function(e,t){var n;let[i,r]=cI("Menu.Button"),o=as(i.buttonRef,t),a=`headlessui-menu-button-${Fs()}`,s=fs(),l=is((e=>{switch(e.key){case Ls.Space:case Ls.Enter:case Ls.ArrowDown:e.preventDefault(),e.stopPropagation(),r({type:0}),s.nextFrame((()=>r({type:2,focus:ZE.First})));break;case Ls.ArrowUp:e.preventDefault(),e.stopPropagation(),r({type:0}),s.nextFrame((()=>r({type:2,focus:ZE.Last})))}})),u=is((e=>{if(e.key===Ls.Space)e.preventDefault()})),d=is((t=>{if(Ps(t.currentTarget))return t.preventDefault();e.disabled||(0===i.menuState?(r({type:1}),s.nextFrame((()=>{var e;return null==(e=i.buttonRef.current)?void 0:e.focus({preventScroll:!0})}))):(t.preventDefault(),r({type:0})))})),h=(0,c.useMemo)((()=>({open:0===i.menuState})),[i]),p=e;return Ga({ourProps:{ref:o,id:a,type:YE(e,i.buttonRef),"aria-haspopup":!0,"aria-controls":null==(n=i.itemsRef.current)?void 0:n.id,"aria-expanded":e.disabled?void 0:0===i.menuState,onKeyDown:l,onKeyUp:u,onClick:d},theirProps:p,slot:h,defaultTag:"button",name:"Menu.Button"})})),mI=Ua.RenderStrategy|Ua.Static,fI=Va((function(e,t){var n,i;let[r,o]=cI("Menu.Items"),a=as(r.itemsRef,t),s=ol(r.itemsRef),l=`headlessui-menu-items-${Fs()}`,u=fs(),d=Ja(),h=null!==d?d===Ya.Open:0===r.menuState;(0,c.useEffect)((()=>{let e=r.itemsRef.current;!e||0===r.menuState&&e!==(null==s?void 0:s.activeElement)&&e.focus({preventScroll:!0})}),[r.menuState,r.itemsRef,s]),JE({container:r.itemsRef.current,enabled:0===r.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=is((e=>{var t,n;switch(u.dispose(),e.key){case Ls.Space:if(""!==r.searchQuery)return e.preventDefault(),e.stopPropagation(),o({type:3,value:e.key});case Ls.Enter:if(e.preventDefault(),e.stopPropagation(),o({type:1}),null!==r.activeItemIndex){let{dataRef:e}=r.items[r.activeItemIndex];null==(n=null==(t=e.current)?void 0:t.domRef.current)||n.click()}Zs(r.buttonRef.current);break;case Ls.ArrowDown:return e.preventDefault(),e.stopPropagation(),o({type:2,focus:ZE.Next});case Ls.ArrowUp:return e.preventDefault(),e.stopPropagation(),o({type:2,focus:ZE.Previous});case Ls.Home:case Ls.PageUp:return e.preventDefault(),e.stopPropagation(),o({type:2,focus:ZE.First});case Ls.End:case Ls.PageDown:return e.preventDefault(),e.stopPropagation(),o({type:2,focus:ZE.Last});case Ls.Escape:e.preventDefault(),e.stopPropagation(),o({type:1}),cs().nextFrame((()=>{var e;return null==(e=r.buttonRef.current)?void 0:e.focus({preventScroll:!0})}));break;case Ls.Tab:e.preventDefault(),e.stopPropagation(),o({type:1}),cs().nextFrame((()=>{el(r.buttonRef.current,e.shiftKey?Vs.Previous:Vs.Next)}));break;default:1===e.key.length&&(o({type:3,value:e.key}),u.setTimeout((()=>o({type:4})),350))}})),m=is((e=>{if(e.key===Ls.Space)e.preventDefault()})),f=(0,c.useMemo)((()=>({open:0===r.menuState})),[r]),g=e;return Ga({ourProps:{"aria-activedescendant":null===r.activeItemIndex||null==(n=r.items[r.activeItemIndex])?void 0:n.id,"aria-labelledby":null==(i=r.buttonRef.current)?void 0:i.id,id:l,onKeyDown:p,onKeyUp:m,role:"menu",tabIndex:0,ref:a},theirProps:g,slot:f,defaultTag:"div",features:mI,visible:h,name:"Menu.Items"})})),gI=c.Fragment,vI=Va((function(e,t){let{disabled:n=!1,...i}=e,[r,o]=cI("Menu.Item"),a=`headlessui-menu-item-${Fs()}`,s=null!==r.activeItemIndex&&r.items[r.activeItemIndex].id===a,l=(0,c.useRef)(null),u=as(t,l);Ka((()=>{if(0!==r.menuState||!s||0===r.activationTrigger)return;let e=cs();return e.requestAnimationFrame((()=>{var e,t;null==(t=null==(e=l.current)?void 0:e.scrollIntoView)||t.call(e,{block:"nearest"})})),e.dispose}),[l,s,r.menuState,r.activationTrigger,r.activeItemIndex]);let d=(0,c.useRef)({disabled:n,domRef:l});Ka((()=>{d.current.disabled=n}),[d,n]),Ka((()=>{var e,t;d.current.textValue=null==(t=null==(e=l.current)?void 0:e.textContent)?void 0:t.toLowerCase()}),[d,l]),Ka((()=>(o({type:5,id:a,dataRef:d}),()=>o({type:6,id:a}))),[d,a]);let h=is((()=>{o({type:1})})),p=is((e=>{if(n)return e.preventDefault();o({type:1}),Zs(r.buttonRef.current)})),m=is((()=>{if(n)return o({type:2,focus:ZE.Nothing});o({type:2,focus:ZE.Specific,id:a})})),f=is((()=>{n||s||o({type:2,focus:ZE.Specific,id:a,trigger:0})})),g=is((()=>{n||!s||o({type:2,focus:ZE.Nothing})})),v=(0,c.useMemo)((()=>({active:s,disabled:n,close:h})),[s,n,h]);return Ga({ourProps:{id:a,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:i,slot:v,defaultTag:gI,name:"Menu.Item"})})),yI=Object.assign(hI,{Button:pI,Items:fI,Item:vI});var _I=({className:e,title:t})=>(0,a.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,a.jsx)("path",{fill:"none",d:"M0 0h24v24H0V0z"}),(0,a.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 bI={"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"},xI={"it-IT":"La risposta non era corretta","fr-FR":"La réponse n'était pas correcte","en-GB":"The answer was not correct"},wI={"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 SI=({memori:e,className:n,onNegativeClick:i,toggle:r=!1,dropdown:o=!1})=>{const[s,l]=(0,c.useState)(),u="it-IT"===e.culture?"it-IT":"fr-FR"===e.culture?"fr-FR":"en-GB",d=bI[u],h=xI[u],p=wI[u];return(0,a.jsx)("div",{className:"memori-chat--feedback"+(n?` ${n}`:""),children:o?(0,a.jsxs)(yI,{as:"div",className:"memori-chat--feedback-menu",children:[(0,a.jsx)(yI.Button,{as:t(c).Fragment,children:(0,a.jsx)(Jl,{ghost:!0,shape:"circle",title:"Feedback",className:"memori-chat--feedback-menu-button",disabled:!!s,icon:(0,a.jsx)(_I,{className:s?"memori-chat--feedback-clicked":void 0})})}),(0,a.jsx)(Os,{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,a.jsx)(yI.Items,{className:"memori-chat--feedback-menu-items",children:(0,a.jsxs)("div",{className:"memori-chat--feedback-menu-items-container",children:[(0,a.jsx)(yI.Item,{children:({active:e})=>(0,a.jsx)("button",{className:"memori-chat--feedback-menu-item"+(e?" memori-chat--feedback-menu-item-active":""),onClick:()=>{l("up"===s&&r?void 0:"up")},children:p})},"ok"),(0,a.jsx)(yI.Item,{children:({active:e})=>(0,a.jsx)("button",{className:"memori-chat--feedback-menu-item"+(e?" memori-chat--feedback-menu-item-active":""),onClick:()=>{l("down"===s&&r?void 0:"down"),i(d)},children:h})},"no")]})})})]}):(0,a.jsx)(nI,{align:"left",content:"Feedback",children:(0,a.jsx)(Jl,{title:"Feedback",onClick:()=>{l("down"===s&&r?void 0:"down"),i(d)},ghost:!0,shape:"circle",icon:(0,a.jsx)(_I,{className:s?"memori-chat--feedback-clicked":void 0})})})})};var EI=({className:e,title:t})=>(0,a.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,a.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,a.jsx)("path",{d:"M9.09 9a3 3 0 015.83 1c0 2-3 3-3 3"}),(0,a.jsx)("path",{d:"M12 17L12.01 17"})]});var AI=({className:e,title:t})=>(0,a.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,a.jsx)("rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"}),(0,a.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 TI=({className:e,title:t})=>(0,a.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,a.jsx)("path",{d:"M10 9.5 8 12l2 2.5"}),(0,a.jsx)("path",{d:"m14 9.5 2 2.5-2 2.5"}),(0,a.jsx)("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"})]});var II=({className:e,title:t})=>(0,a.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,a.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,a.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,a.jsx)("path",{d:"M19 14H22",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),(0,a.jsx)("path",{d:"M5 14H2",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),(0,a.jsx)("path",{d:"M14.5 3.5L17 2",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),(0,a.jsx)("path",{d:"M9.5 3.5L7 2",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),(0,a.jsx)("path",{d:"M20.5 20.0002L18.5 19.2002",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),(0,a.jsx)("path",{d:"M20.5 7.9998L18.5 8.7998",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),(0,a.jsx)("path",{d:"M3.5 20.0002L5.5 19.2002",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),(0,a.jsx)("path",{d:"M3.5 7.9998L5.5 8.7998",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),(0,a.jsx)("path",{d:"M12 21.5V15",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),MI=(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 i={exec:()=>null};function r(e,t=""){let n="string"==typeof e?e:e.source;const i={replace:(e,t)=>{let r="string"==typeof t?t:t.source;return r=r.replace(o.caret,"$1"),n=n.replace(e,r),i},getRegex:()=>new RegExp(n,t)};return i}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")},a=/^(?:[ \t]*(?:\n|$))+/,s=/^((?: {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=r(/^(?!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=r(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",f).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),v=r(/^( {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]*?(?:-->|$))/,b=r("^ {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(),x=r(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(),w={blockquote:r(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",x).getRegex(),code:s,def:g,fences:l,heading:u,hr:c,html:b,lheading:h,list:v,newline:a,paragraph:x,table:i,text:m},S=r("^ *([^\\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(),E={...w,table:S,paragraph:r(p).replace("hr",c).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",S).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={...w,html:r("^ *(?: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:i,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:r(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()},T=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,I=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,M=/^( {2,}|\\)\n(?!\s*$)/,C=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,N=/\p{P}\p{S}/u,O=r(/^((?![*_])[\spunctuation])/,"u").replace(/punctuation/g,N).getRegex(),R=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,L=r(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/,"u").replace(/punct/g,N).getRegex(),P=r("^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)[punct](\\*+)(?=[\\s]|$)|[^punct\\s](\\*+)(?!\\*)(?=[punct\\s]|$)|(?!\\*)[punct\\s](\\*+)(?=[^punct\\s])|[\\s](\\*+)(?!\\*)(?=[punct])|(?!\\*)[punct](\\*+)(?!\\*)(?=[punct])|[^punct\\s](\\*+)(?=[^punct\\s])","gu").replace(/punct/g,N).getRegex(),D=r("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\\s]|$)|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)|(?!_)[punct\\s](_+)(?=[^punct\\s])|[\\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])","gu").replace(/punct/g,N).getRegex(),k=r(/\\([punct])/,"gu").replace(/punct/g,N).getRegex(),B=r(/^<(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(),F=r(_).replace("(?:--\x3e|$)","--\x3e").getRegex(),U=r("^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",F).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),z=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,G=r(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label",z).replace("href",/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),j=r(/^!?\[(label)\]\[(ref)\]/).replace("label",z).replace("ref",f).getRegex(),H=r(/^!?\[(ref)\](?:\[\])?/).replace("ref",f).getRegex(),V=r("reflink|nolink(?!\\()","g").replace("reflink",j).replace("nolink",H).getRegex(),W={_backpedal:i,anyPunctuation:k,autolink:B,blockSkip:R,br:M,code:I,del:i,emStrongLDelim:L,emStrongRDelimAst:P,emStrongRDelimUnd:D,escape:T,link:G,nolink:H,punctuation:O,reflink:j,reflinkSearch:V,tag:U,text:C,url:i},q={...W,link:r(/^!?\[(label)\]\((.*?)\)/).replace("label",z).getRegex(),reflink:r(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",z).getRegex()},$={...W,escape:r(T).replace("])","~|])").getRegex(),url:r(/^((?: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.!#$%&'*+\/=?_`{\|}~-]+@)))/},Y={...$,br:r(M).replace("{2,}","*").getRegex(),text:r($.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},J={normal:w,gfm:E,pedantic:A},Z={normal:W,gfm:$,breaks:Y,pedantic:q},X={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},K=e=>X[e];function Q(e,t){if(t){if(o.escapeTest.test(e))return e.replace(o.escapeReplace,K)}else if(o.escapeTestNoEncode.test(e))return e.replace(o.escapeReplaceNoEncode,K);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 i=!1,r=t;for(;--r>=0&&"\\"===n[r];)i=!i;return i?"|":" |"})).split(o.splitPipe);let i=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(;i<n.length;i++)n[i]=n[i].trim().replace(o.slashPipe,"|");return n}function ne(e,t,n){const i=e.length;if(0===i)return"";let r=0;for(;r<i;){const o=e.charAt(i-r-1);if(o!==t||n){if(o===t||!n)break;r++}else r++}return e.slice(0,i-r)}function ie(e,t){if(-1===e.indexOf(t[1]))return-1;let n=0;for(let i=0;i<e.length;i++)if("\\"===e[i])i++;else if(e[i]===t[0])n++;else if(e[i]===t[1]&&(n--,n<0))return i;return-1}function re(e,t,n,i,r){const o=t.href,a=t.title||null,s=e[1].replace(r.other.outputLinkReplace,"$1");if("!"!==e[0].charAt(0)){i.state.inLink=!0;const e={type:"link",raw:n,href:o,title:a,text:s,tokens:i.inlineTokens(s)};return i.state.inLink=!1,e}return{type:"image",raw:n,href:o,title:a,text:s}}function oe(e,t,n){const i=e.match(n.other.indentCodeCompensation);if(null===i)return t;const r=i[1];return t.split("\n").map((e=>{const t=e.match(n.other.beginningSpace);if(null===t)return e;const[i]=t;return i.length>=r.length?e.slice(r.length):e})).join("\n")}class ae{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="",i="";const r=[];for(;e.length>0;){let t=!1;const o=[];let a;for(a=0;a<e.length;a++)if(this.rules.other.blockquoteStart.test(e[a]))o.push(e[a]),t=!0;else{if(t)break;o.push(e[a])}e=e.slice(a);const s=o.join("\n"),l=s.replace(this.rules.other.blockquoteSetextReplace,"\n $1").replace(this.rules.other.blockquoteSetextReplace2,"");n=n?`${n}\n${s}`:s,i=i?`${i}\n${l}`:l;const c=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(l,r,!0),this.lexer.state.top=c,0===e.length)break;const u=r.at(-1);if("code"===u?.type)break;if("blockquote"===u?.type){const t=u,o=t.raw+"\n"+e.join("\n"),a=this.blockquote(o);r[r.length-1]=a,n=n.substring(0,n.length-t.raw.length)+a.raw,i=i.substring(0,i.length-t.text.length)+a.text;break}if("list"!==u?.type);else{const t=u,o=t.raw+"\n"+e.join("\n"),a=this.list(o);r[r.length-1]=a,n=n.substring(0,n.length-u.raw.length)+a.raw,i=i.substring(0,i.length-t.raw.length)+a.raw,e=o.substring(r.at(-1).raw.length).split("\n")}}return{type:"blockquote",raw:n,tokens:r,text:i}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim();const i=n.length>1,r={type:"list",raw:"",ordered:i,start:i?+n.slice(0,-1):"",loose:!1,items:[]};n=i?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=i?n:"[*+-]");const o=this.rules.other.listItemRegex(n);let a=!1;for(;e;){let n=!1,i="",s="";if(!(t=o.exec(e)))break;if(this.rules.block.hr.test(e))break;i=t[0],e=e.substring(i.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,s=l.trimStart()):u?d=t[1].length+1:(d=t[2].search(this.rules.other.nonSpaceChar),d=d>4?1:d,s=l.slice(d),d+=t[1].length),u&&this.rules.other.blankLine.test(c)&&(i+=c+"\n",e=e.substring(c.length+1),n=!0),!n){const t=this.rules.other.nextBulletRegex(d),n=this.rules.other.hrRegex(d),r=this.rules.other.fencesBeginRegex(d),o=this.rules.other.headingBeginRegex(d),a=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," "),r.test(c))break;if(o.test(c))break;if(a.test(c))break;if(t.test(c))break;if(n.test(c))break;if(p.search(this.rules.other.nonSpaceChar)>=d||!c.trim())s+="\n"+p.slice(d);else{if(u)break;if(l.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4)break;if(r.test(l))break;if(o.test(l))break;if(n.test(l))break;s+="\n"+c}u||c.trim()||(u=!0),i+=h+"\n",e=e.substring(h.length+1),l=p.slice(d)}}r.loose||(a?r.loose=!0:this.rules.other.doubleBlankLine.test(i)&&(a=!0));let h,p=null;this.options.gfm&&(p=this.rules.other.listIsTask.exec(s),p&&(h="[ ] "!==p[0],s=s.replace(this.rules.other.listReplaceTask,""))),r.items.push({type:"list_item",raw:i,task:!!p,checked:h,loose:!1,text:s,tokens:[]}),r.raw+=i}const s=r.items.at(-1);s&&(s.raw=s.raw.trimEnd(),s.text=s.text.trimEnd()),r.raw=r.raw.trimEnd();for(let e=0;e<r.items.length;e++)if(this.lexer.state.top=!1,r.items[e].tokens=this.lexer.blockTokens(r.items[e].text,[]),!r.loose){const t=r.items[e].tokens.filter((e=>"space"===e.type)),n=t.length>0&&t.some((e=>this.rules.other.anyLine.test(e.raw)));r.loose=n}if(r.loose)for(let e=0;e<r.items.length;e++)r.items[e].loose=!0;return r}}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"):"",i=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:i}}}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]),i=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),r=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split("\n"):[],o={type:"table",raw:t[0],header:[],align:[],rows:[]};if(n.length===i.length){for(const e of i)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 r)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=ie(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],i="";if(this.options.pedantic){const e=this.rules.other.pedanticHrefTitle.exec(n);e&&(n=e[1],i=e[3])}else i=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)),re(t,{href:n?n.replace(this.rules.inline.anyPunctuation,"$1"):n,title:i?i.replace(this.rules.inline.anyPunctuation,"$1"):i},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 re(n,e,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let i=this.rules.inline.emStrongLDelim.exec(e);if(i&&(!i[3]||!n.match(this.rules.other.unicodeAlphaNumeric))&&(!i[1]&&!i[2]||!n||this.rules.inline.punctuation.exec(n))){const n=[...i[0]].length-1;let r,o,a=n,s=0;const l="*"===i[0][0]?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(l.lastIndex=0,t=t.slice(-1*e.length+n);null!=(i=l.exec(t));){if(r=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!r)continue;if(o=[...r].length,i[3]||i[4]){a+=o;continue}if((i[5]||i[6])&&n%3&&!((n+o)%3)){s+=o;continue}if(a-=o,a>0)continue;o=Math.min(o,o+a+s);const t=[...i[0]][0].length,l=e.slice(0,n+i.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),i=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return n&&i&&(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 i;do{i=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??""}while(i!==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 se{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 ae,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:J.normal,inline:Z.normal};this.options.pedantic?(n.block=J.pedantic,n.inline=Z.pedantic):this.options.gfm&&(n.block=J.gfm,this.options.breaks?n.inline=Z.breaks:n.inline=Z.gfm),this.tokenizer.rules=n}static get rules(){return{block:J,inline:Z}}static lex(e,t){return new se(t).lex(e)}static lexInline(e,t){return new se(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 i;if(this.options.extensions?.block?.some((n=>!!(i=n.call({lexer:this},e,t))&&(e=e.substring(i.raw.length),t.push(i),!0))))continue;if(i=this.tokenizer.space(e)){e=e.substring(i.raw.length);const n=t.at(-1);1===i.raw.length&&void 0!==n?n.raw+="\n":t.push(i);continue}if(i=this.tokenizer.code(e)){e=e.substring(i.raw.length);const n=t.at(-1);"paragraph"===n?.type||"text"===n?.type?(n.raw+="\n"+i.raw,n.text+="\n"+i.text,this.inlineQueue.at(-1).src=n.text):t.push(i);continue}if(i=this.tokenizer.fences(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.heading(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.hr(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.blockquote(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.list(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.html(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.def(e)){e=e.substring(i.raw.length);const n=t.at(-1);"paragraph"===n?.type||"text"===n?.type?(n.raw+="\n"+i.raw,n.text+="\n"+i.raw,this.inlineQueue.at(-1).src=n.text):this.tokens.links[i.tag]||(this.tokens.links[i.tag]={href:i.href,title:i.title});continue}if(i=this.tokenizer.table(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.lheading(e)){e=e.substring(i.raw.length),t.push(i);continue}let r=e;if(this.options.extensions?.startBlock){let t=1/0;const n=e.slice(1);let i;this.options.extensions.startBlock.forEach((e=>{i=e.call({lexer:this},n),"number"==typeof i&&i>=0&&(t=Math.min(t,i))})),t<1/0&&t>=0&&(r=e.substring(0,t+1))}if(this.state.top&&(i=this.tokenizer.paragraph(r))){const o=t.at(-1);n&&"paragraph"===o?.type?(o.raw+="\n"+i.raw,o.text+="\n"+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=o.text):t.push(i),n=r.length!==e.length,e=e.substring(i.raw.length)}else if(i=this.tokenizer.text(e)){e=e.substring(i.raw.length);const n=t.at(-1);"text"===n?.type?(n.raw+="\n"+i.raw,n.text+="\n"+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(i)}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,i=null;if(this.tokens.links){const e=Object.keys(this.tokens.links);if(e.length>0)for(;null!=(i=this.tokenizer.rules.inline.reflinkSearch.exec(n));)e.includes(i[0].slice(i[0].lastIndexOf("[")+1,-1))&&(n=n.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;null!=(i=this.tokenizer.rules.inline.blockSkip.exec(n));)n=n.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;null!=(i=this.tokenizer.rules.inline.anyPunctuation.exec(n));)n=n.slice(0,i.index)+"++"+n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let r=!1,o="";for(;e;){let i;if(r||(o=""),r=!1,this.options.extensions?.inline?.some((n=>!!(i=n.call({lexer:this},e,t))&&(e=e.substring(i.raw.length),t.push(i),!0))))continue;if(i=this.tokenizer.escape(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.tag(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.link(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(i.raw.length);const n=t.at(-1);"text"===i.type&&"text"===n?.type?(n.raw+=i.raw,n.text+=i.text):t.push(i);continue}if(i=this.tokenizer.emStrong(e,n,o)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.codespan(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.br(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.del(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.autolink(e)){e=e.substring(i.raw.length),t.push(i);continue}if(!this.state.inLink&&(i=this.tokenizer.url(e))){e=e.substring(i.raw.length),t.push(i);continue}let a=e;if(this.options.extensions?.startInline){let t=1/0;const n=e.slice(1);let i;this.options.extensions.startInline.forEach((e=>{i=e.call({lexer:this},n),"number"==typeof i&&i>=0&&(t=Math.min(t,i))})),t<1/0&&t>=0&&(a=e.substring(0,t+1))}if(i=this.tokenizer.inlineText(a)){e=e.substring(i.raw.length),"_"!==i.raw.slice(-1)&&(o=i.raw.slice(-1)),r=!0;const n=t.at(-1);"text"===n?.type?(n.raw+=i.raw,n.text+=i.text):t.push(i)}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 i=(t||"").match(o.notSpaceStart)?.[0],r=e.replace(o.endingNewline,"")+"\n";return i?'<pre><code class="language-'+Q(i)+'">'+(n?r:Q(r,!0))+"</code></pre>\n":"<pre><code>"+(n?r:Q(r,!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 i="";for(let t=0;t<e.items.length;t++){const n=e.items[t];i+=this.listitem(n)}const r=t?"ol":"ul";return"<"+r+(t&&1!==n?' start="'+n+'"':"")+">\n"+i+"</"+r+">\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+" "+Q(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 i="";for(let t=0;t<e.rows.length;t++){const r=e.rows[t];n="";for(let e=0;e<r.length;e++)n+=this.tablecell(r[e]);i+=this.tablerow({text:n})}return i&&(i=`<tbody>${i}</tbody>`),"<table>\n<thead>\n"+t+"</thead>\n"+i+"</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>${Q(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 i=this.parser.parseInline(n),r=ee(e);if(null===r)return i;let o='<a href="'+(e=r)+'"';return t&&(o+=' title="'+Q(t)+'"'),o+=">"+i+"</a>",o}image({href:e,title:t,text:n}){const i=ee(e);if(null===i)return Q(n);let r=`<img src="${e=i}" alt="${n}"`;return t&&(r+=` title="${Q(t)}"`),r+=">",r}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:Q(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 i=0;i<e.length;i++){const r=e[i];if(this.options.extensions?.renderers?.[r.type]){const e=r,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=r;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 r=o,a=this.renderer.text(r);for(;i+1<e.length&&"text"===e[i+1].type;)r=e[++i],a+="\n"+this.renderer.text(r);n+=t?this.renderer.paragraph({type:"paragraph",raw:a,text:a,tokens:[{type:"text",raw:a,text:a,escaped:!0}]}):a;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 i=0;i<e.length;i++){const r=e[i];if(this.options.extensions?.renderers?.[r.type]){const e=this.options.extensions.renderers[r.type].call({parser:this},r);if(!1!==e||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(r.type)){n+=e||"";continue}}const o=r;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?se.lex:se.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=se;Tokenizer=ae;Hooks=de;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(const i of e)switch(n=n.concat(t.call(this,i)),i.type){case"table":{const e=i;for(const i of e.header)n=n.concat(this.walkTokens(i.tokens,t));for(const i of e.rows)for(const e of i)n=n.concat(this.walkTokens(e.tokens,t));break}case"list":{const e=i;n=n.concat(this.walkTokens(e.items,t));break}default:{const e=i;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach((i=>{const r=e[i].flat(1/0);n=n.concat(this.walkTokens(r,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 i=e.renderer.apply(this,t);return!1===i&&(i=n.apply(this,t)),i}: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 i=n,r=e.renderer[i],o=t[i];t[i]=(...e)=>{let n=r.apply(t,e);return!1===n&&(n=o.apply(t,e)),n||""}}n.renderer=t}if(e.tokenizer){const t=this.defaults.tokenizer||new ae(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 i=n,r=e.tokenizer[i],o=t[i];t[i]=(...e)=>{let n=r.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 i=n,r=e.hooks[i],o=t[i];de.passThroughHooks.has(n)?t[i]=e=>{if(this.defaults.async)return Promise.resolve(r.call(t,e)).then((e=>o.call(t,e)));const n=r.call(t,e);return o.call(t,n)}:t[i]=(...e)=>{let n=r.apply(t,e);return!1===n&&(n=o.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){const t=this.defaults.walkTokens,i=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(i.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 se.lex(e,t??this.defaults)}parser(e,t){return ue.parse(e,t??this.defaults)}parseMarkdown(e){const t=(t,n)=>{const i={...n},r={...this.defaults,...i},o=this.onError(!!r.silent,!!r.async);if(!0===this.defaults.async&&!1===i.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"));r.hooks&&(r.hooks.options=r,r.hooks.block=e);const a=r.hooks?r.hooks.provideLexer():e?se.lex:se.lexInline,s=r.hooks?r.hooks.provideParser():e?ue.parse:ue.parseInline;if(r.async)return Promise.resolve(r.hooks?r.hooks.preprocess(t):t).then((e=>a(e,r))).then((e=>r.hooks?r.hooks.processAllTokens(e):e)).then((e=>r.walkTokens?Promise.all(this.walkTokens(e,r.walkTokens)).then((()=>e)):e)).then((e=>s(e,r))).then((e=>r.hooks?r.hooks.postprocess(e):e)).catch(o);try{r.hooks&&(t=r.hooks.preprocess(t));let e=a(t,r);r.hooks&&(e=r.hooks.processAllTokens(e)),r.walkTokens&&this.walkTokens(e,r.walkTokens);let n=s(e,r);return r.hooks&&(n=r.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>"+Q(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=se,me.lexer=se.lex,me.Tokenizer=ae,me.Hooks=de,me.parse=me;const fe=me.options,ge=me.setOptions,ve=me.use,ye=me.walkTokens,_e=me.parseInline,be=me,xe=ue.parse,we=se.lex;e.Hooks=de,e.Lexer=se,e.Marked=he,e.Parser=ue,e.Renderer=le,e.TextRenderer=ce,e.Tokenizer=ae,e.getDefaults=t,e.lexer=we,e.marked=me,e.options=fe,e.parse=be,e.parseInline=_e,e.parser=xe,e.setOptions=ge,e.use=ve,e.walkTokens=ye}(MI);var CI={};
238
- /*! @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 */CI=function(){"use strict";const{entries:e,setPrototypeOf:t,isFrozen:n,getPrototypeOf:i,getOwnPropertyDescriptor:r}=Object;let{freeze:o,seal:a,create:s}=Object,{apply:l,construct:c}="undefined"!=typeof Reflect&&Reflect;o||(o=function(e){return e}),a||(a=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=w(Array.prototype.forEach),d=w(Array.prototype.pop),h=w(Array.prototype.push),p=w(String.prototype.toLowerCase),m=w(String.prototype.toString),f=w(String.prototype.match),g=w(String.prototype.replace),v=w(String.prototype.indexOf),y=w(String.prototype.trim),_=w(Object.prototype.hasOwnProperty),b=w(RegExp.prototype.test),x=S(TypeError);function w(e){return function(t){for(var n=arguments.length,i=new Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];return l(e,t,i)}}function S(e){return function(){for(var t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];return c(e,n)}}function E(e,i){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:p;t&&t(e,null);let o=i.length;for(;o--;){let t=i[o];if("string"==typeof t){const e=r(t);e!==t&&(n(i)||(i[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 T(t){const n=s(null);for(const[i,r]of e(t))_(t,i)&&(Array.isArray(r)?n[i]=A(r):r&&"object"==typeof r&&r.constructor===Object?n[i]=T(r):n[i]=r);return n}function I(e,t){for(;null!==e;){const n=r(e,t);if(n){if(n.get)return w(n.get);if("function"==typeof n.value)return w(n.value)}e=i(e)}function n(){return null}return n}const M=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"]),C=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"]),N=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"]),O=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"]),R=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"]),L=o(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),P=o(["#text"]),D=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"]),F=o(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),U=a(/\{\{[\w\W]*|[\w\W]*\}\}/gm),z=a(/<%[\w\W]*|[\w\W]*%>/gm),G=a(/\${[\w\W]*}/gm),j=a(/^data-[\-\w.\u00B7-\uFFFF]/),H=a(/^aria-[\-\w]+$/),V=a(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),W=a(/^(?:\w+script|data):/i),q=a(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),$=a(/^html$/i),Y=a(/^[a-z][.\w]*(-[.\w]+)+$/i);var J=Object.freeze({__proto__:null,ARIA_ATTR:H,ATTR_WHITESPACE:q,CUSTOM_ELEMENT:Y,DATA_ATTR:j,DOCTYPE_NAME:$,ERB_EXPR:z,IS_ALLOWED_URI:V,IS_SCRIPT_OR_DATA:W,MUSTACHE_EXPR:U,TMPLIT_EXPR:G});const Z={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,progressingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},X=function(){return"undefined"==typeof window?null:window},K=function(e,t){if("object"!=typeof e||"function"!=typeof e.createPolicy)return null;let n=null;const i="data-tt-policy-suffix";t&&t.hasAttribute(i)&&(n=t.getAttribute(i));const r="dompurify"+(n?"#"+n:"");try{return e.createPolicy(r,{createHTML:e=>e,createScriptURL:e=>e})}catch(e){return console.warn("TrustedTypes policy "+r+" could not be created."),null}};function Q(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:X();const n=e=>Q(e);if(n.version="3.2.1",n.removed=[],!t||!t.document||t.document.nodeType!==Z.document)return n.isSupported=!1,n;let{document:i}=t;const r=i,a=r.currentScript,{DocumentFragment:l,HTMLTemplateElement:c,Node:w,Element:S,NodeFilter:A,NamedNodeMap:U=t.NamedNodeMap||t.MozNamedAttrMap,HTMLFormElement:z,DOMParser:G,trustedTypes:j}=t,H=S.prototype,W=I(H,"cloneNode"),q=I(H,"remove"),Y=I(H,"nextSibling"),ee=I(H,"childNodes"),te=I(H,"parentNode");if("function"==typeof c){const e=i.createElement("template");e.content&&e.content.ownerDocument&&(i=e.content.ownerDocument)}let ne,ie="";const{implementation:re,createNodeIterator:oe,createDocumentFragment:ae,getElementsByTagName:se}=i,{importNode:le}=r;let ce={};n.isSupported="function"==typeof e&&"function"==typeof te&&re&&void 0!==re.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}=J;let{IS_ALLOWED_URI:ye}=J,_e=null;const be=E({},[...M,...C,...N,...R,...P]);let xe=null;const we=E({},[...D,...k,...B,...F]);let Se=Object.seal(s(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}})),Ee=null,Ae=null,Te=!0,Ie=!0,Me=!1,Ce=!0,Ne=!1,Oe=!0,Re=!1,Le=!1,Pe=!1,De=!1,ke=!1,Be=!1,Fe=!0,Ue=!1;const ze="user-content-";let Ge=!0,je=!1,He={},Ve=null;const We=E({},["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 $e=E({},["audio","video","img","source","image","track"]);let Ye=null;const Je=E({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Ze="http://www.w3.org/1998/Math/MathML",Xe="http://www.w3.org/2000/svg",Ke="http://www.w3.org/1999/xhtml";let Qe=Ke,et=!1,tt=null;const nt=E({},[Ze,Xe,Ke],m);let it=E({},["mi","mo","mn","ms","mtext"]),rt=E({},["annotation-xml"]);const ot=E({},["title","style","font","a","script"]);let at=null;const st=["application/xhtml+xml","text/html"],lt="text/html";let ct=null,ut=null;const dt=i.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=T(e),at=-1===st.indexOf(e.PARSER_MEDIA_TYPE)?lt:e.PARSER_MEDIA_TYPE,ct="application/xhtml+xml"===at?m:p,_e=_(e,"ALLOWED_TAGS")?E({},e.ALLOWED_TAGS,ct):be,xe=_(e,"ALLOWED_ATTR")?E({},e.ALLOWED_ATTR,ct):we,tt=_(e,"ALLOWED_NAMESPACES")?E({},e.ALLOWED_NAMESPACES,m):nt,Ye=_(e,"ADD_URI_SAFE_ATTR")?E(T(Je),e.ADD_URI_SAFE_ATTR,ct):Je,qe=_(e,"ADD_DATA_URI_TAGS")?E(T($e),e.ADD_DATA_URI_TAGS,ct):$e,Ve=_(e,"FORBID_CONTENTS")?E({},e.FORBID_CONTENTS,ct):We,Ee=_(e,"FORBID_TAGS")?E({},e.FORBID_TAGS,ct):{},Ae=_(e,"FORBID_ATTR")?E({},e.FORBID_ATTR,ct):{},He=!!_(e,"USE_PROFILES")&&e.USE_PROFILES,Te=!1!==e.ALLOW_ARIA_ATTR,Ie=!1!==e.ALLOW_DATA_ATTR,Me=e.ALLOW_UNKNOWN_PROTOCOLS||!1,Ce=!1!==e.ALLOW_SELF_CLOSE_IN_ATTR,Ne=e.SAFE_FOR_TEMPLATES||!1,Oe=!1!==e.SAFE_FOR_XML,Re=e.WHOLE_DOCUMENT||!1,De=e.RETURN_DOM||!1,ke=e.RETURN_DOM_FRAGMENT||!1,Be=e.RETURN_TRUSTED_TYPE||!1,Pe=e.FORCE_BODY||!1,Fe=!1!==e.SANITIZE_DOM,Ue=e.SANITIZE_NAMED_PROPS||!1,Ge=!1!==e.KEEP_CONTENT,je=e.IN_PLACE||!1,ye=e.ALLOWED_URI_REGEXP||V,Qe=e.NAMESPACE||Ke,it=e.MATHML_TEXT_INTEGRATION_POINTS||it,rt=e.HTML_INTEGRATION_POINTS||rt,Se=e.CUSTOM_ELEMENT_HANDLING||{},e.CUSTOM_ELEMENT_HANDLING&&ht(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(Se.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&&ht(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(Se.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(Se.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Ne&&(Ie=!1),ke&&(De=!0),He&&(_e=E({},P),xe=[],!0===He.html&&(E(_e,M),E(xe,D)),!0===He.svg&&(E(_e,C),E(xe,k),E(xe,F)),!0===He.svgFilters&&(E(_e,N),E(xe,k),E(xe,F)),!0===He.mathMl&&(E(_e,R),E(xe,B),E(xe,F))),e.ADD_TAGS&&(_e===be&&(_e=T(_e)),E(_e,e.ADD_TAGS,ct)),e.ADD_ATTR&&(xe===we&&(xe=T(xe)),E(xe,e.ADD_ATTR,ct)),e.ADD_URI_SAFE_ATTR&&E(Ye,e.ADD_URI_SAFE_ATTR,ct),e.FORBID_CONTENTS&&(Ve===We&&(Ve=T(Ve)),E(Ve,e.FORBID_CONTENTS,ct)),Ge&&(_e["#text"]=!0),Re&&E(_e,["html","head","body"]),_e.table&&(E(_e,["tbody"]),delete Ee.tbody),e.TRUSTED_TYPES_POLICY){if("function"!=typeof e.TRUSTED_TYPES_POLICY.createHTML)throw x('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof e.TRUSTED_TYPES_POLICY.createScriptURL)throw x('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');ne=e.TRUSTED_TYPES_POLICY,ie=ne.createHTML("")}else void 0===ne&&(ne=K(j,a)),null!==ne&&"string"==typeof ie&&(ie=ne.createHTML(""));o&&o(e),ut=e}},mt=E({},[...C,...N,...O]),ft=E({},[...R,...L]),gt=function(e){let t=te(e);t&&t.tagName||(t={namespaceURI:Qe,tagName:"template"});const n=p(e.tagName),i=p(t.tagName);return!!tt[e.namespaceURI]&&(e.namespaceURI===Xe?t.namespaceURI===Ke?"svg"===n:t.namespaceURI===Ze?"svg"===n&&("annotation-xml"===i||it[i]):Boolean(mt[n]):e.namespaceURI===Ze?t.namespaceURI===Ke?"math"===n:t.namespaceURI===Xe?"math"===n&&rt[i]:Boolean(ft[n]):e.namespaceURI===Ke?!(t.namespaceURI===Xe&&!rt[i])&&!(t.namespaceURI===Ze&&!it[i])&&!ft[n]&&(ot[n]||!mt[n]):!("application/xhtml+xml"!==at||!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&&!xe[e])if(De||ke)try{vt(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}},_t=function(e){let t=null,n=null;if(Pe)e="<remove></remove>"+e;else{const t=f(e,/^[\r\n\t ]+/);n=t&&t[0]}"application/xhtml+xml"===at&&Qe===Ke&&(e='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+e+"</body></html>");const r=ne?ne.createHTML(e):e;if(Qe===Ke)try{t=(new G).parseFromString(r,at)}catch(e){}if(!t||!t.documentElement){t=re.createDocument(Qe,"template",null);try{t.documentElement.innerHTML=et?ie:r}catch(e){}}const o=t.body||t.documentElement;return e&&n&&o.insertBefore(i.createTextNode(n),o.childNodes[0]||null),Qe===Ke?se.call(t,Re?"html":"body")[0]:Re?t.documentElement:o},bt=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)},xt=function(e){return e instanceof z&&("string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||!(e.attributes instanceof U)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore||"function"!=typeof e.hasChildNodes)},wt=function(e){return"function"==typeof w&&e instanceof w};function St(e,t,i){ce[e]&&u(ce[e],(e=>{e.call(n,t,i,ut)}))}const Et=function(e){let t=null;if(St("beforeSanitizeElements",e,null),xt(e))return vt(e),!0;const i=ct(e.nodeName);if(St("uponSanitizeElement",e,{tagName:i,allowedTags:_e}),e.hasChildNodes()&&!wt(e.firstElementChild)&&b(/<[/\w]/g,e.innerHTML)&&b(/<[/\w]/g,e.textContent))return vt(e),!0;if(e.nodeType===Z.progressingInstruction)return vt(e),!0;if(Oe&&e.nodeType===Z.comment&&b(/<[/\w]/g,e.data))return vt(e),!0;if(!_e[i]||Ee[i]){if(!Ee[i]&&Tt(i)){if(Se.tagNameCheck instanceof RegExp&&b(Se.tagNameCheck,i))return!1;if(Se.tagNameCheck instanceof Function&&Se.tagNameCheck(i))return!1}if(Ge&&!Ve[i]){const t=te(e)||e.parentNode,n=ee(e)||e.childNodes;if(n&&t)for(let i=n.length-1;i>=0;--i){const r=W(n[i],!0);r.__removalCount=(e.__removalCount||0)+1,t.insertBefore(r,Y(e))}}return vt(e),!0}return e instanceof S&&!gt(e)?(vt(e),!0):"noscript"!==i&&"noembed"!==i&&"noframes"!==i||!b(/<\/no(script|embed|frames)/i,e.innerHTML)?(Ne&&e.nodeType===Z.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)),St("afterSanitizeElements",e,null),!1):(vt(e),!0)},At=function(e,t,n){if(Fe&&("id"===t||"name"===t)&&(n in i||n in dt))return!1;if(Ie&&!Ae[t]&&b(pe,t));else if(Te&&b(me,t));else if(!xe[t]||Ae[t]){if(!(Tt(e)&&(Se.tagNameCheck instanceof RegExp&&b(Se.tagNameCheck,e)||Se.tagNameCheck instanceof Function&&Se.tagNameCheck(e))&&(Se.attributeNameCheck instanceof RegExp&&b(Se.attributeNameCheck,t)||Se.attributeNameCheck instanceof Function&&Se.attributeNameCheck(t))||"is"===t&&Se.allowCustomizedBuiltInElements&&(Se.tagNameCheck instanceof RegExp&&b(Se.tagNameCheck,n)||Se.tagNameCheck instanceof Function&&Se.tagNameCheck(n))))return!1}else if(Ye[t]);else if(b(ye,g(n,ge,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==v(n,"data:")||!qe[e])if(Me&&!b(fe,g(n,ge,"")));else if(n)return!1;return!0},Tt=function(e){return"annotation-xml"!==e&&f(e,ve)},It=function(e){St("beforeSanitizeAttributes",e,null);const{attributes:t}=e;if(!t)return;const i={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:xe,forceKeepAttr:void 0};let r=t.length;for(;r--;){const o=t[r],{name:a,namespaceURI:s,value:l}=o,c=ct(a);let h="value"===a?l:y(l);if(i.attrName=c,i.attrValue=h,i.keepAttr=!0,i.forceKeepAttr=void 0,St("uponSanitizeAttribute",e,i),h=i.attrValue,!Ue||"id"!==c&&"name"!==c||(yt(a,e),h=ze+h),Oe&&b(/((--!?|])>)|<\/(style|title)/i,h)){yt(a,e);continue}if(i.forceKeepAttr)continue;if(yt(a,e),!i.keepAttr)continue;if(!Ce&&b(/\/>/i,h)){yt(a,e);continue}Ne&&u([ue,de,he],(e=>{h=g(h,e," ")}));const p=ct(e.nodeName);if(At(p,c,h)){if(ne&&"object"==typeof j&&"function"==typeof j.getAttributeType)if(s);else switch(j.getAttributeType(p,c)){case"TrustedHTML":h=ne.createHTML(h);break;case"TrustedScriptURL":h=ne.createScriptURL(h)}try{s?e.setAttributeNS(s,a,h):e.setAttribute(a,h),xt(e)?vt(e):d(n.removed)}catch(e){}}}St("afterSanitizeAttributes",e,null)},Mt=function e(t){let n=null;const i=bt(t);for(St("beforeSanitizeShadowDOM",t,null);n=i.nextNode();)St("uponSanitizeShadowNode",n,null),Et(n)||(n.content instanceof l&&e(n.content),It(n));St("afterSanitizeShadowDOM",t,null)};return n.sanitize=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=null,o=null,a=null,s=null;if(et=!e,et&&(e="\x3c!--\x3e"),"string"!=typeof e&&!wt(e)){if("function"!=typeof e.toString)throw x("toString is not a function");if("string"!=typeof(e=e.toString()))throw x("dirty is not a string, aborting")}if(!n.isSupported)return e;if(Le||pt(t),n.removed=[],"string"==typeof e&&(je=!1),je){if(e.nodeName){const t=ct(e.nodeName);if(!_e[t]||Ee[t])throw x("root node is forbidden and cannot be sanitized in-place")}}else if(e instanceof w)i=_t("\x3c!----\x3e"),o=i.ownerDocument.importNode(e,!0),o.nodeType===Z.element&&"BODY"===o.nodeName||"HTML"===o.nodeName?i=o:i.appendChild(o);else{if(!De&&!Ne&&!Re&&-1===e.indexOf("<"))return ne&&Be?ne.createHTML(e):e;if(i=_t(e),!i)return De?null:Be?ie:""}i&&Pe&&vt(i.firstChild);const c=bt(je?e:i);for(;a=c.nextNode();)Et(a)||(a.content instanceof l&&Mt(a.content),It(a));if(je)return e;if(De){if(ke)for(s=ae.call(i.ownerDocument);i.firstChild;)s.appendChild(i.firstChild);else s=i;return(xe.shadowroot||xe.shadowrootmode)&&(s=le.call(r,s,!0)),s}let d=Re?i.outerHTML:i.innerHTML;return Re&&_e["!doctype"]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&b($,i.ownerDocument.doctype.name)&&(d="<!DOCTYPE "+i.ownerDocument.doctype.name+">\n"+d),Ne&&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]:{}),Le=!0},n.clearConfig=function(){ut=null,Le=!1},n.isValidAttribute=function(e,t,n){ut||pt({});const i=ct(e),r=ct(t);return At(i,r,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 Q()}();var NI=o("1Lq0j"),OI={};OI=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]/,i=/[ \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/;function r(r){const o={};r=r||{},o.src_Any=e.source,o.src_Cc=t.source,o.src_Z=i.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 a="[><|]";return o.src_pseudo_letter="(?:(?!"+a+"|"+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="(?=$|"+a+"|"+o.src_ZPCc+")(?!"+(r["---"]?"-(?!--)|":"-|")+"_|:\\d|\\.-|\\.(?!$|"+o.src_ZPCc+"))",o.src_path="(?:[/?#](?:(?!"+o.src_ZCc+"|"+a+"|[()[\\]{}.,\"'?!\\-;]).|\\[(?:(?!"+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+"|[.]|$)|"+(r["---"]?"\\-(?!--(?:[^-]|$))(?:-*)|":"\\-+|")+",(?!"+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="(^|"+a+'|"|\\(|'+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 a(e){return Object.prototype.toString.call(e)}function s(e){return"[object String]"===a(e)}function l(e){return"[object Object]"===a(e)}function c(e){return"[object RegExp]"===a(e)}function u(e){return"[object Function]"===a(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 i=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(i)?i.match(n.re.http)[0].length:0}},"https:":"http:","ftp:":"http:","//":{validate:function(e,t,n){const i=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(i)?t>=3&&":"===e[t-3]||t>=3&&"/"===e[t-3]?0:i.match(n.re.no_http)[0].length:0}},"mailto:":{validate:function(e,t,n){const i=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(i)?i.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 i=t.slice(n);return e.test(i)?i.match(e)[0].length:0}}function _(){return function(e,t){t.normalize(e)}}function b(e){const t=e.re=r(e.__opts__),n=e.__tlds__.slice();function i(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(i(t.tpl_email_fuzzy),"i"),t.link_fuzzy=RegExp(i(t.tpl_link_fuzzy),"i"),t.link_no_ip_fuzzy=RegExp(i(t.tpl_link_no_ip_fuzzy),"i"),t.host_fuzzy_test=RegExp(i(t.tpl_host_fuzzy_test),"i");const o=[];function a(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 i={validate:null,link:null};if(e.__compiled__[t]=i,l(n))return c(n.validate)?i.validate=y(n.validate):u(n.validate)?i.validate=n.validate:a(t,n),void(u(n.normalize)?i.normalize=n.normalize:n.normalize?a(t,n):i.normalize=_());s(n)?o.push(t):a(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 x(e,t){const n=e.__index__,i=e.__last_index__,r=e.__text_cache__.slice(n,i);this.schema=e.__schema__.toLowerCase(),this.index=n+t,this.lastIndex=i+t,this.raw=r,this.text=r,this.url=r}function w(e,t){const n=new x(e,t);return e.__compiled__[n.schema].normalize(n,e),n}function S(e,t){if(!(this instanceof S))return new S(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={},b(this)}function E(e={},t={}){const n=new S(e,t);return T(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 i;return 0===t.index?i=t.raw:1===t.index&&"<"===e.charAt(0)&&">"===e.charAt(t.lastIndex)&&(i=`<${t.raw}>`),i?{type:"link",raw:i,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 T(e,t){const n=t.tlds;delete t.tlds;const i=t.tldsKeepOld;delete t.tldsKeepOld,n&&e.tlds(n,i)}return S.prototype.add=function(e,t){return this.__schemas__[e]=t,b(this),this},S.prototype.set=function(e){return this.__opts__=o(this.__opts__,e),this},S.prototype.test=function(e){if(this.__text_cache__=e,this.__index__=-1,!e.length)return!1;let t,n,i,r,o,a,s,l,c;if(this.re.schema_test.test(e))for(s=this.re.schema_search,s.lastIndex=0;null!==(t=s.exec(e));)if(r=this.testSchemaAt(e,t[2],s.lastIndex),r){this.__schema__=t[2],this.__index__=t.index+t[1].length,this.__last_index__=t.index+t[0].length+r;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!==(i=e.match(this.re.email_fuzzy))&&(o=i.index+i[1].length,a=i.index+i[0].length,(this.__index__<0||o<this.__index__||o===this.__index__&&a>this.__last_index__)&&(this.__schema__="mailto:",this.__index__=o,this.__last_index__=a))),this.__index__>=0},S.prototype.pretest=function(e){return this.re.pretest.test(e)},S.prototype.testSchemaAt=function(e,t,n){return this.__compiled__[t.toLowerCase()]?this.__compiled__[t.toLowerCase()].validate(e,n,this):0},S.prototype.match=function(e){const t=[];let n=0;this.__index__>=0&&this.__text_cache__===e&&(t.push(w(this,n)),n=this.__last_index__);let i=n?e.slice(n):e;for(;this.test(i);)t.push(w(this,n)),i=i.slice(this.__last_index__),n+=this.__last_index__;return t.length?t:null},S.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,w(this,0)):null},S.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(),b(this),this):(this.__tlds__=e.slice(),this.__tlds_replaced__=!0,b(this),this)},S.prototype.normalize=function(e){e.schema||(e.url="http://"+e.url),"mailto:"!==e.schema||/^mailto:/i.test(e.url)||(e.url="mailto:"+e.url)},S.prototype.onCompile=function(){},E}();var RI={};RI=function(e){"use strict";const t=/^(\${1,2})(?!\$)((?:\\.|[^\\\n])*?(?:\\.|[^\\\n\$]))\1(?=[\s?!\.,:?!。,:]|$)/,n=/^(\${1,2})(?!\$)((?:\\.|[^\\\n])*?(?:\\.|[^\\\n\$]))\1/,i=/^(\${1,2})\n((?:\\[^]|[^\\])+?)\n\1(?:\n|$)/;function r(e={}){return{extensions:[a(e,o(e,!1)),s(e,o(e,!0))]}}function o(t,n){return i=>e.renderToString(i.text,{...t,displayMode:i.displayMode})+(n?"\n":"")}function a(e,i){const r=e&&e.nonStandard,o=r?n:t;return{name:"inlineKatex",level:"inline",start(e){let t,n=e;for(;n;){if(t=n.indexOf("$"),-1===t)return;if((r?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:i}}function s(e,t){return{name:"blockKatex",level:"block",tokenizer(e,t){const n=e.match(i);if(n)return{type:"blockKatex",raw:n[0],text:n[2].trim(),displayMode:2===n[1].length}},renderer:t}}return r}(o("kqAxc"));const LI=(e,t,n,i)=>{if(!t.rowspan)return"";return`${`<${n}`+(t.colspan>1?` colspan=${t.colspan}`:"")+(t.rowspan>1?` rowspan=${t.rowspan}`:"")+(i?` align=${i}`:"")+">"+e}</${n}>\n`},PI=(e,t,n=[])=>{var i,r,o;const a=[...e.matchAll(/(?:[^|\\]|\\.?)+(?:\|+|$)/g)].map((e=>e[0]));(null===(i=a[0])||void 0===i?void 0:i.trim())||a.shift(),(null===(r=a[a.length-1])||void 0===r?void 0:r.trim())||a.pop();let s,l,c,u,d,h=0;for(s=0;s<a.length;s++){if(c=a[s].split(/\|+$/)[0],a[s]={rowspan:1,colspan:Math.max(a[s].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===a[s].colspan){a[s].rowSpanTarget=null!==(o=u.rowSpanTarget)&&void 0!==o?o:u,a[s].rowSpanTarget.text+=` ${a[s].text.slice(0,-1)}`,a[s].rowSpanTarget.rowspan+=1,a[s].rowspan=0;break}if(d+=u.colspan,d>h)break}h+=a[s].colspan}if(h>t)a.splice(t);else for(;h<t;)a.push({colspan:1,text:""}),h+=1;return a};MI.marked.use({async:!1,gfm:!0,pedantic:!1,renderer:{link:({href:e,title:t,text:n})=>{const i=e?zE(e):null;if(null===i)return n;let r='<a href="'+(e=i)+'"';return t&&(r+=' title="'+t+'"'),r+=' target="_blank" rel="noopener noreferrer">'+n+"</a>",r}}}),MI.marked.use(t(OI)()),MI.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]=PI(e.header[0]);const t=e.header[0].reduce(((e,t)=>e+t.colspan),0);if(t===e.align.length){let i,r,o,a;e.raw=n[0];let s=e.align.length;for(i=0;i<s;i++)/^ *-+: *$/.test(e.align[i])?e.align[i]="right":/^ *:-+: *$/.test(e.align[i])?e.align[i]="center":/^ *:-+ *$/.test(e.align[i])?e.align[i]="left":e.align[i]=null;for(s=e.header.length,i=1;i<s;i++)e.header[i]=PI(e.header[i],t,e.header[i-1]);for(s=e.rows.length,i=0;i<s;i++)e.rows[i]=PI(e.rows[i],t,e.rows[i-1]);for(s=e.header.length,r=0;r<s;r++)for(a=e.header[r],o=0;o<a.length;o++)a[o].tokens=[],this.lexer.inline(a[o].text,a[o].tokens);for(s=e.rows.length,r=0;r<s;r++)for(a=e.rows[r],o=0;o<a.length;o++)a[o].tokens=[],this.lexer.inline(a[o].text,a[o].tokens);return e}}},renderer(e){let t,n,i,r,o,a,s='<div class="memori--responsive-table-wrapper"><table class="memori--table memori--table--compact">';for(s+="<thead>",t=0;t<e.header.length;t++){i=e.header[t];let o=0;for(s+="<tr>",n=0;n<i.length;n++)r=i[n],a=this.parser.parseInline(r.tokens),s+=LI(a,r,"th",e.align[o]),o+=r.colspan;s+="</tr>"}if(s+="</thead>",e.rows.length){for(s+="<tbody>",t=0;t<e.rows.length;t++){for(i=e.rows[t],o=0,s+="<tr>",n=0;n<i.length;n++)r=i[n],a=this.parser.parseInline(r.tokens),s+=LI(a,r,"td",e.align[o]),o+=r.colspan;s+="</tr>"}s+="</tbody>"}return s+="</table></div>",s}}]});const DI=e=>{let t=e;return e.length>NI.MAX_MSG_CHARS&&(t=`${e.slice(0,NI.MAX_MSG_CHARS)}\n<br />...`),t.split(" ").length>NI.MAX_MSG_WORDS&&(t=t.split(" ").slice(0,NI.MAX_MSG_WORDS).join(" ")),t},kI=(e,n=!1,i="Reasoning...",r)=>{try{let o=e.trim().replaceAll(/\[([^\]]+)\]\(([^\)]+)\)/g,'<a href="$2" target="_blank" rel="noopener noreferrer">$1</a>').replaceAll(/<think.*?>(.*?)<\/think>/gs,r?`<details class="memori-think"><summary>${i}</summary>$1</details>`:"").replaceAll(/<document_attachment filename="([^"]+)" type="([^"]+)">([\s\S]*?)<\/document_attachment>/g,"").replaceAll(/<output\s+class\s*=\s*["\']memori-artifact["\'][^>]*data-mimetype\s*=\s*["\']([^"']+)["\'][^>]*>([\s\S]*?)(?:<\/output>|$)/gi,"").replaceAll(/```markdown([^```]+)```/g,"$1").replaceAll("($","( $").replaceAll(":$",": $").replaceAll("\frac","\\frac").replaceAll("\beta","\\beta").replaceAll("cdot","\\cdot");n&&(MI.marked.use(t(RI)({})),o=o.replace(/\\+\[(.*?)\\*\]/gs,((e,t)=>`$$${t}$$`)),o=o.replace(/\[([^[\]]+?)\]/g,((e,t)=>!/[\\+a-z0-9_{}^=\-\+\*\/]+/i.test(t)||e.startsWith("[http")||e.includes("](")?e:`$$${t}$$`)));const a=[];let s=0;o=o.replace(/(<output[^>]*>)([\s\S]*?)(<\/output>)/g,((e,t,n,i)=>{const r=`\x3c!--OUTPUT_PLACEHOLDER_${s++}--\x3e`;return a.push(`${t}${n}${i}`),r})),o=o.replace(/(<!--OUTPUT_PLACEHOLDER_\d+-->)\s*([^\s<\n-])/g,"$1\n\n$2");let l=MI.marked.parse(o).toString().trim();a.forEach(((e,t)=>{l=l.replace(`\x3c!--OUTPUT_PLACEHOLDER_${t}--\x3e`,e)})),l=t(CI).sanitize(l,{ADD_ATTR:["target"]});return{text:l.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}}};NI=o("1Lq0j");var BI=({rows:e,className:n,innerClassName:i,btnClassName:r,lineHeightMultiplier:o=1.2,defaultExpanded:s=!1,expandSymbol:l=(()=>"..."),collapseSymbol:u=(e=>"it"===e?"Mostra meno":"Show less"),children:d,mode:h="rows"})=>{const{i18n:p}=Ve(),m=p.language,f=u(m),g=l(m),[v,y]=(0,c.useState)(s),[_,b]=(0,c.useState)(!1),[x,w]=(0,c.useState)(16),S=(0,c.useRef)(null);(0,c.useEffect)((()=>{if(S.current)if("rows"===h){let t=S.current.getBoundingClientRect().height,n=getComputedStyle(S.current),i=n.lineHeight,r="normal"!==i&&(null==i?void 0:i.length)?parseInt(i,10):o*parseInt(n.fontSize,10);w(r),t&&e&&t>e*r&&b(!0)}else if("characters"===h){const e=S.current.textContent||"";(e.length>NI.MAX_MSG_CHARS||e.split(" ").length>NI.MAX_MSG_WORDS)&&b(!0)}}),[e,h,S.current]);return(0,a.jsxs)("div",{className:t(We)("memori-expandable",n),children:[(0,a.jsx)("div",{ref:S,className:t(We)("memori-expandable--inner",i),style:{maxHeight:v||!_||"characters"===h?"9999px":x*(e||1)+"px"},children:(()=>{var e;if("characters"===h&&!v&&_){const t=(null===(e=S.current)||void 0===e?void 0:e.textContent)||"";return DI(t)}return d})()}),_&&!v&&(0,a.jsx)(Jl,{ghost:!0,padded:!1,className:r,onClick:()=>y(!0),children:g}),_&&v&&(0,a.jsx)(Jl,{ghost:!0,padded:!1,className:r,onClick:()=>y(!1),children:f})]})};const FI=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,SESSION_OTP_NOT_FOUND:-107,SESSION_OTP_EXPIRED:-108,SESSION_MISSING_TEMPORARY_TOKEN:-109,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]))),UI=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=FI.get(e);return t?`errors.${t}`:"error.generic"};c=o("85Hg2"),NI=o("1Lq0j");var zI=({medium:e,className:n,preview:i=!1,showCopyButton:r=!0})=>{var o,s,l,u,d,h,p,m,f;const{t:g}=Ve(),v=()=>{"Prism"in window&&window.Prism.highlightAll&&setTimeout((()=>{Prism.highlightAll()}),100)};return(0,c.useEffect)((()=>{new Promise((e=>{if(document.getElementById("memori-prism-script"))return void e();const t=document.createElement("script");t.src="https://cdn.jsdelivr.net/npm/prismjs@1.29.0/prism.min.js",t.async=!0,t.id="memori-prism-script",t.onload=()=>{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",t.onload=()=>{window.Prism&&window.Prism.plugins&&window.Prism.plugins.autoloader&&(window.Prism.plugins.autoloader.languages_path="https://cdn.jsdelivr.net/npm/prismjs@1.29.0/components/"),e()},document.head.appendChild(t)};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(t)})).then((()=>{v()}))}),[]),(0,c.useEffect)((()=>{v()}),[e.content,e.mimeType]),(0,a.jsxs)("div",{className:"memori-snippet",children:[(0,a.jsxs)("div",{className:"memori-snippet--content",children:[(0,a.jsx)("pre",{className:t(We)("line-numbers",n),"aria-labelledby":(null===(o=e.title)||void 0===o?void 0:o.length)?`#snippet-${e.mediumID}`:void 0,children:(0,a.jsx)("code",{className:`language-${null!==(l=null===(s=NI.prismSyntaxLangs.find((t=>e.mimeType===t.mimeType)))||void 0===s?void 0:s.lang)&&void 0!==l?l:"text"}`,"data-language":null!==(d=null===(u=NI.prismSyntaxLangs.find((t=>e.mimeType===t.mimeType)))||void 0===u?void 0:u.lang)&&void 0!==d?d:"text",children:(null===(h=e.content)||void 0===h?void 0:h.length)&&e.content.length>200&&i?`${null===(p=DE(e.content))||void 0===p?void 0:p.slice(0,200)}\n...`:DE(null!==(m=e.content)&&void 0!==m?m:"")})}),r&&(0,a.jsx)(Jl,{padded:!1,ghost:!0,className:"memori-snippet--copy-button",title:g("copy")||"Copy",icon:(0,a.jsx)(AI,{}),onClick:()=>{var t;return navigator.clipboard.writeText(null!==(t=e.content)&&void 0!==t?t:"")}})]}),!!(null===(f=e.title)||void 0===f?void 0:f.length)&&(0,a.jsx)("p",{id:`snippet-${e.mediumID}`,className:"memori-snippet--caption",children:e.title})]})};c=o("85Hg2"),c=o("85Hg2");var GI,jI=({className:e,title:t})=>(0,a.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,a.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"})}),HI={};GI=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 i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e};function n(e,n){var i=e.el,r=e.elStyle,o=e.elHeight,a=e.rowsLimit,s=e.rowsWrapped,l=e.options,c=e.buffer,u=c;if(s===a+1)return t({},e);var d=c,h=s,p=o;return i.innerHTML=u=c.length?""+c+l.delimiter+n+l.replaceStr:""+n+l.replaceStr,parseFloat(r.height)>parseFloat(o)&&(h++,p=r.height,h===a+1)?(i.innerHTML=u="."===d[d.length-1]&&"..."===l.replaceStr?d+"..":""+d+l.replaceStr,t({},e,{elHeight:p,rowsWrapped:h})):(i.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 i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a={replaceStr:"...",responsive:!1,debounceDelay:250,delimiter:" "},s=t({},a,o),l=i&&(i instanceof NodeList?i:1===i.nodeType?[i]:document.querySelectorAll(i)),c=[],u=0;u<l.length;u++){var d=l[u];c[u]=d.innerHTML;var h=d.innerHTML.split(s.delimiter);d.innerHTML="";var p=window.getComputedStyle(d);h.reduce(n,{el:d,buffer:d.innerHTML,elStyle:p,elHeight:0,rowsLimit:r,rowsWrapped:0,options:s})}if(s.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(i,r,t({},o,{responsive:!1}))}},v=function(){clearTimeout(m),m=setTimeout(g,s.debounceDelay)};return window.addEventListener("resize",v),v}}},"function"==typeof define&&define.amd?define(["exports"],GI):GI(HI);var VI=({loading:e=!1,className:n,title:i,description:r,cover:o,hoverable:s=!1,children:l,onClick:c})=>(0,a.jsx)("div",{onClick:c,className:t(We)("memori-card",n,{"memori-card--loading":e,"memori-card--with-cover":o,"memori-card--hoverable":s,"memori-card--pointer":!!c}),children:(0,a.jsxs)(Yl,{spinning:e,children:[o&&(0,a.jsx)("div",{className:"memori-card--cover",children:o}),(0,a.jsxs)("div",{className:"memori-card--content",children:[i&&(0,a.jsx)("h3",{className:"memori-card--title",children:i}),r&&(0,a.jsx)("p",{className:"memori-card--description",children:r}),(0,a.jsx)("div",{className:"memori-card--children",children:l})]})]})});const WI=({isChild:e=!1,item:n,baseUrl:i,onLinkPreviewInfo:r,descriptionOneLine:o=!1})=>{var s,l,u,d;const[h,p]=(0,c.useState)(null),m=(null===(s=n.url)||void 0===s?void 0:s.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,i).then((e=>{p(e?{...e,urlKey:o}:null),r&&e&&r(e)}))}),[null==n?void 0:n.url,i,r]);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,HI.ellipsis)(".memori-link-item--card .memori-card--description",3,{responsive:!0})}),300)}),[g,n.mediumID]),(0,a.jsx)("a",{href:m,target:"_blank",rel:"noopener noreferrer",className:t(We)("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,a.jsx)(VI,{hoverable:!0,className:t(We)("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,a.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,a.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,a.jsx)("div",{className:"memori-link-item--card-cover-icon",children:(0,a.jsx)(jI,{className:"memori-link-item--icon"})}),title:f,description:g})})};var qI=({items:e,baseUrl:n,descriptionOneLine:i=!1,onLinkPreviewInfo:r,fromUser:o=!1})=>(0,a.jsx)(Os,{appear:!0,show:!0,as:"div",className:"memori-link-items",children:(0,a.jsx)("div",{className:t(We)("memori-link-items--grid memori-chat-scroll-item",{"memori-link-items--user":o,"memori-link-items--agent":!o}),children:e.map(((e,t)=>(0,a.jsx)(Os.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,a.jsx)(WI,{item:e,baseUrl:n,descriptionOneLine:i,onLinkPreviewInfo:r})},e.mediumID)))})});c=o("85Hg2");const $I=["va bene","no grazie","si","no","sì","arrivederci","non c'entrava","non mi è piaciuto"],YI=async(e,t,n,i)=>{var r,o,a,s;let l=(e=>e.replaceAll(/<output.*?>(.*?)<\/output>/g,""))((e=>e.replaceAll(/<think.*?>(.*?)<\/think>/gs,""))(e));const c=e.match(/<think.*?>(.*?)<\/think>/gs),u=$I.indexOf(e.toLowerCase())>-1?"IT":null==n?void 0:n.toUpperCase(),d=t.toUpperCase(),h=await fetch(`${i||"https://www.aisuru.com"}/api/translate`,{cache:"no-cache",method:"POST",body:JSON.stringify({text:l,target_lang:d,source_lang:u}),headers:{Accept:"*/*","Content-Type":"application/json"}}),p=await h.json();return p&&p.translations&&p.translations[0]&&(p.translations[0].text=(c?`<think>${c}</think>`:"")+(null===(o=null===(r=null==p?void 0:p.translations)||void 0===r?void 0:r[0])||void 0===o?void 0:o.text)),null!==(s=null===(a=null==p?void 0:p.translations)||void 0===a?void 0:a[0])&&void 0!==s?s:{text:l}};NI=o("1Lq0j"),c=o("85Hg2");var JI=({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,a.jsx)("div",{className:"model-viewer",children:(0,a.jsx)("model-viewer",{src:e,"ios-src":"",poster:t,alt:n,"shadow-intensity":"1","disable-zoom":!0,"camera-controls":!0,autoplay:!0})}));var ZI=({className:e,title:t})=>(0,a.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,a.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 XI=({className:e,title:t})=>(0,a.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,a.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 KI=({className:e,title:t})=>(0,a.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,a.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 QI=({className:e,title:t})=>(0,a.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,a.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 eM=({isChild:e=!1,item:t,sessionID:n,tenantID:i,preview:r=!1,baseURL:o,apiURL:s,onClick:l,customMediaRenderer:u})=>{var d,h;const[p,m]=(0,c.useState)(!1),[f,g]=(0,c.useState)(!1),[v,y]=(0,c.useState)(!1),_=KT({resourceURI:t.url,sessionID:n,tenantID:i,baseURL:o,apiURL:s}),b=null==u?void 0:u(t.mimeType);if(b)return b;const x=NI.prismSyntaxLangs.map((e=>e.mimeType)).includes(t.mimeType),w="text/html"===t.mimeType,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(")),E=e=>{if(!e)return!1;try{return new URL(e),!0}catch(e){return!1}},A=(()=>{var e,n;return E(_)||E(t.url)?_||t.url:(null===(e=t.url)||void 0===e?void 0:e.startsWith("rgb("))||(null===(n=t.url)||void 0===n?void 0:n.startsWith("rgba("))?t.url:t.content?`data:${t.mimeType};base64,${t.content}`:void 0})(),T=e=>{switch(e.mimeType){case"image/jpeg":case"image/png":case"image/jpg":case"image/gif":return S?(0,a.jsxs)("picture",{className:"memori-media-item--figure",children:[(0,a.jsx)("div",{className:"memori-media-item--rgb-item",style:{backgroundColor:e.url}}),e.title&&(0,a.jsx)("figcaption",{className:"memori-media-item--figure-caption",children:e.title})]}):(0,a.jsxs)("picture",{className:"memori-media-item--figure",children:[!r&&A&&(0,a.jsx)("source",{srcSet:A,type:e.mimeType}),(0,a.jsx)("img",{alt:e.title,src:v||!A?"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjAwIiBoZWlnaHQ9IjIwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cmVjdCB3aWR0aD0iMjAwIiBoZWlnaHQ9IjIwMCIgZmlsbD0iI2YwZjBmMCIvPjx0ZXh0IHg9IjUwJSIgeT0iNTAlIiBmb250LWZhbWlseT0iQXJpYWwsIHNhbnMtc2VyaWYiIGZvbnQtc2l6ZT0iMTQiIGZpbGw9IiM5OTk5OTkiIHRleHQtYW5jaG9yPSJtaWRkbGUiIGR5PSIuM2VtIj5JbWFnZSBub3QgYXZhaWxhYmxlPC90ZXh0Pjwvc3ZnPg==":A,onError:()=>y(!0)}),e.title&&(0,a.jsx)("figcaption",{className:"memori-media-item--figure-caption",children:e.title})]});case"application/msword":case"application/vnd.openxmlformats-officedocument.wordprocessingml.document":return(0,a.jsx)(QI,{className:"memori-media-item--icon"});case"application/vnd.ms-excel":case"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":return(0,a.jsx)(KI,{className:"memori-media-item--icon"});case"application/pdf":return(0,a.jsx)(XI,{className:"memori-media-item--icon"});case"video/mp4":case"video/quicktime":case"video/avi":case"video/mpeg":return(0,a.jsxs)("video",{style:{width:"100%",height:"100%"},controls:!0,src:_,title:e.title,children:["video/quicktime"===e.mimeType&&(0,a.jsx)("source",{src:e.url,type:"video/mp4"}),(0,a.jsx)("source",{src:e.url,type:e.mimeType}),"Your browser does not support this video format.",(0,a.jsx)("br",{}),(0,a.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,a.jsx)("audio",{style:{width:"100%",height:"100%"},controls:!0,src:_});case"model/gltf-binary":return(0,a.jsx)(JI,{src:_,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,a.jsx)(ZI,{className:"memori-media-item--icon"})}};if(x&&t.content||w)return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("a",{className:"memori-media-item--link",href:"#",onClick:e=>{e.preventDefault(),m(!0)},title:t.title,children:(0,a.jsx)(VI,{hoverable:!0,cover:T(t),title:t.title})}),(0,a.jsx)(CA,{open:p,onClose:()=>m(!1),title:t.title,className:"memori-media-item-preview--modal",width:"80%",widthMd:"90%",children:(0,a.jsx)("div",{className:"memori-media-item-preview--content",children:(0,a.jsx)(zI,{medium:t,showCopyButton:!0})})})]});if(!t.url&&"document"===(null==t?void 0:t.type)&&t.content&&!["image/jpeg","image/png","image/jpg","image/gif"].includes(t.mimeType))return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("a",{className:"memori-media-item--link",href:"#",onClick:e=>{e.preventDefault(),m(!0)},title:t.title,children:(0,a.jsx)(VI,{hoverable:!0,cover:T(t),title:t.title})}),(0,a.jsx)(CA,{open:p,onClose:()=>m(!1),title:t.title,className:"memori-media-item-preview--modal",width:"60%",widthMd:"70%",footer:(0,a.jsx)("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem"},children:(0,a.jsx)(Jl,{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,a.jsx)(AI,{}),children:f?"Copied!":"Copy Content"})}),children:(0,a.jsx)("div",{className:"memori-media-item-preview--content",children:(0,a.jsx)("div",{className:"memori-media-item-preview--text",dangerouslySetInnerHTML:{__html:FE(t.content||"")}})})})]});switch(t.mimeType){case"image/jpeg":case"image/png":case"image/jpg":case"image/gif":return S?(0,a.jsx)(VI,{hoverable:!0,className:"memori-media-item--card memori-media-item--image",cover:T(t)}):(0,a.jsx)("a",{className:"memori-media-item--link",href:A||"#",onClick:n=>{e&&n.preventDefault(),l&&(n.preventDefault(),l(t.mediumID)),A&&!v||n.preventDefault()},target:"_blank",rel:"noopener noreferrer",title:t.title,children:(0,a.jsx)(VI,{hoverable:!0,className:"memori-media-item--card memori-media-item--image",cover:T(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,a.jsx)("a",{className:"memori-media-item--link",href:_,target:"_blank",rel:"noopener noreferrer",title:t.title,children:(0,a.jsx)(VI,{hoverable:!0,cover:T(t),title:t.title})});case"video/mp4":case"video/quicktime":case"video/avi":case"video/mpeg":return(0,a.jsx)("a",{className:"memori-media-item--link",href:_,onClick:n=>{e&&n.preventDefault(),l&&(n.preventDefault(),l(t.mediumID))},target:"_blank",rel:"noopener noreferrer",title:t.title,children:(0,a.jsx)(VI,{hoverable:!0,cover:T(t),title:t.title})});case"model/gltf-binary":return(0,a.jsx)(VI,{hoverable:!0,cover:T(t)})}},tM=({item:e,sessionID:t,tenantID:n,baseURL:i,apiURL:r,onClick:o})=>{var s;return((s=e.content)?s.split("\n").length:0)<=5?(0,a.jsx)("div",{className:"memori-media-item--snippet-direct",children:(0,a.jsx)(VI,{className:"memori-media-item--card memori-media-item--snippet",children:(0,a.jsx)("div",{className:"memori-media-item--snippet-preview",children:(0,a.jsx)(zI,{showCopyButton:!0,preview:!1,medium:e})})})}):(0,a.jsx)(a.Fragment,{children:(0,a.jsx)("a",{href:"#",onClick:t=>{t.preventDefault(),o&&o(e.mediumID)},className:"memori-media-item--link",title:e.title,children:(0,a.jsx)(VI,{hoverable:!0,className:"memori-media-item--card memori-media-item--snippet",children:(0,a.jsx)("div",{className:"memori-media-item--snippet-preview",children:(0,a.jsx)(zI,{showCopyButton:!1,preview:!0,medium:e})})})})})};var nM=(0,c.memo)((({items:e,sessionID:n,tenantID:i,translateTo:r,baseURL:o,apiURL:s,customMediaRenderer:l,fromUser:u=!1})=>{const[d,h]=(0,c.useState)(e),[p,m]=(0,c.useState)();(0,c.useEffect)((()=>{h(e)}),[e]);const f=(0,c.useCallback)((async()=>{if(!r)return;const t=await Promise.all((null!=e?e:[]).map((async e=>{var t;if(!e.title)return e;try{const n=await YI(e.title,r);return{...e,title:null!==(t=n.text)&&void 0!==t?t:e.title}}catch(t){return console.error(t),e}})));h(t)}),[r,e]);(0,c.useEffect)((()=>{r&&f()}),[r,f]);const g=d.filter((e=>{var t;return!(null===(t=e.properties)||void 0===t?void 0:t.executable)&&!NI.prismSyntaxLangs.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)&&NI.prismSyntaxLangs.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,a.jsxs)(Os,{appear:!0,show:!0,as:"div",className:"memori-media-items",children:[!!g.length&&(0,a.jsx)("div",{className:t(We)("memori-media-items--grid memori-chat-scroll-item",{"memori-media-items--user":u,"memori-media-items--agent":!u}),children:g.map(((e,t)=>(0,a.jsx)(Os.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,a.jsx)(eM,{isChild:!0,sessionID:n,tenantID:i,baseURL:o,apiURL:s,onClick:e=>{m(g.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.length&&(0,a.jsx)("div",{className:t(We)("memori-media-items--grid memori-chat-scroll-item",{"memori-media-items--user":u,"memori-media-items--agent":!u}),children:v.map(((e,t)=>(0,a.jsx)(Os.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,a.jsx)(tM,{sessionID:n,tenantID:i,baseURL:o,apiURL:s,onClick:e=>{const t=v.find((t=>t.mediumID===e));m(t)},item:{...e,title:e.title,url:e.url,content:e.content,type:"document"}})},e.mediumID+"&index="+t)))}),y.map((e=>(0,a.jsx)("style",{dangerouslySetInnerHTML:{__html:e.content||""}},e.mediumID))),p&&(0,a.jsx)(CA,{width:"100%",widthMd:"100%",className:"memori-media-item--modal",open:!!p,onClose:()=>m(void 0),footer:null,children:NI.prismSyntaxLangs.map((e=>e.mimeType)).includes(p.mimeType)?(0,a.jsx)("div",{style:{minHeight:"100%",background:"none"},className:"memori-media-item-preview--content",children:(0,a.jsx)(zI,{preview:!1,medium:p})}):(0,a.jsx)(eM,{isChild:!0,sessionID:n,tenantID:i,baseURL:o,apiURL:s,item:{...p,title:p.title,url:p.url,content:p.content,type:"document"},customMediaRenderer:l})})]})}));var iM=(0,c.memo)((({hints:e=[],links:n=[],media:i=[],simulateUserPrompt:r=(()=>{}),sessionID:o,baseUrl:s,apiUrl:l,translateTo:u,customMediaRenderer:d,fromUser:h=!1})=>{const{t:p}=Ve(),[m,f]=(0,c.useState)(!0),[g,v]=(0,c.useState)(6);return(0,c.useEffect)((()=>{f(!0)}),[e]),(0,a.jsxs)("div",{className:"memori-media-widget",children:[(null==i?void 0:i.length)>0&&(0,a.jsx)(nM,{items:i,sessionID:o,translateTo:u,baseURL:s,apiURL:l,customMediaRenderer:d,fromUser:h}),(null==n?void 0:n.length)>0&&(0,a.jsx)(qI,{items:n,baseUrl:s,fromUser:h}),(null==e?void 0:e.length)>0&&m&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(Os,{appear:!0,show:!0,as:"ul",className:"memori-media--hints",children:e.slice(0,g).map(((e,n)=>(0,a.jsx)(Os.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,a.jsx)(Jl,{className:t(We)("memori-media--hint"),primary:!0,onClick:()=>{r(e.originalText,e.text),f(!1)},onTouchEnd:()=>{r(e.originalText,e.text),f(!1)},children:e.text},e.text+n)},e.text+n)))}),e.length>g&&(0,a.jsx)("div",{className:"memori-hints--show-more",children:(0,a.jsx)(Jl,{className:"memori-hints--show-more-button",id:"showMoreHints",onClick:()=>v(g+6),children:p("expand")||"Expand"})})]})]})}));const rM=e=>e.endsWith("?")?e:`${e}?`;var oM=({message:e,sessionID:n,visible:i=!0,initialMatches:r=[],closeDrawer:o,client:s,_TEST_loading:l=!1})=>{const{t:u}=Ve(),d=null==s?void 0:s.search.searchMemory,[h,p]=(0,c.useState)(r),[m,f]=(0,c.useState)(l),g=(0,c.useCallback)((async()=>{if(f(!0),!l&&d){try{const{matches:i,...r}=await d(n,{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!==r.resultCode?(console.error(r),t(So).error(u(UI(r.resultCode)))):p(null!=i?i:[])}catch(e){console.error("WHYTHISANSWER/FETCH",e),p(null!=r?r:[])}f(!1)}}),[e,n]);return(0,c.useEffect)((()=>{g()}),[g,e,n]),(0,a.jsxs)(Ql,{open:i,width:"80%",animated:!1,className:"memori-whythisanswer-drawer",onClose:()=>o(),title:u("whyThisAnswer"),children:[(0,a.jsx)("p",{children:u("whyThisAnswerHelper")}),e.questionAnswered&&(0,a.jsxs)("p",{className:"memori--whythisanswer-question-answered",children:[(0,a.jsxs)("strong",{children:[u("question")||"Question",":"]})," ",e.questionAnswered]}),(0,a.jsxs)(Yl,{primary:!0,spinning:m,children:[!m&&0===h.length&&(0,a.jsx)("p",{role:"info",className:"memori--whythisanswer-no-results",children:u("nothingFound")}),m&&0===h.length&&(0,a.jsxs)("ul",{className:"memori--whythisanswer-list memori--whythisanswer-skeleton",children:[(0,a.jsxs)("li",{children:[(0,a.jsxs)("div",{className:"memori--whythisanswer-title",children:[(0,a.jsx)("span",{className:"memori--whythisanswer-confidence",children:(0,a.jsx)("span",{className:"memori--whythisanswer-skeleton-text"})}),(0,a.jsx)("div",{className:"memori--whythisanswer-title-text",children:(0,a.jsx)("p",{className:"memori--whythisanswer-skeleton-text"})})]}),(0,a.jsxs)("p",{children:[(0,a.jsx)("div",{className:"memori--whythisanswer-skeleton-text"}),(0,a.jsx)("div",{className:"memori--whythisanswer-skeleton-text"}),(0,a.jsx)("div",{className:"memori--whythisanswer-skeleton-text"})]}),(0,a.jsx)("div",{className:"memori--whythisanswer-skeleton-block"})]}),(0,a.jsxs)("li",{children:[(0,a.jsxs)("div",{className:"memori--whythisanswer-title",children:[(0,a.jsx)("span",{className:"memori--whythisanswer-confidence",children:(0,a.jsx)("span",{className:"memori--whythisanswer-skeleton-text"})}),(0,a.jsxs)("div",{className:"memori--whythisanswer-title-text",children:[(0,a.jsx)("p",{className:"memori--whythisanswer-skeleton-text"}),(0,a.jsx)("p",{className:"memori--whythisanswer-skeleton-text"})]})]}),(0,a.jsxs)("p",{children:[(0,a.jsx)("div",{className:"memori--whythisanswer-skeleton-text"}),(0,a.jsx)("div",{className:"memori--whythisanswer-skeleton-text"})]}),(0,a.jsx)("div",{className:"memori--whythisanswer-skeleton-block"})]})]}),h.length>0&&(0,a.jsx)("ul",{className:"memori--whythisanswer-list",children:h.map((e=>{var t,n,i,r,o,s,l;return(0,a.jsxs)("li",{children:[(0,a.jsxs)("div",{className:"memori--whythisanswer-title",children:[(0,a.jsx)("span",{className:"memori--whythisanswer-confidence",children:e.confidenceLevel}),(0,a.jsxs)("div",{className:"memori--whythisanswer-title-text",children:[(0,a.jsx)("div",{className:"memori--whythisanswer-title-text-top-container",children:(0,a.jsx)("p",{children:(0,a.jsx)("strong",{children:rM(null!==(t=e.memory.title)&&void 0!==t?t:"")})})}),(0,a.jsx)("p",{children:null===(i=null===(n=e.memory.titleVariants)||void 0===n?void 0:n.map((e=>rM(e))))||void 0===i?void 0:i.join(" | ")}),(e.memory.receiverName||e.memory.receiverTag)&&(0,a.jsxs)("p",{className:"memori--whythisanswer-title-text-top",children:[u("receiverLabel"),": ",e.memory.receiverTag," ",e.memory.receiverName]})]})]}),e.memory.contextVars&&(0,a.jsx)("div",{className:"memori--whythisanswer-contextvars",children:Object.entries(e.memory.contextVars||{}).map((([e,t])=>(0,a.jsx)(VI,{className:"memori--whythisanswer-contextvars-card",children:(0,a.jsxs)("span",{children:[e,": ",(null==t?void 0:t.toString())||"✔️"]})},e)))}),null===(r=e.memory.answers)||void 0===r?void 0:r.map(((e,t)=>(0,a.jsx)("p",{className:"memori--whythisanswer-answer",children:(0,a.jsx)(BI,{mode:"rows",rows:3,children:e.text})},t))),(0,a.jsx)(iM,{links:null===(o=e.memory.media)||void 0===o?void 0:o.filter((e=>"text/html"===e.mimeType))}),null===(l=null===(s=e.memory.media)||void 0===s?void 0:s.filter((e=>"text/plain"===e.mimeType)))||void 0===l?void 0:l.map((e=>(0,a.jsx)(BI,{mode:"rows",rows:2,lineHeightMultiplier:2,innerClassName:"memori--whythisanswer-snippet-expandable",children:(0,a.jsx)(zI,{medium:e,showCopyButton:!1},e.mediumID)},e.mediumID)))]},e.memory.memoryID)}))})]})]})};var aM=({message:e,memori:n,tenant:i,baseUrl:r,apiUrl:o,client:s,sessionID:l,showFeedback:u,showWhyThisAnswer:d=!0,showCopyButton:h=!0,showTranslationOriginal:p=!1,simulateUserPrompt:m,showAIicon:f=!0,isFirst:g=!1,useMathFormatting:v=!1,user:y,userAvatar:_,experts:b,showFunctionCache:x=!1,showReasoning:w=!1})=>{var S,E,A,T,I,M,C,N,O,R,L,P,D,k;const{t:B,i18n:F}=Ve(),U=F.language||"en",[z,G]=(0,c.useState)(!1),[j,H]=(0,c.useState)(!1),[V,W]=(0,c.useState)({plain:!1,raw:!1}),q=(0,c.useRef)({plain:null,raw:null});(0,c.useEffect)((()=>{"undefined"==typeof window||window.MathJax||jE()}),[]);const $=(e.translatedText||e.text).replace(/<document_attachment filename="([^"]+)" type="([^"]+)">([\s\S]*?)<\/document_attachment>/g,""),{text:Y}=kI($,v,B("reasoning")||"Reasoning...",w),J=e.fromUser?DI($):FE(kE(Y)),Z=e.fromUser?$:J,X=h&&(!!(null==J?void 0:J.length)||!!(null===(S=e.text)||void 0===S?void 0:S.length)),K=X&&!!(null===(E=e.text)||void 0===E?void 0:E.length)&&J!==e.text,Q=e.fromUser?e.text||"":(e.text||"").replaceAll(/<think.*?>(.*?)<\/think>/gs,""),ee=B("copied")||"Copied",te=null===(A=e.media)||void 0===A?void 0:A.filter((e=>{var t;return"true"===(null===(t=e.properties)||void 0===t?void 0:t.functionCache)}));(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 i=e.scrollHeight-n;e.scrollTop=t+i}})).catch((e=>console.error("MathJax typesetting failed:",e)))}}catch(e){console.error("Error during MathJax typesetting:",e)}}),100);return()=>clearTimeout(e)}}),[$,e.fromUser,Y]),(0,c.useEffect)((()=>()=>{Object.keys(q.current).forEach((e=>{const t=q.current[e];t&&(clearTimeout(t),q.current[e]=null)}))}),[]);const ne=e=>{W((t=>({...t,[e]:!0}))),q.current[e]&&clearTimeout(q.current[e]),q.current[e]=setTimeout((()=>{W((t=>({...t,[e]:!1}))),q.current[e]=null}),1500)},ie=(e,t)=>{var n;(null==t?void 0:t.length)&&("undefined"!=typeof navigator&&(null===(n=navigator.clipboard)||void 0===n?void 0:n.writeText)?navigator.clipboard.writeText(t).then((()=>ne(e))).catch((e=>{console.error("Copy failed",e)})):ne(e))},re="string"==typeof e.initial?e.initial:null,oe=(!0===e.initial||g)&&!re,ae="system"===e.emitter;return re?(0,a.jsx)("div",{className:"memori-chat--bubble-status-message",children:(0,a.jsx)("div",{className:"memori-chat--bubble-status-message-content",children:re})}):ae?(0,a.jsxs)(Os,{show:!0,appear:!0,as:"div",className:t(We)("memori-chat--bubble-container memori-chat-scroll-item",{"memori-chat--bubble-from-user":!1}),children:[(0,a.jsx)(Os.Child,{as:"picture",className:"memori-chat--bubble-avatar",enter:"transition ease-in-out duration-300",enterFrom:"opacity-0 scale-075 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 translate-x--15",title:(null===(T=e.emitter)||void 0===T?void 0:T.length)&&n.enableBoardOfExperts?e.emitter:n.name,children:(0,a.jsx)("img",{className:"memori-chat--bubble-avatar-img",alt:(null===(I=e.emitter)||void 0===I?void 0:I.length)&&n.enableBoardOfExperts?e.emitter:n.name,src:(null===(M=e.emitter)||void 0===M?void 0:M.length)&&n.enableBoardOfExperts&&(null==b?void 0:b.find((t=>t.name===e.emitter)))?`${new URL(null!=o?o:"/").origin}/api/v1/memoriai/memori/avatar/${null===(C=b.find((t=>t.name===e.emitter)))||void 0===C?void 0:C.expertMemoriID}`:n.avatarURL&&n.avatarURL.length>0?KT({type:"avatar",tenantID:null==i?void 0:i.name,resourceURI:n.avatarURL,baseURL:r,apiURL:o}):KT({tenantID:null==i?void 0:i.name,type:"avatar",baseURL:r||"https://www.aisuru.com",apiURL:o}),onError:e=>{e.currentTarget.src=n.avatarURL&&n.avatarURL.length>0?KT({type:"avatar",tenantID:null==i?void 0:i.name,resourceURI:n.avatarURL,baseURL:r}):KT({tenantID:null==i?void 0:i.name,type:"avatar",baseURL:r}),e.currentTarget.onerror=null}})}),(0,a.jsx)("div",{className:"memori-chat--bubble memori-chat--bubble-status-message-error",children:(0,a.jsx)("div",{className:"memori-chat--bubble-message ",children:$})})]}):(0,a.jsxs)(a.Fragment,{children:[oe&&(0,a.jsx)("div",{className:"memori-chat--bubble-initial"}),(0,a.jsxs)(Os,{show:!0,appear:!0,as:"div",className:t(We)("memori-chat--bubble-container memori-chat-scroll-item",{"memori-chat--bubble-from-user":!!e.fromUser,"memori-chat--with-addon":e.generatedByAI&&f||u&&m}),children:[!e.fromUser&&(0,a.jsx)(Os.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===(N=e.emitter)||void 0===N?void 0:N.length)&&n.enableBoardOfExperts?e.emitter:n.name,children:(0,a.jsx)("img",{className:"memori-chat--bubble-avatar-img",alt:(null===(O=e.emitter)||void 0===O?void 0:O.length)&&n.enableBoardOfExperts?e.emitter:n.name,src:(null===(R=e.emitter)||void 0===R?void 0:R.length)&&n.enableBoardOfExperts&&(null==b?void 0:b.find((t=>t.name===e.emitter)))?`${new URL(null!=o?o:"/").origin}/api/v1/memoriai/memori/avatar/${null===(L=b.find((t=>t.name===e.emitter)))||void 0===L?void 0:L.expertMemoriID}`:n.avatarURL&&n.avatarURL.length>0?KT({type:"avatar",tenantID:null==i?void 0:i.name,resourceURI:n.avatarURL,baseURL:r,apiURL:o}):KT({tenantID:null==i?void 0:i.name,type:"avatar",baseURL:r||"https://www.aisuru.com",apiURL:o}),onError:e=>{e.currentTarget.src=n.avatarURL&&n.avatarURL.length>0?KT({type:"avatar",tenantID:null==i?void 0:i.name,resourceURI:n.avatarURL,baseURL:r}):KT({tenantID:null==i?void 0:i.name,type:"avatar",baseURL:r}),e.currentTarget.onerror=null}})}),(0,a.jsxs)(Os.Child,{as:"div",className:t(We)("memori-chat--bubble",{"memori-chat--user-bubble":!!e.fromUser,"memori-chat--with-addon":X||e.generatedByAI&&f||u&&m,"memori-chat--ai-generated":e.generatedByAI&&f,"memori-chat--with-feedback":u}),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,a.jsx)(BI,{className:"memori-chat--bubble-content",mode:"characters",children:(0,a.jsx)("div",{dir:"auto",className:"memori-chat--bubble-content",dangerouslySetInnerHTML:{__html:Y}})}):(0,a.jsx)("div",{dir:"auto",className:"memori-chat--bubble-content",dangerouslySetInnerHTML:{__html:Y}}),(X||e.generatedByAI&&f||e.generatedByAI&&x||u&&m)&&(0,a.jsxs)("div",{className:"memori-chat--bubble-addon",children:[X&&(0,a.jsx)(Jl,{ghost:!0,shape:"circle",title:V.plain?ee:B("copy")||"Copy",className:t(We)("memori-chat--bubble-action-icon",{"memori-chat--bubble-action-icon--from-user":e.fromUser,"memori-chat--bubble-action-icon--copied":V.plain}),icon:(0,a.jsx)(AI,{"aria-label":V.plain?ee:B("copy")||"Copy"}),onClick:()=>ie("plain",Z)}),V.plain&&(0,a.jsx)("span",{role:"status","aria-live":"polite",className:t(We)("memori-chat--bubble-action-feedback",{"memori-chat--bubble-action-feedback--from-user":e.fromUser}),children:ee}),K&&(0,a.jsx)(Jl,{ghost:!0,shape:"circle",title:V.raw?ee:B("copyRawCode")||"Copy raw code",className:t(We)("memori-chat--bubble-action-icon",{"memori-chat--bubble-action-icon--from-user":e.fromUser,"memori-chat--bubble-action-icon--copied":V.raw}),icon:(0,a.jsx)(TI,{"aria-label":V.raw?ee:B("copyRawCode")||"Copy raw code"}),onClick:()=>ie("raw",Q)}),V.raw&&(0,a.jsx)("span",{role:"status","aria-live":"polite",className:t(We)("memori-chat--bubble-action-feedback",{"memori-chat--bubble-action-feedback--from-user":e.fromUser}),children:ee}),!e.fromUser&&x&&(null===(P=e.media)||void 0===P?void 0:P.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,a.jsx)(Jl,{ghost:!0,shape:"circle",title:"Debug",className:"memori-chat--bubble-action-icon memori-chat--bubble-action-icon--debug",icon:(0,a.jsx)(II,{"aria-label":"Debug"}),onClick:()=>H(!0)}),u&&!!m&&(0,a.jsx)(SI,{memori:n,className:"memori-chat--bubble-feedback",dropdown:!0,onNegativeClick:e=>{e&&m(e)}}),e.generatedByAI&&f&&(0,a.jsx)(nI,{align:"right",content:B("generatedByAI")||("it"===U?"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,a.jsx)("span",{children:(0,a.jsx)(eI,{title:B("generatedByAI")||("it"===U?"Risposta generata da IA, può talvolta generare informazioni non corrette":"Answer generated by AI, may occasionally generate incorrect informations")})})}),p&&e.translatedText&&e.translatedText!==e.text&&(0,a.jsx)(nI,{align:"right",content:`${"it"===U?"Testo originale":"Original text"}: ${e.text}`,className:"memori-chat--bubble-action-icon memori-chat--bubble-action-icon--ai",children:(0,a.jsx)("span",{children:(0,a.jsx)(tI,{"aria-label":"it"===U?"Testo originale":"Original text"})})}),!e.fromUser&&e.questionAnswered&&o&&d&&(0,a.jsx)(Jl,{ghost:!0,shape:"circle",title:B("whyThisAnswer")||void 0,className:"memori-chat--bubble-action-icon",onClick:()=>G(!0),disabled:z,icon:(0,a.jsx)(EI,{title:B("whyThisAnswer")||void 0})})]})]}),e.fromUser&&(0,a.jsx)(a.Fragment,{children:_&&"string"==typeof _||!_&&(null===(D=null==y?void 0:y.avatarURL)||void 0===D?void 0:D.length)?(0,a.jsx)(Os.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,a.jsx)("img",{className:"memori-chat--bubble-avatar-img",alt:null!==(k=null==y?void 0:y.userName)&&void 0!==k?k:"User",src:null!=_?_:null==y?void 0:y.avatarURL})}):_?(0,a.jsx)(Os.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,a.jsx)(Os.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,a.jsx)(QT,{})})})]}),z&&s&&(0,a.jsx)(oM,{client:s,visible:z,message:e,closeDrawer:()=>G(!1),sessionID:l}),(0,a.jsx)(CA,{open:j,onClose:()=>H(!1),className:"memori-chat--function-cache-modal",children:null==te?void 0:te.map(((e,t)=>(0,a.jsxs)("div",{style:t>0?{marginTop:"1.5rem",paddingTop:"1.5rem",borderTop:"1px solid #e0e0e0"}:{paddingTop:"1.5rem"},children:[(0,a.jsx)("h3",{style:{marginTop:0},children:e.title}),(0,a.jsx)("pre",{style:{whiteSpace:"pre-wrap",wordWrap:"break-word"},children:e.content},e.mediumID)]},e.mediumID)))})]})};c=o("85Hg2"),c=o("85Hg2");var sM=({disabled:e=!1,value:n,onChange:i,onPressEnter:r,onFocus:o,onBlur:s,onExpandedChange:l})=>{const{t:u}=Ve(),d=(0,c.useRef)(null),h=(0,c.useRef)(null);return(0,c.useEffect)((()=>{const e=d.current,t=h.current;if(e&&t)if(0===n.length){e.style.height="36px",t.style.height="36px",l&&l(!1);const n=document.getElementsByClassName("memori-chat--content");if(n){const e=n[n.length-1];e&&(e.style.paddingBottom="0px")}}else{e.style.height="auto";const n=e.scrollHeight,i=Math.min(Math.max(n,36),208);e.style.height=`${i}px`,t.style.height=`${i}px`;const r=document.getElementsByClassName("memori-chat--content");if(r){r[r.length-1]&&r[0].scrollTo({top:r[0].scrollHeight,behavior:"smooth"})}}}),[n]),(0,a.jsx)("div",{"data-testid":"chat-textarea",className:t(We)("memori-chat-textarea",{"memori-chat-textarea--disabled":e}),children:(0,a.jsx)("div",{ref:h,className:"memori-chat-textarea--inner",children:(0,a.jsx)("textarea",{ref:d,className:"memori-chat-textarea--input",disabled:e,value:n,placeholder:u("placeholder","Ask a question")||"Ask a question",onChange:e=>{i(e.target.value)},onKeyDownCapture:e=>{const t=IE();"Enter"!==e.key||e.shiftKey||!r||t||r(e)},onFocus:o,onBlur:s,maxLength:1e5})})})};var lM=({className:e,title:t})=>(0,a.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,a.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 cM=({className:e,title:t})=>(0,a.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,a.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 uM=({listening:e,stopAudio:n,startListening:i,stopListening:r})=>{const{t:o}=Ve(),[s,l]=(0,c.useState)(),u=(0,c.useRef)(null),d=e=>{e.preventDefault(),e.stopPropagation(),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"),i()}),300))},h=e=>{e&&(e.preventDefault(),e.stopPropagation()),u.current&&(clearTimeout(u.current),u.current=null),r(),l(void 0)};return(0,c.useEffect)((()=>()=>h()),[]),(0,a.jsx)(nI,{visible:!!s,content:(0,a.jsx)("span",{children:s||o("write_and_speak.pressAndHoldToSpeak")||"Press and hold to speak"}),align:"topLeft",className:"memori-mic-btn-tooltip",children:(0,a.jsx)("div",{onContextMenu:e=>{e.preventDefault(),e.stopPropagation()},children:(0,a.jsx)(Jl,{primary:!0,className:t(We)("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:e=>{e.preventDefault(),e.stopPropagation(),d(e)},onMouseUp:h,onTouchEnd:e=>{e.preventDefault(),e.stopPropagation(),h(e)},onMouseLeave:h,shape:"circle",icon:(0,a.jsx)(cM,{})})})})};c=o("85Hg2");const dM=({className:e})=>(0,a.jsxs)("svg",{className:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,a.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,a.jsx)("path",{d:"M17 8L12 3L7 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),(0,a.jsx)("path",{d:"M12 3V15",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]});c=o("85Hg2");var hM=({open:e=!1,onClose:n,className:i,title:r,description:o,children:s,type:l="info",icon:u,closable:d=!0,duration:h=null,action:p,width:m="400px"})=>{const{t:f}=Ve();t(c).useEffect((()=>{if(h&&e){const e=setTimeout((()=>{n(!1)}),h);return()=>clearTimeout(e)}}),[h,e,n]);return(0,a.jsx)(Os,{show:e,as:t(c).Fragment,appear:!0,children:(0,a.jsxs)("div",{className:t(We)("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),i),children:[(0,a.jsx)("style",{dangerouslySetInnerHTML:{__html:`\n .memori-alert {\n --memori-alert--width: ${m};\n }\n `}}),(0,a.jsx)(Os.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,a.jsxs)("div",{className:"memori-alert--container",children:[u&&(0,a.jsx)("div",{className:"memori-alert--icon",children:u}),(0,a.jsxs)("div",{className:"memori-alert--content",children:[r&&(0,a.jsx)("div",{className:"memori-alert--title",children:r}),o&&(0,a.jsx)("div",{className:"memori-alert--description",children:o}),s]}),(0,a.jsxs)("div",{className:"memori-alert--actions",children:[p&&(0,a.jsx)("div",{className:"memori-alert--action",children:p}),d&&(0,a.jsx)(Jl,{ghost:!0,padded:!0,shape:"circle",icon:(0,a.jsx)(Zl,{}),title:f("close")||"Close",onClick:()=>n(!1),className:"memori-alert--close"})]})]})})]})})};c=o("85Hg2");const pM=({className:e})=>(0,a.jsxs)("svg",{className:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,a.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,a.jsx)("path",{d:"M14 2.5V8H19.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),(0,a.jsx)("path",{d:"M16 13H8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),(0,a.jsx)("path",{d:"M16 17H8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),(0,a.jsx)("path",{d:"M10 9H8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]});NI=o("1Lq0j");const mM="3.11.174",fM=`https://cdnjs.cloudflare.com/ajax/libs/pdf.js/${mM}/pdf.worker.min.js`,gM=`https://cdnjs.cloudflare.com/ajax/libs/pdf.js/${mM}/pdf.min.js`;var vM=({setDocumentPreviewFiles:e,maxDocuments:n,documentPreviewFiles:i,onLoadingChange:r,onDocumentError:o,onValidateFile:s,onValidatePayloadSize:l})=>{const[u,d]=(0,c.useState)(!1),[h,p]=(0,c.useState)(null),m=(0,c.useRef)(null);(0,c.useEffect)((()=>{r&&r(u)}),[u,r]);const f=e=>!s||s(e),g=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=gM,n.onload=()=>{window.pdfjsLib.GlobalWorkerOptions.workerSrc=fM,e(!0)},n.onerror=t,document.head.appendChild(n)}));const t=await e.arrayBuffer(),n=await window.pdfjsLib.getDocument({data:t}).promise;let i="";for(let e=1;e<=n.numPages;e++){const t=await n.getPage(e);i+=(await t.getTextContent()).items.filter((e=>e.str&&"string"==typeof e.str)).map((e=>e.str)).join(" ")+"\n"}return i}catch(e){throw console.error("PDF extraction failed:",e),new Error(`PDF extraction failed: ${e instanceof Error?e.message:"Unknown error"}`)}})(e):["txt","md","json","csv","html"].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 i="";for(const e of n.SheetNames){const t=n.Sheets[e],r=window.XLSX.utils.sheet_to_json(t,{header:1,raw:!1}),o=r.reduce(((e,t)=>(t.forEach(((t,n)=>{const i=(t||"").toString().length;e[n]=Math.max(e[n]||0,i)})),e)),[]),a=r.map((e=>e.map(((e,t)=>(e||"").toString().padEnd(o[t]+2))).join("|").trim()));if(a.length>0){const e=o.map((e=>"-".repeat(e+2))).join("+");a.splice(1,0,e)}i+=`Sheet: ${e}\n${a.join("\n")}\n\n`}return i}catch(e){throw console.error("XLSX extraction failed:",e),new Error(`XLSX extraction failed: ${e instanceof Error?e.message:"Unknown error"}`)}})(e)),t&&t.length>NI.MAX_DOCUMENT_CONTENT_LENGTH&&(console.warn("Document content exceeds length limit:",t.length,">",NI.MAX_DOCUMENT_CONTENT_LENGTH),null==o||o({message:`File "${e.name}" content exceeds ${NI.MAX_DOCUMENT_CONTENT_LENGTH} characters and was truncated`,severity:"warning"}),t=t.substring(0,NI.MAX_DOCUMENT_CONTENT_LENGTH)+"\n\n[Content truncated due to size limits]"),t}catch(t){throw console.error("Document processing failed:",t),new Error(`Failed to process "${e.name}": ${t instanceof Error?t.message:"Unknown error"}`)}};return(0,a.jsxs)("div",{className:"memori--document-upload-wrapper",children:[(0,a.jsx)("input",{ref:m,type:"file",accept:".pdf,.txt,.md,.json,.xlsx,.csv,.html",multiple:!0,className:"memori--upload-file-input",onChange:async t=>{const r=Array.from(t.target.files||[]);if(0===r.length)return;const a=i.length;if(n&&a+r.length>n)return null==o||o({message:`Maximum ${n} media files allowed. You can upload ${Math.max(0,n-a)} more file${n-a!=1?"s":""}.`,severity:"error"}),void(m.current&&(m.current.value=""));d(!0);const s=[];for(const e of r){if(!f(e))continue;const t=Math.random().toString(36).substr(2,9);try{const n=await g(e);n&&s.push({name:e.name,id:t,content:n,mimeType:e.type})}catch(e){console.error("File processing error:",e),null==o||o({message:`${e instanceof Error?e.message:"Unknown error"}`,severity:"error"})}}if(s.length>0){if(c=s,l&&!l(c))return d(!1),void(m.current&&(m.current.value=""));const t=i.filter((e=>"document"===e.type));i.filter((e=>"image"===e.type));e([...t,...s.map((e=>({...e,type:"document"})))])}var c;d(!1),m.current&&(m.current.value="")}}),(0,a.jsx)("button",{className:t(We)("memori-button","memori-button--circle","memori-button--icon-only","memori-share-button--button","memori--conversation-button","memori--document-upload-button",{"memori--error":!1}),onClick:()=>{var e;return null===(e=m.current)||void 0===e?void 0:e.click()},disabled:u||n&&i.length>=n||!1,title:"Upload documents",children:u?(0,a.jsx)(Yl,{spinning:!0,className:"memori--upload-icon"}):(0,a.jsx)(t(c).Fragment,{children:(0,a.jsx)(pM,{className:"memori--upload-icon"})})}),(0,a.jsx)(CA,{width:"80%",widthMd:"80%",open:!!h,className:"memori--modal-preview-file",onClose:()=>p(null),closable:!0,title:null==h?void 0:h.name,children:(0,a.jsx)("div",{className:"memori--preview-content",style:{maxHeight:"70vh",overflowY:"auto",textAlign:"center",whiteSpace:"pre-wrap"},children:null==h?void 0:h.content})})]})};c=o("85Hg2");const yM=({className:e})=>(0,a.jsxs)("svg",{className:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,a.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),(0,a.jsx)("circle",{cx:"8.5",cy:"8.5",r:"1.5",fill:"currentColor"}),(0,a.jsx)("path",{d:"M21 15L16 10L5 21",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),_M={maxWidth:1920,maxHeight:1920,quality:.75,maxSizeMB:2},bM=e=>new Promise(((t,n)=>{const i=new Image,r=URL.createObjectURL(e);i.onload=()=>{URL.revokeObjectURL(r),t(i)},i.onerror=()=>{URL.revokeObjectURL(r),n(new Error("Failed to load image"))},i.src=r})),xM=async(e,t={})=>{const n={..._M,...t};if(!(e.size/1048576>1))try{const t=await bM(e);if(!(t.width>n.maxWidth||t.height>n.maxHeight))return e}catch(t){return e}try{const t=await bM(e),i=1,{width:r,height:o}=((e,t,n,i)=>{if(e<=n&&t<=i)return{width:e,height:t};const r=n/e,o=i/t,a=Math.min(r,o,1);return{width:Math.round(e*a),height:Math.round(t*a)}})(t.width,t.height,n.maxWidth,n.maxHeight),a=document.createElement("canvas");a.width=r,a.height=o;const s=a.getContext("2d");if(!s)throw new Error("Failed to get canvas context");return((e,t,n,i)=>{switch(t){case 2:e.transform(-1,0,0,1,n,0);break;case 3:e.transform(-1,0,0,-1,n,i);break;case 4:e.transform(1,0,0,-1,0,i);break;case 5:e.transform(0,1,1,0,0,0);break;case 6:e.transform(0,1,-1,0,i,0);break;case 7:e.transform(0,-1,-1,0,i,n);break;case 8:e.transform(0,-1,1,0,0,n)}})(s,i,r,o),s.drawImage(t,0,0,r,o),new Promise(((t,i)=>{a.toBlob((r=>{if(!r)return void i(new Error("Failed to compress image"));if(r.size/1048576>n.maxSizeMB)a.toBlob((n=>{if(!n){const n=new File([r],e.name.replace(/\.[^/.]+$/,".jpg"),{type:"image/jpeg"});return void t(n)}const i=new File([n],e.name.replace(/\.[^/.]+$/,".jpg"),{type:"image/jpeg"});t(i)}),"image/jpeg",Math.max(.5,n.quality-.2));else{const n=new File([r],e.name.replace(/\.[^/.]+$/,".jpg"),{type:"image/jpeg"});t(n)}}),"image/jpeg",n.quality)}))}catch(t){return e}};var wM=({authToken:e="",sessionID:n="",client:i,isMediaAccepted:r=!1,setDocumentPreviewFiles:o,documentPreviewFiles:s,onLoadingChange:l,maxImages:u=5,memoriID:d="",onImageError:h,onValidateImageFile:p})=>{var m,f,g;const{t:v,i18n:y}=Ve(),{backend:_,dialog:b}=i||{backend:{uploadAsset:null,uploadAssetUnlogged:null},dialog:{postMediumSelectedEvent:null,postMediumDeselectedEvent:null}},[x,w]=(0,c.useState)(!1),[S,E]=(0,c.useState)(null),[A,T]=(0,c.useState)(null),[I,M]=(0,c.useState)(""),[C,N]=(0,c.useState)(!1),O=(0,c.useRef)(null);(0,c.useEffect)((()=>{l&&l(x)}),[x,l]);const R=s.length,L=async t=>{var r;w(!0);try{const r=t.map((async t=>{let r=t;try{r=await xM(t)}catch(e){console.warn("Image compression failed, using original file",e),r=t}return new Promise((t=>{const o=new FileReader;o.onload=async o=>{var a,l,c,u,p;const m=null===(a=o.target)||void 0===a?void 0:a.result,f=Math.random().toString(36).substr(2,9),g=r.name.split(".").slice(0,-1).join(".");if(i)try{let i,o;if(e&&(null==_?void 0:_.uploadAsset))o=await _.uploadAsset(r.name,m,e);else{if(!(d&&n&&(null==_?void 0:_.uploadAssetUnlogged)))throw new Error("Missing required parameters for upload");if(o=await _.uploadAssetUnlogged(r.name,m,d,n),!o)throw new Error("Upload failed")}if(i=o.asset,0!==o.resultCode)throw new Error(o.resultMessage||"Upload failed");let a,u=null;if((null==b?void 0:b.postMediumSelectedEvent)&&n&&(u=await b.postMediumSelectedEvent(n,{url:i.assetURL,mimeType:i.mimeType})),null===(l=null==u?void 0:u.currentState)||void 0===l?void 0:l.currentMedia){const e=new Set(s.map((e=>e.mediumID)));a=null===(c=u.currentState.currentMedia.find((t=>!e.has(t.mediumID))))||void 0===c?void 0:c.mediumID}t({name:g,id:f,url:i.assetURL,content:i.assetURL,type:"image",mediumID:a,mimeType:i.mimeType})}catch(e){null==h||h({message:null!==(u=v("upload.uploadFailed"))&&void 0!==u?u:"Upload failed",severity:"error"}),t(null)}else null==h||h({message:null!==(p=v("upload.apiClientNotConfigured"))&&void 0!==p?p:"API client not configured properly for media upload",severity:"warning"}),t(null)},o.onerror=()=>{var e;null==h||h({message:null!==(e=v("upload.fileReadingFailed"))&&void 0!==e?e:"File reading failed",severity:"error"}),t(null)},o.readAsDataURL(r)}))})),a=(await Promise.all(r)).filter((e=>null!==e));a.length>0&&o((e=>[...e,...a]))}catch(e){null==h||h({message:null!==(r=v("upload.uploadFailed"))&&void 0!==r?r:"Upload failed",severity:"error"})}finally{w(!1)}},P=()=>{N(!1),E(null),T(null),M("")};return(0,a.jsxs)("div",{className:"memori--image-upload-wrapper",children:[(0,a.jsx)("input",{ref:O,type:"file",accept:".jpg,.jpeg,.png",multiple:!0,className:"memori--upload-file-input",onChange:async e=>{const t=Array.from(e.target.files||[]);if(0===t.length)return;if(R+t.length>u)return void(null==h||h({message:`Maximum ${u} media files allowed. You can upload ${Math.max(0,u-R)} more file${u-R!=1?"s":""}.`,severity:"error"}));const n=t.filter((e=>!!(e=>!p||p(e))(e)));if(0!==n.length){if(1===n.length){const e=n[0];E(e),T(URL.createObjectURL(e));const t=e.name.split(".").slice(0,-1).join(".");M(t),N(!0)}else await L(n);O.current&&(O.current.value="")}else O.current&&(O.current.value="")},disabled:x||!r||R>=u}),(0,a.jsx)("button",{className:t(We)("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=O.current)||void 0===e?void 0:e.click()},disabled:x||!r||R>=u,children:x?(0,a.jsx)(Yl,{spinning:!0,className:"memori--upload-icon"}):(0,a.jsx)(yM,{className:"memori--upload-icon"})}),(0,a.jsx)(CA,{width:"80%",widthMd:"80%",open:C&&!!S,className:"memori--modal-preview-file",onClose:P,closable:!0,children:(0,a.jsxs)("div",{className:"memori--preview-content",style:{maxHeight:"70vh",overflowY:"auto",textAlign:"center"},children:[A&&(0,a.jsx)("img",{src:A,alt:(null==S?void 0:S.name)||"Preview",style:{maxWidth:"100%",maxHeight:"40vh",marginBottom:"20px"}}),(0,a.jsxs)("div",{style:{maxWidth:"400px",margin:"0 auto",textAlign:"left"},children:[(0,a.jsx)("p",{style:{marginBottom:"10px",color:"#666"},children:v("upload.titleHelp")}),(0,a.jsx)("input",{value:I,onChange:e=>M(e.target.value),placeholder:null!==(m=v("upload.titlePlaceholder"))&&void 0!==m?m:"Enter image title",style:{width:"90%",marginBottom:"20px"},className:"memori--upload-title-input"}),(0,a.jsxs)("div",{style:{display:"flex",gap:"10px",justifyContent:"center",alignItems:"center"},children:[(0,a.jsx)(Jl,{onClick:P,className:"memori-button memori-button--outline memori--upload-image",children:null!==(f=v("cancel"))&&void 0!==f?f:"Cancel"}),(0,a.jsx)(Jl,{onClick:async()=>{var t;if(S&&I.trim()){w(!0),N(!1);try{let t=S;try{t=await xM(S)}catch(e){console.warn("Image compression failed, using original file",e),t=S}const r=new FileReader;r.onload=async r=>{var a,l,c,u,p;const m=null===(a=r.target)||void 0===a?void 0:a.result,f=Math.random().toString(36).substr(2,9);if(i)try{let i,r;if(e&&(null==_?void 0:_.uploadAsset))r=await _.uploadAsset(t.name,m,e);else{if(!(d&&n&&(null==_?void 0:_.uploadAssetUnlogged)))throw new Error("Missing required parameters for upload");if(r=await _.uploadAssetUnlogged(t.name,m,d,n),!r)throw new Error("Upload failed")}if(i=r.asset,0!==r.resultCode)throw new Error(r.resultMessage||"Upload failed");let a,u=null;if((null==b?void 0:b.postMediumSelectedEvent)&&n&&(u=await b.postMediumSelectedEvent(n,{url:i.assetURL,mimeType:i.mimeType})),null===(l=null==u?void 0:u.currentState)||void 0===l?void 0:l.currentMedia){const e=new Set(s.map((e=>e.mediumID)));a=null===(c=u.currentState.currentMedia.find((t=>!e.has(t.mediumID))))||void 0===c?void 0:c.mediumID}o((e=>[...e,{name:I,id:f,url:i.assetURL,content:i.assetURL,type:"image",mediumID:a,mimeType:i.mimeType}]))}catch(e){null==h||h({message:null!==(u=v("upload.uploadFailed"))&&void 0!==u?u:"Upload failed",severity:"error"})}else null==h||h({message:null!==(p=v("upload.apiClientNotConfigured"))&&void 0!==p?p:"API client not configured properly for media upload",severity:"warning"});w(!1)},r.onerror=()=>{var e;null==h||h({message:null!==(e=v("upload.fileReadingFailed"))&&void 0!==e?e:"File reading failed",severity:"error"}),w(!1)},r.readAsDataURL(t)}catch(e){null==h||h({message:null!==(t=v("upload.uploadFailed"))&&void 0!==t?t:"Upload failed",severity:"error"}),w(!1)}}},disabled:!S||!I.trim(),className:"memori-button memori-button--primary memori-button--image-confirm memori--upload-image",children:null!==(g=v("confirm"))&&void 0!==g?g:"Confirm"})]})]})]})})]})};const SM=10;var EM=({authToken:e="",client:n,sessionID:i="",isMediaAccepted:r=!1,setDocumentPreviewFiles:s,documentPreviewFiles:l,memoriID:u=""})=>{var d;const[h,p]=(0,c.useState)(!1),[m,f]=(0,c.useState)([]),[g,v]=(0,c.useState)(!1),{t:y,i18n:_}=Ve(),b=(0,c.useRef)(null),x=(0,c.useRef)(null),w=(0,c.useRef)(null),S=(0,c.useRef)(null),E=(0,c.useRef)(null),A=l.length,T=SM-A<=0,I=e=>{f((t=>t.filter((t=>t.message!==e))))},M=e=>{f((t=>[...t,e])),setTimeout((()=>I(e.message)),5e3)},C=(0,c.useRef)(r),N=(0,c.useRef)(A),O=(0,c.useRef)(M);(0,c.useEffect)((()=>{C.current=r,N.current=A,O.current=M}),[r,A,M]);const R=(0,c.useCallback)((e=>{var t,n,i;const r=Array.from(e);if(0===r.length)return;const o=[],a=[];r.forEach((e=>{(e=>{var t;const n=`.${null===(t=e.name.split(".").pop())||void 0===t?void 0:t.toLowerCase()}`;return["image/jpeg","image/jpg","image/png"].includes(e.type)||[".jpg",".jpeg",".png"].includes(n)})(e)?o.push(e):(e=>{var t;const n=`.${null===(t=e.name.split(".").pop())||void 0===t?void 0:t.toLowerCase()}`;return[".pdf",".txt",".json",".xlsx",".csv",".md",".html"].includes(n)})(e)?a.push(e):O.current({message:`File "${e.name}" is not a supported image or document type`,severity:"error"})}));const s=o.length+a.length;if(N.current+s>SM)O.current({message:"Maximum 10 media files allowed.",severity:"error"});else{if(o.length>0)if(C.current){const e=null===(n=w.current)||void 0===n?void 0:n.querySelector('input[type="file"]');if(e){const t=new DataTransfer;if(o.forEach((e=>{try{t.items.add(e)}catch(e){console.warn("Failed to add image file to DataTransfer:",e)}})),t.files.length>0){e.files=t.files;const n=new Event("change",{bubbles:!0});e.dispatchEvent(n)}}}else O.current({message:null!==(t=y("upload.mediaNotAccepted"))&&void 0!==t?t:"Media uploads are not accepted",severity:"info"});if(a.length>0){const e=null===(i=x.current)||void 0===i?void 0:i.querySelector('input[type="file"]');if(e){const t=new DataTransfer;if(a.forEach((e=>{try{t.items.add(e)}catch(e){console.warn("Failed to add document file to DataTransfer:",e)}})),t.files.length>0){e.files=t.files;const n=new Event("change",{bubbles:!0});e.dispatchEvent(n)}}}}}),[y]);(0,c.useEffect)((()=>{const e=e=>{const t=e.clipboardData;if(!t)return void console.log("[UploadButton] handlePaste: No clipboardData available.");const n=[],i=e=>n.some((t=>t.name===e.name&&t.size===e.size&&t.lastModified===e.lastModified));if(t.files&&t.files.length>0){const e=Array.from(t.files);console.log("[UploadButton] handlePaste: clipboardData.files found",e),e.forEach((e=>{i(e)?console.log("[UploadButton] handlePaste: Duplicate file skipped from clipboardData.files:",e):n.push(e)}))}else{const e=t.items;if(e)for(let t=0;t<e.length;t++){const r=e[t];if("file"===r.kind){const e=r.getAsFile();e&&!i(e)?(console.log("[UploadButton] handlePaste: Adding file from items array:",e),n.push(e)):e&&console.log("[UploadButton] handlePaste: Duplicate file skipped from items array:",e)}}}n.length>0?(console.log(`[UploadButton] handlePaste: ${n.length} file(s) to process from paste`,n),e.preventDefault(),R(n)):console.log("[UploadButton] handlePaste: No files found in paste event.")};return document.addEventListener("paste",e),()=>{document.removeEventListener("paste",e)}}),[R]),(0,c.useEffect)((()=>{let e=0;const t=t=>{t.preventDefault(),t.stopPropagation(),e++,1===e&&v(!0)},n=t=>{t.preventDefault(),t.stopPropagation(),e--,0===e&&v(!1)},i=e=>{e.preventDefault(),e.stopPropagation()},r=t=>{var n;t.preventDefault(),t.stopPropagation(),e=0,v(!1);const i=null===(n=t.dataTransfer)||void 0===n?void 0:n.files;i&&i.length>0&&R(i)};return document.addEventListener("dragenter",t),document.addEventListener("dragleave",n),document.addEventListener("dragover",i),document.addEventListener("drop",r),()=>{document.removeEventListener("dragenter",t),document.removeEventListener("dragleave",n),document.removeEventListener("dragover",i),document.removeEventListener("drop",r)}}),[R]);const L=e=>{p(e)};return(0,a.jsxs)("div",{className:t(We)("memori--unified-upload-wrapper",{"memori--dragging":g}),ref:E,children:[(0,a.jsx)("input",{ref:S,type:"file",accept:".jpg,.jpeg,.png,.pdf,.txt,.json,.xlsx,.csv,.md,.html",multiple:!0,className:"memori--upload-file-input",onChange:e=>{const t=e.target.files;t&&t.length>0&&R(t),S.current&&(S.current.value="")},style:{display:"none"}}),(0,a.jsx)("button",{ref:b,className:t(We)("memori-button","memori-button--circle","memori-button--icon-only","memori-share-button--button","memori--conversation-button","memori--unified-upload-button",{"memori--error":m.length>0}),onClick:()=>{S.current&&S.current.click()},disabled:h||T,title:null!==(d=y("upload.uploadFiles",{shortcut:/Mac|iPhone|iPod|iPad/i.test(navigator.platform)||navigator.userAgent.includes("Mac")?"Cmd":"Ctrl"}))&&void 0!==d?d:"Upload files (drag & drop)",children:h?(0,a.jsx)(Yl,{spinning:!0,className:"memori--upload-icon"}):(0,a.jsx)(dM,{className:"memori--upload-icon"})}),A>0&&(0,a.jsxs)("div",{className:t(We)("memori--document-count",{"memori--document-count-full":T}),children:[A,"/",SM]}),(0,a.jsx)("div",{className:"memori--hidden-uploader",ref:x,children:(0,a.jsx)(vM,{setDocumentPreviewFiles:e=>{if(0===e.length)return;const t=e.map((e=>{const t=`<document_attachment filename="${e.name.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#39;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}" type="${e.mimeType}">\n\n${e.content}\n\n</document_attachment>`;return{name:e.name,id:e.id,content:t,type:"document",mimeType:e.mimeType}})),n=l.filter((e=>"image"===e.type));s([...t,...n]),p(!1)},maxDocuments:SM,documentPreviewFiles:l,onLoadingChange:L,onDocumentError:e=>{M(e)},onValidateFile:e=>{var t;const n=`.${null===(t=e.name.split(".").pop())||void 0===t?void 0:t.toLowerCase()}`,i=[".pdf",".txt",".json",".xlsx",".csv",".md",".html"],r=10485760;return i.includes(n)?!(e.size>r)||(M({message:`File "${e.name}" exceeds 10MB limit`,severity:"error"}),!1):(M({message:`File type "${n}" is not supported. Please use: ${i.join(", ")}`,severity:"error"}),!1)},onValidatePayloadSize:e=>{const{MAX_TOTAL_MESSAGE_PAYLOAD:t}=o("1Lq0j");return!([...l.filter((e=>"document"===e.type)),...e].reduce(((e,t)=>e+t.content.length),0)>t)||(M({message:`Total document content exceeds ${t} characters limit. Please remove some documents.`,severity:"error"}),!1)}})}),(0,a.jsx)("div",{className:"memori--hidden-uploader",ref:w,children:(0,a.jsx)(wM,{authToken:e,client:n,setDocumentPreviewFiles:s,sessionID:i,documentPreviewFiles:l,isMediaAccepted:r,onLoadingChange:L,maxImages:SM,memoriID:u,onImageError:e=>{M(e)},onValidateImageFile:e=>{var t;const n=`.${null===(t=e.name.split(".").pop())||void 0===t?void 0:t.toLowerCase()}`,i=[".jpg",".jpeg",".png"],r=10485760;return i.includes(n)||e.type.startsWith("image/")?!(e.size>r)||(M({message:`File "${e.name}" exceeds 10MB limit`,severity:"error"}),!1):(M({message:`File type "${n}" is not supported. Please use: ${i.join(", ")}`,severity:"error"}),!1)}})}),(0,a.jsx)("div",{className:"memori--error-message-container",children:m.map(((e,t)=>(0,a.jsx)(hM,{className:"memori--error-message-alert",open:!0,type:e.severity,title:"Upload notification",description:e.message,onClose:()=>I(e.message),width:"350px"},`${e.message}-${t}`)))})]})};c=o("85Hg2");var AM=({previewFiles:e,removeFile:t,allowRemove:n=!0})=>{const[i,r]=(0,c.useState)(null),[o,s]=(0,c.useState)(null),l=(e,t)=>{var n,i;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===(i=e.split(".").pop())||void 0===i?void 0:i.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"}};(0,c.useEffect)((()=>{const e=document.getElementsByClassName("memori-chat--content");if(e){e[e.length-1]&&e[0].scrollTo({top:e[0].scrollHeight,behavior:"smooth"})}}),[e]);const u=(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,a.jsxs)(a.Fragment,{children:[e.length>0&&(0,a.jsx)("div",{className:"memori--preview-container",children:(0,a.jsx)("div",{className:"memori--preview-list",children:e.map((e=>(0,a.jsxs)("div",{className:"memori--preview-item "+(u(e.content,e.type)?"memori--preview-item--image":"memori--preview-item--document"),onMouseEnter:()=>s(e.id),onMouseLeave:()=>s(null),onClick:()=>r(e),children:[u(e.content,e.type)?(0,a.jsx)("div",{className:"memori--preview-thumbnail",children:(0,a.jsx)("img",{src:e.content,alt:e.name})}):(0,a.jsx)(pM,{className:"memori--preview-icon"}),(0,a.jsxs)("div",{className:"memori--preview-file-info",children:[(0,a.jsx)("span",{className:"memori--preview-filename",children:e.name}),(0,a.jsx)("span",{className:"memori--preview-filetype",children:l(e.name,e.type)})]}),n&&(0,a.jsx)(Jl,{shape:"rounded",icon:(0,a.jsx)(Zl,{}),danger:!0,className:"memori--remove-button "+(o===e.id?"visible":""),onClick:n=>{n.stopPropagation(),t(e.id,null==e?void 0:e.mediumID)}})]},e.id)))})}),(0,a.jsx)(CA,{width:"80%",widthMd:"80%",open:!!i,className:"memori--modal-preview-file",onClose:()=>r(null),closable:!0,title:null==i?void 0:i.name,children:(0,a.jsx)("div",{className:"memori--preview-content",style:{maxHeight:"70vh",overflowY:"auto",textAlign:"center",whiteSpace:i&&!u(i.content,i.type)?"pre-wrap":"normal"},children:i&&u(i.content,i.type)?(0,a.jsx)(a.Fragment,{children:(0,a.jsx)("img",{src:i.content,alt:i.name,style:{maxWidth:"100%",maxHeight:"60vh"}})}):FE((null==i?void 0:i.content)||"")})})]})};var TM=({dialogState:e,userMessage:n="",sendOnEnter:i,onChangeUserMessage:r,sendMessage:o,onTextareaFocus:s,onTextareaBlur:l,showMicrophone:u=!1,microphoneMode:d="HOLD_TO_TALK",listening:h=!1,stopAudio:p,startListening:m,stopListening:f,showUpload:g=!1,isTyping:v=!1,sessionID:y,authToken:_,memoriID:b,client:x,onTextareaExpanded:w})=>{const{t:S}=Ve(),[E,A]=(0,c.useState)(!1),[T,I]=(0,c.useState)([]),{dialog:M}=x||{dialog:{postMediumDeselectedEvent:null}},C="X2a"===(null==e?void 0:e.state)||"X3"===(null==e?void 0:e.state),N=["R2","R3","R4","R5","G3","X3"].includes((null==e?void 0:e.state)||"");return(0,a.jsx)("div",{className:"memori-chat-inputs-wrapper",children:(0,a.jsxs)("fieldset",{id:"chat-fieldset",className:t(We)("memori-chat-inputs",{"memori-chat-inputs--expanded":E}),disabled:C,children:[g&&(0,a.jsx)(AM,{previewFiles:T,removeFile:async(e,t)=>{M.postMediumDeselectedEvent&&y&&t&&await M.postMediumDeselectedEvent(y,t),I((t=>t.filter((t=>t.id!==e))))}}),(0,a.jsxs)("div",{className:"memori-chat-inputs--container",children:[(0,a.jsx)("div",{className:"memori-chat-inputs--leading",children:g&&(0,a.jsx)("div",{className:"memori-chat-inputs--upload-wrapper",children:(0,a.jsx)(EM,{authToken:_,client:x,sessionID:y,isMediaAccepted:(null==e?void 0:e.acceptsMedia)||!1,setDocumentPreviewFiles:I,documentPreviewFiles:T,memoriID:b})})}),(0,a.jsx)("div",{className:"memori-chat-inputs--primary",children:(0,a.jsx)(sM,{value:n,onChange:r,onPressEnter:e=>{if(e.preventDefault(),!v&&"keypress"===i&&(null==n?void 0:n.length)>0){f();const e=T.map(((e,t)=>({mediumID:e.mediumID||`file_${Date.now()}_${t}_${Math.random().toString(36).substr(2,9)}`,mimeType:e.mimeType,content:e.content,title:e.name,properties:{isAttachedFile:!0},type:e.type,url:e.url})));o(n,e),I([]),r("")}},onFocus:s,onBlur:l,onExpandedChange:e=>{A(e),w&&w(e)},disabled:N})}),(0,a.jsx)("div",{className:"memori-chat-inputs--trailing",children:(0,a.jsxs)("div",{className:"memori-chat-inputs--trailing-inner",children:[u&&"CONTINUOUS"===d&&(0,a.jsx)("button",{type:"button",className:t(We)("memori-chat-inputs--mic-btn",{"memori-chat-inputs--mic-btn--listening":h}),title:h?S("write_and_speak.micButtonPopoverListening")||"Listening":S("write_and_speak.micButtonPopover")||"Start listening",onClick:()=>{h?f():(p(),m())},disabled:C,"aria-label":h?S("write_and_speak.micButtonPopoverListening")||"Listening":S("write_and_speak.micButtonPopover")||"Start listening",children:(0,a.jsx)(cM,{className:"icon"})}),u&&"HOLD_TO_TALK"===d&&(0,a.jsx)(uM,{listening:h,startListening:m,stopListening:()=>{f(),h&&(null==n?void 0:n.length)&&o(n)},stopAudio:p}),(0,a.jsx)("button",{type:"button",className:t(We)("memori-chat-inputs--send-btn",{"memori-chat-inputs--send-btn--active":!!(null==n?void 0:n.length),"memori-chat-inputs--send-btn--disabled":!n||0===n.length}),onClick:()=>{(e=>{if(v)return;const t=e.map(((e,t)=>({mediumID:e.mediumID||`file_${Date.now()}_${t}_${Math.random().toString(36).substr(2,9)}`,mimeType:e.mimeType,content:e.content,title:e.name,properties:{isAttachedFile:!0},type:e.type,url:e.url})));o(n,t),I([]),p(),speechSynthesis.speak(new SpeechSynthesisUtterance(""))})(T)},disabled:!n||0===n.length||v,title:S("send")||"Send","aria-label":S("send")||"Send",children:v?(0,a.jsx)("div",{className:"memori-chat-inputs--send-btn--loading"}):(0,a.jsx)(lM,{className:"icon"})})]})})]})]})})};c=o("85Hg2");const IM=15,MM={en:[{delayAfter:IM,text:"Processing in progress..."},{delayAfter:IM,text:"I'm thinking..."},{delayAfter:IM,text:"Analysing the request..."},{delayAfter:IM,text:"Preparing the reply..."},{delayAfter:IM,text:"Gathering information..."},{delayAfter:IM,text:"Formulating ideas..."},{delayAfter:IM,text:"One moment please..."},{delayAfter:IM,text:"Almost ready..."},{delayAfter:IM,text:"Connecting concepts..."},{delayAfter:IM,text:"Organising ideas..."},{delayAfter:IM,text:"Evaluating options..."},{delayAfter:IM,text:"Looking for the best solution..."},{delayAfter:IM,text:"Working for you..."},{delayAfter:IM,text:"Please wait..."},{delayAfter:IM,text:"Processing data..."},{delayAfter:IM,text:"Calculating response..."},{delayAfter:IM,text:"Synthesising information..."},{delayAfter:IM,text:"Generating content..."},{delayAfter:IM,text:"Reflecting on question..."},{delayAfter:IM,text:"Refining the answer"}],it:[{delayAfter:IM,text:"Elaborazione in corso..."},{delayAfter:IM,text:"Sto pensando..."},{delayAfter:IM,text:"Analizzando la richiesta..."},{delayAfter:IM,text:"Preparando la risposta..."},{delayAfter:IM,text:"Raccogliendo informazioni..."},{delayAfter:IM,text:"Formulando idee..."},{delayAfter:IM,text:"Un momento per favore..."},{delayAfter:IM,text:"Quasi pronto..."},{delayAfter:IM,text:"Connettendo i concetti..."},{delayAfter:IM,text:"Organizzando le idee..."},{delayAfter:IM,text:"Valutando le opzioni..."},{delayAfter:IM,text:"Cercando la soluzione migliore..."},{delayAfter:IM,text:"Sto lavorando per te..."},{delayAfter:IM,text:"Attendere prego..."},{delayAfter:IM,text:"Elaborazione dati in corso..."},{delayAfter:IM,text:"Calcolando la risposta..."},{delayAfter:IM,text:"Sintetizzando informazioni..."},{delayAfter:IM,text:"Generando contenuti..."},{delayAfter:IM,text:"Sto riflettendo sulla domanda..."},{delayAfter:IM,text:"Perfezionando la risposta..."}]},CM=(e=15)=>new Array(20*e).fill(" ").join("");var NM=({useDefaultSentences:e=!1,lang:t="en",sentence:n,sentences:i})=>{var r;const[o,s]=(0,c.useState)(0),[l,u]=(0,c.useState)((null===(r=null==i?void 0:i[t])||void 0===r?void 0:r.length)?`${i[t][0].text.endsWith("...")||!i[t][0].text.length?i[t][0].text:`${i[t][0].text}...`}${CM(i[t][0].delayAfter)}`:n?`${n.endsWith("...")||!n.length?n:`${n}...`}${CM()}`:""),[d,h]=(0,c.useState)(""),[p,m]=(0,c.useState)(0);return(0,c.useEffect)((()=>{const r=setInterval((()=>{var r;m((e=>e+50));const a=l[d.length];if(void 0!==a&&l.length>0)h((e=>e+a));else if((null===(r=null==i?void 0:i[t])||void 0===r?void 0:r.length)&&o<i[t].length-1){const e=o+1,n=i[t][e];u(`${n.text.endsWith("...")||!n.text.length?n.text:`${n.text}...`}${CM(n.delayAfter)}`),h(""),s(e)}else if(!i&&!n&&(e||p>2e4)){const e=MM[t][Math.floor(Math.random()*MM[t].length)];u(`${e.text}${CM(e.delayAfter)}`),h("")}}),50);return()=>clearInterval(r)})),(0,a.jsx)("div",{className:"memori-chat--bubble",children:(0,a.jsxs)("div",{className:"memori-chat--bubble-typing",children:[(0,a.jsxs)("div",{id:"wave",children:[(0,a.jsx)("span",{className:"dot"}),(0,a.jsx)("span",{className:"dot"}),(0,a.jsx)("span",{className:"dot"})]}),l.length>0&&(0,a.jsx)("p",{children:d})]})})};NI=o("1Lq0j"),c=o("85Hg2");var OM=({className:e,title:t})=>(0,a.jsx)("svg",{...t?{}:{"aria-hidden":"true"},focusable:"false",role:"img",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",className:e,"aria-label":t,children:(0,a.jsx)("path",{d:"M9 18L15 12 9 6"})});c=o("85Hg2"),c=o("85Hg2");var RM=({className:e,title:t})=>(0,a.jsxs)("svg",{...t?{}:{"aria-hidden":"true"},"aria-label":t,className:e,viewBox:"0 -2 32 32",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:[(0,a.jsx)("title",{children:t}),(0,a.jsx)("desc",{children:"Created with Sketch Beta."}),(0,a.jsx)("defs",{}),(0,a.jsx)("g",{id:"Page-1",stroke:"none","stroke-width":"1",fill:"none","fill-rule":"evenodd",children:(0,a.jsx)("g",{id:"Icon-Set",transform:"translate(-100.000000, -205.000000)",fill:"#000000",children:(0,a.jsx)("path",{d:"M130,226 C130,227.104 129.104,228 128,228 L125.858,228 C125.413,226.278 123.862,225 122,225 L110,225 C108.138,225 106.587,226.278 106.142,228 L104,228 C102.896,228 102,227.104 102,226 L102,224 C102,222.896 102.896,222 104,222 L128,222 C129.104,222 130,222.896 130,224 L130,226 L130,226 Z M122,231 L110,231 C108.896,231 108,230.104 108,229 C108,227.896 108.896,227 110,227 L122,227 C123.104,227 124,227.896 124,229 C124,230.104 123.104,231 122,231 L122,231 Z M108,209 C108,207.896 108.896,207 110,207 L122,207 C123.104,207 124,207.896 124,209 L124,220 L108,220 L108,209 L108,209 Z M128,220 L126,220 L126,209 C126,206.791 124.209,205 122,205 L110,205 C107.791,205 106,206.791 106,209 L106,220 L104,220 C101.791,220 100,221.791 100,224 L100,226 C100,228.209 101.791,230 104,230 L106.142,230 C106.587,231.723 108.138,233 110,233 L122,233 C123.862,233 125.413,231.723 125.858,230 L128,230 C130.209,230 132,228.209 132,226 L132,224 C132,221.791 130.209,220 128,220 L128,220 Z",id:"print"})})})]});c=o("85Hg2"),c=o("85Hg2");class LM{constructor(){this.printWindow=null}static getInstance(){return LM.instance||(LM.instance=new LM),LM.instance}convertMarkdownToHTML(e){return(0,MI.marked)(e)}generatePDFCSS(e={}){const{margin:t={top:"1in",right:"1in",bottom:"1in",left:"1in"},fontSize:n="12pt",fontFamily:i="system-ui, -apple-system, sans-serif",lineHeight:r="1.6",color:o="#333",backgroundColor:a="#fff"}=e;return`\n <style>\n @page {\n margin: ${t.top} ${t.right} ${t.bottom} ${t.left};\n size: A4;\n }\n\n @media print {\n * {\n -webkit-print-color-adjust: exact !important;\n color-adjust: exact !important;\n }\n\n body {\n font-family: ${i};\n font-size: ${n};\n line-height: ${r};\n color: ${o};\n background-color: ${a};\n margin: 0;\n padding: 0;\n max-width: none;\n word-wrap: break-word;\n overflow-wrap: break-word;\n }\n\n h1, h2, h3, h4, h5, h6 {\n page-break-after: avoid;\n margin-top: 1.5em;\n margin-bottom: 0.5em;\n font-weight: 600;\n }\n\n h1 { font-size: 1.8em; }\n h2 { font-size: 1.5em; }\n h3 { font-size: 1.3em; }\n\n p {\n margin: 0 0 1em 0;\n orphans: 3;\n widows: 3;\n }\n\n pre, code {\n font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;\n font-size: 0.9em;\n background-color: #f5f5f5;\n border: 1px solid #ddd;\n border-radius: 3px;\n padding: 0.2em 0.4em;\n page-break-inside: avoid;\n }\n\n pre {\n padding: 1em;\n overflow-x: auto;\n white-space: pre;\n margin: 1em 0;\n }\n\n pre code {\n background: none;\n border: none;\n padding: 0;\n }\n\n blockquote {\n margin: 1em 0;\n padding-left: 1em;\n border-left: 3px solid #ddd;\n font-style: italic;\n page-break-inside: avoid;\n }\n\n ul, ol {\n margin: 1em 0;\n padding-left: 2em;\n }\n\n li {\n margin: 0.25em 0;\n page-break-inside: avoid;\n }\n\n table {\n border-collapse: collapse;\n width: 100%;\n margin: 1em 0;\n page-break-inside: avoid;\n }\n\n th, td {\n border: 1px solid #ddd;\n padding: 0.5em;\n text-align: left;\n }\n\n th {\n background-color: #f5f5f5;\n font-weight: 600;\n }\n\n a {\n color: #0066cc;\n text-decoration: none;\n }\n\n a:hover {\n text-decoration: underline;\n }\n\n img {\n max-width: 100%;\n height: auto;\n page-break-inside: avoid;\n }\n\n .page-break {\n page-break-before: always;\n }\n\n .no-print {\n display: none !important;\n }\n }\n\n @media screen {\n body {\n font-family: ${i};\n font-size: ${n};\n line-height: ${r};\n color: ${o};\n background-color: ${a};\n margin: 20px;\n padding: 20px;\n max-width: 800px;\n margin: 0 auto;\n }\n }\n </style>\n `}createPDFDocument(e,t="Artifact",n={}){const i=this.convertMarkdownToHTML(e);return`\n <!DOCTYPE html>\n <html lang="en">\n <head>\n <meta charset="UTF-8">\n <meta name="viewport" content="width=device-width, initial-scale=1.0">\n <title>${t}</title>\n ${this.generatePDFCSS(n)}\n </head>\n <body>\n <div class="content">\n ${i}\n </div>\n </body>\n </html>\n `}async exportAsPDFSafari(e,t="Artifact",n={}){return new Promise(((i,r)=>{try{const r=this.createPDFDocument(e,t,n),o=window.open("","_blank","width=800,height=600,scrollbars=yes,resizable=yes");if(!o){const e=`data:text/html;charset=utf-8,${encodeURIComponent(r)}`,n=document.createElement("a");return n.href=e,n.download=`${t}.html`,n.target="_blank",n.style.display="none",document.body.appendChild(n),n.click(),document.body.removeChild(n),void i()}o.document.open("text/html","replace"),o.document.write(r),o.document.close(),o.document.title=t,setTimeout((()=>{try{o.focus(),o.print(),setTimeout((()=>{o&&!o.closed&&o.close(),i()}),3e3)}catch(e){if(console.warn("Print failed, trying alternative:",e),o&&!o.closed){const e=o.document.createElement("div");e.style.cssText="\n position: fixed;\n top: 20px;\n left: 20px;\n right: 20px;\n background: #f0f8ff;\n border: 2px solid #0066cc;\n padding: 20px;\n border-radius: 8px;\n font-family: system-ui, sans-serif;\n z-index: 10000;\n box-shadow: 0 4px 12px rgba(0,0,0,0.15);\n ",e.innerHTML='\n <h3 style="margin: 0 0 10px 0; color: #0066cc;">📄 PDF Export Instructions</h3>\n <p style="margin: 0 0 10px 0;">To save as PDF:</p>\n <ol style="margin: 0 0 15px 0; padding-left: 20px;">\n <li>Press <strong>Cmd+P</strong> (Mac) or <strong>Ctrl+P</strong> (Windows)</li>\n <li>In the print dialog, click the "PDF" dropdown</li>\n <li>Select "Save as PDF"</li>\n <li>Choose your save location and click "Save"</li>\n </ol>\n <button onclick="this.parentElement.remove()" style="\n background: #0066cc;\n color: white;\n border: none;\n padding: 8px 16px;\n border-radius: 4px;\n cursor: pointer;\n ">Got it!</button>\n ',o.document.body.appendChild(e)}i()}}),1e3)}catch(e){r(new Error(`Safari PDF export failed: ${e}`))}}))}async exportAsPDF(e,t="Artifact",n={}){return ME()?this.exportAsPDFSafari(e,t,n):new Promise(((i,r)=>{try{this.printWindow&&!this.printWindow.closed&&this.printWindow.close();const o=CE()?"width=800,height=600,scrollbars=yes,resizable=yes":"width=800,height=600,scrollbars=yes,resizable=yes,toolbar=no,menubar=no,location=no,status=no";if(this.printWindow=window.open("","_blank",o),!this.printWindow)return void r(new Error("Popup blocked! Please enable popups to export PDF."));const a=this.createPDFDocument(e,t,n);ME()?(this.printWindow.document.open("text/html","replace"),this.printWindow.document.write(a),this.printWindow.document.close(),setTimeout((()=>{if(this.printWindow&&!this.printWindow.closed)try{this.printWindow.document.title=t,this.printWindow.focus(),this.printWindow.print(),setTimeout((()=>{this.printWindow&&!this.printWindow.closed&&this.printWindow.close(),i()}),2e3)}catch(e){console.warn("Print dialog failed, trying alternative method:",e),this.printWindow.print(),setTimeout((()=>{this.printWindow&&!this.printWindow.closed&&this.printWindow.close(),i()}),2e3)}}),1e3)):(this.printWindow.document.write(a),this.printWindow.document.close(),this.printWindow.onload=()=>{setTimeout((()=>{this.printWindow&&(this.printWindow.document.title=t,this.printWindow.print(),setTimeout((()=>{this.printWindow&&(this.printWindow.close(),i())}),1e3))}),500)},this.printWindow.onerror=e=>{r(new Error(`PDF export failed: ${e}`))})}catch(e){r(new Error(`PDF export failed: ${e}`))}}))}isSupported(){return"undefined"!=typeof window&&"function"==typeof window.open}isSafariSupported(){return ME()&&"undefined"!=typeof window&&"function"==typeof window.open}cleanup(){this.printWindow&&!this.printWindow.closed&&this.printWindow.close(),this.printWindow=null}}const PM=LM.getInstance(),DM=(e,n,i,r)=>{const{t:o}=Ve(),[a,s]=(0,c.useState)({isOpen:!1,loading:!1,success:!1,error:null,activeFormat:null}),l=(0,c.useCallback)((e=>{try{MI.marked.use({async:!1,gfm:!0,pedantic:!1,renderer:{link:({href:e,title:t,text:n})=>{if(!e)return n;return`<a href="${e.startsWith("http")?e:`https://${e}`}" target="_blank" rel="noopener noreferrer"${t?` title="${t}"`:""}>${n}</a>`}}});const n=MI.marked.parse(e).toString().trim();return t(CI).sanitize(n,{ADD_ATTR:["target","rel"],ALLOWED_TAGS:["h1","h2","h3","h4","h5","h6","p","br","strong","em","u","s","ul","ol","li","blockquote","pre","code","a","img","table","thead","tbody","tr","th","td","div","span"],ALLOWED_ATTR:["href","title","target","rel","src","alt","class","id"]})}catch(t){return console.error("Error rendering markdown:",t),e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\n/g,"<br>")}}),[]),u=(0,c.useMemo)((()=>{const t=[];switch(e.mimeType){case"markdown":t.push({id:"markdown",label:o("artifact.downloadAsMarkdown")||"Download as Markdown",description:o("artifact.downloadRawMarkdownText")||"Download raw markdown text",mimeType:"text/markdown",action:"download"},{id:"pdf",label:o("artifact.downloadAsPdf")||"Download as PDF",description:o("artifact.exportAsPdfDocument")||"Export as PDF document",mimeType:"application/pdf",action:"pdf",isAsync:!0});break;case"html":t.push({id:"html",label:o("artifact.downloadAsHtml")||"Download as HTML",description:o("artifact.downloadFormattedHtml")||"Download formatted HTML",mimeType:"text/html",action:"download"});break;case"json":t.push({id:"json",label:o("artifact.downloadAsJson")||"Download as JSON",description:o("artifact.downloadJsonData")||"Download JSON data",mimeType:"application/json",action:"download"});break;case"image/png":t.push({id:"png",label:o("artifact.downloadAsPng")||"Download as PNG",description:o("artifact.downloadPngImage")||"Download PNG image",mimeType:"image/png",action:"download"});break;case"image/jpeg":t.push({id:"jpeg",label:o("artifact.downloadAsJpeg")||"Download as JPEG",description:o("artifact.downloadJpegImage")||"Download JPEG image",mimeType:"image/jpeg",action:"download"});break;case"image/gif":t.push({id:"gif",label:o("artifact.downloadAsGif")||"Download as GIF",description:o("artifact.downloadGifImage")||"Download GIF image",mimeType:"image/gif",action:"download"});break;case"image/webp":t.push({id:"webp",label:o("artifact.downloadAsWebp")||"Download as WebP",description:o("artifact.downloadWebpImage")||"Download WebP image",mimeType:"image/webp",action:"download"});break;case"image/svg+xml":t.push({id:"svg",label:o("artifact.copyAsSvg")||"Copy as SVG",description:o("artifact.copySvgSourceCode")||"Copy SVG source code",mimeType:"image/svg+xml",action:"copy"},{id:"plain",label:o("artifact.copyAsPlainText")||"Copy as Plain Text",description:o("artifact.copyAsText")||"Copy as text",mimeType:"text/plain",action:"copy"});break;default:if(e.mimeType.startsWith("application/vnd.ant.code")){const n=e.mimeType.split(".").pop()||"text";t.push({id:"code",label:o("artifact.copyAsLanguage",{language:n.charAt(0).toUpperCase()+n.slice(1)})||`Copy as ${n.charAt(0).toUpperCase()+n.slice(1)}`,description:o("artifact.copyLanguageCode",{language:n})||`Copy ${n} code`,mimeType:e.mimeType,action:"copy"},{id:"plain",label:o("artifact.copyAsPlainText")||"Copy as Plain Text",description:o("artifact.copyWithoutSyntaxHighlighting")||"Copy without syntax highlighting",mimeType:"text/plain",action:"copy"})}else t.push({id:"text",label:o("artifact.copyAsText")||"Copy as Text",description:o("artifact.copyTextContent")||"Copy text content",mimeType:"text/plain",action:"copy"})}return t}),[e.mimeType,o]),d=(0,c.useCallback)((t=>{const{content:n}=e;switch(t.id){case"plain":return n.replace(/<[^>]*>/g,"").replace(/#{1,6}\s+/g,"").replace(/\*\*(.*?)\*\*/g,"$1").replace(/\*(.*?)\*/g,"$1").replace(/`([^`]+)`/g,"$1").replace(/```[\s\S]*?```/g,"").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").trim();case"html":case"markdown":case"svg":default:return n;case"raw":return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}}),[e.content]),h=(0,c.useCallback)((async e=>{if(navigator.clipboard&&window.isSecureContext)await navigator.clipboard.writeText(e);else{const t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.left="-999999px",t.style.top="-999999px",document.body.appendChild(t),t.focus(),t.select(),document.execCommand("copy"),document.body.removeChild(t)}}),[]),p=(0,c.useCallback)((async t=>{s((e=>({...e,loading:!0,error:null,activeFormat:t.id})));try{if("pdf"===t.action){if(!PM.isSupported())throw new Error(o("artifact.pdfExportNotSupported")||"PDF export is not supported in this browser");const t={title:e.title||"Artifact",fontSize:"12pt",fontFamily:"system-ui, -apple-system, sans-serif",lineHeight:"1.6",color:"#333",backgroundColor:"#fff"};try{await PM.exportAsPDF(e.content,e.title||"Artifact",t),null==r||r()}catch(e){if(ME())return s((e=>({...e,loading:!1,success:!0,error:null}))),setTimeout((()=>{s((e=>({...e,success:!1})))}),3e3),void(null==r||r());throw e}}else if("print"===t.action){const n=d(t),i=window.open("","_blank");if(!i)throw new Error(o("artifact.popupBlocked")||"Popup blocked! Please enable popups to print.");let a;if("markdown"===e.mimeType){const t=l(e.content);a=`\n <!DOCTYPE html>\n <html>\n <head>\n <title>${e.title||"Artifact"}</title>\n <style>\n body {\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;\n line-height: 1.6;\n color: #333;\n max-width: 800px;\n margin: 0 auto;\n padding: 20px;\n background-color: #fff;\n }\n h1, h2, h3, h4, h5, h6 {\n color: #2c3e50;\n margin-top: 1.5em;\n margin-bottom: 0.5em;\n }\n h1 { border-bottom: 2px solid #eee; padding-bottom: 10px; }\n h2 { border-bottom: 1px solid #eee; padding-bottom: 5px; }\n code {\n background-color: #f4f4f4;\n padding: 2px 4px;\n border-radius: 3px;\n font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;\n }\n pre {\n background-color: #f8f8f8;\n padding: 15px;\n border-radius: 5px;\n overflow-x: auto;\n border: 1px solid #e1e1e1;\n }\n pre code {\n background-color: transparent;\n padding: 0;\n }\n blockquote {\n border-left: 4px solid #ddd;\n margin: 0;\n padding-left: 20px;\n color: #666;\n }\n table {\n border-collapse: collapse;\n width: 100%;\n margin: 1em 0;\n }\n th, td {\n border: 1px solid #ddd;\n padding: 8px 12px;\n text-align: left;\n }\n th {\n background-color: #f5f5f5;\n font-weight: 600;\n }\n a {\n color: #007acc;\n text-decoration: none;\n }\n a:hover {\n text-decoration: underline;\n }\n ul, ol {\n padding-left: 20px;\n }\n img {\n max-width: 100%;\n height: auto;\n }\n @media print { \n body { margin: 0; } \n }\n </style>\n </head>\n <body>${t}</body>\n </html>\n `}else a=`\n <!DOCTYPE html>\n <html>\n <head>\n <title>${e.title||"Artifact"}</title>\n <style>\n body { \n font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace; \n white-space: pre-wrap; \n margin: 20px; \n line-height: 1.4;\n }\n @media print { \n body { margin: 0; } \n }\n </style>\n </head>\n <body>${n.replace(/</g,"&lt;").replace(/>/g,"&gt;")}</body>\n </html>\n `;i.document.write(a),i.document.close(),setTimeout((()=>{i.print(),i.close()}),500),null==r||r()}else if("download"===t.action){const n=d(t),r=new Blob([n],{type:t.mimeType}),o=URL.createObjectURL(r),a=document.createElement("a");let s=t.mimeType.split("/")[1];"x-python"===s?s="py":"x-java"===s?s="java":"x-c++"===s?s="cpp":"markdown"===s&&(s="md"),a.href=o,a.download=`${e.title||"Artifact"}.${s}`,a.click(),URL.revokeObjectURL(o),null==i||i()}else if("copy"===t.action){const e=d(t);await h(e),null==n||n()}s((e=>({...e,loading:!1,success:"copy"===t.action,error:null}))),"copy"===t.action&&setTimeout((()=>{s((e=>({...e,success:!1})))}),2e3)}catch(e){console.error("Copy operation failed:",e),s((t=>({...t,loading:!1,success:!1,error:e instanceof Error?e.message:"Copy operation failed"}))),setTimeout((()=>{s((e=>({...e,error:null})))}),3e3)}}),[e,d,h,n,r,o,l]),m=(0,c.useCallback)((async()=>{const e=d(u[0]);await h(e),s((e=>({...e,loading:!1,success:!0,error:null}))),null==n||n()}),[d,h,n,u]),f=(0,c.useCallback)((()=>{s((e=>({...e,isOpen:!e.isOpen,error:null})))}),[]),g=(0,c.useCallback)((()=>{s((e=>({...e,isOpen:!1})))}),[]),v=(0,c.useCallback)((()=>{s({isOpen:!1,loading:!1,success:!1,error:null,activeFormat:null})}),[]);return{copyState:a,formats:u,handleCopy:p,handleCopyClick:m,toggleDropdown:f,closeDropdown:g,resetState:v}};var kM=({className:e,title:t})=>(0,a.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,a.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 BM=({format:e,onClick:n,loading:i=!1,disabled:r=!1,active:o=!1})=>(0,a.jsx)("button",{type:"button",className:t(We)("memori-copy-menu-item",{"memori-copy-menu-item--loading":i,"memori-copy-menu-item--disabled":r,"memori-copy-menu-item--pdf":"pdf"===e.action,"memori-copy-menu-item--print":"print"===e.action,"memori-copy-menu-item--active":o,"memori-copy-menu-item--external":"link"===e.action,"memori-copy-menu-item--copy":"copy"===e.action,"memori-copy-menu-item--download":"download"===e.action}),onClick:()=>{r||i||n(e)},disabled:r||i,title:e.description,children:(0,a.jsxs)("div",{className:"memori-copy-menu-item-content",children:[(0,a.jsx)("div",{className:"memori-copy-menu-item-icon-wrapper",children:(()=>{if(i)return(0,a.jsx)("div",{className:"memori-copy-menu-item-loading",children:(0,a.jsx)("div",{className:"memori-copy-menu-item-spinner"})});switch(e.action){case"pdf":return(0,a.jsx)(kM,{className:"memori-copy-menu-item-icon"});case"print":return(0,a.jsx)(RM,{className:"memori-copy-menu-item-icon"});case"link":return(0,a.jsx)(jI,{className:"memori-copy-menu-item-icon"});default:return(0,a.jsx)(AI,{className:"memori-copy-menu-item-icon"})}})()}),(0,a.jsxs)("div",{className:"memori-copy-menu-item-text",children:[(0,a.jsx)("div",{className:"memori-copy-menu-item-label",children:e.label}),e.description&&(0,a.jsx)("div",{className:"memori-copy-menu-item-description",children:e.description})]}),e.isAsync&&(0,a.jsx)("div",{className:"memori-copy-menu-item-async-indicator",children:(0,a.jsx)("span",{className:"memori-copy-menu-item-async-badge",children:"PDF"})})]})});var FM=({className:e,title:t})=>(0,a.jsx)("svg",{fill:"#000000",xmlns:"http://www.w3.org/2000/svg",width:"800px",height:"800px",viewBox:"0 0 52 52",enableBackground:"new 0 0 52 52",xmlSpace:"preserve",...t?{}:{"aria-hidden":"true"},focusable:"false",role:"img",className:e,"aria-label":t,children:(0,a.jsx)("path",{d:"M47.6,17.8L27.1,38.5c-0.6,0.6-1.6,0.6-2.2,0L4.4,17.8c-0.6-0.6-0.6-1.6,0-2.2l2.2-2.2 c0.6-0.6,1.6-0.6,2.2,0l16.1,16.3c0.6,0.6,1.6,0.6,2.2,0l16.1-16.2c0.6-0.6,1.6-0.6,2.2,0l2.2,2.2C48.1,16.3,48.1,17.2,47.6,17.8z"})});var UM=({className:e,title:t})=>(0,a.jsx)("svg",{...t?{}:{"aria-hidden":"true"},focusable:"false",role:"img",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",tabIndex:-1,className:e,"aria-label":t,children:(0,a.jsx)("path",{d:"M14 9V5a3 3 0 00-3-3l-4 9v11h11.28a2 2 0 002-1.7l1.38-9a2 2 0 00-2-2.3zM7 22H4a2 2 0 01-2-2v-7a2 2 0 012-2h3"})});var zM=({className:e,title:t})=>(0,a.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,a.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 GM=({artifact:e,onCopy:n,onDownload:i,onPrint:r,onOpenExternal:o,loading:s=!1,className:l,disabled:u=!1})=>{const{copyState:d,formats:h,handleCopy:p,handleCopyClick:m}=DM(e,n,i,r),{t:f}=Ve(),g=async e=>{await p(e)},v=(0,c.useCallback)((e=>{try{MI.marked.use({async:!1,gfm:!0,pedantic:!1,renderer:{link:({href:e,title:t,text:n})=>{if(!e)return n;return`<a href="${e.startsWith("http")?e:`https://${e}`}" target="_blank" rel="noopener noreferrer"${t?` title="${t}"`:""}>${n}</a>`}}});const n=MI.marked.parse(e).toString().trim();return t(CI).sanitize(n,{ADD_ATTR:["target","rel"],ALLOWED_TAGS:["h1","h2","h3","h4","h5","h6","p","br","strong","em","u","s","ul","ol","li","blockquote","pre","code","a","img","table","thead","tbody","tr","th","td","div","span"],ALLOWED_ATTR:["href","title","target","rel","src","alt","class","id"]})}catch(t){return console.error("Error rendering markdown:",t),e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\n/g,"<br>")}}),[]),y=(0,c.useCallback)((e=>({html:"text/html",json:"application/json",markdown:"text/markdown",css:"text/css",javascript:"text/javascript",typescript:"text/typescript",svg:"image/svg+xml",xml:"text/xml",text:"text/plain",python:"text/x-python",java:"text/x-java",cpp:"text/x-c++",csharp:"text/x-csharp",php:"text/x-php",ruby:"text/x-ruby",go:"text/x-go",rust:"text/x-rust",yaml:"text/yaml",sql:"text/x-sql"}[e]||"text/plain")),[]),_=(0,c.useCallback)((()=>{try{const t=window.open("","_blank");if(!t)return void alert("Popup blocked! Please enable popups to print the artifact.");let n;n="html"===e.mimeType?e.content:`\n <!DOCTYPE html>\n <html>\n <head>\n <title>Artifact - ${e.mimeType.toUpperCase()}</title>\n <style>\n body { \n font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace; \n white-space: pre-wrap; \n margin: 20px; \n line-height: 1.4;\n }\n @media print { \n body { margin: 0; } \n }\n </style>\n </head>\n <body>${e.content.replace(/</g,"&lt;").replace(/>/g,"&gt;")}</body>\n </html>\n `,t.document.write(n),t.document.close(),setTimeout((()=>{t.print(),t.close()}),500),null==r||r()}catch(e){console.error("Print failed:",e)}}),[e,r]),b=(0,c.useCallback)((()=>{try{let t=e.content,n=y(e.mimeType);if("markdown"===e.mimeType){const i=v(e.content);t=`\n<!DOCTYPE html>\n<html lang="en">\n<head>\n <meta charset="UTF-8">\n <meta name="viewport" content="width=device-width, initial-scale=1.0">\n <title>${e.title||"Artifact"}</title>\n <style>\n body {\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;\n line-height: 1.6;\n color: #333;\n max-width: 800px;\n margin: 0 auto;\n padding: 20px;\n background-color: #fff;\n }\n h1, h2, h3, h4, h5, h6 {\n color: #2c3e50;\n margin-top: 1.5em;\n margin-bottom: 0.5em;\n }\n h1 { border-bottom: 2px solid #eee; padding-bottom: 10px; }\n h2 { border-bottom: 1px solid #eee; padding-bottom: 5px; }\n code {\n background-color: #f4f4f4;\n padding: 2px 4px;\n border-radius: 3px;\n font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;\n }\n pre {\n background-color: #f8f8f8;\n padding: 15px;\n border-radius: 5px;\n overflow-x: auto;\n border: 1px solid #e1e1e1;\n }\n pre code {\n background-color: transparent;\n padding: 0;\n }\n blockquote {\n border-left: 4px solid #ddd;\n margin: 0;\n padding-left: 20px;\n color: #666;\n }\n table {\n border-collapse: collapse;\n width: 100%;\n margin: 1em 0;\n }\n th, td {\n border: 1px solid #ddd;\n padding: 8px 12px;\n text-align: left;\n }\n th {\n background-color: #f5f5f5;\n font-weight: 600;\n }\n a {\n color: #007acc;\n text-decoration: none;\n }\n a:hover {\n text-decoration: underline;\n }\n ul, ol {\n padding-left: 20px;\n }\n img {\n max-width: 100%;\n height: auto;\n }\n </style>\n</head>\n<body>\n ${i}\n</body>\n</html>`,n="text/html"}const i=new Blob([t],{type:n}),r=URL.createObjectURL(i);if(!window.open(r,"_blank"))return void alert("Popup blocked! Please enable popups to open the artifact in a new window.");setTimeout((()=>{URL.revokeObjectURL(r)}),6e4),null==o||o()}catch(e){console.error("External open failed:",e)}}),[e,y,v,o]);return(0,a.jsx)("div",{className:"memori-copy-button-wrapper",children:(0,a.jsxs)("div",{className:"memori-copy-button-group",children:[(0,a.jsx)(Jl,{onClick:m,disabled:u||s||d.loading,className:t(We)("memori-copy-button memori-copy-button--main ",{"memori-copy-button--success":d.success,"memori-copy-button--error":d.error,"memori-copy-button--loading":d.loading},l),ghost:!0,title:d.success?"Copied successfully!":d.error?`Error: ${d.error}`:d.loading?"pdf"===d.activeFormat?"Generating PDF...":"Copying...":h.length>0?`Copy as ${h[0].label}`:"Copy",children:d.success?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(UM,{className:"memori-copy-button-icon memori-copy-button-icon--success"}),(0,a.jsx)("span",{className:"memori-copy-button-text",children:f("artifact.copied")||"Copied!"})]}):d.error?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(zM,{className:"memori-copy-button-icon memori-copy-button-icon--error"}),(0,a.jsx)("span",{className:"memori-copy-button-text",children:f("artifact.error")||"Error"})]}):d.loading?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"memori-copy-button-loading",children:(0,a.jsx)("div",{className:"memori-copy-button-spinner"})}),(0,a.jsx)("span",{className:"memori-copy-button-text",children:"pdf"===d.activeFormat?f("artifact.generatingPdf")||"Generating PDF...":f("artifact.copying")||"Copying..."})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(AI,{className:"memori-copy-button-icon"}),(0,a.jsx)("span",{className:"memori-copy-button-text",children:f("artifact.copy")||"Copy"})]})}),h.length>0&&(0,a.jsx)(yI,{as:"div",className:"memori-copy-menu-wrapper",children:()=>(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(yI.Button,{as:"div",className:"memori-copy-button-trigger",children:(0,a.jsx)(Jl,{disabled:u||s||d.loading,className:"memori-copy-button--dropdown",ghost:!0,title:"More copy options",children:(0,a.jsx)(FM,{className:"memori-copy-button-chevron"})})}),(0,a.jsx)(Os,{as:t(c).Fragment,enter:"memori-copy-dropdown-enter",enterFrom:"memori-copy-dropdown-enter-from",enterTo:"memori-copy-dropdown-enter-to",leave:"memori-copy-dropdown-leave",leaveFrom:"memori-copy-dropdown-leave-from",leaveTo:"memori-copy-dropdown-leave-to",children:(0,a.jsx)(yI.Items,{className:"memori-copy-dropdown",children:(0,a.jsx)("div",{className:"memori-copy-dropdown-content",children:(0,a.jsxs)("div",{className:"memori-copy-dropdown-list",children:[h.map((e=>(0,a.jsx)(yI.Item,{children:({active:t})=>(0,a.jsx)(BM,{format:e,onClick:g,loading:d.loading,active:t})},e.id))),(0,a.jsx)(BM,{format:{id:"external",label:f("artifact.external")||"External",action:"link",mimeType:e.mimeType},onClick:b,loading:d.loading,active:!1}),(0,a.jsx)(BM,{format:{id:"print",label:f("artifact.print")||"Print",action:"print",mimeType:e.mimeType},onClick:_,loading:d.loading,active:!1})]})})})})]})})]})})};var jM=({className:e,title:t,bold:n=!1})=>(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:800,height:800,fill:"none",viewBox:"0 0 24 24",className:e,"aria-label":t,children:(0,a.jsx)("path",{stroke:"#000",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:n?3:2,d:"M13 5a1 1 0 1 0-2 0 1 1 0 0 0 2 0ZM13 12a1 1 0 1 0-2 0 1 1 0 0 0 2 0ZM13 19a1 1 0 1 0-2 0 1 1 0 0 0 2 0Z"})});var HM=({artifact:e,onCopy:n,onDownload:i,onPrint:r,onOpenExternal:o,loading:s=!1,isMobile:l=!1})=>{const{t:u}=Ve(),d=((0,c.useCallback)((e=>({html:"html",json:"json",markdown:"md",css:"css",javascript:"js",typescript:"ts",svg:"svg",xml:"xml",text:"txt",python:"py",java:"java",cpp:"cpp",csharp:"cs",php:"php",ruby:"rb",go:"go",rust:"rs",yaml:"yml",sql:"sql"}[e]||"txt")),[]),(0,c.useCallback)((e=>({html:"text/html",json:"application/json",markdown:"text/markdown",css:"text/css",javascript:"text/javascript",typescript:"text/typescript",svg:"image/svg+xml",xml:"text/xml",text:"text/plain",python:"text/x-python",java:"text/x-java",cpp:"text/x-c++",csharp:"text/x-csharp",php:"text/x-php",ruby:"text/x-ruby",go:"text/x-go",rust:"text/x-rust",yaml:"text/yaml",sql:"text/x-sql"}[e]||"text/plain")),[])),h=(0,c.useCallback)((()=>{try{const t=window.open("","_blank");if(!t)return void alert("Popup blocked! Please enable popups to print the artifact.");let n;n="html"===e.mimeType?e.content:`\n <!DOCTYPE html>\n <html>\n <head>\n <title>Artifact - ${e.mimeType.toUpperCase()}</title>\n <style>\n body { \n font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace; \n white-space: pre-wrap; \n margin: 20px; \n line-height: 1.4;\n }\n @media print { \n body { margin: 0; } \n }\n </style>\n </head>\n <body>${e.content.replace(/</g,"&lt;").replace(/>/g,"&gt;")}</body>\n </html>\n `,t.document.write(n),t.document.close(),setTimeout((()=>{t.print(),t.close()}),500),null==r||r()}catch(e){console.error("Print failed:",e)}}),[e,r]),p=(0,c.useCallback)((()=>{try{const t=d(e.mimeType),n=new Blob([e.content],{type:t}),i=URL.createObjectURL(n);if(!window.open(i,"_blank"))return void alert("Popup blocked! Please enable popups to open the artifact in a new window.");setTimeout((()=>{URL.revokeObjectURL(i)}),6e4),null==o||o()}catch(e){console.error("External open failed:",e)}}),[e,d,o]);return(0,a.jsx)("div",{className:"memori-artifact-actions",children:(0,a.jsxs)("div",{className:"memori-artifact-actions-row",children:[(0,a.jsx)(GM,{artifact:e,onCopy:n,onDownload:i,onPrint:r,loading:s,className:"memori-artifact-action-btn"}),l&&(0,a.jsxs)(yI,{as:"div",className:"memori-copy-menu-wrapper",children:[(0,a.jsx)(yI.Button,{as:"div",className:"memori-copy-button-trigger",children:(0,a.jsx)(Jl,{disabled:s,className:t(We)("memori-button","memori-button--more-options","memori-button--icon-only"),ghost:!0,title:"More copy options",children:(0,a.jsx)(jM,{className:"memori-artifact-action-icon"})})}),(0,a.jsx)(Os,{as:t(c).Fragment,enter:"memori-copy-dropdown-enter",enterFrom:"memori-copy-dropdown-enter-from",enterTo:"memori-copy-dropdown-enter-to",leave:"memori-copy-dropdown-leave",leaveFrom:"memori-copy-dropdown-leave-from",leaveTo:"memori-copy-dropdown-leave-to",children:(0,a.jsx)(yI.Items,{className:"memori-copy-dropdown",style:{minWidth:"200px"},children:(0,a.jsxs)("div",{className:"memori-copy-dropdown-list",children:[(0,a.jsx)(Jl,{onClick:h,disabled:s,className:"memori-artifact-action-btn memori-artifact-action-btn--print",ghost:!0,icon:(0,a.jsx)(RM,{className:"memori-artifact-action-icon"}),title:u("artifact.print")||"Print",children:(0,a.jsx)("span",{className:"memori-artifact-action-text",children:u("artifact.print")||"Print"})}),(0,a.jsx)(Jl,{onClick:p,disabled:s,className:"memori-artifact-action-btn memori-artifact-action-btn--external",ghost:!0,icon:(0,a.jsx)(jI,{className:"memori-artifact-action-icon"}),title:u("artifact.external")||"External",children:(0,a.jsx)("span",{className:"memori-artifact-action-text",children:u("artifact.external")||"External"})})]})})})]})]})})};c=o("85Hg2");var VM=({artifact:e,activeTab:n})=>{const{t:i}=Ve(),r=(0,c.useCallback)((()=>{switch(e.mimeType){case"html":return(0,a.jsx)("iframe",{className:"memori-artifact-preview-iframe",srcDoc:e.content,style:{width:"100%",height:"100%",border:"none",borderRadius:"6px"},title:`${e.title} Preview`,scrolling:"auto"});case"markdown":return(0,a.jsx)("div",{className:"memori-artifact-preview-markdown",dangerouslySetInnerHTML:{__html:o(e.content)}});default:return(0,a.jsx)("div",{className:"memori-artifact-preview-text",dangerouslySetInnerHTML:{__html:e.content}})}}),[e]),o=(0,c.useCallback)((e=>e.replace(/^# (.*$)/gim,"<h1>$1</h1>").replace(/^## (.*$)/gim,"<h2>$1</h2>").replace(/^### (.*$)/gim,"<h3>$1</h3>").replace(/^#### (.*$)/gim,"<h4>$1</h4>").replace(/^##### (.*$)/gim,"<h5>$1</h5>").replace(/^###### (.*$)/gim,"<h6>$1</h6>").replace(/\*\*(.*?)\*\*/g,"<strong>$1</strong>").replace(/\*(.*?)\*/g,"<em>$1</em>").replace(/`(.*?)`/g,"<code>$1</code>").replace(/```([\s\S]*?)```/g,"<pre><code>$1</code></pre>").replace(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2" target="_blank" rel="noopener noreferrer">$1</a>').replace(/\n/g,"<br>")),[]),s=(0,c.useCallback)((e=>{switch(e){case"javascript":return"text/javascript";case"typescript":return"text/ecmascript";case"html":return"application/xml";case"css":return"text/css";case"json":return"application/json";case"python":return"text/x-python";case"bash":return"application/x-sh";case"cpp":case"csharp":return"text/x-c++src";case"php":return"application/x-php";case"sql":return"text/x-sql";case"ruby":return"text/x-ruby";default:return"text/plain"}}),[]),l="html"===e.mimeType||"markdown"===e.mimeType||"svg"===e.mimeType;return(0,a.jsx)("div",{className:"memori-artifact-preview",children:(0,a.jsxs)("div",{className:"memori-artifact-content",children:[(0,a.jsx)("div",{className:t(We)("memori-artifact-tab-content",{"memori-artifact-tab-content--active":"code"===n||!l}),children:(0,a.jsx)("div",{className:"memori-artifact-code",children:(0,a.jsx)(zI,{showCopyButton:!1,medium:{mediumID:e.id,mimeType:s(e.mimeType),content:e.content,title:e.title,creationTimestamp:e.timestamp.toISOString(),creationName:"System",lastChangeTimestamp:e.timestamp.toISOString(),lastChangeName:"System"}})})}),l&&(0,a.jsx)("div",{className:t(We)("memori-artifact-tab-content",{"memori-artifact-tab-content--active":"preview"===n}),children:(0,a.jsx)("div",{className:"memori-artifact-preview-content",children:r()})})]})})};const WM=({className:e})=>(0,a.jsxs)("svg",{className:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,a.jsx)("path",{d:"M1 12C1 12 5 4 12 4C19 4 23 12 23 12C23 12 19 20 12 20C5 20 1 12 1 12Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),(0,a.jsx)("circle",{cx:"12",cy:"12",r:"3",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]});var qM=({activeTab:e,onTabChange:n,hasPreview:i})=>{const r=[{id:"code",icon:TI},...i?[{id:"preview",icon:WM}]:[]];return(0,a.jsx)("div",{className:"memori-tab-switch",children:(0,a.jsx)("div",{className:"memori-tab-switch__container",children:(0,a.jsxs)("div",{className:"memori-tab-switch__track",style:{"--tab-count":r.length},children:[(0,a.jsx)("div",{className:"memori-tab-switch__indicator",style:{"--active-index":r.findIndex((t=>t.id===e))}}),r.map((i=>{const r=i.icon;return(0,a.jsx)("button",{type:"button",className:t(We)("memori-tab-switch__button",{"memori-tab-switch__button--active":e===i.id}),onClick:()=>n(i.id),"aria-pressed":e===i.id,children:(0,a.jsx)(r,{className:"memori-tab-switch__icon"})},i.id)}))]})})})};var $M=({isChatLogPanel:e=!1})=>{const{state:n,closeArtifact:i,toggleFullscreen:r}=re(),{t:o}=Ve(),[s,l]=(0,c.useState)(!1),[u,d]=(0,c.useState)("preview"),h=(0,c.useCallback)((e=>{d(e)}),[u]),{copyState:p,formats:m,handleCopy:f,handleCopyClick:g}=DM(n.currentArtifact||{content:"",mimeType:"text/plain"},(()=>console.log("Copy completed")),(()=>console.log("Download completed")),(()=>console.log("Print completed")));(0,c.useEffect)((()=>{const e=()=>{l(window.innerWidth<=768)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)}),[]);const v=(0,c.useCallback)((async()=>{if(n.currentArtifact)try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(n.currentArtifact.content);else{const e=document.createElement("textarea");e.value=n.currentArtifact.content,e.style.position="fixed",e.style.left="-999999px",e.style.top="-999999px",document.body.appendChild(e),e.focus(),e.select(),document.execCommand("copy"),document.body.removeChild(e)}}catch(e){throw console.error("Copy failed:",e),e}}),[n.currentArtifact]),y=((0,c.useCallback)((()=>{r&&r()}),[r]),(0,c.useCallback)((()=>{i()}),[i]));if(!n.currentArtifact)return null;const _="html"===n.currentArtifact.mimeType||"markdown"===n.currentArtifact.mimeType,b=(0,c.useCallback)((({children:t})=>e?(0,a.jsx)("div",{style:{minHeight:"75vh",maxHeight:"75vh"},className:"memori-artifact-panel",children:t}):(0,a.jsx)(Ql,{open:n.isDrawerOpen,onClose:y,placement:"right",width:"50%",className:n.isFullscreen?"memori-artifact-panel-drawer-fullscreen":"memori-artifact-panel-drawer",widthMd:"100%",widthLg:"50%",closable:!1,animated:!0,enterDuration:s?"duration-500":"duration-300",leaveDuration:s?"duration-400":"duration-200",showBackdrop:!1,preventBackdropClose:!0,confirmDialogTitle:o("artifact.confirmDialogTitle")||"Are you sure you want to close this artifact?",confirmDialogMessage:o("artifact.confirmDialogMessage")||"This action cannot be undone.",children:t})),[e,y,n.isDrawerOpen,n.isFullscreen,s]),x=(0,c.useCallback)((e=>({html:"text/html",json:"application/json",markdown:"text/markdown",css:"text/css",javascript:"text/javascript",typescript:"text/typescript",svg:"image/svg+xml",xml:"text/xml",text:"text/plain",python:"text/x-python",java:"text/x-java",cpp:"text/x-c++",csharp:"text/x-csharp",php:"text/x-php",ruby:"text/x-ruby",go:"text/x-go",rust:"text/x-rust",yaml:"text/yaml",sql:"text/x-sql"}[e]||"text/plain")),[]),w=(0,c.useCallback)((e=>{try{const t=x(e.mimeType),n=new Blob([e.content],{type:t}),i=URL.createObjectURL(n);if(!window.open(i,"_blank"))return void alert("Popup blocked! Please enable popups to open the artifact in a new window.");setTimeout((()=>{URL.revokeObjectURL(i)}),6e4)}catch(e){console.error("External open failed:",e)}}),[]);return(0,a.jsxs)(b,{children:[(0,a.jsx)("div",{className:t(We)("memori-artifact-drawer-container-actions",{"memori-artifact-drawer-container-actions--no-preview":!_,"memori-artifact-drawer-container-actions--chatlog":e}),children:!s&&(0,a.jsxs)(a.Fragment,{children:[_&&(0,a.jsx)(qM,{activeTab:u,onTabChange:h,hasPreview:_}),(0,a.jsx)(HM,{artifact:n.currentArtifact,onCopy:v,loading:!1,isMobile:s}),(0,a.jsx)(Jl,{onClick:i,className:t(We)("memori-artifact-drawer--close","memori-button--icon-only",{"memori-artifact-drawer--close-desktop":!_}),ghost:!0,title:o("artifact.close")||"Close",children:(0,a.jsx)(Zl,{className:"memori-artifact-panel--close-icon"})})]})}),(0,a.jsxs)("div",{className:t(We)("memori-artifact-drawer-top-right",{"memori-artifact-drawer-top-right--no-preview":!_,"memori-artifact-drawer-top-right--chatlog":e}),children:[s&&(0,a.jsxs)(a.Fragment,{children:[_&&(0,a.jsx)(qM,{activeTab:u,onTabChange:h,hasPreview:_}),(0,a.jsxs)(yI,{as:"div",className:"memori-mobile-actions-menu",children:[(0,a.jsx)(yI.Button,{as:"div",className:"memori-mobile-actions-trigger",children:(0,a.jsx)(Jl,{className:t(We)("memori-button","memori-button--more-options","memori-button--icon-only"),ghost:!0,title:o("artifact.actions")||"Actions",children:(0,a.jsx)(jM,{className:"memori-artifact-action-icon"})})}),(0,a.jsx)(Os,{as:t(c).Fragment,enter:"memori-mobile-dropdown-enter",enterFrom:"memori-mobile-dropdown-enter-from",enterTo:"memori-mobile-dropdown-enter-to",leave:"memori-mobile-dropdown-leave",leaveFrom:"memori-mobile-dropdown-leave-from",leaveTo:"memori-mobile-dropdown-leave-to",children:(0,a.jsx)(yI.Items,{className:"memori-mobile-dropdown",children:(0,a.jsxs)("div",{className:"memori-mobile-dropdown-list",children:[(0,a.jsx)(Jl,{onClick:v,disabled:!1,className:"memori-artifact-action-btn",ghost:!0,title:o("artifact.copy")||"Copy",children:(0,a.jsx)("span",{className:"memori-artifact-action-text",children:o("artifact.copy")||"Copy"})}),m.map((e=>(0,a.jsx)(Jl,{onClick:()=>f(e),disabled:p.loading&&p.activeFormat===e.id,className:"memori-artifact-action-btn",ghost:!0,icon:(()=>{switch(e.action){case"copy":default:return(0,a.jsx)(jI,{className:"memori-artifact-action-icon"});case"download":return(0,a.jsx)(kM,{className:"memori-artifact-action-icon"});case"print":case"pdf":return(0,a.jsx)(RM,{className:"memori-artifact-action-icon"})}})(),title:e.label,children:(0,a.jsx)("span",{className:"memori-artifact-action-text",children:e.label})},e.id))),(0,a.jsx)(Jl,{onClick:()=>{var e;return w(null!==(e=n.currentArtifact)&&void 0!==e?e:{content:"",mimeType:"",title:"",timestamp:new Date,size:0,id:""})},disabled:!1,className:"memori-artifact-action-btn",ghost:!0,icon:(0,a.jsx)(jI,{className:"memori-artifact-action-icon"}),title:o("artifact.external")||"External",children:(0,a.jsx)("span",{className:"memori-artifact-action-text",children:o("artifact.external")||"External"})})]})})})]})]}),s&&(0,a.jsx)(Jl,{onClick:i,className:t(We)("memori-artifact-drawer--close","memori-button--icon-only"),ghost:!0,title:o("artifact.close")||"Close",children:(0,a.jsx)(Zl,{className:"memori-artifact-panel--close-icon"})})]}),(0,a.jsx)("div",{className:"memori-artifact-panel--header"}),(0,a.jsx)("div",{className:"memori-artifact-panel--content",children:(0,a.jsx)("div",{className:"memori-artifact-panel--main",children:(0,a.jsx)(VM,{artifact:n.currentArtifact,activeTab:u})})})]})};var YM=({className:e,title:t})=>(0,a.jsx)("svg",{...t?{}:{"aria-hidden":"true"},focusable:"false",role:"img",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",className:e,"aria-label":t,children:(0,a.jsx)("path",{d:"M15 18L9 12 15 6"})});var JM=({className:e,title:t})=>(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",xmlSpace:"preserve",width:800,height:800,viewBox:"0 0 52 52",...t?{}:{"aria-hidden":"true"},focusable:"false",role:"img",className:e,"aria-label":t,children:(0,a.jsx)("path",{d:"m4.4 34.2 20.5-20.7c.6-.6 1.6-.6 2.2 0l20.5 20.7c.6.6.6 1.6 0 2.2l-2.2 2.2c-.6.6-1.6.6-2.2 0L27.1 22.2c-.6-.6-1.6-.6-2.2 0L8.8 38.5c-.6.6-1.6.6-2.2 0l-2.2-2.2c-.5-.6-.5-1.5 0-2.1z"})});const ZM=e=>{if(0===e)return"0 Bytes";const t=Math.floor(Math.log(e)/Math.log(1024));return parseFloat((e/Math.pow(1024,t)).toFixed(2))+" "+["Bytes","KB","MB"][t]};var XM=(0,c.memo)((({isChatlogPanel:e=!1,message:n})=>{var i;const{openArtifact:r,state:o,closeArtifact:s}=re(),l=(0,c.useMemo)((()=>n.translatedText||n.text||""),[n.translatedText,n.text]),u=(0,c.useMemo)((()=>`${n.timestamp}-${n.fromUser}`),[n.timestamp,n.fromUser]),d=(0,c.useCallback)((e=>{const t=new CustomEvent("artifactCreated",{detail:{artifact:e,message:n}});document.dispatchEvent(t)}),[n]),h=(0,c.useCallback)(((e,t)=>{if(!e||t)return[];e=BE(e);const n=[],i=/<output\s+class="memori-artifact"[^>]*data-mimetype="([^"]+)"[^>]*>([\s\S]*?)<\/output>/gi,r=(e,t,n)=>{const i=n.match(/data-title\s*=\s*["\']([^"']+)["\']/i);if(i)return i[1];const r=t.match(/<title>([^<]+)<\/title>/i);return r?r[1]:`${e.toUpperCase()} Artifact`};let o,a=0;for(;null!==(o=i.exec(e));){a++;const e=o[1],t=o[2].trim(),i=o[0],s={id:`artifact-${Date.now()}-${a}-${Math.random().toString(36).substr(2,9)}`,content:t,mimeType:e,title:r(e,t,i),timestamp:new Date,size:t.length};n.push(s)}return n}),[]),p=(0,c.useMemo)((()=>h(l,n.fromUser||!1)),[l,n.fromUser,h]);(0,c.useEffect)((()=>{l.length>0&&p.length>0&&(p.forEach((e=>{d(e)})),e||setTimeout((()=>{r(p[0])}),100))}),[u,p,d,e,r]);const m=(0,c.useCallback)((e=>{var t;o.isDrawerOpen&&(null===(t=o.currentArtifact)||void 0===t?void 0:t.id)===e.id?s():r(e)}),[o.isDrawerOpen,null===(i=o.currentArtifact)||void 0===i?void 0:i.id,s,r]),f=(0,c.useCallback)((e=>e.includes("html")?"🌐":e.includes("markdown")?"📝":e.includes("javascript")||e.includes("typescript")?"📜":e.includes("python")?"🐍":e.includes("json")?"📊":e.includes("css")?"🎨":e.includes("xml")?"📋":e.includes("svg")?"🖼️":"📄"),[]);return 0===p.length?null:(0,a.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:p.map((n=>{var i,r,s,l;const u=o.isDrawerOpen&&(null===(i=o.currentArtifact)||void 0===i?void 0:i.id)===n.id;return(0,a.jsxs)(t(c).Fragment,{children:[(0,a.jsxs)("div",{className:"memori-artifact-handler"+(u?" memori-artifact-handler--selected":""),onClick:()=>m(n),style:u?{border:"2px solid var(--memori-primary, #3b82f6)",boxShadow:"0 0 0 3px rgba(59, 130, 246, 0.1)"}:void 0,children:[(0,a.jsx)("div",{className:"memori-artifact-handler-icon",children:f(n.mimeType)}),(0,a.jsxs)("div",{className:"memori-artifact-handler-info",children:[(0,a.jsx)("div",{className:"memori-artifact-handler-title",children:n.title}),(0,a.jsxs)("div",{className:"memori-artifact-handler-meta",children:[n.mimeType," •"," ",ZM(n.size||0)]})]}),(0,a.jsx)("div",{className:"memori-artifact-handler-action",children:e?o.isDrawerOpen&&(null===(r=o.currentArtifact)||void 0===r?void 0:r.id)===n.id?(0,a.jsx)(JM,{className:"memori-artifact-handler-action-icon"}):(0,a.jsx)(FM,{className:"memori-artifact-handler-action-icon"}):o.isDrawerOpen&&(null===(s=o.currentArtifact)||void 0===s?void 0:s.id)===n.id?(0,a.jsx)(YM,{className:"memori-artifact-handler-action-icon"}):(0,a.jsx)(OM,{className:"memori-artifact-handler-action-icon"})})]}),o.isDrawerOpen&&(null===(l=o.currentArtifact)||void 0===l?void 0:l.id)===n.id&&(0,a.jsx)($M,{isChatLogPanel:e})]},n.id)}))})}),((e,t)=>{const n=e.message.translatedText||e.message.text||"",i=t.message.translatedText||t.message.text||"";return e.isChatlogPanel===t.isChatlogPanel&&n===i&&e.message.fromUser===t.message.fromUser&&e.message.timestamp===t.message.timestamp}));var KM=(0,c.memo)((({memori:e,tenant:n,sessionID:i,baseUrl:r,apiUrl:o,client:s,translateTo:l,memoriTyping:u,typingText:d,showTypingText:h=!1,history:p=[],authToken:m,dialogState:f,simulateUserPrompt:g,showDates:v=!1,showContextPerLine:y=!1,showAIicon:_=!0,showWhyThisAnswer:b=!0,showCopyButton:x=!0,showTranslationOriginal:w=!1,showReasoning:S=!1,preview:E=!1,instruct:A=!1,showInputs:T=!0,showMicrophone:I=!1,microphoneMode:M="HOLD_TO_TALK",sendOnEnter:C,setSendOnEnter:N,attachmentsMenuOpen:O,setAttachmentsMenuOpen:R,userMessage:L="",onChangeUserMessage:P,sendMessage:D,listening:k,setEnableFocusChatInput:B,isPlayingAudio:F,stopAudio:U,startListening:z,stopListening:G,customMediaRenderer:j,user:H,userAvatar:V,showUpload:W=!1,experts:q,useMathFormatting:$=!1,isHistoryView:Y=!1,isChatlogPanel:J=!1,showFunctionCache:Z=!1})=>{var X,K,Q,ee,te,ne,ie,re;const[oe,ae]=(0,c.useState)(!1),[se,le]=(0,c.useState)(!1),{t:ce}=Ve(),ue=()=>{Y||setTimeout((()=>{var e,t;let n=document.querySelectorAll(".memori-chat-scroll-item");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)((()=>{!E&&!Y&&ue()}),[p,E,Y]);return(0,c.useEffect)((()=>{if(!W)return;let e=0;const t=document.getElementById("chat-wrapper"),n=t=>{var n;(null===(n=t.dataTransfer)||void 0===n?void 0:n.types.includes("Files"))&&(e++,1===e&&le(!0))},i=t=>{var n;(null===(n=t.dataTransfer)||void 0===n?void 0:n.types.includes("Files"))&&(e--,0===e&&le(!1))},r=e=>{var t;(null===(t=e.dataTransfer)||void 0===t?void 0:t.types.includes("Files"))&&e.preventDefault()},o=t=>{var n;(null===(n=t.dataTransfer)||void 0===n?void 0:n.types.includes("Files"))&&(e=0,le(!1))};return t&&(t.addEventListener("dragenter",n),t.addEventListener("dragleave",i),t.addEventListener("dragover",r),t.addEventListener("drop",o)),()=>{t&&(t.removeEventListener("dragenter",n),t.removeEventListener("dragleave",i),t.removeEventListener("dragover",r),t.removeEventListener("drop",o))}}),[W]),(0,a.jsxs)("div",{className:t(We)("memori-chat--wrapper",{"memori-chat-wrapper--translate":l,"memori-chat-wrapper--expanded":oe,"memori-chat-wrapper--dragging":se}),id:"chat-wrapper",lang:null==l?void 0:l.toUpperCase(),"data-memori-lang":null!==(ee=null===(Q=null===(K=null===(X=e.culture)||void 0===X?void 0:X.split("-"))||void 0===K?void 0:K[0])||void 0===Q?void 0:Q.toUpperCase())&&void 0!==ee?ee:"EN",children:[se&&(0,a.jsxs)("div",{className:"memori-chat--drag-overlay",children:[(0,a.jsx)(pM,{className:"memori-chat--drag-overlay-icon"}),(0,a.jsx)("span",{className:"memori-chat--drag-overlay-text",children:null!==(te=ce("upload.dragAndDropFiles"))&&void 0!==te?te:"Drag and drop files here to add them to the chat"})]}),(0,a.jsx)("div",{className:t(We)("memori-chat--history",{"memori-chat--history-touch":IE()}),children:(0,a.jsxs)("div",{className:t(We)("memori-chat--content",{"memori-chat--content-touch":IE()}),children:[(0,a.jsx)("div",{className:t(We)("memori-chat--cover"),style:{backgroundImage:`url("${KT({type:"cover",tenantID:null==n?void 0:n.name,resourceURI:e.coverURL,baseURL:r,apiURL:o})}"), url("${KT({type:"cover",tenantID:null==n?void 0:n.name,baseURL:r||"https://www.aisuru.com",apiURL:o})}")`}}),p.map(((u,d)=>{var h,m,E,A,T;return(0,a.jsxs)(t(c).Fragment,{children:[(0,a.jsx)(aM,{isFirst:0===d,message:u,memori:e,tenant:n,client:s,baseUrl:r,apiUrl:o,sessionID:i,simulateUserPrompt:g,showAIicon:_,showWhyThisAnswer:b,showTranslationOriginal:w,showFeedback:d===p.length-1&&!u.fromUser&&(null==f?void 0:f.acceptsFeedback),user:H,userAvatar:V,experts:q,showCopyButton:x,useMathFormatting:$,showFunctionCache:Z,showReasoning:S},`chatbubble-${d}-${(null===(h=u.text)||void 0===h?void 0:h.includes("<document_attachment"))?"has-attachments":"no-attachments"}-${u.timestamp}`),v&&!!u.timestamp&&(0,a.jsx)("small",{className:"memori-chat--timestamp "+(u.fromUser?"text-right":"text-left"),children:new Intl.DateTimeFormat("it",{hour:"2-digit",minute:"2-digit",second:"2-digit"}).format(new Date(u.timestamp.endsWith("Z")?u.timestamp:`${u.timestamp}Z`))}),y&&!!Object.keys(null!==(m=u.contextVars)&&void 0!==m?m:{}).length&&(0,a.jsx)("div",{className:"memori-chat--context-vars",children:Object.keys(null!==(E=u.contextVars)&&void 0!==E?E:{}).map((e=>{var t,n,i;return"-"===(null===(t=u.contextVars)||void 0===t?void 0:t[e])?(0,a.jsx)("div",{className:"memori-chat--context-tag memori-chat--context-tag-canceled",children:(0,a.jsx)("span",{className:"memori-chat--context-tag-text",children:e})},e):"✔️"===(null===(n=u.contextVars)||void 0===n?void 0:n[e])?(0,a.jsx)("div",{className:"memori-chat--context-tag",children:(0,a.jsx)("span",{className:"memori-chat--context-tag-text",children:e})},e):(0,a.jsx)("div",{className:"memori-chat--context-tag",children:(0,a.jsxs)("span",{className:"memori-chat--context-tag-text",children:[e,": ",null===(i=u.contextVars)||void 0===i?void 0:i[e]]})},e)}))}),(0,a.jsx)(iM,{simulateUserPrompt:g,media:[...(null===(A=null==u?void 0:u.media)||void 0===A?void 0:A.filter((e=>{var t;return!(null===(t=e.properties)||void 0===t?void 0:t.functionSignature)})))||[],...(()=>{const e=u.translatedText||u.text,t=/<document_attachment filename="([^"]+)" type="([^"]+)">([\s\S]*?)<\/document_attachment>/g,n=[];let i,r=0;for(;null!==(i=t.exec(e));){const[,e,t,o]=i;n.push({mediumID:`doc_${Date.now()}_${r}_${Math.random().toString(36).substr(2,9)}`,url:"",mimeType:t,title:e,content:o.trim(),properties:{isDocumentAttachment:!0},type:"document"}),r++}return n})()],sessionID:i,baseUrl:r,apiUrl:o,translateTo:l,customMediaRenderer:j,fromUser:u.fromUser}),!Y&&!u.fromUser&&(0,a.jsx)(XM,{isChatlogPanel:J,message:u})]},`${d}-${(null===(T=u.text)||void 0===T?void 0:T.includes("<document_attachment"))?"has-attachments":"no-attachments"}-${u.timestamp}`)})),(null==f?void 0:f.hints)&&f.hints.length>0&&!u&&(0,a.jsx)(iM,{simulateUserPrompt:g,hints:f.translatedHints?f.translatedHints:f.hints.map((e=>({text:e,originalText:e})))}),!!u&&(0,a.jsx)(NM,{useDefaultSentences:h,lang:l?"it"===l.toLowerCase()?"it":"en":"it"===(null===(re=null===(ie=null===(ne=e.culture)||void 0===ne?void 0:ne.split("-"))||void 0===ie?void 0:ie[0])||void 0===re?void 0:re.toLowerCase())?"it":"en",sentence:d,sentences:e.enableBoardOfExperts?NI.boardOfExpertsLoadingSentences:void 0},d),(0,a.jsx)("div",{id:"end-messages-ref"})]})}),T&&(0,a.jsx)(TM,{userMessage:L,onChangeUserMessage:P,dialogState:f,instruct:A,authToken:m,sendMessage:D,isTyping:u,microphoneMode:M,sendOnEnter:C,setSendOnEnter:N,client:s,sessionID:i,showUpload:W,attachmentsMenuOpen:O,setAttachmentsMenuOpen:R,onTextareaFocus:()=>{G();IE()&&B(!0)},onTextareaBlur:()=>{var e,t,n,i,r;(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===(r=null===(i=document.querySelector(".memori.memori-widget"))||void 0===i?void 0:i.classList)||void 0===r||r.remove("chat-focused"),ue())},onTextareaExpanded:e=>{ae(e)},startListening:z,stopListening:G,stopAudio:U,listening:k,isPlayingAudio:F,showMicrophone:I,memoriID:null==e?void 0:e.memoriID})]})}));c=o("85Hg2"),NI=o("1Lq0j");var QM=({className:e,title:t})=>(0,a.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,a.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 eC=({memoriName:e,blockedUntil:t,notEnoughCredits:n=!1,showGiverInfo:i=!1,showTitle:r=!1,marginLeft:o=!1})=>{const{t:s}=Ve(),l=new Date(t||Date.now());return n||l>new Date(Date.now())?(0,a.jsx)(nI,{className:"blocked-memori-badge--tooltip",content:n?(0,a.jsx)(a.Fragment,{children:s("notEnoughCredits")}):(0,a.jsxs)(a.Fragment,{children:[!i&&s("memoriBlockedAnon",{name:e,date:new Intl.DateTimeFormat("it",{day:"numeric",month:"long",year:"numeric"}).format(l)}),i&&s("memoriBlockedUntil",{date:new Intl.DateTimeFormat("it",{day:"numeric",month:"long",year:"numeric"}).format(l)}),i&&` ${s("memoriBlockedReasonExceedChats")}`,i&&(0,a.jsx)("br",{}),i&&`\n${s("memoriBlockedGiverHelper")}`]}),children:(0,a.jsxs)("div",{className:"blocked-memori-badge--wrapper",children:[(0,a.jsx)("div",{className:"blocked-memori-badge "+(o?" margin-left":""),children:(0,a.jsx)(QM,{className:"blocked-memori-badge--icon"})}),r&&(0,a.jsx)("span",{className:"blocked-memori-badge--title",children:s("memoriBlockedTitle")})]})}):null};var tC=({className:e,title:t})=>(0,a.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,a.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 nC=({className:e,title:t})=>(0,a.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,a.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,a.jsx)("path",{d:"M27.917 12L31.417 12"}),(0,a.jsx)("path",{d:"M27.917 26L31.417 26"}),(0,a.jsx)("path",{d:"M29.667 12L29.667 26"}),(0,a.jsx)("path",{d:"M23.992 26L19.904 12 19.226 12 15.159 26"}),(0,a.jsx)("path",{d:"M16.854 21.133L22.276 21.133"})]});c=o("85Hg2");var iC=({className:e,title:t})=>(0,a.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,a.jsx)("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"1.5"}),(0,a.jsx)("path",{d:"M12 17V11",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),(0,a.jsx)("circle",{cx:"1",cy:"1",r:"1",transform:"matrix(1 0 0 -1 11 9)",fill:"currentColor"})]});const rC={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 oC=({forceStatus:e,provider:t="Anthropic"})=>{const{t:n}=Ve(),[i,r]=(0,c.useState)(null!=e?e:"operational"),[o,s]=(0,c.useState)(!1),l=rC[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.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){s(!0);try{const e=await u();t&&r(e)}catch(e){console.error("Failed to check status:",e),t&&r("operational")}finally{t&&s(!1)}}})(),()=>{t=!1,n.abort()}}),[e,u]),o)return(0,a.jsx)("div",{className:"memori--completion-provider-status--loading",children:(0,a.jsx)(Yl,{spinning:!0})});if(!i||"operational"===i)return null;const{Icon:d,message:h,className:p}=(()=>{switch(i){case"major_outage":return{Icon:zM,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:QM,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:iC,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,a.jsx)(nI,{className:"memori--completion-provider-status--tooltip",align:"right",content:(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{children:h}),(null==l?void 0:l.statusPage)&&(0,a.jsx)("p",{children:(0,a.jsx)("a",{href:l.statusPage,rel:"noopener noreferrer",target:"_blank",children:n("completionProviderCheckStatusPage")})})]}),children:(0,a.jsx)(d,{className:`memori--completion-provider-status--icon ${p}`})})};var aC=({className:e,title:t})=>(0,a.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,a.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 sC=({memori:e,tenant:t,language:n,userLang:i,setUserLang:r,baseUrl:o,apiUrl:s,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:b,notEnoughCredits:x=!1,isMultilanguageEnabled:w})=>{var S,E,A,T;const{t:I,i18n:M}=Ve(),[C,N]=(0,c.useState)(e.description),[O,R]=(0,c.useState)(!0);return(0,c.useEffect)((()=>{var t,i,r,a,s,l;(null!==(i=null===(t=M.language)||void 0===t?void 0:t.toUpperCase())&&void 0!==i?i:"IT")===(null!==(r=null==n?void 0:n.toUpperCase())&&void 0!==r?r:"IT")&&C===e.description||!(null===(a=e.description)||void 0===a?void 0:a.length)||YI(e.description,null!==(l=null===(s=M.language)||void 0===s?void 0:s.toUpperCase())&&void 0!==l?l:"IT",n,o).then((e=>{N(e.text)})).catch(console.error)}),[M.language,n,e.description,o]),(0,a.jsxs)("div",{className:"memori--start-panel",children:[(0,a.jsxs)("div",{className:"memori--cover",style:{backgroundImage:`url("${KT({type:"cover",tenantID:null==t?void 0:t.name,resourceURI:e.coverURL,baseURL:o,apiURL:s})}"), url("${KT({type:"cover",tenantID:null==t?void 0:t.name,baseURL:o,apiURL:s})}")`},children:[!!e.enableCompletions&&!e.enableBoardOfExperts&&(0,a.jsx)("div",{className:"memori--completions-enabled",children:(0,a.jsx)(nI,{align:"left",content:I("completionsEnabled"),children:(0,a.jsx)("span",{"aria-label":I("completionsEnabled")||"Completions",children:(0,a.jsx)(eI,{})})})}),!!e.enableBoardOfExperts&&(0,a.jsx)("div",{className:"memori--board-of-experts",children:(0,a.jsx)(nI,{align:"left",content:I("boardOfExperts"),children:(0,a.jsx)("span",{"aria-label":I("boardOfExperts")||"Board of Experts",children:(0,a.jsx)(tC,{})})})}),!!e.nsfw&&(0,a.jsx)("div",{className:"memori--nsfw",children:(0,a.jsx)(nI,{align:"left",content:I("nsfw"),children:(0,a.jsx)("span",{title:I("nsfw")||"NSFW",children:"🔞"})})})]}),(0,a.jsxs)("picture",{className:"memori--avatar",children:[(0,a.jsx)("source",{src:null!==(S=e.avatarURL)&&void 0!==S?S:KT({type:"avatar",tenantID:null==t?void 0:t.name,resourceURI:e.avatarURL,baseURL:o,apiURL:s})}),(0,a.jsx)("img",{alt:e.name,src:e.avatarURL&&e.avatarURL.length>0?KT({type:"avatar",tenantID:null==t?void 0:t.name,resourceURI:e.avatarURL,baseURL:o,apiURL:s}):KT({type:"avatar",tenantID:null==t?void 0:t.name,baseURL:o,apiURL:s})})]}),(0,a.jsx)("h2",{className:"memori--title",children:e.name}),e.needsPosition&&!l&&(0,a.jsxs)("div",{className:"memori--needsPosition",children:[(0,a.jsx)("p",{children:I("write_and_speak.requirePositionHelp",{name:e.name})}),(0,a.jsx)(Jl,{primary:!0,onClick:()=>u(),className:"memori--start-button",icon:(0,a.jsx)(aC,{}),children:I("widget.position")})]}),(e.needsPosition&&l||!e.needsPosition)&&!!e.requireLoginToken&&!v&&(0,a.jsxs)("div",{className:"memori--needsLogin",children:[(0,a.jsx)("p",{children:I("write_and_speak.requirePositionHelp",{name:e.name})}),(0,a.jsx)(Jl,{primary:!0,onClick:()=>b(!0),className:"memori--start-button",icon:(0,a.jsx)(QT,{}),children:I("login.login")||"Login"})]}),(e.needsPosition&&l||!e.needsPosition)&&(!e.requireLoginToken||e.requireLoginToken&&v)&&(0,a.jsxs)("div",{className:"memori--description",children:[(0,a.jsxs)("p",{children:[(0,a.jsx)(BI,{className:"memori--description-text",rows:3,children:C&&O?C:e.description}),C!==e.description&&(0,a.jsx)(Jl,{ghost:!0,className:"memori--translation-toggle",icon:(0,a.jsx)(tI,{}),onClick:()=>{R((e=>!e))},children:I(O?"showOriginalText":"showTranslatedText")})]}),w&&!d&&(0,a.jsxs)("div",{className:"memori--language-chooser",children:[(0,a.jsx)("label",{id:"user-lang-pref-label",htmlFor:"user-lang-pref",children:I("write_and_speak.iWantToTalkToIn",{name:e.name})}),(0,a.jsxs)("select",{id:"user-lang-pref",className:"memori-select--button",value:(null!=i?i:M.language).toUpperCase(),"aria-labelledby":"user-lang-pref-label",onChange:e=>{r(e.target.value)},children:[(0,a.jsx)("optgroup",{label:I("popularLanguages")||"Popular",children:(0,NI.getGroupedChatLanguages)().popular.map((e=>(0,a.jsx)("option",{value:e.value,"aria-label":e.label,children:e.label},`popular-${e.value}`)))}),(0,a.jsx)("optgroup",{label:I("allLanguages")||"All Languages",children:(0,NI.getGroupedChatLanguages)().all.map((e=>(0,a.jsx)("option",{value:e.value,"aria-label":e.label,children:e.label},`all-${e.value}`)))})]})]}),(0,a.jsxs)("div",{className:"memori--start-privacy-explanation-container",children:[(0,a.jsx)("p",{className:"memori--start-privacy-explanation",children:I("write_and_speak.pagePrivacyExplanation")}),(0,a.jsx)(nI,{align:"right",content:(0,a.jsxs)("div",{className:"memori--privacy-tooltip-content",children:[(0,a.jsxs)("p",{children:[" ",I("write_and_speak.pagePrivacyExplanationList.allConversations")]}),(0,a.jsx)("ul",{className:"memori--privacy-tooltip-content-list",children:v?(0,a.jsx)("li",{children:I("write_and_speak.pagePrivacyExplanationList.contentAndUsername")}):(0,a.jsx)("li",{children:I("write_and_speak.pagePrivacyExplanationList.contentAndIpAddress")})}),(0,a.jsx)("p",{children:I("write_and_speak.pagePrivacyExplanationList.authorUsesInfo")}),(0,a.jsx)("a",{href:null!==(E=null==t?void 0:t.privacyPolicyURL)&&void 0!==E?E:"https://memori.ai/en/privacy-policy",target:"_blank",rel:"noopener noreferrer",children:null!==(A=null==t?void 0:t.privacyPolicyURL)&&void 0!==A?A:I("privacyPolicy")})]}),children:(0,a.jsx)(EI,{className:"memori--start-privacy-explanation-icon"})})]}),(0,a.jsx)(Jl,{primary:!0,disabled:!!e.blockedUntil&&!e.isGiver||x,loading:p,onClick:e=>{try{window.speechSynthesis.speak(new SpeechSynthesisUtterance(""))}catch(e){console.error(e)}f&&f(),m&&m()},className:"memori--start-button",children:I("write_and_speak."+(d?"instructButton":h?"resumeButton":"tryMeButton"))}),(0,a.jsx)(oC,{provider:null===(T=null==e?void 0:e.completionConfigForQuestionAnswering)||void 0===T?void 0:T.provider,forceStatus:g}),(0,a.jsx)("p",{className:"memori--start-description",children:I(d?"write_and_speak.pageInstructExplanation":"write_and_speak.pageTryMeExplanation")}),(e.blockedUntil||x)&&(0,a.jsx)(eC,{memoriName:e.name,blockedUntil:e.blockedUntil,notEnoughCredits:x,showGiverInfo:e.isGiver,showTitle:!0,marginLeft:!0}),!!e.enableDeepThought&&!d&&(0,a.jsxs)("div",{className:"memori--deep-thought-disclaimer",children:[(0,a.jsx)(nI,{align:"left",content:I("deepThoughtHelper"),children:(0,a.jsx)(nC,{})}),(0,a.jsx)("h2",{children:v&&(null==y?void 0:y.pAndCUAccepted)?I("deepThoughtDisclaimerTitle"):I("deepThought")}),v&&!(null==y?void 0:y.pAndCUAccepted)&&(0,a.jsx)("p",{children:I("deepThoughtPreDisclaimerNotAllowed")}),!v&&(0,a.jsx)("p",{children:I("deepThoughtPreDisclaimerUnlogged")}),!v&&_&&(0,a.jsx)("p",{children:(0,a.jsx)(Jl,{outlined:!0,padded:!1,onClick:()=>b(!0),children:I("login.login")||"Login"})}),(0,a.jsx)("p",{className:"memori--deep-thought-disclaimer-text",children:I("deepThoughtDisclaimer")})]})]})]})},lC=(c=o("85Hg2"),c=o("85Hg2"),{}),cC={};(cC=function(e,t){if(null==e)return{};var n,i,r={},o=Object.keys(e);for(i=0;i<o.length;i++)n=o[i],t.indexOf(n)>=0||(r[n]=e[n]);return r}).__esModule=!0,cC.default=cC,(lC=function(e,t){if(null==e)return{};var n,i,r=cC(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(i=0;i<o.length;i++)n=o[i],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}).__esModule=!0,lC.default=lC;c=o("85Hg2");var uC=["forwardedRef"];function dC(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function hC(e){for(var n=1;n<arguments.length;n++){var i=null!=arguments[n]?arguments[n]:{};n%2?dC(Object(i),!0).forEach((function(n){t(fe)(e,n,i[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):dC(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}class pC 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,a.jsxs)("div",{style:{background:"rgba(255, 255, 255, 0.4)",color:"#000",padding:"2rem",borderRadius:"10px"},children:[(0,a.jsx)("h2",{children:this.props.t("error.generic")}),(0,a.jsx)(Jl,{primary:!0,onClick:()=>this.setState({hasError:!1}),children:this.props.t("error.tryAgain")||"Try again"})]}):this.props.children}}var mC=function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(i){function r(r){var o=r.forwardedRef,a=t(lC)(r,uC),s=Ve(e,hC(hC({},a),{},{keyPrefix:n.keyPrefix})),l=t(ce)(s,3),u=l[0],d=l[1],h=l[2],p=hC(hC({},a),{},{t:u,i18n:d,tReady:h});return n.withRef&&o?p.ref=o:!n.withRef&&o&&(p.forwardedRef=o),(0,c.createElement)(i,p)}r.displayName="withI18nextTranslation(".concat(ze(i),")"),r.WrappedComponent=i;return n.withRef?(0,c.forwardRef)((function(e,t){return(0,c.createElement)(r,Object.assign({},e,{forwardedRef:t}))})):r}}(["common"])(pC);var fC=({avatar:e,speaking:n=!1})=>(0,a.jsxs)("div",{className:t(We)("memori-blob",{"memori-blob--speaking":n}),children:[e&&(0,a.jsx)("figure",{children:(0,a.jsx)("img",{src:e,alt:"",role:"presentation"})}),(0,a.jsx)("div",{className:"mainDiv"}),(0,a.jsx)("div",{className:"mainDiv"}),(0,a.jsx)("div",{className:"mainDiv"}),(0,a.jsx)("div",{className:"mainDiv"}),(0,a.jsx)("div",{className:"mainDiv"})]});var gC=({className:e,title:t})=>(0,a.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,a.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 vC=({className:e,title:t})=>(0,a.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,a.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,a.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 yC=({className:e,title:t})=>(0,a.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,a.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"})}),_C=(c=o("85Hg2"),c=o("85Hg2"),c=o("85Hg2"),{});Object.defineProperty(_C,"__esModule",{value:!0});c=o("85Hg2");function bC(e){var t,n=new Set,i=function(e,i){var r="function"==typeof e?e(t):e;if(r!==t){var o=t;t=i?r:Object.assign({},t,r),n.forEach((function(e){return e(t,o)}))}},r=function(){return t},o={setState:i,getState:r,subscribe:function(e,i,o){return i||o?function(e,i,o){void 0===i&&(i=r),void 0===o&&(o=Object.is),console.warn("[DEPRECATED] Please use `subscribeWithSelector` middleware");var a=i(t);function s(){var n=i(t);if(!o(a,n)){var r=a;e(a=n,r)}}return n.add(s),function(){return n.delete(s)}}(e,i,o):(n.add(e),function(){return n.delete(e)})},destroy:function(){return n.clear()}};return t=e(i,r,o),o}var xC="undefined"==typeof window||!window.navigator||/ServerSideRendering|^Deno\//.test(window.navigator.userAgent)?c.useEffect:c.useLayoutEffect;_C.default=function(e){var t="function"==typeof e?bC(e):e,n=function(e,n){void 0===e&&(e=t.getState),void 0===n&&(n=Object.is);var i,r=c.useReducer((function(e){return e+1}),0)[1],o=t.getState(),a=c.useRef(o),s=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;(a.current!==o||s.current!==e||l.current!==n||u.current)&&(i=e(o),h=!n(d.current,i)),xC((function(){h&&(d.current=i),a.current=o,s.current=e,l.current=n,u.current=!1}));var p=c.useRef(o);xC((function(){var e=function(){try{var e=t.getState(),n=s.current(e);l.current(d.current,n)||(a.current=e,d.current=n,r())}catch(e){u.current=!0,r()}},n=t.subscribe(e);return t.getState()!==p.current&&e(),n}),[]);var m=h?i: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 wC;wC=o("YtP34");var SC,EC=o("kMsGZ");SC=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 i,r,o;if(Array.isArray(t)){if((i=t.length)!=n.length)return!1;for(r=i;0!=r--;)if(!e(t[r],n[r]))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((i=(o=Object.keys(t)).length)!==Object.keys(n).length)return!1;for(r=i;0!=r--;)if(!Object.prototype.hasOwnProperty.call(n,o[r]))return!1;for(r=i;0!=r--;){var a=o[r];if(!e(t[a],n[a]))return!1}return!0}return t!=t&&n!=n};const AC=[];function TC(e,n,i,r=0,o=!1){for(const e of n)if(t(SC)(i,e.args)){if(o)return;if(e.error)throw e.error;if(e.response)return e.response;throw e.promise}const a={args:i,promise:e(...i).then((e=>a.response=null==e||e)).catch((e=>a.error=null!=e?e:"unknown error")).then((()=>{r>0&&setTimeout((()=>{const e=n.indexOf(a);-1!==e&&n.splice(e,1)}),r)}))};if(n.push(a),!o)throw a.promise}function IC(e,...n){if(void 0===n||0===n.length)e.splice(0,e.length);else{const i=e.find((e=>t(SC)(n,e.args)));if(i){const t=e.indexOf(i);-1!==t&&e.splice(t,1)}}}function MC(e,...t){return TC(e,AC,t,MC.lifespan)}MC.lifespan=0,MC.clear=(...e)=>IC(AC,...e),MC.preload=(e,...t)=>{TC(e,AC,t,MC.lifespan,!0)},MC.peek=(...e)=>{var n;return null==(n=AC.find((n=>t(SC)(e,n.args))))?void 0:n.response};var CC,NC=function(e){return function(t){e.forEach((function(e){"function"==typeof e?e(t):null!=e&&(e.current=t)}))}};c=o("85Hg2");function OC(e,t,n){var i,r,o,a,s;function l(){var c=Date.now()-a;c<t&&c>=0?i=setTimeout(l,t-c):(i=null,n||(s=e.apply(o,r),o=r=null))}null==t&&(t=100);var c=function(){o=this,r=arguments,a=Date.now();var c=n&&!i;return i||(i=setTimeout(l,t)),c&&(s=e.apply(o,r),o=r=null),s};return c.clear=function(){i&&(clearTimeout(i),i=null)},c.flush=function(){i&&(s=e.apply(o,r),o=r=null,clearTimeout(i),i=null)},c}function RC(e){let{debounce:n,scroll:i,polyfill:r,offsetSize:o}=void 0===e?{debounce:0,scroll:!1,offsetSize:!1}:e;const a=r||("undefined"==typeof window?class{}:window.ResizeObserver);if(!a)throw new Error("This browser does not support ResizeObserver out of the box. See: https://github.com/react-spring/react-use-measure/#resize-observer-polyfills");const[s,l]=(0,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:s}),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:i,bottom:r,right:a,x:s,y:c}=u.current.element.getBoundingClientRect(),d={left:e,top:t,width:n,height:i,bottom:r,right:a,x:s,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&&!DC(u.current.lastBounds,d)&&l(u.current.lastBounds=d)};return[e,h?t(CC)(e,h):e,d?t(CC)(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 a(g),u.current.resizeObserver.observe(u.current.element),i&&u.current.scrollContainers&&u.current.scrollContainers.forEach((e=>e.addEventListener("scroll",g,{capture:!0,passive:!0}))))}var _,b,x;return _=g,b=Boolean(i),(0,c.useEffect)((()=>{if(b){const e=_;return window.addEventListener("scroll",e,{capture:!0,passive:!0}),()=>{window.removeEventListener("scroll",e,!0)}}}),[_,b]),x=f,(0,c.useEffect)((()=>{const e=x;return window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}}),[x]),(0,c.useEffect)((()=>{v(),y()}),[i,g,f]),(0,c.useEffect)((()=>v),[]),[e=>{e&&e!==u.current.element&&(v(),u.current.element=e,u.current.scrollContainers=LC(e),y())},s,m]}function LC(e){const t=[];if(!e||e===document.body)return t;const{overflow:n,overflowX:i,overflowY:r}=window.getComputedStyle(e);return[n,i,r].some((e=>"auto"===e||"scroll"===e))&&t.push(e),[...t,...LC(e.parentElement)]}OC.debounce=OC,CC=OC;const PC=["x","y","top","bottom","left","right","width","height"],DC=(e,t)=>PC.every((n=>e[n]===t[n]));const kC={obj:e=>e===Object(e)&&!kC.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(kC.str(e)||kC.num(e)||kC.obj(e))return e===t;if(kC.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!kC.und(n)||e===t}};function BC(e){return(e.eventObject||e.object).uuid+"/"+e.index+e.instanceId}function FC(e,t,n,i){const r=n.get(t);r&&(n.delete(t),0===n.size&&(e.delete(i),r.target.releasePointerCapture(i)))}function UC(e){const t=new Tc.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 i(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 i=e.eventObject.__r3f,r=null==i?void 0:i.handlers;if(n.hovered.delete(BC(e)),null!=i&&i.eventCount){const n={...e,intersections:t||[]};null==r.onPointerOut||r.onPointerOut(n),null==r.onPointerLeave||r.onPointerLeave(n)}}}))}function r(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()=>i([]);case"onLostPointerCapture":return t=>{const{internal:n}=e.getState();"pointerId"in t&&!n.capturedMap.has(t.pointerId)&&(n.capturedMap.delete(t.pointerId),i([]))}}return a=>{const{onPointerMissed:s,internal:l}=e.getState();!function(t){var n;const i=e.getState(),{raycaster:r,mouse:o,camera:a,size:s}=i,{offsetX:l,offsetY:c}=null!=(n=null==r.computeOffsets?void 0:r.computeOffsets(t,i))?n:t,{width:u,height:d}=s;o.set(l/u*2-1,-c/d*2+1),r.setFromCamera(o,a)}(a),l.lastEvent.current=a;const c="onPointerMove"===o,u="onClick"===o||"onContextMenu"===o||"onDoubleClick"===o,d=function(t,n){const{internal:i}=e.getState();if("pointerId"in n&&i.capturedMap.has(n.pointerId))for(let e of i.capturedMap.get(n.pointerId).values())t.push(e.intersection);return t}(function(t){const n=e.getState(),{raycaster:i,internal:r}=n;if(!i.enabled)return[];const o=new Set,a=[],s=t?t(r.interaction):r.interaction;let l=i.intersectObjects(s,!0).filter((e=>{const t=BC(e);return!o.has(t)&&(o.add(t),!0)}));i.filter&&(l=i.filter(l,n));for(const e of l){let t=e.object;for(;t;){var c;null!=(c=t.__r3f)&&c.eventCount&&a.push({...e,eventObject:t}),t=t.parent}}return a}(c?n:void 0),a),h=u?function(t){const{internal:n}=e.getState(),i=t.offsetX-n.initialClick[0],r=t.offsetY-n.initialClick[1];return Math.round(Math.sqrt(i*i+r*r))}(a):0;"onPointerDown"===o&&(l.initialClick=[a.offsetX,a.offsetY],l.initialHits=d.map((e=>e.eventObject))),u&&!d.length&&h<=2&&(r(a,l.interaction),s&&s(a)),c&&i(d),function(n,r,o,a){const{raycaster:s,mouse:l,camera:c,internal:u}=e.getState();if(n.length){const e=t.set(l.x,l.y,0).unproject(c),d={stopped:!1};for(const t of n){const h=e=>{var n,i;return null!=(n=null==(i=u.capturedMap.get(e))?void 0:i.has(t.eventObject))&&n},p=e=>{const n={intersection:t,target:r.target};u.capturedMap.has(e)?u.capturedMap.get(e).set(t.eventObject,n):u.capturedMap.set(e,new Map([[t.eventObject,n]])),r.target.setPointerCapture(e)},m=e=>{const n=u.capturedMap.get(e);n&&FC(u.capturedMap,t.eventObject,n,e)};let f={};for(let e in r){let t=r[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:s.ray,camera:c,stopPropagation:()=>{const e="pointerId"in r&&u.capturedMap.get(r.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)))&&i([...n.slice(0,n.indexOf(t)),t])},target:{hasPointerCapture:h,setPointerCapture:p,releasePointerCapture:m},currentTarget:{hasPointerCapture:h,setPointerCapture:p,releasePointerCapture:m},sourceEvent:r,nativeEvent:r};if(a(g),!0===d.stopped)break}}}(d,a,h,(e=>{const t=e.eventObject,n=t.__r3f,i=null==n?void 0:n.handlers;if(null!=n&&n.eventCount)if(c){if(i.onPointerOver||i.onPointerEnter||i.onPointerOut||i.onPointerLeave){const t=BC(e),n=l.hovered.get(t);n?n.stopped&&e.stopPropagation():(l.hovered.set(t,e),null==i.onPointerOver||i.onPointerOver(e),null==i.onPointerEnter||i.onPointerEnter(e))}null==i.onPointerMove||i.onPointerMove(e)}else{const n=i[o];n?u&&!l.initialHits.includes(t)||(r(a,l.interaction.filter((e=>!l.initialHits.includes(e)))),n(e)):u&&l.initialHits.includes(t)&&r(a,l.interaction.filter((e=>!l.initialHits.includes(e))))}}))}}}}const zC=e=>e&&!!e.getState,GC=(e,t)=>{var n,i;return{root:zC(e)?e:null!=(n=null==(i=e.__r3f)?void 0:i.root)?n:t.__r3f.root,container:zC(e)?e.getState().scene:e}},jC="__default",HC={};let VC={};function WC(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 qC=e=>e&&e.isOrthographicCamera;function $C(e){return Array.isArray(e)?Math.min(Math.max(e[0],window.devicePixelRatio),e[1]):e}const YC=c.createContext(null);let JC,ZC=[],XC=[],KC=[];function QC(e,t){for(JC=0;JC<e.length;JC++)e[JC](t)}function eN(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),JC=0;JC<t.internal.subscribers.length;JC++)t.internal.subscribers[JC].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 tN(e){const{handlePointer:t}=UC(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 i;const{set:r,events:o}=e.getState();null==o.disconnect||o.disconnect(),r((e=>({events:{...e.events,connected:t}}))),Object.entries(null!=(i=null==o?void 0:o.handlers)?i:[]).forEach((([e,i])=>{const[r,o]=n[e];t.addEventListener(r,i,{passive:o})}))},disconnect:()=>{const{set:t,events:i}=e.getState();var r;i.connected&&(Object.entries(null!=(r=i.handlers)?r:[]).forEach((([e,t])=>{if(i&&i.connected instanceof HTMLElement){const[r]=n[e];i.connected.removeEventListener(r,t)}})),t((e=>({events:{...e.events,connected:!1}}))))}}}const nN="undefined"!=typeof window?c.useLayoutEffect:c.useEffect;function iN({set:e}){return nN((()=>(e(new Promise((()=>null))),()=>e(!1))),[]),null}class rN 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}}rN.getDerivedStateFromError=()=>({error:!0});const oN=c.forwardRef((function({children:e,fallback:n,tabIndex:i,resize:r,id:o,style:a,className:s,events:l,...u},d){const[h,{width:p,height:m}]=RC({scroll:!0,debounce:{scroll:50,resize:0},...r}),f=c.useRef(null),[g,v]=c.useState(!1),[y,_]=c.useState(!1);if(g)throw g;if(y)throw y;return nN((()=>{p>0&&m>0&&function(e,n,{gl:i,size:r,mode:o=pN[1],events:a,onCreated:s,...l}={}){var u,d,h,p,m;r||(r={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=hN.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||kC.equ(y.viewport.dpr,$C(l.dpr))||y.setDpr(l.dpr),y.size.width===r.width&&y.size.height===r.height||y.setSize(r.width,r.height),y.frameloop!==l.frameloop&&y.setFrameloop(l.frameloop);l.linear!==y.internal.lastProps.linear&&(_N(n),g=void 0)}if(!g){const e=((e,t)=>{const n="function"==typeof e?e(t):e;if(i=n,null!=i&&i.render)return n;var i;const r=new Tc.WebGLRenderer({powerPreference:"high-performance",canvas:t,antialias:!0,alpha:!0,...e});r.outputEncoding=Tc.sRGBEncoding,r.toneMapping=Tc.ACESFilmicToneMapping,e&&vN(r,e);return r})(i,n);l.vr&&(e.xr.enabled=!0,e.setAnimationLoop((e=>fN(e,!0)))),v=((e,n,i,r)=>{const{gl:o,size:a,shadows:s=!1,linear:l=!1,flat:u=!1,vr:d=!1,orthographic:h=!1,frameloop:p="always",dpr:m=1,performance:f,clock:g=new Tc.Clock,raycaster:v,camera:y,onPointerMissed:_}=r;s&&(o.shadowMap.enabled=!0,"object"==typeof s?Object.assign(o.shadowMap,s):o.shadowMap.type=Tc.PCFSoftShadowMap),l&&(o.outputEncoding=Tc.LinearEncoding),u&&(o.toneMapping=Tc.NoToneMapping),"never"===p&&(g.stop(),g.elapsedTime=0);const b=t(_C)(((t,a)=>{const s=new Tc.Raycaster,{params:b,...x}=v||{};e(s,{enabled:!0,...x,params:{...s.params,...b}});const w=y instanceof Tc.Camera,S=w?y:h?new Tc.OrthographicCamera(0,0,0,0,.1,1e3):new Tc.PerspectiveCamera(75,0,.1,1e3);w||(S.position.z=5,y&&e(S,y),null!=y&&y.rotation||S.lookAt(0,0,0));const E=$C(m),A=new Tc.Vector3,T=new Tc.Vector3,I=new Tc.Vector3;function M(e=a().camera,t=T,n=a().size){const{width:i,height:r}=n,o=i/r;t instanceof Tc.Vector3?I.copy(t):I.set(...t);const s=e.getWorldPosition(A).distanceTo(I);if(qC(e))return{width:i/e.zoom,height:r/e.zoom,factor:1,distance:s,aspect:o};{const t=e.fov*Math.PI/180,n=2*Math.tan(t/2)*s,a=n*(i/r);return{width:a,height:n,factor:i/a,distance:s,aspect:o}}}let C;const N=e=>t((t=>({performance:{...t.performance,current:e}})));return{gl:o,set:t,get:a,invalidate:()=>n(a()),advance:(e,t)=>i(e,t,a()),linear:l,flat:u,scene:WC(new Tc.Scene),camera:S,controls:null,raycaster:s,clock:g,mouse:new Tc.Vector2,vr:d,frameloop:p,onPointerMissed:_,performance:{current:1,min:.5,max:1,debounce:200,...f,regress:()=>{const e=a();C&&clearTimeout(C),e.performance.current!==e.performance.min&&N(e.performance.min),C=setTimeout((()=>N(a().performance.max)),e.performance.debounce)}},size:{width:0,height:0},viewport:{initialDpr:E,dpr:E,width:0,height:0,aspect:0,distance:0,factor:0,getCurrentViewport:M},setSize:(e,n)=>{const i={width:e,height:n};t((e=>({size:i,viewport:{...e.viewport,...M(S,T,i)}})))},setDpr:e=>t((t=>({viewport:{...t.viewport,dpr:$C(e)}}))),setFrameloop:(e="always")=>t((()=>({frameloop:e}))),events:{connected:!1},internal:{active:!1,priority:0,frames:0,lastProps:r,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))}})))})}}})),x=b.getState();let w=x.size,S=x.viewport.dpr;return b.subscribe((()=>{const{camera:e,size:t,viewport:n,internal:i}=b.getState();t===w&&n.dpr===S||(e.manual||i.lastProps.camera instanceof Tc.Camera||(qC(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),w=t,S=n.dpr)})),a&&x.setSize(a.width,a.height),b.subscribe((e=>n(e))),b})(vN,mN,fN,{gl:e,size:r,...l});const s=v.getState();g=gN.createContainer(v,pN.indexOf(o),!1,null),hN.set(n,{fiber:g,store:v}),a&&s.set({events:a(v)})}if(v&&g)return gN.updateContainer(c.createElement(yN,{store:v,element:e,onCreated:s,target:n}),g,null,(()=>{})),v;throw"Error creating root!"}(c.createElement(rN,{set:_},c.createElement(c.Suspense,{fallback:c.createElement(iN,{set:v})},e)),f.current,{...u,size:{width:p,height:m},events:l||tN})}),[p,m,e]),nN((()=>{const e=f.current;return()=>_N(e)}),[]),c.createElement("div",{ref:h,id:o,className:s,tabIndex:i,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden",...a}},c.createElement("canvas",{ref:NC([f,d]),style:{display:"block"}},n))}));function aN(){const e=c.useContext(YC);if(!e)throw"R3F hooks can only be used within the Canvas component!";return e}function sN(e=(e=>e),t){return aN()(e,t)}function lN(e,t=0){const n=aN().getState().internal.subscribe,i=c.useRef(e);return c.useLayoutEffect((()=>{i.current=e}),[e]),c.useLayoutEffect((()=>n(i,t)),[t,n]),null}function cN(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 uN(e,t){return function(n,...i){const r=new n;return e&&e(r),Promise.all(i.map((e=>new Promise(((n,i)=>r.load(e,(e=>{e.scene&&Object.assign(e,cN(e.scene)),n(e)}),t,(t=>i(`Could not load ${e}: ${t.message}`))))))))}}function dN(e,t,n,i){const r=Array.isArray(t)?t:[t],o=MC(uN(n,i),e,...r);return Array.isArray(t)?o:o[0]}dN.preload=function(e,t,n){const i=Array.isArray(t)?t:[t];return MC.preload(uN(n),e,...i)},dN.clear=function(e,t){const n=Array.isArray(t)?t:[t];return MC.clear(e,...n)};const hN=new Map,pN=["legacy","blocking","concurrent"],{invalidate:mN,advance:fN}=function(e){let t,n=!1;function i(r){if(n=!0,t=0,QC(ZC,r),e.forEach((e=>{const n=e.store.getState();n.internal.active&&("always"===n.frameloop||n.internal.frames>0)&&(t+=eN(r,n))})),QC(XC,r),t>0)return requestAnimationFrame(i);QC(KC,r),n=!1}return{loop:i,invalidate:function t(r){if(!r)return e.forEach((e=>t(e.store.getState())));!r.vr&&r.internal.active&&"never"!==r.frameloop&&(r.internal.frames=Math.min(60,r.internal.frames+1),n||(n=!0,requestAnimationFrame(i)))},advance:function(t,n=!0,i){n&&QC(ZC,t),i?eN(t,i):e.forEach((e=>eN(t,e.store.getState()))),n&&QC(XC,t)}}}(hN),{reconciler:gN,applyProps:vN}=function(e){function n(e,{children:t,key:n,ref:i,...r},{children:o,key:a,ref:s,...l}={},c=!1){var u;const d=null!=(u=null==e?void 0:e.__r3f)?u:{},h=Object.entries(r),p=[];if(c){const e=Object.keys(l);for(let t=0;t<e.length;t++)r.hasOwnProperty(e[t])||h.unshift([e[t],jC+"remove"])}h.forEach((([t,n])=>{var i;if(null!=(i=e.__r3f)&&i.primitive&&"object"===t)return;if(function(e,t){return!(!kC.arr(e)||!kC.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 r=[];t.includes("-")&&(r=t.split("-")),p.push([t,n,!1,r])}));const m={...r};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 i(e,t){var i,a,s;const l=null!=(i=null==e?void 0:e.__r3f)?i:{},c=l.root,u=null!=(a=null==c||null==c.getState?void 0:c.getState())?a:{},{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,i,o])=>{var a;let s=e,c=s[t];if(o.length&&(c=o.reduce(((e,t)=>e[t]),e),!c||!c.set)){const[n,...i]=o.reverse();s=i.reverse().reduce(((e,t)=>e[t]),e),t=n}if(n===jC+"remove")if(c&&c.constructor)n=new c.constructor(d.args);else if(s.constructor){const e=new s.constructor(s.__r3f.memoizedProps.args);n=e[c],e.dispose&&e.dispose()}else n=0;const h=(null==u||null==(a=u.gl)?void 0:a.outputEncoding)===Tc.LinearEncoding;if(i)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 Tc.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 Tc.Color;!e&&c.setScalar?c.setScalar(n):c instanceof Tc.Layers&&n instanceof Tc.Layers?c.mask=n.mask:c.set(n),!h&&e&&c.convertSRGBToLinear()}}else s[t]=n,!h&&s[t]instanceof Tc.Texture&&(s[t].encoding=Tc.sRGBEncoding);r(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!=(s=e.__r3f)&&s.parent&&o(e),e}function r(e){var t,n;const i=null==(t=e.__r3f)||null==(n=t.root)||null==n.getState?void 0:n.getState();i&&0===i.internal.frames&&i.invalidate()}function o(e){null==e.onUpdate||e.onUpdate(e)}function a(e,{args:t=[],...n},r,o,a){let s,l=`${e[0].toUpperCase()}${e.slice(1)}`;if(!zC(r)&&a){const e=t=>t.return?e(t.return):t.stateNode&&t.stateNode.containerInfo;r=e(a)}if(!r||!zC(r))throw`No valid root for ${l}!`;if("primitive"===e){if(void 0===n.object)throw"Primitives without 'object' are invalid!";s=WC(n.object,{root:r,primitive:!0})}else{const e=VC[l]||Tc[l];if(!e)throw`${l} is not part of the THREE namespace! Did you forget to extend? See: https://github.com/pmndrs/react-three-fiber/blob/master/markdown/api.md#using-3rd-party-objects-declaratively`;if(!Array.isArray(t))throw"The args prop must be an array!";s=WC(new e(...t),{root:r,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})),i(s,n),s}function s(e,t){let n=!1;if(t){if(t.attachArray)kC.arr(e[t.attachArray])||(e[t.attachArray]=[]),e[t.attachArray].push(t);else if(t.attachObject)kC.obj(e[t.attachObject[0]])||(e[t.attachObject[0]]={}),e[t.attachObject[0]][t.attachObject[1]]=t;else if(t.attach&&!kC.fun(t.attach))e[t.attach]=t;else if(kC.arr(t.attachFns)){const[n]=t.attachFns;kC.str(n)&&kC.fun(e[n])?e[n](t):kC.fun(n)&&n(t,e)}else t.isObject3D&&e.isObject3D&&(e.add(t),n=!0);n||e.__r3f.objects.push(t),t.__r3f||WC(t,{}),t.__r3f.parent=e,o(t),r(t)}}function l(e,t,n){let i=!1;if(t){if(t.attachArray){const i=e[t.attachArray];kC.arr(i)||(e[t.attachArray]=[]),i.splice(i.indexOf(n),0,t)}else{if(t.attachObject||t.attach&&!kC.fun(t.attach))return s(e,t);if(t.isObject3D&&e.isObject3D){t.parent=e,t.dispatchEvent({type:"added"});const r=e.children.filter((e=>e!==t)),o=r.indexOf(n);e.children=[...r.slice(0,o),t,...r.slice(o)],i=!0}}i||e.__r3f.objects.push(t),t.__r3f||WC(t,{}),t.__r3f.parent=e,o(t),r(t)}}function c(e,t,n=!1){e&&[...e].forEach((e=>u(t,e,n)))}function u(e,t,n){if(t){var i,o;if(t.__r3f&&(t.__r3f.parent=null),null!=(i=e.__r3f)&&i.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&&!kC.fun(t.attach)&&e[t.attach]===t)e[t.attach]=null;else if(kC.arr(t.attachFns)){const[,n]=t.attachFns;kC.str(n)&&kC.fun(e[n])?e[n](t):kC.fun(n)&&n(t,e)}else if(t.isObject3D&&e.isObject3D){var a;e.remove(t),null!=(a=t.__r3f)&&a.root&&function(e,t){const{internal:n}=e.getState();n.interaction=n.interaction.filter((e=>e!==t)),n.initialHits=n.initialHits.filter((e=>e!==t)),n.hovered.forEach(((e,i)=>{e.eventObject!==t&&e.object!==t||n.hovered.delete(i)})),n.capturedMap.forEach(((e,i)=>{FC(n.capturedMap,t,e,i)}))}(t.__r3f.root,t)}const l=null==(o=t.__r3f)?void 0:o.primitive,u=void 0===n?null!==t.dispose&&!l:n;var s;if(!l)c(null==(s=t.__r3f)?void 0:s.objects,t,u),c(t.children,t,u);t.__r3f&&(delete t.__r3f.root,delete t.__r3f.objects,delete t.__r3f.handlers,delete t.__r3f.memoizedProps,l||delete t.__r3f),u&&t.dispose&&"Scene"!==t.type&&(0,EC.unstable_runWithPriority)(EC.unstable_IdlePriority,(()=>{try{t.dispose()}catch(e){}})),r(e)}}return{reconciler:t(wC)({now:EC.unstable_now,createInstance:a,removeChild:u,appendChild:s,appendInitialChild:s,insertBefore:l,warnsIfNotActing:!0,supportsMutation:!0,isPrimaryRenderer:!1,scheduleTimeout:kC.fun(setTimeout)?setTimeout:void 0,cancelTimeout:kC.fun(clearTimeout)?clearTimeout:void 0,setTimeout:kC.fun(setTimeout)?setTimeout:void 0,clearTimeout:kC.fun(clearTimeout)?clearTimeout:void 0,noTimeout:-1,appendChildToContainer:(e,t)=>{const{container:n,root:i}=GC(e,t);n.__r3f.root=i,s(n,t)},removeChildFromContainer:(e,t)=>u(GC(e,t).container,t),insertInContainerBefore:(e,t,n)=>l(GC(e,t).container,t,n),prepareUpdate(e,t,i,r){if(e.__r3f.primitive&&r.object&&r.object!==e)return[!0];{const{args:t=[],children:o,...a}=r,{args:l=[],children:c,...u}=i;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,a,u,!0);if(d.changes.length)return[!1,d];if(e.attach&&"function"!=typeof e.attach){const t=e.__r3f.parent;t&&t[e.attach]!==e&&s(t,e)}return null}},commitUpdate(e,[t,n],r,o,l,c){t?function(e,t,n,i){var r;const o=null==(r=e.__r3f)?void 0:r.parent;if(!o)return;const l=a(t,n,e.__r3f.root);"primitive"!==t&&e.children&&(e.children.forEach((e=>s(l,e))),e.children=[]),e.__r3f.objects.forEach((e=>s(l,e))),e.__r3f.objects=[],u(o,e),s(o,l),l.raycast&&l.__r3f.eventCount&&l.__r3f.root.getState().internal.interaction.push(l);[i,i.alternate].forEach((e=>{null!==e&&(e.stateNode=l,e.ref&&("function"==typeof e.ref?e.ref(l):e.ref.current=l))}))}(e,r,l,c):i(e,n)},hideInstance(e){e.isObject3D&&(e.visible=!1,r(e))},unhideInstance(e,t){(e.isObject3D&&null==t.visible||t.visible)&&(e.visible=!0,r(e))},hideTextInstance(){throw new Error("Text is not allowed in the R3F tree.")},getPublicInstance:e=>e,getRootHostContext:e=>HC,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){WC(e)},resetAfterCommit(){},shouldSetTextContent:()=>!1,clearContainer:()=>!1}),applyProps:i}}();function yN({store:e,element:t,onCreated:n,target:i}){return c.useEffect((()=>{const t=e.getState();t.set((e=>({internal:{...e.internal,active:!0}}))),null==t.events.connect||t.events.connect(i),n&&n(t)}),[]),c.createElement(YC.Provider,{value:e},t)}function _N(e,t){const n=hN.get(e),i=null==n?void 0:n.fiber;if(i){const r=null==n?void 0:n.store.getState();r&&(r.internal.active=!1),gN.updateContainer(null,i,null,(()=>{r&&setTimeout((()=>{var n,i,o;null==r.events.disconnect||r.events.disconnect(),null==(n=r.gl)||null==(i=n.renderLists)||null==i.dispose||i.dispose(),null==(o=r.gl)||null==o.forceContextLoss||o.forceContextLoss(),function(e){e.dispose&&"Scene"!==e.type&&e.dispose();for(const i in e){var t,n;null==(t=(n=i).dispose)||t.call(n),delete e[i]}}(r),hN.delete(e),t&&t(e)}),500)}))}}gN.act;function bN(){return bN=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},bN.apply(this,arguments)}gN.injectIntoDevTools({bundleType:0,rendererPackageName:"@react-three/fiber",version:"17.0.2"});c=o("85Hg2");function xN(e){return xN="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},xN(e)}function wN(e,t){if("object"!==xN(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!==xN(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function SN(e){var t=wN(e,"string");return"symbol"===xN(t)?t:String(t)}function EN(e,t,n){return(t=SN(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const AN=(e,t)=>(e%t+t)%t;class TN extends Bh{constructor(e,t){super(),EN(this,"object",void 0),EN(this,"domElement",void 0),EN(this,"enabled",!0),EN(this,"target",new Cp),EN(this,"minDistance",0),EN(this,"maxDistance",1/0),EN(this,"minZoom",0),EN(this,"maxZoom",1/0),EN(this,"minPolarAngle",0),EN(this,"maxPolarAngle",Math.PI),EN(this,"minAzimuthAngle",-1/0),EN(this,"maxAzimuthAngle",1/0),EN(this,"enableDamping",!1),EN(this,"dampingFactor",.05),EN(this,"enableZoom",!0),EN(this,"zoomSpeed",1),EN(this,"enableRotate",!0),EN(this,"rotateSpeed",1),EN(this,"enablePan",!0),EN(this,"panSpeed",1),EN(this,"screenSpacePanning",!0),EN(this,"keyPanSpeed",7),EN(this,"autoRotate",!1),EN(this,"autoRotateSpeed",2),EN(this,"reverseOrbit",!1),EN(this,"keys",{LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"}),EN(this,"mouseButtons",{LEFT:Mc.ROTATE,MIDDLE:Mc.DOLLY,RIGHT:Mc.PAN}),EN(this,"touches",{ONE:Cc.ROTATE,TWO:Cc.DOLLY_PAN}),EN(this,"target0",void 0),EN(this,"position0",void 0),EN(this,"zoom0",void 0),EN(this,"_domElementKeyEvents",null),EN(this,"getPolarAngle",void 0),EN(this,"getAzimuthalAngle",void 0),EN(this,"setPolarAngle",void 0),EN(this,"setAzimuthalAngle",void 0),EN(this,"getDistance",void 0),EN(this,"listenToKeyEvents",void 0),EN(this,"saveState",void 0),EN(this,"reset",void 0),EN(this,"update",void 0),EN(this,"connect",void 0),EN(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 Uf?this.object.zoom:1,this.getPolarAngle=()=>c.phi,this.getAzimuthalAngle=()=>c.theta,this.setPolarAngle=e=>{let t=AN(e,2*Math.PI),i=c.phi;i<0&&(i+=2*Math.PI),t<0&&(t+=2*Math.PI);let r=Math.abs(t-i);2*Math.PI-r<r&&(t<i?t+=2*Math.PI:i+=2*Math.PI),u.phi=t-i,n.update()},this.setAzimuthalAngle=e=>{let t=AN(e,2*Math.PI),i=c.theta;i<0&&(i+=2*Math.PI),t<0&&(t+=2*Math.PI);let r=Math.abs(t-i);2*Math.PI-r<r&&(t<i?t+=2*Math.PI:i+=2*Math.PI),u.theta=t-i,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 Uf?n.object.zoom:1},this.reset=()=>{n.target.copy(n.target0),n.object.position.copy(n.position0),n.object instanceof Uf&&(n.object.zoom=n.zoom0,n.object.updateProjectionMatrix()),n.dispatchEvent(i),n.update(),s=a.NONE},this.update=(()=>{const t=new Cp,r=(new Mp).setFromUnitVectors(e.up,new Cp(0,1,0)),o=r.clone().invert(),m=new Cp,f=new Mp,g=2*Math.PI;return function(){const e=n.object.position;t.copy(e).sub(n.target),t.applyQuaternion(r),c.setFromVector3(t),n.autoRotate&&s===a.NONE&&T(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(i),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",$),n.domElement.addEventListener("pointerdown",G),n.domElement.addEventListener("pointercancel",V),n.domElement.addEventListener("wheel",W)},this.dispose=()=>{var e,t,i,r,o,a;null===(e=n.domElement)||void 0===e||e.removeEventListener("contextmenu",$),null===(t=n.domElement)||void 0===t||t.removeEventListener("pointerdown",G),null===(i=n.domElement)||void 0===i||i.removeEventListener("pointercancel",V),null===(r=n.domElement)||void 0===r||r.removeEventListener("wheel",W),null===(o=n.domElement)||void 0===o||o.ownerDocument.removeEventListener("pointermove",j),null===(a=n.domElement)||void 0===a||a.ownerDocument.removeEventListener("pointerup",H),null!==n._domElementKeyEvents&&n._domElementKeyEvents.removeEventListener("keydown",q)};const n=this,i={type:"change"},r={type:"start"},o={type:"end"},a={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let s=a.NONE;const l=1e-6,c=new gS,u=new gS;let d=1;const h=new Cp;let p=!1;const m=new Kh,f=new Kh,g=new Kh,v=new Kh,y=new Kh,_=new Kh,b=new Kh,x=new Kh,w=new Kh,S=[],E={};function A(){return Math.pow(.95,n.zoomSpeed)}function T(e){n.reverseOrbit?u.theta+=e:u.theta-=e}function I(e){n.reverseOrbit?u.phi+=e:u.phi-=e}const M=(()=>{const e=new Cp;return function(t,n){e.setFromMatrixColumn(n,0),e.multiplyScalar(-t),h.add(e)}})(),C=(()=>{const e=new Cp;return function(t,i){!0===n.screenSpacePanning?e.setFromMatrixColumn(i,1):(e.setFromMatrixColumn(i,0),e.crossVectors(n.object.up,e)),e.multiplyScalar(t),h.add(e)}})(),N=(()=>{const e=new Cp;return function(t,i){const r=n.domElement;if(r&&n.object instanceof Uf&&n.object.isPerspectiveCamera){const o=n.object.position;e.copy(o).sub(n.target);let a=e.length();a*=Math.tan(n.object.fov/2*Math.PI/180),M(2*t*a/r.clientHeight,n.object.matrix),C(2*i*a/r.clientHeight,n.object.matrix)}else r&&n.object instanceof cg&&n.object.isOrthographicCamera?(M(t*(n.object.right-n.object.left)/n.object.zoom/r.clientWidth,n.object.matrix),C(i*(n.object.top-n.object.bottom)/n.object.zoom/r.clientHeight,n.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),n.enablePan=!1)}})();function O(e){n.object instanceof Uf&&n.object.isPerspectiveCamera?d/=e:n.object instanceof cg&&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 R(e){n.object instanceof Uf&&n.object.isPerspectiveCamera?d*=e:n.object instanceof cg&&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 L(e){m.set(e.clientX,e.clientY)}function P(e){v.set(e.clientX,e.clientY)}function D(){if(1==S.length)m.set(S[0].pageX,S[0].pageY);else{const e=.5*(S[0].pageX+S[1].pageX),t=.5*(S[0].pageY+S[1].pageY);m.set(e,t)}}function k(){if(1==S.length)v.set(S[0].pageX,S[0].pageY);else{const e=.5*(S[0].pageX+S[1].pageX),t=.5*(S[0].pageY+S[1].pageY);v.set(e,t)}}function B(){const e=S[0].pageX-S[1].pageX,t=S[0].pageY-S[1].pageY,n=Math.sqrt(e*e+t*t);b.set(0,n)}function F(e){if(1==S.length)f.set(e.pageX,e.pageY);else{const t=Z(e),n=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);f.set(n,i)}g.subVectors(f,m).multiplyScalar(n.rotateSpeed);const t=n.domElement;t&&(T(2*Math.PI*g.x/t.clientHeight),I(2*Math.PI*g.y/t.clientHeight)),m.copy(f)}function U(e){if(1==S.length)y.set(e.pageX,e.pageY);else{const t=Z(e),n=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);y.set(n,i)}_.subVectors(y,v).multiplyScalar(n.panSpeed),N(_.x,_.y),v.copy(y)}function z(e){const t=Z(e),i=e.pageX-t.x,r=e.pageY-t.y,o=Math.sqrt(i*i+r*r);x.set(0,o),w.set(0,Math.pow(x.y/b.y,n.zoomSpeed)),O(w.y),b.copy(x)}function G(e){if(!1!==n.enabled){var t,i;if(0===S.length)null===(t=n.domElement)||void 0===t||t.ownerDocument.addEventListener("pointermove",j),null===(i=n.domElement)||void 0===i||i.ownerDocument.addEventListener("pointerup",H);!function(e){S.push(e)}(e),"touch"===e.pointerType?function(e){switch(J(e),S.length){case 1:switch(n.touches.ONE){case Cc.ROTATE:if(!1===n.enableRotate)return;D(),s=a.TOUCH_ROTATE;break;case Cc.PAN:if(!1===n.enablePan)return;k(),s=a.TOUCH_PAN;break;default:s=a.NONE}break;case 2:switch(n.touches.TWO){case Cc.DOLLY_PAN:if(!1===n.enableZoom&&!1===n.enablePan)return;n.enableZoom&&B(),n.enablePan&&k(),s=a.TOUCH_DOLLY_PAN;break;case Cc.DOLLY_ROTATE:if(!1===n.enableZoom&&!1===n.enableRotate)return;n.enableZoom&&B(),n.enableRotate&&D(),s=a.TOUCH_DOLLY_ROTATE;break;default:s=a.NONE}break;default:s=a.NONE}s!==a.NONE&&n.dispatchEvent(r)}(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 Mc.DOLLY:if(!1===n.enableZoom)return;!function(e){b.set(e.clientX,e.clientY)}(e),s=a.DOLLY;break;case Mc.ROTATE:if(e.ctrlKey||e.metaKey||e.shiftKey){if(!1===n.enablePan)return;P(e),s=a.PAN}else{if(!1===n.enableRotate)return;L(e),s=a.ROTATE}break;case Mc.PAN:if(e.ctrlKey||e.metaKey||e.shiftKey){if(!1===n.enableRotate)return;L(e),s=a.ROTATE}else{if(!1===n.enablePan)return;P(e),s=a.PAN}break;default:s=a.NONE}s!==a.NONE&&n.dispatchEvent(r)}(e)}}function j(e){!1!==n.enabled&&("touch"===e.pointerType?function(e){switch(J(e),s){case a.TOUCH_ROTATE:if(!1===n.enableRotate)return;F(e),n.update();break;case a.TOUCH_PAN:if(!1===n.enablePan)return;U(e),n.update();break;case a.TOUCH_DOLLY_PAN:if(!1===n.enableZoom&&!1===n.enablePan)return;!function(e){n.enableZoom&&z(e),n.enablePan&&U(e)}(e),n.update();break;case a.TOUCH_DOLLY_ROTATE:if(!1===n.enableZoom&&!1===n.enableRotate)return;!function(e){n.enableZoom&&z(e),n.enableRotate&&F(e)}(e),n.update();break;default:s=a.NONE}}(e):function(e){if(!1===n.enabled)return;switch(s){case a.ROTATE:if(!1===n.enableRotate)return;!function(e){f.set(e.clientX,e.clientY),g.subVectors(f,m).multiplyScalar(n.rotateSpeed);const t=n.domElement;t&&(T(2*Math.PI*g.x/t.clientHeight),I(2*Math.PI*g.y/t.clientHeight)),m.copy(f),n.update()}(e);break;case a.DOLLY:if(!1===n.enableZoom)return;!function(e){x.set(e.clientX,e.clientY),w.subVectors(x,b),w.y>0?O(A()):w.y<0&&R(A()),b.copy(x),n.update()}(e);break;case a.PAN:if(!1===n.enablePan)return;!function(e){y.set(e.clientX,e.clientY),_.subVectors(y,v).multiplyScalar(n.panSpeed),N(_.x,_.y),v.copy(y),n.update()}(e)}}(e))}function H(e){var t,i,r;(Y(e),0===S.length)&&(null===(t=n.domElement)||void 0===t||t.releasePointerCapture(e.pointerId),null===(i=n.domElement)||void 0===i||i.ownerDocument.removeEventListener("pointermove",j),null===(r=n.domElement)||void 0===r||r.ownerDocument.removeEventListener("pointerup",H));n.dispatchEvent(o),s=a.NONE}function V(e){Y(e)}function W(e){!1===n.enabled||!1===n.enableZoom||s!==a.NONE&&s!==a.ROTATE||(e.preventDefault(),n.dispatchEvent(r),function(e){e.deltaY<0?R(A()):e.deltaY>0&&O(A()),n.update()}(e),n.dispatchEvent(o))}function q(e){!1!==n.enabled&&!1!==n.enablePan&&function(e){let t=!1;switch(e.code){case n.keys.UP:N(0,n.keyPanSpeed),t=!0;break;case n.keys.BOTTOM:N(0,-n.keyPanSpeed),t=!0;break;case n.keys.LEFT:N(n.keyPanSpeed,0),t=!0;break;case n.keys.RIGHT:N(-n.keyPanSpeed,0),t=!0}t&&(e.preventDefault(),n.update())}(e)}function $(e){!1!==n.enabled&&e.preventDefault()}function Y(e){delete E[e.pointerId];for(let t=0;t<S.length;t++)if(S[t].pointerId==e.pointerId)return void S.splice(t,1)}function J(e){let t=E[e.pointerId];void 0===t&&(t=new Kh,E[e.pointerId]=t),t.set(e.pageX,e.pageY)}function Z(e){const t=e.pointerId===S[0].pointerId?S[1]:S[0];return E[t.pointerId]}void 0!==t&&this.connect(t),this.update()}}const IN=c.forwardRef((({makeDefault:e,camera:t,regress:n,domElement:i,enableDamping:r=!0,onChange:o,onStart:a,onEnd:s,...l},u)=>{const d=sN((e=>e.invalidate)),h=sN((e=>e.camera)),p=sN((e=>e.gl)),m=sN((e=>e.events)),f=sN((e=>e.set)),g=sN((e=>e.get)),v=sN((e=>e.performance)),y=t||h,_=i||m.connected||p.domElement,b=c.useMemo((()=>new TN(y)),[y]);return lN((()=>{b.enabled&&b.update()})),c.useEffect((()=>(b.connect(_),()=>{b.dispose()})),[_,n,b,d]),c.useEffect((()=>{const e=e=>{d(),n&&v.regress(),o&&o(e)};return b.addEventListener("change",e),a&&b.addEventListener("start",a),s&&b.addEventListener("end",s),()=>{a&&b.removeEventListener("start",a),s&&b.removeEventListener("end",s),b.removeEventListener("change",e)}}),[o,a,s]),c.useEffect((()=>{if(e){const e=g().controls;return f({controls:b}),()=>f({controls:e})}}),[e,b]),c.createElement("primitive",bN({ref:u,object:b,enableDamping:r},l))}));const MN=(c=o("85Hg2")).forwardRef((({makeDefault:e,...t},n)=>{const i=sN((({set:e})=>e)),r=sN((({camera:e})=>e)),o=sN((({size:e})=>e)),a=c.useRef();return c.useLayoutEffect((()=>{const{current:e}=a;e&&!t.manual&&(e.aspect=o.width/o.height,e.updateProjectionMatrix())}),[o,t]),c.useLayoutEffect((()=>{if(e&&a.current){const e=r;return i((()=>({camera:a.current}))),()=>i((()=>({camera:e})))}}),[r,a,e,i]),c.createElement("perspectiveCamera",bN({ref:NC([a,n])},t))}));c=o("85Hg2"),c=o("85Hg2");const CN=new WeakMap;class NN extends Hx{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,i){const r=new qx(this.manager);r.setPath(this.path),r.setResponseType("arraybuffer"),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(e,(e=>{const n={attributeIDs:this.defaultAttributeIDs,attributeTypes:this.defaultAttributeTypes,useUniqueIDs:!1};this.decodeGeometry(e,n).then(t).catch(i)}),n,i)}decodeDracoFile(e,t,n,i){const r={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:i||this.defaultAttributeTypes,useUniqueIDs:!!n};this.decodeGeometry(e,r).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(CN.has(e)){const t=CN.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 i;const r=this.workerNextTaskID++,o=e.byteLength,a=this._getWorker(r,o).then((n=>(i=n,new Promise(((n,o)=>{i._callbacks[r]={resolve:n,reject:o},i.postMessage({type:"decode",id:r,taskConfig:t,buffer:e},[e])}))))).then((e=>this._createGeometry(e.geometry)));return a.catch((()=>!0)).then((()=>{i&&r&&this._releaseTask(i,r)})),CN.set(e,{key:n,promise:a}),a}_createGeometry(e){const t=new pf;e.index&&t.setIndex(new Ym(e.index.array,1));for(let n=0;n<e.attributes.length;n++){const i=e.attributes[n],r=i.name,o=i.array,a=i.itemSize;t.setAttribute(r,new Ym(o,a))}return t}_loadLibrary(e,t){const n=new qx(this.manager);return n.setPath(this.decoderPath),n.setResponseType(t),n.setWithCredentials(this.withCredentials),new Promise(((t,i)=>{n.load(e,t,void 0,i)}))}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 i=ON.toString(),r=["/* draco decoder */",n,"","/* worker */",i.substring(i.indexOf("{")+1,i.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([r]))})),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 ON(){let e,t;function n(e,t,n,i,r,o){const a=o.num_components(),s=n.num_points()*a,l=s*r.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,r),u=e._malloc(l);t.GetAttributeDataArrayForAllPoints(n,o,c,l,u);const d=new r(e.HEAPF32.buffer,u,s).slice();return e._free(u),{name:i,array:d,itemSize:a}}onmessage=function(i){const r=i.data;switch(r.type){case"init":e=r.decoderConfig,t=new Promise((function(t){e.onModuleLoaded=function(e){t({draco:e})},DracoDecoderModule(e)}));break;case"decode":const i=r.buffer,o=r.taskConfig;t.then((e=>{const t=e.draco,a=new t.Decoder,s=new t.DecoderBuffer;s.Init(new Int8Array(i),i.byteLength);try{const e=function(e,t,i,r){const o=r.attributeIDs,a=r.attributeTypes;let s,l;const c=t.GetEncodedGeometryType(i);if(c===e.TRIANGULAR_MESH)s=new e.Mesh,l=t.DecodeBufferToMesh(i,s);else{if(c!==e.POINT_CLOUD)throw new Error("THREE.DRACOLoader: Unexpected geometry type.");s=new e.PointCloud,l=t.DecodeBufferToPointCloud(i,s)}if(!l.ok()||0===s.ptr)throw new Error("THREE.DRACOLoader: Decoding failed: "+l.error_msg());const u={index:null,attributes:[]};for(const i in o){const l=self[a[i]];let c,d;if(r.useUniqueIDs)d=o[i],c=t.GetAttributeByUniqueId(s,d);else{if(d=t.GetAttributeId(s,e[o[i]]),-1===d)continue;c=t.GetAttribute(s,d)}u.attributes.push(n(e,t,s,i,l,c))}c===e.TRIANGULAR_MESH&&(u.index=function(e,t,n){const i=n.num_faces(),r=3*i,o=4*r,a=e._malloc(o);t.GetTrianglesUInt32Array(n,o,a);const s=new Uint32Array(e.HEAPF32.buffer,a,r).slice();return e._free(a),{array:s,itemSize:1}}(e,t,s));return e.destroy(s),u}(t,a,s,o),i=e.attributes.map((e=>e.array.buffer));e.index&&i.push(e.index.array.buffer),self.postMessage({type:"decode",id:r.id,geometry:e},i)}catch(e){console.error(e),self.postMessage({type:"error",id:r.id,error:e.message})}finally{t.destroy(s),t.destroy(a)}}))}}}let RN;const LN=()=>{if(RN)return RN;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,i="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)&&(i="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 r=WebAssembly.instantiate(function(e){const n=new Uint8Array(e.length);for(let t=0;t<e.length;++t){const i=e.charCodeAt(t);n[t]=i>96?i-71:i>64?i-65:i>47?i+4:i>46?63:62}let i=0;for(let r=0;r<e.length;++r)n[i++]=n[r]<60?t[n[r]]:64*(n[r]-60)+n[++r];return n.buffer.slice(0,i)}(i),{}).then((e=>{n=e.instance,n.exports.__wasm_call_ctors()}));function o(e,t,i,r,o,a){const s=n.exports.sbrk,l=i+3&-4,c=s(l*r),u=s(o.length),d=new Uint8Array(n.exports.memory.buffer);d.set(o,u);const h=e(c,i,r,u,o.length);if(0===h&&a&&a(c,l,r),t.set(d.subarray(c,c+i*r)),s(c-s(0)),0!==h)throw new Error(`Malformed buffer data: ${h}`)}const a={0:"",1:"meshopt_decodeFilterOct",2:"meshopt_decodeFilterQuat",3:"meshopt_decodeFilterExp",NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},s={0:"meshopt_decodeVertexBuffer",1:"meshopt_decodeIndexBuffer",2:"meshopt_decodeIndexSequence",ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return RN={ready:r,supported:!0,decodeVertexBuffer(e,t,i,r,s){o(n.exports.meshopt_decodeVertexBuffer,e,t,i,r,n.exports[a[s]])},decodeIndexBuffer(e,t,i,r){o(n.exports.meshopt_decodeIndexBuffer,e,t,i,r)},decodeIndexSequence(e,t,i,r){o(n.exports.meshopt_decodeIndexSequence,e,t,i,r)},decodeGltfBuffer(e,t,i,r,l,c){o(n.exports[s[l]],e,t,i,r,n.exports[a[c]])}},RN};class PN extends Hx{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register((function(e){return new zN(e)})),this.register((function(e){return new $N(e)})),this.register((function(e){return new YN(e)})),this.register((function(e){return new jN(e)})),this.register((function(e){return new HN(e)})),this.register((function(e){return new VN(e)})),this.register((function(e){return new WN(e)})),this.register((function(e){return new UN(e)})),this.register((function(e){return new qN(e)})),this.register((function(e){return new GN(e)})),this.register((function(e){return new BN(e)})),this.register((function(e){return new JN(e)}))}load(e,t,n,i){const r=this;let o;o=""!==this.resourcePath?this.resourcePath:""!==this.path?this.path:_w.extractUrlBase(e),this.manager.itemStart(e);const a=function(t){i?i(t):console.error(t),r.manager.itemError(e),r.manager.itemEnd(e)},s=new qx(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,(function(n){try{r.parse(n,o,(function(n){t(n),r.manager.itemEnd(e)}),a)}catch(e){a(e)}}),n,a)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return-1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}unregister(e){return-1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,i){let r;const o={},a={};if("string"==typeof e)r=e;else{if(_w.decodeText(new Uint8Array(e,0,4))===ZN){try{o[kN.KHR_BINARY_GLTF]=new QN(e)}catch(e){return void(i&&i(e))}r=o[kN.KHR_BINARY_GLTF].content}else r=_w.decodeText(new Uint8Array(e))}const s=JSON.parse(r);if(void 0===s.asset||s.asset.version[0]<2)return void(i&&i(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));const l=new OO(s,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e<this.pluginCallbacks.length;e++){const t=this.pluginCallbacks[e](l);a[t.name]=t,o[t.name]=!0}if(s.extensionsUsed)for(let e=0;e<s.extensionsUsed.length;++e){const t=s.extensionsUsed[e],n=s.extensionsRequired||[];switch(t){case kN.KHR_MATERIALS_UNLIT:o[t]=new FN;break;case kN.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:o[t]=new iO;break;case kN.KHR_DRACO_MESH_COMPRESSION:o[t]=new eO(s,this.dracoLoader);break;case kN.KHR_TEXTURE_TRANSFORM:o[t]=new tO;break;case kN.KHR_MESH_QUANTIZATION:o[t]=new rO;break;default:n.indexOf(t)>=0&&void 0===a[t]&&console.warn('THREE.GLTFLoader: Unknown extension "'+t+'".')}}l.setExtensions(o),l.setPlugins(a),l.parse(n,i)}parseAsync(e,t){const n=this;return new Promise((function(i,r){n.parse(e,t,i,r)}))}}function DN(){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 kN={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 BN{constructor(e){this.parser=e,this.name=kN.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n<i;n++){const i=t[n];i.extensions&&i.extensions[this.name]&&void 0!==i.extensions[this.name].light&&e._addNodeRef(this.cache,i.extensions[this.name].light)}}_loadLight(e){const t=this.parser,n="light:"+e;let i=t.cache.get(n);if(i)return i;const r=t.json,o=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e];let a;const s=new mp(16777215);void 0!==o.color&&s.fromArray(o.color);const l=void 0!==o.range?o.range:0;switch(o.type){case"directional":a=new pw(s),a.target.position.set(0,0,-1),a.add(a.target);break;case"point":a=new dw(s),a.distance=l;break;case"spot":a=new aw(s),a.distance=l,o.spot=o.spot||{},o.spot.innerConeAngle=void 0!==o.spot.innerConeAngle?o.spot.innerConeAngle:0,o.spot.outerConeAngle=void 0!==o.spot.outerConeAngle?o.spot.outerConeAngle:Math.PI/4,a.angle=o.spot.outerConeAngle,a.penumbra=1-o.spot.innerConeAngle/o.spot.outerConeAngle,a.target.position.set(0,0,-1),a.add(a.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+o.type)}return a.position.set(0,0,0),a.decay=2,void 0!==o.intensity&&(a.intensity=o.intensity),a.name=t.createUniqueName(o.name||"light_"+e),i=Promise.resolve(a),t.cache.add(n,i),i}createNodeAttachment(e){const t=this,n=this.parser,i=n.json.nodes[e],r=(i.extensions&&i.extensions[this.name]||{}).light;return void 0===r?null:this._loadLight(r).then((function(e){return n._getNodeRef(t.cache,r,e)}))}}class FN{constructor(){this.name=kN.KHR_MATERIALS_UNLIT}getMaterialType(){return Wm}extendParams(e,t,n){const i=[];e.color=new mp(1,1,1),e.opacity=1;const r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){const t=r.baseColorFactor;e.color.fromArray(t),e.opacity=t[3]}void 0!==r.baseColorTexture&&i.push(n.assignTexture(e,"map",r.baseColorTexture,th))}return Promise.all(i)}}class UN{constructor(e){this.parser=e,this.name=kN.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 i=n.extensions[this.name].emissiveStrength;return void 0!==i&&(t.emissiveIntensity=i),Promise.resolve()}}class zN{constructor(e){this.parser=e,this.name=kN.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?hx:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],o=i.extensions[this.name];if(void 0!==o.clearcoatFactor&&(t.clearcoat=o.clearcoatFactor),void 0!==o.clearcoatTexture&&r.push(n.assignTexture(t,"clearcoatMap",o.clearcoatTexture)),void 0!==o.clearcoatRoughnessFactor&&(t.clearcoatRoughness=o.clearcoatRoughnessFactor),void 0!==o.clearcoatRoughnessTexture&&r.push(n.assignTexture(t,"clearcoatRoughnessMap",o.clearcoatRoughnessTexture)),void 0!==o.clearcoatNormalTexture&&(r.push(n.assignTexture(t,"clearcoatNormalMap",o.clearcoatNormalTexture)),void 0!==o.clearcoatNormalTexture.scale)){const e=o.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new Kh(e,e)}return Promise.all(r)}}class GN{constructor(e){this.parser=e,this.name=kN.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?hx:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],o=i.extensions[this.name];return void 0!==o.iridescenceFactor&&(t.iridescence=o.iridescenceFactor),void 0!==o.iridescenceTexture&&r.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&&r.push(n.assignTexture(t,"iridescenceThicknessMap",o.iridescenceThicknessTexture)),Promise.all(r)}}class jN{constructor(e){this.parser=e,this.name=kN.KHR_MATERIALS_SHEEN}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?hx:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[];t.sheenColor=new mp(0,0,0),t.sheenRoughness=0,t.sheen=1;const o=i.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&&r.push(n.assignTexture(t,"sheenColorMap",o.sheenColorTexture,th)),void 0!==o.sheenRoughnessTexture&&r.push(n.assignTexture(t,"sheenRoughnessMap",o.sheenRoughnessTexture)),Promise.all(r)}}class HN{constructor(e){this.parser=e,this.name=kN.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?hx:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],o=i.extensions[this.name];return void 0!==o.transmissionFactor&&(t.transmission=o.transmissionFactor),void 0!==o.transmissionTexture&&r.push(n.assignTexture(t,"transmissionMap",o.transmissionTexture)),Promise.all(r)}}class VN{constructor(e){this.parser=e,this.name=kN.KHR_MATERIALS_VOLUME}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?hx:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],o=i.extensions[this.name];t.thickness=void 0!==o.thicknessFactor?o.thicknessFactor:0,void 0!==o.thicknessTexture&&r.push(n.assignTexture(t,"thicknessMap",o.thicknessTexture)),t.attenuationDistance=o.attenuationDistance||1/0;const a=o.attenuationColor||[1,1,1];return t.attenuationColor=new mp(a[0],a[1],a[2]),Promise.all(r)}}class WN{constructor(e){this.parser=e,this.name=kN.KHR_MATERIALS_IOR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?hx:null}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name];return t.ior=void 0!==i.ior?i.ior:1.5,Promise.resolve()}}class qN{constructor(e){this.parser=e,this.name=kN.KHR_MATERIALS_SPECULAR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?hx:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],o=i.extensions[this.name];t.specularIntensity=void 0!==o.specularFactor?o.specularFactor:1,void 0!==o.specularTexture&&r.push(n.assignTexture(t,"specularIntensityMap",o.specularTexture));const a=o.specularColorFactor||[1,1,1];return t.specularColor=new mp(a[0],a[1],a[2]),void 0!==o.specularColorTexture&&r.push(n.assignTexture(t,"specularColorMap",o.specularColorTexture,th)),Promise.all(r)}}class $N{constructor(e){this.parser=e,this.name=kN.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,i=n.textures[e];if(!i.extensions||!i.extensions[this.name])return null;const r=i.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,r.source,o)}}class YN{constructor(e){this.parser=e,this.name=kN.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;const o=r.extensions[t],a=i.images[o.source];let s=n.textureLoader;if(a.uri){const e=n.options.manager.getHandler(a.uri);null!==e&&(s=e)}return this.detectSupport().then((function(r){if(r)return n.loadTextureImage(e,o.source,s);if(i.extensionsRequired&&i.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 JN{constructor(e){this.name=kN.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],i=this.parser.getDependency("buffer",e.buffer),r=this.parser.options.meshoptDecoder;if(!r||!r.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 i.then((function(t){const n=e.byteOffset||0,i=e.byteLength||0,o=e.count,a=e.byteStride,s=new Uint8Array(t,n,i);return r.decodeGltfBufferAsync?r.decodeGltfBufferAsync(o,a,s,e.mode,e.filter).then((function(e){return e.buffer})):r.ready.then((function(){const t=new ArrayBuffer(o*a);return r.decodeGltfBuffer(new Uint8Array(t),o,a,s,e.mode,e.filter),t}))}))}return null}}const ZN="glTF",XN=1313821514,KN=5130562;class QN{constructor(e){this.name=kN.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,12);if(this.header={magic:_w.decodeText(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==ZN)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,i=new DataView(e,12);let r=0;for(;r<n;){const t=i.getUint32(r,!0);r+=4;const n=i.getUint32(r,!0);if(r+=4,n===XN){const n=new Uint8Array(e,12+r,t);this.content=_w.decodeText(n)}else if(n===KN){const n=12+r;this.body=e.slice(n,n+t)}r+=t}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class eO{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=kN.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,i=this.dracoLoader,r=e.extensions[this.name].bufferView,o=e.extensions[this.name].attributes,a={},s={},l={};for(const e in o){const t=_O[e]||e.toLowerCase();a[t]=o[e]}for(const t in e.attributes){const i=_O[t]||t.toLowerCase();if(void 0!==o[t]){const r=n.accessors[e.attributes[t]],o=fO[r.componentType];l[i]=o.name,s[i]=!0===r.normalized}}return t.getDependency("bufferView",r).then((function(e){return new Promise((function(t){i.decodeDracoFile(e,(function(e){for(const t in e.attributes){const n=e.attributes[t],i=s[t];void 0!==i&&(n.normalized=i)}t(e)}),a,l)}))}))}}class tO{constructor(){this.name=kN.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 nO extends dx{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"),i=["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"),r=["float glossinessFactor = glossiness;","#ifdef USE_GLOSSINESSMAP","\tvec4 texelGlossiness = texture2D( glossinessMap, vUv );","\t// reads channel A, compatible with a glTF Specular-Glossiness (RGBA) texture","\tglossinessFactor *= texelGlossiness.a;","#endif"].join("\n"),o=["PhysicalMaterial material;","material.diffuseColor = diffuseColor.rgb * ( 1. - max( specularFactor.r, max( specularFactor.g, specularFactor.b ) ) );","vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );","float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );","material.roughness = max( 1.0 - glossinessFactor, 0.0525 ); // 0.0525 corresponds to the base mip of a 256 cubemap.","material.roughness += geometryRoughness;","material.roughness = min( material.roughness, 1.0 );","material.specularColor = specularFactor;"].join("\n"),a={specular:{value:(new mp).setHex(16777215)},glossiness:{value:1},specularMap:{value:null},glossinessMap:{value:null}};this._extraUniforms=a,this.onBeforeCompile=function(e){for(const t in a)e.uniforms[t]=a[t];e.fragmentShader=e.fragmentShader.replace("uniform float roughness;","uniform vec3 specular;").replace("uniform float metalness;","uniform float glossiness;").replace("#include <roughnessmap_pars_fragment>",t).replace("#include <metalnessmap_pars_fragment>",n).replace("#include <roughnessmap_fragment>",i).replace("#include <metalnessmap_fragment>",r).replace("#include <lights_physical_fragment>",o)},Object.defineProperties(this,{specular:{get:function(){return a.specular.value},set:function(e){a.specular.value=e}},specularMap:{get:function(){return a.specularMap.value},set:function(e){a.specularMap.value=e,e?this.defines.USE_SPECULARMAP="":delete this.defines.USE_SPECULARMAP}},glossiness:{get:function(){return a.glossiness.value},set:function(e){a.glossiness.value=e}},glossinessMap:{get:function(){return a.glossinessMap.value},set:function(e){a.glossinessMap.value=e,e?(this.defines.USE_GLOSSINESSMAP="",this.defines.USE_UV=""):(delete this.defines.USE_GLOSSINESSMAP,delete this.defines.USE_UV)}}}),delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this.setValues(e)}copy(e){return super.copy(e),this.specularMap=e.specularMap,this.specular.copy(e.specular),this.glossinessMap=e.glossinessMap,this.glossiness=e.glossiness,delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this}}class iO{constructor(){this.name=kN.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 nO}extendParams(e,t,n){const i=t.extensions[this.name];e.color=new mp(1,1,1),e.opacity=1;const r=[];if(Array.isArray(i.diffuseFactor)){const t=i.diffuseFactor;e.color.fromArray(t),e.opacity=t[3]}if(void 0!==i.diffuseTexture&&r.push(n.assignTexture(e,"map",i.diffuseTexture,th)),e.emissive=new mp(0,0,0),e.glossiness=void 0!==i.glossinessFactor?i.glossinessFactor:1,e.specular=new mp(1,1,1),Array.isArray(i.specularFactor)&&e.specular.fromArray(i.specularFactor),void 0!==i.specularGlossinessTexture){const t=i.specularGlossinessTexture;r.push(n.assignTexture(e,"glossinessMap",t)),r.push(n.assignTexture(e,"specularMap",t,th))}return Promise.all(r)}createMaterial(e){const t=new nO(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=rh,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 rO{constructor(){this.name=kN.KHR_MESH_QUANTIZATION}}class oO extends Tx{constructor(e,t,n,i){super(e,t,n,i)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i*3+i;for(let e=0;e!==i;e++)t[e]=n[r+e];return t}interpolate_(e,t,n,i){const r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,s=2*a,l=3*a,c=i-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!==a;e++){const t=o[m+e+a],n=o[m+e+s]*c,i=o[p+e+a],l=o[p+e]*c;r[e]=v*t+y*n+f*i+g*l}return r}}const aO=new Mp;class sO extends oO{interpolate_(e,t,n,i){const r=super.interpolate_(e,t,n,i);return aO.fromArray(r).normalize().toArray(r),r}}const lO=0,cO=1,uO=2,dO=3,hO=4,pO=5,mO=6,fO={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},gO={9728:Du,9729:zu,9984:ku,9985:Gu,9986:Fu,9987:Hu},vO={33071:Lu,33648:Pu,10497:Ru},yO={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},_O={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},bO={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},xO={CUBICSPLINE:void 0,LINEAR:Vd,STEP:Hd},wO="OPAQUE",SO="MASK",EO="BLEND";function AO(e,t,n){for(const i in n.extensions)void 0===e[i]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[i]=n.extensions[i])}function TO(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 IO(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(let n=0,i=t.weights.length;n<i;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,i=n.length;t<i;t++)e.morphTargetDictionary[n[t]]=t}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function MO(e){const t=e.extensions&&e.extensions[kN.KHR_DRACO_MESH_COMPRESSION];let n;return n=t?"draco:"+t.bufferView+":"+t.indices+":"+CO(t.attributes):e.indices+":"+CO(e.attributes)+":"+e.mode,n}function CO(e){let t="";const n=Object.keys(e).sort();for(let i=0,r=n.length;i<r;i++)t+=n[i]+":"+e[n[i]]+";";return t}function NO(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 OO{constructor(e={},t={}){var n,i;this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new DN,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 r="undefined"!=typeof navigator&&!0===/^((?!chrome|android).)*safari/i.test(navigator.userAgent),o="undefined"!=typeof navigator&&(null===(n=navigator.userAgent)||void 0===n?void 0:n.indexOf("Firefox"))>-1,a="undefined"!=typeof navigator&&o?null===(i=navigator.userAgent)||void 0===i?void 0:i.match(/Firefox\/([0-9]+)\./)[1]:-1;"undefined"==typeof createImageBitmap||r||o&&a<98?this.textureLoader=new Kx(this.options.manager):this.textureLoader=new Tw(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new qx(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,i=this.json,r=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][i.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:i.asset,parser:n,userData:{}};AO(r,o,i),TO(o,i),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,i=t.length;n<i;n++){const i=t[n].joints;for(let t=0,n=i.length;t<n;t++)e[i[t]].isBone=!0}for(let t=0,i=e.length;t<i;t++){const i=e[t];void 0!==i.mesh&&(this._addNodeRef(this.meshCache,i.mesh),void 0!==i.skin&&(n[i.mesh].isSkinnedMesh=!0)),void 0!==i.camera&&this._addNodeRef(this.cameraCache,i.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 i=n.clone(),r=(e,t)=>{const n=this.associations.get(e);null!=n&&this.associations.set(t,n);for(const[n,i]of e.children.entries())r(i,t.children[n])};return r(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const i=e(t[n]);if(i)return i}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let i=0;i<t.length;i++){const r=e(t[i]);r&&n.push(r)}return n}getDependency(e,t){const n=e+":"+t;let i=this.cache.get(n);if(!i){switch(e){case"scene":i=this.loadScene(t);break;case"node":i=this.loadNode(t);break;case"mesh":i=this._invokeOne((function(e){return e.loadMesh&&e.loadMesh(t)}));break;case"accessor":i=this.loadAccessor(t);break;case"bufferView":i=this._invokeOne((function(e){return e.loadBufferView&&e.loadBufferView(t)}));break;case"buffer":i=this.loadBuffer(t);break;case"material":i=this._invokeOne((function(e){return e.loadMaterial&&e.loadMaterial(t)}));break;case"texture":i=this._invokeOne((function(e){return e.loadTexture&&e.loadTexture(t)}));break;case"skin":i=this.loadSkin(t);break;case"animation":i=this._invokeOne((function(e){return e.loadAnimation&&e.loadAnimation(t)}));break;case"camera":i=this.loadCamera(t);break;default:throw new Error("Unknown type: "+e)}this.cache.add(n,i)}return i}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,i=this.json[e+("mesh"===e?"es":"s")]||[];t=Promise.all(i.map((function(t,i){return n.getDependency(e,i)}))),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[kN.KHR_BINARY_GLTF].body);const i=this.options;return new Promise((function(e,r){n.load(_w.resolveURL(t.uri,i.path),e,void 0,(function(){r(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,i=t.byteOffset||0;return e.slice(i,i+n)}))}loadAccessor(e){const t=this,n=this.json,i=this.json.accessors[e];if(void 0===i.bufferView&&void 0===i.sparse)return Promise.resolve(null);const r=[];return void 0!==i.bufferView?r.push(this.getDependency("bufferView",i.bufferView)):r.push(null),void 0!==i.sparse&&(r.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",i.sparse.values.bufferView))),Promise.all(r).then((function(e){const r=e[0],o=yO[i.type],a=fO[i.componentType],s=a.BYTES_PER_ELEMENT,l=s*o,c=i.byteOffset||0,u=void 0!==i.bufferView?n.bufferViews[i.bufferView].byteStride:void 0,d=!0===i.normalized;let h,p;if(u&&u!==l){const e=Math.floor(c/u),n="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+e+":"+i.count;let l=t.cache.get(n);l||(h=new a(r,e*u,i.count*u/s),l=new Ly(h,u/s),t.cache.add(n,l)),p=new Dy(l,o,c%u/s,d)}else h=null===r?new a(i.count*o):new a(r,c,i.count*o),p=new Ym(h,o,d);if(void 0!==i.sparse){const t=yO.SCALAR,n=fO[i.sparse.indices.componentType],s=i.sparse.indices.byteOffset||0,l=i.sparse.values.byteOffset||0,c=new n(e[1],s,i.sparse.count*t),u=new a(e[2],l,i.sparse.count*o);null!==r&&(p=new Ym(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,i=t.textures[e].source,r=t.images[i];let o=this.textureLoader;if(r.uri){const e=n.manager.getHandler(r.uri);null!==e&&(o=e)}return this.loadTextureImage(e,i,o)}loadTextureImage(e,t,n){const i=this,r=this.json,o=r.textures[e],a=r.images[t],s=(a.uri||a.bufferView)+":"+o.sampler;if(this.textureCache[s])return this.textureCache[s];const l=this.loadImageSource(t,n).then((function(t){t.flipY=!1,o.name&&(t.name=o.name);const n=(r.samplers||{})[o.sampler]||{};return t.magFilter=gO[n.magFilter]||zu,t.minFilter=gO[n.minFilter]||Hu,t.wrapS=vO[n.wrapS]||Ru,t.wrapT=vO[n.wrapT]||Ru,i.associations.set(t,{textures:e}),t})).catch((function(){return null}));return this.textureCache[s]=l,l}loadImageSource(e,t){const n=this.json,i=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then((e=>e.clone()));const r=n.images[e],o=self.URL||self.webkitURL;let a=r.uri||"",s=!1;if(void 0!==r.bufferView)a=this.getDependency("bufferView",r.bufferView).then((function(e){s=!0;const t=new Blob([e],{type:r.mimeType});return a=o.createObjectURL(t),a}));else if(void 0===r.uri)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const l=Promise.resolve(a).then((function(e){return new Promise((function(n,r){let o=n;!0===t.isImageBitmapLoader&&(o=function(e){const t=new bp(e);t.needsUpdate=!0,n(t)}),t.load(_w.resolveURL(e,i.path),o,void 0,r)}))})).then((function(e){var t;return!0===s&&o.revokeObjectURL(a),e.userData.mimeType=r.mimeType||((t=r.uri).search(/\.jpe?g($|\?)/i)>0||0===t.search(/^data\:image\/jpeg/)?"image/jpeg":t.search(/\.webp($|\?)/i)>0||0===t.search(/^data\:image\/webp/)?"image/webp":"image/png"),e})).catch((function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",a),e}));return this.sourceCache[e]=l,l}assignTexture(e,t,n,i){const r=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."),r.extensions[kN.KHR_TEXTURE_TRANSFORM]){const e=void 0!==n.extensions?n.extensions[kN.KHR_TEXTURE_TRANSFORM]:void 0;if(e){const t=r.associations.get(o);o=r.extensions[kN.KHR_TEXTURE_TRANSFORM].extendTexture(o,e),r.associations.set(o,t)}}return void 0!==i&&(o.encoding=i),e[t]=o,o}))}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const i=void 0===t.attributes.tangent,r=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 C_,Vm.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 y_,Vm.prototype.copy.call(t,n),t.color.copy(n.color),this.cache.add(e,t)),n=t}if(i||r||o){let e="ClonedMaterial:"+n.uuid+":";n.isGLTFSpecularGlossinessMaterial&&(e+="specular-glossiness:"),i&&(e+="derivative-tangents:"),r&&(e+="vertex-colors:"),o&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=n.clone(),r&&(t.vertexColors=!0),o&&(t.flatShading=!0),i&&(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 dx}loadMaterial(e){const t=this,n=this.json,i=this.extensions,r=n.materials[e];let o;const a={},s=r.extensions||{},l=[];if(s[kN.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]){const e=i[kN.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS];o=e.getMaterialType(),l.push(e.extendParams(a,r,t))}else if(s[kN.KHR_MATERIALS_UNLIT]){const e=i[kN.KHR_MATERIALS_UNLIT];o=e.getMaterialType(),l.push(e.extendParams(a,r,t))}else{const n=r.pbrMetallicRoughness||{};if(a.color=new mp(1,1,1),a.opacity=1,Array.isArray(n.baseColorFactor)){const e=n.baseColorFactor;a.color.fromArray(e),a.opacity=e[3]}void 0!==n.baseColorTexture&&l.push(t.assignTexture(a,"map",n.baseColorTexture,th)),a.metalness=void 0!==n.metallicFactor?n.metallicFactor:1,a.roughness=void 0!==n.roughnessFactor?n.roughnessFactor:1,void 0!==n.metallicRoughnessTexture&&(l.push(t.assignTexture(a,"metalnessMap",n.metallicRoughnessTexture)),l.push(t.assignTexture(a,"roughnessMap",n.metallicRoughnessTexture))),o=this._invokeOne((function(t){return t.getMaterialType&&t.getMaterialType(e)})),l.push(Promise.all(this._invokeAll((function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,a)}))))}!0===r.doubleSided&&(a.side=zc);const c=r.alphaMode||wO;if(c===EO?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,c===SO&&(a.alphaTest=void 0!==r.alphaCutoff?r.alphaCutoff:.5)),void 0!==r.normalTexture&&o!==Wm&&(l.push(t.assignTexture(a,"normalMap",r.normalTexture)),a.normalScale=new Kh(1,1),void 0!==r.normalTexture.scale)){const e=r.normalTexture.scale;a.normalScale.set(e,e)}return void 0!==r.occlusionTexture&&o!==Wm&&(l.push(t.assignTexture(a,"aoMap",r.occlusionTexture)),void 0!==r.occlusionTexture.strength&&(a.aoMapIntensity=r.occlusionTexture.strength)),void 0!==r.emissiveFactor&&o!==Wm&&(a.emissive=(new mp).fromArray(r.emissiveFactor)),void 0!==r.emissiveTexture&&o!==Wm&&l.push(t.assignTexture(a,"emissiveMap",r.emissiveTexture,th)),Promise.all(l).then((function(){let n;return n=o===nO?i[kN.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].createMaterial(a):new o(a),r.name&&(n.name=r.name),TO(n,r),t.associations.set(n,{materials:e}),r.extensions&&AO(i,n,r),n}))}createUniqueName(e){const t=iS.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,i=this.primitiveCache;function r(e){return n[kN.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then((function(n){return LO(n,e,t)}))}const o=[];for(let n=0,a=e.length;n<a;n++){const a=e[n],s=MO(a),l=i[s];if(l)o.push(l.promise);else{let e;e=a.extensions&&a.extensions[kN.KHR_DRACO_MESH_COMPRESSION]?r(a):LO(new pf,a,t),i[s]={primitive:a,promise:e},o.push(e)}}return Promise.all(o)}loadMesh(e){const t=this,n=this.json,i=this.extensions,r=n.meshes[e],o=r.primitives,a=[];for(let e=0,t=o.length;e<t;e++){const t=void 0===o[e].material?(void 0===(s=this.cache).DefaultMaterial&&(s.DefaultMaterial=new dx({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:Fc})),s.DefaultMaterial):this.getDependency("material",o[e].material);a.push(t)}var s;return a.push(t.loadGeometries(o)),Promise.all(a).then((function(n){const a=n.slice(0,n.length-1),s=n[n.length-1],l=[];for(let n=0,c=s.length;n<c;n++){const c=s[n],u=o[n];let d;const h=a[n];if(u.mode===hO||u.mode===pO||u.mode===mO||void 0===u.mode)d=!0===r.isSkinnedMesh?new a_(c,h):new Of(c,h),!0!==d.isSkinnedMesh||d.geometry.attributes.skinWeight.normalized||d.normalizeSkinWeights(),u.mode===pO?d.geometry=PO(d.geometry,Kd):u.mode===mO&&(d.geometry=PO(d.geometry,Qd));else if(u.mode===cO)d=new I_(c,h);else if(u.mode===dO)d=new E_(c,h);else if(u.mode===uO)d=new M_(c,h);else{if(u.mode!==lO)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+u.mode);d=new P_(c,h)}Object.keys(d.geometry.morphAttributes).length>0&&IO(d,r),d.name=t.createUniqueName(r.name||"mesh_"+e),TO(d,r),u.extensions&&AO(i,d,u),t.assignFinalMaterial(d),l.push(d)}for(let n=0,i=l.length;n<i;n++)t.associations.set(l[n],{meshes:e,primitives:n});if(1===l.length)return l[0];const c=new xy;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],i=n[n.type];if(i)return"perspective"===n.type?t=new Uf(Xh.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):"orthographic"===n.type&&(t=new cg(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),TO(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=[],i=[],r=[],o=[],a=[];for(let e=0,s=t.channels.length;e<s;e++){const s=t.channels[e],l=t.samplers[s.sampler],c=s.target,u=c.node,d=void 0!==t.parameters?t.parameters[l.input]:l.input,h=void 0!==t.parameters?t.parameters[l.output]:l.output;n.push(this.getDependency("node",u)),i.push(this.getDependency("accessor",d)),r.push(this.getDependency("accessor",h)),o.push(l),a.push(c)}return Promise.all([Promise.all(n),Promise.all(i),Promise.all(r),Promise.all(o),Promise.all(a)]).then((function(n){const i=n[0],r=n[1],o=n[2],a=n[3],s=n[4],l=[];for(let e=0,t=i.length;e<t;e++){const t=i[e],n=r[e],c=o[e],u=a[e],d=s[e];if(void 0===t)continue;let h;switch(t.updateMatrix(),bO[d.path]){case bO.weights:h=Lx;break;case bO.rotation:h=Dx;break;default:h=Bx}const p=t.name?t.name:t.uuid,m=void 0!==u.interpolation?xO[u.interpolation]:Vd,f=[];bO[d.path]===bO.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=NO(g.constructor),t=new Float32Array(g.length);for(let n=0,i=g.length;n<i;n++)t[n]=g[n]*e;g=t}for(let e=0,t=f.length;e<t;e++){const t=new h(f[e]+"."+bO[d.path],n.array,g,m);"CUBICSPLINE"===u.interpolation&&(t.createInterpolant=function(e){return new(this instanceof Dx?sO:oO)(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 Fx(c,void 0,l)}))}createNodeMesh(e){const t=this.json,n=this,i=t.nodes[e];return void 0===i.mesh?null:n.getDependency("mesh",i.mesh).then((function(e){const t=n._getNodeRef(n.meshCache,i.mesh,e);return void 0!==i.weights&&t.traverse((function(e){if(e.isMesh)for(let t=0,n=i.weights.length;t<n;t++)e.morphTargetInfluences[t]=i.weights[t]})),t}))}loadNode(e){const t=this.json,n=this.extensions,i=this,r=t.nodes[e],o=r.name?i.createUniqueName(r.name):"";return function(){const t=[],n=i._invokeOne((function(t){return t.createNodeMesh&&t.createNodeMesh(e)}));return n&&t.push(n),void 0!==r.camera&&t.push(i.getDependency("camera",r.camera).then((function(e){return i._getNodeRef(i.cameraCache,r.camera,e)}))),i._invokeAll((function(t){return t.createNodeAttachment&&t.createNodeAttachment(e)})).forEach((function(e){t.push(e)})),Promise.all(t)}().then((function(t){let a;if(a=!0===r.isBone?new s_:t.length>1?new xy:1===t.length?t[0]:new Om,a!==t[0])for(let e=0,n=t.length;e<n;e++)a.add(t[e]);if(r.name&&(a.userData.name=r.name,a.name=o),TO(a,r),r.extensions&&AO(n,a,r),void 0!==r.matrix){const e=new am;e.fromArray(r.matrix),a.applyMatrix4(e)}else void 0!==r.translation&&a.position.fromArray(r.translation),void 0!==r.rotation&&a.quaternion.fromArray(r.rotation),void 0!==r.scale&&a.scale.fromArray(r.scale);return i.associations.has(a)||i.associations.set(a,{}),i.associations.get(a).nodes=e,a}))}loadScene(e){const t=this.json,n=this.extensions,i=this.json.scenes[e],r=this,o=new xy;i.name&&(o.name=r.createUniqueName(i.name)),TO(o,i),i.extensions&&AO(n,o,i);const a=i.nodes||[],s=[];for(let e=0,n=a.length;e<n;e++)s.push(RO(a[e],o,t,r));return Promise.all(s).then((function(){return r.associations=(e=>{const t=new Map;for(const[e,n]of r.associations)(e instanceof Vm||e instanceof bp)&&t.set(e,n);return e.traverse((e=>{const n=r.associations.get(e);null!=n&&t.set(e,n)})),t})(o),o}))}}function RO(e,t,n,i){const r=n.nodes[e];return i.getDependency("node",e).then((function(e){if(void 0===r.skin)return e;let t;return i.getDependency("skin",r.skin).then((function(e){t=e;const n=[];for(let e=0,r=t.joints.length;e<r;e++)n.push(i.getDependency("node",t.joints[e]));return Promise.all(n)})).then((function(n){return e.traverse((function(e){if(!e.isMesh)return;const i=[],r=[];for(let e=0,o=n.length;e<o;e++){const o=n[e];if(o){i.push(o);const n=new am;void 0!==t.inverseBindMatrices&&n.fromArray(t.inverseBindMatrices.array,16*e),r.push(n)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[e])}e.bind(new d_(i,r),e.matrixWorld)})),e}))})).then((function(e){t.add(e);const o=[];if(r.children){const t=r.children;for(let r=0,a=t.length;r<a;r++){const a=t[r];o.push(RO(a,e,n,i))}}return Promise.all(o)}))}function LO(e,t,n){const i=t.attributes,r=[];function o(t,i){return n.getDependency("accessor",t).then((function(t){e.setAttribute(i,t)}))}for(const t in i){const n=_O[t]||t.toLowerCase();n in e.attributes||r.push(o(i[t],n))}if(void 0!==t.indices&&!e.index){const i=n.getDependency("accessor",t.indices).then((function(t){e.setIndex(t)}));r.push(i)}return TO(e,t),function(e,t,n){const i=t.attributes,r=new Rp;if(void 0===i.POSITION)return;{const e=n.json.accessors[i.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(r.set(new Cp(t[0],t[1],t[2]),new Cp(o[0],o[1],o[2])),e.normalized){const t=NO(fO[e.componentType]);r.min.multiplyScalar(t),r.max.multiplyScalar(t)}}const o=t.targets;if(void 0!==o){const e=new Cp,t=new Cp;for(let i=0,r=o.length;i<r;i++){const r=o[i];if(void 0!==r.POSITION){const i=n.json.accessors[r.POSITION],o=i.min,a=i.max;if(void 0!==o&&void 0!==a){if(t.setX(Math.max(Math.abs(o[0]),Math.abs(a[0]))),t.setY(Math.max(Math.abs(o[1]),Math.abs(a[1]))),t.setZ(Math.max(Math.abs(o[2]),Math.abs(a[2]))),i.normalized){const e=NO(fO[i.componentType]);t.multiplyScalar(e)}e.max(t)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}r.expandByVector(e)}e.boundingBox=r;const a=new Xp;r.getCenter(a.center),a.radius=r.min.distanceTo(r.max)/2,e.boundingSphere=a}(e,t,n),Promise.all(r).then((function(){return void 0!==t.targets?function(e,t,n){let i=!1,r=!1,o=!1;for(let e=0,n=t.length;e<n;e++){const n=t[e];if(void 0!==n.POSITION&&(i=!0),void 0!==n.NORMAL&&(r=!0),void 0!==n.COLOR_0&&(o=!0),i&&r&&o)break}if(!i&&!r&&!o)return Promise.resolve(e);const a=[],s=[],l=[];for(let c=0,u=t.length;c<u;c++){const u=t[c];if(i){const t=void 0!==u.POSITION?n.getDependency("accessor",u.POSITION):e.attributes.position;a.push(t)}if(r){const t=void 0!==u.NORMAL?n.getDependency("accessor",u.NORMAL):e.attributes.normal;s.push(t)}if(o){const t=void 0!==u.COLOR_0?n.getDependency("accessor",u.COLOR_0):e.attributes.color;l.push(t)}}return Promise.all([Promise.all(a),Promise.all(s),Promise.all(l)]).then((function(t){const n=t[0],a=t[1],s=t[2];return i&&(e.morphAttributes.position=n),r&&(e.morphAttributes.normal=a),o&&(e.morphAttributes.color=s),e.morphTargetsRelative=!0,e}))}(e,t.targets,n):e}))}function PO(e,t){let n=e.getIndex();if(null===n){const t=[],i=e.getAttribute("position");if(void 0===i)return console.error("THREE.GLTFLoader.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e;for(let e=0;e<i.count;e++)t.push(e);e.setIndex(t),n=e.getIndex()}const i=n.count-2,r=[];if(t===Qd)for(let e=1;e<=i;e++)r.push(n.getX(0)),r.push(n.getX(e)),r.push(n.getX(e+1));else for(let e=0;e<i;e++)e%2==0?(r.push(n.getX(e)),r.push(n.getX(e+1)),r.push(n.getX(e+2))):(r.push(n.getX(e+2)),r.push(n.getX(e+1)),r.push(n.getX(e)));r.length/3!==i&&console.error("THREE.GLTFLoader.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const o=e.clone();return o.setIndex(r),o}let DO=null;function kO(e,t,n){return i=>{n&&n(i),e&&(DO||(DO=new NN),DO.setDecoderPath("string"==typeof e?e:"https://www.gstatic.com/draco/versioned/decoders/1.4.3/"),i.setDRACOLoader(DO)),t&&i.setMeshoptDecoder(LN())}}function BO(e,t=!0,n=!0,i){return dN(PN,e,kO(t,n,i))}BO.preload=(e,t=!0,n=!0,i)=>dN.preload(PN,e,kO(t,n,i)),BO.clear=e=>dN.clear(PN,e);c=o("85Hg2");function FO(e,t){const n=c.useRef(),[i]=c.useState((()=>t?t instanceof Om?{current:t}:t:n)),[r]=c.useState((()=>new sS(void 0))),o=c.useRef({}),[a]=c.useState((()=>{const t={};return e.forEach((e=>Object.defineProperty(t,e.name,{enumerable:!0,get(){if(i.current)return o.current[e.name]||(o.current[e.name]=r.clipAction(e,i.current))}}))),{ref:i,clips:e,actions:t,names:e.map((e=>e.name)),mixer:r}}));return lN(((e,t)=>r.update(t))),c.useEffect((()=>{const e=i.current;return()=>{o.current={},Object.values(a.actions).forEach((t=>{e&&r.uncacheAction(t,e)}))}}),[e]),a}const UO=new Cp(0,-1,0),zO=new gm(.175,0,0),GO=new Cp(0,-1.45,0),jO=[{italian:"Gioia",english:"Joy"},{italian:"Rabbia",english:"Anger"},{italian:"Sorpresa",english:"Surprise"},{italian:"Tristezza",english:"Sadness"},{italian:"Timore",english:"Fear"}],HO=[{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,mouthSmile:.5}},{emotion:{italian:"Gioia",english:"Joy"},blendShapes:{browDownLeft:.5,browDownRight:.5,browInnerUp:.5,mouthSmile:.5}}],VO={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"},WO={minInterval:1e3,maxInterval:5e3,blinkDuration:150};class qO{constructor(e,t,n){this.currentEmotionValues={},this.previousEmotionKeys=new Set,this.isRPM=!1,this.rpmBlendShapes=HO,this.customGlbMapping=jO,this.headMesh=e,this.isRPM="GBNL__Head"!==e.name,t&&(this.rpmBlendShapes=t),n&&(this.customGlbMapping=n)}processChatEmission(e,t){var n,i;const r=this.getDefaultEmotionMorphTargets();if(t||!e)return r;if(!(null==e?void 0:e.includes('<output class="memori-emotion">')))return r;const o=null===(i=null===(n=null==e?void 0:e.split('<output class="memori-emotion">')[1])||void 0===n?void 0:n.split("</output>")[0])||void 0===i?void 0:i.trim();return o?this.processEmotion(o):r}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 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,i,r,o){if(!this.headMesh.morphTargetDictionary||!this.headMesh.morphTargetInfluences)return void console.error("[MorphTargetController] Missing morphTargetDictionary or morphTargetInfluences");const a=this.processChatEmission(t,n),s=this.calculateBlinkValue(e,o,r),l=new Set(Object.keys(a));Object.entries(this.headMesh.morphTargetDictionary).forEach((([e,t])=>{if("number"!=typeof t)return;let n=0;if(l.has(e)){const t=a[e],i=this.currentEmotionValues[e]||0,r=Xh.lerp(i,1.5*t,.3);this.currentEmotionValues[e]=r,n+=r}if(i&&e===i.name&&(n+=i.weight),"eyesClosed"===e&&r&&(n+=s),n=Xh.clamp(n,0,1),this.headMesh.morphTargetInfluences){const e=Xh.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 i=0;if(e>=t.nextBlinkTime&&!t.isBlinking&&(t.isBlinking=!0,t.blinkStartTime=e,t.lastBlinkTime=e,t.nextBlinkTime=e+Math.random()*(WO.maxInterval-WO.minInterval)+WO.minInterval),t.isBlinking){const n=(e-t.blinkStartTime)/WO.blinkDuration;n<=.5?i=2*n:n<=1?i=2-2*n:(t.isBlinking=!1,i=0)}return i}}class $O{constructor(e=UO.clone(),t=GO.clone(),n=.6){this.defaultPosition=e,this.zoomedPosition=t,this.currentScale=new Cp(1,1,1),this.targetScale=new Cp(1,1,1),this.currentPosition=e.clone(),this.basePosition=e.clone(),this.initialCameraPosition=new Cp(0,0,n)}mapHeightToScale(e,t){return t?Xh.lerp(1.4,2.1,e/100):Xh.lerp(.5,1.5,e/100)}mapDepthToCamera(e,t){const n=this.initialCameraPosition.z;return Xh.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 YO{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=[],i="CUSTOM_GLB"){if(this.initialized||this.mixer)return void console.warn("[AvatarAnimator] Already initialized, ignoring duplicate initialization");this.mixer=new sS(e),this.avatarType=i,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 r=["Idle1","Idle2","Idle3","Idle4","Idle5"];let o=!1;for(const e of r)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}`)}))}registerAnimation(e,t){const n=t.getClip().duration;let i="ACTION",r=1,o=!1;const a=e.toLowerCase();a.includes("idle")?(i="IDLE",r=0,o=!0):(a.includes("loading")||a.includes("wait"))&&(i="LOADING",r=0,o=!0),this.animations.set(e,{name:e,category:i,duration:n,canLoop:o,defaultLoopCount:r})}play(e,t={}){var n,i,r,o;try{if(!this.initialized||!this.mixer)return void console.warn(`[AvatarAnimator] Cannot play ${e} - not initialized`);const a=this.actions[e];if(!a){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 s=this.getAnimationInfo(e);if(!s)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!==(i=t.fadeOutDuration)&&void 0!==i?i:this.fadeOutDuration,u=null!==(r=t.loopCount)&&void 0!==r?r:s.defaultLoopCount,d=null!==(o=t.timeScale)&&void 0!==o?o:this.timeScale;if("IDLE"===s.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))}a.reset(),a.fadeIn(l),a.timeScale=d,a.enabled=!0,0===u?a.setLoop(1/0,1/0):(a.setLoop(u>1?u:zd,u>1?u:1),a.clampWhenFinished=!0),a.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:s.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 i=e.match(/<output class="animation-sequence">(.*?)<\/output>/),r=e.match(/<output class="animation">(.*?)(\[loop=(\d+)\])?<\/output>/),o=e.match(/<output class="memori-emotion">(.*?)<\/output>/),a=this.calculateTransitionOptions();if(i&&i[1]){const e=i[1].trim();if(this.currentSequence&&this.currentSequence.join("->")===e&&this.sequenceIndex<this.currentSequence.length)return;this.executeWithTransition(e,a)}else{if(r&&r[1]){const e=r[1].trim();let t;return r[3]&&(t=parseInt(r[3],10)),void this.play(e,{...a,loopCount:t})}if(o&&o[1]){const e=o[1].trim();let t=[];if(jO.find((t=>t.english===e))){let n=jO.filter((t=>t.english===e));t=this.getAllAnimationNames().filter((e=>n.some((t=>e.toLowerCase().startsWith(t.italian.toLowerCase())))))}else t=this.getAllAnimationNames().filter((t=>t.toLowerCase().startsWith(e.toLowerCase())));if(t.length>0){const e=t[Math.floor(Math.random()*t.length)];return void this.play(e,a)}}"IDLE"!==this.getAnimationCategory()&&this.idle(a)}}calculateTransitionOptions(){var e,t;const n={fadeInDuration:this.fadeInDuration,fadeOutDuration:this.fadeOutDuration,timeScale:this.timeScale},i=(this.getAnimationCategory(),this.currentAnimation?this.actions[this.currentAnimation]:null);if(n.fadeOutDuration=.8,n.fadeInDuration=.8,i){const r=i.getClip(),o=i.time/r.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 i=e.match(/\[loop=(\d+)\]/);if(i&&(n=parseInt(i[1],10),e=e.replace(i[0],"").trim()),e.includes("->")){const i=e.split("->").map((e=>e.trim())),r={...t,loopCount:n||1};this.playSequence(i,r)}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,i,r,o,a,s,l,c;const u=this.getAnimationsByCategory("IDLE");if(u.length>0){let r=u;"IDLE"===this.getAnimationCategory()&&(r=u.filter((e=>e.name!==this.currentAnimation)),0===r.length&&(r=u));const o=r[Math.floor(Math.random()*r.length)].name,a={fadeInDuration:null!==(t=e.fadeInDuration)&&void 0!==t?t:.7,fadeOutDuration:null!==(n=e.fadeOutDuration)&&void 0!==n?n:.7,timeScale:null!==(i=e.timeScale)&&void 0!==i?i:.9,loopCount:0,...e};return a.loopCount=0,this.play(o,a),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!==(r=e.fadeInDuration)&&void 0!==r?r:.7,fadeOutDuration:null!==(o=e.fadeOutDuration)&&void 0!==o?o:.7,timeScale:null!==(a=e.timeScale)&&void 0!==a?a:.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!==(s=e.fadeInDuration)&&void 0!==s?s:.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,i;const r=this.getRandomAnimation("LOADING");if(r){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!==(i=e.timeScale)&&void 0!==i?i:this.timeScale,...e};o.loopCount=0,this.play(r,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 i=e.filter((e=>this.actions[e]));if(0===i.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=[...i],this.sequenceIndex=0;const r={fadeInDuration:.6,fadeOutDuration:.6,loopCount:1,timeScale:null!==(n=t.timeScale)&&void 0!==n?n:this.timeScale},o=i[0];this.play(o,r)}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}}}}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")}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 JO={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 "},ZO={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 "},XO=c.forwardRef((({scale:e,frames:t=1/0,opacity:n=1,width:i=1,height:r=1,blur:o=1,far:a=10,resolution:s=256,smooth:l=!0,color:u="#000000",...d},h)=>{const p=sN((({scene:e})=>e)),m=sN((({gl:e})=>e)),f=c.useRef(null);i*=Array.isArray(e)?e[0]:e||1,r*=Array.isArray(e)?e[1]:e||1;const[g,v,y,_,b,x,w]=c.useMemo((()=>{const e=new wp(s,s),t=new wp(s,s);t.texture.generateMipmaps=e.texture.generateMipmaps=!1;const n=new yE(i,r).rotateX(Math.PI/2),o=new Of(n),a=new my;a.depthTest=a.depthWrite=!1,a.onBeforeCompile=e=>{e.uniforms={...e.uniforms,ucolor:{value:new mp(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 Bf(JO),c=new Bf(ZO);return c.depthTest=l.depthTest=!1,[e,n,a,o,l,c,t]}),[s,i,r,e]),S=c.useCallback((e=>{_.visible=!0,_.material=b,b.uniforms.tDiffuse.value=g.texture,b.uniforms.h.value=1*e/256,m.setRenderTarget(w),m.render(_,f.current),_.material=x,x.uniforms.tDiffuse.value=w.texture,x.uniforms.v.value=1*e/256,m.setRenderTarget(g),m.render(_,f.current),_.visible=!1}),[]);let E=0;return lN((()=>{if(f.current&&(t===1/0||E<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,S(o),l&&S(.4*o),m.setRenderTarget(null),p.background=e,E++}})),c.createElement("group",bN({"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:[-i/2,i/2,r/2,-r/2,0,a]}))}));var KO=({animator:e,avatarPosition:t})=>{const n=(()=>{var t,n,i,r,o;const a={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"))?{...a,opacity:.85,blur:3,width:12,height:12}:(null===(n=e.getCurrentAnimationName())||void 0===n?void 0:n.includes("Gioia"))||(null===(i=e.getCurrentAnimationName())||void 0===i?void 0:i.includes("Joy"))?{...a,opacity:.9,blur:2,width:11,height:11}:(null===(r=e.getCurrentAnimationName())||void 0===r?void 0:r.includes("Rabbia"))||(null===(o=e.getCurrentAnimationName())||void 0===o?void 0:o.includes("Anger"))?{...a,opacity:.95,blur:1.8,width:12,height:12}:{...a,opacity:.9,blur:2.2}:{...a,opacity:0}})();return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(XO,{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,a.jsx)(XO,{opacity:1,width:5,height:5,blur:1,far:2,resolution:1024,color:"#000000",position:[0,-.98,0]})]})};c=o("85Hg2");const QO=(e,t,n=.05)=>e*(1-n)+t*n,eR=(e,t,n,i,r)=>((e=((e,t,n)=>Math.min(Math.max(e,t),n))(e,t,n))-t)*(r-i)/(n-t)+i,tR=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 nR=Math.PI/180;let iR,rR=!1;const oR=new Kh(0,0),aR=new Kh(0,0),sR=()=>{iR=setTimeout((()=>{rR=!0}),1e3)},lR=()=>{clearTimeout(iR),rR=!1};function cR(e,t){const{gl:n}=sN();(0,c.useEffect)((()=>{if(e)return n.domElement.addEventListener("mouseleave",sR),n.domElement.addEventListener("mouseenter",lR),()=>{n.domElement.removeEventListener("mouseleave",sR),n.domElement.removeEventListener("mouseenter",lR)}}),[n.domElement,e]),lN((n=>{if(!e||!(null==t?void 0:t.Neck)||!(null==t?void 0:t.Head))return;const i=Math.abs(n.camera.rotation.z);!rR&&i<.2?(oR.x=eR(n.mouse.y,-1,1,5*nR,-5*nR),oR.y=eR(n.mouse.x,-1,1,-10*nR,10*nR)):oR.set(0,0),aR.x=QO(aR.x,oR.x),aR.y=QO(aR.y,oR.y),t.Neck.rotation.x=aR.x+.1,t.Neck.rotation.y=aR.y,t.Head.rotation.x=2*aR.x,t.Head.rotation.y=2*aR.y}))}const uR=(0,c.memo)((function({url:e,sex:t,eyeBlink:n,updateCurrentViseme:i,avatarHeight:r=50,avatarDepth:o=0,onCameraZChange:s,chatEmission:l,loading:u,setAnimatorRef:d}){const{scene:h,animations:p}=BO(e),{animations:m}=BO(VO[t]),f=(0,c.useMemo)((()=>{let e=!1;return h.traverse((t=>{t instanceof a_&&("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}=FO(g,h),y=(0,c.useRef)(null),_=(0,c.useRef)(null),b=(0,c.useRef)(null),x=(0,c.useRef)(!1),w=(0,c.useRef)(UO.clone()),S=(0,c.useRef)(0),[E,A]=(0,c.useState)(!1),T=(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 a_){if("Wolf3D_Avatar"===t.name||"Wolf3D_Avatar006_1"===t.name)return A(!0),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||{}),i=n.some((e=>e.toLowerCase().includes("viseme"))),r=n.some((e=>{const t=e.toLowerCase();return t.includes("mouth")||t.includes("eye")||t.includes("jaw")||t.includes("smile")}));(i||r)&&(e=t)}}}})),e?y.current||(y.current=new qO(e)):console.warn("⚠️ No suitable avatar mesh found")}),[h]),(0,c.useEffect)((()=>(_.current||(_.current=new $O(UO)),()=>{})),[]),(0,c.useEffect)((()=>{_.current&&_.current.updateHeight(r,!1)}),[r]),(0,c.useEffect)((()=>{if(_.current&&s){const e=_.current.updateDepth(o,!1);s(e)}}),[o,s]),(0,c.useEffect)((()=>{if(!h||!v||x.current)return;b.current||(b.current=new YO);const e=b.current;return(async()=>{try{if(e.isInitialized())return;await e.initialize(h,v,g,E?"RPM":"CUSTOM_GLB"),d&&d(e),x.current=!0,e.setTimeScale(.8)}catch(e){console.error("Error initializing AvatarAnimator:",e)}})(),()=>{b.current&&x.current&&("mixer"in b.current&&b.current.mixer&&b.current.mixer.stopAllAction(),d&&d(null),x.current=!1)}}),[h,v,g,t,d]),lN((0,c.useCallback)(((e,t)=>{const r=1e3*e.clock.elapsedTime;if(b.current&&x.current&&b.current.update(t),y.current){const e=i(r/1e3);y.current.updateMorphTargets(r,l,u,e,n,T.current)}if(h&&_.current){const e=_.current.updateScale(.1);if(h.scale.copy(e),r-S.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))),w.current.copy(e),S.current=r}}}),[h,i,l,u,n]));const I=(0,c.useMemo)((()=>{var e;return(null===(e=_.current)||void 0===e?void 0:e.getPosition())||UO.clone()}),[]);return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(KO,{animator:b.current,avatarPosition:I}),(0,a.jsx)("group",{position:I,rotation:zO,children:(0,a.jsx)("primitive",{object:h})})]})})),dR=(0,c.memo)((function({url:e,updateCurrentViseme:t,eyeBlink:n=!1,avatarHeight:i=50,avatarDepth:r=0,headMovement:o=!1,onLoaded:s,onCameraZChange:l,chatEmission:u,loading:d=!1}){var h;const{scene:p}=BO(e),{nodes:m,materials:f}=(g=p,c.useMemo((()=>cN(g)),[g]));var g;const{camera:v}=sN(),y=(0,c.useRef)(null),_=(0,c.useRef)(null);(0,c.useRef)(v.position.z),cR(o,m);const b=(0,c.useRef)({isBlinking:!1,lastBlinkTime:0,nextBlinkTime:0,blinkStartTime:0}),x=(0,c.useMemo)((()=>{let e;return null==p||p.traverse((t=>{t instanceof a_&&("GBNL__Head"===t.name||"Wolf3D_Avatar"===t.name||"Wolf3D_Avatar006_1"===t.name)&&(e=t)})),e}),[p]);(0,c.useEffect)((()=>(_.current||(_.current=new $O(UO,GO)),x&&(y.current=new qO(x)),HE(f),null==s||s(),tR(m),()=>{Object.values(f).forEach((e=>e.dispose())),Object.values(m).filter(VE).forEach((e=>e.geometry.dispose()))})),[f,m,e,s,p,x]),(0,c.useEffect)((()=>{_.current&&_.current.updateHeight(i,!0)}),[i]),(0,c.useEffect)((()=>{if(_.current&&l){const e=_.current.updateDepth(r,!0);l(e)}}),[r,l]),lN((e=>{const i=1e3*e.clock.elapsedTime;if(y.current){const e=t(i/1e3);y.current.updateMorphTargets(i,u,d,e,n,b.current)}if(p&&_.current){const e=_.current.updateScale(.1);p.scale.copy(e)}}));const w=(null===(h=_.current)||void 0===h?void 0:h.getPosition())||UO;return(0,a.jsx)("group",{position:w,children:(0,a.jsx)("primitive",{object:p})})})),hR=({chatEmission:e,url:t,sex:n,eyeBlink:i,halfBody:r,loading:o,avatarHeight:s=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&&(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:s,avatarDepth:l,setAnimatorRef:f})),[t,d,u,s,l,f]);return(0,a.jsxs)(a.Fragment,{children:[r?(0,a.jsx)(dR,{...g(),eyeBlink:i,headMovement:h}):(0,a.jsx)(uR,{...g(),sex:n,eyeBlink:i,chatEmission:e,loading:o}),p&&m.current&&(0,a.jsx)("div",{className:"animation-controls"})]})};(0,c.memo)(hR),c=o("85Hg2");const pR={muteSpeaker:"@memori:muteSpeaker",microphoneMode:"@memori:microphoneMode",continuousSpeechTimeout:"@memori:continuousSpeechTimeout",birthDate:"@memori:birthDate",controlsPosition:"@memori:controlsPosition",hideEmissions:"@memori:hideEmissions",loginToken:"@memori:loginToken",location:"@memori:location"},mR=(e,t)=>{var n;try{const i=window.localStorage.getItem(null!==(n=pR[e])&&void 0!==n?n:e);if(!i)return t;try{return JSON.parse(i)}catch(e){return i}}catch(e){return console.error("error",e),t}},fR=(e,t)=>{var n;try{window.localStorage.setItem(null!==(n=pR[e])&&void 0!==n?n:e,t.toString())}catch(e){console.error("error",e)}},gR=e=>{var t;try{window.localStorage.removeItem(null!==(t=pR[e])&&void 0!==t?t:e)}catch(e){console.error("error",e)}};c=o("85Hg2"),c=o("85Hg2");var vR=(e=>(e[e.Open=0]="Open",e[e.Closed=1]="Closed",e))(vR||{}),yR=(e=>(e[e.Single=0]="Single",e[e.Multi=1]="Multi",e))(yR||{}),_R=(e=>(e[e.Pointer=0]="Pointer",e[e.Other=1]="Other",e))(_R||{}),bR=(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))(bR||{});function xR(e,t=(e=>e)){let n=null!==e.activeOptionIndex?e.options[e.activeOptionIndex]:null,i=Qs(t(e.options.slice()),(e=>e.dataRef.current.domRef.current)),r=n?i.indexOf(n):null;return-1===r&&(r=null),{options:i,activeOptionIndex:r}}let wR={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:i,compare:r}=e.propsRef.current,o=e.options.findIndex((e=>{let t=e.dataRef.current.value;return Ba(i,{1:()=>n.some((e=>r(e,t))),0:()=>r(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 i=xR(e),r=XE(t,{resolveItems:()=>i.options,resolveActiveIndex:()=>i.activeOptionIndex,resolveId:e=>e.id,resolveDisabled:e=>e.dataRef.current.disabled});return{...e,...i,searchQuery:"",activeOptionIndex:r,activationTrigger:null!=(n=t.trigger)?n:1}},5:(e,t)=>{if(e.disabled||1===e.listboxState)return e;let n=""!==e.searchQuery?0:1,i=e.searchQuery+t.value.toLowerCase(),r=(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(i))})),o=r?e.options.indexOf(r):-1;return-1===o||o===e.activeOptionIndex?{...e,searchQuery:i}:{...e,searchQuery:i,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},i=xR(e,(e=>[...e,n]));if(null===e.activeOptionIndex){let{value:r,mode:o,compare:a}=e.propsRef.current,s=t.dataRef.current.value;Ba(o,{1:()=>r.some((e=>a(e,s))),0:()=>a(r,s)})&&(i.activeOptionIndex=i.options.indexOf(n))}return{...e,...i}},8:(e,t)=>{let n=xR(e,(e=>{let n=e.findIndex((e=>e.id===t.id));return-1!==n&&e.splice(n,1),e}));return{...e,...n,activationTrigger:1}}},SR=(0,c.createContext)(null);function ER(e){let t=(0,c.useContext)(SR);if(null===t){let t=new Error(`<${e} /> is missing a parent <Listbox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(t,ER),t}return t}function AR(e,t){return Ba(t.type,wR,e,t)}SR.displayName="ListboxContext";let TR=c.Fragment,IR=Va((function(e,n){let{value:i,defaultValue:r,name:o,onChange:a,by:s=((e,t)=>e===t),disabled:l=!1,horizontal:u=!1,multiple:d=!1,...h}=e;const p=u?"horizontal":"vertical";let m=as(n),[f,g]=nA(i,a,r),v=(0,c.useReducer)(AR,{listboxState:1,propsRef:{current:{value:f,onChange:g,mode:d?1:0,compare:is("string"==typeof s?(e,t)=>{let n=s;return(null==e?void 0:e[n])===(null==t?void 0:t[n])}:s)}},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:b,buttonRef:x},w]=v;_.current.value=f,_.current.mode=d?1:0,Ka((()=>{_.current.onChange=e=>Ba(_.current.mode,{0:()=>g(e),1(){let t=_.current.value.slice(),{compare:n}=_.current,i=t.findIndex((t=>n(t,e)));return-1===i?t.push(e):t.splice(i,1),g(t)}})}),[g,_]),Ka((()=>w({type:2,disabled:l})),[l]),Ka((()=>w({type:3,orientation:p})),[p]),Rl([x,b],((e,t)=>{var n;w({type:1}),Js(t,Ys.Loose)||(e.preventDefault(),null==(n=x.current)||n.focus())}),0===y);let S=(0,c.useMemo)((()=>({open:0===y,disabled:l,value:f})),[y,l,f]),E={ref:m};return t(c).createElement(SR.Provider,{value:v},t(c).createElement(Za,{value:Ba(y,{0:Ya.Open,1:Ya.Closed})},null!=o&&null!=f&&KE({[o]:f}).map((([e,n])=>t(c).createElement(zs,{features:Us.Hidden,...Wa({key:e,as:"input",type:"hidden",hidden:!0,readOnly:!0,name:e,value:n})}))),Ga({ourProps:E,theirProps:h,slot:S,defaultTag:TR,name:"Listbox"})))})),MR=Va((function(e,t){var n;let[i,r]=ER("Listbox.Button"),o=as(i.buttonRef,t),a=`headlessui-listbox-button-${Fs()}`,s=fs(),l=is((e=>{switch(e.key){case Ls.Space:case Ls.Enter:case Ls.ArrowDown:e.preventDefault(),r({type:0}),s.nextFrame((()=>{i.propsRef.current.value||r({type:4,focus:ZE.First})}));break;case Ls.ArrowUp:e.preventDefault(),r({type:0}),s.nextFrame((()=>{i.propsRef.current.value||r({type:4,focus:ZE.Last})}))}})),u=is((e=>{if(e.key===Ls.Space)e.preventDefault()})),d=is((e=>{if(Ps(e.currentTarget))return e.preventDefault();0===i.listboxState?(r({type:1}),s.nextFrame((()=>{var e;return null==(e=i.buttonRef.current)?void 0:e.focus({preventScroll:!0})}))):(e.preventDefault(),r({type:0}))})),h=qE((()=>{if(i.labelRef.current)return[i.labelRef.current.id,a].join(" ")}),[i.labelRef.current,a]),p=(0,c.useMemo)((()=>({open:0===i.listboxState,disabled:i.disabled,value:i.propsRef.current.value})),[i]),m=e;return Ga({ourProps:{ref:o,id:a,type:YE(e,i.buttonRef),"aria-haspopup":!0,"aria-controls":null==(n=i.optionsRef.current)?void 0:n.id,"aria-expanded":i.disabled?void 0:0===i.listboxState,"aria-labelledby":h,disabled:i.disabled,onKeyDown:l,onKeyUp:u,onClick:d},theirProps:m,slot:p,defaultTag:"button",name:"Listbox.Button"})})),CR=Va((function(e,t){let[n]=ER("Listbox.Label"),i=`headlessui-listbox-label-${Fs()}`;return Ga({ourProps:{ref:as(n.labelRef,t),id:i,onClick:is((()=>{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"})})),NR=Ua.RenderStrategy|Ua.Static,OR=Va((function(e,t){var n;let[i,r]=ER("Listbox.Options"),o=as(i.optionsRef,t),a=`headlessui-listbox-options-${Fs()}`,s=fs(),l=fs(),u=Ja(),d=null!==u?u===Ya.Open:0===i.listboxState;(0,c.useEffect)((()=>{var e;let t=i.optionsRef.current;!t||0===i.listboxState&&t!==(null==(e=Gs(t))?void 0:e.activeElement)&&t.focus({preventScroll:!0})}),[i.listboxState,i.optionsRef]);let h=is((e=>{switch(l.dispose(),e.key){case Ls.Space:if(""!==i.searchQuery)return e.preventDefault(),e.stopPropagation(),r({type:5,value:e.key});case Ls.Enter:if(e.preventDefault(),e.stopPropagation(),null!==i.activeOptionIndex){let{dataRef:e}=i.options[i.activeOptionIndex];i.propsRef.current.onChange(e.current.value)}0===i.propsRef.current.mode&&(r({type:1}),cs().nextFrame((()=>{var e;return null==(e=i.buttonRef.current)?void 0:e.focus({preventScroll:!0})})));break;case Ba(i.orientation,{vertical:Ls.ArrowDown,horizontal:Ls.ArrowRight}):return e.preventDefault(),e.stopPropagation(),r({type:4,focus:ZE.Next});case Ba(i.orientation,{vertical:Ls.ArrowUp,horizontal:Ls.ArrowLeft}):return e.preventDefault(),e.stopPropagation(),r({type:4,focus:ZE.Previous});case Ls.Home:case Ls.PageUp:return e.preventDefault(),e.stopPropagation(),r({type:4,focus:ZE.First});case Ls.End:case Ls.PageDown:return e.preventDefault(),e.stopPropagation(),r({type:4,focus:ZE.Last});case Ls.Escape:return e.preventDefault(),e.stopPropagation(),r({type:1}),s.nextFrame((()=>{var e;return null==(e=i.buttonRef.current)?void 0:e.focus({preventScroll:!0})}));case Ls.Tab:e.preventDefault(),e.stopPropagation();break;default:1===e.key.length&&(r({type:5,value:e.key}),l.setTimeout((()=>r({type:6})),350))}})),p=qE((()=>{var e,t,n;return null!=(n=null==(e=i.labelRef.current)?void 0:e.id)?n:null==(t=i.buttonRef.current)?void 0:t.id}),[i.labelRef.current,i.buttonRef.current]),m=(0,c.useMemo)((()=>({open:0===i.listboxState})),[i]),f=e;return Ga({ourProps:{"aria-activedescendant":null===i.activeOptionIndex||null==(n=i.options[i.activeOptionIndex])?void 0:n.id,"aria-multiselectable":1===i.propsRef.current.mode||void 0,"aria-labelledby":p,"aria-orientation":i.orientation,id:a,onKeyDown:h,role:"listbox",tabIndex:0,ref:o},theirProps:f,slot:m,defaultTag:"ul",features:NR,visible:d,name:"Listbox.Options"})})),RR=Va((function(e,t){let{disabled:n=!1,value:i,...r}=e,[o,a]=ER("Listbox.Option"),s=`headlessui-listbox-option-${Fs()}`,l=null!==o.activeOptionIndex&&o.options[o.activeOptionIndex].id===s,{value:u,compare:d}=o.propsRef.current,h=Ba(o.propsRef.current.mode,{1:()=>u.some((e=>d(e,i))),0:()=>d(u,i)}),p=(0,c.useRef)(null),m=as(t,p);Ka((()=>{if(0!==o.listboxState||!l||0===o.activationTrigger)return;let e=cs();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:i,domRef:p});Ka((()=>{f.current.disabled=n}),[f,n]),Ka((()=>{f.current.value=i}),[f,i]),Ka((()=>{var e,t;f.current.textValue=null==(t=null==(e=p.current)?void 0:e.textContent)?void 0:t.toLowerCase()}),[f,p]);let g=is((()=>o.propsRef.current.onChange(i)));Ka((()=>(a({type:7,id:s,dataRef:f}),()=>a({type:8,id:s}))),[f,s]);let v=is((e=>{if(n)return e.preventDefault();g(),0===o.propsRef.current.mode&&(a({type:1}),cs().nextFrame((()=>{var e;return null==(e=o.buttonRef.current)?void 0:e.focus({preventScroll:!0})})))})),y=is((()=>{if(n)return a({type:4,focus:ZE.Nothing});a({type:4,focus:ZE.Specific,id:s})})),_=is((()=>{n||l||a({type:4,focus:ZE.Specific,id:s,trigger:0})})),b=is((()=>{n||!l||a({type:4,focus:ZE.Nothing})})),x=(0,c.useMemo)((()=>({active:l,selected:h,disabled:n})),[l,h,n]);return Ga({ourProps:{id:s,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:b,onMouseLeave:b},theirProps:r,slot:x,defaultTag:"li",name:"Listbox.Option"})})),LR=Object.assign(IR,{Button:MR,Label:CR,Options:OR,Option:RR});var PR=({min:e=0,max:n=100,step:i=1,defaultValue:r=50,label:o,onChange:s,disabled:l=!1})=>{const[u,d]=(0,c.useState)(r),[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 r=m.current.getBoundingClientRect(),o=t-r.left,a=r.width,s=Math.max(0,Math.min(100,o/a*100)),l=Math.round(s/100*(n-e)+e),c=Math.round(l/i)*i;return Math.min(Math.max(c,e),n)},y=e=>{if(l)return;p(!0);const t=v(e);d(t),null==s||s(t)},_=e=>{if(!h||l)return;const t=v(e);d(t),null==s||s(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(r)}),[r]),(0,a.jsxs)("div",{className:t(We)("memori--slider-container",{"memori--slider-disabled":l}),style:{"--percentage":`${f}%`},children:[(0,a.jsxs)("div",{className:"memori--slider-header",children:[o&&(0,a.jsx)("div",{className:"memori--slider-label",children:o}),(0,a.jsx)("div",{className:"memori--slider-value",children:u})]}),(0,a.jsxs)("div",{ref:m,className:"memori--slider-track-container",onMouseDown:e=>y(e.clientX),onTouchStart:e=>y(e.touches[0].clientX),children:[(0,a.jsx)("div",{className:"memori--slider-track",children:(0,a.jsx)("div",{className:"memori--slider-track-fill"})}),(0,a.jsx)("div",{className:"memori--slider-marks",children:g.map((e=>(0,a.jsxs)("div",{className:"memori--slider-mark",children:[(0,a.jsx)("div",{className:"memori--slider-mark-line"}),(0,a.jsx)("span",{className:"memori--slider-mark-value",children:e})]},e)))}),(0,a.jsx)(LR,{value:u,onChange:d,disabled:l,children:(0,a.jsx)("div",{className:"memori--slider-thumb",role:"slider","aria-valuemin":e,"aria-valuemax":n,"aria-valuenow":u,tabIndex:l?-1:0})})]})]})};var DR=({avatarHeight:e,avatarDepth:t,setAvatarHeight:n,setAvatarDepth:i,halfBody:r,setEnablePositionControls:o})=>{const s=r?{height:80,depth:50}:{height:25,depth:25},l=r?{height:55,depth:10}:{height:15,depth:5},u=r?{height:100,depth:80}:{height:65,depth:100},d=(0,c.useRef)({height:e,depth:t,zoomed:!1,normal:!1,far:!1}),{t:h}=Ve();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);i(e),fR("avatarDepth",e)}else if(("+"===e.key||"="===e.key)&&d.current.depth>-100){const e=Math.max(d.current.depth-10,-100);i(e),fR("avatarDepth",e)}};return window.addEventListener("keydown",e),()=>{window.removeEventListener("keydown",e)}}),[i]),(0,c.useEffect)((()=>{const e=e=>{if("ArrowUp"===e.key&&d.current.height<100){const e=d.current.height+5;n(e),fR("avatarHeight",e)}},t=e=>{if("ArrowDown"===e.key&&d.current.height>0){const e=d.current.height-5;n(e),fR("avatarHeight",e)}};return window.addEventListener("keydown",e),window.addEventListener("keydown",t),()=>{window.removeEventListener("keydown",e),window.removeEventListener("keydown",t)}}),[n]),(0,a.jsxs)("div",{className:"memori--position-controls",children:[(0,a.jsx)("div",{className:"memori--position-controls-close",children:(0,a.jsx)(Jl,{ghost:!0,icon:(0,a.jsx)(Zl,{}),outlined:!0,danger:!0,shape:"circle",className:"memori--position-controls-close-button",onClick:()=>{o(!1)}})}),(0,a.jsx)(PR,{defaultValue:d.current.height,min:.5,max:100,label:h("write_and_speak.height"),step:1,onChange:e=>{n(e),fR("avatarHeight",e)}}),(0,a.jsx)(PR,{defaultValue:d.current.depth,min:.5,max:100,step:5,label:h("write_and_speak.depth"),onChange:e=>{i(e),fR("avatarDepth",e)}}),(0,a.jsxs)("div",{className:"memori--preset-buttons",children:[(0,a.jsx)(Jl,{outlined:!0,isActive:e===(r?l.height:s.height)&&t===(r?l.depth:s.depth),onClick:()=>{n(l.height),i(l.depth),fR("avatarHeight",l.height),fR("avatarDepth",l.depth)},children:h("write_and_speak.zoomed")}),(0,a.jsx)(Jl,{outlined:!0,isActive:e===(r?s.height:l.height)&&t===(r?s.depth:l.depth),onClick:()=>{n(s.height),i(s.depth),fR("avatarHeight",s.height),fR("avatarDepth",s.depth)},children:h("write_and_speak.normal")}),(0,a.jsx)(Jl,{outlined:!0,isActive:e===(r?u.height:s.height)&&t===(r?u.depth:s.depth),onClick:()=>{n(u.height),i(u.depth),fR("avatarHeight",u.height),fR("avatarDepth",u.depth)},children:h("write_and_speak.far")})]})]})};let kR=0;const BR=t(_C)((e=>(jx.onStart=(t,n,i)=>{e({active:!0,item:t,loaded:n,total:i,progress:(n-kR)/(i-kR)*100})},jx.onLoad=()=>{e({active:!1})},jx.onError=t=>e((e=>({errors:[...e.errors,t]}))),jx.onProgress=(t,n,i)=>{n===i&&(kR=i),e({active:!0,item:t,loaded:n,total:i,progress:(n-kR)/(i-kR)*100||100})},{errors:[],active:!1,progress:0,item:"",loaded:0,total:0})));c=o("85Hg2");const FR=new Cp,UR=new Cp,zR=new Cp;function GR(e,t,n){const i=FR.setFromMatrixPosition(e.matrixWorld);i.project(t);const r=n.width/2,o=n.height/2;return[i.x*r+r,-i.y*o+o]}const jR=e=>Math.abs(e)<1e-10?0:e;function HR(e,t,n=""){let i="matrix3d(";for(let n=0;16!==n;n++)i+=jR(t[n]*e.elements[n])+(15!==n?",":")");return n+i}const VR=(WR=[1,-1,1,1,1,-1,1,1,1,-1,1,1,1,-1,1,1],e=>HR(e,WR));var WR;const qR=(e,t)=>{return HR(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},$R=c.forwardRef((({children:e,eps:t=.001,style:n,className:i,prepend:r,center:o,fullscreen:a,portal:l,distanceFactor:u,sprite:d=!1,transform:h=!1,occlude:p,onOcclude:m,zIndexRange:f=[16777271,0],calculatePosition:g=GR,as:v="div",wrapperClass:y,pointerEvents:_="auto",...b},x)=>{var w;const S=sN((({gl:e})=>e)),E=sN((({camera:e})=>e)),A=sN((({scene:e})=>e)),T=sN((({size:e})=>e)),I=sN((({raycaster:e})=>e)),[M]=c.useState((()=>document.createElement(v))),C=c.useRef(null),N=c.useRef(0),O=c.useRef([0,0]),R=c.useRef(null),L=c.useRef(null),P=null!==(w=null==l?void 0:l.current)&&void 0!==w?w:S.domElement.parentNode;c.useEffect((()=>{if(C.current){if(A.updateMatrixWorld(),h)M.style.cssText="position:absolute;top:0;left:0;pointer-events:none;overflow:hidden;";else{const e=g(C.current,E,T);M.style.cssText=`position:absolute;top:0;left:0;transform:translate3d(${e[0]}px,${e[1]}px,0);transform-origin:0 0;`}return P&&(r?P.prepend(M):P.appendChild(M)),()=>{P&&P.removeChild(M),s.unmountComponentAtNode(M)}}}),[P,h]),c.useLayoutEffect((()=>{y&&(M.className=y)}),[y]);const D=c.useMemo((()=>h?{position:"absolute",top:0,left:0,width:T.width,height:T.height,transformStyle:"preserve-3d",pointerEvents:"none"}:{position:"absolute",transform:o?"translate3d(-50%,-50%,0)":"none",...a&&{top:-T.height/2,left:-T.width/2,width:T.width,height:T.height},...n}),[n,o,a,T,h]),k=c.useMemo((()=>({position:"absolute",pointerEvents:_})),[_]);c.useLayoutEffect((()=>{h?s.render(c.createElement("div",{ref:R,style:D},c.createElement("div",{ref:L,style:k},c.createElement("div",{ref:x,className:i,style:n,children:e}))),M):s.render(c.createElement("div",{ref:x,style:D,className:i,children:e}),M)}));const B=c.useRef(!0);return lN((()=>{if(C.current){E.updateMatrixWorld(),C.current.updateWorldMatrix(!0,!1);const e=h?O.current:g(C.current,E,T);if(h||Math.abs(N.current-E.zoom)>t||Math.abs(O.current[0]-e[0])>t||Math.abs(O.current[1]-e[1])>t){const t=function(e,t){const n=FR.setFromMatrixPosition(e.matrixWorld),i=UR.setFromMatrixPosition(t.matrixWorld),r=n.sub(i),o=t.getWorldDirection(zR);return r.angleTo(o)>Math.PI/2}(C.current,E);let n=!1;"boolean"==typeof p?!0===p&&(n=[A]):Array.isArray(p)&&(n=p.map((e=>e.current)));const i=B.current;if(n){const e=function(e,t,n,i){const r=FR.setFromMatrixPosition(e.matrixWorld),o=r.clone();o.project(t),n.setFromCamera(o,t);const a=n.intersectObjects(i,!0);if(a.length){const e=a[0].distance;return r.distanceTo(n.ray.origin)<e}return!0}(C.current,E,I,n);B.current=e&&!t}else B.current=!t;if(i!==B.current&&(m?m(!B.current):M.style.display=B.current?"block":"none"),M.style.zIndex=`${function(e,t,n){if(t instanceof Uf||t instanceof cg){const i=FR.setFromMatrixPosition(e.matrixWorld),r=UR.setFromMatrixPosition(t.matrixWorld),o=i.distanceTo(r),a=(n[1]-n[0])/(t.far-t.near),s=n[1]-a*t.far;return Math.round(a*o+s)}}(C.current,E,f)}`,h){const[e,t]=[T.width/2,T.height/2],n=E.projectionMatrix.elements[5]*t,{isOrthographicCamera:i,top:r,left:o,bottom:a,right:s}=E,l=VR(E.matrixWorldInverse),c=i?`scale(${n})translate(${jR(-(s+o)/2)}px,${jR((r+a)/2)}px)`:`translateZ(${n}px)`;let h=C.current.matrixWorld;d&&(h=E.matrixWorldInverse.clone().transpose().copyPosition(h).scale(C.current.scale),h.elements[3]=h.elements[7]=h.elements[11]=0,h.elements[15]=1),M.style.width=T.width+"px",M.style.height=T.height+"px",M.style.perspective=i?"":`${n}px`,R.current&&L.current&&(R.current.style.transform=`${c}${l}translate(${e}px,${t}px)`,L.current.style.transform=qR(h,1/((u||10)/400)))}else{const t=void 0===u?1:function(e,t){if(t instanceof cg)return t.zoom;if(t instanceof Uf){const n=FR.setFromMatrixPosition(e.matrixWorld),i=UR.setFromMatrixPosition(t.matrixWorld),r=t.fov*Math.PI/180,o=n.distanceTo(i);return 1/(2*Math.tan(r/2)*o)}return 1}(C.current,E)*u;M.style.transform=`translate3d(${e[0]}px,${e[1]}px,0) scale(${t})`}O.current=e,N.current=E.zoom}}})),c.createElement("group",bN({},b,{ref:C}))}));var YR=({fallbackImg:e})=>{const{progress:t}=BR();return(0,a.jsx)($R,{center:!0,className:"avatar-loader",children:(0,a.jsx)(Yl,{spinning:!0,children:e?(0,a.jsxs)("figure",{children:[(0,a.jsx)("img",{src:e,alt:`${Math.round(t)}% loaded`,title:`${Math.round(t)}% loaded`}),(0,a.jsx)("figcaption",{children:`${Math.round(t)}%`})]}):(0,a.jsxs)(a.Fragment,{children:[Math.round(t)," % loaded"]})})})};c=o("85Hg2");const JR=e=>{return t=Object.entries(e).filter((([e,t])=>void 0!==t)),Object.assign({},...t.map((([e,t])=>({[e]:t}))));var t},ZR=Object.freeze({fillLightAngle:Math.PI/3,backLightAngle:Math.PI/8,keyLightAngle:Math.PI/2,silhouetteLightAngle:1.25*Math.PI,keyLightPosition:new Cp(.75,1.75,.75),liftLightPosition:new Cp(.25,1.5,2),dirLightPosition:new Cp(-.75,2.5,-1),silhouetteLightPosition:new Cp(-1.25,.25,-1.25),defaultProps:{keyLightIntensity:1.2,keyLightColor:"#FFF5EB",fillLightIntensity:2.5,fillLightColor:"#A4C4FF",fillLightPosition:new Cp(-.6,1.7,-.4),backLightIntensity:4,backLightColor:"#FFD4A8",backLightPosition:new Cp(.6,1.7,-1),lightTarget:new Cp(0,1.65,0)}});var XR=e=>{const{keyLightIntensity:t,keyLightColor:n,fillLightIntensity:i,fillLightColor:r,fillLightPosition:o,backLightIntensity:s,backLightColor:l,backLightPosition:u,lightTarget:d}=Object.assign(ZR.defaultProps,JR(e)),{scene:h}=sN(),[p]=(0,c.useState)({head:new Om,shoe:new Om});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,a.jsxs)("group",{children:[(0,a.jsx)("spotLight",{position:o,target:p.head,angle:ZR.fillLightAngle,color:r,intensity:i,castShadow:!0,"shadow-bias":-1e-4,penumbra:.2}),(0,a.jsx)("spotLight",{position:u,target:p.head,angle:ZR.backLightAngle,color:l,intensity:s,castShadow:!0,"shadow-bias":-1e-4,penumbra:.2}),(0,a.jsx)("spotLight",{position:ZR.keyLightPosition,target:p.head,angle:ZR.keyLightAngle,color:n,intensity:t,penumbra:.3,castShadow:!0}),(0,a.jsx)("spotLight",{position:ZR.liftLightPosition,target:p.shoe,angle:ZR.keyLightAngle,color:n,intensity:.3*t,penumbra:.4}),(0,a.jsx)("spotLight",{position:ZR.silhouetteLightPosition,target:p.head,angle:ZR.silhouetteLightAngle,color:n,intensity:.3*t,penumbra:.3}),(0,a.jsx)("ambientLight",{intensity:.2,color:"#FFF8EF"})]})};const KR={halfBody:{width:"100%",height:"100%",minHeight:"500px",backgroundColor:"white",borderRadius:"100%"},fullBody:{width:"500px",height:"500px",backgroundColor:"white"}},QR=(e,t)=>({fov:t?44:40,position:[0,0,e?.6:3],target:[0,0,0]});function eL({url:e,sex:t,style:n,rotateAvatar:i,eyeBlink:r,headMovement:o,speaking:s,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[b,x]=(0,c.useState)((()=>QR(d,m||!1).position[2])),[w,S]=(0,c.useState)((()=>{if(_){return mR("avatarHeight",50)}return d?80:m?16:65})()),[E,A]=(0,c.useState)((()=>{if(_){return mR("avatarDepth",50)}return d?50:m?5:100})());return(0,a.jsxs)(a.Fragment,{children:[v&&(0,a.jsx)(DR,{avatarHeight:w,avatarDepth:E,halfBody:d,setAvatarHeight:S,setAvatarDepth:A,setEnablePositionControls:y}),(0,a.jsxs)(oN,{style:n||KR.fullBody,shadows:!0,dpr:[1,2],gl:{antialias:!0,alpha:!0,powerPreference:"high-performance",stencil:!1},children:[(0,a.jsx)(MN,{makeDefault:!0,position:[0,0,b],fov:QR(d,m||!1).fov,near:.1,far:1e3}),i&&(0,a.jsx)(IN,{enablePan:!1,enableZoom:!1,target:[0,0,0],enableDamping:!0,dampingFactor:.05}),(0,a.jsxs)(c.Suspense,{fallback:l||(0,a.jsx)(YR,{fallbackImg:u}),children:[(0,a.jsx)(XR,{}),(0,a.jsx)(hR,{url:e,sex:t,showControls:p,loading:h||!1,eyeBlink:r||!1,headMovement:o||!1,speaking:s||!1,halfBody:d,chatEmission:f,updateCurrentViseme:g,setCameraZ:x,avatarHeight:w,avatarDepth:E})]})]})]})}const tL=(0,(c=o("85Hg2")).createContext)(void 0),nL={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:iL,VISEME_OVERLAP:rL,SMOOTHING_FACTOR:oL,LOG_INTERVAL:aL,PRELOAD:sL,WEIGHT_MULTIPLIER:lL}={DEFAULT_VISEME_DURATION:.12,VISEME_OVERLAP:.02,SMOOTHING_FACTOR:.4,LOG_INTERVAL:60,PRELOAD:.2,WEIGHT_MULTIPLIER:.8},cL=(e,t)=>e.endTime<t-rL,uL=e=>Math.sin(Math.PI*Math.min(e,1))*lL,dL=(e,t)=>e+(t-e)*oL,hL=({children:e})=>{const t=(0,c.useRef)([]),n=(0,c.useRef)(null),i=(0,c.useRef)(null),[r,o]=(0,c.useState)(!1),[s,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,null!==e.onstatechange&&(e.onstatechange=()=>{switch(e.state){case"running":l("active");break;case"suspended":l("paused");break;case"closed":l("finished"),v()}})}),[]),m=(0,c.useCallback)((e=>{e?(n.current=e,i.current=e.currentTime,d.current=0,o(!0),l("active")):console.error("[VisemeContext] No audio context provided")}),[]),f=(0,c.useCallback)(((e,n)=>{if("finished"===s)return;const i=nL[e]||"viseme_sil",r=n/1e7;null===h.current&&(h.current=r);const o=r-(h.current||0),a={name:i,weight:0,startTime:o,endTime:o+iL};t.current.push(a),"idle"===s&&l("preparing")}),[s]),g=(0,c.useCallback)((()=>{t.current=[],u.current=null,i.current=null,h.current=null,d.current=0,l("idle")}),[]),v=(0,c.useCallback)((()=>{o(!1),l("finished"),i.current=null,u.current=null,d.current=0,n.current=null}),[]),y=(0,c.useCallback)((e=>{if(!r||!n.current)return null;const o=n.current.currentTime-(i.current||0)+sL;t.current=t.current.filter((e=>!cL(e,o)));const a=t.current.find((e=>e.startTime<=o&&e.endTime>o-rL));if(a){const e=(o-a.startTime)/(a.endTime-a.startTime),t=uL(e),n=u.current?dL(u.current.weight,t):t,i={...a,weight:n};return u.current=i,i}if(u.current){const e=u.current.weight*(1-oL);u.current={...u.current,weight:e}}return u.current=null,null}),[r]),_=(0,c.useCallback)((e=>{v(),g(),m(e)}),[v,g,m,s]),b=(0,c.useMemo)((()=>({addViseme:f,updateCurrentViseme:y,startProcessing:m,stopProcessing:v,resetAndStartProcessing:_,resetVisemeQueue:g,isProcessing:r,setAudioContext:p})),[f,y,m,v,_,g,r,p]);return(0,a.jsx)(tL.Provider,{value:b,children:e})},pL=()=>{const e=(0,c.useContext)(tL);if(!e)throw new Error("useVisemeContext must be used within a VisemeProvider");return e};var mL=(0,c.memo)((({memori:e,integration:n,integrationConfig:i,tenant:r,instruct:o=!1,avatar3dVisible:s=!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:b,isTotem:x=!1})=>{const{t:w}=Ve(),[S,E]=(0,c.useState)(!1),{stopProcessing:A,updateCurrentViseme:T,resetVisemeQueue:I}=pL();(0,c.useEffect)((()=>{E(!0)}),[]);const M=()=>{if("userAvatar"===(null==i?void 0:i.avatar)&&e.avatarURL&&e.avatarURL.length>0)return KT({type:"avatar",tenantID:null==r?void 0:r.name,resourceURI:e.avatarURL,baseURL:p,apiURL:m})},C=()=>{var t;return S?"readyplayerme"===(null==i?void 0:i.avatar)||"readyplayerme-full"===(null==i?void 0:i.avatar)||"customrpm"===(null==i?void 0:i.avatar)?(0,a.jsx)(mC,{fallback:(0,a.jsx)("div",{className:"memori--blob-container",children:S&&(0,a.jsx)(fC,{speaking:d,avatar:M()})}),children:(0,a.jsx)(eL,{enablePositionControls:_,updateCurrentViseme:T,url:i.avatarURL,sex:"FEMALE"===e.voiceType?"FEMALE":"MALE",fallbackImg:M(),headMovement:!0,eyeBlink:!0,animation:f,halfBody:"readyplayerme"===i.avatar,speaking:d,loading:h,style:O(),stopProcessing:A,resetVisemeQueue:I,isZoomed:g,isTotem:x,chatEmission:null===(t=null==v?void 0:v.dialogState)||void 0===t?void 0:t.emission,setEnablePositionControls:b})}):"customglb"===(null==i?void 0:i.avatar)?(0,a.jsx)(JI,{poster:M()||"",src:i.avatarURL,alt:""}):null:null},N=()=>(0,a.jsx)("div",{className:"memori--avatar-toggle",children:(0,a.jsx)(Jl,{ghost:!0,onClick:()=>l(!s),icon:s?(0,a.jsx)(vC,{}):(0,a.jsx)(gC,{}),children:(0,a.jsx)("span",{className:"memori--avatar-toggle-text",children:w(s?"hide":"show")})})}),O=()=>"readyplayerme"===(null==i?void 0:i.avatar)?{width:"100%",height:"100%",backgroundColor:"none",boxShadow:"none"}:{width:"100%",height:"100%",backgroundColor:"none"};return(0,a.jsxs)(a.Fragment,{children:[("readyplayerme"===(null==i?void 0:i.avatar)||"readyplayerme-full"===(null==i?void 0:i.avatar)||"customglb"===(null==i?void 0:i.avatar)||"customrpm"===(null==i?void 0:i.avatar))&&(null==i?void 0:i.avatarURL)&&y&&"blob"!==y?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:t(We)("memori--avatar-wrapper",`memori--avatar-${(null==i?void 0:i.avatar)||"default"}`,{hidden:!s}),children:C()}),N()]}):(0,a.jsx)("div",{className:"memori--blob-container",children:S&&(0,a.jsx)(fC,{speaking:d,avatar:M()})}),(()=>{if(!o||u||!e.isGiver||!(null==r?void 0:r.name))return null;const t=`https://${r.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,a.jsx)("div",{className:"memori--avatar-link-to-integrations",children:(0,a.jsx)("a",{className:"memori-button memori-button--circle memori-button--outlined",href:t,children:(0,a.jsx)(nI,{content:w("widgetgoToIntegrationsToCustomizeAvatar"),children:(0,a.jsx)("span",{className:"memori-button--icon",children:(0,a.jsx)(yC,{})})})})})})()]})}),((e,t)=>JSON.stringify(e)===JSON.stringify(t)));c=o("85Hg2"),c=o("85Hg2");var fL=({open:e=!1,onClose:n,children:i,className:r,trigger:o,placement:s="bottom-right"})=>{const l=(0,c.useRef)(null),[u,d]=(0,c.useState)(e);(0,c.useEffect)((()=>{d(e)}),[e]),(0,c.useEffect)((()=>{const e=e=>{l.current&&!l.current.contains(e.target)&&(d(!1),null==n||n())};return u&&document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}}),[u,n]);return(0,a.jsxs)("div",{className:t(We)("memori-dropdown",r),ref:l,children:[(0,a.jsx)("div",{className:"memori-dropdown--trigger",onClick:()=>{d(!u)},children:o}),u&&(0,a.jsx)("div",{className:t(We)("memori-dropdown--content",`memori-dropdown--content--${s}`),children:i})]})};var gL=({className:e,title:t})=>(0,a.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,a.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 vL=({className:e,title:t})=>(0,a.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,a.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 yL=({className:e,title:t})=>(0,a.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,a.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 _L=({className:e,title:t})=>(0,a.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,a.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 bL=({className:e,title:t})=>(0,a.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,a.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 xL=({className:e,title:t})=>(0,a.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,a.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 wL=({className:e,title:t})=>(0,a.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,a.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,a.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 SL=({className:e,title:t})=>(0,a.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,a.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 EL=({className:e,title:t})=>(0,a.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,a.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 AL,TL=({className:e,title:t})=>(0,a.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,a.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"})}),IL=(c=o("85Hg2"),Object.defineProperty),ML=Object.getOwnPropertySymbols,CL=Object.prototype.hasOwnProperty,NL=Object.prototype.propertyIsEnumerable,OL=(e,t,n)=>t in e?IL(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,RL=(e,t)=>{for(var n in t||(t={}))CL.call(t,n)&&OL(e,n,t[n]);if(ML)for(var n of ML(t))NL.call(t,n)&&OL(e,n,t[n]);return e},LL=(e,t)=>{var n={};for(var i in e)CL.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&ML)for(var i of ML(e))t.indexOf(i)<0&&NL.call(e,i)&&(n[i]=e[i]);return n};(e=>{const t=class{constructor(e,n,i,r){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(r<-1||r>7)throw new RangeError("Mask value out of range");this.size=4*e+17;let a=[];for(let e=0;e<this.size;e++)a.push(!1);for(let e=0;e<this.size;e++)this.modules.push(a.slice()),this.isFunction.push(a.slice());this.drawFunctionPatterns();const s=this.addEccAndInterleave(i);if(this.drawCodewords(s),-1==r){let e=1e9;for(let t=0;t<8;t++){this.applyMask(t),this.drawFormatBits(t);const n=this.getPenaltyScore();n<e&&(r=t,e=n),this.applyMask(t)}}o(0<=r&&r<=7),this.mask=r,this.applyMask(r),this.drawFormatBits(r),this.isFunction=[]}static encodeText(n,i){const r=e.QrSegment.makeSegments(n);return t.encodeSegments(r,i)}static encodeBinary(n,i){const r=e.QrSegment.makeBytes(n);return t.encodeSegments([r],i)}static encodeSegments(e,n,r=1,a=40,l=-1,c=!0){if(!(t.MIN_VERSION<=r&&r<=a&&a<=t.MAX_VERSION)||l<-1||l>7)throw new RangeError("Invalid value");let u,d;for(u=r;;u++){const i=8*t.getNumDataCodewords(u,n),r=s.getTotalBits(e,u);if(r<=i){d=r;break}if(u>=a)throw new RangeError("Data too long")}for(const e of[t.Ecc.MEDIUM,t.Ecc.QUARTILE,t.Ecc.HIGH])c&&d<=8*t.getNumDataCodewords(u,e)&&(n=e);let h=[];for(const t of e){i(t.mode.modeBits,4,h),i(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),i(0,Math.min(4,p-h.length),h),i(0,(8-h.length%8)%8,h),o(h.length%8==0);for(let e=236;h.length<p;e^=253)i(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 i=0;i<t;i++)0==n&&0==i||0==n&&i==t-1||n==t-1&&0==i||this.drawAlignmentPattern(e[n],e[i]);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 i=21522^(t<<10|n);o(i>>>15==0);for(let e=0;e<=5;e++)this.setFunctionModule(8,e,r(i,e));this.setFunctionModule(8,7,r(i,6)),this.setFunctionModule(8,8,r(i,7)),this.setFunctionModule(7,8,r(i,8));for(let e=9;e<15;e++)this.setFunctionModule(14-e,8,r(i,e));for(let e=0;e<8;e++)this.setFunctionModule(this.size-1-e,8,r(i,e));for(let e=8;e<15;e++)this.setFunctionModule(8,this.size-15+e,r(i,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=r(t,e),i=this.size-11+e%3,o=Math.floor(e/3);this.setFunctionModule(i,o,n),this.setFunctionModule(o,i,n)}}drawFinderPattern(e,t){for(let n=-4;n<=4;n++)for(let i=-4;i<=4;i++){const r=Math.max(Math.abs(i),Math.abs(n)),o=e+i,a=t+n;0<=o&&o<this.size&&0<=a&&a<this.size&&this.setFunctionModule(o,a,2!=r&&4!=r)}}drawAlignmentPattern(e,t){for(let n=-2;n<=2;n++)for(let i=-2;i<=2;i++)this.setFunctionModule(e+i,t+n,1!=Math.max(Math.abs(i),Math.abs(n)))}setFunctionModule(e,t,n){this.modules[t][e]=n,this.isFunction[t][e]=!0}addEccAndInterleave(e){const n=this.version,i=this.errorCorrectionLevel;if(e.length!=t.getNumDataCodewords(n,i))throw new RangeError("Invalid argument");const r=t.NUM_ERROR_CORRECTION_BLOCKS[i.ordinal][n],a=t.ECC_CODEWORDS_PER_BLOCK[i.ordinal][n],s=Math.floor(t.getNumRawDataModules(n)/8),l=r-s%r,c=Math.floor(s/r);let u=[];const d=t.reedSolomonComputeDivisor(a);for(let n=0,i=0;n<r;n++){let r=e.slice(i,i+c-a+(n<l?0:1));i+=r.length;const o=t.reedSolomonComputeRemainder(r,d);n<l&&r.push(0),u.push(r.concat(o))}let h=[];for(let e=0;e<u[0].length;e++)u.forEach(((t,n)=>{(e!=c-a||n>=l)&&h.push(t[e])}));return o(h.length==s),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 i=0;i<this.size;i++)for(let o=0;o<2;o++){const a=t-o,s=0==(t+1&2)?this.size-1-i:i;!this.isFunction[s][a]&&n<8*e.length&&(this.modules[s][a]=r(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 i;switch(e){case 0:i=(n+t)%2==0;break;case 1:i=t%2==0;break;case 2:i=n%3==0;break;case 3:i=(n+t)%3==0;break;case 4:i=(Math.floor(n/3)+Math.floor(t/2))%2==0;break;case 5:i=n*t%2+n*t%3==0;break;case 6:i=(n*t%2+n*t%3)%2==0;break;case 7:i=((n+t)%2+n*t%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[t][n]&&i&&(this.modules[t][n]=!this.modules[t][n])}}getPenaltyScore(){let e=0;for(let n=0;n<this.size;n++){let i=!1,r=0,o=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[n][a]==i?(r++,5==r?e+=t.PENALTY_N1:r>5&&e++):(this.finderPenaltyAddHistory(r,o),i||(e+=this.finderPenaltyCountPatterns(o)*t.PENALTY_N3),i=this.modules[n][a],r=1);e+=this.finderPenaltyTerminateAndCount(i,r,o)*t.PENALTY_N3}for(let n=0;n<this.size;n++){let i=!1,r=0,o=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[a][n]==i?(r++,5==r?e+=t.PENALTY_N1:r>5&&e++):(this.finderPenaltyAddHistory(r,o),i||(e+=this.finderPenaltyCountPatterns(o)*t.PENALTY_N3),i=this.modules[a][n],r=1);e+=this.finderPenaltyTerminateAndCount(i,r,o)*t.PENALTY_N3}for(let n=0;n<this.size-1;n++)for(let i=0;i<this.size-1;i++){const r=this.modules[n][i];r==this.modules[n][i+1]&&r==this.modules[n+1][i]&&r==this.modules[n+1][i+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 i=this.size*this.size,r=Math.ceil(Math.abs(20*n-10*i)/i)-1;return o(0<=r&&r<=9),e+=r*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 i=this.size-7;n.length<e;i-=t)n.splice(1,0,i);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 i=1;for(let r=0;r<e;r++){for(let e=0;e<n.length;e++)n[e]=t.reedSolomonMultiply(n[e],i),e+1<n.length&&(n[e]^=n[e+1]);i=t.reedSolomonMultiply(i,2)}return n}static reedSolomonComputeRemainder(e,n){let i=n.map((e=>0));for(const r of e){const e=r^i.shift();i.push(0),n.forEach(((n,r)=>i[r]^=t.reedSolomonMultiply(n,e)))}return i}static reedSolomonMultiply(e,t){if(e>>>8!=0||t>>>8!=0)throw new RangeError("Byte out of range");let n=0;for(let i=7;i>=0;i--)n=n<<1^285*(n>>>7),n^=(t>>>i&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 i(e,t,n){if(t<0||t>31||e>>>t!=0)throw new RangeError("Value out of range");for(let i=t-1;i>=0;i--)n.push(e>>>i&1)}function r(e,t){return 0!=(e>>>t&1)}function o(e){if(!e)throw new Error("Assertion error")}n.MIN_VERSION=1,n.MAX_VERSION=40,n.PENALTY_N1=3,n.PENALTY_N2=3,n.PENALTY_N3=40,n.PENALTY_N4=10,n.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],n.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],e.QrCode=n;const a=class{constructor(e,t,n){if(this.mode=e,this.numChars=t,this.bitData=n,t<0)throw new RangeError("Invalid argument");this.bitData=n.slice()}static makeBytes(e){let t=[];for(const n of e)i(n,8,t);return new a(a.Mode.BYTE,e.length,t)}static makeNumeric(e){if(!a.isNumeric(e))throw new RangeError("String contains non-numeric characters");let t=[];for(let n=0;n<e.length;){const r=Math.min(e.length-n,3);i(parseInt(e.substr(n,r),10),3*r+1,t),n+=r}return new a(a.Mode.NUMERIC,e.length,t)}static makeAlphanumeric(e){if(!a.isAlphanumeric(e))throw new RangeError("String contains unencodable characters in alphanumeric mode");let t,n=[];for(t=0;t+2<=e.length;t+=2){let r=45*a.ALPHANUMERIC_CHARSET.indexOf(e.charAt(t));r+=a.ALPHANUMERIC_CHARSET.indexOf(e.charAt(t+1)),i(r,11,n)}return t<e.length&&i(a.ALPHANUMERIC_CHARSET.indexOf(e.charAt(t)),6,n),new a(a.Mode.ALPHANUMERIC,e.length,n)}static makeSegments(e){return""==e?[]:a.isNumeric(e)?[a.makeNumeric(e)]:a.isAlphanumeric(e)?[a.makeAlphanumeric(e)]:[a.makeBytes(a.toUtf8ByteArray(e))]}static makeEci(e){let t=[];if(e<0)throw new RangeError("ECI assignment value out of range");if(e<128)i(e,8,t);else if(e<16384)i(2,2,t),i(e,14,t);else{if(!(e<1e6))throw new RangeError("ECI assignment value out of range");i(6,3,t),i(e,21,t)}return new a(a.Mode.ECI,0,t)}static isNumeric(e){return a.NUMERIC_REGEX.test(e)}static isAlphanumeric(e){return a.ALPHANUMERIC_REGEX.test(e)}getData(){return this.bitData.slice()}static getTotalBits(e,t){let n=0;for(const i of e){const e=i.mode.numCharCountBits(t);if(i.numChars>=1<<e)return 1/0;n+=4+e+i.bitData.length}return n}static toUtf8ByteArray(e){e=encodeURI(e);let t=[];for(let n=0;n<e.length;n++)"%"!=e.charAt(n)?t.push(e.charCodeAt(n)):(t.push(parseInt(e.substr(n+1,2),16)),n+=2);return t}};let s=a;s.NUMERIC_REGEX=/^[0-9]*$/,s.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,s.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:",e.QrSegment=s})(AL||(AL={})),(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={}))})(AL||(AL={})),(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={}))})(AL||(AL={}));var PL=AL,DL={L:PL.QrCode.Ecc.LOW,M:PL.QrCode.Ecc.MEDIUM,Q:PL.QrCode.Ecc.QUARTILE,H:PL.QrCode.Ecc.HIGH},kL=128,BL="L",FL="#FFFFFF",UL="#000000",zL=!1;
238
+ /*! @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 */CI=function(){"use strict";const{entries:e,setPrototypeOf:t,isFrozen:n,getPrototypeOf:i,getOwnPropertyDescriptor:r}=Object;let{freeze:o,seal:a,create:s}=Object,{apply:l,construct:c}="undefined"!=typeof Reflect&&Reflect;o||(o=function(e){return e}),a||(a=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=w(Array.prototype.forEach),d=w(Array.prototype.pop),h=w(Array.prototype.push),p=w(String.prototype.toLowerCase),m=w(String.prototype.toString),f=w(String.prototype.match),g=w(String.prototype.replace),v=w(String.prototype.indexOf),y=w(String.prototype.trim),_=w(Object.prototype.hasOwnProperty),b=w(RegExp.prototype.test),x=S(TypeError);function w(e){return function(t){for(var n=arguments.length,i=new Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];return l(e,t,i)}}function S(e){return function(){for(var t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];return c(e,n)}}function E(e,i){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:p;t&&t(e,null);let o=i.length;for(;o--;){let t=i[o];if("string"==typeof t){const e=r(t);e!==t&&(n(i)||(i[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 T(t){const n=s(null);for(const[i,r]of e(t))_(t,i)&&(Array.isArray(r)?n[i]=A(r):r&&"object"==typeof r&&r.constructor===Object?n[i]=T(r):n[i]=r);return n}function I(e,t){for(;null!==e;){const n=r(e,t);if(n){if(n.get)return w(n.get);if("function"==typeof n.value)return w(n.value)}e=i(e)}function n(){return null}return n}const M=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"]),C=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"]),N=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"]),O=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"]),R=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"]),L=o(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),P=o(["#text"]),D=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"]),F=o(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),U=a(/\{\{[\w\W]*|[\w\W]*\}\}/gm),z=a(/<%[\w\W]*|[\w\W]*%>/gm),G=a(/\${[\w\W]*}/gm),j=a(/^data-[\-\w.\u00B7-\uFFFF]/),H=a(/^aria-[\-\w]+$/),V=a(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),W=a(/^(?:\w+script|data):/i),q=a(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),$=a(/^html$/i),Y=a(/^[a-z][.\w]*(-[.\w]+)+$/i);var J=Object.freeze({__proto__:null,ARIA_ATTR:H,ATTR_WHITESPACE:q,CUSTOM_ELEMENT:Y,DATA_ATTR:j,DOCTYPE_NAME:$,ERB_EXPR:z,IS_ALLOWED_URI:V,IS_SCRIPT_OR_DATA:W,MUSTACHE_EXPR:U,TMPLIT_EXPR:G});const Z={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,progressingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},X=function(){return"undefined"==typeof window?null:window},K=function(e,t){if("object"!=typeof e||"function"!=typeof e.createPolicy)return null;let n=null;const i="data-tt-policy-suffix";t&&t.hasAttribute(i)&&(n=t.getAttribute(i));const r="dompurify"+(n?"#"+n:"");try{return e.createPolicy(r,{createHTML:e=>e,createScriptURL:e=>e})}catch(e){return console.warn("TrustedTypes policy "+r+" could not be created."),null}};function Q(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:X();const n=e=>Q(e);if(n.version="3.2.1",n.removed=[],!t||!t.document||t.document.nodeType!==Z.document)return n.isSupported=!1,n;let{document:i}=t;const r=i,a=r.currentScript,{DocumentFragment:l,HTMLTemplateElement:c,Node:w,Element:S,NodeFilter:A,NamedNodeMap:U=t.NamedNodeMap||t.MozNamedAttrMap,HTMLFormElement:z,DOMParser:G,trustedTypes:j}=t,H=S.prototype,W=I(H,"cloneNode"),q=I(H,"remove"),Y=I(H,"nextSibling"),ee=I(H,"childNodes"),te=I(H,"parentNode");if("function"==typeof c){const e=i.createElement("template");e.content&&e.content.ownerDocument&&(i=e.content.ownerDocument)}let ne,ie="";const{implementation:re,createNodeIterator:oe,createDocumentFragment:ae,getElementsByTagName:se}=i,{importNode:le}=r;let ce={};n.isSupported="function"==typeof e&&"function"==typeof te&&re&&void 0!==re.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}=J;let{IS_ALLOWED_URI:ye}=J,_e=null;const be=E({},[...M,...C,...N,...R,...P]);let xe=null;const we=E({},[...D,...k,...B,...F]);let Se=Object.seal(s(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}})),Ee=null,Ae=null,Te=!0,Ie=!0,Me=!1,Ce=!0,Ne=!1,Oe=!0,Re=!1,Le=!1,Pe=!1,De=!1,ke=!1,Be=!1,Fe=!0,Ue=!1;const ze="user-content-";let Ge=!0,je=!1,He={},Ve=null;const We=E({},["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 $e=E({},["audio","video","img","source","image","track"]);let Ye=null;const Je=E({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Ze="http://www.w3.org/1998/Math/MathML",Xe="http://www.w3.org/2000/svg",Ke="http://www.w3.org/1999/xhtml";let Qe=Ke,et=!1,tt=null;const nt=E({},[Ze,Xe,Ke],m);let it=E({},["mi","mo","mn","ms","mtext"]),rt=E({},["annotation-xml"]);const ot=E({},["title","style","font","a","script"]);let at=null;const st=["application/xhtml+xml","text/html"],lt="text/html";let ct=null,ut=null;const dt=i.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=T(e),at=-1===st.indexOf(e.PARSER_MEDIA_TYPE)?lt:e.PARSER_MEDIA_TYPE,ct="application/xhtml+xml"===at?m:p,_e=_(e,"ALLOWED_TAGS")?E({},e.ALLOWED_TAGS,ct):be,xe=_(e,"ALLOWED_ATTR")?E({},e.ALLOWED_ATTR,ct):we,tt=_(e,"ALLOWED_NAMESPACES")?E({},e.ALLOWED_NAMESPACES,m):nt,Ye=_(e,"ADD_URI_SAFE_ATTR")?E(T(Je),e.ADD_URI_SAFE_ATTR,ct):Je,qe=_(e,"ADD_DATA_URI_TAGS")?E(T($e),e.ADD_DATA_URI_TAGS,ct):$e,Ve=_(e,"FORBID_CONTENTS")?E({},e.FORBID_CONTENTS,ct):We,Ee=_(e,"FORBID_TAGS")?E({},e.FORBID_TAGS,ct):{},Ae=_(e,"FORBID_ATTR")?E({},e.FORBID_ATTR,ct):{},He=!!_(e,"USE_PROFILES")&&e.USE_PROFILES,Te=!1!==e.ALLOW_ARIA_ATTR,Ie=!1!==e.ALLOW_DATA_ATTR,Me=e.ALLOW_UNKNOWN_PROTOCOLS||!1,Ce=!1!==e.ALLOW_SELF_CLOSE_IN_ATTR,Ne=e.SAFE_FOR_TEMPLATES||!1,Oe=!1!==e.SAFE_FOR_XML,Re=e.WHOLE_DOCUMENT||!1,De=e.RETURN_DOM||!1,ke=e.RETURN_DOM_FRAGMENT||!1,Be=e.RETURN_TRUSTED_TYPE||!1,Pe=e.FORCE_BODY||!1,Fe=!1!==e.SANITIZE_DOM,Ue=e.SANITIZE_NAMED_PROPS||!1,Ge=!1!==e.KEEP_CONTENT,je=e.IN_PLACE||!1,ye=e.ALLOWED_URI_REGEXP||V,Qe=e.NAMESPACE||Ke,it=e.MATHML_TEXT_INTEGRATION_POINTS||it,rt=e.HTML_INTEGRATION_POINTS||rt,Se=e.CUSTOM_ELEMENT_HANDLING||{},e.CUSTOM_ELEMENT_HANDLING&&ht(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(Se.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&&ht(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(Se.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(Se.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Ne&&(Ie=!1),ke&&(De=!0),He&&(_e=E({},P),xe=[],!0===He.html&&(E(_e,M),E(xe,D)),!0===He.svg&&(E(_e,C),E(xe,k),E(xe,F)),!0===He.svgFilters&&(E(_e,N),E(xe,k),E(xe,F)),!0===He.mathMl&&(E(_e,R),E(xe,B),E(xe,F))),e.ADD_TAGS&&(_e===be&&(_e=T(_e)),E(_e,e.ADD_TAGS,ct)),e.ADD_ATTR&&(xe===we&&(xe=T(xe)),E(xe,e.ADD_ATTR,ct)),e.ADD_URI_SAFE_ATTR&&E(Ye,e.ADD_URI_SAFE_ATTR,ct),e.FORBID_CONTENTS&&(Ve===We&&(Ve=T(Ve)),E(Ve,e.FORBID_CONTENTS,ct)),Ge&&(_e["#text"]=!0),Re&&E(_e,["html","head","body"]),_e.table&&(E(_e,["tbody"]),delete Ee.tbody),e.TRUSTED_TYPES_POLICY){if("function"!=typeof e.TRUSTED_TYPES_POLICY.createHTML)throw x('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof e.TRUSTED_TYPES_POLICY.createScriptURL)throw x('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');ne=e.TRUSTED_TYPES_POLICY,ie=ne.createHTML("")}else void 0===ne&&(ne=K(j,a)),null!==ne&&"string"==typeof ie&&(ie=ne.createHTML(""));o&&o(e),ut=e}},mt=E({},[...C,...N,...O]),ft=E({},[...R,...L]),gt=function(e){let t=te(e);t&&t.tagName||(t={namespaceURI:Qe,tagName:"template"});const n=p(e.tagName),i=p(t.tagName);return!!tt[e.namespaceURI]&&(e.namespaceURI===Xe?t.namespaceURI===Ke?"svg"===n:t.namespaceURI===Ze?"svg"===n&&("annotation-xml"===i||it[i]):Boolean(mt[n]):e.namespaceURI===Ze?t.namespaceURI===Ke?"math"===n:t.namespaceURI===Xe?"math"===n&&rt[i]:Boolean(ft[n]):e.namespaceURI===Ke?!(t.namespaceURI===Xe&&!rt[i])&&!(t.namespaceURI===Ze&&!it[i])&&!ft[n]&&(ot[n]||!mt[n]):!("application/xhtml+xml"!==at||!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&&!xe[e])if(De||ke)try{vt(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}},_t=function(e){let t=null,n=null;if(Pe)e="<remove></remove>"+e;else{const t=f(e,/^[\r\n\t ]+/);n=t&&t[0]}"application/xhtml+xml"===at&&Qe===Ke&&(e='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+e+"</body></html>");const r=ne?ne.createHTML(e):e;if(Qe===Ke)try{t=(new G).parseFromString(r,at)}catch(e){}if(!t||!t.documentElement){t=re.createDocument(Qe,"template",null);try{t.documentElement.innerHTML=et?ie:r}catch(e){}}const o=t.body||t.documentElement;return e&&n&&o.insertBefore(i.createTextNode(n),o.childNodes[0]||null),Qe===Ke?se.call(t,Re?"html":"body")[0]:Re?t.documentElement:o},bt=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)},xt=function(e){return e instanceof z&&("string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||!(e.attributes instanceof U)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore||"function"!=typeof e.hasChildNodes)},wt=function(e){return"function"==typeof w&&e instanceof w};function St(e,t,i){ce[e]&&u(ce[e],(e=>{e.call(n,t,i,ut)}))}const Et=function(e){let t=null;if(St("beforeSanitizeElements",e,null),xt(e))return vt(e),!0;const i=ct(e.nodeName);if(St("uponSanitizeElement",e,{tagName:i,allowedTags:_e}),e.hasChildNodes()&&!wt(e.firstElementChild)&&b(/<[/\w]/g,e.innerHTML)&&b(/<[/\w]/g,e.textContent))return vt(e),!0;if(e.nodeType===Z.progressingInstruction)return vt(e),!0;if(Oe&&e.nodeType===Z.comment&&b(/<[/\w]/g,e.data))return vt(e),!0;if(!_e[i]||Ee[i]){if(!Ee[i]&&Tt(i)){if(Se.tagNameCheck instanceof RegExp&&b(Se.tagNameCheck,i))return!1;if(Se.tagNameCheck instanceof Function&&Se.tagNameCheck(i))return!1}if(Ge&&!Ve[i]){const t=te(e)||e.parentNode,n=ee(e)||e.childNodes;if(n&&t)for(let i=n.length-1;i>=0;--i){const r=W(n[i],!0);r.__removalCount=(e.__removalCount||0)+1,t.insertBefore(r,Y(e))}}return vt(e),!0}return e instanceof S&&!gt(e)?(vt(e),!0):"noscript"!==i&&"noembed"!==i&&"noframes"!==i||!b(/<\/no(script|embed|frames)/i,e.innerHTML)?(Ne&&e.nodeType===Z.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)),St("afterSanitizeElements",e,null),!1):(vt(e),!0)},At=function(e,t,n){if(Fe&&("id"===t||"name"===t)&&(n in i||n in dt))return!1;if(Ie&&!Ae[t]&&b(pe,t));else if(Te&&b(me,t));else if(!xe[t]||Ae[t]){if(!(Tt(e)&&(Se.tagNameCheck instanceof RegExp&&b(Se.tagNameCheck,e)||Se.tagNameCheck instanceof Function&&Se.tagNameCheck(e))&&(Se.attributeNameCheck instanceof RegExp&&b(Se.attributeNameCheck,t)||Se.attributeNameCheck instanceof Function&&Se.attributeNameCheck(t))||"is"===t&&Se.allowCustomizedBuiltInElements&&(Se.tagNameCheck instanceof RegExp&&b(Se.tagNameCheck,n)||Se.tagNameCheck instanceof Function&&Se.tagNameCheck(n))))return!1}else if(Ye[t]);else if(b(ye,g(n,ge,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==v(n,"data:")||!qe[e])if(Me&&!b(fe,g(n,ge,"")));else if(n)return!1;return!0},Tt=function(e){return"annotation-xml"!==e&&f(e,ve)},It=function(e){St("beforeSanitizeAttributes",e,null);const{attributes:t}=e;if(!t)return;const i={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:xe,forceKeepAttr:void 0};let r=t.length;for(;r--;){const o=t[r],{name:a,namespaceURI:s,value:l}=o,c=ct(a);let h="value"===a?l:y(l);if(i.attrName=c,i.attrValue=h,i.keepAttr=!0,i.forceKeepAttr=void 0,St("uponSanitizeAttribute",e,i),h=i.attrValue,!Ue||"id"!==c&&"name"!==c||(yt(a,e),h=ze+h),Oe&&b(/((--!?|])>)|<\/(style|title)/i,h)){yt(a,e);continue}if(i.forceKeepAttr)continue;if(yt(a,e),!i.keepAttr)continue;if(!Ce&&b(/\/>/i,h)){yt(a,e);continue}Ne&&u([ue,de,he],(e=>{h=g(h,e," ")}));const p=ct(e.nodeName);if(At(p,c,h)){if(ne&&"object"==typeof j&&"function"==typeof j.getAttributeType)if(s);else switch(j.getAttributeType(p,c)){case"TrustedHTML":h=ne.createHTML(h);break;case"TrustedScriptURL":h=ne.createScriptURL(h)}try{s?e.setAttributeNS(s,a,h):e.setAttribute(a,h),xt(e)?vt(e):d(n.removed)}catch(e){}}}St("afterSanitizeAttributes",e,null)},Mt=function e(t){let n=null;const i=bt(t);for(St("beforeSanitizeShadowDOM",t,null);n=i.nextNode();)St("uponSanitizeShadowNode",n,null),Et(n)||(n.content instanceof l&&e(n.content),It(n));St("afterSanitizeShadowDOM",t,null)};return n.sanitize=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=null,o=null,a=null,s=null;if(et=!e,et&&(e="\x3c!--\x3e"),"string"!=typeof e&&!wt(e)){if("function"!=typeof e.toString)throw x("toString is not a function");if("string"!=typeof(e=e.toString()))throw x("dirty is not a string, aborting")}if(!n.isSupported)return e;if(Le||pt(t),n.removed=[],"string"==typeof e&&(je=!1),je){if(e.nodeName){const t=ct(e.nodeName);if(!_e[t]||Ee[t])throw x("root node is forbidden and cannot be sanitized in-place")}}else if(e instanceof w)i=_t("\x3c!----\x3e"),o=i.ownerDocument.importNode(e,!0),o.nodeType===Z.element&&"BODY"===o.nodeName||"HTML"===o.nodeName?i=o:i.appendChild(o);else{if(!De&&!Ne&&!Re&&-1===e.indexOf("<"))return ne&&Be?ne.createHTML(e):e;if(i=_t(e),!i)return De?null:Be?ie:""}i&&Pe&&vt(i.firstChild);const c=bt(je?e:i);for(;a=c.nextNode();)Et(a)||(a.content instanceof l&&Mt(a.content),It(a));if(je)return e;if(De){if(ke)for(s=ae.call(i.ownerDocument);i.firstChild;)s.appendChild(i.firstChild);else s=i;return(xe.shadowroot||xe.shadowrootmode)&&(s=le.call(r,s,!0)),s}let d=Re?i.outerHTML:i.innerHTML;return Re&&_e["!doctype"]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&b($,i.ownerDocument.doctype.name)&&(d="<!DOCTYPE "+i.ownerDocument.doctype.name+">\n"+d),Ne&&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]:{}),Le=!0},n.clearConfig=function(){ut=null,Le=!1},n.isValidAttribute=function(e,t,n){ut||pt({});const i=ct(e),r=ct(t);return At(i,r,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 Q()}();var NI=o("1Lq0j"),OI={};OI=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]/,i=/[ \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/;function r(r){const o={};r=r||{},o.src_Any=e.source,o.src_Cc=t.source,o.src_Z=i.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 a="[><|]";return o.src_pseudo_letter="(?:(?!"+a+"|"+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="(?=$|"+a+"|"+o.src_ZPCc+")(?!"+(r["---"]?"-(?!--)|":"-|")+"_|:\\d|\\.-|\\.(?!$|"+o.src_ZPCc+"))",o.src_path="(?:[/?#](?:(?!"+o.src_ZCc+"|"+a+"|[()[\\]{}.,\"'?!\\-;]).|\\[(?:(?!"+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+"|[.]|$)|"+(r["---"]?"\\-(?!--(?:[^-]|$))(?:-*)|":"\\-+|")+",(?!"+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="(^|"+a+'|"|\\(|'+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 a(e){return Object.prototype.toString.call(e)}function s(e){return"[object String]"===a(e)}function l(e){return"[object Object]"===a(e)}function c(e){return"[object RegExp]"===a(e)}function u(e){return"[object Function]"===a(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 i=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(i)?i.match(n.re.http)[0].length:0}},"https:":"http:","ftp:":"http:","//":{validate:function(e,t,n){const i=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(i)?t>=3&&":"===e[t-3]||t>=3&&"/"===e[t-3]?0:i.match(n.re.no_http)[0].length:0}},"mailto:":{validate:function(e,t,n){const i=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(i)?i.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 i=t.slice(n);return e.test(i)?i.match(e)[0].length:0}}function _(){return function(e,t){t.normalize(e)}}function b(e){const t=e.re=r(e.__opts__),n=e.__tlds__.slice();function i(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(i(t.tpl_email_fuzzy),"i"),t.link_fuzzy=RegExp(i(t.tpl_link_fuzzy),"i"),t.link_no_ip_fuzzy=RegExp(i(t.tpl_link_no_ip_fuzzy),"i"),t.host_fuzzy_test=RegExp(i(t.tpl_host_fuzzy_test),"i");const o=[];function a(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 i={validate:null,link:null};if(e.__compiled__[t]=i,l(n))return c(n.validate)?i.validate=y(n.validate):u(n.validate)?i.validate=n.validate:a(t,n),void(u(n.normalize)?i.normalize=n.normalize:n.normalize?a(t,n):i.normalize=_());s(n)?o.push(t):a(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 x(e,t){const n=e.__index__,i=e.__last_index__,r=e.__text_cache__.slice(n,i);this.schema=e.__schema__.toLowerCase(),this.index=n+t,this.lastIndex=i+t,this.raw=r,this.text=r,this.url=r}function w(e,t){const n=new x(e,t);return e.__compiled__[n.schema].normalize(n,e),n}function S(e,t){if(!(this instanceof S))return new S(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={},b(this)}function E(e={},t={}){const n=new S(e,t);return T(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 i;return 0===t.index?i=t.raw:1===t.index&&"<"===e.charAt(0)&&">"===e.charAt(t.lastIndex)&&(i=`<${t.raw}>`),i?{type:"link",raw:i,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 T(e,t){const n=t.tlds;delete t.tlds;const i=t.tldsKeepOld;delete t.tldsKeepOld,n&&e.tlds(n,i)}return S.prototype.add=function(e,t){return this.__schemas__[e]=t,b(this),this},S.prototype.set=function(e){return this.__opts__=o(this.__opts__,e),this},S.prototype.test=function(e){if(this.__text_cache__=e,this.__index__=-1,!e.length)return!1;let t,n,i,r,o,a,s,l,c;if(this.re.schema_test.test(e))for(s=this.re.schema_search,s.lastIndex=0;null!==(t=s.exec(e));)if(r=this.testSchemaAt(e,t[2],s.lastIndex),r){this.__schema__=t[2],this.__index__=t.index+t[1].length,this.__last_index__=t.index+t[0].length+r;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!==(i=e.match(this.re.email_fuzzy))&&(o=i.index+i[1].length,a=i.index+i[0].length,(this.__index__<0||o<this.__index__||o===this.__index__&&a>this.__last_index__)&&(this.__schema__="mailto:",this.__index__=o,this.__last_index__=a))),this.__index__>=0},S.prototype.pretest=function(e){return this.re.pretest.test(e)},S.prototype.testSchemaAt=function(e,t,n){return this.__compiled__[t.toLowerCase()]?this.__compiled__[t.toLowerCase()].validate(e,n,this):0},S.prototype.match=function(e){const t=[];let n=0;this.__index__>=0&&this.__text_cache__===e&&(t.push(w(this,n)),n=this.__last_index__);let i=n?e.slice(n):e;for(;this.test(i);)t.push(w(this,n)),i=i.slice(this.__last_index__),n+=this.__last_index__;return t.length?t:null},S.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,w(this,0)):null},S.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(),b(this),this):(this.__tlds__=e.slice(),this.__tlds_replaced__=!0,b(this),this)},S.prototype.normalize=function(e){e.schema||(e.url="http://"+e.url),"mailto:"!==e.schema||/^mailto:/i.test(e.url)||(e.url="mailto:"+e.url)},S.prototype.onCompile=function(){},E}();var RI={};RI=function(e){"use strict";const t=/^(\${1,2})(?!\$)((?:\\.|[^\\\n])*?(?:\\.|[^\\\n\$]))\1(?=[\s?!\.,:?!。,:]|$)/,n=/^(\${1,2})(?!\$)((?:\\.|[^\\\n])*?(?:\\.|[^\\\n\$]))\1/,i=/^(\${1,2})\n((?:\\[^]|[^\\])+?)\n\1(?:\n|$)/;function r(e={}){return{extensions:[a(e,o(e,!1)),s(e,o(e,!0))]}}function o(t,n){return i=>e.renderToString(i.text,{...t,displayMode:i.displayMode})+(n?"\n":"")}function a(e,i){const r=e&&e.nonStandard,o=r?n:t;return{name:"inlineKatex",level:"inline",start(e){let t,n=e;for(;n;){if(t=n.indexOf("$"),-1===t)return;if((r?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:i}}function s(e,t){return{name:"blockKatex",level:"block",tokenizer(e,t){const n=e.match(i);if(n)return{type:"blockKatex",raw:n[0],text:n[2].trim(),displayMode:2===n[1].length}},renderer:t}}return r}(o("kqAxc"));const LI=(e,t,n,i)=>{if(!t.rowspan)return"";return`${`<${n}`+(t.colspan>1?` colspan=${t.colspan}`:"")+(t.rowspan>1?` rowspan=${t.rowspan}`:"")+(i?` align=${i}`:"")+">"+e}</${n}>\n`},PI=(e,t,n=[])=>{var i,r,o;const a=[...e.matchAll(/(?:[^|\\]|\\.?)+(?:\|+|$)/g)].map((e=>e[0]));(null===(i=a[0])||void 0===i?void 0:i.trim())||a.shift(),(null===(r=a[a.length-1])||void 0===r?void 0:r.trim())||a.pop();let s,l,c,u,d,h=0;for(s=0;s<a.length;s++){if(c=a[s].split(/\|+$/)[0],a[s]={rowspan:1,colspan:Math.max(a[s].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===a[s].colspan){a[s].rowSpanTarget=null!==(o=u.rowSpanTarget)&&void 0!==o?o:u,a[s].rowSpanTarget.text+=` ${a[s].text.slice(0,-1)}`,a[s].rowSpanTarget.rowspan+=1,a[s].rowspan=0;break}if(d+=u.colspan,d>h)break}h+=a[s].colspan}if(h>t)a.splice(t);else for(;h<t;)a.push({colspan:1,text:""}),h+=1;return a};MI.marked.use({async:!1,gfm:!0,pedantic:!1,renderer:{link:({href:e,title:t,text:n})=>{const i=e?zE(e):null;if(null===i)return n;let r='<a href="'+(e=i)+'"';return t&&(r+=' title="'+t+'"'),r+=' target="_blank" rel="noopener noreferrer">'+n+"</a>",r}}}),MI.marked.use(t(OI)()),MI.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]=PI(e.header[0]);const t=e.header[0].reduce(((e,t)=>e+t.colspan),0);if(t===e.align.length){let i,r,o,a;e.raw=n[0];let s=e.align.length;for(i=0;i<s;i++)/^ *-+: *$/.test(e.align[i])?e.align[i]="right":/^ *:-+: *$/.test(e.align[i])?e.align[i]="center":/^ *:-+ *$/.test(e.align[i])?e.align[i]="left":e.align[i]=null;for(s=e.header.length,i=1;i<s;i++)e.header[i]=PI(e.header[i],t,e.header[i-1]);for(s=e.rows.length,i=0;i<s;i++)e.rows[i]=PI(e.rows[i],t,e.rows[i-1]);for(s=e.header.length,r=0;r<s;r++)for(a=e.header[r],o=0;o<a.length;o++)a[o].tokens=[],this.lexer.inline(a[o].text,a[o].tokens);for(s=e.rows.length,r=0;r<s;r++)for(a=e.rows[r],o=0;o<a.length;o++)a[o].tokens=[],this.lexer.inline(a[o].text,a[o].tokens);return e}}},renderer(e){let t,n,i,r,o,a,s='<div class="memori--responsive-table-wrapper"><table class="memori--table memori--table--compact">';for(s+="<thead>",t=0;t<e.header.length;t++){i=e.header[t];let o=0;for(s+="<tr>",n=0;n<i.length;n++)r=i[n],a=this.parser.parseInline(r.tokens),s+=LI(a,r,"th",e.align[o]),o+=r.colspan;s+="</tr>"}if(s+="</thead>",e.rows.length){for(s+="<tbody>",t=0;t<e.rows.length;t++){for(i=e.rows[t],o=0,s+="<tr>",n=0;n<i.length;n++)r=i[n],a=this.parser.parseInline(r.tokens),s+=LI(a,r,"td",e.align[o]),o+=r.colspan;s+="</tr>"}s+="</tbody>"}return s+="</table></div>",s}}]});const DI=e=>{let t=e;return e.length>NI.MAX_MSG_CHARS&&(t=`${e.slice(0,NI.MAX_MSG_CHARS)}\n<br />...`),t.split(" ").length>NI.MAX_MSG_WORDS&&(t=t.split(" ").slice(0,NI.MAX_MSG_WORDS).join(" ")),t},kI=(e,n=!1,i="Reasoning...",r)=>{try{let o=e.trim().replaceAll(/\[([^\]]+)\]\(([^\)]+)\)/g,'<a href="$2" target="_blank" rel="noopener noreferrer">$1</a>').replaceAll(/<think.*?>(.*?)<\/think>/gs,r?`<details class="memori-think"><summary>${i}</summary>$1</details>`:"").replaceAll(/<document_attachment filename="([^"]+)" type="([^"]+)">([\s\S]*?)<\/document_attachment>/g,"").replaceAll(/<output\s+class\s*=\s*["\']memori-artifact["\'][^>]*data-mimetype\s*=\s*["\']([^"']+)["\'][^>]*>([\s\S]*?)(?:<\/output>|$)/gi,"").replaceAll(/```markdown([^```]+)```/g,"$1").replaceAll("($","( $").replaceAll(":$",": $").replaceAll("\frac","\\frac").replaceAll("\beta","\\beta").replaceAll("cdot","\\cdot");n&&(MI.marked.use(t(RI)({})),o=o.replace(/\\+\[(.*?)\\*\]/gs,((e,t)=>`$$${t}$$`)),o=o.replace(/\[([^[\]]+?)\]/g,((e,t)=>!/[\\+a-z0-9_{}^=\-\+\*\/]+/i.test(t)||e.startsWith("[http")||e.includes("](")?e:`$$${t}$$`)));const a=[];let s=0;o=o.replace(/(<output[^>]*>)([\s\S]*?)(<\/output>)/g,((e,t,n,i)=>{const r=`\x3c!--OUTPUT_PLACEHOLDER_${s++}--\x3e`;return a.push(`${t}${n}${i}`),r})),o=o.replace(/(<!--OUTPUT_PLACEHOLDER_\d+-->)\s*([^\s<\n-])/g,"$1\n\n$2");let l=MI.marked.parse(o).toString().trim();a.forEach(((e,t)=>{l=l.replace(`\x3c!--OUTPUT_PLACEHOLDER_${t}--\x3e`,e)})),l=t(CI).sanitize(l,{ADD_ATTR:["target"]});return{text:l.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}}};NI=o("1Lq0j");var BI=({rows:e,className:n,innerClassName:i,btnClassName:r,lineHeightMultiplier:o=1.2,defaultExpanded:s=!1,expandSymbol:l=(()=>"..."),collapseSymbol:u=(e=>"it"===e?"Mostra meno":"Show less"),children:d,mode:h="rows"})=>{const{i18n:p}=Ve(),m=p.language,f=u(m),g=l(m),[v,y]=(0,c.useState)(s),[_,b]=(0,c.useState)(!1),[x,w]=(0,c.useState)(16),S=(0,c.useRef)(null);(0,c.useEffect)((()=>{if(S.current)if("rows"===h){let t=S.current.getBoundingClientRect().height,n=getComputedStyle(S.current),i=n.lineHeight,r="normal"!==i&&(null==i?void 0:i.length)?parseInt(i,10):o*parseInt(n.fontSize,10);w(r),t&&e&&t>e*r&&b(!0)}else if("characters"===h){const e=S.current.textContent||"";(e.length>NI.MAX_MSG_CHARS||e.split(" ").length>NI.MAX_MSG_WORDS)&&b(!0)}}),[e,h,S.current]);return(0,a.jsxs)("div",{className:t(We)("memori-expandable",n),children:[(0,a.jsx)("div",{ref:S,className:t(We)("memori-expandable--inner",i),style:{maxHeight:v||!_||"characters"===h?"9999px":x*(e||1)+"px"},children:(()=>{var e;if("characters"===h&&!v&&_){const t=(null===(e=S.current)||void 0===e?void 0:e.textContent)||"";return DI(t)}return d})()}),_&&!v&&(0,a.jsx)(Jl,{ghost:!0,padded:!1,className:r,onClick:()=>y(!0),children:g}),_&&v&&(0,a.jsx)(Jl,{ghost:!0,padded:!1,className:r,onClick:()=>y(!1),children:f})]})};const FI=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,SESSION_OTP_NOT_FOUND:-107,SESSION_OTP_EXPIRED:-108,SESSION_MISSING_TEMPORARY_TOKEN:-109,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]))),UI=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=FI.get(e);return t?`errors.${t}`:"error.generic"};c=o("85Hg2"),NI=o("1Lq0j");var zI=({medium:e,className:n,preview:i=!1,showCopyButton:r=!0})=>{var o,s,l,u,d,h,p,m,f;const{t:g}=Ve(),v=()=>{"Prism"in window&&window.Prism.highlightAll&&setTimeout((()=>{Prism.highlightAll()}),100)};return(0,c.useEffect)((()=>{new Promise((e=>{if(document.getElementById("memori-prism-script"))return void e();const t=document.createElement("script");t.src="https://cdn.jsdelivr.net/npm/prismjs@1.29.0/prism.min.js",t.async=!0,t.id="memori-prism-script",t.onload=()=>{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",t.onload=()=>{window.Prism&&window.Prism.plugins&&window.Prism.plugins.autoloader&&(window.Prism.plugins.autoloader.languages_path="https://cdn.jsdelivr.net/npm/prismjs@1.29.0/components/"),e()},document.head.appendChild(t)};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(t)})).then((()=>{v()}))}),[]),(0,c.useEffect)((()=>{v()}),[e.content,e.mimeType]),(0,a.jsxs)("div",{className:"memori-snippet",children:[(0,a.jsxs)("div",{className:"memori-snippet--content",children:[(0,a.jsx)("pre",{className:t(We)("line-numbers",n),"aria-labelledby":(null===(o=e.title)||void 0===o?void 0:o.length)?`#snippet-${e.mediumID}`:void 0,children:(0,a.jsx)("code",{className:`language-${null!==(l=null===(s=NI.prismSyntaxLangs.find((t=>e.mimeType===t.mimeType)))||void 0===s?void 0:s.lang)&&void 0!==l?l:"text"}`,"data-language":null!==(d=null===(u=NI.prismSyntaxLangs.find((t=>e.mimeType===t.mimeType)))||void 0===u?void 0:u.lang)&&void 0!==d?d:"text",children:(null===(h=e.content)||void 0===h?void 0:h.length)&&e.content.length>200&&i?`${null===(p=DE(e.content))||void 0===p?void 0:p.slice(0,200)}\n...`:DE(null!==(m=e.content)&&void 0!==m?m:"")})}),r&&(0,a.jsx)(Jl,{padded:!1,ghost:!0,className:"memori-snippet--copy-button",title:g("copy")||"Copy",icon:(0,a.jsx)(AI,{}),onClick:()=>{var t;return navigator.clipboard.writeText(null!==(t=e.content)&&void 0!==t?t:"")}})]}),!!(null===(f=e.title)||void 0===f?void 0:f.length)&&(0,a.jsx)("p",{id:`snippet-${e.mediumID}`,className:"memori-snippet--caption",children:e.title})]})};c=o("85Hg2"),c=o("85Hg2");var GI,jI=({className:e,title:t})=>(0,a.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,a.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"})}),HI={};GI=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 i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e};function n(e,n){var i=e.el,r=e.elStyle,o=e.elHeight,a=e.rowsLimit,s=e.rowsWrapped,l=e.options,c=e.buffer,u=c;if(s===a+1)return t({},e);var d=c,h=s,p=o;return i.innerHTML=u=c.length?""+c+l.delimiter+n+l.replaceStr:""+n+l.replaceStr,parseFloat(r.height)>parseFloat(o)&&(h++,p=r.height,h===a+1)?(i.innerHTML=u="."===d[d.length-1]&&"..."===l.replaceStr?d+"..":""+d+l.replaceStr,t({},e,{elHeight:p,rowsWrapped:h})):(i.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 i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a={replaceStr:"...",responsive:!1,debounceDelay:250,delimiter:" "},s=t({},a,o),l=i&&(i instanceof NodeList?i:1===i.nodeType?[i]:document.querySelectorAll(i)),c=[],u=0;u<l.length;u++){var d=l[u];c[u]=d.innerHTML;var h=d.innerHTML.split(s.delimiter);d.innerHTML="";var p=window.getComputedStyle(d);h.reduce(n,{el:d,buffer:d.innerHTML,elStyle:p,elHeight:0,rowsLimit:r,rowsWrapped:0,options:s})}if(s.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(i,r,t({},o,{responsive:!1}))}},v=function(){clearTimeout(m),m=setTimeout(g,s.debounceDelay)};return window.addEventListener("resize",v),v}}},"function"==typeof define&&define.amd?define(["exports"],GI):GI(HI);var VI=({loading:e=!1,className:n,title:i,description:r,cover:o,hoverable:s=!1,children:l,onClick:c})=>(0,a.jsx)("div",{onClick:c,className:t(We)("memori-card",n,{"memori-card--loading":e,"memori-card--with-cover":o,"memori-card--hoverable":s,"memori-card--pointer":!!c}),children:(0,a.jsxs)(Yl,{spinning:e,children:[o&&(0,a.jsx)("div",{className:"memori-card--cover",children:o}),(0,a.jsxs)("div",{className:"memori-card--content",children:[i&&(0,a.jsx)("h3",{className:"memori-card--title",children:i}),r&&(0,a.jsx)("p",{className:"memori-card--description",children:r}),(0,a.jsx)("div",{className:"memori-card--children",children:l})]})]})});const WI=({isChild:e=!1,item:n,baseUrl:i,onLinkPreviewInfo:r,descriptionOneLine:o=!1})=>{var s,l,u,d;const[h,p]=(0,c.useState)(null),m=(null===(s=n.url)||void 0===s?void 0:s.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,i).then((e=>{p(e?{...e,urlKey:o}:null),r&&e&&r(e)}))}),[null==n?void 0:n.url,i,r]);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,HI.ellipsis)(".memori-link-item--card .memori-card--description",3,{responsive:!0})}),300)}),[g,n.mediumID]),(0,a.jsx)("a",{href:m,target:"_blank",rel:"noopener noreferrer",className:t(We)("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,a.jsx)(VI,{hoverable:!0,className:t(We)("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,a.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,a.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,a.jsx)("div",{className:"memori-link-item--card-cover-icon",children:(0,a.jsx)(jI,{className:"memori-link-item--icon"})}),title:f,description:g})})};var qI=({items:e,baseUrl:n,descriptionOneLine:i=!1,onLinkPreviewInfo:r,fromUser:o=!1})=>(0,a.jsx)(Os,{appear:!0,show:!0,as:"div",className:"memori-link-items",children:(0,a.jsx)("div",{className:t(We)("memori-link-items--grid memori-chat-scroll-item",{"memori-link-items--user":o,"memori-link-items--agent":!o}),children:e.map(((e,t)=>(0,a.jsx)(Os.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,a.jsx)(WI,{item:e,baseUrl:n,descriptionOneLine:i,onLinkPreviewInfo:r})},e.mediumID)))})});c=o("85Hg2");const $I=["va bene","no grazie","si","no","sì","arrivederci","non c'entrava","non mi è piaciuto"],YI=async(e,t,n,i)=>{var r,o,a,s;let l=(e=>e.replaceAll(/<output.*?>(.*?)<\/output>/g,""))((e=>e.replaceAll(/<think.*?>(.*?)<\/think>/gs,""))(e));const c=e.match(/<think.*?>(.*?)<\/think>/gs),u=$I.indexOf(e.toLowerCase())>-1?"IT":null==n?void 0:n.toUpperCase(),d=t.toUpperCase(),h=await fetch(`${i||"https://www.aisuru.com"}/api/translate`,{cache:"no-cache",method:"POST",body:JSON.stringify({text:l,target_lang:d,source_lang:u}),headers:{Accept:"*/*","Content-Type":"application/json"}}),p=await h.json();return p&&p.translations&&p.translations[0]&&(p.translations[0].text=(c?`<think>${c}</think>`:"")+(null===(o=null===(r=null==p?void 0:p.translations)||void 0===r?void 0:r[0])||void 0===o?void 0:o.text)),null!==(s=null===(a=null==p?void 0:p.translations)||void 0===a?void 0:a[0])&&void 0!==s?s:{text:l}};NI=o("1Lq0j"),c=o("85Hg2");var JI=({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,a.jsx)("div",{className:"model-viewer",children:(0,a.jsx)("model-viewer",{src:e,"ios-src":"",poster:t,alt:n,"shadow-intensity":"1","disable-zoom":!0,"camera-controls":!0,autoplay:!0})}));var ZI=({className:e,title:t})=>(0,a.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,a.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 XI=({className:e,title:t})=>(0,a.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,a.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 KI=({className:e,title:t})=>(0,a.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,a.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 QI=({className:e,title:t})=>(0,a.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,a.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 eM=({isChild:e=!1,item:t,sessionID:n,tenantID:i,preview:r=!1,baseURL:o,apiURL:s,onClick:l,customMediaRenderer:u})=>{var d,h;const[p,m]=(0,c.useState)(!1),[f,g]=(0,c.useState)(!1),[v,y]=(0,c.useState)(!1),_=KT({resourceURI:t.url,sessionID:n,tenantID:i,baseURL:o,apiURL:s}),b=null==u?void 0:u(t.mimeType);if(b)return b;const x=NI.prismSyntaxLangs.map((e=>e.mimeType)).includes(t.mimeType),w="text/html"===t.mimeType,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(")),E=e=>{if(!e)return!1;try{return new URL(e),!0}catch(e){return!1}},A=(()=>{var e,n;return E(_)||E(t.url)?_||t.url:(null===(e=t.url)||void 0===e?void 0:e.startsWith("rgb("))||(null===(n=t.url)||void 0===n?void 0:n.startsWith("rgba("))?t.url:t.content?`data:${t.mimeType};base64,${t.content}`:void 0})(),T=e=>{switch(e.mimeType){case"image/jpeg":case"image/png":case"image/jpg":case"image/gif":return S?(0,a.jsxs)("picture",{className:"memori-media-item--figure",children:[(0,a.jsx)("div",{className:"memori-media-item--rgb-item",style:{backgroundColor:e.url}}),e.title&&(0,a.jsx)("figcaption",{className:"memori-media-item--figure-caption",children:e.title})]}):(0,a.jsxs)("picture",{className:"memori-media-item--figure",children:[!r&&A&&(0,a.jsx)("source",{srcSet:A,type:e.mimeType}),(0,a.jsx)("img",{alt:e.title,src:v||!A?"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjAwIiBoZWlnaHQ9IjIwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cmVjdCB3aWR0aD0iMjAwIiBoZWlnaHQ9IjIwMCIgZmlsbD0iI2YwZjBmMCIvPjx0ZXh0IHg9IjUwJSIgeT0iNTAlIiBmb250LWZhbWlseT0iQXJpYWwsIHNhbnMtc2VyaWYiIGZvbnQtc2l6ZT0iMTQiIGZpbGw9IiM5OTk5OTkiIHRleHQtYW5jaG9yPSJtaWRkbGUiIGR5PSIuM2VtIj5JbWFnZSBub3QgYXZhaWxhYmxlPC90ZXh0Pjwvc3ZnPg==":A,onError:()=>y(!0)}),e.title&&(0,a.jsx)("figcaption",{className:"memori-media-item--figure-caption",children:e.title})]});case"application/msword":case"application/vnd.openxmlformats-officedocument.wordprocessingml.document":return(0,a.jsx)(QI,{className:"memori-media-item--icon"});case"application/vnd.ms-excel":case"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":return(0,a.jsx)(KI,{className:"memori-media-item--icon"});case"application/pdf":return(0,a.jsx)(XI,{className:"memori-media-item--icon"});case"video/mp4":case"video/quicktime":case"video/avi":case"video/mpeg":return(0,a.jsxs)("video",{style:{width:"100%",height:"100%"},controls:!0,src:_,title:e.title,children:["video/quicktime"===e.mimeType&&(0,a.jsx)("source",{src:e.url,type:"video/mp4"}),(0,a.jsx)("source",{src:e.url,type:e.mimeType}),"Your browser does not support this video format.",(0,a.jsx)("br",{}),(0,a.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,a.jsx)("audio",{style:{width:"100%",height:"100%"},controls:!0,src:_});case"model/gltf-binary":return(0,a.jsx)(JI,{src:_,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,a.jsx)(ZI,{className:"memori-media-item--icon"})}};if(x&&t.content||w)return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("a",{className:"memori-media-item--link",href:"#",onClick:e=>{e.preventDefault(),m(!0)},title:t.title,children:(0,a.jsx)(VI,{hoverable:!0,cover:T(t),title:t.title})}),(0,a.jsx)(CA,{open:p,onClose:()=>m(!1),title:t.title,className:"memori-media-item-preview--modal",width:"80%",widthMd:"90%",children:(0,a.jsx)("div",{className:"memori-media-item-preview--content",children:(0,a.jsx)(zI,{medium:t,showCopyButton:!0})})})]});if(!t.url&&"document"===(null==t?void 0:t.type)&&t.content&&!["image/jpeg","image/png","image/jpg","image/gif"].includes(t.mimeType))return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("a",{className:"memori-media-item--link",href:"#",onClick:e=>{e.preventDefault(),m(!0)},title:t.title,children:(0,a.jsx)(VI,{hoverable:!0,cover:T(t),title:t.title})}),(0,a.jsx)(CA,{open:p,onClose:()=>m(!1),title:t.title,className:"memori-media-item-preview--modal",width:"60%",widthMd:"70%",footer:(0,a.jsx)("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem"},children:(0,a.jsx)(Jl,{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,a.jsx)(AI,{}),children:f?"Copied!":"Copy Content"})}),children:(0,a.jsx)("div",{className:"memori-media-item-preview--content",children:(0,a.jsx)("div",{className:"memori-media-item-preview--text",dangerouslySetInnerHTML:{__html:FE(t.content||"")}})})})]});switch(t.mimeType){case"image/jpeg":case"image/png":case"image/jpg":case"image/gif":return S?(0,a.jsx)(VI,{hoverable:!0,className:"memori-media-item--card memori-media-item--image",cover:T(t)}):(0,a.jsx)("a",{className:"memori-media-item--link",href:A||"#",onClick:n=>{e&&n.preventDefault(),l&&(n.preventDefault(),l(t.mediumID)),A&&!v||n.preventDefault()},target:"_blank",rel:"noopener noreferrer",title:t.title,children:(0,a.jsx)(VI,{hoverable:!0,className:"memori-media-item--card memori-media-item--image",cover:T(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,a.jsx)("a",{className:"memori-media-item--link",href:_,target:"_blank",rel:"noopener noreferrer",title:t.title,children:(0,a.jsx)(VI,{hoverable:!0,cover:T(t),title:t.title})});case"video/mp4":case"video/quicktime":case"video/avi":case"video/mpeg":return(0,a.jsx)("a",{className:"memori-media-item--link",href:_,onClick:n=>{e&&n.preventDefault(),l&&(n.preventDefault(),l(t.mediumID))},target:"_blank",rel:"noopener noreferrer",title:t.title,children:(0,a.jsx)(VI,{hoverable:!0,cover:T(t),title:t.title})});case"model/gltf-binary":return(0,a.jsx)(VI,{hoverable:!0,cover:T(t)})}},tM=({item:e,sessionID:t,tenantID:n,baseURL:i,apiURL:r,onClick:o})=>{var s,l;const c=(u=e.content)?u.split(/\r\n|\r|\n/).length:0;var u;const d=null!==(l=null===(s=e.content)||void 0===s?void 0:s.length)&&void 0!==l?l:0;return c<=5&&d<=200?(0,a.jsx)("div",{className:"memori-media-item--snippet-direct",children:(0,a.jsx)(VI,{className:"memori-media-item--card memori-media-item--snippet",children:(0,a.jsx)("div",{className:"memori-media-item--snippet-preview",children:(0,a.jsx)(zI,{showCopyButton:!0,preview:!1,medium:e})})})}):(0,a.jsx)(a.Fragment,{children:(0,a.jsx)("a",{href:"#",onClick:t=>{t.preventDefault(),o&&o(e.mediumID)},className:"memori-media-item--link",title:e.title,children:(0,a.jsx)(VI,{hoverable:!0,className:"memori-media-item--card memori-media-item--snippet",children:(0,a.jsx)("div",{className:"memori-media-item--snippet-preview",children:(0,a.jsx)(zI,{showCopyButton:!1,preview:!0,medium:e})})})})})};var nM=(0,c.memo)((({items:e,sessionID:n,tenantID:i,translateTo:r,baseURL:o,apiURL:s,customMediaRenderer:l,fromUser:u=!1})=>{const[d,h]=(0,c.useState)(e),[p,m]=(0,c.useState)();(0,c.useEffect)((()=>{h(e)}),[e]);const f=(0,c.useCallback)((async()=>{if(!r)return;const t=await Promise.all((null!=e?e:[]).map((async e=>{var t;if(!e.title)return e;try{const n=await YI(e.title,r);return{...e,title:null!==(t=n.text)&&void 0!==t?t:e.title}}catch(t){return console.error(t),e}})));h(t)}),[r,e]);(0,c.useEffect)((()=>{r&&f()}),[r,f]);const g=d.filter((e=>{var t;return!(null===(t=e.properties)||void 0===t?void 0:t.executable)&&!NI.prismSyntaxLangs.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)&&NI.prismSyntaxLangs.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,a.jsxs)(Os,{appear:!0,show:!0,as:"div",className:"memori-media-items",children:[!!g.length&&(0,a.jsx)("div",{className:t(We)("memori-media-items--grid memori-chat-scroll-item",{"memori-media-items--user":u,"memori-media-items--agent":!u}),children:g.map(((e,t)=>(0,a.jsx)(Os.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,a.jsx)(eM,{isChild:!0,sessionID:n,tenantID:i,baseURL:o,apiURL:s,onClick:e=>{m(g.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.length&&(0,a.jsx)("div",{className:t(We)("memori-media-items--grid memori-chat-scroll-item",{"memori-media-items--user":u,"memori-media-items--agent":!u}),children:v.map(((e,t)=>(0,a.jsx)(Os.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,a.jsx)(tM,{sessionID:n,tenantID:i,baseURL:o,apiURL:s,onClick:e=>{const t=v.find((t=>t.mediumID===e));m(t)},item:{...e,title:e.title,url:e.url,content:e.content,type:"document"}})},e.mediumID+"&index="+t)))}),y.map((e=>(0,a.jsx)("style",{dangerouslySetInnerHTML:{__html:e.content||""}},e.mediumID))),p&&(0,a.jsx)(CA,{width:"100%",widthMd:"100%",className:"memori-media-item--modal",open:!!p,onClose:()=>m(void 0),footer:null,children:NI.prismSyntaxLangs.map((e=>e.mimeType)).includes(p.mimeType)?(0,a.jsx)("div",{style:{minHeight:"100%",background:"none"},className:"memori-media-item-preview--content",children:(0,a.jsx)(zI,{preview:!1,medium:p})}):(0,a.jsx)(eM,{isChild:!0,sessionID:n,tenantID:i,baseURL:o,apiURL:s,item:{...p,title:p.title,url:p.url,content:p.content,type:"document"},customMediaRenderer:l})})]})}));var iM=(0,c.memo)((({hints:e=[],links:n=[],media:i=[],simulateUserPrompt:r=(()=>{}),sessionID:o,baseUrl:s,apiUrl:l,translateTo:u,customMediaRenderer:d,fromUser:h=!1})=>{const{t:p}=Ve(),[m,f]=(0,c.useState)(!0),[g,v]=(0,c.useState)(6);return(0,c.useEffect)((()=>{f(!0)}),[e]),(0,a.jsxs)("div",{className:"memori-media-widget",children:[(null==i?void 0:i.length)>0&&(0,a.jsx)(nM,{items:i,sessionID:o,translateTo:u,baseURL:s,apiURL:l,customMediaRenderer:d,fromUser:h}),(null==n?void 0:n.length)>0&&(0,a.jsx)(qI,{items:n,baseUrl:s,fromUser:h}),(null==e?void 0:e.length)>0&&m&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(Os,{appear:!0,show:!0,as:"ul",className:"memori-media--hints",children:e.slice(0,g).map(((e,n)=>(0,a.jsx)(Os.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,a.jsx)(Jl,{className:t(We)("memori-media--hint"),primary:!0,onClick:()=>{r(e.originalText,e.text),f(!1)},onTouchEnd:()=>{r(e.originalText,e.text),f(!1)},children:e.text},e.text+n)},e.text+n)))}),e.length>g&&(0,a.jsx)("div",{className:"memori-hints--show-more",children:(0,a.jsx)(Jl,{className:"memori-hints--show-more-button",id:"showMoreHints",onClick:()=>v(g+6),children:p("expand")||"Expand"})})]})]})}));const rM=e=>e.endsWith("?")?e:`${e}?`;var oM=({message:e,sessionID:n,visible:i=!0,initialMatches:r=[],closeDrawer:o,client:s,_TEST_loading:l=!1})=>{const{t:u}=Ve(),d=null==s?void 0:s.search.searchMemory,[h,p]=(0,c.useState)(r),[m,f]=(0,c.useState)(l),g=(0,c.useCallback)((async()=>{if(f(!0),!l&&d){try{const{matches:i,...r}=await d(n,{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!==r.resultCode?(console.error(r),t(So).error(u(UI(r.resultCode)))):p(null!=i?i:[])}catch(e){console.error("WHYTHISANSWER/FETCH",e),p(null!=r?r:[])}f(!1)}}),[e,n]);return(0,c.useEffect)((()=>{g()}),[g,e,n]),(0,a.jsxs)(Ql,{open:i,width:"80%",animated:!1,className:"memori-whythisanswer-drawer",onClose:()=>o(),title:u("whyThisAnswer"),children:[(0,a.jsx)("p",{children:u("whyThisAnswerHelper")}),e.questionAnswered&&(0,a.jsxs)("p",{className:"memori--whythisanswer-question-answered",children:[(0,a.jsxs)("strong",{children:[u("question")||"Question",":"]})," ",e.questionAnswered]}),(0,a.jsxs)(Yl,{primary:!0,spinning:m,children:[!m&&0===h.length&&(0,a.jsx)("p",{role:"info",className:"memori--whythisanswer-no-results",children:u("nothingFound")}),m&&0===h.length&&(0,a.jsxs)("ul",{className:"memori--whythisanswer-list memori--whythisanswer-skeleton",children:[(0,a.jsxs)("li",{children:[(0,a.jsxs)("div",{className:"memori--whythisanswer-title",children:[(0,a.jsx)("span",{className:"memori--whythisanswer-confidence",children:(0,a.jsx)("span",{className:"memori--whythisanswer-skeleton-text"})}),(0,a.jsx)("div",{className:"memori--whythisanswer-title-text",children:(0,a.jsx)("p",{className:"memori--whythisanswer-skeleton-text"})})]}),(0,a.jsxs)("p",{children:[(0,a.jsx)("div",{className:"memori--whythisanswer-skeleton-text"}),(0,a.jsx)("div",{className:"memori--whythisanswer-skeleton-text"}),(0,a.jsx)("div",{className:"memori--whythisanswer-skeleton-text"})]}),(0,a.jsx)("div",{className:"memori--whythisanswer-skeleton-block"})]}),(0,a.jsxs)("li",{children:[(0,a.jsxs)("div",{className:"memori--whythisanswer-title",children:[(0,a.jsx)("span",{className:"memori--whythisanswer-confidence",children:(0,a.jsx)("span",{className:"memori--whythisanswer-skeleton-text"})}),(0,a.jsxs)("div",{className:"memori--whythisanswer-title-text",children:[(0,a.jsx)("p",{className:"memori--whythisanswer-skeleton-text"}),(0,a.jsx)("p",{className:"memori--whythisanswer-skeleton-text"})]})]}),(0,a.jsxs)("p",{children:[(0,a.jsx)("div",{className:"memori--whythisanswer-skeleton-text"}),(0,a.jsx)("div",{className:"memori--whythisanswer-skeleton-text"})]}),(0,a.jsx)("div",{className:"memori--whythisanswer-skeleton-block"})]})]}),h.length>0&&(0,a.jsx)("ul",{className:"memori--whythisanswer-list",children:h.map((e=>{var t,n,i,r,o,s,l;return(0,a.jsxs)("li",{children:[(0,a.jsxs)("div",{className:"memori--whythisanswer-title",children:[(0,a.jsx)("span",{className:"memori--whythisanswer-confidence",children:e.confidenceLevel}),(0,a.jsxs)("div",{className:"memori--whythisanswer-title-text",children:[(0,a.jsx)("div",{className:"memori--whythisanswer-title-text-top-container",children:(0,a.jsx)("p",{children:(0,a.jsx)("strong",{children:rM(null!==(t=e.memory.title)&&void 0!==t?t:"")})})}),(0,a.jsx)("p",{children:null===(i=null===(n=e.memory.titleVariants)||void 0===n?void 0:n.map((e=>rM(e))))||void 0===i?void 0:i.join(" | ")}),(e.memory.receiverName||e.memory.receiverTag)&&(0,a.jsxs)("p",{className:"memori--whythisanswer-title-text-top",children:[u("receiverLabel"),": ",e.memory.receiverTag," ",e.memory.receiverName]})]})]}),e.memory.contextVars&&(0,a.jsx)("div",{className:"memori--whythisanswer-contextvars",children:Object.entries(e.memory.contextVars||{}).map((([e,t])=>(0,a.jsx)(VI,{className:"memori--whythisanswer-contextvars-card",children:(0,a.jsxs)("span",{children:[e,": ",(null==t?void 0:t.toString())||"✔️"]})},e)))}),null===(r=e.memory.answers)||void 0===r?void 0:r.map(((e,t)=>(0,a.jsx)("p",{className:"memori--whythisanswer-answer",children:(0,a.jsx)(BI,{mode:"rows",rows:3,children:e.text})},t))),(0,a.jsx)(iM,{links:null===(o=e.memory.media)||void 0===o?void 0:o.filter((e=>"text/html"===e.mimeType))}),null===(l=null===(s=e.memory.media)||void 0===s?void 0:s.filter((e=>"text/plain"===e.mimeType)))||void 0===l?void 0:l.map((e=>(0,a.jsx)(BI,{mode:"rows",rows:2,lineHeightMultiplier:2,innerClassName:"memori--whythisanswer-snippet-expandable",children:(0,a.jsx)(zI,{medium:e,showCopyButton:!1},e.mediumID)},e.mediumID)))]},e.memory.memoryID)}))})]})]})};var aM=({message:e,memori:n,tenant:i,baseUrl:r,apiUrl:o,client:s,sessionID:l,showFeedback:u,showWhyThisAnswer:d=!0,showCopyButton:h=!0,showTranslationOriginal:p=!1,simulateUserPrompt:m,showAIicon:f=!0,isFirst:g=!1,useMathFormatting:v=!1,user:y,userAvatar:_,experts:b,showFunctionCache:x=!1,showReasoning:w=!1})=>{var S,E,A,T,I,M,C,N,O,R,L,P,D,k;const{t:B,i18n:F}=Ve(),U=F.language||"en",[z,G]=(0,c.useState)(!1),[j,H]=(0,c.useState)(!1),[V,W]=(0,c.useState)({plain:!1,raw:!1}),q=(0,c.useRef)({plain:null,raw:null});(0,c.useEffect)((()=>{"undefined"==typeof window||window.MathJax||jE()}),[]);const $=(e.translatedText||e.text).replace(/<document_attachment filename="([^"]+)" type="([^"]+)">([\s\S]*?)<\/document_attachment>/g,""),{text:Y}=kI($,v,B("reasoning")||"Reasoning...",w),J=e.fromUser?DI($):FE(kE(Y)),Z=e.fromUser?$:J,X=h&&(!!(null==J?void 0:J.length)||!!(null===(S=e.text)||void 0===S?void 0:S.length)),K=X&&!!(null===(E=e.text)||void 0===E?void 0:E.length)&&J!==e.text,Q=e.fromUser?e.text||"":(e.text||"").replaceAll(/<think.*?>(.*?)<\/think>/gs,""),ee=B("copied")||"Copied",te=null===(A=e.media)||void 0===A?void 0:A.filter((e=>{var t;return"true"===(null===(t=e.properties)||void 0===t?void 0:t.functionCache)}));(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 i=e.scrollHeight-n;e.scrollTop=t+i}})).catch((e=>console.error("MathJax typesetting failed:",e)))}}catch(e){console.error("Error during MathJax typesetting:",e)}}),100);return()=>clearTimeout(e)}}),[$,e.fromUser,Y]),(0,c.useEffect)((()=>()=>{Object.keys(q.current).forEach((e=>{const t=q.current[e];t&&(clearTimeout(t),q.current[e]=null)}))}),[]);const ne=e=>{W((t=>({...t,[e]:!0}))),q.current[e]&&clearTimeout(q.current[e]),q.current[e]=setTimeout((()=>{W((t=>({...t,[e]:!1}))),q.current[e]=null}),1500)},ie=(e,t)=>{var n;(null==t?void 0:t.length)&&("undefined"!=typeof navigator&&(null===(n=navigator.clipboard)||void 0===n?void 0:n.writeText)?navigator.clipboard.writeText(t).then((()=>ne(e))).catch((e=>{console.error("Copy failed",e)})):ne(e))},re="string"==typeof e.initial?e.initial:null,oe=(!0===e.initial||g)&&!re,ae="system"===e.emitter;return re?(0,a.jsx)("div",{className:"memori-chat--bubble-status-message",children:(0,a.jsx)("div",{className:"memori-chat--bubble-status-message-content",children:re})}):ae?(0,a.jsxs)(Os,{show:!0,appear:!0,as:"div",className:t(We)("memori-chat--bubble-container memori-chat-scroll-item",{"memori-chat--bubble-from-user":!1}),children:[(0,a.jsx)(Os.Child,{as:"picture",className:"memori-chat--bubble-avatar",enter:"transition ease-in-out duration-300",enterFrom:"opacity-0 scale-075 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 translate-x--15",title:(null===(T=e.emitter)||void 0===T?void 0:T.length)&&n.enableBoardOfExperts?e.emitter:n.name,children:(0,a.jsx)("img",{className:"memori-chat--bubble-avatar-img",alt:(null===(I=e.emitter)||void 0===I?void 0:I.length)&&n.enableBoardOfExperts?e.emitter:n.name,src:(null===(M=e.emitter)||void 0===M?void 0:M.length)&&n.enableBoardOfExperts&&(null==b?void 0:b.find((t=>t.name===e.emitter)))?`${new URL(null!=o?o:"/").origin}/api/v1/memoriai/memori/avatar/${null===(C=b.find((t=>t.name===e.emitter)))||void 0===C?void 0:C.expertMemoriID}`:n.avatarURL&&n.avatarURL.length>0?KT({type:"avatar",tenantID:null==i?void 0:i.name,resourceURI:n.avatarURL,baseURL:r,apiURL:o}):KT({tenantID:null==i?void 0:i.name,type:"avatar",baseURL:r||"https://www.aisuru.com",apiURL:o}),onError:e=>{e.currentTarget.src=n.avatarURL&&n.avatarURL.length>0?KT({type:"avatar",tenantID:null==i?void 0:i.name,resourceURI:n.avatarURL,baseURL:r}):KT({tenantID:null==i?void 0:i.name,type:"avatar",baseURL:r}),e.currentTarget.onerror=null}})}),(0,a.jsx)("div",{className:"memori-chat--bubble memori-chat--bubble-status-message-error",children:(0,a.jsx)("div",{className:"memori-chat--bubble-message ",children:$})})]}):(0,a.jsxs)(a.Fragment,{children:[oe&&(0,a.jsx)("div",{className:"memori-chat--bubble-initial"}),(0,a.jsxs)(Os,{show:!0,appear:!0,as:"div",className:t(We)("memori-chat--bubble-container memori-chat-scroll-item",{"memori-chat--bubble-from-user":!!e.fromUser,"memori-chat--with-addon":e.generatedByAI&&f||u&&m}),children:[!e.fromUser&&(0,a.jsx)(Os.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===(N=e.emitter)||void 0===N?void 0:N.length)&&n.enableBoardOfExperts?e.emitter:n.name,children:(0,a.jsx)("img",{className:"memori-chat--bubble-avatar-img",alt:(null===(O=e.emitter)||void 0===O?void 0:O.length)&&n.enableBoardOfExperts?e.emitter:n.name,src:(null===(R=e.emitter)||void 0===R?void 0:R.length)&&n.enableBoardOfExperts&&(null==b?void 0:b.find((t=>t.name===e.emitter)))?`${new URL(null!=o?o:"/").origin}/api/v1/memoriai/memori/avatar/${null===(L=b.find((t=>t.name===e.emitter)))||void 0===L?void 0:L.expertMemoriID}`:n.avatarURL&&n.avatarURL.length>0?KT({type:"avatar",tenantID:null==i?void 0:i.name,resourceURI:n.avatarURL,baseURL:r,apiURL:o}):KT({tenantID:null==i?void 0:i.name,type:"avatar",baseURL:r||"https://www.aisuru.com",apiURL:o}),onError:e=>{e.currentTarget.src=n.avatarURL&&n.avatarURL.length>0?KT({type:"avatar",tenantID:null==i?void 0:i.name,resourceURI:n.avatarURL,baseURL:r}):KT({tenantID:null==i?void 0:i.name,type:"avatar",baseURL:r}),e.currentTarget.onerror=null}})}),(0,a.jsxs)(Os.Child,{as:"div",className:t(We)("memori-chat--bubble",{"memori-chat--user-bubble":!!e.fromUser,"memori-chat--with-addon":X||e.generatedByAI&&f||u&&m,"memori-chat--ai-generated":e.generatedByAI&&f,"memori-chat--with-feedback":u}),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,a.jsx)(BI,{className:"memori-chat--bubble-content",mode:"characters",children:(0,a.jsx)("div",{dir:"auto",className:"memori-chat--bubble-content",dangerouslySetInnerHTML:{__html:Y}})}):(0,a.jsx)("div",{dir:"auto",className:"memori-chat--bubble-content",dangerouslySetInnerHTML:{__html:Y}}),(X||e.generatedByAI&&f||e.generatedByAI&&x||u&&m)&&(0,a.jsxs)("div",{className:"memori-chat--bubble-addon",children:[X&&(0,a.jsx)(Jl,{ghost:!0,shape:"circle",title:V.plain?ee:B("copy")||"Copy",className:t(We)("memori-chat--bubble-action-icon",{"memori-chat--bubble-action-icon--from-user":e.fromUser,"memori-chat--bubble-action-icon--copied":V.plain}),icon:(0,a.jsx)(AI,{"aria-label":V.plain?ee:B("copy")||"Copy"}),onClick:()=>ie("plain",Z)}),V.plain&&(0,a.jsx)("span",{role:"status","aria-live":"polite",className:t(We)("memori-chat--bubble-action-feedback",{"memori-chat--bubble-action-feedback--from-user":e.fromUser}),children:ee}),K&&(0,a.jsx)(Jl,{ghost:!0,shape:"circle",title:V.raw?ee:B("copyRawCode")||"Copy raw code",className:t(We)("memori-chat--bubble-action-icon",{"memori-chat--bubble-action-icon--from-user":e.fromUser,"memori-chat--bubble-action-icon--copied":V.raw}),icon:(0,a.jsx)(TI,{"aria-label":V.raw?ee:B("copyRawCode")||"Copy raw code"}),onClick:()=>ie("raw",Q)}),V.raw&&(0,a.jsx)("span",{role:"status","aria-live":"polite",className:t(We)("memori-chat--bubble-action-feedback",{"memori-chat--bubble-action-feedback--from-user":e.fromUser}),children:ee}),!e.fromUser&&x&&(null===(P=e.media)||void 0===P?void 0:P.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,a.jsx)(Jl,{ghost:!0,shape:"circle",title:"Debug",className:"memori-chat--bubble-action-icon memori-chat--bubble-action-icon--debug",icon:(0,a.jsx)(II,{"aria-label":"Debug"}),onClick:()=>H(!0)}),u&&!!m&&(0,a.jsx)(SI,{memori:n,className:"memori-chat--bubble-feedback",dropdown:!0,onNegativeClick:e=>{e&&m(e)}}),e.generatedByAI&&f&&(0,a.jsx)(nI,{align:"right",content:B("generatedByAI")||("it"===U?"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,a.jsx)("span",{children:(0,a.jsx)(eI,{title:B("generatedByAI")||("it"===U?"Risposta generata da IA, può talvolta generare informazioni non corrette":"Answer generated by AI, may occasionally generate incorrect informations")})})}),p&&e.translatedText&&e.translatedText!==e.text&&(0,a.jsx)(nI,{align:"right",content:`${"it"===U?"Testo originale":"Original text"}: ${e.text}`,className:"memori-chat--bubble-action-icon memori-chat--bubble-action-icon--ai",children:(0,a.jsx)("span",{children:(0,a.jsx)(tI,{"aria-label":"it"===U?"Testo originale":"Original text"})})}),!e.fromUser&&e.questionAnswered&&o&&d&&(0,a.jsx)(Jl,{ghost:!0,shape:"circle",title:B("whyThisAnswer")||void 0,className:"memori-chat--bubble-action-icon",onClick:()=>G(!0),disabled:z,icon:(0,a.jsx)(EI,{title:B("whyThisAnswer")||void 0})})]})]}),e.fromUser&&(0,a.jsx)(a.Fragment,{children:_&&"string"==typeof _||!_&&(null===(D=null==y?void 0:y.avatarURL)||void 0===D?void 0:D.length)?(0,a.jsx)(Os.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,a.jsx)("img",{className:"memori-chat--bubble-avatar-img",alt:null!==(k=null==y?void 0:y.userName)&&void 0!==k?k:"User",src:null!=_?_:null==y?void 0:y.avatarURL})}):_?(0,a.jsx)(Os.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,a.jsx)(Os.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,a.jsx)(QT,{})})})]}),z&&s&&(0,a.jsx)(oM,{client:s,visible:z,message:e,closeDrawer:()=>G(!1),sessionID:l}),(0,a.jsx)(CA,{open:j,onClose:()=>H(!1),className:"memori-chat--function-cache-modal",children:null==te?void 0:te.map(((e,t)=>(0,a.jsxs)("div",{style:t>0?{marginTop:"1.5rem",paddingTop:"1.5rem",borderTop:"1px solid #e0e0e0"}:{paddingTop:"1.5rem"},children:[(0,a.jsx)("h3",{style:{marginTop:0},children:e.title}),(0,a.jsx)("pre",{style:{whiteSpace:"pre-wrap",wordWrap:"break-word"},children:e.content},e.mediumID)]},e.mediumID)))})]})};c=o("85Hg2"),c=o("85Hg2");var sM=({disabled:e=!1,value:n,onChange:i,onPressEnter:r,onFocus:o,onBlur:s,onExpandedChange:l})=>{const{t:u}=Ve(),d=(0,c.useRef)(null),h=(0,c.useRef)(null);return(0,c.useEffect)((()=>{const e=d.current,t=h.current;if(e&&t)if(0===n.length){e.style.height="36px",t.style.height="36px",l&&l(!1);const n=document.getElementsByClassName("memori-chat--content");if(n){const e=n[n.length-1];e&&(e.style.paddingBottom="0px")}}else{e.style.height="auto";const n=e.scrollHeight,i=Math.min(Math.max(n,36),208);e.style.height=`${i}px`,t.style.height=`${i}px`;const r=document.getElementsByClassName("memori-chat--content");if(r){r[r.length-1]&&r[0].scrollTo({top:r[0].scrollHeight,behavior:"smooth"})}}}),[n]),(0,a.jsx)("div",{"data-testid":"chat-textarea",className:t(We)("memori-chat-textarea",{"memori-chat-textarea--disabled":e}),children:(0,a.jsx)("div",{ref:h,className:"memori-chat-textarea--inner",children:(0,a.jsx)("textarea",{ref:d,className:"memori-chat-textarea--input",disabled:e,value:n,placeholder:u("placeholder","Ask a question")||"Ask a question",onChange:e=>{i(e.target.value)},onKeyDownCapture:e=>{const t=IE();"Enter"!==e.key||e.shiftKey||!r||t||r(e)},onFocus:o,onBlur:s,maxLength:1e5})})})};var lM=({className:e,title:t})=>(0,a.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,a.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 cM=({className:e,title:t})=>(0,a.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,a.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 uM=({listening:e,stopAudio:n,startListening:i,stopListening:r})=>{const{t:o}=Ve(),[s,l]=(0,c.useState)(),u=(0,c.useRef)(null),d=e=>{e.preventDefault(),e.stopPropagation(),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"),i()}),300))},h=e=>{e&&(e.preventDefault(),e.stopPropagation()),u.current&&(clearTimeout(u.current),u.current=null),r(),l(void 0)};return(0,c.useEffect)((()=>()=>h()),[]),(0,a.jsx)(nI,{visible:!!s,content:(0,a.jsx)("span",{children:s||o("write_and_speak.pressAndHoldToSpeak")||"Press and hold to speak"}),align:"topLeft",className:"memori-mic-btn-tooltip",children:(0,a.jsx)("div",{onContextMenu:e=>{e.preventDefault(),e.stopPropagation()},children:(0,a.jsx)(Jl,{primary:!0,className:t(We)("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:e=>{e.preventDefault(),e.stopPropagation(),d(e)},onMouseUp:h,onTouchEnd:e=>{e.preventDefault(),e.stopPropagation(),h(e)},onMouseLeave:h,shape:"circle",icon:(0,a.jsx)(cM,{})})})})};c=o("85Hg2");const dM=({className:e})=>(0,a.jsxs)("svg",{className:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,a.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,a.jsx)("path",{d:"M17 8L12 3L7 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),(0,a.jsx)("path",{d:"M12 3V15",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]});c=o("85Hg2");var hM=({open:e=!1,onClose:n,className:i,title:r,description:o,children:s,type:l="info",icon:u,closable:d=!0,duration:h=null,action:p,width:m="400px"})=>{const{t:f}=Ve();t(c).useEffect((()=>{if(h&&e){const e=setTimeout((()=>{n(!1)}),h);return()=>clearTimeout(e)}}),[h,e,n]);return(0,a.jsx)(Os,{show:e,as:t(c).Fragment,appear:!0,children:(0,a.jsxs)("div",{className:t(We)("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),i),children:[(0,a.jsx)("style",{dangerouslySetInnerHTML:{__html:`\n .memori-alert {\n --memori-alert--width: ${m};\n }\n `}}),(0,a.jsx)(Os.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,a.jsxs)("div",{className:"memori-alert--container",children:[u&&(0,a.jsx)("div",{className:"memori-alert--icon",children:u}),(0,a.jsxs)("div",{className:"memori-alert--content",children:[r&&(0,a.jsx)("div",{className:"memori-alert--title",children:r}),o&&(0,a.jsx)("div",{className:"memori-alert--description",children:o}),s]}),(0,a.jsxs)("div",{className:"memori-alert--actions",children:[p&&(0,a.jsx)("div",{className:"memori-alert--action",children:p}),d&&(0,a.jsx)(Jl,{ghost:!0,padded:!0,shape:"circle",icon:(0,a.jsx)(Zl,{}),title:f("close")||"Close",onClick:()=>n(!1),className:"memori-alert--close"})]})]})})]})})};c=o("85Hg2");const pM=({className:e})=>(0,a.jsxs)("svg",{className:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,a.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,a.jsx)("path",{d:"M14 2.5V8H19.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),(0,a.jsx)("path",{d:"M16 13H8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),(0,a.jsx)("path",{d:"M16 17H8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),(0,a.jsx)("path",{d:"M10 9H8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]});NI=o("1Lq0j");const mM="3.11.174",fM=`https://cdnjs.cloudflare.com/ajax/libs/pdf.js/${mM}/pdf.worker.min.js`,gM=`https://cdnjs.cloudflare.com/ajax/libs/pdf.js/${mM}/pdf.min.js`;var vM=({setDocumentPreviewFiles:e,maxDocuments:n,documentPreviewFiles:i,onLoadingChange:r,onDocumentError:o,onValidateFile:s,onValidatePayloadSize:l})=>{const[u,d]=(0,c.useState)(!1),[h,p]=(0,c.useState)(null),m=(0,c.useRef)(null);(0,c.useEffect)((()=>{r&&r(u)}),[u,r]);const f=e=>!s||s(e),g=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=gM,n.onload=()=>{window.pdfjsLib.GlobalWorkerOptions.workerSrc=fM,e(!0)},n.onerror=t,document.head.appendChild(n)}));const t=await e.arrayBuffer(),n=await window.pdfjsLib.getDocument({data:t}).promise;let i="";for(let e=1;e<=n.numPages;e++){const t=await n.getPage(e);i+=(await t.getTextContent()).items.filter((e=>e.str&&"string"==typeof e.str)).map((e=>e.str)).join(" ")+"\n"}return i}catch(e){throw console.error("PDF extraction failed:",e),new Error(`PDF extraction failed: ${e instanceof Error?e.message:"Unknown error"}`)}})(e):["txt","md","json","csv","html"].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 i="";for(const e of n.SheetNames){const t=n.Sheets[e],r=window.XLSX.utils.sheet_to_json(t,{header:1,raw:!1}),o=r.reduce(((e,t)=>(t.forEach(((t,n)=>{const i=(t||"").toString().length;e[n]=Math.max(e[n]||0,i)})),e)),[]),a=r.map((e=>e.map(((e,t)=>(e||"").toString().padEnd(o[t]+2))).join("|").trim()));if(a.length>0){const e=o.map((e=>"-".repeat(e+2))).join("+");a.splice(1,0,e)}i+=`Sheet: ${e}\n${a.join("\n")}\n\n`}return i}catch(e){throw console.error("XLSX extraction failed:",e),new Error(`XLSX extraction failed: ${e instanceof Error?e.message:"Unknown error"}`)}})(e)),t&&t.length>NI.MAX_DOCUMENT_CONTENT_LENGTH&&(console.warn("Document content exceeds length limit:",t.length,">",NI.MAX_DOCUMENT_CONTENT_LENGTH),null==o||o({message:`File "${e.name}" content exceeds ${NI.MAX_DOCUMENT_CONTENT_LENGTH} characters and was truncated`,severity:"warning"}),t=t.substring(0,NI.MAX_DOCUMENT_CONTENT_LENGTH)+"\n\n[Content truncated due to size limits]"),t}catch(t){throw console.error("Document processing failed:",t),new Error(`Failed to process "${e.name}": ${t instanceof Error?t.message:"Unknown error"}`)}};return(0,a.jsxs)("div",{className:"memori--document-upload-wrapper",children:[(0,a.jsx)("input",{ref:m,type:"file",accept:".pdf,.txt,.md,.json,.xlsx,.csv,.html",multiple:!0,className:"memori--upload-file-input",onChange:async t=>{const r=Array.from(t.target.files||[]);if(0===r.length)return;const a=i.length;if(n&&a+r.length>n)return null==o||o({message:`Maximum ${n} media files allowed. You can upload ${Math.max(0,n-a)} more file${n-a!=1?"s":""}.`,severity:"error"}),void(m.current&&(m.current.value=""));d(!0);const s=[];for(const e of r){if(!f(e))continue;const t=Math.random().toString(36).substr(2,9);try{const n=await g(e);n&&s.push({name:e.name,id:t,content:n,mimeType:e.type})}catch(e){console.error("File processing error:",e),null==o||o({message:`${e instanceof Error?e.message:"Unknown error"}`,severity:"error"})}}if(s.length>0){if(c=s,l&&!l(c))return d(!1),void(m.current&&(m.current.value=""));const t=i.filter((e=>"document"===e.type));i.filter((e=>"image"===e.type));e([...t,...s.map((e=>({...e,type:"document"})))])}var c;d(!1),m.current&&(m.current.value="")}}),(0,a.jsx)("button",{className:t(We)("memori-button","memori-button--circle","memori-button--icon-only","memori-share-button--button","memori--conversation-button","memori--document-upload-button",{"memori--error":!1}),onClick:()=>{var e;return null===(e=m.current)||void 0===e?void 0:e.click()},disabled:u||n&&i.length>=n||!1,title:"Upload documents",children:u?(0,a.jsx)(Yl,{spinning:!0,className:"memori--upload-icon"}):(0,a.jsx)(t(c).Fragment,{children:(0,a.jsx)(pM,{className:"memori--upload-icon"})})}),(0,a.jsx)(CA,{width:"80%",widthMd:"80%",open:!!h,className:"memori--modal-preview-file",onClose:()=>p(null),closable:!0,title:null==h?void 0:h.name,children:(0,a.jsx)("div",{className:"memori--preview-content",style:{maxHeight:"70vh",overflowY:"auto",textAlign:"center",whiteSpace:"pre-wrap"},children:null==h?void 0:h.content})})]})};c=o("85Hg2");const yM=({className:e})=>(0,a.jsxs)("svg",{className:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,a.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),(0,a.jsx)("circle",{cx:"8.5",cy:"8.5",r:"1.5",fill:"currentColor"}),(0,a.jsx)("path",{d:"M21 15L16 10L5 21",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),_M={maxWidth:1920,maxHeight:1920,quality:.75,maxSizeMB:2},bM=e=>new Promise(((t,n)=>{const i=new Image,r=URL.createObjectURL(e);i.onload=()=>{URL.revokeObjectURL(r),t(i)},i.onerror=()=>{URL.revokeObjectURL(r),n(new Error("Failed to load image"))},i.src=r})),xM=async(e,t={})=>{const n={..._M,...t};if(!(e.size/1048576>1))try{const t=await bM(e);if(!(t.width>n.maxWidth||t.height>n.maxHeight))return e}catch(t){return e}try{const t=await bM(e),i=1,{width:r,height:o}=((e,t,n,i)=>{if(e<=n&&t<=i)return{width:e,height:t};const r=n/e,o=i/t,a=Math.min(r,o,1);return{width:Math.round(e*a),height:Math.round(t*a)}})(t.width,t.height,n.maxWidth,n.maxHeight),a=document.createElement("canvas");a.width=r,a.height=o;const s=a.getContext("2d");if(!s)throw new Error("Failed to get canvas context");return((e,t,n,i)=>{switch(t){case 2:e.transform(-1,0,0,1,n,0);break;case 3:e.transform(-1,0,0,-1,n,i);break;case 4:e.transform(1,0,0,-1,0,i);break;case 5:e.transform(0,1,1,0,0,0);break;case 6:e.transform(0,1,-1,0,i,0);break;case 7:e.transform(0,-1,-1,0,i,n);break;case 8:e.transform(0,-1,1,0,0,n)}})(s,i,r,o),s.drawImage(t,0,0,r,o),new Promise(((t,i)=>{a.toBlob((r=>{if(!r)return void i(new Error("Failed to compress image"));if(r.size/1048576>n.maxSizeMB)a.toBlob((n=>{if(!n){const n=new File([r],e.name.replace(/\.[^/.]+$/,".jpg"),{type:"image/jpeg"});return void t(n)}const i=new File([n],e.name.replace(/\.[^/.]+$/,".jpg"),{type:"image/jpeg"});t(i)}),"image/jpeg",Math.max(.5,n.quality-.2));else{const n=new File([r],e.name.replace(/\.[^/.]+$/,".jpg"),{type:"image/jpeg"});t(n)}}),"image/jpeg",n.quality)}))}catch(t){return e}};var wM=({authToken:e="",sessionID:n="",client:i,isMediaAccepted:r=!1,setDocumentPreviewFiles:o,documentPreviewFiles:s,onLoadingChange:l,maxImages:u=5,memoriID:d="",onImageError:h,onValidateImageFile:p})=>{var m,f,g;const{t:v,i18n:y}=Ve(),{backend:_,dialog:b}=i||{backend:{uploadAsset:null,uploadAssetUnlogged:null},dialog:{postMediumSelectedEvent:null,postMediumDeselectedEvent:null}},[x,w]=(0,c.useState)(!1),[S,E]=(0,c.useState)(null),[A,T]=(0,c.useState)(null),[I,M]=(0,c.useState)(""),[C,N]=(0,c.useState)(!1),O=(0,c.useRef)(null);(0,c.useEffect)((()=>{l&&l(x)}),[x,l]);const R=s.length,L=async t=>{var r;w(!0);try{const r=t.map((async t=>{let r=t;try{r=await xM(t)}catch(e){console.warn("Image compression failed, using original file",e),r=t}return new Promise((t=>{const o=new FileReader;o.onload=async o=>{var a,l,c,u,p;const m=null===(a=o.target)||void 0===a?void 0:a.result,f=Math.random().toString(36).substr(2,9),g=r.name.split(".").slice(0,-1).join(".");if(i)try{let i,o;if(e&&(null==_?void 0:_.uploadAsset))o=await _.uploadAsset(r.name,m,e);else{if(!(d&&n&&(null==_?void 0:_.uploadAssetUnlogged)))throw new Error("Missing required parameters for upload");if(o=await _.uploadAssetUnlogged(r.name,m,d,n),!o)throw new Error("Upload failed")}if(i=o.asset,0!==o.resultCode)throw new Error(o.resultMessage||"Upload failed");let a,u=null;if((null==b?void 0:b.postMediumSelectedEvent)&&n&&(u=await b.postMediumSelectedEvent(n,{url:i.assetURL,mimeType:i.mimeType})),null===(l=null==u?void 0:u.currentState)||void 0===l?void 0:l.currentMedia){const e=new Set(s.map((e=>e.mediumID)));a=null===(c=u.currentState.currentMedia.find((t=>!e.has(t.mediumID))))||void 0===c?void 0:c.mediumID}t({name:g,id:f,url:i.assetURL,content:i.assetURL,type:"image",mediumID:a,mimeType:i.mimeType})}catch(e){null==h||h({message:null!==(u=v("upload.uploadFailed"))&&void 0!==u?u:"Upload failed",severity:"error"}),t(null)}else null==h||h({message:null!==(p=v("upload.apiClientNotConfigured"))&&void 0!==p?p:"API client not configured properly for media upload",severity:"warning"}),t(null)},o.onerror=()=>{var e;null==h||h({message:null!==(e=v("upload.fileReadingFailed"))&&void 0!==e?e:"File reading failed",severity:"error"}),t(null)},o.readAsDataURL(r)}))})),a=(await Promise.all(r)).filter((e=>null!==e));a.length>0&&o((e=>[...e,...a]))}catch(e){null==h||h({message:null!==(r=v("upload.uploadFailed"))&&void 0!==r?r:"Upload failed",severity:"error"})}finally{w(!1)}},P=()=>{N(!1),E(null),T(null),M("")};return(0,a.jsxs)("div",{className:"memori--image-upload-wrapper",children:[(0,a.jsx)("input",{ref:O,type:"file",accept:".jpg,.jpeg,.png",multiple:!0,className:"memori--upload-file-input",onChange:async e=>{const t=Array.from(e.target.files||[]);if(0===t.length)return;if(R+t.length>u)return void(null==h||h({message:`Maximum ${u} media files allowed. You can upload ${Math.max(0,u-R)} more file${u-R!=1?"s":""}.`,severity:"error"}));const n=t.filter((e=>!!(e=>!p||p(e))(e)));if(0!==n.length){if(1===n.length){const e=n[0];E(e),T(URL.createObjectURL(e));const t=e.name.split(".").slice(0,-1).join(".");M(t),N(!0)}else await L(n);O.current&&(O.current.value="")}else O.current&&(O.current.value="")},disabled:x||!r||R>=u}),(0,a.jsx)("button",{className:t(We)("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=O.current)||void 0===e?void 0:e.click()},disabled:x||!r||R>=u,children:x?(0,a.jsx)(Yl,{spinning:!0,className:"memori--upload-icon"}):(0,a.jsx)(yM,{className:"memori--upload-icon"})}),(0,a.jsx)(CA,{width:"80%",widthMd:"80%",open:C&&!!S,className:"memori--modal-preview-file",onClose:P,closable:!0,children:(0,a.jsxs)("div",{className:"memori--preview-content",style:{maxHeight:"70vh",overflowY:"auto",textAlign:"center"},children:[A&&(0,a.jsx)("img",{src:A,alt:(null==S?void 0:S.name)||"Preview",style:{maxWidth:"100%",maxHeight:"40vh",marginBottom:"20px"}}),(0,a.jsxs)("div",{style:{maxWidth:"400px",margin:"0 auto",textAlign:"left"},children:[(0,a.jsx)("p",{style:{marginBottom:"10px",color:"#666"},children:v("upload.titleHelp")}),(0,a.jsx)("input",{value:I,onChange:e=>M(e.target.value),placeholder:null!==(m=v("upload.titlePlaceholder"))&&void 0!==m?m:"Enter image title",style:{width:"90%",marginBottom:"20px"},className:"memori--upload-title-input"}),(0,a.jsxs)("div",{style:{display:"flex",gap:"10px",justifyContent:"center",alignItems:"center"},children:[(0,a.jsx)(Jl,{onClick:P,className:"memori-button memori-button--outline memori--upload-image",children:null!==(f=v("cancel"))&&void 0!==f?f:"Cancel"}),(0,a.jsx)(Jl,{onClick:async()=>{var t;if(S&&I.trim()){w(!0),N(!1);try{let t=S;try{t=await xM(S)}catch(e){console.warn("Image compression failed, using original file",e),t=S}const r=new FileReader;r.onload=async r=>{var a,l,c,u,p;const m=null===(a=r.target)||void 0===a?void 0:a.result,f=Math.random().toString(36).substr(2,9);if(i)try{let i,r;if(e&&(null==_?void 0:_.uploadAsset))r=await _.uploadAsset(t.name,m,e);else{if(!(d&&n&&(null==_?void 0:_.uploadAssetUnlogged)))throw new Error("Missing required parameters for upload");if(r=await _.uploadAssetUnlogged(t.name,m,d,n),!r)throw new Error("Upload failed")}if(i=r.asset,0!==r.resultCode)throw new Error(r.resultMessage||"Upload failed");let a,u=null;if((null==b?void 0:b.postMediumSelectedEvent)&&n&&(u=await b.postMediumSelectedEvent(n,{url:i.assetURL,mimeType:i.mimeType})),null===(l=null==u?void 0:u.currentState)||void 0===l?void 0:l.currentMedia){const e=new Set(s.map((e=>e.mediumID)));a=null===(c=u.currentState.currentMedia.find((t=>!e.has(t.mediumID))))||void 0===c?void 0:c.mediumID}o((e=>[...e,{name:I,id:f,url:i.assetURL,content:i.assetURL,type:"image",mediumID:a,mimeType:i.mimeType}]))}catch(e){null==h||h({message:null!==(u=v("upload.uploadFailed"))&&void 0!==u?u:"Upload failed",severity:"error"})}else null==h||h({message:null!==(p=v("upload.apiClientNotConfigured"))&&void 0!==p?p:"API client not configured properly for media upload",severity:"warning"});w(!1)},r.onerror=()=>{var e;null==h||h({message:null!==(e=v("upload.fileReadingFailed"))&&void 0!==e?e:"File reading failed",severity:"error"}),w(!1)},r.readAsDataURL(t)}catch(e){null==h||h({message:null!==(t=v("upload.uploadFailed"))&&void 0!==t?t:"Upload failed",severity:"error"}),w(!1)}}},disabled:!S||!I.trim(),className:"memori-button memori-button--primary memori-button--image-confirm memori--upload-image",children:null!==(g=v("confirm"))&&void 0!==g?g:"Confirm"})]})]})]})})]})};const SM=10;var EM=({authToken:e="",client:n,sessionID:i="",isMediaAccepted:r=!1,setDocumentPreviewFiles:s,documentPreviewFiles:l,memoriID:u=""})=>{var d;const[h,p]=(0,c.useState)(!1),[m,f]=(0,c.useState)([]),[g,v]=(0,c.useState)(!1),{t:y,i18n:_}=Ve(),b=(0,c.useRef)(null),x=(0,c.useRef)(null),w=(0,c.useRef)(null),S=(0,c.useRef)(null),E=(0,c.useRef)(null),A=l.length,T=SM-A<=0,I=e=>{f((t=>t.filter((t=>t.message!==e))))},M=e=>{f((t=>[...t,e])),setTimeout((()=>I(e.message)),5e3)},C=(0,c.useRef)(r),N=(0,c.useRef)(A),O=(0,c.useRef)(M);(0,c.useEffect)((()=>{C.current=r,N.current=A,O.current=M}),[r,A,M]);const R=(0,c.useCallback)((e=>{var t,n,i;const r=Array.from(e);if(0===r.length)return;const o=[],a=[];r.forEach((e=>{(e=>{var t;const n=`.${null===(t=e.name.split(".").pop())||void 0===t?void 0:t.toLowerCase()}`;return["image/jpeg","image/jpg","image/png"].includes(e.type)||[".jpg",".jpeg",".png"].includes(n)})(e)?o.push(e):(e=>{var t;const n=`.${null===(t=e.name.split(".").pop())||void 0===t?void 0:t.toLowerCase()}`;return[".pdf",".txt",".json",".xlsx",".csv",".md",".html"].includes(n)})(e)?a.push(e):O.current({message:`File "${e.name}" is not a supported image or document type`,severity:"error"})}));const s=o.length+a.length;if(N.current+s>SM)O.current({message:"Maximum 10 media files allowed.",severity:"error"});else{if(o.length>0)if(C.current){const e=null===(n=w.current)||void 0===n?void 0:n.querySelector('input[type="file"]');if(e){const t=new DataTransfer;if(o.forEach((e=>{try{t.items.add(e)}catch(e){console.warn("Failed to add image file to DataTransfer:",e)}})),t.files.length>0){e.files=t.files;const n=new Event("change",{bubbles:!0});e.dispatchEvent(n)}}}else O.current({message:null!==(t=y("upload.mediaNotAccepted"))&&void 0!==t?t:"Media uploads are not accepted",severity:"info"});if(a.length>0){const e=null===(i=x.current)||void 0===i?void 0:i.querySelector('input[type="file"]');if(e){const t=new DataTransfer;if(a.forEach((e=>{try{t.items.add(e)}catch(e){console.warn("Failed to add document file to DataTransfer:",e)}})),t.files.length>0){e.files=t.files;const n=new Event("change",{bubbles:!0});e.dispatchEvent(n)}}}}}),[y]);(0,c.useEffect)((()=>{const e=e=>{const t=e.clipboardData;if(!t)return void console.log("[UploadButton] handlePaste: No clipboardData available.");const n=[],i=e=>n.some((t=>t.name===e.name&&t.size===e.size&&t.lastModified===e.lastModified));if(t.files&&t.files.length>0){const e=Array.from(t.files);console.log("[UploadButton] handlePaste: clipboardData.files found",e),e.forEach((e=>{i(e)?console.log("[UploadButton] handlePaste: Duplicate file skipped from clipboardData.files:",e):n.push(e)}))}else{const e=t.items;if(e)for(let t=0;t<e.length;t++){const r=e[t];if("file"===r.kind){const e=r.getAsFile();e&&!i(e)?(console.log("[UploadButton] handlePaste: Adding file from items array:",e),n.push(e)):e&&console.log("[UploadButton] handlePaste: Duplicate file skipped from items array:",e)}}}n.length>0?(console.log(`[UploadButton] handlePaste: ${n.length} file(s) to process from paste`,n),e.preventDefault(),R(n)):console.log("[UploadButton] handlePaste: No files found in paste event.")};return document.addEventListener("paste",e),()=>{document.removeEventListener("paste",e)}}),[R]),(0,c.useEffect)((()=>{let e=0;const t=t=>{t.preventDefault(),t.stopPropagation(),e++,1===e&&v(!0)},n=t=>{t.preventDefault(),t.stopPropagation(),e--,0===e&&v(!1)},i=e=>{e.preventDefault(),e.stopPropagation()},r=t=>{var n;t.preventDefault(),t.stopPropagation(),e=0,v(!1);const i=null===(n=t.dataTransfer)||void 0===n?void 0:n.files;i&&i.length>0&&R(i)};return document.addEventListener("dragenter",t),document.addEventListener("dragleave",n),document.addEventListener("dragover",i),document.addEventListener("drop",r),()=>{document.removeEventListener("dragenter",t),document.removeEventListener("dragleave",n),document.removeEventListener("dragover",i),document.removeEventListener("drop",r)}}),[R]);const L=e=>{p(e)};return(0,a.jsxs)("div",{className:t(We)("memori--unified-upload-wrapper",{"memori--dragging":g}),ref:E,children:[(0,a.jsx)("input",{ref:S,type:"file",accept:".jpg,.jpeg,.png,.pdf,.txt,.json,.xlsx,.csv,.md,.html",multiple:!0,className:"memori--upload-file-input",onChange:e=>{const t=e.target.files;t&&t.length>0&&R(t),S.current&&(S.current.value="")},style:{display:"none"}}),(0,a.jsx)("button",{ref:b,className:t(We)("memori-button","memori-button--circle","memori-button--icon-only","memori-share-button--button","memori--conversation-button","memori--unified-upload-button",{"memori--error":m.length>0}),onClick:()=>{S.current&&S.current.click()},disabled:h||T,title:null!==(d=y("upload.uploadFiles",{shortcut:/Mac|iPhone|iPod|iPad/i.test(navigator.platform)||navigator.userAgent.includes("Mac")?"Cmd":"Ctrl"}))&&void 0!==d?d:"Upload files (drag & drop)",children:h?(0,a.jsx)(Yl,{spinning:!0,className:"memori--upload-icon"}):(0,a.jsx)(dM,{className:"memori--upload-icon"})}),A>0&&(0,a.jsxs)("div",{className:t(We)("memori--document-count",{"memori--document-count-full":T}),children:[A,"/",SM]}),(0,a.jsx)("div",{className:"memori--hidden-uploader",ref:x,children:(0,a.jsx)(vM,{setDocumentPreviewFiles:e=>{if(0===e.length)return;const t=e.map((e=>{const t=`<document_attachment filename="${e.name.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#39;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}" type="${e.mimeType}">\n\n${e.content}\n\n</document_attachment>`;return{name:e.name,id:e.id,content:t,type:"document",mimeType:e.mimeType}})),n=l.filter((e=>"image"===e.type));s([...t,...n]),p(!1)},maxDocuments:SM,documentPreviewFiles:l,onLoadingChange:L,onDocumentError:e=>{M(e)},onValidateFile:e=>{var t;const n=`.${null===(t=e.name.split(".").pop())||void 0===t?void 0:t.toLowerCase()}`,i=[".pdf",".txt",".json",".xlsx",".csv",".md",".html"],r=10485760;return i.includes(n)?!(e.size>r)||(M({message:`File "${e.name}" exceeds 10MB limit`,severity:"error"}),!1):(M({message:`File type "${n}" is not supported. Please use: ${i.join(", ")}`,severity:"error"}),!1)},onValidatePayloadSize:e=>{const{MAX_TOTAL_MESSAGE_PAYLOAD:t}=o("1Lq0j");return!([...l.filter((e=>"document"===e.type)),...e].reduce(((e,t)=>e+t.content.length),0)>t)||(M({message:`Total document content exceeds ${t} characters limit. Please remove some documents.`,severity:"error"}),!1)}})}),(0,a.jsx)("div",{className:"memori--hidden-uploader",ref:w,children:(0,a.jsx)(wM,{authToken:e,client:n,setDocumentPreviewFiles:s,sessionID:i,documentPreviewFiles:l,isMediaAccepted:r,onLoadingChange:L,maxImages:SM,memoriID:u,onImageError:e=>{M(e)},onValidateImageFile:e=>{var t;const n=`.${null===(t=e.name.split(".").pop())||void 0===t?void 0:t.toLowerCase()}`,i=[".jpg",".jpeg",".png"],r=10485760;return i.includes(n)||e.type.startsWith("image/")?!(e.size>r)||(M({message:`File "${e.name}" exceeds 10MB limit`,severity:"error"}),!1):(M({message:`File type "${n}" is not supported. Please use: ${i.join(", ")}`,severity:"error"}),!1)}})}),(0,a.jsx)("div",{className:"memori--error-message-container",children:m.map(((e,t)=>(0,a.jsx)(hM,{className:"memori--error-message-alert",open:!0,type:e.severity,title:"Upload notification",description:e.message,onClose:()=>I(e.message),width:"350px"},`${e.message}-${t}`)))})]})};c=o("85Hg2");var AM=({previewFiles:e,removeFile:t,allowRemove:n=!0})=>{const[i,r]=(0,c.useState)(null),[o,s]=(0,c.useState)(null),l=(e,t)=>{var n,i;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===(i=e.split(".").pop())||void 0===i?void 0:i.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"}};(0,c.useEffect)((()=>{const e=document.getElementsByClassName("memori-chat--content");if(e){e[e.length-1]&&e[0].scrollTo({top:e[0].scrollHeight,behavior:"smooth"})}}),[e]);const u=(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,a.jsxs)(a.Fragment,{children:[e.length>0&&(0,a.jsx)("div",{className:"memori--preview-container",children:(0,a.jsx)("div",{className:"memori--preview-list",children:e.map((e=>(0,a.jsxs)("div",{className:"memori--preview-item "+(u(e.content,e.type)?"memori--preview-item--image":"memori--preview-item--document"),onMouseEnter:()=>s(e.id),onMouseLeave:()=>s(null),onClick:()=>r(e),children:[u(e.content,e.type)?(0,a.jsx)("div",{className:"memori--preview-thumbnail",children:(0,a.jsx)("img",{src:e.content,alt:e.name})}):(0,a.jsx)(pM,{className:"memori--preview-icon"}),(0,a.jsxs)("div",{className:"memori--preview-file-info",children:[(0,a.jsx)("span",{className:"memori--preview-filename",children:e.name}),(0,a.jsx)("span",{className:"memori--preview-filetype",children:l(e.name,e.type)})]}),n&&(0,a.jsx)(Jl,{shape:"rounded",icon:(0,a.jsx)(Zl,{}),danger:!0,className:"memori--remove-button "+(o===e.id?"visible":""),onClick:n=>{n.stopPropagation(),t(e.id,null==e?void 0:e.mediumID)}})]},e.id)))})}),(0,a.jsx)(CA,{width:"80%",widthMd:"80%",open:!!i,className:"memori--modal-preview-file",onClose:()=>r(null),closable:!0,title:null==i?void 0:i.name,children:(0,a.jsx)("div",{className:"memori--preview-content",style:{maxHeight:"70vh",overflowY:"auto",textAlign:"center",whiteSpace:i&&!u(i.content,i.type)?"pre-wrap":"normal"},children:i&&u(i.content,i.type)?(0,a.jsx)(a.Fragment,{children:(0,a.jsx)("img",{src:i.content,alt:i.name,style:{maxWidth:"100%",maxHeight:"60vh"}})}):FE((null==i?void 0:i.content)||"")})})]})};var TM=({dialogState:e,userMessage:n="",sendOnEnter:i,onChangeUserMessage:r,sendMessage:o,onTextareaFocus:s,onTextareaBlur:l,showMicrophone:u=!1,microphoneMode:d="HOLD_TO_TALK",listening:h=!1,stopAudio:p,startListening:m,stopListening:f,showUpload:g=!1,isTyping:v=!1,sessionID:y,authToken:_,memoriID:b,client:x,onTextareaExpanded:w})=>{const{t:S}=Ve(),[E,A]=(0,c.useState)(!1),[T,I]=(0,c.useState)([]),{dialog:M}=x||{dialog:{postMediumDeselectedEvent:null}},C="X2a"===(null==e?void 0:e.state)||"X3"===(null==e?void 0:e.state),N=["R2","R3","R4","R5","G3","X3"].includes((null==e?void 0:e.state)||"");return(0,a.jsx)("div",{className:"memori-chat-inputs-wrapper",children:(0,a.jsxs)("fieldset",{id:"chat-fieldset",className:t(We)("memori-chat-inputs",{"memori-chat-inputs--expanded":E}),disabled:C,children:[g&&(0,a.jsx)(AM,{previewFiles:T,removeFile:async(e,t)=>{M.postMediumDeselectedEvent&&y&&t&&await M.postMediumDeselectedEvent(y,t),I((t=>t.filter((t=>t.id!==e))))}}),(0,a.jsxs)("div",{className:"memori-chat-inputs--container",children:[(0,a.jsx)("div",{className:"memori-chat-inputs--leading",children:g&&(0,a.jsx)("div",{className:"memori-chat-inputs--upload-wrapper",children:(0,a.jsx)(EM,{authToken:_,client:x,sessionID:y,isMediaAccepted:(null==e?void 0:e.acceptsMedia)||!1,setDocumentPreviewFiles:I,documentPreviewFiles:T,memoriID:b})})}),(0,a.jsx)("div",{className:"memori-chat-inputs--primary",children:(0,a.jsx)(sM,{value:n,onChange:r,onPressEnter:e=>{if(e.preventDefault(),!v&&"keypress"===i&&(null==n?void 0:n.length)>0){f();const e=T.map(((e,t)=>({mediumID:e.mediumID||`file_${Date.now()}_${t}_${Math.random().toString(36).substr(2,9)}`,mimeType:e.mimeType,content:e.content,title:e.name,properties:{isAttachedFile:!0},type:e.type,url:e.url})));o(n,e),I([]),r("")}},onFocus:s,onBlur:l,onExpandedChange:e=>{A(e),w&&w(e)},disabled:N})}),(0,a.jsx)("div",{className:"memori-chat-inputs--trailing",children:(0,a.jsxs)("div",{className:"memori-chat-inputs--trailing-inner",children:[u&&"CONTINUOUS"===d&&(0,a.jsx)("button",{type:"button",className:t(We)("memori-chat-inputs--mic-btn",{"memori-chat-inputs--mic-btn--listening":h}),title:h?S("write_and_speak.micButtonPopoverListening")||"Listening":S("write_and_speak.micButtonPopover")||"Start listening",onClick:()=>{h?f():(p(),m())},disabled:C,"aria-label":h?S("write_and_speak.micButtonPopoverListening")||"Listening":S("write_and_speak.micButtonPopover")||"Start listening",children:(0,a.jsx)(cM,{className:"icon"})}),u&&"HOLD_TO_TALK"===d&&(0,a.jsx)(uM,{listening:h,startListening:m,stopListening:()=>{f(),h&&(null==n?void 0:n.length)&&o(n)},stopAudio:p}),(0,a.jsx)("button",{type:"button",className:t(We)("memori-chat-inputs--send-btn",{"memori-chat-inputs--send-btn--active":!!(null==n?void 0:n.length),"memori-chat-inputs--send-btn--disabled":!n||0===n.length}),onClick:()=>{(e=>{if(v)return;const t=e.map(((e,t)=>({mediumID:e.mediumID||`file_${Date.now()}_${t}_${Math.random().toString(36).substr(2,9)}`,mimeType:e.mimeType,content:e.content,title:e.name,properties:{isAttachedFile:!0},type:e.type,url:e.url})));o(n,t),I([]),p(),speechSynthesis.speak(new SpeechSynthesisUtterance(""))})(T)},disabled:!n||0===n.length||v,title:S("send")||"Send","aria-label":S("send")||"Send",children:v?(0,a.jsx)("div",{className:"memori-chat-inputs--send-btn--loading"}):(0,a.jsx)(lM,{className:"icon"})})]})})]})]})})};c=o("85Hg2");const IM=15,MM={en:[{delayAfter:IM,text:"Processing in progress..."},{delayAfter:IM,text:"I'm thinking..."},{delayAfter:IM,text:"Analysing the request..."},{delayAfter:IM,text:"Preparing the reply..."},{delayAfter:IM,text:"Gathering information..."},{delayAfter:IM,text:"Formulating ideas..."},{delayAfter:IM,text:"One moment please..."},{delayAfter:IM,text:"Almost ready..."},{delayAfter:IM,text:"Connecting concepts..."},{delayAfter:IM,text:"Organising ideas..."},{delayAfter:IM,text:"Evaluating options..."},{delayAfter:IM,text:"Looking for the best solution..."},{delayAfter:IM,text:"Working for you..."},{delayAfter:IM,text:"Please wait..."},{delayAfter:IM,text:"Processing data..."},{delayAfter:IM,text:"Calculating response..."},{delayAfter:IM,text:"Synthesising information..."},{delayAfter:IM,text:"Generating content..."},{delayAfter:IM,text:"Reflecting on question..."},{delayAfter:IM,text:"Refining the answer"}],it:[{delayAfter:IM,text:"Elaborazione in corso..."},{delayAfter:IM,text:"Sto pensando..."},{delayAfter:IM,text:"Analizzando la richiesta..."},{delayAfter:IM,text:"Preparando la risposta..."},{delayAfter:IM,text:"Raccogliendo informazioni..."},{delayAfter:IM,text:"Formulando idee..."},{delayAfter:IM,text:"Un momento per favore..."},{delayAfter:IM,text:"Quasi pronto..."},{delayAfter:IM,text:"Connettendo i concetti..."},{delayAfter:IM,text:"Organizzando le idee..."},{delayAfter:IM,text:"Valutando le opzioni..."},{delayAfter:IM,text:"Cercando la soluzione migliore..."},{delayAfter:IM,text:"Sto lavorando per te..."},{delayAfter:IM,text:"Attendere prego..."},{delayAfter:IM,text:"Elaborazione dati in corso..."},{delayAfter:IM,text:"Calcolando la risposta..."},{delayAfter:IM,text:"Sintetizzando informazioni..."},{delayAfter:IM,text:"Generando contenuti..."},{delayAfter:IM,text:"Sto riflettendo sulla domanda..."},{delayAfter:IM,text:"Perfezionando la risposta..."}]},CM=(e=15)=>new Array(20*e).fill(" ").join("");var NM=({useDefaultSentences:e=!1,lang:t="en",sentence:n,sentences:i})=>{var r;const[o,s]=(0,c.useState)(0),[l,u]=(0,c.useState)((null===(r=null==i?void 0:i[t])||void 0===r?void 0:r.length)?`${i[t][0].text.endsWith("...")||!i[t][0].text.length?i[t][0].text:`${i[t][0].text}...`}${CM(i[t][0].delayAfter)}`:n?`${n.endsWith("...")||!n.length?n:`${n}...`}${CM()}`:""),[d,h]=(0,c.useState)(""),[p,m]=(0,c.useState)(0);return(0,c.useEffect)((()=>{const r=setInterval((()=>{var r;m((e=>e+50));const a=l[d.length];if(void 0!==a&&l.length>0)h((e=>e+a));else if((null===(r=null==i?void 0:i[t])||void 0===r?void 0:r.length)&&o<i[t].length-1){const e=o+1,n=i[t][e];u(`${n.text.endsWith("...")||!n.text.length?n.text:`${n.text}...`}${CM(n.delayAfter)}`),h(""),s(e)}else if(!i&&!n&&(e||p>2e4)){const e=MM[t][Math.floor(Math.random()*MM[t].length)];u(`${e.text}${CM(e.delayAfter)}`),h("")}}),50);return()=>clearInterval(r)})),(0,a.jsx)("div",{className:"memori-chat--bubble",children:(0,a.jsxs)("div",{className:"memori-chat--bubble-typing",children:[(0,a.jsxs)("div",{id:"wave",children:[(0,a.jsx)("span",{className:"dot"}),(0,a.jsx)("span",{className:"dot"}),(0,a.jsx)("span",{className:"dot"})]}),l.length>0&&(0,a.jsx)("p",{children:d})]})})};NI=o("1Lq0j"),c=o("85Hg2");var OM=({className:e,title:t})=>(0,a.jsx)("svg",{...t?{}:{"aria-hidden":"true"},focusable:"false",role:"img",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",className:e,"aria-label":t,children:(0,a.jsx)("path",{d:"M9 18L15 12 9 6"})});c=o("85Hg2"),c=o("85Hg2");var RM=({className:e,title:t})=>(0,a.jsxs)("svg",{...t?{}:{"aria-hidden":"true"},"aria-label":t,className:e,viewBox:"0 -2 32 32",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:[(0,a.jsx)("title",{children:t}),(0,a.jsx)("desc",{children:"Created with Sketch Beta."}),(0,a.jsx)("defs",{}),(0,a.jsx)("g",{id:"Page-1",stroke:"none","stroke-width":"1",fill:"none","fill-rule":"evenodd",children:(0,a.jsx)("g",{id:"Icon-Set",transform:"translate(-100.000000, -205.000000)",fill:"#000000",children:(0,a.jsx)("path",{d:"M130,226 C130,227.104 129.104,228 128,228 L125.858,228 C125.413,226.278 123.862,225 122,225 L110,225 C108.138,225 106.587,226.278 106.142,228 L104,228 C102.896,228 102,227.104 102,226 L102,224 C102,222.896 102.896,222 104,222 L128,222 C129.104,222 130,222.896 130,224 L130,226 L130,226 Z M122,231 L110,231 C108.896,231 108,230.104 108,229 C108,227.896 108.896,227 110,227 L122,227 C123.104,227 124,227.896 124,229 C124,230.104 123.104,231 122,231 L122,231 Z M108,209 C108,207.896 108.896,207 110,207 L122,207 C123.104,207 124,207.896 124,209 L124,220 L108,220 L108,209 L108,209 Z M128,220 L126,220 L126,209 C126,206.791 124.209,205 122,205 L110,205 C107.791,205 106,206.791 106,209 L106,220 L104,220 C101.791,220 100,221.791 100,224 L100,226 C100,228.209 101.791,230 104,230 L106.142,230 C106.587,231.723 108.138,233 110,233 L122,233 C123.862,233 125.413,231.723 125.858,230 L128,230 C130.209,230 132,228.209 132,226 L132,224 C132,221.791 130.209,220 128,220 L128,220 Z",id:"print"})})})]});c=o("85Hg2"),c=o("85Hg2");class LM{constructor(){this.printWindow=null}static getInstance(){return LM.instance||(LM.instance=new LM),LM.instance}convertMarkdownToHTML(e){return(0,MI.marked)(e)}generatePDFCSS(e={}){const{margin:t={top:"1in",right:"1in",bottom:"1in",left:"1in"},fontSize:n="12pt",fontFamily:i="system-ui, -apple-system, sans-serif",lineHeight:r="1.6",color:o="#333",backgroundColor:a="#fff"}=e;return`\n <style>\n @page {\n margin: ${t.top} ${t.right} ${t.bottom} ${t.left};\n size: A4;\n }\n\n @media print {\n * {\n -webkit-print-color-adjust: exact !important;\n color-adjust: exact !important;\n }\n\n body {\n font-family: ${i};\n font-size: ${n};\n line-height: ${r};\n color: ${o};\n background-color: ${a};\n margin: 0;\n padding: 0;\n max-width: none;\n word-wrap: break-word;\n overflow-wrap: break-word;\n }\n\n h1, h2, h3, h4, h5, h6 {\n page-break-after: avoid;\n margin-top: 1.5em;\n margin-bottom: 0.5em;\n font-weight: 600;\n }\n\n h1 { font-size: 1.8em; }\n h2 { font-size: 1.5em; }\n h3 { font-size: 1.3em; }\n\n p {\n margin: 0 0 1em 0;\n orphans: 3;\n widows: 3;\n }\n\n pre, code {\n font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;\n font-size: 0.9em;\n background-color: #f5f5f5;\n border: 1px solid #ddd;\n border-radius: 3px;\n padding: 0.2em 0.4em;\n page-break-inside: avoid;\n }\n\n pre {\n padding: 1em;\n overflow-x: auto;\n white-space: pre;\n margin: 1em 0;\n }\n\n pre code {\n background: none;\n border: none;\n padding: 0;\n }\n\n blockquote {\n margin: 1em 0;\n padding-left: 1em;\n border-left: 3px solid #ddd;\n font-style: italic;\n page-break-inside: avoid;\n }\n\n ul, ol {\n margin: 1em 0;\n padding-left: 2em;\n }\n\n li {\n margin: 0.25em 0;\n page-break-inside: avoid;\n }\n\n table {\n border-collapse: collapse;\n width: 100%;\n margin: 1em 0;\n page-break-inside: avoid;\n }\n\n th, td {\n border: 1px solid #ddd;\n padding: 0.5em;\n text-align: left;\n }\n\n th {\n background-color: #f5f5f5;\n font-weight: 600;\n }\n\n a {\n color: #0066cc;\n text-decoration: none;\n }\n\n a:hover {\n text-decoration: underline;\n }\n\n img {\n max-width: 100%;\n height: auto;\n page-break-inside: avoid;\n }\n\n .page-break {\n page-break-before: always;\n }\n\n .no-print {\n display: none !important;\n }\n }\n\n @media screen {\n body {\n font-family: ${i};\n font-size: ${n};\n line-height: ${r};\n color: ${o};\n background-color: ${a};\n margin: 20px;\n padding: 20px;\n max-width: 800px;\n margin: 0 auto;\n }\n }\n </style>\n `}createPDFDocument(e,t="Artifact",n={}){const i=this.convertMarkdownToHTML(e);return`\n <!DOCTYPE html>\n <html lang="en">\n <head>\n <meta charset="UTF-8">\n <meta name="viewport" content="width=device-width, initial-scale=1.0">\n <title>${t}</title>\n ${this.generatePDFCSS(n)}\n </head>\n <body>\n <div class="content">\n ${i}\n </div>\n </body>\n </html>\n `}async exportAsPDFSafari(e,t="Artifact",n={}){return new Promise(((i,r)=>{try{const r=this.createPDFDocument(e,t,n),o=window.open("","_blank","width=800,height=600,scrollbars=yes,resizable=yes");if(!o){const e=`data:text/html;charset=utf-8,${encodeURIComponent(r)}`,n=document.createElement("a");return n.href=e,n.download=`${t}.html`,n.target="_blank",n.style.display="none",document.body.appendChild(n),n.click(),document.body.removeChild(n),void i()}o.document.open("text/html","replace"),o.document.write(r),o.document.close(),o.document.title=t,setTimeout((()=>{try{o.focus(),o.print(),setTimeout((()=>{o&&!o.closed&&o.close(),i()}),3e3)}catch(e){if(console.warn("Print failed, trying alternative:",e),o&&!o.closed){const e=o.document.createElement("div");e.style.cssText="\n position: fixed;\n top: 20px;\n left: 20px;\n right: 20px;\n background: #f0f8ff;\n border: 2px solid #0066cc;\n padding: 20px;\n border-radius: 8px;\n font-family: system-ui, sans-serif;\n z-index: 10000;\n box-shadow: 0 4px 12px rgba(0,0,0,0.15);\n ",e.innerHTML='\n <h3 style="margin: 0 0 10px 0; color: #0066cc;">📄 PDF Export Instructions</h3>\n <p style="margin: 0 0 10px 0;">To save as PDF:</p>\n <ol style="margin: 0 0 15px 0; padding-left: 20px;">\n <li>Press <strong>Cmd+P</strong> (Mac) or <strong>Ctrl+P</strong> (Windows)</li>\n <li>In the print dialog, click the "PDF" dropdown</li>\n <li>Select "Save as PDF"</li>\n <li>Choose your save location and click "Save"</li>\n </ol>\n <button onclick="this.parentElement.remove()" style="\n background: #0066cc;\n color: white;\n border: none;\n padding: 8px 16px;\n border-radius: 4px;\n cursor: pointer;\n ">Got it!</button>\n ',o.document.body.appendChild(e)}i()}}),1e3)}catch(e){r(new Error(`Safari PDF export failed: ${e}`))}}))}async exportAsPDF(e,t="Artifact",n={}){return ME()?this.exportAsPDFSafari(e,t,n):new Promise(((i,r)=>{try{this.printWindow&&!this.printWindow.closed&&this.printWindow.close();const o=CE()?"width=800,height=600,scrollbars=yes,resizable=yes":"width=800,height=600,scrollbars=yes,resizable=yes,toolbar=no,menubar=no,location=no,status=no";if(this.printWindow=window.open("","_blank",o),!this.printWindow)return void r(new Error("Popup blocked! Please enable popups to export PDF."));const a=this.createPDFDocument(e,t,n);ME()?(this.printWindow.document.open("text/html","replace"),this.printWindow.document.write(a),this.printWindow.document.close(),setTimeout((()=>{if(this.printWindow&&!this.printWindow.closed)try{this.printWindow.document.title=t,this.printWindow.focus(),this.printWindow.print(),setTimeout((()=>{this.printWindow&&!this.printWindow.closed&&this.printWindow.close(),i()}),2e3)}catch(e){console.warn("Print dialog failed, trying alternative method:",e),this.printWindow.print(),setTimeout((()=>{this.printWindow&&!this.printWindow.closed&&this.printWindow.close(),i()}),2e3)}}),1e3)):(this.printWindow.document.write(a),this.printWindow.document.close(),this.printWindow.onload=()=>{setTimeout((()=>{this.printWindow&&(this.printWindow.document.title=t,this.printWindow.print(),setTimeout((()=>{this.printWindow&&(this.printWindow.close(),i())}),1e3))}),500)},this.printWindow.onerror=e=>{r(new Error(`PDF export failed: ${e}`))})}catch(e){r(new Error(`PDF export failed: ${e}`))}}))}isSupported(){return"undefined"!=typeof window&&"function"==typeof window.open}isSafariSupported(){return ME()&&"undefined"!=typeof window&&"function"==typeof window.open}cleanup(){this.printWindow&&!this.printWindow.closed&&this.printWindow.close(),this.printWindow=null}}const PM=LM.getInstance(),DM=(e,n,i,r)=>{const{t:o}=Ve(),[a,s]=(0,c.useState)({isOpen:!1,loading:!1,success:!1,error:null,activeFormat:null}),l=(0,c.useCallback)((e=>{try{MI.marked.use({async:!1,gfm:!0,pedantic:!1,renderer:{link:({href:e,title:t,text:n})=>{if(!e)return n;return`<a href="${e.startsWith("http")?e:`https://${e}`}" target="_blank" rel="noopener noreferrer"${t?` title="${t}"`:""}>${n}</a>`}}});const n=MI.marked.parse(e).toString().trim();return t(CI).sanitize(n,{ADD_ATTR:["target","rel"],ALLOWED_TAGS:["h1","h2","h3","h4","h5","h6","p","br","strong","em","u","s","ul","ol","li","blockquote","pre","code","a","img","table","thead","tbody","tr","th","td","div","span"],ALLOWED_ATTR:["href","title","target","rel","src","alt","class","id"]})}catch(t){return console.error("Error rendering markdown:",t),e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\n/g,"<br>")}}),[]),u=(0,c.useMemo)((()=>{const t=[];switch(e.mimeType){case"markdown":t.push({id:"markdown",label:o("artifact.downloadAsMarkdown")||"Download as Markdown",description:o("artifact.downloadRawMarkdownText")||"Download raw markdown text",mimeType:"text/markdown",action:"download"},{id:"pdf",label:o("artifact.downloadAsPdf")||"Download as PDF",description:o("artifact.exportAsPdfDocument")||"Export as PDF document",mimeType:"application/pdf",action:"pdf",isAsync:!0});break;case"html":t.push({id:"html",label:o("artifact.downloadAsHtml")||"Download as HTML",description:o("artifact.downloadFormattedHtml")||"Download formatted HTML",mimeType:"text/html",action:"download"});break;case"json":t.push({id:"json",label:o("artifact.downloadAsJson")||"Download as JSON",description:o("artifact.downloadJsonData")||"Download JSON data",mimeType:"application/json",action:"download"});break;case"image/png":t.push({id:"png",label:o("artifact.downloadAsPng")||"Download as PNG",description:o("artifact.downloadPngImage")||"Download PNG image",mimeType:"image/png",action:"download"});break;case"image/jpeg":t.push({id:"jpeg",label:o("artifact.downloadAsJpeg")||"Download as JPEG",description:o("artifact.downloadJpegImage")||"Download JPEG image",mimeType:"image/jpeg",action:"download"});break;case"image/gif":t.push({id:"gif",label:o("artifact.downloadAsGif")||"Download as GIF",description:o("artifact.downloadGifImage")||"Download GIF image",mimeType:"image/gif",action:"download"});break;case"image/webp":t.push({id:"webp",label:o("artifact.downloadAsWebp")||"Download as WebP",description:o("artifact.downloadWebpImage")||"Download WebP image",mimeType:"image/webp",action:"download"});break;case"image/svg+xml":t.push({id:"svg",label:o("artifact.copyAsSvg")||"Copy as SVG",description:o("artifact.copySvgSourceCode")||"Copy SVG source code",mimeType:"image/svg+xml",action:"copy"},{id:"plain",label:o("artifact.copyAsPlainText")||"Copy as Plain Text",description:o("artifact.copyAsText")||"Copy as text",mimeType:"text/plain",action:"copy"});break;default:if(e.mimeType.startsWith("application/vnd.ant.code")){const n=e.mimeType.split(".").pop()||"text";t.push({id:"code",label:o("artifact.copyAsLanguage",{language:n.charAt(0).toUpperCase()+n.slice(1)})||`Copy as ${n.charAt(0).toUpperCase()+n.slice(1)}`,description:o("artifact.copyLanguageCode",{language:n})||`Copy ${n} code`,mimeType:e.mimeType,action:"copy"},{id:"plain",label:o("artifact.copyAsPlainText")||"Copy as Plain Text",description:o("artifact.copyWithoutSyntaxHighlighting")||"Copy without syntax highlighting",mimeType:"text/plain",action:"copy"})}else t.push({id:"text",label:o("artifact.copyAsText")||"Copy as Text",description:o("artifact.copyTextContent")||"Copy text content",mimeType:"text/plain",action:"copy"})}return t}),[e.mimeType,o]),d=(0,c.useCallback)((t=>{const{content:n}=e;switch(t.id){case"plain":return n.replace(/<[^>]*>/g,"").replace(/#{1,6}\s+/g,"").replace(/\*\*(.*?)\*\*/g,"$1").replace(/\*(.*?)\*/g,"$1").replace(/`([^`]+)`/g,"$1").replace(/```[\s\S]*?```/g,"").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").trim();case"html":case"markdown":case"svg":default:return n;case"raw":return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}}),[e.content]),h=(0,c.useCallback)((async e=>{if(navigator.clipboard&&window.isSecureContext)await navigator.clipboard.writeText(e);else{const t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.left="-999999px",t.style.top="-999999px",document.body.appendChild(t),t.focus(),t.select(),document.execCommand("copy"),document.body.removeChild(t)}}),[]),p=(0,c.useCallback)((async t=>{s((e=>({...e,loading:!0,error:null,activeFormat:t.id})));try{if("pdf"===t.action){if(!PM.isSupported())throw new Error(o("artifact.pdfExportNotSupported")||"PDF export is not supported in this browser");const t={title:e.title||"Artifact",fontSize:"12pt",fontFamily:"system-ui, -apple-system, sans-serif",lineHeight:"1.6",color:"#333",backgroundColor:"#fff"};try{await PM.exportAsPDF(e.content,e.title||"Artifact",t),null==r||r()}catch(e){if(ME())return s((e=>({...e,loading:!1,success:!0,error:null}))),setTimeout((()=>{s((e=>({...e,success:!1})))}),3e3),void(null==r||r());throw e}}else if("print"===t.action){const n=d(t),i=window.open("","_blank");if(!i)throw new Error(o("artifact.popupBlocked")||"Popup blocked! Please enable popups to print.");let a;if("markdown"===e.mimeType){const t=l(e.content);a=`\n <!DOCTYPE html>\n <html>\n <head>\n <title>${e.title||"Artifact"}</title>\n <style>\n body {\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;\n line-height: 1.6;\n color: #333;\n max-width: 800px;\n margin: 0 auto;\n padding: 20px;\n background-color: #fff;\n }\n h1, h2, h3, h4, h5, h6 {\n color: #2c3e50;\n margin-top: 1.5em;\n margin-bottom: 0.5em;\n }\n h1 { border-bottom: 2px solid #eee; padding-bottom: 10px; }\n h2 { border-bottom: 1px solid #eee; padding-bottom: 5px; }\n code {\n background-color: #f4f4f4;\n padding: 2px 4px;\n border-radius: 3px;\n font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;\n }\n pre {\n background-color: #f8f8f8;\n padding: 15px;\n border-radius: 5px;\n overflow-x: auto;\n border: 1px solid #e1e1e1;\n }\n pre code {\n background-color: transparent;\n padding: 0;\n }\n blockquote {\n border-left: 4px solid #ddd;\n margin: 0;\n padding-left: 20px;\n color: #666;\n }\n table {\n border-collapse: collapse;\n width: 100%;\n margin: 1em 0;\n }\n th, td {\n border: 1px solid #ddd;\n padding: 8px 12px;\n text-align: left;\n }\n th {\n background-color: #f5f5f5;\n font-weight: 600;\n }\n a {\n color: #007acc;\n text-decoration: none;\n }\n a:hover {\n text-decoration: underline;\n }\n ul, ol {\n padding-left: 20px;\n }\n img {\n max-width: 100%;\n height: auto;\n }\n @media print { \n body { margin: 0; } \n }\n </style>\n </head>\n <body>${t}</body>\n </html>\n `}else a=`\n <!DOCTYPE html>\n <html>\n <head>\n <title>${e.title||"Artifact"}</title>\n <style>\n body { \n font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace; \n white-space: pre-wrap; \n margin: 20px; \n line-height: 1.4;\n }\n @media print { \n body { margin: 0; } \n }\n </style>\n </head>\n <body>${n.replace(/</g,"&lt;").replace(/>/g,"&gt;")}</body>\n </html>\n `;i.document.write(a),i.document.close(),setTimeout((()=>{i.print(),i.close()}),500),null==r||r()}else if("download"===t.action){const n=d(t),r=new Blob([n],{type:t.mimeType}),o=URL.createObjectURL(r),a=document.createElement("a");let s=t.mimeType.split("/")[1];"x-python"===s?s="py":"x-java"===s?s="java":"x-c++"===s?s="cpp":"markdown"===s&&(s="md"),a.href=o,a.download=`${e.title||"Artifact"}.${s}`,a.click(),URL.revokeObjectURL(o),null==i||i()}else if("copy"===t.action){const e=d(t);await h(e),null==n||n()}s((e=>({...e,loading:!1,success:"copy"===t.action,error:null}))),"copy"===t.action&&setTimeout((()=>{s((e=>({...e,success:!1})))}),2e3)}catch(e){console.error("Copy operation failed:",e),s((t=>({...t,loading:!1,success:!1,error:e instanceof Error?e.message:"Copy operation failed"}))),setTimeout((()=>{s((e=>({...e,error:null})))}),3e3)}}),[e,d,h,n,r,o,l]),m=(0,c.useCallback)((async()=>{const e=d(u[0]);await h(e),s((e=>({...e,loading:!1,success:!0,error:null}))),null==n||n()}),[d,h,n,u]),f=(0,c.useCallback)((()=>{s((e=>({...e,isOpen:!e.isOpen,error:null})))}),[]),g=(0,c.useCallback)((()=>{s((e=>({...e,isOpen:!1})))}),[]),v=(0,c.useCallback)((()=>{s({isOpen:!1,loading:!1,success:!1,error:null,activeFormat:null})}),[]);return{copyState:a,formats:u,handleCopy:p,handleCopyClick:m,toggleDropdown:f,closeDropdown:g,resetState:v}};var kM=({className:e,title:t})=>(0,a.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,a.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 BM=({format:e,onClick:n,loading:i=!1,disabled:r=!1,active:o=!1})=>(0,a.jsx)("button",{type:"button",className:t(We)("memori-copy-menu-item",{"memori-copy-menu-item--loading":i,"memori-copy-menu-item--disabled":r,"memori-copy-menu-item--pdf":"pdf"===e.action,"memori-copy-menu-item--print":"print"===e.action,"memori-copy-menu-item--active":o,"memori-copy-menu-item--external":"link"===e.action,"memori-copy-menu-item--copy":"copy"===e.action,"memori-copy-menu-item--download":"download"===e.action}),onClick:()=>{r||i||n(e)},disabled:r||i,title:e.description,children:(0,a.jsxs)("div",{className:"memori-copy-menu-item-content",children:[(0,a.jsx)("div",{className:"memori-copy-menu-item-icon-wrapper",children:(()=>{if(i)return(0,a.jsx)("div",{className:"memori-copy-menu-item-loading",children:(0,a.jsx)("div",{className:"memori-copy-menu-item-spinner"})});switch(e.action){case"pdf":return(0,a.jsx)(kM,{className:"memori-copy-menu-item-icon"});case"print":return(0,a.jsx)(RM,{className:"memori-copy-menu-item-icon"});case"link":return(0,a.jsx)(jI,{className:"memori-copy-menu-item-icon"});default:return(0,a.jsx)(AI,{className:"memori-copy-menu-item-icon"})}})()}),(0,a.jsxs)("div",{className:"memori-copy-menu-item-text",children:[(0,a.jsx)("div",{className:"memori-copy-menu-item-label",children:e.label}),e.description&&(0,a.jsx)("div",{className:"memori-copy-menu-item-description",children:e.description})]}),e.isAsync&&(0,a.jsx)("div",{className:"memori-copy-menu-item-async-indicator",children:(0,a.jsx)("span",{className:"memori-copy-menu-item-async-badge",children:"PDF"})})]})});var FM=({className:e,title:t})=>(0,a.jsx)("svg",{fill:"#000000",xmlns:"http://www.w3.org/2000/svg",width:"800px",height:"800px",viewBox:"0 0 52 52",enableBackground:"new 0 0 52 52",xmlSpace:"preserve",...t?{}:{"aria-hidden":"true"},focusable:"false",role:"img",className:e,"aria-label":t,children:(0,a.jsx)("path",{d:"M47.6,17.8L27.1,38.5c-0.6,0.6-1.6,0.6-2.2,0L4.4,17.8c-0.6-0.6-0.6-1.6,0-2.2l2.2-2.2 c0.6-0.6,1.6-0.6,2.2,0l16.1,16.3c0.6,0.6,1.6,0.6,2.2,0l16.1-16.2c0.6-0.6,1.6-0.6,2.2,0l2.2,2.2C48.1,16.3,48.1,17.2,47.6,17.8z"})});var UM=({className:e,title:t})=>(0,a.jsx)("svg",{...t?{}:{"aria-hidden":"true"},focusable:"false",role:"img",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",tabIndex:-1,className:e,"aria-label":t,children:(0,a.jsx)("path",{d:"M14 9V5a3 3 0 00-3-3l-4 9v11h11.28a2 2 0 002-1.7l1.38-9a2 2 0 00-2-2.3zM7 22H4a2 2 0 01-2-2v-7a2 2 0 012-2h3"})});var zM=({className:e,title:t})=>(0,a.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,a.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 GM=({artifact:e,onCopy:n,onDownload:i,onPrint:r,onOpenExternal:o,loading:s=!1,className:l,disabled:u=!1})=>{const{copyState:d,formats:h,handleCopy:p,handleCopyClick:m}=DM(e,n,i,r),{t:f}=Ve(),g=async e=>{await p(e)},v=(0,c.useCallback)((e=>{try{MI.marked.use({async:!1,gfm:!0,pedantic:!1,renderer:{link:({href:e,title:t,text:n})=>{if(!e)return n;return`<a href="${e.startsWith("http")?e:`https://${e}`}" target="_blank" rel="noopener noreferrer"${t?` title="${t}"`:""}>${n}</a>`}}});const n=MI.marked.parse(e).toString().trim();return t(CI).sanitize(n,{ADD_ATTR:["target","rel"],ALLOWED_TAGS:["h1","h2","h3","h4","h5","h6","p","br","strong","em","u","s","ul","ol","li","blockquote","pre","code","a","img","table","thead","tbody","tr","th","td","div","span"],ALLOWED_ATTR:["href","title","target","rel","src","alt","class","id"]})}catch(t){return console.error("Error rendering markdown:",t),e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\n/g,"<br>")}}),[]),y=(0,c.useCallback)((e=>({html:"text/html",json:"application/json",markdown:"text/markdown",css:"text/css",javascript:"text/javascript",typescript:"text/typescript",svg:"image/svg+xml",xml:"text/xml",text:"text/plain",python:"text/x-python",java:"text/x-java",cpp:"text/x-c++",csharp:"text/x-csharp",php:"text/x-php",ruby:"text/x-ruby",go:"text/x-go",rust:"text/x-rust",yaml:"text/yaml",sql:"text/x-sql"}[e]||"text/plain")),[]),_=(0,c.useCallback)((()=>{try{const t=window.open("","_blank");if(!t)return void alert("Popup blocked! Please enable popups to print the artifact.");let n;n="html"===e.mimeType?e.content:`\n <!DOCTYPE html>\n <html>\n <head>\n <title>Artifact - ${e.mimeType.toUpperCase()}</title>\n <style>\n body { \n font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace; \n white-space: pre-wrap; \n margin: 20px; \n line-height: 1.4;\n }\n @media print { \n body { margin: 0; } \n }\n </style>\n </head>\n <body>${e.content.replace(/</g,"&lt;").replace(/>/g,"&gt;")}</body>\n </html>\n `,t.document.write(n),t.document.close(),setTimeout((()=>{t.print(),t.close()}),500),null==r||r()}catch(e){console.error("Print failed:",e)}}),[e,r]),b=(0,c.useCallback)((()=>{try{let t=e.content,n=y(e.mimeType);if("markdown"===e.mimeType){const i=v(e.content);t=`\n<!DOCTYPE html>\n<html lang="en">\n<head>\n <meta charset="UTF-8">\n <meta name="viewport" content="width=device-width, initial-scale=1.0">\n <title>${e.title||"Artifact"}</title>\n <style>\n body {\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;\n line-height: 1.6;\n color: #333;\n max-width: 800px;\n margin: 0 auto;\n padding: 20px;\n background-color: #fff;\n }\n h1, h2, h3, h4, h5, h6 {\n color: #2c3e50;\n margin-top: 1.5em;\n margin-bottom: 0.5em;\n }\n h1 { border-bottom: 2px solid #eee; padding-bottom: 10px; }\n h2 { border-bottom: 1px solid #eee; padding-bottom: 5px; }\n code {\n background-color: #f4f4f4;\n padding: 2px 4px;\n border-radius: 3px;\n font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;\n }\n pre {\n background-color: #f8f8f8;\n padding: 15px;\n border-radius: 5px;\n overflow-x: auto;\n border: 1px solid #e1e1e1;\n }\n pre code {\n background-color: transparent;\n padding: 0;\n }\n blockquote {\n border-left: 4px solid #ddd;\n margin: 0;\n padding-left: 20px;\n color: #666;\n }\n table {\n border-collapse: collapse;\n width: 100%;\n margin: 1em 0;\n }\n th, td {\n border: 1px solid #ddd;\n padding: 8px 12px;\n text-align: left;\n }\n th {\n background-color: #f5f5f5;\n font-weight: 600;\n }\n a {\n color: #007acc;\n text-decoration: none;\n }\n a:hover {\n text-decoration: underline;\n }\n ul, ol {\n padding-left: 20px;\n }\n img {\n max-width: 100%;\n height: auto;\n }\n </style>\n</head>\n<body>\n ${i}\n</body>\n</html>`,n="text/html"}const i=new Blob([t],{type:n}),r=URL.createObjectURL(i);if(!window.open(r,"_blank"))return void alert("Popup blocked! Please enable popups to open the artifact in a new window.");setTimeout((()=>{URL.revokeObjectURL(r)}),6e4),null==o||o()}catch(e){console.error("External open failed:",e)}}),[e,y,v,o]);return(0,a.jsx)("div",{className:"memori-copy-button-wrapper",children:(0,a.jsxs)("div",{className:"memori-copy-button-group",children:[(0,a.jsx)(Jl,{onClick:m,disabled:u||s||d.loading,className:t(We)("memori-copy-button memori-copy-button--main ",{"memori-copy-button--success":d.success,"memori-copy-button--error":d.error,"memori-copy-button--loading":d.loading},l),ghost:!0,title:d.success?"Copied successfully!":d.error?`Error: ${d.error}`:d.loading?"pdf"===d.activeFormat?"Generating PDF...":"Copying...":h.length>0?`Copy as ${h[0].label}`:"Copy",children:d.success?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(UM,{className:"memori-copy-button-icon memori-copy-button-icon--success"}),(0,a.jsx)("span",{className:"memori-copy-button-text",children:f("artifact.copied")||"Copied!"})]}):d.error?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(zM,{className:"memori-copy-button-icon memori-copy-button-icon--error"}),(0,a.jsx)("span",{className:"memori-copy-button-text",children:f("artifact.error")||"Error"})]}):d.loading?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"memori-copy-button-loading",children:(0,a.jsx)("div",{className:"memori-copy-button-spinner"})}),(0,a.jsx)("span",{className:"memori-copy-button-text",children:"pdf"===d.activeFormat?f("artifact.generatingPdf")||"Generating PDF...":f("artifact.copying")||"Copying..."})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(AI,{className:"memori-copy-button-icon"}),(0,a.jsx)("span",{className:"memori-copy-button-text",children:f("artifact.copy")||"Copy"})]})}),h.length>0&&(0,a.jsx)(yI,{as:"div",className:"memori-copy-menu-wrapper",children:()=>(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(yI.Button,{as:"div",className:"memori-copy-button-trigger",children:(0,a.jsx)(Jl,{disabled:u||s||d.loading,className:"memori-copy-button--dropdown",ghost:!0,title:"More copy options",children:(0,a.jsx)(FM,{className:"memori-copy-button-chevron"})})}),(0,a.jsx)(Os,{as:t(c).Fragment,enter:"memori-copy-dropdown-enter",enterFrom:"memori-copy-dropdown-enter-from",enterTo:"memori-copy-dropdown-enter-to",leave:"memori-copy-dropdown-leave",leaveFrom:"memori-copy-dropdown-leave-from",leaveTo:"memori-copy-dropdown-leave-to",children:(0,a.jsx)(yI.Items,{className:"memori-copy-dropdown",children:(0,a.jsx)("div",{className:"memori-copy-dropdown-content",children:(0,a.jsxs)("div",{className:"memori-copy-dropdown-list",children:[h.map((e=>(0,a.jsx)(yI.Item,{children:({active:t})=>(0,a.jsx)(BM,{format:e,onClick:g,loading:d.loading,active:t})},e.id))),(0,a.jsx)(BM,{format:{id:"external",label:f("artifact.external")||"External",action:"link",mimeType:e.mimeType},onClick:b,loading:d.loading,active:!1}),(0,a.jsx)(BM,{format:{id:"print",label:f("artifact.print")||"Print",action:"print",mimeType:e.mimeType},onClick:_,loading:d.loading,active:!1})]})})})})]})})]})})};var jM=({className:e,title:t,bold:n=!1})=>(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:800,height:800,fill:"none",viewBox:"0 0 24 24",className:e,"aria-label":t,children:(0,a.jsx)("path",{stroke:"#000",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:n?3:2,d:"M13 5a1 1 0 1 0-2 0 1 1 0 0 0 2 0ZM13 12a1 1 0 1 0-2 0 1 1 0 0 0 2 0ZM13 19a1 1 0 1 0-2 0 1 1 0 0 0 2 0Z"})});var HM=({artifact:e,onCopy:n,onDownload:i,onPrint:r,onOpenExternal:o,loading:s=!1,isMobile:l=!1})=>{const{t:u}=Ve(),d=((0,c.useCallback)((e=>({html:"html",json:"json",markdown:"md",css:"css",javascript:"js",typescript:"ts",svg:"svg",xml:"xml",text:"txt",python:"py",java:"java",cpp:"cpp",csharp:"cs",php:"php",ruby:"rb",go:"go",rust:"rs",yaml:"yml",sql:"sql"}[e]||"txt")),[]),(0,c.useCallback)((e=>({html:"text/html",json:"application/json",markdown:"text/markdown",css:"text/css",javascript:"text/javascript",typescript:"text/typescript",svg:"image/svg+xml",xml:"text/xml",text:"text/plain",python:"text/x-python",java:"text/x-java",cpp:"text/x-c++",csharp:"text/x-csharp",php:"text/x-php",ruby:"text/x-ruby",go:"text/x-go",rust:"text/x-rust",yaml:"text/yaml",sql:"text/x-sql"}[e]||"text/plain")),[])),h=(0,c.useCallback)((()=>{try{const t=window.open("","_blank");if(!t)return void alert("Popup blocked! Please enable popups to print the artifact.");let n;n="html"===e.mimeType?e.content:`\n <!DOCTYPE html>\n <html>\n <head>\n <title>Artifact - ${e.mimeType.toUpperCase()}</title>\n <style>\n body { \n font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace; \n white-space: pre-wrap; \n margin: 20px; \n line-height: 1.4;\n }\n @media print { \n body { margin: 0; } \n }\n </style>\n </head>\n <body>${e.content.replace(/</g,"&lt;").replace(/>/g,"&gt;")}</body>\n </html>\n `,t.document.write(n),t.document.close(),setTimeout((()=>{t.print(),t.close()}),500),null==r||r()}catch(e){console.error("Print failed:",e)}}),[e,r]),p=(0,c.useCallback)((()=>{try{const t=d(e.mimeType),n=new Blob([e.content],{type:t}),i=URL.createObjectURL(n);if(!window.open(i,"_blank"))return void alert("Popup blocked! Please enable popups to open the artifact in a new window.");setTimeout((()=>{URL.revokeObjectURL(i)}),6e4),null==o||o()}catch(e){console.error("External open failed:",e)}}),[e,d,o]);return(0,a.jsx)("div",{className:"memori-artifact-actions",children:(0,a.jsxs)("div",{className:"memori-artifact-actions-row",children:[(0,a.jsx)(GM,{artifact:e,onCopy:n,onDownload:i,onPrint:r,loading:s,className:"memori-artifact-action-btn"}),l&&(0,a.jsxs)(yI,{as:"div",className:"memori-copy-menu-wrapper",children:[(0,a.jsx)(yI.Button,{as:"div",className:"memori-copy-button-trigger",children:(0,a.jsx)(Jl,{disabled:s,className:t(We)("memori-button","memori-button--more-options","memori-button--icon-only"),ghost:!0,title:"More copy options",children:(0,a.jsx)(jM,{className:"memori-artifact-action-icon"})})}),(0,a.jsx)(Os,{as:t(c).Fragment,enter:"memori-copy-dropdown-enter",enterFrom:"memori-copy-dropdown-enter-from",enterTo:"memori-copy-dropdown-enter-to",leave:"memori-copy-dropdown-leave",leaveFrom:"memori-copy-dropdown-leave-from",leaveTo:"memori-copy-dropdown-leave-to",children:(0,a.jsx)(yI.Items,{className:"memori-copy-dropdown",style:{minWidth:"200px"},children:(0,a.jsxs)("div",{className:"memori-copy-dropdown-list",children:[(0,a.jsx)(Jl,{onClick:h,disabled:s,className:"memori-artifact-action-btn memori-artifact-action-btn--print",ghost:!0,icon:(0,a.jsx)(RM,{className:"memori-artifact-action-icon"}),title:u("artifact.print")||"Print",children:(0,a.jsx)("span",{className:"memori-artifact-action-text",children:u("artifact.print")||"Print"})}),(0,a.jsx)(Jl,{onClick:p,disabled:s,className:"memori-artifact-action-btn memori-artifact-action-btn--external",ghost:!0,icon:(0,a.jsx)(jI,{className:"memori-artifact-action-icon"}),title:u("artifact.external")||"External",children:(0,a.jsx)("span",{className:"memori-artifact-action-text",children:u("artifact.external")||"External"})})]})})})]})]})})};c=o("85Hg2");var VM=({artifact:e,activeTab:n})=>{const{t:i}=Ve(),r=(0,c.useCallback)((()=>{switch(e.mimeType){case"html":return(0,a.jsx)("iframe",{className:"memori-artifact-preview-iframe",srcDoc:e.content,style:{width:"100%",height:"100%",border:"none",borderRadius:"6px"},title:`${e.title} Preview`,scrolling:"auto"});case"markdown":return(0,a.jsx)("div",{className:"memori-artifact-preview-markdown",dangerouslySetInnerHTML:{__html:o(e.content)}});default:return(0,a.jsx)("div",{className:"memori-artifact-preview-text",dangerouslySetInnerHTML:{__html:e.content}})}}),[e]),o=(0,c.useCallback)((e=>e.replace(/^# (.*$)/gim,"<h1>$1</h1>").replace(/^## (.*$)/gim,"<h2>$1</h2>").replace(/^### (.*$)/gim,"<h3>$1</h3>").replace(/^#### (.*$)/gim,"<h4>$1</h4>").replace(/^##### (.*$)/gim,"<h5>$1</h5>").replace(/^###### (.*$)/gim,"<h6>$1</h6>").replace(/\*\*(.*?)\*\*/g,"<strong>$1</strong>").replace(/\*(.*?)\*/g,"<em>$1</em>").replace(/`(.*?)`/g,"<code>$1</code>").replace(/```([\s\S]*?)```/g,"<pre><code>$1</code></pre>").replace(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2" target="_blank" rel="noopener noreferrer">$1</a>').replace(/\n/g,"<br>")),[]),s=(0,c.useCallback)((e=>{switch(e){case"javascript":return"text/javascript";case"typescript":return"text/ecmascript";case"html":return"application/xml";case"css":return"text/css";case"json":return"application/json";case"python":return"text/x-python";case"bash":return"application/x-sh";case"cpp":case"csharp":return"text/x-c++src";case"php":return"application/x-php";case"sql":return"text/x-sql";case"ruby":return"text/x-ruby";default:return"text/plain"}}),[]),l="html"===e.mimeType||"markdown"===e.mimeType||"svg"===e.mimeType;return(0,a.jsx)("div",{className:"memori-artifact-preview",children:(0,a.jsxs)("div",{className:"memori-artifact-content",children:[(0,a.jsx)("div",{className:t(We)("memori-artifact-tab-content",{"memori-artifact-tab-content--active":"code"===n||!l}),children:(0,a.jsx)("div",{className:"memori-artifact-code",children:(0,a.jsx)(zI,{showCopyButton:!1,medium:{mediumID:e.id,mimeType:s(e.mimeType),content:e.content,title:e.title,creationTimestamp:e.timestamp.toISOString(),creationName:"System",lastChangeTimestamp:e.timestamp.toISOString(),lastChangeName:"System"}})})}),l&&(0,a.jsx)("div",{className:t(We)("memori-artifact-tab-content",{"memori-artifact-tab-content--active":"preview"===n}),children:(0,a.jsx)("div",{className:"memori-artifact-preview-content",children:r()})})]})})};const WM=({className:e})=>(0,a.jsxs)("svg",{className:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,a.jsx)("path",{d:"M1 12C1 12 5 4 12 4C19 4 23 12 23 12C23 12 19 20 12 20C5 20 1 12 1 12Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),(0,a.jsx)("circle",{cx:"12",cy:"12",r:"3",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]});var qM=({activeTab:e,onTabChange:n,hasPreview:i})=>{const r=[{id:"code",icon:TI},...i?[{id:"preview",icon:WM}]:[]];return(0,a.jsx)("div",{className:"memori-tab-switch",children:(0,a.jsx)("div",{className:"memori-tab-switch__container",children:(0,a.jsxs)("div",{className:"memori-tab-switch__track",style:{"--tab-count":r.length},children:[(0,a.jsx)("div",{className:"memori-tab-switch__indicator",style:{"--active-index":r.findIndex((t=>t.id===e))}}),r.map((i=>{const r=i.icon;return(0,a.jsx)("button",{type:"button",className:t(We)("memori-tab-switch__button",{"memori-tab-switch__button--active":e===i.id}),onClick:()=>n(i.id),"aria-pressed":e===i.id,children:(0,a.jsx)(r,{className:"memori-tab-switch__icon"})},i.id)}))]})})})};var $M=({isChatLogPanel:e=!1})=>{const{state:n,closeArtifact:i,toggleFullscreen:r}=re(),{t:o}=Ve(),[s,l]=(0,c.useState)(!1),[u,d]=(0,c.useState)("preview"),h=(0,c.useCallback)((e=>{d(e)}),[u]),{copyState:p,formats:m,handleCopy:f,handleCopyClick:g}=DM(n.currentArtifact||{content:"",mimeType:"text/plain"},(()=>console.log("Copy completed")),(()=>console.log("Download completed")),(()=>console.log("Print completed")));(0,c.useEffect)((()=>{const e=()=>{l(window.innerWidth<=768)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)}),[]);const v=(0,c.useCallback)((async()=>{if(n.currentArtifact)try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(n.currentArtifact.content);else{const e=document.createElement("textarea");e.value=n.currentArtifact.content,e.style.position="fixed",e.style.left="-999999px",e.style.top="-999999px",document.body.appendChild(e),e.focus(),e.select(),document.execCommand("copy"),document.body.removeChild(e)}}catch(e){throw console.error("Copy failed:",e),e}}),[n.currentArtifact]),y=((0,c.useCallback)((()=>{r&&r()}),[r]),(0,c.useCallback)((()=>{i()}),[i]));if(!n.currentArtifact)return null;const _="html"===n.currentArtifact.mimeType||"markdown"===n.currentArtifact.mimeType,b=(0,c.useCallback)((({children:t})=>e?(0,a.jsx)("div",{style:{minHeight:"75vh",maxHeight:"75vh"},className:"memori-artifact-panel",children:t}):(0,a.jsx)(Ql,{open:n.isDrawerOpen,onClose:y,placement:"right",width:"50%",className:n.isFullscreen?"memori-artifact-panel-drawer-fullscreen":"memori-artifact-panel-drawer",widthMd:"100%",widthLg:"50%",closable:!1,animated:!0,enterDuration:s?"duration-500":"duration-300",leaveDuration:s?"duration-400":"duration-200",showBackdrop:!1,preventBackdropClose:!0,confirmDialogTitle:o("artifact.confirmDialogTitle")||"Are you sure you want to close this artifact?",confirmDialogMessage:o("artifact.confirmDialogMessage")||"This action cannot be undone.",children:t})),[e,y,n.isDrawerOpen,n.isFullscreen,s]),x=(0,c.useCallback)((e=>({html:"text/html",json:"application/json",markdown:"text/markdown",css:"text/css",javascript:"text/javascript",typescript:"text/typescript",svg:"image/svg+xml",xml:"text/xml",text:"text/plain",python:"text/x-python",java:"text/x-java",cpp:"text/x-c++",csharp:"text/x-csharp",php:"text/x-php",ruby:"text/x-ruby",go:"text/x-go",rust:"text/x-rust",yaml:"text/yaml",sql:"text/x-sql"}[e]||"text/plain")),[]),w=(0,c.useCallback)((e=>{try{const t=x(e.mimeType),n=new Blob([e.content],{type:t}),i=URL.createObjectURL(n);if(!window.open(i,"_blank"))return void alert("Popup blocked! Please enable popups to open the artifact in a new window.");setTimeout((()=>{URL.revokeObjectURL(i)}),6e4)}catch(e){console.error("External open failed:",e)}}),[]);return(0,a.jsxs)(b,{children:[(0,a.jsx)("div",{className:t(We)("memori-artifact-drawer-container-actions",{"memori-artifact-drawer-container-actions--no-preview":!_,"memori-artifact-drawer-container-actions--chatlog":e}),children:!s&&(0,a.jsxs)(a.Fragment,{children:[_&&(0,a.jsx)(qM,{activeTab:u,onTabChange:h,hasPreview:_}),(0,a.jsx)(HM,{artifact:n.currentArtifact,onCopy:v,loading:!1,isMobile:s}),(0,a.jsx)(Jl,{onClick:i,className:t(We)("memori-artifact-drawer--close","memori-button--icon-only",{"memori-artifact-drawer--close-desktop":!_}),ghost:!0,title:o("artifact.close")||"Close",children:(0,a.jsx)(Zl,{className:"memori-artifact-panel--close-icon"})})]})}),(0,a.jsxs)("div",{className:t(We)("memori-artifact-drawer-top-right",{"memori-artifact-drawer-top-right--no-preview":!_,"memori-artifact-drawer-top-right--chatlog":e}),children:[s&&(0,a.jsxs)(a.Fragment,{children:[_&&(0,a.jsx)(qM,{activeTab:u,onTabChange:h,hasPreview:_}),(0,a.jsxs)(yI,{as:"div",className:"memori-mobile-actions-menu",children:[(0,a.jsx)(yI.Button,{as:"div",className:"memori-mobile-actions-trigger",children:(0,a.jsx)(Jl,{className:t(We)("memori-button","memori-button--more-options","memori-button--icon-only"),ghost:!0,title:o("artifact.actions")||"Actions",children:(0,a.jsx)(jM,{className:"memori-artifact-action-icon"})})}),(0,a.jsx)(Os,{as:t(c).Fragment,enter:"memori-mobile-dropdown-enter",enterFrom:"memori-mobile-dropdown-enter-from",enterTo:"memori-mobile-dropdown-enter-to",leave:"memori-mobile-dropdown-leave",leaveFrom:"memori-mobile-dropdown-leave-from",leaveTo:"memori-mobile-dropdown-leave-to",children:(0,a.jsx)(yI.Items,{className:"memori-mobile-dropdown",children:(0,a.jsxs)("div",{className:"memori-mobile-dropdown-list",children:[(0,a.jsx)(Jl,{onClick:v,disabled:!1,className:"memori-artifact-action-btn",ghost:!0,title:o("artifact.copy")||"Copy",children:(0,a.jsx)("span",{className:"memori-artifact-action-text",children:o("artifact.copy")||"Copy"})}),m.map((e=>(0,a.jsx)(Jl,{onClick:()=>f(e),disabled:p.loading&&p.activeFormat===e.id,className:"memori-artifact-action-btn",ghost:!0,icon:(()=>{switch(e.action){case"copy":default:return(0,a.jsx)(jI,{className:"memori-artifact-action-icon"});case"download":return(0,a.jsx)(kM,{className:"memori-artifact-action-icon"});case"print":case"pdf":return(0,a.jsx)(RM,{className:"memori-artifact-action-icon"})}})(),title:e.label,children:(0,a.jsx)("span",{className:"memori-artifact-action-text",children:e.label})},e.id))),(0,a.jsx)(Jl,{onClick:()=>{var e;return w(null!==(e=n.currentArtifact)&&void 0!==e?e:{content:"",mimeType:"",title:"",timestamp:new Date,size:0,id:""})},disabled:!1,className:"memori-artifact-action-btn",ghost:!0,icon:(0,a.jsx)(jI,{className:"memori-artifact-action-icon"}),title:o("artifact.external")||"External",children:(0,a.jsx)("span",{className:"memori-artifact-action-text",children:o("artifact.external")||"External"})})]})})})]})]}),s&&(0,a.jsx)(Jl,{onClick:i,className:t(We)("memori-artifact-drawer--close","memori-button--icon-only"),ghost:!0,title:o("artifact.close")||"Close",children:(0,a.jsx)(Zl,{className:"memori-artifact-panel--close-icon"})})]}),(0,a.jsx)("div",{className:"memori-artifact-panel--header"}),(0,a.jsx)("div",{className:"memori-artifact-panel--content",children:(0,a.jsx)("div",{className:"memori-artifact-panel--main",children:(0,a.jsx)(VM,{artifact:n.currentArtifact,activeTab:u})})})]})};var YM=({className:e,title:t})=>(0,a.jsx)("svg",{...t?{}:{"aria-hidden":"true"},focusable:"false",role:"img",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",className:e,"aria-label":t,children:(0,a.jsx)("path",{d:"M15 18L9 12 15 6"})});var JM=({className:e,title:t})=>(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",xmlSpace:"preserve",width:800,height:800,viewBox:"0 0 52 52",...t?{}:{"aria-hidden":"true"},focusable:"false",role:"img",className:e,"aria-label":t,children:(0,a.jsx)("path",{d:"m4.4 34.2 20.5-20.7c.6-.6 1.6-.6 2.2 0l20.5 20.7c.6.6.6 1.6 0 2.2l-2.2 2.2c-.6.6-1.6.6-2.2 0L27.1 22.2c-.6-.6-1.6-.6-2.2 0L8.8 38.5c-.6.6-1.6.6-2.2 0l-2.2-2.2c-.5-.6-.5-1.5 0-2.1z"})});const ZM=e=>{if(0===e)return"0 Bytes";const t=Math.floor(Math.log(e)/Math.log(1024));return parseFloat((e/Math.pow(1024,t)).toFixed(2))+" "+["Bytes","KB","MB"][t]};var XM=(0,c.memo)((({isChatlogPanel:e=!1,message:n})=>{var i;const{openArtifact:r,state:o,closeArtifact:s}=re(),l=(0,c.useMemo)((()=>n.translatedText||n.text||""),[n.translatedText,n.text]),u=(0,c.useMemo)((()=>`${n.timestamp}-${n.fromUser}`),[n.timestamp,n.fromUser]),d=(0,c.useCallback)((e=>{const t=new CustomEvent("artifactCreated",{detail:{artifact:e,message:n}});document.dispatchEvent(t)}),[n]),h=(0,c.useCallback)(((e,t)=>{if(!e||t)return[];e=BE(e);const n=[],i=/<output\s+class="memori-artifact"[^>]*data-mimetype="([^"]+)"[^>]*>([\s\S]*?)<\/output>/gi,r=(e,t,n)=>{const i=n.match(/data-title\s*=\s*["\']([^"']+)["\']/i);if(i)return i[1];const r=t.match(/<title>([^<]+)<\/title>/i);return r?r[1]:`${e.toUpperCase()} Artifact`};let o,a=0;for(;null!==(o=i.exec(e));){a++;const e=o[1],t=o[2].trim(),i=o[0],s={id:`artifact-${Date.now()}-${a}-${Math.random().toString(36).substr(2,9)}`,content:t,mimeType:e,title:r(e,t,i),timestamp:new Date,size:t.length};n.push(s)}return n}),[]),p=(0,c.useMemo)((()=>h(l,n.fromUser||!1)),[l,n.fromUser,h]);(0,c.useEffect)((()=>{l.length>0&&p.length>0&&(p.forEach((e=>{d(e)})),e||setTimeout((()=>{r(p[0])}),100))}),[u,p,d,e,r]);const m=(0,c.useCallback)((e=>{var t;o.isDrawerOpen&&(null===(t=o.currentArtifact)||void 0===t?void 0:t.id)===e.id?s():r(e)}),[o.isDrawerOpen,null===(i=o.currentArtifact)||void 0===i?void 0:i.id,s,r]),f=(0,c.useCallback)((e=>e.includes("html")?"🌐":e.includes("markdown")?"📝":e.includes("javascript")||e.includes("typescript")?"📜":e.includes("python")?"🐍":e.includes("json")?"📊":e.includes("css")?"🎨":e.includes("xml")?"📋":e.includes("svg")?"🖼️":"📄"),[]);return 0===p.length?null:(0,a.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:p.map((n=>{var i,r,s,l;const u=o.isDrawerOpen&&(null===(i=o.currentArtifact)||void 0===i?void 0:i.id)===n.id;return(0,a.jsxs)(t(c).Fragment,{children:[(0,a.jsxs)("div",{className:"memori-artifact-handler"+(u?" memori-artifact-handler--selected":""),onClick:()=>m(n),style:u?{border:"2px solid var(--memori-primary, #3b82f6)",boxShadow:"0 0 0 3px rgba(59, 130, 246, 0.1)"}:void 0,children:[(0,a.jsx)("div",{className:"memori-artifact-handler-icon",children:f(n.mimeType)}),(0,a.jsxs)("div",{className:"memori-artifact-handler-info",children:[(0,a.jsx)("div",{className:"memori-artifact-handler-title",children:n.title}),(0,a.jsxs)("div",{className:"memori-artifact-handler-meta",children:[n.mimeType," •"," ",ZM(n.size||0)]})]}),(0,a.jsx)("div",{className:"memori-artifact-handler-action",children:e?o.isDrawerOpen&&(null===(r=o.currentArtifact)||void 0===r?void 0:r.id)===n.id?(0,a.jsx)(JM,{className:"memori-artifact-handler-action-icon"}):(0,a.jsx)(FM,{className:"memori-artifact-handler-action-icon"}):o.isDrawerOpen&&(null===(s=o.currentArtifact)||void 0===s?void 0:s.id)===n.id?(0,a.jsx)(YM,{className:"memori-artifact-handler-action-icon"}):(0,a.jsx)(OM,{className:"memori-artifact-handler-action-icon"})})]}),o.isDrawerOpen&&(null===(l=o.currentArtifact)||void 0===l?void 0:l.id)===n.id&&(0,a.jsx)($M,{isChatLogPanel:e})]},n.id)}))})}),((e,t)=>{const n=e.message.translatedText||e.message.text||"",i=t.message.translatedText||t.message.text||"";return e.isChatlogPanel===t.isChatlogPanel&&n===i&&e.message.fromUser===t.message.fromUser&&e.message.timestamp===t.message.timestamp}));var KM=(0,c.memo)((({memori:e,tenant:n,sessionID:i,baseUrl:r,apiUrl:o,client:s,translateTo:l,memoriTyping:u,typingText:d,showTypingText:h=!1,history:p=[],authToken:m,dialogState:f,simulateUserPrompt:g,showDates:v=!1,showContextPerLine:y=!1,showAIicon:_=!0,showWhyThisAnswer:b=!0,showCopyButton:x=!0,showTranslationOriginal:w=!1,showReasoning:S=!1,preview:E=!1,instruct:A=!1,showInputs:T=!0,showMicrophone:I=!1,microphoneMode:M="HOLD_TO_TALK",sendOnEnter:C,setSendOnEnter:N,attachmentsMenuOpen:O,setAttachmentsMenuOpen:R,userMessage:L="",onChangeUserMessage:P,sendMessage:D,listening:k,setEnableFocusChatInput:B,isPlayingAudio:F,stopAudio:U,startListening:z,stopListening:G,customMediaRenderer:j,user:H,userAvatar:V,showUpload:W=!1,experts:q,useMathFormatting:$=!1,isHistoryView:Y=!1,isChatlogPanel:J=!1,showFunctionCache:Z=!1})=>{var X,K,Q,ee,te,ne,ie,re,oe,ae,se,le,ce,ue;const[de,he]=(0,c.useState)(!1),[pe,me]=(0,c.useState)(!1),{t:fe}=Ve(),ge=(0,c.useCallback)((()=>{Y||setTimeout((()=>{var e,t;let n=document.querySelectorAll(".memori-chat-scroll-item");null===(t=null===(e=n[n.length-1])||void 0===e?void 0:e.scrollIntoView)||void 0===t||t.call(e)}),200)}),[Y]),ve=(0,c.useRef)(null),ye=null==p?void 0:p[p.length-1],_e=`${null!==(X=null==p?void 0:p.length)&&void 0!==X?X:0}|${null!==(K=null==ye?void 0:ye.timestamp)&&void 0!==K?K:""}|${(null==ye?void 0:ye.fromUser)?"u":"m"}|${null!==(ee=null===(Q=null==ye?void 0:ye.text)||void 0===Q?void 0:Q.length)&&void 0!==ee?ee:0}|${null!==(ne=null===(te=null==ye?void 0:ye.translatedText)||void 0===te?void 0:te.length)&&void 0!==ne?ne:0}`;(0,c.useEffect)((()=>{E||Y||ve.current!==_e&&(ve.current=_e,ge())}),[E,Y,_e,ge]);return(0,c.useEffect)((()=>{if(!W)return;let e=0;const t=document.getElementById("chat-wrapper"),n=t=>{var n;(null===(n=t.dataTransfer)||void 0===n?void 0:n.types.includes("Files"))&&(e++,1===e&&me(!0))},i=t=>{var n;(null===(n=t.dataTransfer)||void 0===n?void 0:n.types.includes("Files"))&&(e--,0===e&&me(!1))},r=e=>{var t;(null===(t=e.dataTransfer)||void 0===t?void 0:t.types.includes("Files"))&&e.preventDefault()},o=t=>{var n;(null===(n=t.dataTransfer)||void 0===n?void 0:n.types.includes("Files"))&&(e=0,me(!1))};return t&&(t.addEventListener("dragenter",n),t.addEventListener("dragleave",i),t.addEventListener("dragover",r),t.addEventListener("drop",o)),()=>{t&&(t.removeEventListener("dragenter",n),t.removeEventListener("dragleave",i),t.removeEventListener("dragover",r),t.removeEventListener("drop",o))}}),[W]),(0,a.jsxs)("div",{className:t(We)("memori-chat--wrapper",{"memori-chat-wrapper--translate":l,"memori-chat-wrapper--expanded":de,"memori-chat-wrapper--dragging":pe}),id:"chat-wrapper",lang:null==l?void 0:l.toUpperCase(),"data-memori-lang":null!==(ae=null===(oe=null===(re=null===(ie=e.culture)||void 0===ie?void 0:ie.split("-"))||void 0===re?void 0:re[0])||void 0===oe?void 0:oe.toUpperCase())&&void 0!==ae?ae:"EN",children:[pe&&(0,a.jsxs)("div",{className:"memori-chat--drag-overlay",children:[(0,a.jsx)(pM,{className:"memori-chat--drag-overlay-icon"}),(0,a.jsx)("span",{className:"memori-chat--drag-overlay-text",children:null!==(se=fe("upload.dragAndDropFiles"))&&void 0!==se?se:"Drag and drop files here to add them to the chat"})]}),(0,a.jsx)("div",{className:t(We)("memori-chat--history",{"memori-chat--history-touch":IE()}),children:(0,a.jsxs)("div",{className:t(We)("memori-chat--content",{"memori-chat--content-touch":IE()}),children:[(0,a.jsx)("div",{className:t(We)("memori-chat--cover"),style:{backgroundImage:`url("${KT({type:"cover",tenantID:null==n?void 0:n.name,resourceURI:e.coverURL,baseURL:r,apiURL:o})}"), url("${KT({type:"cover",tenantID:null==n?void 0:n.name,baseURL:r||"https://www.aisuru.com",apiURL:o})}")`}}),p.map(((u,d)=>{var h,m,E,A,T,I,M,C;return(0,a.jsxs)(t(c).Fragment,{children:[(0,a.jsx)(aM,{isFirst:0===d,message:u,memori:e,tenant:n,client:s,baseUrl:r,apiUrl:o,sessionID:i,simulateUserPrompt:g,showAIicon:_,showWhyThisAnswer:b,showTranslationOriginal:w,showFeedback:d===p.length-1&&!u.fromUser&&(null==f?void 0:f.acceptsFeedback),user:H,userAvatar:V,experts:q,showCopyButton:x,useMathFormatting:$,showFunctionCache:Z,showReasoning:S},`chatbubble-${d}-${(null===(h=u.text)||void 0===h?void 0:h.includes("<document_attachment"))?"has-attachments":"no-attachments"}-${u.timestamp}`),v&&!!u.timestamp&&(0,a.jsx)("small",{className:"memori-chat--timestamp "+(u.fromUser?"text-right":"text-left"),children:new Intl.DateTimeFormat("it",{hour:"2-digit",minute:"2-digit",second:"2-digit"}).format(new Date(u.timestamp.endsWith("Z")?u.timestamp:`${u.timestamp}Z`))}),y&&!!Object.keys(null!==(m=u.contextVars)&&void 0!==m?m:{}).length&&(0,a.jsx)("div",{className:"memori-chat--context-vars",children:Object.keys(null!==(E=u.contextVars)&&void 0!==E?E:{}).map((e=>{var t,n,i;return"-"===(null===(t=u.contextVars)||void 0===t?void 0:t[e])?(0,a.jsx)("div",{className:"memori-chat--context-tag memori-chat--context-tag-canceled",children:(0,a.jsx)("span",{className:"memori-chat--context-tag-text",children:e})},e):"✔️"===(null===(n=u.contextVars)||void 0===n?void 0:n[e])?(0,a.jsx)("div",{className:"memori-chat--context-tag",children:(0,a.jsx)("span",{className:"memori-chat--context-tag-text",children:e})},e):(0,a.jsx)("div",{className:"memori-chat--context-tag",children:(0,a.jsxs)("span",{className:"memori-chat--context-tag-text",children:[e,": ",null===(i=u.contextVars)||void 0===i?void 0:i[e]]})},e)}))}),(0,a.jsx)(iM,{simulateUserPrompt:g,links:(null===(T=null===(A=null==u?void 0:u.media)||void 0===A?void 0:A.filter((e=>{var t;return!(null===(t=e.properties)||void 0===t?void 0:t.functionSignature)})))||void 0===T?void 0:T.filter((e=>"text/html"===e.mimeType&&!!e.url)))||[],media:[...(null===(M=null===(I=null==u?void 0:u.media)||void 0===I?void 0:I.filter((e=>{var t;return!(null===(t=e.properties)||void 0===t?void 0:t.functionSignature)})))||void 0===M?void 0:M.filter((e=>!("text/html"===e.mimeType&&e.url))))||[],...(()=>{const e=u.translatedText||u.text,t=/<document_attachment filename="([^"]+)" type="([^"]+)">([\s\S]*?)<\/document_attachment>/g,n=[];let i,r=0;for(;null!==(i=t.exec(e));){const[,e,t,o]=i;n.push({mediumID:`doc_${Date.now()}_${r}_${Math.random().toString(36).substr(2,9)}`,url:"",mimeType:t,title:e,content:o.trim(),properties:{isDocumentAttachment:!0},type:"document"}),r++}return n})()],sessionID:i,baseUrl:r,apiUrl:o,translateTo:l,customMediaRenderer:j,fromUser:u.fromUser}),!Y&&!u.fromUser&&(0,a.jsx)(XM,{isChatlogPanel:J,message:u})]},`${d}-${(null===(C=u.text)||void 0===C?void 0:C.includes("<document_attachment"))?"has-attachments":"no-attachments"}-${u.timestamp}`)})),(null==f?void 0:f.hints)&&f.hints.length>0&&!u&&(0,a.jsx)(iM,{simulateUserPrompt:g,hints:f.translatedHints?f.translatedHints:f.hints.map((e=>({text:e,originalText:e})))}),!!u&&(0,a.jsx)(NM,{useDefaultSentences:h,lang:l?"it"===l.toLowerCase()?"it":"en":"it"===(null===(ue=null===(ce=null===(le=e.culture)||void 0===le?void 0:le.split("-"))||void 0===ce?void 0:ce[0])||void 0===ue?void 0:ue.toLowerCase())?"it":"en",sentence:d,sentences:e.enableBoardOfExperts?NI.boardOfExpertsLoadingSentences:void 0},d),(0,a.jsx)("div",{id:"end-messages-ref"})]})}),T&&(0,a.jsx)(TM,{userMessage:L,onChangeUserMessage:P,dialogState:f,instruct:A,authToken:m,sendMessage:D,isTyping:u,microphoneMode:M,sendOnEnter:C,setSendOnEnter:N,client:s,sessionID:i,showUpload:W,attachmentsMenuOpen:O,setAttachmentsMenuOpen:R,onTextareaFocus:()=>{G();IE()&&B(!0)},onTextareaBlur:()=>{var e,t,n,i,r;(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===(r=null===(i=document.querySelector(".memori.memori-widget"))||void 0===i?void 0:i.classList)||void 0===r||r.remove("chat-focused"),ge())},onTextareaExpanded:e=>{he(e)},startListening:z,stopListening:G,stopAudio:U,listening:k,isPlayingAudio:F,showMicrophone:I,memoriID:null==e?void 0:e.memoriID})]})}));c=o("85Hg2"),NI=o("1Lq0j");var QM=({className:e,title:t})=>(0,a.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,a.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 eC=({memoriName:e,blockedUntil:t,notEnoughCredits:n=!1,showGiverInfo:i=!1,showTitle:r=!1,marginLeft:o=!1})=>{const{t:s}=Ve(),l=new Date(t||Date.now());return n||l>new Date(Date.now())?(0,a.jsx)(nI,{className:"blocked-memori-badge--tooltip",content:n?(0,a.jsx)(a.Fragment,{children:s("notEnoughCredits")}):(0,a.jsxs)(a.Fragment,{children:[!i&&s("memoriBlockedAnon",{name:e,date:new Intl.DateTimeFormat("it",{day:"numeric",month:"long",year:"numeric"}).format(l)}),i&&s("memoriBlockedUntil",{date:new Intl.DateTimeFormat("it",{day:"numeric",month:"long",year:"numeric"}).format(l)}),i&&` ${s("memoriBlockedReasonExceedChats")}`,i&&(0,a.jsx)("br",{}),i&&`\n${s("memoriBlockedGiverHelper")}`]}),children:(0,a.jsxs)("div",{className:"blocked-memori-badge--wrapper",children:[(0,a.jsx)("div",{className:"blocked-memori-badge "+(o?" margin-left":""),children:(0,a.jsx)(QM,{className:"blocked-memori-badge--icon"})}),r&&(0,a.jsx)("span",{className:"blocked-memori-badge--title",children:s("memoriBlockedTitle")})]})}):null};var tC=({className:e,title:t})=>(0,a.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,a.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 nC=({className:e,title:t})=>(0,a.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,a.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,a.jsx)("path",{d:"M27.917 12L31.417 12"}),(0,a.jsx)("path",{d:"M27.917 26L31.417 26"}),(0,a.jsx)("path",{d:"M29.667 12L29.667 26"}),(0,a.jsx)("path",{d:"M23.992 26L19.904 12 19.226 12 15.159 26"}),(0,a.jsx)("path",{d:"M16.854 21.133L22.276 21.133"})]});c=o("85Hg2");var iC=({className:e,title:t})=>(0,a.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,a.jsx)("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"1.5"}),(0,a.jsx)("path",{d:"M12 17V11",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),(0,a.jsx)("circle",{cx:"1",cy:"1",r:"1",transform:"matrix(1 0 0 -1 11 9)",fill:"currentColor"})]});const rC={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 oC=({forceStatus:e,provider:t="Anthropic"})=>{const{t:n}=Ve(),[i,r]=(0,c.useState)(null!=e?e:"operational"),[o,s]=(0,c.useState)(!1),l=rC[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.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){s(!0);try{const e=await u();t&&r(e)}catch(e){console.error("Failed to check status:",e),t&&r("operational")}finally{t&&s(!1)}}})(),()=>{t=!1,n.abort()}}),[e,u]),o)return(0,a.jsx)("div",{className:"memori--completion-provider-status--loading",children:(0,a.jsx)(Yl,{spinning:!0})});if(!i||"operational"===i)return null;const{Icon:d,message:h,className:p}=(()=>{switch(i){case"major_outage":return{Icon:zM,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:QM,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:iC,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,a.jsx)(nI,{className:"memori--completion-provider-status--tooltip",align:"right",content:(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{children:h}),(null==l?void 0:l.statusPage)&&(0,a.jsx)("p",{children:(0,a.jsx)("a",{href:l.statusPage,rel:"noopener noreferrer",target:"_blank",children:n("completionProviderCheckStatusPage")})})]}),children:(0,a.jsx)(d,{className:`memori--completion-provider-status--icon ${p}`})})};var aC=({className:e,title:t})=>(0,a.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,a.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 sC=({memori:e,tenant:t,language:n,userLang:i,setUserLang:r,baseUrl:o,apiUrl:s,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:b,notEnoughCredits:x=!1,isMultilanguageEnabled:w})=>{var S,E,A,T;const{t:I,i18n:M}=Ve(),[C,N]=(0,c.useState)(e.description),[O,R]=(0,c.useState)(!0);return(0,c.useEffect)((()=>{var t,i,r,a,s,l;(null!==(i=null===(t=M.language)||void 0===t?void 0:t.toUpperCase())&&void 0!==i?i:"IT")===(null!==(r=null==n?void 0:n.toUpperCase())&&void 0!==r?r:"IT")&&C===e.description||!(null===(a=e.description)||void 0===a?void 0:a.length)||YI(e.description,null!==(l=null===(s=M.language)||void 0===s?void 0:s.toUpperCase())&&void 0!==l?l:"IT",n,o).then((e=>{N(e.text)})).catch(console.error)}),[M.language,n,e.description,o]),(0,a.jsxs)("div",{className:"memori--start-panel",children:[(0,a.jsxs)("div",{className:"memori--cover",style:{backgroundImage:`url("${KT({type:"cover",tenantID:null==t?void 0:t.name,resourceURI:e.coverURL,baseURL:o,apiURL:s})}"), url("${KT({type:"cover",tenantID:null==t?void 0:t.name,baseURL:o,apiURL:s})}")`},children:[!!e.enableCompletions&&!e.enableBoardOfExperts&&(0,a.jsx)("div",{className:"memori--completions-enabled",children:(0,a.jsx)(nI,{align:"left",content:I("completionsEnabled"),children:(0,a.jsx)("span",{"aria-label":I("completionsEnabled")||"Completions",children:(0,a.jsx)(eI,{})})})}),!!e.enableBoardOfExperts&&(0,a.jsx)("div",{className:"memori--board-of-experts",children:(0,a.jsx)(nI,{align:"left",content:I("boardOfExperts"),children:(0,a.jsx)("span",{"aria-label":I("boardOfExperts")||"Board of Experts",children:(0,a.jsx)(tC,{})})})}),!!e.nsfw&&(0,a.jsx)("div",{className:"memori--nsfw",children:(0,a.jsx)(nI,{align:"left",content:I("nsfw"),children:(0,a.jsx)("span",{title:I("nsfw")||"NSFW",children:"🔞"})})})]}),(0,a.jsxs)("picture",{className:"memori--avatar",children:[(0,a.jsx)("source",{src:null!==(S=e.avatarURL)&&void 0!==S?S:KT({type:"avatar",tenantID:null==t?void 0:t.name,resourceURI:e.avatarURL,baseURL:o,apiURL:s})}),(0,a.jsx)("img",{alt:e.name,src:e.avatarURL&&e.avatarURL.length>0?KT({type:"avatar",tenantID:null==t?void 0:t.name,resourceURI:e.avatarURL,baseURL:o,apiURL:s}):KT({type:"avatar",tenantID:null==t?void 0:t.name,baseURL:o,apiURL:s})})]}),(0,a.jsx)("h2",{className:"memori--title",children:e.name}),e.needsPosition&&!l&&(0,a.jsxs)("div",{className:"memori--needsPosition",children:[(0,a.jsx)("p",{children:I("write_and_speak.requirePositionHelp",{name:e.name})}),(0,a.jsx)(Jl,{primary:!0,onClick:()=>u(),className:"memori--start-button",icon:(0,a.jsx)(aC,{}),children:I("widget.position")})]}),(e.needsPosition&&l||!e.needsPosition)&&!!e.requireLoginToken&&!v&&(0,a.jsxs)("div",{className:"memori--needsLogin",children:[(0,a.jsx)("p",{children:I("write_and_speak.requirePositionHelp",{name:e.name})}),(0,a.jsx)(Jl,{primary:!0,onClick:()=>b(!0),className:"memori--start-button",icon:(0,a.jsx)(QT,{}),children:I("login.login")||"Login"})]}),(e.needsPosition&&l||!e.needsPosition)&&(!e.requireLoginToken||e.requireLoginToken&&v)&&(0,a.jsxs)("div",{className:"memori--description",children:[(0,a.jsxs)("p",{children:[(0,a.jsx)(BI,{className:"memori--description-text",rows:3,children:C&&O?C:e.description}),C!==e.description&&(0,a.jsx)(Jl,{ghost:!0,className:"memori--translation-toggle",icon:(0,a.jsx)(tI,{}),onClick:()=>{R((e=>!e))},children:I(O?"showOriginalText":"showTranslatedText")})]}),w&&!d&&(0,a.jsxs)("div",{className:"memori--language-chooser",children:[(0,a.jsx)("label",{id:"user-lang-pref-label",htmlFor:"user-lang-pref",children:I("write_and_speak.iWantToTalkToIn",{name:e.name})}),(0,a.jsxs)("select",{id:"user-lang-pref",className:"memori-select--button",value:(null!=i?i:M.language).toUpperCase(),"aria-labelledby":"user-lang-pref-label",onChange:e=>{r(e.target.value)},children:[(0,a.jsx)("optgroup",{label:I("popularLanguages")||"Popular",children:(0,NI.getGroupedChatLanguages)().popular.map((e=>(0,a.jsx)("option",{value:e.value,"aria-label":e.label,children:e.label},`popular-${e.value}`)))}),(0,a.jsx)("optgroup",{label:I("allLanguages")||"All Languages",children:(0,NI.getGroupedChatLanguages)().all.map((e=>(0,a.jsx)("option",{value:e.value,"aria-label":e.label,children:e.label},`all-${e.value}`)))})]})]}),(0,a.jsxs)("div",{className:"memori--start-privacy-explanation-container",children:[(0,a.jsx)("p",{className:"memori--start-privacy-explanation",children:I("write_and_speak.pagePrivacyExplanation")}),(0,a.jsx)(nI,{align:"right",content:(0,a.jsxs)("div",{className:"memori--privacy-tooltip-content",children:[(0,a.jsxs)("p",{children:[" ",I("write_and_speak.pagePrivacyExplanationList.allConversations")]}),(0,a.jsx)("ul",{className:"memori--privacy-tooltip-content-list",children:v?(0,a.jsx)("li",{children:I("write_and_speak.pagePrivacyExplanationList.contentAndUsername")}):(0,a.jsx)("li",{children:I("write_and_speak.pagePrivacyExplanationList.contentAndIpAddress")})}),(0,a.jsx)("p",{children:I("write_and_speak.pagePrivacyExplanationList.authorUsesInfo")}),(0,a.jsx)("a",{href:null!==(E=null==t?void 0:t.privacyPolicyURL)&&void 0!==E?E:"https://memori.ai/en/privacy-policy",target:"_blank",rel:"noopener noreferrer",children:null!==(A=null==t?void 0:t.privacyPolicyURL)&&void 0!==A?A:I("privacyPolicy")})]}),children:(0,a.jsx)(EI,{className:"memori--start-privacy-explanation-icon"})})]}),(0,a.jsx)(Jl,{primary:!0,disabled:!!e.blockedUntil&&!e.isGiver||x,loading:p,onClick:e=>{try{window.speechSynthesis.speak(new SpeechSynthesisUtterance(""))}catch(e){console.error(e)}f&&f(),m&&m()},className:"memori--start-button",children:I("write_and_speak."+(d?"instructButton":h?"resumeButton":"tryMeButton"))}),(0,a.jsx)(oC,{provider:null===(T=null==e?void 0:e.completionConfigForQuestionAnswering)||void 0===T?void 0:T.provider,forceStatus:g}),(0,a.jsx)("p",{className:"memori--start-description",children:I(d?"write_and_speak.pageInstructExplanation":"write_and_speak.pageTryMeExplanation")}),(e.blockedUntil||x)&&(0,a.jsx)(eC,{memoriName:e.name,blockedUntil:e.blockedUntil,notEnoughCredits:x,showGiverInfo:e.isGiver,showTitle:!0,marginLeft:!0}),!!e.enableDeepThought&&!d&&(0,a.jsxs)("div",{className:"memori--deep-thought-disclaimer",children:[(0,a.jsx)(nI,{align:"left",content:I("deepThoughtHelper"),children:(0,a.jsx)(nC,{})}),(0,a.jsx)("h2",{children:v&&(null==y?void 0:y.pAndCUAccepted)?I("deepThoughtDisclaimerTitle"):I("deepThought")}),v&&!(null==y?void 0:y.pAndCUAccepted)&&(0,a.jsx)("p",{children:I("deepThoughtPreDisclaimerNotAllowed")}),!v&&(0,a.jsx)("p",{children:I("deepThoughtPreDisclaimerUnlogged")}),!v&&_&&(0,a.jsx)("p",{children:(0,a.jsx)(Jl,{outlined:!0,padded:!1,onClick:()=>b(!0),children:I("login.login")||"Login"})}),(0,a.jsx)("p",{className:"memori--deep-thought-disclaimer-text",children:I("deepThoughtDisclaimer")})]})]})]})},lC=(c=o("85Hg2"),c=o("85Hg2"),{}),cC={};(cC=function(e,t){if(null==e)return{};var n,i,r={},o=Object.keys(e);for(i=0;i<o.length;i++)n=o[i],t.indexOf(n)>=0||(r[n]=e[n]);return r}).__esModule=!0,cC.default=cC,(lC=function(e,t){if(null==e)return{};var n,i,r=cC(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(i=0;i<o.length;i++)n=o[i],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}).__esModule=!0,lC.default=lC;c=o("85Hg2");var uC=["forwardedRef"];function dC(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function hC(e){for(var n=1;n<arguments.length;n++){var i=null!=arguments[n]?arguments[n]:{};n%2?dC(Object(i),!0).forEach((function(n){t(fe)(e,n,i[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):dC(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}class pC 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,a.jsxs)("div",{style:{background:"rgba(255, 255, 255, 0.4)",color:"#000",padding:"2rem",borderRadius:"10px"},children:[(0,a.jsx)("h2",{children:this.props.t("error.generic")}),(0,a.jsx)(Jl,{primary:!0,onClick:()=>this.setState({hasError:!1}),children:this.props.t("error.tryAgain")||"Try again"})]}):this.props.children}}var mC=function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(i){function r(r){var o=r.forwardedRef,a=t(lC)(r,uC),s=Ve(e,hC(hC({},a),{},{keyPrefix:n.keyPrefix})),l=t(ce)(s,3),u=l[0],d=l[1],h=l[2],p=hC(hC({},a),{},{t:u,i18n:d,tReady:h});return n.withRef&&o?p.ref=o:!n.withRef&&o&&(p.forwardedRef=o),(0,c.createElement)(i,p)}r.displayName="withI18nextTranslation(".concat(ze(i),")"),r.WrappedComponent=i;return n.withRef?(0,c.forwardRef)((function(e,t){return(0,c.createElement)(r,Object.assign({},e,{forwardedRef:t}))})):r}}(["common"])(pC);var fC=({avatar:e,speaking:n=!1})=>(0,a.jsxs)("div",{className:t(We)("memori-blob",{"memori-blob--speaking":n}),children:[e&&(0,a.jsx)("figure",{children:(0,a.jsx)("img",{src:e,alt:"",role:"presentation"})}),(0,a.jsx)("div",{className:"mainDiv"}),(0,a.jsx)("div",{className:"mainDiv"}),(0,a.jsx)("div",{className:"mainDiv"}),(0,a.jsx)("div",{className:"mainDiv"}),(0,a.jsx)("div",{className:"mainDiv"})]});var gC=({className:e,title:t})=>(0,a.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,a.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 vC=({className:e,title:t})=>(0,a.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,a.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,a.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 yC=({className:e,title:t})=>(0,a.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,a.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"})}),_C=(c=o("85Hg2"),c=o("85Hg2"),c=o("85Hg2"),{});Object.defineProperty(_C,"__esModule",{value:!0});c=o("85Hg2");function bC(e){var t,n=new Set,i=function(e,i){var r="function"==typeof e?e(t):e;if(r!==t){var o=t;t=i?r:Object.assign({},t,r),n.forEach((function(e){return e(t,o)}))}},r=function(){return t},o={setState:i,getState:r,subscribe:function(e,i,o){return i||o?function(e,i,o){void 0===i&&(i=r),void 0===o&&(o=Object.is),console.warn("[DEPRECATED] Please use `subscribeWithSelector` middleware");var a=i(t);function s(){var n=i(t);if(!o(a,n)){var r=a;e(a=n,r)}}return n.add(s),function(){return n.delete(s)}}(e,i,o):(n.add(e),function(){return n.delete(e)})},destroy:function(){return n.clear()}};return t=e(i,r,o),o}var xC="undefined"==typeof window||!window.navigator||/ServerSideRendering|^Deno\//.test(window.navigator.userAgent)?c.useEffect:c.useLayoutEffect;_C.default=function(e){var t="function"==typeof e?bC(e):e,n=function(e,n){void 0===e&&(e=t.getState),void 0===n&&(n=Object.is);var i,r=c.useReducer((function(e){return e+1}),0)[1],o=t.getState(),a=c.useRef(o),s=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;(a.current!==o||s.current!==e||l.current!==n||u.current)&&(i=e(o),h=!n(d.current,i)),xC((function(){h&&(d.current=i),a.current=o,s.current=e,l.current=n,u.current=!1}));var p=c.useRef(o);xC((function(){var e=function(){try{var e=t.getState(),n=s.current(e);l.current(d.current,n)||(a.current=e,d.current=n,r())}catch(e){u.current=!0,r()}},n=t.subscribe(e);return t.getState()!==p.current&&e(),n}),[]);var m=h?i: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 wC;wC=o("YtP34");var SC,EC=o("kMsGZ");SC=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 i,r,o;if(Array.isArray(t)){if((i=t.length)!=n.length)return!1;for(r=i;0!=r--;)if(!e(t[r],n[r]))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((i=(o=Object.keys(t)).length)!==Object.keys(n).length)return!1;for(r=i;0!=r--;)if(!Object.prototype.hasOwnProperty.call(n,o[r]))return!1;for(r=i;0!=r--;){var a=o[r];if(!e(t[a],n[a]))return!1}return!0}return t!=t&&n!=n};const AC=[];function TC(e,n,i,r=0,o=!1){for(const e of n)if(t(SC)(i,e.args)){if(o)return;if(e.error)throw e.error;if(e.response)return e.response;throw e.promise}const a={args:i,promise:e(...i).then((e=>a.response=null==e||e)).catch((e=>a.error=null!=e?e:"unknown error")).then((()=>{r>0&&setTimeout((()=>{const e=n.indexOf(a);-1!==e&&n.splice(e,1)}),r)}))};if(n.push(a),!o)throw a.promise}function IC(e,...n){if(void 0===n||0===n.length)e.splice(0,e.length);else{const i=e.find((e=>t(SC)(n,e.args)));if(i){const t=e.indexOf(i);-1!==t&&e.splice(t,1)}}}function MC(e,...t){return TC(e,AC,t,MC.lifespan)}MC.lifespan=0,MC.clear=(...e)=>IC(AC,...e),MC.preload=(e,...t)=>{TC(e,AC,t,MC.lifespan,!0)},MC.peek=(...e)=>{var n;return null==(n=AC.find((n=>t(SC)(e,n.args))))?void 0:n.response};var CC,NC=function(e){return function(t){e.forEach((function(e){"function"==typeof e?e(t):null!=e&&(e.current=t)}))}};c=o("85Hg2");function OC(e,t,n){var i,r,o,a,s;function l(){var c=Date.now()-a;c<t&&c>=0?i=setTimeout(l,t-c):(i=null,n||(s=e.apply(o,r),o=r=null))}null==t&&(t=100);var c=function(){o=this,r=arguments,a=Date.now();var c=n&&!i;return i||(i=setTimeout(l,t)),c&&(s=e.apply(o,r),o=r=null),s};return c.clear=function(){i&&(clearTimeout(i),i=null)},c.flush=function(){i&&(s=e.apply(o,r),o=r=null,clearTimeout(i),i=null)},c}function RC(e){let{debounce:n,scroll:i,polyfill:r,offsetSize:o}=void 0===e?{debounce:0,scroll:!1,offsetSize:!1}:e;const a=r||("undefined"==typeof window?class{}:window.ResizeObserver);if(!a)throw new Error("This browser does not support ResizeObserver out of the box. See: https://github.com/react-spring/react-use-measure/#resize-observer-polyfills");const[s,l]=(0,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:s}),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:i,bottom:r,right:a,x:s,y:c}=u.current.element.getBoundingClientRect(),d={left:e,top:t,width:n,height:i,bottom:r,right:a,x:s,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&&!DC(u.current.lastBounds,d)&&l(u.current.lastBounds=d)};return[e,h?t(CC)(e,h):e,d?t(CC)(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 a(g),u.current.resizeObserver.observe(u.current.element),i&&u.current.scrollContainers&&u.current.scrollContainers.forEach((e=>e.addEventListener("scroll",g,{capture:!0,passive:!0}))))}var _,b,x;return _=g,b=Boolean(i),(0,c.useEffect)((()=>{if(b){const e=_;return window.addEventListener("scroll",e,{capture:!0,passive:!0}),()=>{window.removeEventListener("scroll",e,!0)}}}),[_,b]),x=f,(0,c.useEffect)((()=>{const e=x;return window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}}),[x]),(0,c.useEffect)((()=>{v(),y()}),[i,g,f]),(0,c.useEffect)((()=>v),[]),[e=>{e&&e!==u.current.element&&(v(),u.current.element=e,u.current.scrollContainers=LC(e),y())},s,m]}function LC(e){const t=[];if(!e||e===document.body)return t;const{overflow:n,overflowX:i,overflowY:r}=window.getComputedStyle(e);return[n,i,r].some((e=>"auto"===e||"scroll"===e))&&t.push(e),[...t,...LC(e.parentElement)]}OC.debounce=OC,CC=OC;const PC=["x","y","top","bottom","left","right","width","height"],DC=(e,t)=>PC.every((n=>e[n]===t[n]));const kC={obj:e=>e===Object(e)&&!kC.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(kC.str(e)||kC.num(e)||kC.obj(e))return e===t;if(kC.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!kC.und(n)||e===t}};function BC(e){return(e.eventObject||e.object).uuid+"/"+e.index+e.instanceId}function FC(e,t,n,i){const r=n.get(t);r&&(n.delete(t),0===n.size&&(e.delete(i),r.target.releasePointerCapture(i)))}function UC(e){const t=new Tc.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 i(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 i=e.eventObject.__r3f,r=null==i?void 0:i.handlers;if(n.hovered.delete(BC(e)),null!=i&&i.eventCount){const n={...e,intersections:t||[]};null==r.onPointerOut||r.onPointerOut(n),null==r.onPointerLeave||r.onPointerLeave(n)}}}))}function r(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()=>i([]);case"onLostPointerCapture":return t=>{const{internal:n}=e.getState();"pointerId"in t&&!n.capturedMap.has(t.pointerId)&&(n.capturedMap.delete(t.pointerId),i([]))}}return a=>{const{onPointerMissed:s,internal:l}=e.getState();!function(t){var n;const i=e.getState(),{raycaster:r,mouse:o,camera:a,size:s}=i,{offsetX:l,offsetY:c}=null!=(n=null==r.computeOffsets?void 0:r.computeOffsets(t,i))?n:t,{width:u,height:d}=s;o.set(l/u*2-1,-c/d*2+1),r.setFromCamera(o,a)}(a),l.lastEvent.current=a;const c="onPointerMove"===o,u="onClick"===o||"onContextMenu"===o||"onDoubleClick"===o,d=function(t,n){const{internal:i}=e.getState();if("pointerId"in n&&i.capturedMap.has(n.pointerId))for(let e of i.capturedMap.get(n.pointerId).values())t.push(e.intersection);return t}(function(t){const n=e.getState(),{raycaster:i,internal:r}=n;if(!i.enabled)return[];const o=new Set,a=[],s=t?t(r.interaction):r.interaction;let l=i.intersectObjects(s,!0).filter((e=>{const t=BC(e);return!o.has(t)&&(o.add(t),!0)}));i.filter&&(l=i.filter(l,n));for(const e of l){let t=e.object;for(;t;){var c;null!=(c=t.__r3f)&&c.eventCount&&a.push({...e,eventObject:t}),t=t.parent}}return a}(c?n:void 0),a),h=u?function(t){const{internal:n}=e.getState(),i=t.offsetX-n.initialClick[0],r=t.offsetY-n.initialClick[1];return Math.round(Math.sqrt(i*i+r*r))}(a):0;"onPointerDown"===o&&(l.initialClick=[a.offsetX,a.offsetY],l.initialHits=d.map((e=>e.eventObject))),u&&!d.length&&h<=2&&(r(a,l.interaction),s&&s(a)),c&&i(d),function(n,r,o,a){const{raycaster:s,mouse:l,camera:c,internal:u}=e.getState();if(n.length){const e=t.set(l.x,l.y,0).unproject(c),d={stopped:!1};for(const t of n){const h=e=>{var n,i;return null!=(n=null==(i=u.capturedMap.get(e))?void 0:i.has(t.eventObject))&&n},p=e=>{const n={intersection:t,target:r.target};u.capturedMap.has(e)?u.capturedMap.get(e).set(t.eventObject,n):u.capturedMap.set(e,new Map([[t.eventObject,n]])),r.target.setPointerCapture(e)},m=e=>{const n=u.capturedMap.get(e);n&&FC(u.capturedMap,t.eventObject,n,e)};let f={};for(let e in r){let t=r[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:s.ray,camera:c,stopPropagation:()=>{const e="pointerId"in r&&u.capturedMap.get(r.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)))&&i([...n.slice(0,n.indexOf(t)),t])},target:{hasPointerCapture:h,setPointerCapture:p,releasePointerCapture:m},currentTarget:{hasPointerCapture:h,setPointerCapture:p,releasePointerCapture:m},sourceEvent:r,nativeEvent:r};if(a(g),!0===d.stopped)break}}}(d,a,h,(e=>{const t=e.eventObject,n=t.__r3f,i=null==n?void 0:n.handlers;if(null!=n&&n.eventCount)if(c){if(i.onPointerOver||i.onPointerEnter||i.onPointerOut||i.onPointerLeave){const t=BC(e),n=l.hovered.get(t);n?n.stopped&&e.stopPropagation():(l.hovered.set(t,e),null==i.onPointerOver||i.onPointerOver(e),null==i.onPointerEnter||i.onPointerEnter(e))}null==i.onPointerMove||i.onPointerMove(e)}else{const n=i[o];n?u&&!l.initialHits.includes(t)||(r(a,l.interaction.filter((e=>!l.initialHits.includes(e)))),n(e)):u&&l.initialHits.includes(t)&&r(a,l.interaction.filter((e=>!l.initialHits.includes(e))))}}))}}}}const zC=e=>e&&!!e.getState,GC=(e,t)=>{var n,i;return{root:zC(e)?e:null!=(n=null==(i=e.__r3f)?void 0:i.root)?n:t.__r3f.root,container:zC(e)?e.getState().scene:e}},jC="__default",HC={};let VC={};function WC(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 qC=e=>e&&e.isOrthographicCamera;function $C(e){return Array.isArray(e)?Math.min(Math.max(e[0],window.devicePixelRatio),e[1]):e}const YC=c.createContext(null);let JC,ZC=[],XC=[],KC=[];function QC(e,t){for(JC=0;JC<e.length;JC++)e[JC](t)}function eN(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),JC=0;JC<t.internal.subscribers.length;JC++)t.internal.subscribers[JC].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 tN(e){const{handlePointer:t}=UC(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 i;const{set:r,events:o}=e.getState();null==o.disconnect||o.disconnect(),r((e=>({events:{...e.events,connected:t}}))),Object.entries(null!=(i=null==o?void 0:o.handlers)?i:[]).forEach((([e,i])=>{const[r,o]=n[e];t.addEventListener(r,i,{passive:o})}))},disconnect:()=>{const{set:t,events:i}=e.getState();var r;i.connected&&(Object.entries(null!=(r=i.handlers)?r:[]).forEach((([e,t])=>{if(i&&i.connected instanceof HTMLElement){const[r]=n[e];i.connected.removeEventListener(r,t)}})),t((e=>({events:{...e.events,connected:!1}}))))}}}const nN="undefined"!=typeof window?c.useLayoutEffect:c.useEffect;function iN({set:e}){return nN((()=>(e(new Promise((()=>null))),()=>e(!1))),[]),null}class rN 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}}rN.getDerivedStateFromError=()=>({error:!0});const oN=c.forwardRef((function({children:e,fallback:n,tabIndex:i,resize:r,id:o,style:a,className:s,events:l,...u},d){const[h,{width:p,height:m}]=RC({scroll:!0,debounce:{scroll:50,resize:0},...r}),f=c.useRef(null),[g,v]=c.useState(!1),[y,_]=c.useState(!1);if(g)throw g;if(y)throw y;return nN((()=>{p>0&&m>0&&function(e,n,{gl:i,size:r,mode:o=pN[1],events:a,onCreated:s,...l}={}){var u,d,h,p,m;r||(r={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=hN.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||kC.equ(y.viewport.dpr,$C(l.dpr))||y.setDpr(l.dpr),y.size.width===r.width&&y.size.height===r.height||y.setSize(r.width,r.height),y.frameloop!==l.frameloop&&y.setFrameloop(l.frameloop);l.linear!==y.internal.lastProps.linear&&(_N(n),g=void 0)}if(!g){const e=((e,t)=>{const n="function"==typeof e?e(t):e;if(i=n,null!=i&&i.render)return n;var i;const r=new Tc.WebGLRenderer({powerPreference:"high-performance",canvas:t,antialias:!0,alpha:!0,...e});r.outputEncoding=Tc.sRGBEncoding,r.toneMapping=Tc.ACESFilmicToneMapping,e&&vN(r,e);return r})(i,n);l.vr&&(e.xr.enabled=!0,e.setAnimationLoop((e=>fN(e,!0)))),v=((e,n,i,r)=>{const{gl:o,size:a,shadows:s=!1,linear:l=!1,flat:u=!1,vr:d=!1,orthographic:h=!1,frameloop:p="always",dpr:m=1,performance:f,clock:g=new Tc.Clock,raycaster:v,camera:y,onPointerMissed:_}=r;s&&(o.shadowMap.enabled=!0,"object"==typeof s?Object.assign(o.shadowMap,s):o.shadowMap.type=Tc.PCFSoftShadowMap),l&&(o.outputEncoding=Tc.LinearEncoding),u&&(o.toneMapping=Tc.NoToneMapping),"never"===p&&(g.stop(),g.elapsedTime=0);const b=t(_C)(((t,a)=>{const s=new Tc.Raycaster,{params:b,...x}=v||{};e(s,{enabled:!0,...x,params:{...s.params,...b}});const w=y instanceof Tc.Camera,S=w?y:h?new Tc.OrthographicCamera(0,0,0,0,.1,1e3):new Tc.PerspectiveCamera(75,0,.1,1e3);w||(S.position.z=5,y&&e(S,y),null!=y&&y.rotation||S.lookAt(0,0,0));const E=$C(m),A=new Tc.Vector3,T=new Tc.Vector3,I=new Tc.Vector3;function M(e=a().camera,t=T,n=a().size){const{width:i,height:r}=n,o=i/r;t instanceof Tc.Vector3?I.copy(t):I.set(...t);const s=e.getWorldPosition(A).distanceTo(I);if(qC(e))return{width:i/e.zoom,height:r/e.zoom,factor:1,distance:s,aspect:o};{const t=e.fov*Math.PI/180,n=2*Math.tan(t/2)*s,a=n*(i/r);return{width:a,height:n,factor:i/a,distance:s,aspect:o}}}let C;const N=e=>t((t=>({performance:{...t.performance,current:e}})));return{gl:o,set:t,get:a,invalidate:()=>n(a()),advance:(e,t)=>i(e,t,a()),linear:l,flat:u,scene:WC(new Tc.Scene),camera:S,controls:null,raycaster:s,clock:g,mouse:new Tc.Vector2,vr:d,frameloop:p,onPointerMissed:_,performance:{current:1,min:.5,max:1,debounce:200,...f,regress:()=>{const e=a();C&&clearTimeout(C),e.performance.current!==e.performance.min&&N(e.performance.min),C=setTimeout((()=>N(a().performance.max)),e.performance.debounce)}},size:{width:0,height:0},viewport:{initialDpr:E,dpr:E,width:0,height:0,aspect:0,distance:0,factor:0,getCurrentViewport:M},setSize:(e,n)=>{const i={width:e,height:n};t((e=>({size:i,viewport:{...e.viewport,...M(S,T,i)}})))},setDpr:e=>t((t=>({viewport:{...t.viewport,dpr:$C(e)}}))),setFrameloop:(e="always")=>t((()=>({frameloop:e}))),events:{connected:!1},internal:{active:!1,priority:0,frames:0,lastProps:r,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))}})))})}}})),x=b.getState();let w=x.size,S=x.viewport.dpr;return b.subscribe((()=>{const{camera:e,size:t,viewport:n,internal:i}=b.getState();t===w&&n.dpr===S||(e.manual||i.lastProps.camera instanceof Tc.Camera||(qC(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),w=t,S=n.dpr)})),a&&x.setSize(a.width,a.height),b.subscribe((e=>n(e))),b})(vN,mN,fN,{gl:e,size:r,...l});const s=v.getState();g=gN.createContainer(v,pN.indexOf(o),!1,null),hN.set(n,{fiber:g,store:v}),a&&s.set({events:a(v)})}if(v&&g)return gN.updateContainer(c.createElement(yN,{store:v,element:e,onCreated:s,target:n}),g,null,(()=>{})),v;throw"Error creating root!"}(c.createElement(rN,{set:_},c.createElement(c.Suspense,{fallback:c.createElement(iN,{set:v})},e)),f.current,{...u,size:{width:p,height:m},events:l||tN})}),[p,m,e]),nN((()=>{const e=f.current;return()=>_N(e)}),[]),c.createElement("div",{ref:h,id:o,className:s,tabIndex:i,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden",...a}},c.createElement("canvas",{ref:NC([f,d]),style:{display:"block"}},n))}));function aN(){const e=c.useContext(YC);if(!e)throw"R3F hooks can only be used within the Canvas component!";return e}function sN(e=(e=>e),t){return aN()(e,t)}function lN(e,t=0){const n=aN().getState().internal.subscribe,i=c.useRef(e);return c.useLayoutEffect((()=>{i.current=e}),[e]),c.useLayoutEffect((()=>n(i,t)),[t,n]),null}function cN(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 uN(e,t){return function(n,...i){const r=new n;return e&&e(r),Promise.all(i.map((e=>new Promise(((n,i)=>r.load(e,(e=>{e.scene&&Object.assign(e,cN(e.scene)),n(e)}),t,(t=>i(`Could not load ${e}: ${t.message}`))))))))}}function dN(e,t,n,i){const r=Array.isArray(t)?t:[t],o=MC(uN(n,i),e,...r);return Array.isArray(t)?o:o[0]}dN.preload=function(e,t,n){const i=Array.isArray(t)?t:[t];return MC.preload(uN(n),e,...i)},dN.clear=function(e,t){const n=Array.isArray(t)?t:[t];return MC.clear(e,...n)};const hN=new Map,pN=["legacy","blocking","concurrent"],{invalidate:mN,advance:fN}=function(e){let t,n=!1;function i(r){if(n=!0,t=0,QC(ZC,r),e.forEach((e=>{const n=e.store.getState();n.internal.active&&("always"===n.frameloop||n.internal.frames>0)&&(t+=eN(r,n))})),QC(XC,r),t>0)return requestAnimationFrame(i);QC(KC,r),n=!1}return{loop:i,invalidate:function t(r){if(!r)return e.forEach((e=>t(e.store.getState())));!r.vr&&r.internal.active&&"never"!==r.frameloop&&(r.internal.frames=Math.min(60,r.internal.frames+1),n||(n=!0,requestAnimationFrame(i)))},advance:function(t,n=!0,i){n&&QC(ZC,t),i?eN(t,i):e.forEach((e=>eN(t,e.store.getState()))),n&&QC(XC,t)}}}(hN),{reconciler:gN,applyProps:vN}=function(e){function n(e,{children:t,key:n,ref:i,...r},{children:o,key:a,ref:s,...l}={},c=!1){var u;const d=null!=(u=null==e?void 0:e.__r3f)?u:{},h=Object.entries(r),p=[];if(c){const e=Object.keys(l);for(let t=0;t<e.length;t++)r.hasOwnProperty(e[t])||h.unshift([e[t],jC+"remove"])}h.forEach((([t,n])=>{var i;if(null!=(i=e.__r3f)&&i.primitive&&"object"===t)return;if(function(e,t){return!(!kC.arr(e)||!kC.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 r=[];t.includes("-")&&(r=t.split("-")),p.push([t,n,!1,r])}));const m={...r};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 i(e,t){var i,a,s;const l=null!=(i=null==e?void 0:e.__r3f)?i:{},c=l.root,u=null!=(a=null==c||null==c.getState?void 0:c.getState())?a:{},{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,i,o])=>{var a;let s=e,c=s[t];if(o.length&&(c=o.reduce(((e,t)=>e[t]),e),!c||!c.set)){const[n,...i]=o.reverse();s=i.reverse().reduce(((e,t)=>e[t]),e),t=n}if(n===jC+"remove")if(c&&c.constructor)n=new c.constructor(d.args);else if(s.constructor){const e=new s.constructor(s.__r3f.memoizedProps.args);n=e[c],e.dispose&&e.dispose()}else n=0;const h=(null==u||null==(a=u.gl)?void 0:a.outputEncoding)===Tc.LinearEncoding;if(i)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 Tc.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 Tc.Color;!e&&c.setScalar?c.setScalar(n):c instanceof Tc.Layers&&n instanceof Tc.Layers?c.mask=n.mask:c.set(n),!h&&e&&c.convertSRGBToLinear()}}else s[t]=n,!h&&s[t]instanceof Tc.Texture&&(s[t].encoding=Tc.sRGBEncoding);r(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!=(s=e.__r3f)&&s.parent&&o(e),e}function r(e){var t,n;const i=null==(t=e.__r3f)||null==(n=t.root)||null==n.getState?void 0:n.getState();i&&0===i.internal.frames&&i.invalidate()}function o(e){null==e.onUpdate||e.onUpdate(e)}function a(e,{args:t=[],...n},r,o,a){let s,l=`${e[0].toUpperCase()}${e.slice(1)}`;if(!zC(r)&&a){const e=t=>t.return?e(t.return):t.stateNode&&t.stateNode.containerInfo;r=e(a)}if(!r||!zC(r))throw`No valid root for ${l}!`;if("primitive"===e){if(void 0===n.object)throw"Primitives without 'object' are invalid!";s=WC(n.object,{root:r,primitive:!0})}else{const e=VC[l]||Tc[l];if(!e)throw`${l} is not part of the THREE namespace! Did you forget to extend? See: https://github.com/pmndrs/react-three-fiber/blob/master/markdown/api.md#using-3rd-party-objects-declaratively`;if(!Array.isArray(t))throw"The args prop must be an array!";s=WC(new e(...t),{root:r,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})),i(s,n),s}function s(e,t){let n=!1;if(t){if(t.attachArray)kC.arr(e[t.attachArray])||(e[t.attachArray]=[]),e[t.attachArray].push(t);else if(t.attachObject)kC.obj(e[t.attachObject[0]])||(e[t.attachObject[0]]={}),e[t.attachObject[0]][t.attachObject[1]]=t;else if(t.attach&&!kC.fun(t.attach))e[t.attach]=t;else if(kC.arr(t.attachFns)){const[n]=t.attachFns;kC.str(n)&&kC.fun(e[n])?e[n](t):kC.fun(n)&&n(t,e)}else t.isObject3D&&e.isObject3D&&(e.add(t),n=!0);n||e.__r3f.objects.push(t),t.__r3f||WC(t,{}),t.__r3f.parent=e,o(t),r(t)}}function l(e,t,n){let i=!1;if(t){if(t.attachArray){const i=e[t.attachArray];kC.arr(i)||(e[t.attachArray]=[]),i.splice(i.indexOf(n),0,t)}else{if(t.attachObject||t.attach&&!kC.fun(t.attach))return s(e,t);if(t.isObject3D&&e.isObject3D){t.parent=e,t.dispatchEvent({type:"added"});const r=e.children.filter((e=>e!==t)),o=r.indexOf(n);e.children=[...r.slice(0,o),t,...r.slice(o)],i=!0}}i||e.__r3f.objects.push(t),t.__r3f||WC(t,{}),t.__r3f.parent=e,o(t),r(t)}}function c(e,t,n=!1){e&&[...e].forEach((e=>u(t,e,n)))}function u(e,t,n){if(t){var i,o;if(t.__r3f&&(t.__r3f.parent=null),null!=(i=e.__r3f)&&i.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&&!kC.fun(t.attach)&&e[t.attach]===t)e[t.attach]=null;else if(kC.arr(t.attachFns)){const[,n]=t.attachFns;kC.str(n)&&kC.fun(e[n])?e[n](t):kC.fun(n)&&n(t,e)}else if(t.isObject3D&&e.isObject3D){var a;e.remove(t),null!=(a=t.__r3f)&&a.root&&function(e,t){const{internal:n}=e.getState();n.interaction=n.interaction.filter((e=>e!==t)),n.initialHits=n.initialHits.filter((e=>e!==t)),n.hovered.forEach(((e,i)=>{e.eventObject!==t&&e.object!==t||n.hovered.delete(i)})),n.capturedMap.forEach(((e,i)=>{FC(n.capturedMap,t,e,i)}))}(t.__r3f.root,t)}const l=null==(o=t.__r3f)?void 0:o.primitive,u=void 0===n?null!==t.dispose&&!l:n;var s;if(!l)c(null==(s=t.__r3f)?void 0:s.objects,t,u),c(t.children,t,u);t.__r3f&&(delete t.__r3f.root,delete t.__r3f.objects,delete t.__r3f.handlers,delete t.__r3f.memoizedProps,l||delete t.__r3f),u&&t.dispose&&"Scene"!==t.type&&(0,EC.unstable_runWithPriority)(EC.unstable_IdlePriority,(()=>{try{t.dispose()}catch(e){}})),r(e)}}return{reconciler:t(wC)({now:EC.unstable_now,createInstance:a,removeChild:u,appendChild:s,appendInitialChild:s,insertBefore:l,warnsIfNotActing:!0,supportsMutation:!0,isPrimaryRenderer:!1,scheduleTimeout:kC.fun(setTimeout)?setTimeout:void 0,cancelTimeout:kC.fun(clearTimeout)?clearTimeout:void 0,setTimeout:kC.fun(setTimeout)?setTimeout:void 0,clearTimeout:kC.fun(clearTimeout)?clearTimeout:void 0,noTimeout:-1,appendChildToContainer:(e,t)=>{const{container:n,root:i}=GC(e,t);n.__r3f.root=i,s(n,t)},removeChildFromContainer:(e,t)=>u(GC(e,t).container,t),insertInContainerBefore:(e,t,n)=>l(GC(e,t).container,t,n),prepareUpdate(e,t,i,r){if(e.__r3f.primitive&&r.object&&r.object!==e)return[!0];{const{args:t=[],children:o,...a}=r,{args:l=[],children:c,...u}=i;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,a,u,!0);if(d.changes.length)return[!1,d];if(e.attach&&"function"!=typeof e.attach){const t=e.__r3f.parent;t&&t[e.attach]!==e&&s(t,e)}return null}},commitUpdate(e,[t,n],r,o,l,c){t?function(e,t,n,i){var r;const o=null==(r=e.__r3f)?void 0:r.parent;if(!o)return;const l=a(t,n,e.__r3f.root);"primitive"!==t&&e.children&&(e.children.forEach((e=>s(l,e))),e.children=[]),e.__r3f.objects.forEach((e=>s(l,e))),e.__r3f.objects=[],u(o,e),s(o,l),l.raycast&&l.__r3f.eventCount&&l.__r3f.root.getState().internal.interaction.push(l);[i,i.alternate].forEach((e=>{null!==e&&(e.stateNode=l,e.ref&&("function"==typeof e.ref?e.ref(l):e.ref.current=l))}))}(e,r,l,c):i(e,n)},hideInstance(e){e.isObject3D&&(e.visible=!1,r(e))},unhideInstance(e,t){(e.isObject3D&&null==t.visible||t.visible)&&(e.visible=!0,r(e))},hideTextInstance(){throw new Error("Text is not allowed in the R3F tree.")},getPublicInstance:e=>e,getRootHostContext:e=>HC,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){WC(e)},resetAfterCommit(){},shouldSetTextContent:()=>!1,clearContainer:()=>!1}),applyProps:i}}();function yN({store:e,element:t,onCreated:n,target:i}){return c.useEffect((()=>{const t=e.getState();t.set((e=>({internal:{...e.internal,active:!0}}))),null==t.events.connect||t.events.connect(i),n&&n(t)}),[]),c.createElement(YC.Provider,{value:e},t)}function _N(e,t){const n=hN.get(e),i=null==n?void 0:n.fiber;if(i){const r=null==n?void 0:n.store.getState();r&&(r.internal.active=!1),gN.updateContainer(null,i,null,(()=>{r&&setTimeout((()=>{var n,i,o;null==r.events.disconnect||r.events.disconnect(),null==(n=r.gl)||null==(i=n.renderLists)||null==i.dispose||i.dispose(),null==(o=r.gl)||null==o.forceContextLoss||o.forceContextLoss(),function(e){e.dispose&&"Scene"!==e.type&&e.dispose();for(const i in e){var t,n;null==(t=(n=i).dispose)||t.call(n),delete e[i]}}(r),hN.delete(e),t&&t(e)}),500)}))}}gN.act;function bN(){return bN=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},bN.apply(this,arguments)}gN.injectIntoDevTools({bundleType:0,rendererPackageName:"@react-three/fiber",version:"17.0.2"});c=o("85Hg2");function xN(e){return xN="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},xN(e)}function wN(e,t){if("object"!==xN(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!==xN(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function SN(e){var t=wN(e,"string");return"symbol"===xN(t)?t:String(t)}function EN(e,t,n){return(t=SN(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const AN=(e,t)=>(e%t+t)%t;class TN extends Bh{constructor(e,t){super(),EN(this,"object",void 0),EN(this,"domElement",void 0),EN(this,"enabled",!0),EN(this,"target",new Cp),EN(this,"minDistance",0),EN(this,"maxDistance",1/0),EN(this,"minZoom",0),EN(this,"maxZoom",1/0),EN(this,"minPolarAngle",0),EN(this,"maxPolarAngle",Math.PI),EN(this,"minAzimuthAngle",-1/0),EN(this,"maxAzimuthAngle",1/0),EN(this,"enableDamping",!1),EN(this,"dampingFactor",.05),EN(this,"enableZoom",!0),EN(this,"zoomSpeed",1),EN(this,"enableRotate",!0),EN(this,"rotateSpeed",1),EN(this,"enablePan",!0),EN(this,"panSpeed",1),EN(this,"screenSpacePanning",!0),EN(this,"keyPanSpeed",7),EN(this,"autoRotate",!1),EN(this,"autoRotateSpeed",2),EN(this,"reverseOrbit",!1),EN(this,"keys",{LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"}),EN(this,"mouseButtons",{LEFT:Mc.ROTATE,MIDDLE:Mc.DOLLY,RIGHT:Mc.PAN}),EN(this,"touches",{ONE:Cc.ROTATE,TWO:Cc.DOLLY_PAN}),EN(this,"target0",void 0),EN(this,"position0",void 0),EN(this,"zoom0",void 0),EN(this,"_domElementKeyEvents",null),EN(this,"getPolarAngle",void 0),EN(this,"getAzimuthalAngle",void 0),EN(this,"setPolarAngle",void 0),EN(this,"setAzimuthalAngle",void 0),EN(this,"getDistance",void 0),EN(this,"listenToKeyEvents",void 0),EN(this,"saveState",void 0),EN(this,"reset",void 0),EN(this,"update",void 0),EN(this,"connect",void 0),EN(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 Uf?this.object.zoom:1,this.getPolarAngle=()=>c.phi,this.getAzimuthalAngle=()=>c.theta,this.setPolarAngle=e=>{let t=AN(e,2*Math.PI),i=c.phi;i<0&&(i+=2*Math.PI),t<0&&(t+=2*Math.PI);let r=Math.abs(t-i);2*Math.PI-r<r&&(t<i?t+=2*Math.PI:i+=2*Math.PI),u.phi=t-i,n.update()},this.setAzimuthalAngle=e=>{let t=AN(e,2*Math.PI),i=c.theta;i<0&&(i+=2*Math.PI),t<0&&(t+=2*Math.PI);let r=Math.abs(t-i);2*Math.PI-r<r&&(t<i?t+=2*Math.PI:i+=2*Math.PI),u.theta=t-i,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 Uf?n.object.zoom:1},this.reset=()=>{n.target.copy(n.target0),n.object.position.copy(n.position0),n.object instanceof Uf&&(n.object.zoom=n.zoom0,n.object.updateProjectionMatrix()),n.dispatchEvent(i),n.update(),s=a.NONE},this.update=(()=>{const t=new Cp,r=(new Mp).setFromUnitVectors(e.up,new Cp(0,1,0)),o=r.clone().invert(),m=new Cp,f=new Mp,g=2*Math.PI;return function(){const e=n.object.position;t.copy(e).sub(n.target),t.applyQuaternion(r),c.setFromVector3(t),n.autoRotate&&s===a.NONE&&T(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(i),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",$),n.domElement.addEventListener("pointerdown",G),n.domElement.addEventListener("pointercancel",V),n.domElement.addEventListener("wheel",W)},this.dispose=()=>{var e,t,i,r,o,a;null===(e=n.domElement)||void 0===e||e.removeEventListener("contextmenu",$),null===(t=n.domElement)||void 0===t||t.removeEventListener("pointerdown",G),null===(i=n.domElement)||void 0===i||i.removeEventListener("pointercancel",V),null===(r=n.domElement)||void 0===r||r.removeEventListener("wheel",W),null===(o=n.domElement)||void 0===o||o.ownerDocument.removeEventListener("pointermove",j),null===(a=n.domElement)||void 0===a||a.ownerDocument.removeEventListener("pointerup",H),null!==n._domElementKeyEvents&&n._domElementKeyEvents.removeEventListener("keydown",q)};const n=this,i={type:"change"},r={type:"start"},o={type:"end"},a={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let s=a.NONE;const l=1e-6,c=new gS,u=new gS;let d=1;const h=new Cp;let p=!1;const m=new Kh,f=new Kh,g=new Kh,v=new Kh,y=new Kh,_=new Kh,b=new Kh,x=new Kh,w=new Kh,S=[],E={};function A(){return Math.pow(.95,n.zoomSpeed)}function T(e){n.reverseOrbit?u.theta+=e:u.theta-=e}function I(e){n.reverseOrbit?u.phi+=e:u.phi-=e}const M=(()=>{const e=new Cp;return function(t,n){e.setFromMatrixColumn(n,0),e.multiplyScalar(-t),h.add(e)}})(),C=(()=>{const e=new Cp;return function(t,i){!0===n.screenSpacePanning?e.setFromMatrixColumn(i,1):(e.setFromMatrixColumn(i,0),e.crossVectors(n.object.up,e)),e.multiplyScalar(t),h.add(e)}})(),N=(()=>{const e=new Cp;return function(t,i){const r=n.domElement;if(r&&n.object instanceof Uf&&n.object.isPerspectiveCamera){const o=n.object.position;e.copy(o).sub(n.target);let a=e.length();a*=Math.tan(n.object.fov/2*Math.PI/180),M(2*t*a/r.clientHeight,n.object.matrix),C(2*i*a/r.clientHeight,n.object.matrix)}else r&&n.object instanceof cg&&n.object.isOrthographicCamera?(M(t*(n.object.right-n.object.left)/n.object.zoom/r.clientWidth,n.object.matrix),C(i*(n.object.top-n.object.bottom)/n.object.zoom/r.clientHeight,n.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),n.enablePan=!1)}})();function O(e){n.object instanceof Uf&&n.object.isPerspectiveCamera?d/=e:n.object instanceof cg&&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 R(e){n.object instanceof Uf&&n.object.isPerspectiveCamera?d*=e:n.object instanceof cg&&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 L(e){m.set(e.clientX,e.clientY)}function P(e){v.set(e.clientX,e.clientY)}function D(){if(1==S.length)m.set(S[0].pageX,S[0].pageY);else{const e=.5*(S[0].pageX+S[1].pageX),t=.5*(S[0].pageY+S[1].pageY);m.set(e,t)}}function k(){if(1==S.length)v.set(S[0].pageX,S[0].pageY);else{const e=.5*(S[0].pageX+S[1].pageX),t=.5*(S[0].pageY+S[1].pageY);v.set(e,t)}}function B(){const e=S[0].pageX-S[1].pageX,t=S[0].pageY-S[1].pageY,n=Math.sqrt(e*e+t*t);b.set(0,n)}function F(e){if(1==S.length)f.set(e.pageX,e.pageY);else{const t=Z(e),n=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);f.set(n,i)}g.subVectors(f,m).multiplyScalar(n.rotateSpeed);const t=n.domElement;t&&(T(2*Math.PI*g.x/t.clientHeight),I(2*Math.PI*g.y/t.clientHeight)),m.copy(f)}function U(e){if(1==S.length)y.set(e.pageX,e.pageY);else{const t=Z(e),n=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);y.set(n,i)}_.subVectors(y,v).multiplyScalar(n.panSpeed),N(_.x,_.y),v.copy(y)}function z(e){const t=Z(e),i=e.pageX-t.x,r=e.pageY-t.y,o=Math.sqrt(i*i+r*r);x.set(0,o),w.set(0,Math.pow(x.y/b.y,n.zoomSpeed)),O(w.y),b.copy(x)}function G(e){if(!1!==n.enabled){var t,i;if(0===S.length)null===(t=n.domElement)||void 0===t||t.ownerDocument.addEventListener("pointermove",j),null===(i=n.domElement)||void 0===i||i.ownerDocument.addEventListener("pointerup",H);!function(e){S.push(e)}(e),"touch"===e.pointerType?function(e){switch(J(e),S.length){case 1:switch(n.touches.ONE){case Cc.ROTATE:if(!1===n.enableRotate)return;D(),s=a.TOUCH_ROTATE;break;case Cc.PAN:if(!1===n.enablePan)return;k(),s=a.TOUCH_PAN;break;default:s=a.NONE}break;case 2:switch(n.touches.TWO){case Cc.DOLLY_PAN:if(!1===n.enableZoom&&!1===n.enablePan)return;n.enableZoom&&B(),n.enablePan&&k(),s=a.TOUCH_DOLLY_PAN;break;case Cc.DOLLY_ROTATE:if(!1===n.enableZoom&&!1===n.enableRotate)return;n.enableZoom&&B(),n.enableRotate&&D(),s=a.TOUCH_DOLLY_ROTATE;break;default:s=a.NONE}break;default:s=a.NONE}s!==a.NONE&&n.dispatchEvent(r)}(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 Mc.DOLLY:if(!1===n.enableZoom)return;!function(e){b.set(e.clientX,e.clientY)}(e),s=a.DOLLY;break;case Mc.ROTATE:if(e.ctrlKey||e.metaKey||e.shiftKey){if(!1===n.enablePan)return;P(e),s=a.PAN}else{if(!1===n.enableRotate)return;L(e),s=a.ROTATE}break;case Mc.PAN:if(e.ctrlKey||e.metaKey||e.shiftKey){if(!1===n.enableRotate)return;L(e),s=a.ROTATE}else{if(!1===n.enablePan)return;P(e),s=a.PAN}break;default:s=a.NONE}s!==a.NONE&&n.dispatchEvent(r)}(e)}}function j(e){!1!==n.enabled&&("touch"===e.pointerType?function(e){switch(J(e),s){case a.TOUCH_ROTATE:if(!1===n.enableRotate)return;F(e),n.update();break;case a.TOUCH_PAN:if(!1===n.enablePan)return;U(e),n.update();break;case a.TOUCH_DOLLY_PAN:if(!1===n.enableZoom&&!1===n.enablePan)return;!function(e){n.enableZoom&&z(e),n.enablePan&&U(e)}(e),n.update();break;case a.TOUCH_DOLLY_ROTATE:if(!1===n.enableZoom&&!1===n.enableRotate)return;!function(e){n.enableZoom&&z(e),n.enableRotate&&F(e)}(e),n.update();break;default:s=a.NONE}}(e):function(e){if(!1===n.enabled)return;switch(s){case a.ROTATE:if(!1===n.enableRotate)return;!function(e){f.set(e.clientX,e.clientY),g.subVectors(f,m).multiplyScalar(n.rotateSpeed);const t=n.domElement;t&&(T(2*Math.PI*g.x/t.clientHeight),I(2*Math.PI*g.y/t.clientHeight)),m.copy(f),n.update()}(e);break;case a.DOLLY:if(!1===n.enableZoom)return;!function(e){x.set(e.clientX,e.clientY),w.subVectors(x,b),w.y>0?O(A()):w.y<0&&R(A()),b.copy(x),n.update()}(e);break;case a.PAN:if(!1===n.enablePan)return;!function(e){y.set(e.clientX,e.clientY),_.subVectors(y,v).multiplyScalar(n.panSpeed),N(_.x,_.y),v.copy(y),n.update()}(e)}}(e))}function H(e){var t,i,r;(Y(e),0===S.length)&&(null===(t=n.domElement)||void 0===t||t.releasePointerCapture(e.pointerId),null===(i=n.domElement)||void 0===i||i.ownerDocument.removeEventListener("pointermove",j),null===(r=n.domElement)||void 0===r||r.ownerDocument.removeEventListener("pointerup",H));n.dispatchEvent(o),s=a.NONE}function V(e){Y(e)}function W(e){!1===n.enabled||!1===n.enableZoom||s!==a.NONE&&s!==a.ROTATE||(e.preventDefault(),n.dispatchEvent(r),function(e){e.deltaY<0?R(A()):e.deltaY>0&&O(A()),n.update()}(e),n.dispatchEvent(o))}function q(e){!1!==n.enabled&&!1!==n.enablePan&&function(e){let t=!1;switch(e.code){case n.keys.UP:N(0,n.keyPanSpeed),t=!0;break;case n.keys.BOTTOM:N(0,-n.keyPanSpeed),t=!0;break;case n.keys.LEFT:N(n.keyPanSpeed,0),t=!0;break;case n.keys.RIGHT:N(-n.keyPanSpeed,0),t=!0}t&&(e.preventDefault(),n.update())}(e)}function $(e){!1!==n.enabled&&e.preventDefault()}function Y(e){delete E[e.pointerId];for(let t=0;t<S.length;t++)if(S[t].pointerId==e.pointerId)return void S.splice(t,1)}function J(e){let t=E[e.pointerId];void 0===t&&(t=new Kh,E[e.pointerId]=t),t.set(e.pageX,e.pageY)}function Z(e){const t=e.pointerId===S[0].pointerId?S[1]:S[0];return E[t.pointerId]}void 0!==t&&this.connect(t),this.update()}}const IN=c.forwardRef((({makeDefault:e,camera:t,regress:n,domElement:i,enableDamping:r=!0,onChange:o,onStart:a,onEnd:s,...l},u)=>{const d=sN((e=>e.invalidate)),h=sN((e=>e.camera)),p=sN((e=>e.gl)),m=sN((e=>e.events)),f=sN((e=>e.set)),g=sN((e=>e.get)),v=sN((e=>e.performance)),y=t||h,_=i||m.connected||p.domElement,b=c.useMemo((()=>new TN(y)),[y]);return lN((()=>{b.enabled&&b.update()})),c.useEffect((()=>(b.connect(_),()=>{b.dispose()})),[_,n,b,d]),c.useEffect((()=>{const e=e=>{d(),n&&v.regress(),o&&o(e)};return b.addEventListener("change",e),a&&b.addEventListener("start",a),s&&b.addEventListener("end",s),()=>{a&&b.removeEventListener("start",a),s&&b.removeEventListener("end",s),b.removeEventListener("change",e)}}),[o,a,s]),c.useEffect((()=>{if(e){const e=g().controls;return f({controls:b}),()=>f({controls:e})}}),[e,b]),c.createElement("primitive",bN({ref:u,object:b,enableDamping:r},l))}));const MN=(c=o("85Hg2")).forwardRef((({makeDefault:e,...t},n)=>{const i=sN((({set:e})=>e)),r=sN((({camera:e})=>e)),o=sN((({size:e})=>e)),a=c.useRef();return c.useLayoutEffect((()=>{const{current:e}=a;e&&!t.manual&&(e.aspect=o.width/o.height,e.updateProjectionMatrix())}),[o,t]),c.useLayoutEffect((()=>{if(e&&a.current){const e=r;return i((()=>({camera:a.current}))),()=>i((()=>({camera:e})))}}),[r,a,e,i]),c.createElement("perspectiveCamera",bN({ref:NC([a,n])},t))}));c=o("85Hg2"),c=o("85Hg2");const CN=new WeakMap;class NN extends Hx{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,i){const r=new qx(this.manager);r.setPath(this.path),r.setResponseType("arraybuffer"),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(e,(e=>{const n={attributeIDs:this.defaultAttributeIDs,attributeTypes:this.defaultAttributeTypes,useUniqueIDs:!1};this.decodeGeometry(e,n).then(t).catch(i)}),n,i)}decodeDracoFile(e,t,n,i){const r={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:i||this.defaultAttributeTypes,useUniqueIDs:!!n};this.decodeGeometry(e,r).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(CN.has(e)){const t=CN.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 i;const r=this.workerNextTaskID++,o=e.byteLength,a=this._getWorker(r,o).then((n=>(i=n,new Promise(((n,o)=>{i._callbacks[r]={resolve:n,reject:o},i.postMessage({type:"decode",id:r,taskConfig:t,buffer:e},[e])}))))).then((e=>this._createGeometry(e.geometry)));return a.catch((()=>!0)).then((()=>{i&&r&&this._releaseTask(i,r)})),CN.set(e,{key:n,promise:a}),a}_createGeometry(e){const t=new pf;e.index&&t.setIndex(new Ym(e.index.array,1));for(let n=0;n<e.attributes.length;n++){const i=e.attributes[n],r=i.name,o=i.array,a=i.itemSize;t.setAttribute(r,new Ym(o,a))}return t}_loadLibrary(e,t){const n=new qx(this.manager);return n.setPath(this.decoderPath),n.setResponseType(t),n.setWithCredentials(this.withCredentials),new Promise(((t,i)=>{n.load(e,t,void 0,i)}))}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 i=ON.toString(),r=["/* draco decoder */",n,"","/* worker */",i.substring(i.indexOf("{")+1,i.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([r]))})),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 ON(){let e,t;function n(e,t,n,i,r,o){const a=o.num_components(),s=n.num_points()*a,l=s*r.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,r),u=e._malloc(l);t.GetAttributeDataArrayForAllPoints(n,o,c,l,u);const d=new r(e.HEAPF32.buffer,u,s).slice();return e._free(u),{name:i,array:d,itemSize:a}}onmessage=function(i){const r=i.data;switch(r.type){case"init":e=r.decoderConfig,t=new Promise((function(t){e.onModuleLoaded=function(e){t({draco:e})},DracoDecoderModule(e)}));break;case"decode":const i=r.buffer,o=r.taskConfig;t.then((e=>{const t=e.draco,a=new t.Decoder,s=new t.DecoderBuffer;s.Init(new Int8Array(i),i.byteLength);try{const e=function(e,t,i,r){const o=r.attributeIDs,a=r.attributeTypes;let s,l;const c=t.GetEncodedGeometryType(i);if(c===e.TRIANGULAR_MESH)s=new e.Mesh,l=t.DecodeBufferToMesh(i,s);else{if(c!==e.POINT_CLOUD)throw new Error("THREE.DRACOLoader: Unexpected geometry type.");s=new e.PointCloud,l=t.DecodeBufferToPointCloud(i,s)}if(!l.ok()||0===s.ptr)throw new Error("THREE.DRACOLoader: Decoding failed: "+l.error_msg());const u={index:null,attributes:[]};for(const i in o){const l=self[a[i]];let c,d;if(r.useUniqueIDs)d=o[i],c=t.GetAttributeByUniqueId(s,d);else{if(d=t.GetAttributeId(s,e[o[i]]),-1===d)continue;c=t.GetAttribute(s,d)}u.attributes.push(n(e,t,s,i,l,c))}c===e.TRIANGULAR_MESH&&(u.index=function(e,t,n){const i=n.num_faces(),r=3*i,o=4*r,a=e._malloc(o);t.GetTrianglesUInt32Array(n,o,a);const s=new Uint32Array(e.HEAPF32.buffer,a,r).slice();return e._free(a),{array:s,itemSize:1}}(e,t,s));return e.destroy(s),u}(t,a,s,o),i=e.attributes.map((e=>e.array.buffer));e.index&&i.push(e.index.array.buffer),self.postMessage({type:"decode",id:r.id,geometry:e},i)}catch(e){console.error(e),self.postMessage({type:"error",id:r.id,error:e.message})}finally{t.destroy(s),t.destroy(a)}}))}}}let RN;const LN=()=>{if(RN)return RN;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,i="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)&&(i="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 r=WebAssembly.instantiate(function(e){const n=new Uint8Array(e.length);for(let t=0;t<e.length;++t){const i=e.charCodeAt(t);n[t]=i>96?i-71:i>64?i-65:i>47?i+4:i>46?63:62}let i=0;for(let r=0;r<e.length;++r)n[i++]=n[r]<60?t[n[r]]:64*(n[r]-60)+n[++r];return n.buffer.slice(0,i)}(i),{}).then((e=>{n=e.instance,n.exports.__wasm_call_ctors()}));function o(e,t,i,r,o,a){const s=n.exports.sbrk,l=i+3&-4,c=s(l*r),u=s(o.length),d=new Uint8Array(n.exports.memory.buffer);d.set(o,u);const h=e(c,i,r,u,o.length);if(0===h&&a&&a(c,l,r),t.set(d.subarray(c,c+i*r)),s(c-s(0)),0!==h)throw new Error(`Malformed buffer data: ${h}`)}const a={0:"",1:"meshopt_decodeFilterOct",2:"meshopt_decodeFilterQuat",3:"meshopt_decodeFilterExp",NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},s={0:"meshopt_decodeVertexBuffer",1:"meshopt_decodeIndexBuffer",2:"meshopt_decodeIndexSequence",ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return RN={ready:r,supported:!0,decodeVertexBuffer(e,t,i,r,s){o(n.exports.meshopt_decodeVertexBuffer,e,t,i,r,n.exports[a[s]])},decodeIndexBuffer(e,t,i,r){o(n.exports.meshopt_decodeIndexBuffer,e,t,i,r)},decodeIndexSequence(e,t,i,r){o(n.exports.meshopt_decodeIndexSequence,e,t,i,r)},decodeGltfBuffer(e,t,i,r,l,c){o(n.exports[s[l]],e,t,i,r,n.exports[a[c]])}},RN};class PN extends Hx{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register((function(e){return new zN(e)})),this.register((function(e){return new $N(e)})),this.register((function(e){return new YN(e)})),this.register((function(e){return new jN(e)})),this.register((function(e){return new HN(e)})),this.register((function(e){return new VN(e)})),this.register((function(e){return new WN(e)})),this.register((function(e){return new UN(e)})),this.register((function(e){return new qN(e)})),this.register((function(e){return new GN(e)})),this.register((function(e){return new BN(e)})),this.register((function(e){return new JN(e)}))}load(e,t,n,i){const r=this;let o;o=""!==this.resourcePath?this.resourcePath:""!==this.path?this.path:_w.extractUrlBase(e),this.manager.itemStart(e);const a=function(t){i?i(t):console.error(t),r.manager.itemError(e),r.manager.itemEnd(e)},s=new qx(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,(function(n){try{r.parse(n,o,(function(n){t(n),r.manager.itemEnd(e)}),a)}catch(e){a(e)}}),n,a)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return-1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}unregister(e){return-1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,i){let r;const o={},a={};if("string"==typeof e)r=e;else{if(_w.decodeText(new Uint8Array(e,0,4))===ZN){try{o[kN.KHR_BINARY_GLTF]=new QN(e)}catch(e){return void(i&&i(e))}r=o[kN.KHR_BINARY_GLTF].content}else r=_w.decodeText(new Uint8Array(e))}const s=JSON.parse(r);if(void 0===s.asset||s.asset.version[0]<2)return void(i&&i(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));const l=new OO(s,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e<this.pluginCallbacks.length;e++){const t=this.pluginCallbacks[e](l);a[t.name]=t,o[t.name]=!0}if(s.extensionsUsed)for(let e=0;e<s.extensionsUsed.length;++e){const t=s.extensionsUsed[e],n=s.extensionsRequired||[];switch(t){case kN.KHR_MATERIALS_UNLIT:o[t]=new FN;break;case kN.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:o[t]=new iO;break;case kN.KHR_DRACO_MESH_COMPRESSION:o[t]=new eO(s,this.dracoLoader);break;case kN.KHR_TEXTURE_TRANSFORM:o[t]=new tO;break;case kN.KHR_MESH_QUANTIZATION:o[t]=new rO;break;default:n.indexOf(t)>=0&&void 0===a[t]&&console.warn('THREE.GLTFLoader: Unknown extension "'+t+'".')}}l.setExtensions(o),l.setPlugins(a),l.parse(n,i)}parseAsync(e,t){const n=this;return new Promise((function(i,r){n.parse(e,t,i,r)}))}}function DN(){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 kN={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 BN{constructor(e){this.parser=e,this.name=kN.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n<i;n++){const i=t[n];i.extensions&&i.extensions[this.name]&&void 0!==i.extensions[this.name].light&&e._addNodeRef(this.cache,i.extensions[this.name].light)}}_loadLight(e){const t=this.parser,n="light:"+e;let i=t.cache.get(n);if(i)return i;const r=t.json,o=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e];let a;const s=new mp(16777215);void 0!==o.color&&s.fromArray(o.color);const l=void 0!==o.range?o.range:0;switch(o.type){case"directional":a=new pw(s),a.target.position.set(0,0,-1),a.add(a.target);break;case"point":a=new dw(s),a.distance=l;break;case"spot":a=new aw(s),a.distance=l,o.spot=o.spot||{},o.spot.innerConeAngle=void 0!==o.spot.innerConeAngle?o.spot.innerConeAngle:0,o.spot.outerConeAngle=void 0!==o.spot.outerConeAngle?o.spot.outerConeAngle:Math.PI/4,a.angle=o.spot.outerConeAngle,a.penumbra=1-o.spot.innerConeAngle/o.spot.outerConeAngle,a.target.position.set(0,0,-1),a.add(a.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+o.type)}return a.position.set(0,0,0),a.decay=2,void 0!==o.intensity&&(a.intensity=o.intensity),a.name=t.createUniqueName(o.name||"light_"+e),i=Promise.resolve(a),t.cache.add(n,i),i}createNodeAttachment(e){const t=this,n=this.parser,i=n.json.nodes[e],r=(i.extensions&&i.extensions[this.name]||{}).light;return void 0===r?null:this._loadLight(r).then((function(e){return n._getNodeRef(t.cache,r,e)}))}}class FN{constructor(){this.name=kN.KHR_MATERIALS_UNLIT}getMaterialType(){return Wm}extendParams(e,t,n){const i=[];e.color=new mp(1,1,1),e.opacity=1;const r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){const t=r.baseColorFactor;e.color.fromArray(t),e.opacity=t[3]}void 0!==r.baseColorTexture&&i.push(n.assignTexture(e,"map",r.baseColorTexture,th))}return Promise.all(i)}}class UN{constructor(e){this.parser=e,this.name=kN.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 i=n.extensions[this.name].emissiveStrength;return void 0!==i&&(t.emissiveIntensity=i),Promise.resolve()}}class zN{constructor(e){this.parser=e,this.name=kN.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?hx:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],o=i.extensions[this.name];if(void 0!==o.clearcoatFactor&&(t.clearcoat=o.clearcoatFactor),void 0!==o.clearcoatTexture&&r.push(n.assignTexture(t,"clearcoatMap",o.clearcoatTexture)),void 0!==o.clearcoatRoughnessFactor&&(t.clearcoatRoughness=o.clearcoatRoughnessFactor),void 0!==o.clearcoatRoughnessTexture&&r.push(n.assignTexture(t,"clearcoatRoughnessMap",o.clearcoatRoughnessTexture)),void 0!==o.clearcoatNormalTexture&&(r.push(n.assignTexture(t,"clearcoatNormalMap",o.clearcoatNormalTexture)),void 0!==o.clearcoatNormalTexture.scale)){const e=o.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new Kh(e,e)}return Promise.all(r)}}class GN{constructor(e){this.parser=e,this.name=kN.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?hx:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],o=i.extensions[this.name];return void 0!==o.iridescenceFactor&&(t.iridescence=o.iridescenceFactor),void 0!==o.iridescenceTexture&&r.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&&r.push(n.assignTexture(t,"iridescenceThicknessMap",o.iridescenceThicknessTexture)),Promise.all(r)}}class jN{constructor(e){this.parser=e,this.name=kN.KHR_MATERIALS_SHEEN}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?hx:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[];t.sheenColor=new mp(0,0,0),t.sheenRoughness=0,t.sheen=1;const o=i.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&&r.push(n.assignTexture(t,"sheenColorMap",o.sheenColorTexture,th)),void 0!==o.sheenRoughnessTexture&&r.push(n.assignTexture(t,"sheenRoughnessMap",o.sheenRoughnessTexture)),Promise.all(r)}}class HN{constructor(e){this.parser=e,this.name=kN.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?hx:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],o=i.extensions[this.name];return void 0!==o.transmissionFactor&&(t.transmission=o.transmissionFactor),void 0!==o.transmissionTexture&&r.push(n.assignTexture(t,"transmissionMap",o.transmissionTexture)),Promise.all(r)}}class VN{constructor(e){this.parser=e,this.name=kN.KHR_MATERIALS_VOLUME}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?hx:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],o=i.extensions[this.name];t.thickness=void 0!==o.thicknessFactor?o.thicknessFactor:0,void 0!==o.thicknessTexture&&r.push(n.assignTexture(t,"thicknessMap",o.thicknessTexture)),t.attenuationDistance=o.attenuationDistance||1/0;const a=o.attenuationColor||[1,1,1];return t.attenuationColor=new mp(a[0],a[1],a[2]),Promise.all(r)}}class WN{constructor(e){this.parser=e,this.name=kN.KHR_MATERIALS_IOR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?hx:null}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name];return t.ior=void 0!==i.ior?i.ior:1.5,Promise.resolve()}}class qN{constructor(e){this.parser=e,this.name=kN.KHR_MATERIALS_SPECULAR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?hx:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],o=i.extensions[this.name];t.specularIntensity=void 0!==o.specularFactor?o.specularFactor:1,void 0!==o.specularTexture&&r.push(n.assignTexture(t,"specularIntensityMap",o.specularTexture));const a=o.specularColorFactor||[1,1,1];return t.specularColor=new mp(a[0],a[1],a[2]),void 0!==o.specularColorTexture&&r.push(n.assignTexture(t,"specularColorMap",o.specularColorTexture,th)),Promise.all(r)}}class $N{constructor(e){this.parser=e,this.name=kN.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,i=n.textures[e];if(!i.extensions||!i.extensions[this.name])return null;const r=i.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,r.source,o)}}class YN{constructor(e){this.parser=e,this.name=kN.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;const o=r.extensions[t],a=i.images[o.source];let s=n.textureLoader;if(a.uri){const e=n.options.manager.getHandler(a.uri);null!==e&&(s=e)}return this.detectSupport().then((function(r){if(r)return n.loadTextureImage(e,o.source,s);if(i.extensionsRequired&&i.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 JN{constructor(e){this.name=kN.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],i=this.parser.getDependency("buffer",e.buffer),r=this.parser.options.meshoptDecoder;if(!r||!r.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 i.then((function(t){const n=e.byteOffset||0,i=e.byteLength||0,o=e.count,a=e.byteStride,s=new Uint8Array(t,n,i);return r.decodeGltfBufferAsync?r.decodeGltfBufferAsync(o,a,s,e.mode,e.filter).then((function(e){return e.buffer})):r.ready.then((function(){const t=new ArrayBuffer(o*a);return r.decodeGltfBuffer(new Uint8Array(t),o,a,s,e.mode,e.filter),t}))}))}return null}}const ZN="glTF",XN=1313821514,KN=5130562;class QN{constructor(e){this.name=kN.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,12);if(this.header={magic:_w.decodeText(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==ZN)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,i=new DataView(e,12);let r=0;for(;r<n;){const t=i.getUint32(r,!0);r+=4;const n=i.getUint32(r,!0);if(r+=4,n===XN){const n=new Uint8Array(e,12+r,t);this.content=_w.decodeText(n)}else if(n===KN){const n=12+r;this.body=e.slice(n,n+t)}r+=t}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class eO{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=kN.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,i=this.dracoLoader,r=e.extensions[this.name].bufferView,o=e.extensions[this.name].attributes,a={},s={},l={};for(const e in o){const t=_O[e]||e.toLowerCase();a[t]=o[e]}for(const t in e.attributes){const i=_O[t]||t.toLowerCase();if(void 0!==o[t]){const r=n.accessors[e.attributes[t]],o=fO[r.componentType];l[i]=o.name,s[i]=!0===r.normalized}}return t.getDependency("bufferView",r).then((function(e){return new Promise((function(t){i.decodeDracoFile(e,(function(e){for(const t in e.attributes){const n=e.attributes[t],i=s[t];void 0!==i&&(n.normalized=i)}t(e)}),a,l)}))}))}}class tO{constructor(){this.name=kN.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 nO extends dx{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"),i=["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"),r=["float glossinessFactor = glossiness;","#ifdef USE_GLOSSINESSMAP","\tvec4 texelGlossiness = texture2D( glossinessMap, vUv );","\t// reads channel A, compatible with a glTF Specular-Glossiness (RGBA) texture","\tglossinessFactor *= texelGlossiness.a;","#endif"].join("\n"),o=["PhysicalMaterial material;","material.diffuseColor = diffuseColor.rgb * ( 1. - max( specularFactor.r, max( specularFactor.g, specularFactor.b ) ) );","vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );","float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );","material.roughness = max( 1.0 - glossinessFactor, 0.0525 ); // 0.0525 corresponds to the base mip of a 256 cubemap.","material.roughness += geometryRoughness;","material.roughness = min( material.roughness, 1.0 );","material.specularColor = specularFactor;"].join("\n"),a={specular:{value:(new mp).setHex(16777215)},glossiness:{value:1},specularMap:{value:null},glossinessMap:{value:null}};this._extraUniforms=a,this.onBeforeCompile=function(e){for(const t in a)e.uniforms[t]=a[t];e.fragmentShader=e.fragmentShader.replace("uniform float roughness;","uniform vec3 specular;").replace("uniform float metalness;","uniform float glossiness;").replace("#include <roughnessmap_pars_fragment>",t).replace("#include <metalnessmap_pars_fragment>",n).replace("#include <roughnessmap_fragment>",i).replace("#include <metalnessmap_fragment>",r).replace("#include <lights_physical_fragment>",o)},Object.defineProperties(this,{specular:{get:function(){return a.specular.value},set:function(e){a.specular.value=e}},specularMap:{get:function(){return a.specularMap.value},set:function(e){a.specularMap.value=e,e?this.defines.USE_SPECULARMAP="":delete this.defines.USE_SPECULARMAP}},glossiness:{get:function(){return a.glossiness.value},set:function(e){a.glossiness.value=e}},glossinessMap:{get:function(){return a.glossinessMap.value},set:function(e){a.glossinessMap.value=e,e?(this.defines.USE_GLOSSINESSMAP="",this.defines.USE_UV=""):(delete this.defines.USE_GLOSSINESSMAP,delete this.defines.USE_UV)}}}),delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this.setValues(e)}copy(e){return super.copy(e),this.specularMap=e.specularMap,this.specular.copy(e.specular),this.glossinessMap=e.glossinessMap,this.glossiness=e.glossiness,delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this}}class iO{constructor(){this.name=kN.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 nO}extendParams(e,t,n){const i=t.extensions[this.name];e.color=new mp(1,1,1),e.opacity=1;const r=[];if(Array.isArray(i.diffuseFactor)){const t=i.diffuseFactor;e.color.fromArray(t),e.opacity=t[3]}if(void 0!==i.diffuseTexture&&r.push(n.assignTexture(e,"map",i.diffuseTexture,th)),e.emissive=new mp(0,0,0),e.glossiness=void 0!==i.glossinessFactor?i.glossinessFactor:1,e.specular=new mp(1,1,1),Array.isArray(i.specularFactor)&&e.specular.fromArray(i.specularFactor),void 0!==i.specularGlossinessTexture){const t=i.specularGlossinessTexture;r.push(n.assignTexture(e,"glossinessMap",t)),r.push(n.assignTexture(e,"specularMap",t,th))}return Promise.all(r)}createMaterial(e){const t=new nO(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=rh,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 rO{constructor(){this.name=kN.KHR_MESH_QUANTIZATION}}class oO extends Tx{constructor(e,t,n,i){super(e,t,n,i)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i*3+i;for(let e=0;e!==i;e++)t[e]=n[r+e];return t}interpolate_(e,t,n,i){const r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,s=2*a,l=3*a,c=i-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!==a;e++){const t=o[m+e+a],n=o[m+e+s]*c,i=o[p+e+a],l=o[p+e]*c;r[e]=v*t+y*n+f*i+g*l}return r}}const aO=new Mp;class sO extends oO{interpolate_(e,t,n,i){const r=super.interpolate_(e,t,n,i);return aO.fromArray(r).normalize().toArray(r),r}}const lO=0,cO=1,uO=2,dO=3,hO=4,pO=5,mO=6,fO={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},gO={9728:Du,9729:zu,9984:ku,9985:Gu,9986:Fu,9987:Hu},vO={33071:Lu,33648:Pu,10497:Ru},yO={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},_O={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},bO={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},xO={CUBICSPLINE:void 0,LINEAR:Vd,STEP:Hd},wO="OPAQUE",SO="MASK",EO="BLEND";function AO(e,t,n){for(const i in n.extensions)void 0===e[i]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[i]=n.extensions[i])}function TO(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 IO(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(let n=0,i=t.weights.length;n<i;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,i=n.length;t<i;t++)e.morphTargetDictionary[n[t]]=t}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function MO(e){const t=e.extensions&&e.extensions[kN.KHR_DRACO_MESH_COMPRESSION];let n;return n=t?"draco:"+t.bufferView+":"+t.indices+":"+CO(t.attributes):e.indices+":"+CO(e.attributes)+":"+e.mode,n}function CO(e){let t="";const n=Object.keys(e).sort();for(let i=0,r=n.length;i<r;i++)t+=n[i]+":"+e[n[i]]+";";return t}function NO(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 OO{constructor(e={},t={}){var n,i;this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new DN,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 r="undefined"!=typeof navigator&&!0===/^((?!chrome|android).)*safari/i.test(navigator.userAgent),o="undefined"!=typeof navigator&&(null===(n=navigator.userAgent)||void 0===n?void 0:n.indexOf("Firefox"))>-1,a="undefined"!=typeof navigator&&o?null===(i=navigator.userAgent)||void 0===i?void 0:i.match(/Firefox\/([0-9]+)\./)[1]:-1;"undefined"==typeof createImageBitmap||r||o&&a<98?this.textureLoader=new Kx(this.options.manager):this.textureLoader=new Tw(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new qx(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,i=this.json,r=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][i.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:i.asset,parser:n,userData:{}};AO(r,o,i),TO(o,i),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,i=t.length;n<i;n++){const i=t[n].joints;for(let t=0,n=i.length;t<n;t++)e[i[t]].isBone=!0}for(let t=0,i=e.length;t<i;t++){const i=e[t];void 0!==i.mesh&&(this._addNodeRef(this.meshCache,i.mesh),void 0!==i.skin&&(n[i.mesh].isSkinnedMesh=!0)),void 0!==i.camera&&this._addNodeRef(this.cameraCache,i.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 i=n.clone(),r=(e,t)=>{const n=this.associations.get(e);null!=n&&this.associations.set(t,n);for(const[n,i]of e.children.entries())r(i,t.children[n])};return r(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const i=e(t[n]);if(i)return i}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let i=0;i<t.length;i++){const r=e(t[i]);r&&n.push(r)}return n}getDependency(e,t){const n=e+":"+t;let i=this.cache.get(n);if(!i){switch(e){case"scene":i=this.loadScene(t);break;case"node":i=this.loadNode(t);break;case"mesh":i=this._invokeOne((function(e){return e.loadMesh&&e.loadMesh(t)}));break;case"accessor":i=this.loadAccessor(t);break;case"bufferView":i=this._invokeOne((function(e){return e.loadBufferView&&e.loadBufferView(t)}));break;case"buffer":i=this.loadBuffer(t);break;case"material":i=this._invokeOne((function(e){return e.loadMaterial&&e.loadMaterial(t)}));break;case"texture":i=this._invokeOne((function(e){return e.loadTexture&&e.loadTexture(t)}));break;case"skin":i=this.loadSkin(t);break;case"animation":i=this._invokeOne((function(e){return e.loadAnimation&&e.loadAnimation(t)}));break;case"camera":i=this.loadCamera(t);break;default:throw new Error("Unknown type: "+e)}this.cache.add(n,i)}return i}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,i=this.json[e+("mesh"===e?"es":"s")]||[];t=Promise.all(i.map((function(t,i){return n.getDependency(e,i)}))),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[kN.KHR_BINARY_GLTF].body);const i=this.options;return new Promise((function(e,r){n.load(_w.resolveURL(t.uri,i.path),e,void 0,(function(){r(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,i=t.byteOffset||0;return e.slice(i,i+n)}))}loadAccessor(e){const t=this,n=this.json,i=this.json.accessors[e];if(void 0===i.bufferView&&void 0===i.sparse)return Promise.resolve(null);const r=[];return void 0!==i.bufferView?r.push(this.getDependency("bufferView",i.bufferView)):r.push(null),void 0!==i.sparse&&(r.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",i.sparse.values.bufferView))),Promise.all(r).then((function(e){const r=e[0],o=yO[i.type],a=fO[i.componentType],s=a.BYTES_PER_ELEMENT,l=s*o,c=i.byteOffset||0,u=void 0!==i.bufferView?n.bufferViews[i.bufferView].byteStride:void 0,d=!0===i.normalized;let h,p;if(u&&u!==l){const e=Math.floor(c/u),n="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+e+":"+i.count;let l=t.cache.get(n);l||(h=new a(r,e*u,i.count*u/s),l=new Ly(h,u/s),t.cache.add(n,l)),p=new Dy(l,o,c%u/s,d)}else h=null===r?new a(i.count*o):new a(r,c,i.count*o),p=new Ym(h,o,d);if(void 0!==i.sparse){const t=yO.SCALAR,n=fO[i.sparse.indices.componentType],s=i.sparse.indices.byteOffset||0,l=i.sparse.values.byteOffset||0,c=new n(e[1],s,i.sparse.count*t),u=new a(e[2],l,i.sparse.count*o);null!==r&&(p=new Ym(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,i=t.textures[e].source,r=t.images[i];let o=this.textureLoader;if(r.uri){const e=n.manager.getHandler(r.uri);null!==e&&(o=e)}return this.loadTextureImage(e,i,o)}loadTextureImage(e,t,n){const i=this,r=this.json,o=r.textures[e],a=r.images[t],s=(a.uri||a.bufferView)+":"+o.sampler;if(this.textureCache[s])return this.textureCache[s];const l=this.loadImageSource(t,n).then((function(t){t.flipY=!1,o.name&&(t.name=o.name);const n=(r.samplers||{})[o.sampler]||{};return t.magFilter=gO[n.magFilter]||zu,t.minFilter=gO[n.minFilter]||Hu,t.wrapS=vO[n.wrapS]||Ru,t.wrapT=vO[n.wrapT]||Ru,i.associations.set(t,{textures:e}),t})).catch((function(){return null}));return this.textureCache[s]=l,l}loadImageSource(e,t){const n=this.json,i=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then((e=>e.clone()));const r=n.images[e],o=self.URL||self.webkitURL;let a=r.uri||"",s=!1;if(void 0!==r.bufferView)a=this.getDependency("bufferView",r.bufferView).then((function(e){s=!0;const t=new Blob([e],{type:r.mimeType});return a=o.createObjectURL(t),a}));else if(void 0===r.uri)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const l=Promise.resolve(a).then((function(e){return new Promise((function(n,r){let o=n;!0===t.isImageBitmapLoader&&(o=function(e){const t=new bp(e);t.needsUpdate=!0,n(t)}),t.load(_w.resolveURL(e,i.path),o,void 0,r)}))})).then((function(e){var t;return!0===s&&o.revokeObjectURL(a),e.userData.mimeType=r.mimeType||((t=r.uri).search(/\.jpe?g($|\?)/i)>0||0===t.search(/^data\:image\/jpeg/)?"image/jpeg":t.search(/\.webp($|\?)/i)>0||0===t.search(/^data\:image\/webp/)?"image/webp":"image/png"),e})).catch((function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",a),e}));return this.sourceCache[e]=l,l}assignTexture(e,t,n,i){const r=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."),r.extensions[kN.KHR_TEXTURE_TRANSFORM]){const e=void 0!==n.extensions?n.extensions[kN.KHR_TEXTURE_TRANSFORM]:void 0;if(e){const t=r.associations.get(o);o=r.extensions[kN.KHR_TEXTURE_TRANSFORM].extendTexture(o,e),r.associations.set(o,t)}}return void 0!==i&&(o.encoding=i),e[t]=o,o}))}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const i=void 0===t.attributes.tangent,r=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 C_,Vm.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 y_,Vm.prototype.copy.call(t,n),t.color.copy(n.color),this.cache.add(e,t)),n=t}if(i||r||o){let e="ClonedMaterial:"+n.uuid+":";n.isGLTFSpecularGlossinessMaterial&&(e+="specular-glossiness:"),i&&(e+="derivative-tangents:"),r&&(e+="vertex-colors:"),o&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=n.clone(),r&&(t.vertexColors=!0),o&&(t.flatShading=!0),i&&(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 dx}loadMaterial(e){const t=this,n=this.json,i=this.extensions,r=n.materials[e];let o;const a={},s=r.extensions||{},l=[];if(s[kN.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]){const e=i[kN.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS];o=e.getMaterialType(),l.push(e.extendParams(a,r,t))}else if(s[kN.KHR_MATERIALS_UNLIT]){const e=i[kN.KHR_MATERIALS_UNLIT];o=e.getMaterialType(),l.push(e.extendParams(a,r,t))}else{const n=r.pbrMetallicRoughness||{};if(a.color=new mp(1,1,1),a.opacity=1,Array.isArray(n.baseColorFactor)){const e=n.baseColorFactor;a.color.fromArray(e),a.opacity=e[3]}void 0!==n.baseColorTexture&&l.push(t.assignTexture(a,"map",n.baseColorTexture,th)),a.metalness=void 0!==n.metallicFactor?n.metallicFactor:1,a.roughness=void 0!==n.roughnessFactor?n.roughnessFactor:1,void 0!==n.metallicRoughnessTexture&&(l.push(t.assignTexture(a,"metalnessMap",n.metallicRoughnessTexture)),l.push(t.assignTexture(a,"roughnessMap",n.metallicRoughnessTexture))),o=this._invokeOne((function(t){return t.getMaterialType&&t.getMaterialType(e)})),l.push(Promise.all(this._invokeAll((function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,a)}))))}!0===r.doubleSided&&(a.side=zc);const c=r.alphaMode||wO;if(c===EO?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,c===SO&&(a.alphaTest=void 0!==r.alphaCutoff?r.alphaCutoff:.5)),void 0!==r.normalTexture&&o!==Wm&&(l.push(t.assignTexture(a,"normalMap",r.normalTexture)),a.normalScale=new Kh(1,1),void 0!==r.normalTexture.scale)){const e=r.normalTexture.scale;a.normalScale.set(e,e)}return void 0!==r.occlusionTexture&&o!==Wm&&(l.push(t.assignTexture(a,"aoMap",r.occlusionTexture)),void 0!==r.occlusionTexture.strength&&(a.aoMapIntensity=r.occlusionTexture.strength)),void 0!==r.emissiveFactor&&o!==Wm&&(a.emissive=(new mp).fromArray(r.emissiveFactor)),void 0!==r.emissiveTexture&&o!==Wm&&l.push(t.assignTexture(a,"emissiveMap",r.emissiveTexture,th)),Promise.all(l).then((function(){let n;return n=o===nO?i[kN.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].createMaterial(a):new o(a),r.name&&(n.name=r.name),TO(n,r),t.associations.set(n,{materials:e}),r.extensions&&AO(i,n,r),n}))}createUniqueName(e){const t=iS.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,i=this.primitiveCache;function r(e){return n[kN.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then((function(n){return LO(n,e,t)}))}const o=[];for(let n=0,a=e.length;n<a;n++){const a=e[n],s=MO(a),l=i[s];if(l)o.push(l.promise);else{let e;e=a.extensions&&a.extensions[kN.KHR_DRACO_MESH_COMPRESSION]?r(a):LO(new pf,a,t),i[s]={primitive:a,promise:e},o.push(e)}}return Promise.all(o)}loadMesh(e){const t=this,n=this.json,i=this.extensions,r=n.meshes[e],o=r.primitives,a=[];for(let e=0,t=o.length;e<t;e++){const t=void 0===o[e].material?(void 0===(s=this.cache).DefaultMaterial&&(s.DefaultMaterial=new dx({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:Fc})),s.DefaultMaterial):this.getDependency("material",o[e].material);a.push(t)}var s;return a.push(t.loadGeometries(o)),Promise.all(a).then((function(n){const a=n.slice(0,n.length-1),s=n[n.length-1],l=[];for(let n=0,c=s.length;n<c;n++){const c=s[n],u=o[n];let d;const h=a[n];if(u.mode===hO||u.mode===pO||u.mode===mO||void 0===u.mode)d=!0===r.isSkinnedMesh?new a_(c,h):new Of(c,h),!0!==d.isSkinnedMesh||d.geometry.attributes.skinWeight.normalized||d.normalizeSkinWeights(),u.mode===pO?d.geometry=PO(d.geometry,Kd):u.mode===mO&&(d.geometry=PO(d.geometry,Qd));else if(u.mode===cO)d=new I_(c,h);else if(u.mode===dO)d=new E_(c,h);else if(u.mode===uO)d=new M_(c,h);else{if(u.mode!==lO)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+u.mode);d=new P_(c,h)}Object.keys(d.geometry.morphAttributes).length>0&&IO(d,r),d.name=t.createUniqueName(r.name||"mesh_"+e),TO(d,r),u.extensions&&AO(i,d,u),t.assignFinalMaterial(d),l.push(d)}for(let n=0,i=l.length;n<i;n++)t.associations.set(l[n],{meshes:e,primitives:n});if(1===l.length)return l[0];const c=new xy;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],i=n[n.type];if(i)return"perspective"===n.type?t=new Uf(Xh.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):"orthographic"===n.type&&(t=new cg(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),TO(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=[],i=[],r=[],o=[],a=[];for(let e=0,s=t.channels.length;e<s;e++){const s=t.channels[e],l=t.samplers[s.sampler],c=s.target,u=c.node,d=void 0!==t.parameters?t.parameters[l.input]:l.input,h=void 0!==t.parameters?t.parameters[l.output]:l.output;n.push(this.getDependency("node",u)),i.push(this.getDependency("accessor",d)),r.push(this.getDependency("accessor",h)),o.push(l),a.push(c)}return Promise.all([Promise.all(n),Promise.all(i),Promise.all(r),Promise.all(o),Promise.all(a)]).then((function(n){const i=n[0],r=n[1],o=n[2],a=n[3],s=n[4],l=[];for(let e=0,t=i.length;e<t;e++){const t=i[e],n=r[e],c=o[e],u=a[e],d=s[e];if(void 0===t)continue;let h;switch(t.updateMatrix(),bO[d.path]){case bO.weights:h=Lx;break;case bO.rotation:h=Dx;break;default:h=Bx}const p=t.name?t.name:t.uuid,m=void 0!==u.interpolation?xO[u.interpolation]:Vd,f=[];bO[d.path]===bO.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=NO(g.constructor),t=new Float32Array(g.length);for(let n=0,i=g.length;n<i;n++)t[n]=g[n]*e;g=t}for(let e=0,t=f.length;e<t;e++){const t=new h(f[e]+"."+bO[d.path],n.array,g,m);"CUBICSPLINE"===u.interpolation&&(t.createInterpolant=function(e){return new(this instanceof Dx?sO:oO)(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 Fx(c,void 0,l)}))}createNodeMesh(e){const t=this.json,n=this,i=t.nodes[e];return void 0===i.mesh?null:n.getDependency("mesh",i.mesh).then((function(e){const t=n._getNodeRef(n.meshCache,i.mesh,e);return void 0!==i.weights&&t.traverse((function(e){if(e.isMesh)for(let t=0,n=i.weights.length;t<n;t++)e.morphTargetInfluences[t]=i.weights[t]})),t}))}loadNode(e){const t=this.json,n=this.extensions,i=this,r=t.nodes[e],o=r.name?i.createUniqueName(r.name):"";return function(){const t=[],n=i._invokeOne((function(t){return t.createNodeMesh&&t.createNodeMesh(e)}));return n&&t.push(n),void 0!==r.camera&&t.push(i.getDependency("camera",r.camera).then((function(e){return i._getNodeRef(i.cameraCache,r.camera,e)}))),i._invokeAll((function(t){return t.createNodeAttachment&&t.createNodeAttachment(e)})).forEach((function(e){t.push(e)})),Promise.all(t)}().then((function(t){let a;if(a=!0===r.isBone?new s_:t.length>1?new xy:1===t.length?t[0]:new Om,a!==t[0])for(let e=0,n=t.length;e<n;e++)a.add(t[e]);if(r.name&&(a.userData.name=r.name,a.name=o),TO(a,r),r.extensions&&AO(n,a,r),void 0!==r.matrix){const e=new am;e.fromArray(r.matrix),a.applyMatrix4(e)}else void 0!==r.translation&&a.position.fromArray(r.translation),void 0!==r.rotation&&a.quaternion.fromArray(r.rotation),void 0!==r.scale&&a.scale.fromArray(r.scale);return i.associations.has(a)||i.associations.set(a,{}),i.associations.get(a).nodes=e,a}))}loadScene(e){const t=this.json,n=this.extensions,i=this.json.scenes[e],r=this,o=new xy;i.name&&(o.name=r.createUniqueName(i.name)),TO(o,i),i.extensions&&AO(n,o,i);const a=i.nodes||[],s=[];for(let e=0,n=a.length;e<n;e++)s.push(RO(a[e],o,t,r));return Promise.all(s).then((function(){return r.associations=(e=>{const t=new Map;for(const[e,n]of r.associations)(e instanceof Vm||e instanceof bp)&&t.set(e,n);return e.traverse((e=>{const n=r.associations.get(e);null!=n&&t.set(e,n)})),t})(o),o}))}}function RO(e,t,n,i){const r=n.nodes[e];return i.getDependency("node",e).then((function(e){if(void 0===r.skin)return e;let t;return i.getDependency("skin",r.skin).then((function(e){t=e;const n=[];for(let e=0,r=t.joints.length;e<r;e++)n.push(i.getDependency("node",t.joints[e]));return Promise.all(n)})).then((function(n){return e.traverse((function(e){if(!e.isMesh)return;const i=[],r=[];for(let e=0,o=n.length;e<o;e++){const o=n[e];if(o){i.push(o);const n=new am;void 0!==t.inverseBindMatrices&&n.fromArray(t.inverseBindMatrices.array,16*e),r.push(n)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[e])}e.bind(new d_(i,r),e.matrixWorld)})),e}))})).then((function(e){t.add(e);const o=[];if(r.children){const t=r.children;for(let r=0,a=t.length;r<a;r++){const a=t[r];o.push(RO(a,e,n,i))}}return Promise.all(o)}))}function LO(e,t,n){const i=t.attributes,r=[];function o(t,i){return n.getDependency("accessor",t).then((function(t){e.setAttribute(i,t)}))}for(const t in i){const n=_O[t]||t.toLowerCase();n in e.attributes||r.push(o(i[t],n))}if(void 0!==t.indices&&!e.index){const i=n.getDependency("accessor",t.indices).then((function(t){e.setIndex(t)}));r.push(i)}return TO(e,t),function(e,t,n){const i=t.attributes,r=new Rp;if(void 0===i.POSITION)return;{const e=n.json.accessors[i.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(r.set(new Cp(t[0],t[1],t[2]),new Cp(o[0],o[1],o[2])),e.normalized){const t=NO(fO[e.componentType]);r.min.multiplyScalar(t),r.max.multiplyScalar(t)}}const o=t.targets;if(void 0!==o){const e=new Cp,t=new Cp;for(let i=0,r=o.length;i<r;i++){const r=o[i];if(void 0!==r.POSITION){const i=n.json.accessors[r.POSITION],o=i.min,a=i.max;if(void 0!==o&&void 0!==a){if(t.setX(Math.max(Math.abs(o[0]),Math.abs(a[0]))),t.setY(Math.max(Math.abs(o[1]),Math.abs(a[1]))),t.setZ(Math.max(Math.abs(o[2]),Math.abs(a[2]))),i.normalized){const e=NO(fO[i.componentType]);t.multiplyScalar(e)}e.max(t)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}r.expandByVector(e)}e.boundingBox=r;const a=new Xp;r.getCenter(a.center),a.radius=r.min.distanceTo(r.max)/2,e.boundingSphere=a}(e,t,n),Promise.all(r).then((function(){return void 0!==t.targets?function(e,t,n){let i=!1,r=!1,o=!1;for(let e=0,n=t.length;e<n;e++){const n=t[e];if(void 0!==n.POSITION&&(i=!0),void 0!==n.NORMAL&&(r=!0),void 0!==n.COLOR_0&&(o=!0),i&&r&&o)break}if(!i&&!r&&!o)return Promise.resolve(e);const a=[],s=[],l=[];for(let c=0,u=t.length;c<u;c++){const u=t[c];if(i){const t=void 0!==u.POSITION?n.getDependency("accessor",u.POSITION):e.attributes.position;a.push(t)}if(r){const t=void 0!==u.NORMAL?n.getDependency("accessor",u.NORMAL):e.attributes.normal;s.push(t)}if(o){const t=void 0!==u.COLOR_0?n.getDependency("accessor",u.COLOR_0):e.attributes.color;l.push(t)}}return Promise.all([Promise.all(a),Promise.all(s),Promise.all(l)]).then((function(t){const n=t[0],a=t[1],s=t[2];return i&&(e.morphAttributes.position=n),r&&(e.morphAttributes.normal=a),o&&(e.morphAttributes.color=s),e.morphTargetsRelative=!0,e}))}(e,t.targets,n):e}))}function PO(e,t){let n=e.getIndex();if(null===n){const t=[],i=e.getAttribute("position");if(void 0===i)return console.error("THREE.GLTFLoader.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e;for(let e=0;e<i.count;e++)t.push(e);e.setIndex(t),n=e.getIndex()}const i=n.count-2,r=[];if(t===Qd)for(let e=1;e<=i;e++)r.push(n.getX(0)),r.push(n.getX(e)),r.push(n.getX(e+1));else for(let e=0;e<i;e++)e%2==0?(r.push(n.getX(e)),r.push(n.getX(e+1)),r.push(n.getX(e+2))):(r.push(n.getX(e+2)),r.push(n.getX(e+1)),r.push(n.getX(e)));r.length/3!==i&&console.error("THREE.GLTFLoader.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const o=e.clone();return o.setIndex(r),o}let DO=null;function kO(e,t,n){return i=>{n&&n(i),e&&(DO||(DO=new NN),DO.setDecoderPath("string"==typeof e?e:"https://www.gstatic.com/draco/versioned/decoders/1.4.3/"),i.setDRACOLoader(DO)),t&&i.setMeshoptDecoder(LN())}}function BO(e,t=!0,n=!0,i){return dN(PN,e,kO(t,n,i))}BO.preload=(e,t=!0,n=!0,i)=>dN.preload(PN,e,kO(t,n,i)),BO.clear=e=>dN.clear(PN,e);c=o("85Hg2");function FO(e,t){const n=c.useRef(),[i]=c.useState((()=>t?t instanceof Om?{current:t}:t:n)),[r]=c.useState((()=>new sS(void 0))),o=c.useRef({}),[a]=c.useState((()=>{const t={};return e.forEach((e=>Object.defineProperty(t,e.name,{enumerable:!0,get(){if(i.current)return o.current[e.name]||(o.current[e.name]=r.clipAction(e,i.current))}}))),{ref:i,clips:e,actions:t,names:e.map((e=>e.name)),mixer:r}}));return lN(((e,t)=>r.update(t))),c.useEffect((()=>{const e=i.current;return()=>{o.current={},Object.values(a.actions).forEach((t=>{e&&r.uncacheAction(t,e)}))}}),[e]),a}const UO=new Cp(0,-1,0),zO=new gm(.175,0,0),GO=new Cp(0,-1.45,0),jO=[{italian:"Gioia",english:"Joy"},{italian:"Rabbia",english:"Anger"},{italian:"Sorpresa",english:"Surprise"},{italian:"Tristezza",english:"Sadness"},{italian:"Timore",english:"Fear"}],HO=[{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,mouthSmile:.5}},{emotion:{italian:"Gioia",english:"Joy"},blendShapes:{browDownLeft:.5,browDownRight:.5,browInnerUp:.5,mouthSmile:.5}}],VO={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"},WO={minInterval:1e3,maxInterval:5e3,blinkDuration:150};class qO{constructor(e,t,n){this.currentEmotionValues={},this.previousEmotionKeys=new Set,this.isRPM=!1,this.rpmBlendShapes=HO,this.customGlbMapping=jO,this.headMesh=e,this.isRPM="GBNL__Head"!==e.name,t&&(this.rpmBlendShapes=t),n&&(this.customGlbMapping=n)}processChatEmission(e,t){var n,i;const r=this.getDefaultEmotionMorphTargets();if(t||!e)return r;if(!(null==e?void 0:e.includes('<output class="memori-emotion">')))return r;const o=null===(i=null===(n=null==e?void 0:e.split('<output class="memori-emotion">')[1])||void 0===n?void 0:n.split("</output>")[0])||void 0===i?void 0:i.trim();return o?this.processEmotion(o):r}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 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,i,r,o){if(!this.headMesh.morphTargetDictionary||!this.headMesh.morphTargetInfluences)return void console.error("[MorphTargetController] Missing morphTargetDictionary or morphTargetInfluences");const a=this.processChatEmission(t,n),s=this.calculateBlinkValue(e,o,r),l=new Set(Object.keys(a));Object.entries(this.headMesh.morphTargetDictionary).forEach((([e,t])=>{if("number"!=typeof t)return;let n=0;if(l.has(e)){const t=a[e],i=this.currentEmotionValues[e]||0,r=Xh.lerp(i,1.5*t,.3);this.currentEmotionValues[e]=r,n+=r}if(i&&e===i.name&&(n+=i.weight),"eyesClosed"===e&&r&&(n+=s),n=Xh.clamp(n,0,1),this.headMesh.morphTargetInfluences){const e=Xh.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 i=0;if(e>=t.nextBlinkTime&&!t.isBlinking&&(t.isBlinking=!0,t.blinkStartTime=e,t.lastBlinkTime=e,t.nextBlinkTime=e+Math.random()*(WO.maxInterval-WO.minInterval)+WO.minInterval),t.isBlinking){const n=(e-t.blinkStartTime)/WO.blinkDuration;n<=.5?i=2*n:n<=1?i=2-2*n:(t.isBlinking=!1,i=0)}return i}}class $O{constructor(e=UO.clone(),t=GO.clone(),n=.6){this.defaultPosition=e,this.zoomedPosition=t,this.currentScale=new Cp(1,1,1),this.targetScale=new Cp(1,1,1),this.currentPosition=e.clone(),this.basePosition=e.clone(),this.initialCameraPosition=new Cp(0,0,n)}mapHeightToScale(e,t){return t?Xh.lerp(1.4,2.1,e/100):Xh.lerp(.5,1.5,e/100)}mapDepthToCamera(e,t){const n=this.initialCameraPosition.z;return Xh.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 YO{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=[],i="CUSTOM_GLB"){if(this.initialized||this.mixer)return void console.warn("[AvatarAnimator] Already initialized, ignoring duplicate initialization");this.mixer=new sS(e),this.avatarType=i,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 r=["Idle1","Idle2","Idle3","Idle4","Idle5"];let o=!1;for(const e of r)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}`)}))}registerAnimation(e,t){const n=t.getClip().duration;let i="ACTION",r=1,o=!1;const a=e.toLowerCase();a.includes("idle")?(i="IDLE",r=0,o=!0):(a.includes("loading")||a.includes("wait"))&&(i="LOADING",r=0,o=!0),this.animations.set(e,{name:e,category:i,duration:n,canLoop:o,defaultLoopCount:r})}play(e,t={}){var n,i,r,o;try{if(!this.initialized||!this.mixer)return void console.warn(`[AvatarAnimator] Cannot play ${e} - not initialized`);const a=this.actions[e];if(!a){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 s=this.getAnimationInfo(e);if(!s)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!==(i=t.fadeOutDuration)&&void 0!==i?i:this.fadeOutDuration,u=null!==(r=t.loopCount)&&void 0!==r?r:s.defaultLoopCount,d=null!==(o=t.timeScale)&&void 0!==o?o:this.timeScale;if("IDLE"===s.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))}a.reset(),a.fadeIn(l),a.timeScale=d,a.enabled=!0,0===u?a.setLoop(1/0,1/0):(a.setLoop(u>1?u:zd,u>1?u:1),a.clampWhenFinished=!0),a.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:s.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 i=e.match(/<output class="animation-sequence">(.*?)<\/output>/),r=e.match(/<output class="animation">(.*?)(\[loop=(\d+)\])?<\/output>/),o=e.match(/<output class="memori-emotion">(.*?)<\/output>/),a=this.calculateTransitionOptions();if(i&&i[1]){const e=i[1].trim();if(this.currentSequence&&this.currentSequence.join("->")===e&&this.sequenceIndex<this.currentSequence.length)return;this.executeWithTransition(e,a)}else{if(r&&r[1]){const e=r[1].trim();let t;return r[3]&&(t=parseInt(r[3],10)),void this.play(e,{...a,loopCount:t})}if(o&&o[1]){const e=o[1].trim();let t=[];if(jO.find((t=>t.english===e))){let n=jO.filter((t=>t.english===e));t=this.getAllAnimationNames().filter((e=>n.some((t=>e.toLowerCase().startsWith(t.italian.toLowerCase())))))}else t=this.getAllAnimationNames().filter((t=>t.toLowerCase().startsWith(e.toLowerCase())));if(t.length>0){const e=t[Math.floor(Math.random()*t.length)];return void this.play(e,a)}}"IDLE"!==this.getAnimationCategory()&&this.idle(a)}}calculateTransitionOptions(){var e,t;const n={fadeInDuration:this.fadeInDuration,fadeOutDuration:this.fadeOutDuration,timeScale:this.timeScale},i=(this.getAnimationCategory(),this.currentAnimation?this.actions[this.currentAnimation]:null);if(n.fadeOutDuration=.8,n.fadeInDuration=.8,i){const r=i.getClip(),o=i.time/r.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 i=e.match(/\[loop=(\d+)\]/);if(i&&(n=parseInt(i[1],10),e=e.replace(i[0],"").trim()),e.includes("->")){const i=e.split("->").map((e=>e.trim())),r={...t,loopCount:n||1};this.playSequence(i,r)}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,i,r,o,a,s,l,c;const u=this.getAnimationsByCategory("IDLE");if(u.length>0){let r=u;"IDLE"===this.getAnimationCategory()&&(r=u.filter((e=>e.name!==this.currentAnimation)),0===r.length&&(r=u));const o=r[Math.floor(Math.random()*r.length)].name,a={fadeInDuration:null!==(t=e.fadeInDuration)&&void 0!==t?t:.7,fadeOutDuration:null!==(n=e.fadeOutDuration)&&void 0!==n?n:.7,timeScale:null!==(i=e.timeScale)&&void 0!==i?i:.9,loopCount:0,...e};return a.loopCount=0,this.play(o,a),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!==(r=e.fadeInDuration)&&void 0!==r?r:.7,fadeOutDuration:null!==(o=e.fadeOutDuration)&&void 0!==o?o:.7,timeScale:null!==(a=e.timeScale)&&void 0!==a?a:.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!==(s=e.fadeInDuration)&&void 0!==s?s:.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,i;const r=this.getRandomAnimation("LOADING");if(r){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!==(i=e.timeScale)&&void 0!==i?i:this.timeScale,...e};o.loopCount=0,this.play(r,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 i=e.filter((e=>this.actions[e]));if(0===i.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=[...i],this.sequenceIndex=0;const r={fadeInDuration:.6,fadeOutDuration:.6,loopCount:1,timeScale:null!==(n=t.timeScale)&&void 0!==n?n:this.timeScale},o=i[0];this.play(o,r)}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}}}}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")}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 JO={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 "},ZO={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 "},XO=c.forwardRef((({scale:e,frames:t=1/0,opacity:n=1,width:i=1,height:r=1,blur:o=1,far:a=10,resolution:s=256,smooth:l=!0,color:u="#000000",...d},h)=>{const p=sN((({scene:e})=>e)),m=sN((({gl:e})=>e)),f=c.useRef(null);i*=Array.isArray(e)?e[0]:e||1,r*=Array.isArray(e)?e[1]:e||1;const[g,v,y,_,b,x,w]=c.useMemo((()=>{const e=new wp(s,s),t=new wp(s,s);t.texture.generateMipmaps=e.texture.generateMipmaps=!1;const n=new yE(i,r).rotateX(Math.PI/2),o=new Of(n),a=new my;a.depthTest=a.depthWrite=!1,a.onBeforeCompile=e=>{e.uniforms={...e.uniforms,ucolor:{value:new mp(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 Bf(JO),c=new Bf(ZO);return c.depthTest=l.depthTest=!1,[e,n,a,o,l,c,t]}),[s,i,r,e]),S=c.useCallback((e=>{_.visible=!0,_.material=b,b.uniforms.tDiffuse.value=g.texture,b.uniforms.h.value=1*e/256,m.setRenderTarget(w),m.render(_,f.current),_.material=x,x.uniforms.tDiffuse.value=w.texture,x.uniforms.v.value=1*e/256,m.setRenderTarget(g),m.render(_,f.current),_.visible=!1}),[]);let E=0;return lN((()=>{if(f.current&&(t===1/0||E<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,S(o),l&&S(.4*o),m.setRenderTarget(null),p.background=e,E++}})),c.createElement("group",bN({"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:[-i/2,i/2,r/2,-r/2,0,a]}))}));var KO=({animator:e,avatarPosition:t})=>{const n=(()=>{var t,n,i,r,o;const a={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"))?{...a,opacity:.85,blur:3,width:12,height:12}:(null===(n=e.getCurrentAnimationName())||void 0===n?void 0:n.includes("Gioia"))||(null===(i=e.getCurrentAnimationName())||void 0===i?void 0:i.includes("Joy"))?{...a,opacity:.9,blur:2,width:11,height:11}:(null===(r=e.getCurrentAnimationName())||void 0===r?void 0:r.includes("Rabbia"))||(null===(o=e.getCurrentAnimationName())||void 0===o?void 0:o.includes("Anger"))?{...a,opacity:.95,blur:1.8,width:12,height:12}:{...a,opacity:.9,blur:2.2}:{...a,opacity:0}})();return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(XO,{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,a.jsx)(XO,{opacity:1,width:5,height:5,blur:1,far:2,resolution:1024,color:"#000000",position:[0,-.98,0]})]})};c=o("85Hg2");const QO=(e,t,n=.05)=>e*(1-n)+t*n,eR=(e,t,n,i,r)=>((e=((e,t,n)=>Math.min(Math.max(e,t),n))(e,t,n))-t)*(r-i)/(n-t)+i,tR=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 nR=Math.PI/180;let iR,rR=!1;const oR=new Kh(0,0),aR=new Kh(0,0),sR=()=>{iR=setTimeout((()=>{rR=!0}),1e3)},lR=()=>{clearTimeout(iR),rR=!1};function cR(e,t){const{gl:n}=sN();(0,c.useEffect)((()=>{if(e)return n.domElement.addEventListener("mouseleave",sR),n.domElement.addEventListener("mouseenter",lR),()=>{n.domElement.removeEventListener("mouseleave",sR),n.domElement.removeEventListener("mouseenter",lR)}}),[n.domElement,e]),lN((n=>{if(!e||!(null==t?void 0:t.Neck)||!(null==t?void 0:t.Head))return;const i=Math.abs(n.camera.rotation.z);!rR&&i<.2?(oR.x=eR(n.mouse.y,-1,1,5*nR,-5*nR),oR.y=eR(n.mouse.x,-1,1,-10*nR,10*nR)):oR.set(0,0),aR.x=QO(aR.x,oR.x),aR.y=QO(aR.y,oR.y),t.Neck.rotation.x=aR.x+.1,t.Neck.rotation.y=aR.y,t.Head.rotation.x=2*aR.x,t.Head.rotation.y=2*aR.y}))}const uR=(0,c.memo)((function({url:e,sex:t,eyeBlink:n,updateCurrentViseme:i,avatarHeight:r=50,avatarDepth:o=0,onCameraZChange:s,chatEmission:l,loading:u,setAnimatorRef:d}){const{scene:h,animations:p}=BO(e),{animations:m}=BO(VO[t]),f=(0,c.useMemo)((()=>{let e=!1;return h.traverse((t=>{t instanceof a_&&("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}=FO(g,h),y=(0,c.useRef)(null),_=(0,c.useRef)(null),b=(0,c.useRef)(null),x=(0,c.useRef)(!1),w=(0,c.useRef)(UO.clone()),S=(0,c.useRef)(0),[E,A]=(0,c.useState)(!1),T=(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 a_){if("Wolf3D_Avatar"===t.name||"Wolf3D_Avatar006_1"===t.name)return A(!0),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||{}),i=n.some((e=>e.toLowerCase().includes("viseme"))),r=n.some((e=>{const t=e.toLowerCase();return t.includes("mouth")||t.includes("eye")||t.includes("jaw")||t.includes("smile")}));(i||r)&&(e=t)}}}})),e?y.current||(y.current=new qO(e)):console.warn("⚠️ No suitable avatar mesh found")}),[h]),(0,c.useEffect)((()=>(_.current||(_.current=new $O(UO)),()=>{})),[]),(0,c.useEffect)((()=>{_.current&&_.current.updateHeight(r,!1)}),[r]),(0,c.useEffect)((()=>{if(_.current&&s){const e=_.current.updateDepth(o,!1);s(e)}}),[o,s]),(0,c.useEffect)((()=>{if(!h||!v||x.current)return;b.current||(b.current=new YO);const e=b.current;return(async()=>{try{if(e.isInitialized())return;await e.initialize(h,v,g,E?"RPM":"CUSTOM_GLB"),d&&d(e),x.current=!0,e.setTimeScale(.8)}catch(e){console.error("Error initializing AvatarAnimator:",e)}})(),()=>{b.current&&x.current&&("mixer"in b.current&&b.current.mixer&&b.current.mixer.stopAllAction(),d&&d(null),x.current=!1)}}),[h,v,g,t,d]),lN((0,c.useCallback)(((e,t)=>{const r=1e3*e.clock.elapsedTime;if(b.current&&x.current&&b.current.update(t),y.current){const e=i(r/1e3);y.current.updateMorphTargets(r,l,u,e,n,T.current)}if(h&&_.current){const e=_.current.updateScale(.1);if(h.scale.copy(e),r-S.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))),w.current.copy(e),S.current=r}}}),[h,i,l,u,n]));const I=(0,c.useMemo)((()=>{var e;return(null===(e=_.current)||void 0===e?void 0:e.getPosition())||UO.clone()}),[]);return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(KO,{animator:b.current,avatarPosition:I}),(0,a.jsx)("group",{position:I,rotation:zO,children:(0,a.jsx)("primitive",{object:h})})]})})),dR=(0,c.memo)((function({url:e,updateCurrentViseme:t,eyeBlink:n=!1,avatarHeight:i=50,avatarDepth:r=0,headMovement:o=!1,onLoaded:s,onCameraZChange:l,chatEmission:u,loading:d=!1}){var h;const{scene:p}=BO(e),{nodes:m,materials:f}=(g=p,c.useMemo((()=>cN(g)),[g]));var g;const{camera:v}=sN(),y=(0,c.useRef)(null),_=(0,c.useRef)(null);(0,c.useRef)(v.position.z),cR(o,m);const b=(0,c.useRef)({isBlinking:!1,lastBlinkTime:0,nextBlinkTime:0,blinkStartTime:0}),x=(0,c.useMemo)((()=>{let e;return null==p||p.traverse((t=>{t instanceof a_&&("GBNL__Head"===t.name||"Wolf3D_Avatar"===t.name||"Wolf3D_Avatar006_1"===t.name)&&(e=t)})),e}),[p]);(0,c.useEffect)((()=>(_.current||(_.current=new $O(UO,GO)),x&&(y.current=new qO(x)),HE(f),null==s||s(),tR(m),()=>{Object.values(f).forEach((e=>e.dispose())),Object.values(m).filter(VE).forEach((e=>e.geometry.dispose()))})),[f,m,e,s,p,x]),(0,c.useEffect)((()=>{_.current&&_.current.updateHeight(i,!0)}),[i]),(0,c.useEffect)((()=>{if(_.current&&l){const e=_.current.updateDepth(r,!0);l(e)}}),[r,l]),lN((e=>{const i=1e3*e.clock.elapsedTime;if(y.current){const e=t(i/1e3);y.current.updateMorphTargets(i,u,d,e,n,b.current)}if(p&&_.current){const e=_.current.updateScale(.1);p.scale.copy(e)}}));const w=(null===(h=_.current)||void 0===h?void 0:h.getPosition())||UO;return(0,a.jsx)("group",{position:w,children:(0,a.jsx)("primitive",{object:p})})})),hR=({chatEmission:e,url:t,sex:n,eyeBlink:i,halfBody:r,loading:o,avatarHeight:s=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&&(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:s,avatarDepth:l,setAnimatorRef:f})),[t,d,u,s,l,f]);return(0,a.jsxs)(a.Fragment,{children:[r?(0,a.jsx)(dR,{...g(),eyeBlink:i,headMovement:h}):(0,a.jsx)(uR,{...g(),sex:n,eyeBlink:i,chatEmission:e,loading:o}),p&&m.current&&(0,a.jsx)("div",{className:"animation-controls"})]})};(0,c.memo)(hR),c=o("85Hg2");const pR={muteSpeaker:"@memori:muteSpeaker",microphoneMode:"@memori:microphoneMode",continuousSpeechTimeout:"@memori:continuousSpeechTimeout",birthDate:"@memori:birthDate",controlsPosition:"@memori:controlsPosition",hideEmissions:"@memori:hideEmissions",loginToken:"@memori:loginToken",location:"@memori:location"},mR=(e,t)=>{var n;try{const i=window.localStorage.getItem(null!==(n=pR[e])&&void 0!==n?n:e);if(!i)return t;try{return JSON.parse(i)}catch(e){return i}}catch(e){return console.error("error",e),t}},fR=(e,t)=>{var n;try{window.localStorage.setItem(null!==(n=pR[e])&&void 0!==n?n:e,t.toString())}catch(e){console.error("error",e)}},gR=e=>{var t;try{window.localStorage.removeItem(null!==(t=pR[e])&&void 0!==t?t:e)}catch(e){console.error("error",e)}};c=o("85Hg2"),c=o("85Hg2");var vR=(e=>(e[e.Open=0]="Open",e[e.Closed=1]="Closed",e))(vR||{}),yR=(e=>(e[e.Single=0]="Single",e[e.Multi=1]="Multi",e))(yR||{}),_R=(e=>(e[e.Pointer=0]="Pointer",e[e.Other=1]="Other",e))(_R||{}),bR=(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))(bR||{});function xR(e,t=(e=>e)){let n=null!==e.activeOptionIndex?e.options[e.activeOptionIndex]:null,i=Qs(t(e.options.slice()),(e=>e.dataRef.current.domRef.current)),r=n?i.indexOf(n):null;return-1===r&&(r=null),{options:i,activeOptionIndex:r}}let wR={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:i,compare:r}=e.propsRef.current,o=e.options.findIndex((e=>{let t=e.dataRef.current.value;return Ba(i,{1:()=>n.some((e=>r(e,t))),0:()=>r(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 i=xR(e),r=XE(t,{resolveItems:()=>i.options,resolveActiveIndex:()=>i.activeOptionIndex,resolveId:e=>e.id,resolveDisabled:e=>e.dataRef.current.disabled});return{...e,...i,searchQuery:"",activeOptionIndex:r,activationTrigger:null!=(n=t.trigger)?n:1}},5:(e,t)=>{if(e.disabled||1===e.listboxState)return e;let n=""!==e.searchQuery?0:1,i=e.searchQuery+t.value.toLowerCase(),r=(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(i))})),o=r?e.options.indexOf(r):-1;return-1===o||o===e.activeOptionIndex?{...e,searchQuery:i}:{...e,searchQuery:i,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},i=xR(e,(e=>[...e,n]));if(null===e.activeOptionIndex){let{value:r,mode:o,compare:a}=e.propsRef.current,s=t.dataRef.current.value;Ba(o,{1:()=>r.some((e=>a(e,s))),0:()=>a(r,s)})&&(i.activeOptionIndex=i.options.indexOf(n))}return{...e,...i}},8:(e,t)=>{let n=xR(e,(e=>{let n=e.findIndex((e=>e.id===t.id));return-1!==n&&e.splice(n,1),e}));return{...e,...n,activationTrigger:1}}},SR=(0,c.createContext)(null);function ER(e){let t=(0,c.useContext)(SR);if(null===t){let t=new Error(`<${e} /> is missing a parent <Listbox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(t,ER),t}return t}function AR(e,t){return Ba(t.type,wR,e,t)}SR.displayName="ListboxContext";let TR=c.Fragment,IR=Va((function(e,n){let{value:i,defaultValue:r,name:o,onChange:a,by:s=((e,t)=>e===t),disabled:l=!1,horizontal:u=!1,multiple:d=!1,...h}=e;const p=u?"horizontal":"vertical";let m=as(n),[f,g]=nA(i,a,r),v=(0,c.useReducer)(AR,{listboxState:1,propsRef:{current:{value:f,onChange:g,mode:d?1:0,compare:is("string"==typeof s?(e,t)=>{let n=s;return(null==e?void 0:e[n])===(null==t?void 0:t[n])}:s)}},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:b,buttonRef:x},w]=v;_.current.value=f,_.current.mode=d?1:0,Ka((()=>{_.current.onChange=e=>Ba(_.current.mode,{0:()=>g(e),1(){let t=_.current.value.slice(),{compare:n}=_.current,i=t.findIndex((t=>n(t,e)));return-1===i?t.push(e):t.splice(i,1),g(t)}})}),[g,_]),Ka((()=>w({type:2,disabled:l})),[l]),Ka((()=>w({type:3,orientation:p})),[p]),Rl([x,b],((e,t)=>{var n;w({type:1}),Js(t,Ys.Loose)||(e.preventDefault(),null==(n=x.current)||n.focus())}),0===y);let S=(0,c.useMemo)((()=>({open:0===y,disabled:l,value:f})),[y,l,f]),E={ref:m};return t(c).createElement(SR.Provider,{value:v},t(c).createElement(Za,{value:Ba(y,{0:Ya.Open,1:Ya.Closed})},null!=o&&null!=f&&KE({[o]:f}).map((([e,n])=>t(c).createElement(zs,{features:Us.Hidden,...Wa({key:e,as:"input",type:"hidden",hidden:!0,readOnly:!0,name:e,value:n})}))),Ga({ourProps:E,theirProps:h,slot:S,defaultTag:TR,name:"Listbox"})))})),MR=Va((function(e,t){var n;let[i,r]=ER("Listbox.Button"),o=as(i.buttonRef,t),a=`headlessui-listbox-button-${Fs()}`,s=fs(),l=is((e=>{switch(e.key){case Ls.Space:case Ls.Enter:case Ls.ArrowDown:e.preventDefault(),r({type:0}),s.nextFrame((()=>{i.propsRef.current.value||r({type:4,focus:ZE.First})}));break;case Ls.ArrowUp:e.preventDefault(),r({type:0}),s.nextFrame((()=>{i.propsRef.current.value||r({type:4,focus:ZE.Last})}))}})),u=is((e=>{if(e.key===Ls.Space)e.preventDefault()})),d=is((e=>{if(Ps(e.currentTarget))return e.preventDefault();0===i.listboxState?(r({type:1}),s.nextFrame((()=>{var e;return null==(e=i.buttonRef.current)?void 0:e.focus({preventScroll:!0})}))):(e.preventDefault(),r({type:0}))})),h=qE((()=>{if(i.labelRef.current)return[i.labelRef.current.id,a].join(" ")}),[i.labelRef.current,a]),p=(0,c.useMemo)((()=>({open:0===i.listboxState,disabled:i.disabled,value:i.propsRef.current.value})),[i]),m=e;return Ga({ourProps:{ref:o,id:a,type:YE(e,i.buttonRef),"aria-haspopup":!0,"aria-controls":null==(n=i.optionsRef.current)?void 0:n.id,"aria-expanded":i.disabled?void 0:0===i.listboxState,"aria-labelledby":h,disabled:i.disabled,onKeyDown:l,onKeyUp:u,onClick:d},theirProps:m,slot:p,defaultTag:"button",name:"Listbox.Button"})})),CR=Va((function(e,t){let[n]=ER("Listbox.Label"),i=`headlessui-listbox-label-${Fs()}`;return Ga({ourProps:{ref:as(n.labelRef,t),id:i,onClick:is((()=>{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"})})),NR=Ua.RenderStrategy|Ua.Static,OR=Va((function(e,t){var n;let[i,r]=ER("Listbox.Options"),o=as(i.optionsRef,t),a=`headlessui-listbox-options-${Fs()}`,s=fs(),l=fs(),u=Ja(),d=null!==u?u===Ya.Open:0===i.listboxState;(0,c.useEffect)((()=>{var e;let t=i.optionsRef.current;!t||0===i.listboxState&&t!==(null==(e=Gs(t))?void 0:e.activeElement)&&t.focus({preventScroll:!0})}),[i.listboxState,i.optionsRef]);let h=is((e=>{switch(l.dispose(),e.key){case Ls.Space:if(""!==i.searchQuery)return e.preventDefault(),e.stopPropagation(),r({type:5,value:e.key});case Ls.Enter:if(e.preventDefault(),e.stopPropagation(),null!==i.activeOptionIndex){let{dataRef:e}=i.options[i.activeOptionIndex];i.propsRef.current.onChange(e.current.value)}0===i.propsRef.current.mode&&(r({type:1}),cs().nextFrame((()=>{var e;return null==(e=i.buttonRef.current)?void 0:e.focus({preventScroll:!0})})));break;case Ba(i.orientation,{vertical:Ls.ArrowDown,horizontal:Ls.ArrowRight}):return e.preventDefault(),e.stopPropagation(),r({type:4,focus:ZE.Next});case Ba(i.orientation,{vertical:Ls.ArrowUp,horizontal:Ls.ArrowLeft}):return e.preventDefault(),e.stopPropagation(),r({type:4,focus:ZE.Previous});case Ls.Home:case Ls.PageUp:return e.preventDefault(),e.stopPropagation(),r({type:4,focus:ZE.First});case Ls.End:case Ls.PageDown:return e.preventDefault(),e.stopPropagation(),r({type:4,focus:ZE.Last});case Ls.Escape:return e.preventDefault(),e.stopPropagation(),r({type:1}),s.nextFrame((()=>{var e;return null==(e=i.buttonRef.current)?void 0:e.focus({preventScroll:!0})}));case Ls.Tab:e.preventDefault(),e.stopPropagation();break;default:1===e.key.length&&(r({type:5,value:e.key}),l.setTimeout((()=>r({type:6})),350))}})),p=qE((()=>{var e,t,n;return null!=(n=null==(e=i.labelRef.current)?void 0:e.id)?n:null==(t=i.buttonRef.current)?void 0:t.id}),[i.labelRef.current,i.buttonRef.current]),m=(0,c.useMemo)((()=>({open:0===i.listboxState})),[i]),f=e;return Ga({ourProps:{"aria-activedescendant":null===i.activeOptionIndex||null==(n=i.options[i.activeOptionIndex])?void 0:n.id,"aria-multiselectable":1===i.propsRef.current.mode||void 0,"aria-labelledby":p,"aria-orientation":i.orientation,id:a,onKeyDown:h,role:"listbox",tabIndex:0,ref:o},theirProps:f,slot:m,defaultTag:"ul",features:NR,visible:d,name:"Listbox.Options"})})),RR=Va((function(e,t){let{disabled:n=!1,value:i,...r}=e,[o,a]=ER("Listbox.Option"),s=`headlessui-listbox-option-${Fs()}`,l=null!==o.activeOptionIndex&&o.options[o.activeOptionIndex].id===s,{value:u,compare:d}=o.propsRef.current,h=Ba(o.propsRef.current.mode,{1:()=>u.some((e=>d(e,i))),0:()=>d(u,i)}),p=(0,c.useRef)(null),m=as(t,p);Ka((()=>{if(0!==o.listboxState||!l||0===o.activationTrigger)return;let e=cs();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:i,domRef:p});Ka((()=>{f.current.disabled=n}),[f,n]),Ka((()=>{f.current.value=i}),[f,i]),Ka((()=>{var e,t;f.current.textValue=null==(t=null==(e=p.current)?void 0:e.textContent)?void 0:t.toLowerCase()}),[f,p]);let g=is((()=>o.propsRef.current.onChange(i)));Ka((()=>(a({type:7,id:s,dataRef:f}),()=>a({type:8,id:s}))),[f,s]);let v=is((e=>{if(n)return e.preventDefault();g(),0===o.propsRef.current.mode&&(a({type:1}),cs().nextFrame((()=>{var e;return null==(e=o.buttonRef.current)?void 0:e.focus({preventScroll:!0})})))})),y=is((()=>{if(n)return a({type:4,focus:ZE.Nothing});a({type:4,focus:ZE.Specific,id:s})})),_=is((()=>{n||l||a({type:4,focus:ZE.Specific,id:s,trigger:0})})),b=is((()=>{n||!l||a({type:4,focus:ZE.Nothing})})),x=(0,c.useMemo)((()=>({active:l,selected:h,disabled:n})),[l,h,n]);return Ga({ourProps:{id:s,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:b,onMouseLeave:b},theirProps:r,slot:x,defaultTag:"li",name:"Listbox.Option"})})),LR=Object.assign(IR,{Button:MR,Label:CR,Options:OR,Option:RR});var PR=({min:e=0,max:n=100,step:i=1,defaultValue:r=50,label:o,onChange:s,disabled:l=!1})=>{const[u,d]=(0,c.useState)(r),[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 r=m.current.getBoundingClientRect(),o=t-r.left,a=r.width,s=Math.max(0,Math.min(100,o/a*100)),l=Math.round(s/100*(n-e)+e),c=Math.round(l/i)*i;return Math.min(Math.max(c,e),n)},y=e=>{if(l)return;p(!0);const t=v(e);d(t),null==s||s(t)},_=e=>{if(!h||l)return;const t=v(e);d(t),null==s||s(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(r)}),[r]),(0,a.jsxs)("div",{className:t(We)("memori--slider-container",{"memori--slider-disabled":l}),style:{"--percentage":`${f}%`},children:[(0,a.jsxs)("div",{className:"memori--slider-header",children:[o&&(0,a.jsx)("div",{className:"memori--slider-label",children:o}),(0,a.jsx)("div",{className:"memori--slider-value",children:u})]}),(0,a.jsxs)("div",{ref:m,className:"memori--slider-track-container",onMouseDown:e=>y(e.clientX),onTouchStart:e=>y(e.touches[0].clientX),children:[(0,a.jsx)("div",{className:"memori--slider-track",children:(0,a.jsx)("div",{className:"memori--slider-track-fill"})}),(0,a.jsx)("div",{className:"memori--slider-marks",children:g.map((e=>(0,a.jsxs)("div",{className:"memori--slider-mark",children:[(0,a.jsx)("div",{className:"memori--slider-mark-line"}),(0,a.jsx)("span",{className:"memori--slider-mark-value",children:e})]},e)))}),(0,a.jsx)(LR,{value:u,onChange:d,disabled:l,children:(0,a.jsx)("div",{className:"memori--slider-thumb",role:"slider","aria-valuemin":e,"aria-valuemax":n,"aria-valuenow":u,tabIndex:l?-1:0})})]})]})};var DR=({avatarHeight:e,avatarDepth:t,setAvatarHeight:n,setAvatarDepth:i,halfBody:r,setEnablePositionControls:o})=>{const s=r?{height:80,depth:50}:{height:25,depth:25},l=r?{height:55,depth:10}:{height:15,depth:5},u=r?{height:100,depth:80}:{height:65,depth:100},d=(0,c.useRef)({height:e,depth:t,zoomed:!1,normal:!1,far:!1}),{t:h}=Ve();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);i(e),fR("avatarDepth",e)}else if(("+"===e.key||"="===e.key)&&d.current.depth>-100){const e=Math.max(d.current.depth-10,-100);i(e),fR("avatarDepth",e)}};return window.addEventListener("keydown",e),()=>{window.removeEventListener("keydown",e)}}),[i]),(0,c.useEffect)((()=>{const e=e=>{if("ArrowUp"===e.key&&d.current.height<100){const e=d.current.height+5;n(e),fR("avatarHeight",e)}},t=e=>{if("ArrowDown"===e.key&&d.current.height>0){const e=d.current.height-5;n(e),fR("avatarHeight",e)}};return window.addEventListener("keydown",e),window.addEventListener("keydown",t),()=>{window.removeEventListener("keydown",e),window.removeEventListener("keydown",t)}}),[n]),(0,a.jsxs)("div",{className:"memori--position-controls",children:[(0,a.jsx)("div",{className:"memori--position-controls-close",children:(0,a.jsx)(Jl,{ghost:!0,icon:(0,a.jsx)(Zl,{}),outlined:!0,danger:!0,shape:"circle",className:"memori--position-controls-close-button",onClick:()=>{o(!1)}})}),(0,a.jsx)(PR,{defaultValue:d.current.height,min:.5,max:100,label:h("write_and_speak.height"),step:1,onChange:e=>{n(e),fR("avatarHeight",e)}}),(0,a.jsx)(PR,{defaultValue:d.current.depth,min:.5,max:100,step:5,label:h("write_and_speak.depth"),onChange:e=>{i(e),fR("avatarDepth",e)}}),(0,a.jsxs)("div",{className:"memori--preset-buttons",children:[(0,a.jsx)(Jl,{outlined:!0,isActive:e===(r?l.height:s.height)&&t===(r?l.depth:s.depth),onClick:()=>{n(l.height),i(l.depth),fR("avatarHeight",l.height),fR("avatarDepth",l.depth)},children:h("write_and_speak.zoomed")}),(0,a.jsx)(Jl,{outlined:!0,isActive:e===(r?s.height:l.height)&&t===(r?s.depth:l.depth),onClick:()=>{n(s.height),i(s.depth),fR("avatarHeight",s.height),fR("avatarDepth",s.depth)},children:h("write_and_speak.normal")}),(0,a.jsx)(Jl,{outlined:!0,isActive:e===(r?u.height:s.height)&&t===(r?u.depth:s.depth),onClick:()=>{n(u.height),i(u.depth),fR("avatarHeight",u.height),fR("avatarDepth",u.depth)},children:h("write_and_speak.far")})]})]})};let kR=0;const BR=t(_C)((e=>(jx.onStart=(t,n,i)=>{e({active:!0,item:t,loaded:n,total:i,progress:(n-kR)/(i-kR)*100})},jx.onLoad=()=>{e({active:!1})},jx.onError=t=>e((e=>({errors:[...e.errors,t]}))),jx.onProgress=(t,n,i)=>{n===i&&(kR=i),e({active:!0,item:t,loaded:n,total:i,progress:(n-kR)/(i-kR)*100||100})},{errors:[],active:!1,progress:0,item:"",loaded:0,total:0})));c=o("85Hg2");const FR=new Cp,UR=new Cp,zR=new Cp;function GR(e,t,n){const i=FR.setFromMatrixPosition(e.matrixWorld);i.project(t);const r=n.width/2,o=n.height/2;return[i.x*r+r,-i.y*o+o]}const jR=e=>Math.abs(e)<1e-10?0:e;function HR(e,t,n=""){let i="matrix3d(";for(let n=0;16!==n;n++)i+=jR(t[n]*e.elements[n])+(15!==n?",":")");return n+i}const VR=(WR=[1,-1,1,1,1,-1,1,1,1,-1,1,1,1,-1,1,1],e=>HR(e,WR));var WR;const qR=(e,t)=>{return HR(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},$R=c.forwardRef((({children:e,eps:t=.001,style:n,className:i,prepend:r,center:o,fullscreen:a,portal:l,distanceFactor:u,sprite:d=!1,transform:h=!1,occlude:p,onOcclude:m,zIndexRange:f=[16777271,0],calculatePosition:g=GR,as:v="div",wrapperClass:y,pointerEvents:_="auto",...b},x)=>{var w;const S=sN((({gl:e})=>e)),E=sN((({camera:e})=>e)),A=sN((({scene:e})=>e)),T=sN((({size:e})=>e)),I=sN((({raycaster:e})=>e)),[M]=c.useState((()=>document.createElement(v))),C=c.useRef(null),N=c.useRef(0),O=c.useRef([0,0]),R=c.useRef(null),L=c.useRef(null),P=null!==(w=null==l?void 0:l.current)&&void 0!==w?w:S.domElement.parentNode;c.useEffect((()=>{if(C.current){if(A.updateMatrixWorld(),h)M.style.cssText="position:absolute;top:0;left:0;pointer-events:none;overflow:hidden;";else{const e=g(C.current,E,T);M.style.cssText=`position:absolute;top:0;left:0;transform:translate3d(${e[0]}px,${e[1]}px,0);transform-origin:0 0;`}return P&&(r?P.prepend(M):P.appendChild(M)),()=>{P&&P.removeChild(M),s.unmountComponentAtNode(M)}}}),[P,h]),c.useLayoutEffect((()=>{y&&(M.className=y)}),[y]);const D=c.useMemo((()=>h?{position:"absolute",top:0,left:0,width:T.width,height:T.height,transformStyle:"preserve-3d",pointerEvents:"none"}:{position:"absolute",transform:o?"translate3d(-50%,-50%,0)":"none",...a&&{top:-T.height/2,left:-T.width/2,width:T.width,height:T.height},...n}),[n,o,a,T,h]),k=c.useMemo((()=>({position:"absolute",pointerEvents:_})),[_]);c.useLayoutEffect((()=>{h?s.render(c.createElement("div",{ref:R,style:D},c.createElement("div",{ref:L,style:k},c.createElement("div",{ref:x,className:i,style:n,children:e}))),M):s.render(c.createElement("div",{ref:x,style:D,className:i,children:e}),M)}));const B=c.useRef(!0);return lN((()=>{if(C.current){E.updateMatrixWorld(),C.current.updateWorldMatrix(!0,!1);const e=h?O.current:g(C.current,E,T);if(h||Math.abs(N.current-E.zoom)>t||Math.abs(O.current[0]-e[0])>t||Math.abs(O.current[1]-e[1])>t){const t=function(e,t){const n=FR.setFromMatrixPosition(e.matrixWorld),i=UR.setFromMatrixPosition(t.matrixWorld),r=n.sub(i),o=t.getWorldDirection(zR);return r.angleTo(o)>Math.PI/2}(C.current,E);let n=!1;"boolean"==typeof p?!0===p&&(n=[A]):Array.isArray(p)&&(n=p.map((e=>e.current)));const i=B.current;if(n){const e=function(e,t,n,i){const r=FR.setFromMatrixPosition(e.matrixWorld),o=r.clone();o.project(t),n.setFromCamera(o,t);const a=n.intersectObjects(i,!0);if(a.length){const e=a[0].distance;return r.distanceTo(n.ray.origin)<e}return!0}(C.current,E,I,n);B.current=e&&!t}else B.current=!t;if(i!==B.current&&(m?m(!B.current):M.style.display=B.current?"block":"none"),M.style.zIndex=`${function(e,t,n){if(t instanceof Uf||t instanceof cg){const i=FR.setFromMatrixPosition(e.matrixWorld),r=UR.setFromMatrixPosition(t.matrixWorld),o=i.distanceTo(r),a=(n[1]-n[0])/(t.far-t.near),s=n[1]-a*t.far;return Math.round(a*o+s)}}(C.current,E,f)}`,h){const[e,t]=[T.width/2,T.height/2],n=E.projectionMatrix.elements[5]*t,{isOrthographicCamera:i,top:r,left:o,bottom:a,right:s}=E,l=VR(E.matrixWorldInverse),c=i?`scale(${n})translate(${jR(-(s+o)/2)}px,${jR((r+a)/2)}px)`:`translateZ(${n}px)`;let h=C.current.matrixWorld;d&&(h=E.matrixWorldInverse.clone().transpose().copyPosition(h).scale(C.current.scale),h.elements[3]=h.elements[7]=h.elements[11]=0,h.elements[15]=1),M.style.width=T.width+"px",M.style.height=T.height+"px",M.style.perspective=i?"":`${n}px`,R.current&&L.current&&(R.current.style.transform=`${c}${l}translate(${e}px,${t}px)`,L.current.style.transform=qR(h,1/((u||10)/400)))}else{const t=void 0===u?1:function(e,t){if(t instanceof cg)return t.zoom;if(t instanceof Uf){const n=FR.setFromMatrixPosition(e.matrixWorld),i=UR.setFromMatrixPosition(t.matrixWorld),r=t.fov*Math.PI/180,o=n.distanceTo(i);return 1/(2*Math.tan(r/2)*o)}return 1}(C.current,E)*u;M.style.transform=`translate3d(${e[0]}px,${e[1]}px,0) scale(${t})`}O.current=e,N.current=E.zoom}}})),c.createElement("group",bN({},b,{ref:C}))}));var YR=({fallbackImg:e})=>{const{progress:t}=BR();return(0,a.jsx)($R,{center:!0,className:"avatar-loader",children:(0,a.jsx)(Yl,{spinning:!0,children:e?(0,a.jsxs)("figure",{children:[(0,a.jsx)("img",{src:e,alt:`${Math.round(t)}% loaded`,title:`${Math.round(t)}% loaded`}),(0,a.jsx)("figcaption",{children:`${Math.round(t)}%`})]}):(0,a.jsxs)(a.Fragment,{children:[Math.round(t)," % loaded"]})})})};c=o("85Hg2");const JR=e=>{return t=Object.entries(e).filter((([e,t])=>void 0!==t)),Object.assign({},...t.map((([e,t])=>({[e]:t}))));var t},ZR=Object.freeze({fillLightAngle:Math.PI/3,backLightAngle:Math.PI/8,keyLightAngle:Math.PI/2,silhouetteLightAngle:1.25*Math.PI,keyLightPosition:new Cp(.75,1.75,.75),liftLightPosition:new Cp(.25,1.5,2),dirLightPosition:new Cp(-.75,2.5,-1),silhouetteLightPosition:new Cp(-1.25,.25,-1.25),defaultProps:{keyLightIntensity:1.2,keyLightColor:"#FFF5EB",fillLightIntensity:2.5,fillLightColor:"#A4C4FF",fillLightPosition:new Cp(-.6,1.7,-.4),backLightIntensity:4,backLightColor:"#FFD4A8",backLightPosition:new Cp(.6,1.7,-1),lightTarget:new Cp(0,1.65,0)}});var XR=e=>{const{keyLightIntensity:t,keyLightColor:n,fillLightIntensity:i,fillLightColor:r,fillLightPosition:o,backLightIntensity:s,backLightColor:l,backLightPosition:u,lightTarget:d}=Object.assign(ZR.defaultProps,JR(e)),{scene:h}=sN(),[p]=(0,c.useState)({head:new Om,shoe:new Om});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,a.jsxs)("group",{children:[(0,a.jsx)("spotLight",{position:o,target:p.head,angle:ZR.fillLightAngle,color:r,intensity:i,castShadow:!0,"shadow-bias":-1e-4,penumbra:.2}),(0,a.jsx)("spotLight",{position:u,target:p.head,angle:ZR.backLightAngle,color:l,intensity:s,castShadow:!0,"shadow-bias":-1e-4,penumbra:.2}),(0,a.jsx)("spotLight",{position:ZR.keyLightPosition,target:p.head,angle:ZR.keyLightAngle,color:n,intensity:t,penumbra:.3,castShadow:!0}),(0,a.jsx)("spotLight",{position:ZR.liftLightPosition,target:p.shoe,angle:ZR.keyLightAngle,color:n,intensity:.3*t,penumbra:.4}),(0,a.jsx)("spotLight",{position:ZR.silhouetteLightPosition,target:p.head,angle:ZR.silhouetteLightAngle,color:n,intensity:.3*t,penumbra:.3}),(0,a.jsx)("ambientLight",{intensity:.2,color:"#FFF8EF"})]})};const KR={halfBody:{width:"100%",height:"100%",minHeight:"500px",backgroundColor:"white",borderRadius:"100%"},fullBody:{width:"500px",height:"500px",backgroundColor:"white"}},QR=(e,t)=>({fov:t?44:40,position:[0,0,e?.6:3],target:[0,0,0]});function eL({url:e,sex:t,style:n,rotateAvatar:i,eyeBlink:r,headMovement:o,speaking:s,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[b,x]=(0,c.useState)((()=>QR(d,m||!1).position[2])),[w,S]=(0,c.useState)((()=>{if(_){return mR("avatarHeight",50)}return d?80:m?16:65})()),[E,A]=(0,c.useState)((()=>{if(_){return mR("avatarDepth",50)}return d?50:m?5:100})());return(0,a.jsxs)(a.Fragment,{children:[v&&(0,a.jsx)(DR,{avatarHeight:w,avatarDepth:E,halfBody:d,setAvatarHeight:S,setAvatarDepth:A,setEnablePositionControls:y}),(0,a.jsxs)(oN,{style:n||KR.fullBody,shadows:!0,dpr:[1,2],gl:{antialias:!0,alpha:!0,powerPreference:"high-performance",stencil:!1},children:[(0,a.jsx)(MN,{makeDefault:!0,position:[0,0,b],fov:QR(d,m||!1).fov,near:.1,far:1e3}),i&&(0,a.jsx)(IN,{enablePan:!1,enableZoom:!1,target:[0,0,0],enableDamping:!0,dampingFactor:.05}),(0,a.jsxs)(c.Suspense,{fallback:l||(0,a.jsx)(YR,{fallbackImg:u}),children:[(0,a.jsx)(XR,{}),(0,a.jsx)(hR,{url:e,sex:t,showControls:p,loading:h||!1,eyeBlink:r||!1,headMovement:o||!1,speaking:s||!1,halfBody:d,chatEmission:f,updateCurrentViseme:g,setCameraZ:x,avatarHeight:w,avatarDepth:E})]})]})]})}const tL=(0,(c=o("85Hg2")).createContext)(void 0),nL={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:iL,VISEME_OVERLAP:rL,SMOOTHING_FACTOR:oL,LOG_INTERVAL:aL,PRELOAD:sL,WEIGHT_MULTIPLIER:lL}={DEFAULT_VISEME_DURATION:.12,VISEME_OVERLAP:.02,SMOOTHING_FACTOR:.4,LOG_INTERVAL:60,PRELOAD:.2,WEIGHT_MULTIPLIER:.8},cL=(e,t)=>e.endTime<t-rL,uL=e=>Math.sin(Math.PI*Math.min(e,1))*lL,dL=(e,t)=>e+(t-e)*oL,hL=({children:e})=>{const t=(0,c.useRef)([]),n=(0,c.useRef)(null),i=(0,c.useRef)(null),[r,o]=(0,c.useState)(!1),[s,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,null!==e.onstatechange&&(e.onstatechange=()=>{switch(e.state){case"running":l("active");break;case"suspended":l("paused");break;case"closed":l("finished"),v()}})}),[]),m=(0,c.useCallback)((e=>{e?(n.current=e,i.current=e.currentTime,d.current=0,o(!0),l("active")):console.error("[VisemeContext] No audio context provided")}),[]),f=(0,c.useCallback)(((e,n)=>{if("finished"===s)return;const i=nL[e]||"viseme_sil",r=n/1e7;null===h.current&&(h.current=r);const o=r-(h.current||0),a={name:i,weight:0,startTime:o,endTime:o+iL};t.current.push(a),"idle"===s&&l("preparing")}),[s]),g=(0,c.useCallback)((()=>{t.current=[],u.current=null,i.current=null,h.current=null,d.current=0,l("idle")}),[]),v=(0,c.useCallback)((()=>{o(!1),l("finished"),i.current=null,u.current=null,d.current=0,n.current=null}),[]),y=(0,c.useCallback)((e=>{if(!r||!n.current)return null;const o=n.current.currentTime-(i.current||0)+sL;t.current=t.current.filter((e=>!cL(e,o)));const a=t.current.find((e=>e.startTime<=o&&e.endTime>o-rL));if(a){const e=(o-a.startTime)/(a.endTime-a.startTime),t=uL(e),n=u.current?dL(u.current.weight,t):t,i={...a,weight:n};return u.current=i,i}if(u.current){const e=u.current.weight*(1-oL);u.current={...u.current,weight:e}}return u.current=null,null}),[r]),_=(0,c.useCallback)((e=>{v(),g(),m(e)}),[v,g,m,s]),b=(0,c.useMemo)((()=>({addViseme:f,updateCurrentViseme:y,startProcessing:m,stopProcessing:v,resetAndStartProcessing:_,resetVisemeQueue:g,isProcessing:r,setAudioContext:p})),[f,y,m,v,_,g,r,p]);return(0,a.jsx)(tL.Provider,{value:b,children:e})},pL=()=>{const e=(0,c.useContext)(tL);if(!e)throw new Error("useVisemeContext must be used within a VisemeProvider");return e};var mL=(0,c.memo)((({memori:e,integration:n,integrationConfig:i,tenant:r,instruct:o=!1,avatar3dVisible:s=!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:b,isTotem:x=!1})=>{const{t:w}=Ve(),[S,E]=(0,c.useState)(!1),{stopProcessing:A,updateCurrentViseme:T,resetVisemeQueue:I}=pL();(0,c.useEffect)((()=>{E(!0)}),[]);const M=()=>{if("userAvatar"===(null==i?void 0:i.avatar)&&e.avatarURL&&e.avatarURL.length>0)return KT({type:"avatar",tenantID:null==r?void 0:r.name,resourceURI:e.avatarURL,baseURL:p,apiURL:m})},C=()=>{var t;return S?"readyplayerme"===(null==i?void 0:i.avatar)||"readyplayerme-full"===(null==i?void 0:i.avatar)||"customrpm"===(null==i?void 0:i.avatar)?(0,a.jsx)(mC,{fallback:(0,a.jsx)("div",{className:"memori--blob-container",children:S&&(0,a.jsx)(fC,{speaking:d,avatar:M()})}),children:(0,a.jsx)(eL,{enablePositionControls:_,updateCurrentViseme:T,url:i.avatarURL,sex:"FEMALE"===e.voiceType?"FEMALE":"MALE",fallbackImg:M(),headMovement:!0,eyeBlink:!0,animation:f,halfBody:"readyplayerme"===i.avatar,speaking:d,loading:h,style:O(),stopProcessing:A,resetVisemeQueue:I,isZoomed:g,isTotem:x,chatEmission:null===(t=null==v?void 0:v.dialogState)||void 0===t?void 0:t.emission,setEnablePositionControls:b})}):"customglb"===(null==i?void 0:i.avatar)?(0,a.jsx)(JI,{poster:M()||"",src:i.avatarURL,alt:""}):null:null},N=()=>(0,a.jsx)("div",{className:"memori--avatar-toggle",children:(0,a.jsx)(Jl,{ghost:!0,onClick:()=>l(!s),icon:s?(0,a.jsx)(vC,{}):(0,a.jsx)(gC,{}),children:(0,a.jsx)("span",{className:"memori--avatar-toggle-text",children:w(s?"hide":"show")})})}),O=()=>"readyplayerme"===(null==i?void 0:i.avatar)?{width:"100%",height:"100%",backgroundColor:"none",boxShadow:"none"}:{width:"100%",height:"100%",backgroundColor:"none"};return(0,a.jsxs)(a.Fragment,{children:[("readyplayerme"===(null==i?void 0:i.avatar)||"readyplayerme-full"===(null==i?void 0:i.avatar)||"customglb"===(null==i?void 0:i.avatar)||"customrpm"===(null==i?void 0:i.avatar))&&(null==i?void 0:i.avatarURL)&&y&&"blob"!==y?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:t(We)("memori--avatar-wrapper",`memori--avatar-${(null==i?void 0:i.avatar)||"default"}`,{hidden:!s}),children:C()}),N()]}):(0,a.jsx)("div",{className:"memori--blob-container",children:S&&(0,a.jsx)(fC,{speaking:d,avatar:M()})}),(()=>{if(!o||u||!e.isGiver||!(null==r?void 0:r.name))return null;const t=`https://${r.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,a.jsx)("div",{className:"memori--avatar-link-to-integrations",children:(0,a.jsx)("a",{className:"memori-button memori-button--circle memori-button--outlined",href:t,children:(0,a.jsx)(nI,{content:w("widgetgoToIntegrationsToCustomizeAvatar"),children:(0,a.jsx)("span",{className:"memori-button--icon",children:(0,a.jsx)(yC,{})})})})})})()]})}),((e,t)=>JSON.stringify(e)===JSON.stringify(t)));c=o("85Hg2"),c=o("85Hg2");var fL=({open:e=!1,onClose:n,children:i,className:r,trigger:o,placement:s="bottom-right"})=>{const l=(0,c.useRef)(null),[u,d]=(0,c.useState)(e);(0,c.useEffect)((()=>{d(e)}),[e]),(0,c.useEffect)((()=>{const e=e=>{l.current&&!l.current.contains(e.target)&&(d(!1),null==n||n())};return u&&document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}}),[u,n]);return(0,a.jsxs)("div",{className:t(We)("memori-dropdown",r),ref:l,children:[(0,a.jsx)("div",{className:"memori-dropdown--trigger",onClick:()=>{d(!u)},children:o}),u&&(0,a.jsx)("div",{className:t(We)("memori-dropdown--content",`memori-dropdown--content--${s}`),children:i})]})};var gL=({className:e,title:t})=>(0,a.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,a.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 vL=({className:e,title:t})=>(0,a.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,a.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 yL=({className:e,title:t})=>(0,a.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,a.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 _L=({className:e,title:t})=>(0,a.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,a.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 bL=({className:e,title:t})=>(0,a.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,a.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 xL=({className:e,title:t})=>(0,a.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,a.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 wL=({className:e,title:t})=>(0,a.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,a.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,a.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 SL=({className:e,title:t})=>(0,a.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,a.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 EL=({className:e,title:t})=>(0,a.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,a.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 AL,TL=({className:e,title:t})=>(0,a.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,a.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"})}),IL=(c=o("85Hg2"),Object.defineProperty),ML=Object.getOwnPropertySymbols,CL=Object.prototype.hasOwnProperty,NL=Object.prototype.propertyIsEnumerable,OL=(e,t,n)=>t in e?IL(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,RL=(e,t)=>{for(var n in t||(t={}))CL.call(t,n)&&OL(e,n,t[n]);if(ML)for(var n of ML(t))NL.call(t,n)&&OL(e,n,t[n]);return e},LL=(e,t)=>{var n={};for(var i in e)CL.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&ML)for(var i of ML(e))t.indexOf(i)<0&&NL.call(e,i)&&(n[i]=e[i]);return n};(e=>{const t=class{constructor(e,n,i,r){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(r<-1||r>7)throw new RangeError("Mask value out of range");this.size=4*e+17;let a=[];for(let e=0;e<this.size;e++)a.push(!1);for(let e=0;e<this.size;e++)this.modules.push(a.slice()),this.isFunction.push(a.slice());this.drawFunctionPatterns();const s=this.addEccAndInterleave(i);if(this.drawCodewords(s),-1==r){let e=1e9;for(let t=0;t<8;t++){this.applyMask(t),this.drawFormatBits(t);const n=this.getPenaltyScore();n<e&&(r=t,e=n),this.applyMask(t)}}o(0<=r&&r<=7),this.mask=r,this.applyMask(r),this.drawFormatBits(r),this.isFunction=[]}static encodeText(n,i){const r=e.QrSegment.makeSegments(n);return t.encodeSegments(r,i)}static encodeBinary(n,i){const r=e.QrSegment.makeBytes(n);return t.encodeSegments([r],i)}static encodeSegments(e,n,r=1,a=40,l=-1,c=!0){if(!(t.MIN_VERSION<=r&&r<=a&&a<=t.MAX_VERSION)||l<-1||l>7)throw new RangeError("Invalid value");let u,d;for(u=r;;u++){const i=8*t.getNumDataCodewords(u,n),r=s.getTotalBits(e,u);if(r<=i){d=r;break}if(u>=a)throw new RangeError("Data too long")}for(const e of[t.Ecc.MEDIUM,t.Ecc.QUARTILE,t.Ecc.HIGH])c&&d<=8*t.getNumDataCodewords(u,e)&&(n=e);let h=[];for(const t of e){i(t.mode.modeBits,4,h),i(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),i(0,Math.min(4,p-h.length),h),i(0,(8-h.length%8)%8,h),o(h.length%8==0);for(let e=236;h.length<p;e^=253)i(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 i=0;i<t;i++)0==n&&0==i||0==n&&i==t-1||n==t-1&&0==i||this.drawAlignmentPattern(e[n],e[i]);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 i=21522^(t<<10|n);o(i>>>15==0);for(let e=0;e<=5;e++)this.setFunctionModule(8,e,r(i,e));this.setFunctionModule(8,7,r(i,6)),this.setFunctionModule(8,8,r(i,7)),this.setFunctionModule(7,8,r(i,8));for(let e=9;e<15;e++)this.setFunctionModule(14-e,8,r(i,e));for(let e=0;e<8;e++)this.setFunctionModule(this.size-1-e,8,r(i,e));for(let e=8;e<15;e++)this.setFunctionModule(8,this.size-15+e,r(i,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=r(t,e),i=this.size-11+e%3,o=Math.floor(e/3);this.setFunctionModule(i,o,n),this.setFunctionModule(o,i,n)}}drawFinderPattern(e,t){for(let n=-4;n<=4;n++)for(let i=-4;i<=4;i++){const r=Math.max(Math.abs(i),Math.abs(n)),o=e+i,a=t+n;0<=o&&o<this.size&&0<=a&&a<this.size&&this.setFunctionModule(o,a,2!=r&&4!=r)}}drawAlignmentPattern(e,t){for(let n=-2;n<=2;n++)for(let i=-2;i<=2;i++)this.setFunctionModule(e+i,t+n,1!=Math.max(Math.abs(i),Math.abs(n)))}setFunctionModule(e,t,n){this.modules[t][e]=n,this.isFunction[t][e]=!0}addEccAndInterleave(e){const n=this.version,i=this.errorCorrectionLevel;if(e.length!=t.getNumDataCodewords(n,i))throw new RangeError("Invalid argument");const r=t.NUM_ERROR_CORRECTION_BLOCKS[i.ordinal][n],a=t.ECC_CODEWORDS_PER_BLOCK[i.ordinal][n],s=Math.floor(t.getNumRawDataModules(n)/8),l=r-s%r,c=Math.floor(s/r);let u=[];const d=t.reedSolomonComputeDivisor(a);for(let n=0,i=0;n<r;n++){let r=e.slice(i,i+c-a+(n<l?0:1));i+=r.length;const o=t.reedSolomonComputeRemainder(r,d);n<l&&r.push(0),u.push(r.concat(o))}let h=[];for(let e=0;e<u[0].length;e++)u.forEach(((t,n)=>{(e!=c-a||n>=l)&&h.push(t[e])}));return o(h.length==s),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 i=0;i<this.size;i++)for(let o=0;o<2;o++){const a=t-o,s=0==(t+1&2)?this.size-1-i:i;!this.isFunction[s][a]&&n<8*e.length&&(this.modules[s][a]=r(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 i;switch(e){case 0:i=(n+t)%2==0;break;case 1:i=t%2==0;break;case 2:i=n%3==0;break;case 3:i=(n+t)%3==0;break;case 4:i=(Math.floor(n/3)+Math.floor(t/2))%2==0;break;case 5:i=n*t%2+n*t%3==0;break;case 6:i=(n*t%2+n*t%3)%2==0;break;case 7:i=((n+t)%2+n*t%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[t][n]&&i&&(this.modules[t][n]=!this.modules[t][n])}}getPenaltyScore(){let e=0;for(let n=0;n<this.size;n++){let i=!1,r=0,o=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[n][a]==i?(r++,5==r?e+=t.PENALTY_N1:r>5&&e++):(this.finderPenaltyAddHistory(r,o),i||(e+=this.finderPenaltyCountPatterns(o)*t.PENALTY_N3),i=this.modules[n][a],r=1);e+=this.finderPenaltyTerminateAndCount(i,r,o)*t.PENALTY_N3}for(let n=0;n<this.size;n++){let i=!1,r=0,o=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[a][n]==i?(r++,5==r?e+=t.PENALTY_N1:r>5&&e++):(this.finderPenaltyAddHistory(r,o),i||(e+=this.finderPenaltyCountPatterns(o)*t.PENALTY_N3),i=this.modules[a][n],r=1);e+=this.finderPenaltyTerminateAndCount(i,r,o)*t.PENALTY_N3}for(let n=0;n<this.size-1;n++)for(let i=0;i<this.size-1;i++){const r=this.modules[n][i];r==this.modules[n][i+1]&&r==this.modules[n+1][i]&&r==this.modules[n+1][i+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 i=this.size*this.size,r=Math.ceil(Math.abs(20*n-10*i)/i)-1;return o(0<=r&&r<=9),e+=r*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 i=this.size-7;n.length<e;i-=t)n.splice(1,0,i);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 i=1;for(let r=0;r<e;r++){for(let e=0;e<n.length;e++)n[e]=t.reedSolomonMultiply(n[e],i),e+1<n.length&&(n[e]^=n[e+1]);i=t.reedSolomonMultiply(i,2)}return n}static reedSolomonComputeRemainder(e,n){let i=n.map((e=>0));for(const r of e){const e=r^i.shift();i.push(0),n.forEach(((n,r)=>i[r]^=t.reedSolomonMultiply(n,e)))}return i}static reedSolomonMultiply(e,t){if(e>>>8!=0||t>>>8!=0)throw new RangeError("Byte out of range");let n=0;for(let i=7;i>=0;i--)n=n<<1^285*(n>>>7),n^=(t>>>i&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 i(e,t,n){if(t<0||t>31||e>>>t!=0)throw new RangeError("Value out of range");for(let i=t-1;i>=0;i--)n.push(e>>>i&1)}function r(e,t){return 0!=(e>>>t&1)}function o(e){if(!e)throw new Error("Assertion error")}n.MIN_VERSION=1,n.MAX_VERSION=40,n.PENALTY_N1=3,n.PENALTY_N2=3,n.PENALTY_N3=40,n.PENALTY_N4=10,n.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],n.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],e.QrCode=n;const a=class{constructor(e,t,n){if(this.mode=e,this.numChars=t,this.bitData=n,t<0)throw new RangeError("Invalid argument");this.bitData=n.slice()}static makeBytes(e){let t=[];for(const n of e)i(n,8,t);return new a(a.Mode.BYTE,e.length,t)}static makeNumeric(e){if(!a.isNumeric(e))throw new RangeError("String contains non-numeric characters");let t=[];for(let n=0;n<e.length;){const r=Math.min(e.length-n,3);i(parseInt(e.substr(n,r),10),3*r+1,t),n+=r}return new a(a.Mode.NUMERIC,e.length,t)}static makeAlphanumeric(e){if(!a.isAlphanumeric(e))throw new RangeError("String contains unencodable characters in alphanumeric mode");let t,n=[];for(t=0;t+2<=e.length;t+=2){let r=45*a.ALPHANUMERIC_CHARSET.indexOf(e.charAt(t));r+=a.ALPHANUMERIC_CHARSET.indexOf(e.charAt(t+1)),i(r,11,n)}return t<e.length&&i(a.ALPHANUMERIC_CHARSET.indexOf(e.charAt(t)),6,n),new a(a.Mode.ALPHANUMERIC,e.length,n)}static makeSegments(e){return""==e?[]:a.isNumeric(e)?[a.makeNumeric(e)]:a.isAlphanumeric(e)?[a.makeAlphanumeric(e)]:[a.makeBytes(a.toUtf8ByteArray(e))]}static makeEci(e){let t=[];if(e<0)throw new RangeError("ECI assignment value out of range");if(e<128)i(e,8,t);else if(e<16384)i(2,2,t),i(e,14,t);else{if(!(e<1e6))throw new RangeError("ECI assignment value out of range");i(6,3,t),i(e,21,t)}return new a(a.Mode.ECI,0,t)}static isNumeric(e){return a.NUMERIC_REGEX.test(e)}static isAlphanumeric(e){return a.ALPHANUMERIC_REGEX.test(e)}getData(){return this.bitData.slice()}static getTotalBits(e,t){let n=0;for(const i of e){const e=i.mode.numCharCountBits(t);if(i.numChars>=1<<e)return 1/0;n+=4+e+i.bitData.length}return n}static toUtf8ByteArray(e){e=encodeURI(e);let t=[];for(let n=0;n<e.length;n++)"%"!=e.charAt(n)?t.push(e.charCodeAt(n)):(t.push(parseInt(e.substr(n+1,2),16)),n+=2);return t}};let s=a;s.NUMERIC_REGEX=/^[0-9]*$/,s.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,s.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:",e.QrSegment=s})(AL||(AL={})),(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={}))})(AL||(AL={})),(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={}))})(AL||(AL={}));var PL=AL,DL={L:PL.QrCode.Ecc.LOW,M:PL.QrCode.Ecc.MEDIUM,Q:PL.QrCode.Ecc.QUARTILE,H:PL.QrCode.Ecc.HIGH},kL=128,BL="L",FL="#FFFFFF",UL="#000000",zL=!1;
239
239
  /**
240
240
  * @license qrcode.react
241
241
  * Copyright (c) Paul O'Shannessy