Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

build(ar-studio): rebuild the docs bundle so it carries the server-owner-hash client change

nirholasbbf28865d774
diff --git a/packages/ar-studio/docs/ar-studio.min.js b/packages/ar-studio/docs/ar-studio.min.js
index 76b5802f5..128c537c1 100644
--- a/packages/ar-studio/docs/ar-studio.min.js
+++ b/packages/ar-studio/docs/ar-studio.min.js
@@ -1,10 +1,10 @@
/*! 3d-ar-studio v0.3.2 · https://nirholas.github.io/3D-AR-Studio/
* Apache-2.0 licensed. Bundles three.js (MIT) and colyseus.js (MIT). */
-var xv=Object.create;var wc=Object.defineProperty;var _v=Object.getOwnPropertyDescriptor;var yv=Object.getOwnPropertyNames;var vv=Object.getPrototypeOf,Sv=Object.prototype.hasOwnProperty;var un=(i,e,t)=>()=>{if(t)throw t[0];try{return i&&(e=i(i=0)),e}catch(n){throw t=[n],n}};var dn=(i,e)=>()=>{try{return e||i((e={exports:{}}).exports,e),e.exports}catch(t){throw e=0,t}},Ar=(i,e)=>{for(var t in e)wc(i,t,{get:e[t],enumerable:!0})},ag=(i,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of yv(e))!Sv.call(i,r)&&r!==t&&wc(i,r,{get:()=>e[r],enumerable:!(n=_v(e,r))||n.enumerable});return i};var og=(i,e,t)=>(t=i!=null?xv(vv(i)):{},ag(e||!i||!i.__esModule?wc(t,"default",{value:i,enumerable:!0}):t,i)),Gs=i=>ag(wc({},"__esModule",{value:!0}),i);function wv(i){for(let e=i.length-1;e>=0;--e)if(i[e]>=65535)return!0;return!1}function M0(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}function aa(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function A0(){let i=aa("canvas");return i.style.display="block",i}function eo(...i){let e="THREE."+i.shift();oa?oa("log",e,...i):console.log(e,...i)}function T0(i){let e=i[0];if(typeof e=="string"&&e.startsWith("TSL:")){let t=i[1];t&&t.isStackTrace?i[0]+=" "+t.getLocation():i[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return i}function Ke(...i){i=T0(i);let e="THREE."+i.shift();if(oa)oa("warn",e,...i);else{let t=i[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...i)}}function et(...i){i=T0(i);let e="THREE."+i.shift();if(oa)oa("error",e,...i);else{let t=i[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...i)}}function al(...i){let e=i.join(" ");e in cg||(cg[e]=!0,Ke(...i))}function E0(i,e,t){return new Promise(function(n,r){function s(){switch(i.clientWaitSync(e,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:r();break;case i.TIMEOUT_EXPIRED:setTimeout(s,t);break;default:n()}}setTimeout(s,t)})}function Ii(){let i=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(In[i&255]+In[i>>8&255]+In[i>>16&255]+In[i>>24&255]+"-"+In[e&255]+In[e>>8&255]+"-"+In[e>>16&15|64]+In[e>>24&255]+"-"+In[t&63|128]+In[t>>8&255]+"-"+In[t>>16&255]+In[t>>24&255]+In[n&255]+In[n>>8&255]+In[n>>16&255]+In[n>>24&255]).toLowerCase()}function bt(i,e,t){return Math.max(e,Math.min(t,i))}function zd(i,e){return(i%e+e)%e}function Mv(i,e,t,n,r){return n+(i-e)*(r-n)/(t-e)}function Av(i,e,t){return i!==e?(t-i)/(e-i):0}function Ja(i,e,t){return(1-t)*i+t*e}function Tv(i,e,t,n){return Ja(i,e,1-Math.exp(-t*n))}function Ev(i,e=1){return e-Math.abs(zd(i,e*2)-e)}function Rv(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*(3-2*i))}function Cv(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*i*(i*(i*6-15)+10))}function Iv(i,e){return i+Math.floor(Math.random()*(e-i+1))}function Pv(i,e){return i+Math.random()*(e-i)}function Lv(i){return i*(.5-Math.random())}function Dv(i){i!==void 0&&(lg=i);let e=lg+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function Nv(i){return i*Ya}function Ov(i){return i*bs}function Fv(i){return(i&i-1)===0&&i!==0}function Uv(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function kv(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function Bv(i,e,t,n,r){let s=Math.cos,a=Math.sin,o=s(t/2),l=a(t/2),c=s((e+n)/2),h=a((e+n)/2),d=s((e-n)/2),f=a((e-n)/2),p=s((n-e)/2),x=a((n-e)/2);switch(r){case"XYX":i.set(o*h,l*d,l*f,o*c);break;case"YZY":i.set(l*f,o*h,l*d,o*c);break;case"ZXZ":i.set(l*d,l*f,o*h,o*c);break;case"XZX":i.set(o*h,l*x,l*p,o*c);break;case"YXY":i.set(l*p,o*h,l*x,o*c);break;case"ZYZ":i.set(l*x,l*p,o*h,o*c);break;default:Ke("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function Ri(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return i/4294967295;case Uint16Array:return i/65535;case Uint8Array:return i/255;case Int32Array:return Math.max(i/2147483647,-1);case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("Invalid component type.")}}function Nt(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return Math.round(i*4294967295);case Uint16Array:return Math.round(i*65535);case Uint8Array:return Math.round(i*255);case Int32Array:return Math.round(i*2147483647);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("Invalid component type.")}}function zv(){let i={enabled:!0,workingColorSpace:bn,spaces:{},convert:function(r,s,a){return this.enabled===!1||s===a||!s||!a||(this.spaces[s].transfer===Dt&&(r.r=fr(r.r),r.g=fr(r.g),r.b=fr(r.b)),this.spaces[s].primaries!==this.spaces[a].primaries&&(r.applyMatrix3(this.spaces[s].toXYZ),r.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===Dt&&(r.r=ia(r.r),r.g=ia(r.g),r.b=ia(r.b))),r},workingToColorSpace:function(r,s){return this.convert(r,this.workingColorSpace,s)},colorSpaceToWorking:function(r,s){return this.convert(r,s,this.workingColorSpace)},getPrimaries:function(r){return this.spaces[r].primaries},getTransfer:function(r){return r===Fi?Qa:this.spaces[r].transfer},getToneMappingMode:function(r){return this.spaces[r].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(r,s=this.workingColorSpace){return r.fromArray(this.spaces[s].luminanceCoefficients)},define:function(r){Object.assign(this.spaces,r)},_getMatrix:function(r,s,a){return r.copy(this.spaces[s].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(r){return this.spaces[r].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(r=this.workingColorSpace){return this.spaces[r].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(r,s){return al("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),i.workingToColorSpace(r,s)},toWorkingColorSpace:function(r,s){return al("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),i.colorSpaceToWorking(r,s)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return i.define({[bn]:{primaries:e,whitePoint:n,transfer:Qa,toXYZ:ug,fromXYZ:dg,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:Xt},outputColorSpaceConfig:{drawingBufferColorSpace:Xt}},[Xt]:{primaries:e,whitePoint:n,transfer:Dt,toXYZ:ug,fromXYZ:dg,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:Xt}}}),i}function fr(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function ia(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}function Bu(i){return typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap?ol.getDataURL(i):i.data?{data:Array.from(i.data),width:i.width,height:i.height,type:i.data.constructor.name}:(Ke("Texture: Unable to serialize Texture."),{})}function Gu(i,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?i+(e-i)*6*t:t<1/2?e:t<2/3?i+(e-i)*6*(2/3-t):i}function Yu(i,e,t,n,r){for(let s=0,a=i.length-3;s<=a;s+=3){as.fromArray(i,s);let o=r.x*Math.abs(as.x)+r.y*Math.abs(as.y)+r.z*Math.abs(as.z),l=e.dot(as),c=t.dot(as),h=n.dot(as);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>o)return!1}return!0}function Yv(){let i=new ArrayBuffer(4),e=new Float32Array(i),t=new Uint32Array(i),n=new Uint32Array(512),r=new Uint32Array(512);for(let l=0;l<256;++l){let c=l-127;c<-27?(n[l]=0,n[l|256]=32768,r[l]=24,r[l|256]=24):c<-14?(n[l]=1024>>-c-14,n[l|256]=1024>>-c-14|32768,r[l]=-c-1,r[l|256]=-c-1):c<=15?(n[l]=c+15<<10,n[l|256]=c+15<<10|32768,r[l]=13,r[l|256]=13):c<128?(n[l]=31744,n[l|256]=64512,r[l]=24,r[l|256]=24):(n[l]=31744,n[l|256]=64512,r[l]=13,r[l|256]=13)}let s=new Uint32Array(2048),a=new Uint32Array(64),o=new Uint32Array(64);for(let l=1;l<1024;++l){let c=l<<13,h=0;for(;(c&8388608)===0;)c<<=1,h-=8388608;c&=-8388609,h+=947912704,s[l]=c|h}for(let l=1024;l<2048;++l)s[l]=939524096+(l-1024<<13);for(let l=1;l<31;++l)a[l]=l<<23;a[31]=1199570944,a[32]=2147483648;for(let l=33;l<63;++l)a[l]=2147483648+(l-32<<23);a[63]=3347054592;for(let l=1;l<64;++l)l!==32&&(o[l]=1024);return{floatView:e,uint32View:t,baseTable:n,shiftTable:r,mantissaTable:s,exponentTable:a,offsetTable:o}}function Jv(i){Math.abs(i)>65504&&Ke("DataUtils.toHalfFloat(): Value out of range."),i=bt(i,-65504,65504),dr.floatView[0]=i;let e=dr.uint32View[0],t=e>>23&511;return dr.baseTable[t]+((e&8388607)>>dr.shiftTable[t])}function Zv(i){let e=i>>10;return dr.uint32View[0]=dr.mantissaTable[dr.offsetTable[e]+(i&1023)]+dr.exponentTable[e],dr.floatView[0]}function iS(i,e,t,n,r,s,a,o){let l;if(e.side===An?l=n.intersectTriangle(a,s,r,!0,o):l=n.intersectTriangle(r,s,a,e.side===Pi,o),l===null)return null;kc.copy(o),kc.applyMatrix4(i.matrixWorld);let c=t.ray.origin.distanceTo(kc);return c<t.near||c>t.far?null:{distance:c,point:kc.clone(),object:i}}function Bc(i,e,t,n,r,s,a,o,l,c){i.getVertexPosition(o,Nc),i.getVertexPosition(l,Oc),i.getVertexPosition(c,Fc);let h=iS(i,e,t,n,Nc,Oc,Fc,wg);if(h){let d=new W;Lr.getBarycoord(wg,Nc,Oc,Fc,d),r&&(h.uv=Lr.getInterpolatedAttribute(r,o,l,c,d,new dt)),s&&(h.uv1=Lr.getInterpolatedAttribute(s,o,l,c,d,new dt)),a&&(h.normal=Lr.getInterpolatedAttribute(a,o,l,c,d,new W),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));let f={a:o,b:l,c,normal:new W,materialIndex:0};Lr.getNormal(Nc,Oc,Fc,f.normal),h.face=f,h.barycoord=d}return h}function Wc(i,e,t,n,r,s,a){let o=i.geometry.attributes.position;if(hl.fromBufferAttribute(o,r),ul.fromBufferAttribute(o,s),t.distanceSqToSegment(hl,ul,ad,Lg)>n)return;ad.applyMatrix4(i.matrixWorld);let c=e.ray.origin.distanceTo(ad);if(!(c<e.near||c>e.far))return{distance:c,point:Lg.clone().applyMatrix4(i.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:i}}function Fg(i,e,t,n,r,s,a){let o=dd.distanceSqToPoint(i);if(o<t){let l=new W;dd.closestPointToPoint(i,l),l.applyMatrix4(n);let c=r.ray.origin.distanceTo(l);if(c<r.near||c>r.far)return;s.push({distance:c,distanceToRay:Math.sqrt(o),point:l,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}function Es(i){let e={};for(let t in i){e[t]={};for(let n in i[t]){let r=i[t][n];if(Ug(r))r.isRenderTargetTexture?(Ke("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][n]=null):e[t][n]=r.clone();else if(Array.isArray(r))if(Ug(r[0])){let s=[];for(let a=0,o=r.length;a<o;a++)s[a]=r[a].clone();e[t][n]=s}else e[t][n]=r.slice();else e[t][n]=r}}return e}function Nn(i){let e={};for(let t=0;t<i.length;t++){let n=Es(i[t]);for(let r in n)e[r]=n[r]}return e}function Ug(i){return i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)}function hS(i){let e=[];for(let t=0;t<i.length;t++)e.push(i[t].clone());return e}function Gd(i){let e=i.getRenderTarget();return e===null?i.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:ut.workingColorSpace}function ds(i,e){return!i||i.constructor===e?i:typeof e.BYTES_PER_ELEMENT=="number"?new e(i):Array.prototype.slice.call(i)}function P0(i){function e(r,s){return i[r]-i[s]}let t=i.length,n=new Array(t);for(let r=0;r!==t;++r)n[r]=r;return n.sort(e),n}function fd(i,e,t){let n=i.length,r=new i.constructor(n);for(let s=0,a=0;a!==n;++s){let o=t[s]*e;for(let l=0;l!==e;++l)r[a++]=i[o+l]}return r}function Vd(i,e,t,n){let r=1,s=i[0];for(;s!==void 0&&s[n]===void 0;)s=i[r++];if(s===void 0)return;let a=s[n];if(a!==void 0)if(Array.isArray(a))do a=s[n],a!==void 0&&(e.push(s.time),t.push(...a)),s=i[r++];while(s!==void 0);else if(a.toArray!==void 0)do a=s[n],a!==void 0&&(e.push(s.time),a.toArray(t,t.length)),s=i[r++];while(s!==void 0);else do a=s[n],a!==void 0&&(e.push(s.time),t.push(a)),s=i[r++];while(s!==void 0)}function fS(i,e,t,n,r=30){let s=i.clone();s.name=e;let a=[];for(let l=0;l<s.tracks.length;++l){let c=s.tracks[l],h=c.getValueSize(),d=[],f=[];for(let p=0;p<c.times.length;++p){let x=c.times[p]*r;if(!(x<t||x>=n)){d.push(c.times[p]);for(let y=0;y<h;++y)f.push(c.values[p*h+y])}}d.length!==0&&(c.times=ds(d,c.times.constructor),c.values=ds(f,c.values.constructor),a.push(c))}s.tracks=a;let o=1/0;for(let l=0;l<s.tracks.length;++l)o>s.tracks[l].times[0]&&(o=s.tracks[l].times[0]);for(let l=0;l<s.tracks.length;++l)s.tracks[l].shift(-1*o);return s.resetDuration(),s}function pS(i,e=0,t=i,n=30){n<=0&&(n=30);let r=t.tracks.length,s=e/n;for(let a=0;a<r;++a){let o=t.tracks[a],l=o.ValueTypeName;if(l==="bool"||l==="string")continue;let c=i.tracks.find(function(g){return g.name===o.name&&g.ValueTypeName===l});if(c===void 0)continue;let h=0,d=o.getValueSize();o.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(h=d/3);let f=0,p=c.getValueSize();c.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(f=p/3);let x=o.times.length-1,y;if(s<=o.times[0]){let g=h,S=d-h;y=o.values.slice(g,S)}else if(s>=o.times[x]){let g=x*d+h,S=g+d-h;y=o.values.slice(g,S)}else{let g=o.createInterpolant(),S=h,A=d-h;g.evaluate(s),y=g.resultBuffer.slice(S,A)}l==="quaternion"&&new Pt().fromArray(y).normalize().conjugate().toArray(y);let b=c.times.length;for(let g=0;g<b;++g){let S=g*p+f;if(l==="quaternion")Pt.multiplyQuaternionsFlat(c.values,S,y,0,c.values,S);else{let A=p-f*2;for(let T=0;T<A;++T)c.values[S+T]-=y[T]}}}return i.blendMode=Uo,i}function mS(i){switch(i.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return ji;case"vector":case"vector2":case"vector3":case"vector4":return Ki;case"color":return bo;case"quaternion":return Xi;case"bool":case"boolean":return mr;case"string":return gr}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+i)}function gS(i){if(i.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");let e=mS(i.type);if(i.times===void 0){let t=[],n=[];Vd(i.keys,t,n,"value"),i.times=t,i.values=n}return e.parse!==void 0?e.parse(i):new e(i.name,i.times,i.values,i.interpolation)}function kg(i){try{let e=i.slice(i.indexOf(":")+1);return new URL(e).protocol==="blob:"}catch{return!1}}function Wg(i,e){return i.distance-e.distance}function _d(i,e,t,n){let r=!0;if(i.layers.test(e.layers)&&i.raycast(e,t)===!1&&(r=!1),r===!0&&n===!0){let s=i.children;for(let a=0,o=s.length;a<o;a++)_d(s[a],e,t,!0)}}function $d(i,e,t,n){let r=TS(n);switch(t){case Fd:return i*e;case Ol:return i*e/r.components*r.byteLength;case Fl:return i*e/r.components*r.byteLength;case Xr:return i*e*2/r.components*r.byteLength;case Ul:return i*e*2/r.components*r.byteLength;case Ud:return i*e*3/r.components*r.byteLength;case ci:return i*e*4/r.components*r.byteLength;case kl:return i*e*4/r.components*r.byteLength;case Io:case Po:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case Lo:case Do:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case zl:case Gl:return Math.max(i,16)*Math.max(e,8)/4;case Bl:case Hl:return Math.max(i,8)*Math.max(e,8)/2;case Vl:case Wl:case $l:case jl:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case ql:case No:case Xl:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case Kl:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case Yl:return Math.floor((i+4)/5)*Math.floor((e+3)/4)*16;case Jl:return Math.floor((i+4)/5)*Math.floor((e+4)/5)*16;case Zl:return Math.floor((i+5)/6)*Math.floor((e+4)/5)*16;case Ql:return Math.floor((i+5)/6)*Math.floor((e+5)/6)*16;case eh:return Math.floor((i+7)/8)*Math.floor((e+4)/5)*16;case th:return Math.floor((i+7)/8)*Math.floor((e+5)/6)*16;case nh:return Math.floor((i+7)/8)*Math.floor((e+7)/8)*16;case ih:return Math.floor((i+9)/10)*Math.floor((e+4)/5)*16;case rh:return Math.floor((i+9)/10)*Math.floor((e+5)/6)*16;case sh:return Math.floor((i+9)/10)*Math.floor((e+7)/8)*16;case ah:return Math.floor((i+9)/10)*Math.floor((e+9)/10)*16;case oh:return Math.floor((i+11)/12)*Math.floor((e+9)/10)*16;case ch:return Math.floor((i+11)/12)*Math.floor((e+11)/12)*16;case lh:case hh:case uh:return Math.ceil(i/4)*Math.ceil(e/4)*16;case dh:case fh:return Math.ceil(i/4)*Math.ceil(e/4)*8;case Oo:case ph:return Math.ceil(i/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function TS(i){switch(i){case Qn:case Ld:return{byteLength:1,components:1};case ba:case Dd:case Gn:return{byteLength:2,components:1};case Dl:case Nl:return{byteLength:2,components:4};case Oi:case Ll:case Tn:return{byteLength:4,components:1};case Nd:case Od:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${i}.`)}var qg,vd,$g,Eo,jg,qr,Pi,An,Dn,Ji,fs,Sd,wd,Md,Xg,Dr,Kg,Yg,Jg,Zg,Qg,e0,t0,n0,Yc,Jc,i0,r0,s0,a0,o0,c0,l0,h0,u0,Zc,Qc,el,ps,tl,nl,il,rl,Rl,d0,f0,Ni,Ad,Td,Ed,Ro,Rd,Cd,Id,ld,p0,Pd,$r,As,Cl,Il,Co,Nr,Kn,ra,on,Pl,Ts,zt,ga,xi,Qn,Ld,Dd,ba,Ll,Oi,Tn,Gn,Dl,Nl,xa,Nd,Od,Fd,Ud,ci,Wi,jr,Ol,Fl,Xr,Ul,kl,Io,Po,Lo,Do,Bl,zl,Hl,Gl,Vl,Wl,ql,$l,jl,No,Xl,Kl,Yl,Jl,Zl,Ql,eh,th,nh,ih,rh,sh,ah,oh,ch,lh,hh,uh,dh,fh,Oo,ph,_a,Fo,m0,ms,gs,Kc,hd,hs,us,Za,mh,Uo,kd,ko,ya,g0,Bo,b0,Fi,Xt,bn,Qa,Dt,ls,ud,x0,_0,y0,gh,v0,S0,bh,w0,sl,Bd,Ci,sa,cg,oa,R0,Li,In,lg,Ya,bs,Hd,jd,dt,Pt,Xd,W,Uu,hg,Kd,ct,ku,ug,dg,ut,Vs,ol,Hv,ca,Gv,zu,xn,Yd,kt,cl,Hn,to,ll,El,ot,Ws,Ai,Vv,Wv,Tr,Mc,ri,fg,pg,qi,la,qv,mg,qs,ar,Ac,Ga,$v,jv,gg,bg,xg,_g,Xv,$s,Hu,qt,pn,Kv,ha,C0,Er,Tc,Ve,Pn,no,Or,Ti,or,Vu,cr,js,Xs,yg,Wu,qu,$u,ju,Xu,Ku,Lr,rn,lr,Ei,Ec,Ks,Ys,Js,Rr,Cr,ss,Va,Rc,Cc,as,dr,Fr,fn,Ic,Qv,Kt,io,ro,Qt,eS,Wa,Ju,Yn,tS,pi,Zu,Zs,si,qa,vn,mn,Ur,zn,kr,nS,Ln,hr,Qu,Pc,Ir,ed,Lc,td,Br,gn,vg,os,Dc,Sg,Nc,Oc,Fc,nd,Uc,wg,kc,xt,$a,Mg,Ag,rS,Tg,zc,id,Eg,rd,so,ua,xs,Rg,sS,ao,zr,Qs,Cg,Hc,Ig,aS,ja,Xa,_s,sd,oS,cS,Gi,cs,lS,Gc,da,ys,hl,ul,Pg,Ka,Vc,ad,Lg,vs,Dg,Ng,fa,oo,pa,Og,dd,qc,$c,co,lo,Ss,pr,dl,ho,Hr,uo,mi,Gr,fo,I0,uS,dS,ai,fl,gi,Jn,po,pl,ml,mo,$i,gl,go,bl,xl,Zn,mr,bo,ji,_l,Xi,gr,Ki,bi,Vi,yl,L0,oi,ur,pd,Yi,ea,vl,xo,_o,Vr,ma,od,Bg,zg,yo,jc,Xc,Hi,vo,Pr,Hg,Gg,an,md,So,gd,ws,Wr,bd,Di,Sl,wo,br,cd,Mo,ta,na,wl,Ml,Al,Wd,bS,qd,xS,_S,yS,vS,SS,wS,MS,xd,Ut,Tl,AS,Ms,Vg,Ao,Jd,yd,To,Zd=un(()=>{qg=0,vd=1,$g=2,Eo=1,jg=2,qr=3,Pi=0,An=1,Dn=2,Ji=0,fs=1,Sd=2,wd=3,Md=4,Xg=5,Dr=100,Kg=101,Yg=102,Jg=103,Zg=104,Qg=200,e0=201,t0=202,n0=203,Yc=204,Jc=205,i0=206,r0=207,s0=208,a0=209,o0=210,c0=211,l0=212,h0=213,u0=214,Zc=0,Qc=1,el=2,ps=3,tl=4,nl=5,il=6,rl=7,Rl=0,d0=1,f0=2,Ni=0,Ad=1,Td=2,Ed=3,Ro=4,Rd=5,Cd=6,Id=7,ld="attached",p0="detached",Pd=300,$r=301,As=302,Cl=303,Il=304,Co=306,Nr=1e3,Kn=1001,ra=1002,on=1003,Pl=1004,Ts=1005,zt=1006,ga=1007,xi=1008,Qn=1009,Ld=1010,Dd=1011,ba=1012,Ll=1013,Oi=1014,Tn=1015,Gn=1016,Dl=1017,Nl=1018,xa=1020,Nd=35902,Od=35899,Fd=1021,Ud=1022,ci=1023,Wi=1026,jr=1027,Ol=1028,Fl=1029,Xr=1030,Ul=1031,kl=1033,Io=33776,Po=33777,Lo=33778,Do=33779,Bl=35840,zl=35841,Hl=35842,Gl=35843,Vl=36196,Wl=37492,ql=37496,$l=37488,jl=37489,No=37490,Xl=37491,Kl=37808,Yl=37809,Jl=37810,Zl=37811,Ql=37812,eh=37813,th=37814,nh=37815,ih=37816,rh=37817,sh=37818,ah=37819,oh=37820,ch=37821,lh=36492,hh=36494,uh=36495,dh=36283,fh=36284,Oo=36285,ph=36286,_a=2200,Fo=2201,m0=2202,ms=2300,gs=2301,Kc=2302,hd=2303,hs=2400,us=2401,Za=2402,mh=2500,Uo=2501,kd=0,ko=1,ya=2,g0=3200,Bo=0,b0=1,Fi="",Xt="srgb",bn="srgb-linear",Qa="linear",Dt="srgb",ls=7680,ud=519,x0=512,_0=513,y0=514,gh=515,v0=516,S0=517,bh=518,w0=519,sl=35044,Bd="300 es",Ci=2e3,sa=2001;cg={},oa=null;R0={[Zc]:Qc,[el]:il,[tl]:rl,[ps]:nl,[Qc]:Zc,[il]:el,[rl]:tl,[nl]:ps},Li=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){let n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners;if(n===void 0)return;let r=n[e];if(r!==void 0){let s=r.indexOf(t);s!==-1&&r.splice(s,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let n=t[e.type];if(n!==void 0){e.target=this;let r=n.slice(0);for(let s=0,a=r.length;s<a;s++)r[s].call(this,e);e.target=null}}},In=["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"],lg=1234567,Ya=Math.PI/180,bs=180/Math.PI;Hd={DEG2RAD:Ya,RAD2DEG:bs,generateUUID:Ii,clamp:bt,euclideanModulo:zd,mapLinear:Mv,inverseLerp:Av,lerp:Ja,damp:Tv,pingpong:Ev,smoothstep:Rv,smootherstep:Cv,randInt:Iv,randFloat:Pv,randFloatSpread:Lv,seededRandom:Dv,degToRad:Nv,radToDeg:Ov,isPowerOfTwo:Fv,ceilPowerOfTwo:Uv,floorPowerOfTwo:kv,setQuaternionFromProperEuler:Bv,normalize:Nt,denormalize:Ri},jd=class jd{constructor(e=0,t=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){let t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=bt(this.x,e.x,t.x),this.y=bt(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=bt(this.x,e,t),this.y=bt(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(bt(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(bt(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let 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){let n=Math.cos(t),r=Math.sin(t),s=this.x-e.x,a=this.y-e.y;return this.x=s*n-a*r+e.x,this.y=s*r+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}};jd.prototype.isVector2=!0;dt=jd,Pt=class{constructor(e=0,t=0,n=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=r}static slerpFlat(e,t,n,r,s,a,o){let l=n[r+0],c=n[r+1],h=n[r+2],d=n[r+3],f=s[a+0],p=s[a+1],x=s[a+2],y=s[a+3];if(d!==y||l!==f||c!==p||h!==x){let b=l*f+c*p+h*x+d*y;b<0&&(f=-f,p=-p,x=-x,y=-y,b=-b);let g=1-o;if(b<.9995){let S=Math.acos(b),A=Math.sin(S);g=Math.sin(g*S)/A,o=Math.sin(o*S)/A,l=l*g+f*o,c=c*g+p*o,h=h*g+x*o,d=d*g+y*o}else{l=l*g+f*o,c=c*g+p*o,h=h*g+x*o,d=d*g+y*o;let S=1/Math.sqrt(l*l+c*c+h*h+d*d);l*=S,c*=S,h*=S,d*=S}}e[t]=l,e[t+1]=c,e[t+2]=h,e[t+3]=d}static multiplyQuaternionsFlat(e,t,n,r,s,a){let o=n[r],l=n[r+1],c=n[r+2],h=n[r+3],d=s[a],f=s[a+1],p=s[a+2],x=s[a+3];return e[t]=o*x+h*d+l*p-c*f,e[t+1]=l*x+h*f+c*d-o*p,e[t+2]=c*x+h*p+o*f-l*d,e[t+3]=h*x-o*d-l*f-c*p,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let n=e._x,r=e._y,s=e._z,a=e._order,o=Math.cos,l=Math.sin,c=o(n/2),h=o(r/2),d=o(s/2),f=l(n/2),p=l(r/2),x=l(s/2);switch(a){case"XYZ":this._x=f*h*d+c*p*x,this._y=c*p*d-f*h*x,this._z=c*h*x+f*p*d,this._w=c*h*d-f*p*x;break;case"YXZ":this._x=f*h*d+c*p*x,this._y=c*p*d-f*h*x,this._z=c*h*x-f*p*d,this._w=c*h*d+f*p*x;break;case"ZXY":this._x=f*h*d-c*p*x,this._y=c*p*d+f*h*x,this._z=c*h*x+f*p*d,this._w=c*h*d-f*p*x;break;case"ZYX":this._x=f*h*d-c*p*x,this._y=c*p*d+f*h*x,this._z=c*h*x-f*p*d,this._w=c*h*d+f*p*x;break;case"YZX":this._x=f*h*d+c*p*x,this._y=c*p*d+f*h*x,this._z=c*h*x-f*p*d,this._w=c*h*d-f*p*x;break;case"XZY":this._x=f*h*d-c*p*x,this._y=c*p*d-f*h*x,this._z=c*h*x+f*p*d,this._w=c*h*d+f*p*x;break;default:Ke("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],r=t[4],s=t[8],a=t[1],o=t[5],l=t[9],c=t[2],h=t[6],d=t[10],f=n+o+d;if(f>0){let p=.5/Math.sqrt(f+1);this._w=.25/p,this._x=(h-l)*p,this._y=(s-c)*p,this._z=(a-r)*p}else if(n>o&&n>d){let p=2*Math.sqrt(1+n-o-d);this._w=(h-l)/p,this._x=.25*p,this._y=(r+a)/p,this._z=(s+c)/p}else if(o>d){let p=2*Math.sqrt(1+o-n-d);this._w=(s-c)/p,this._x=(r+a)/p,this._y=.25*p,this._z=(l+h)/p}else{let p=2*Math.sqrt(1+d-n-o);this._w=(a-r)/p,this._x=(s+c)/p,this._y=(l+h)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(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(bt(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let r=Math.min(1,t/n);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let n=e._x,r=e._y,s=e._z,a=e._w,o=t._x,l=t._y,c=t._z,h=t._w;return this._x=n*h+a*o+r*c-s*l,this._y=r*h+a*l+s*o-n*c,this._z=s*h+a*c+n*l-r*o,this._w=a*h-n*o-r*l-s*c,this._onChangeCallback(),this}slerp(e,t){let n=e._x,r=e._y,s=e._z,a=e._w,o=this.dot(e);o<0&&(n=-n,r=-r,s=-s,a=-a,o=-o);let l=1-t;if(o<.9995){let c=Math.acos(o),h=Math.sin(c);l=Math.sin(l*c)/h,t=Math.sin(t*c)/h,this._x=this._x*l+n*t,this._y=this._y*l+r*t,this._z=this._z*l+s*t,this._w=this._w*l+a*t,this._onChangeCallback()}else this._x=this._x*l+n*t,this._y=this._y*l+r*t,this._z=this._z*l+s*t,this._w=this._w*l+a*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),s=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),s*Math.sin(t),s*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},Xd=class Xd{constructor(e=0,t=0,n=0){this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(hg.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(hg.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6]*r,this.y=s[1]*t+s[4]*n+s[7]*r,this.z=s[2]*t+s[5]*n+s[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,s=e.elements,a=1/(s[3]*t+s[7]*n+s[11]*r+s[15]);return this.x=(s[0]*t+s[4]*n+s[8]*r+s[12])*a,this.y=(s[1]*t+s[5]*n+s[9]*r+s[13])*a,this.z=(s[2]*t+s[6]*n+s[10]*r+s[14])*a,this}applyQuaternion(e){let t=this.x,n=this.y,r=this.z,s=e.x,a=e.y,o=e.z,l=e.w,c=2*(a*r-o*n),h=2*(o*t-s*r),d=2*(s*n-a*t);return this.x=t+l*c+a*d-o*h,this.y=n+l*h+o*c-s*d,this.z=r+l*d+s*h-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*r,this.y=s[1]*t+s[5]*n+s[9]*r,this.z=s[2]*t+s[6]*n+s[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=bt(this.x,e.x,t.x),this.y=bt(this.y,e.y,t.y),this.z=bt(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=bt(this.x,e,t),this.y=bt(this.y,e,t),this.z=bt(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(bt(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let n=e.x,r=e.y,s=e.z,a=t.x,o=t.y,l=t.z;return this.x=r*l-s*o,this.y=s*a-n*l,this.z=n*o-r*a,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Uu.copy(this).projectOnVector(e),this.sub(Uu)}reflect(e){return this.sub(Uu.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(bt(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){let r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};Xd.prototype.isVector3=!0;W=Xd,Uu=new W,hg=new Pt,Kd=class Kd{constructor(e,t,n,r,s,a,o,l,c){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,r,s,a,o,l,c)}set(e,t,n,r,s,a,o,l,c){let h=this.elements;return h[0]=e,h[1]=r,h[2]=o,h[3]=t,h[4]=s,h[5]=l,h[6]=n,h[7]=a,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let 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){let 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){let n=e.elements,r=t.elements,s=this.elements,a=n[0],o=n[3],l=n[6],c=n[1],h=n[4],d=n[7],f=n[2],p=n[5],x=n[8],y=r[0],b=r[3],g=r[6],S=r[1],A=r[4],T=r[7],N=r[2],P=r[5],U=r[8];return s[0]=a*y+o*S+l*N,s[3]=a*b+o*A+l*P,s[6]=a*g+o*T+l*U,s[1]=c*y+h*S+d*N,s[4]=c*b+h*A+d*P,s[7]=c*g+h*T+d*U,s[2]=f*y+p*S+x*N,s[5]=f*b+p*A+x*P,s[8]=f*g+p*T+x*U,this}multiplyScalar(e){let 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(){let e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8];return t*a*h-t*o*c-n*s*h+n*o*l+r*s*c-r*a*l}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8],d=h*a-o*c,f=o*l-h*s,p=c*s-a*l,x=t*d+n*f+r*p;if(x===0)return this.set(0,0,0,0,0,0,0,0,0);let y=1/x;return e[0]=d*y,e[1]=(r*c-h*n)*y,e[2]=(o*n-r*a)*y,e[3]=f*y,e[4]=(h*t-r*l)*y,e[5]=(r*s-o*t)*y,e[6]=p*y,e[7]=(n*l-c*t)*y,e[8]=(a*t-n*s)*y,this}transpose(){let e,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){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,r,s,a,o){let l=Math.cos(s),c=Math.sin(s);return this.set(n*l,n*c,-n*(l*a+c*o)+a+e,-r*c,r*l,-r*(-c*a+l*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(ku.makeScale(e,t)),this}rotate(e){return this.premultiply(ku.makeRotation(-e)),this}translate(e,t){return this.premultiply(ku.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,n=e.elements;for(let r=0;r<9;r++)if(t[r]!==n[r])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){let 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)}};Kd.prototype.isMatrix3=!0;ct=Kd,ku=new ct,ug=new ct().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),dg=new ct().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);ut=zv();ol=class{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{Vs===void 0&&(Vs=aa("canvas")),Vs.width=e.width,Vs.height=e.height;let r=Vs.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),n=Vs}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){let t=aa("canvas");t.width=e.width,t.height=e.height;let n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);let r=n.getImageData(0,0,e.width,e.height),s=r.data;for(let a=0;a<s.length;a++)s[a]=fr(s[a]/255)*255;return n.putImageData(r,0,0),t}else if(e.data){let t=e.data.slice(0);for(let n=0;n<t.length;n++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[n]=Math.floor(fr(t[n]/255)*255):t[n]=fr(t[n]);return{data:t,width:e.width,height:e.height}}else return Ke("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},Hv=0,ca=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Hv++}),this.uuid=Ii(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){let t=this.data;return typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):typeof VideoFrame<"u"&&t instanceof VideoFrame?e.set(t.displayWidth,t.displayHeight,0):t!==null?e.set(t.width,t.height,t.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){let t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let n={uuid:this.uuid,url:""},r=this.data;if(r!==null){let s;if(Array.isArray(r)){s=[];for(let a=0,o=r.length;a<o;a++)r[a].isDataTexture?s.push(Bu(r[a].image)):s.push(Bu(r[a]))}else s=Bu(r);n.url=s}return t||(e.images[this.uuid]=n),n}};Gv=0,zu=new W,xn=class i extends Li{constructor(e=i.DEFAULT_IMAGE,t=i.DEFAULT_MAPPING,n=Kn,r=Kn,s=zt,a=xi,o=ci,l=Qn,c=i.DEFAULT_ANISOTROPY,h=Fi){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Gv++}),this.uuid=Ii(),this.name="",this.source=new ca(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=r,this.magFilter=s,this.minFilter=a,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=l,this.offset=new dt(0,0),this.repeat=new dt(1,1),this.center=new dt(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new ct,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(zu).x}get height(){return this.source.getSize(zu).y}get depth(){return this.source.getSize(zu).z}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)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(let t in e){let n=e[t];if(n===void 0){Ke(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){Ke(`Texture.setValues(): property '${t}' does not exist.`);continue}r&&n&&r.isVector2&&n.isVector2||r&&n&&r.isVector3&&n.isVector3||r&&n&&r.isMatrix3&&n.isMatrix3?r.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Pd)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Nr:e.x=e.x-Math.floor(e.x);break;case Kn:e.x=e.x<0?0:1;break;case ra:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case Nr:e.y=e.y-Math.floor(e.y);break;case Kn:e.y=e.y<0?0:1;break;case ra:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}};xn.DEFAULT_IMAGE=null;xn.DEFAULT_MAPPING=Pd;xn.DEFAULT_ANISOTROPY=1;Yd=class Yd{constructor(e=0,t=0,n=0,r=1){this.x=e,this.y=t,this.z=n,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,s=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*s,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*s,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*s,this.w=a[3]*t+a[7]*n+a[11]*r+a[15]*s,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,r,s,l=e.elements,c=l[0],h=l[4],d=l[8],f=l[1],p=l[5],x=l[9],y=l[2],b=l[6],g=l[10];if(Math.abs(h-f)<.01&&Math.abs(d-y)<.01&&Math.abs(x-b)<.01){if(Math.abs(h+f)<.1&&Math.abs(d+y)<.1&&Math.abs(x+b)<.1&&Math.abs(c+p+g-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;let A=(c+1)/2,T=(p+1)/2,N=(g+1)/2,P=(h+f)/4,U=(d+y)/4,v=(x+b)/4;return A>T&&A>N?A<.01?(n=0,r=.707106781,s=.707106781):(n=Math.sqrt(A),r=P/n,s=U/n):T>N?T<.01?(n=.707106781,r=0,s=.707106781):(r=Math.sqrt(T),n=P/r,s=v/r):N<.01?(n=.707106781,r=.707106781,s=0):(s=Math.sqrt(N),n=U/s,r=v/s),this.set(n,r,s,t),this}let S=Math.sqrt((b-x)*(b-x)+(d-y)*(d-y)+(f-h)*(f-h));return Math.abs(S)<.001&&(S=1),this.x=(b-x)/S,this.y=(d-y)/S,this.z=(f-h)/S,this.w=Math.acos((c+p+g-1)/2),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=bt(this.x,e.x,t.x),this.y=bt(this.y,e.y,t.y),this.z=bt(this.z,e.z,t.z),this.w=bt(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=bt(this.x,e,t),this.y=bt(this.y,e,t),this.z=bt(this.z,e,t),this.w=bt(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(bt(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}};Yd.prototype.isVector4=!0;kt=Yd,cl=class extends Li{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:zt,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new kt(0,0,e,t),this.scissorTest=!1,this.viewport=new kt(0,0,e,t),this.textures=[];let r={width:e,height:t,depth:n.depth},s=new xn(r),a=n.count;for(let o=0;o<a;o++)this.textures[o]=s.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview}_setTextureOptions(e={}){let t={minFilter:zt,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let n=0;n<this.textures.length;n++)this.textures[n].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let r=0,s=this.textures.length;r<s;r++)this.textures[r].image.width=e,this.textures[r].image.height=t,this.textures[r].image.depth=n,this.textures[r].isData3DTexture!==!0&&(this.textures[r].isArrayTexture=this.textures[r].image.depth>1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;let r=Object.assign({},e.textures[t].image);this.textures[t].source=new ca(r)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this.multiview=e.multiview,this}dispose(){this.dispatchEvent({type:"dispose"})}},Hn=class extends cl{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}},to=class extends xn{constructor(e=null,t=1,n=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=on,this.minFilter=on,this.wrapR=Kn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},ll=class extends xn{constructor(e=null,t=1,n=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=on,this.minFilter=on,this.wrapR=Kn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},El=class El{constructor(e,t,n,r,s,a,o,l,c,h,d,f,p,x,y,b){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,n,r,s,a,o,l,c,h,d,f,p,x,y,b)}set(e,t,n,r,s,a,o,l,c,h,d,f,p,x,y,b){let g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=r,g[1]=s,g[5]=a,g[9]=o,g[13]=l,g[2]=c,g[6]=h,g[10]=d,g[14]=f,g[3]=p,g[7]=x,g[11]=y,g[15]=b,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 El().fromArray(this.elements)}copy(e){let 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){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let 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 this.determinant()===0?(e.set(1,0,0),t.set(0,1,0),n.set(0,0,1),this):(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){if(e.determinant()===0)return this.identity();let t=this.elements,n=e.elements,r=1/Ws.setFromMatrixColumn(e,0).length(),s=1/Ws.setFromMatrixColumn(e,1).length(),a=1/Ws.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*s,t[5]=n[5]*s,t[6]=n[6]*s,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,n=e.x,r=e.y,s=e.z,a=Math.cos(n),o=Math.sin(n),l=Math.cos(r),c=Math.sin(r),h=Math.cos(s),d=Math.sin(s);if(e.order==="XYZ"){let f=a*h,p=a*d,x=o*h,y=o*d;t[0]=l*h,t[4]=-l*d,t[8]=c,t[1]=p+x*c,t[5]=f-y*c,t[9]=-o*l,t[2]=y-f*c,t[6]=x+p*c,t[10]=a*l}else if(e.order==="YXZ"){let f=l*h,p=l*d,x=c*h,y=c*d;t[0]=f+y*o,t[4]=x*o-p,t[8]=a*c,t[1]=a*d,t[5]=a*h,t[9]=-o,t[2]=p*o-x,t[6]=y+f*o,t[10]=a*l}else if(e.order==="ZXY"){let f=l*h,p=l*d,x=c*h,y=c*d;t[0]=f-y*o,t[4]=-a*d,t[8]=x+p*o,t[1]=p+x*o,t[5]=a*h,t[9]=y-f*o,t[2]=-a*c,t[6]=o,t[10]=a*l}else if(e.order==="ZYX"){let f=a*h,p=a*d,x=o*h,y=o*d;t[0]=l*h,t[4]=x*c-p,t[8]=f*c+y,t[1]=l*d,t[5]=y*c+f,t[9]=p*c-x,t[2]=-c,t[6]=o*l,t[10]=a*l}else if(e.order==="YZX"){let f=a*l,p=a*c,x=o*l,y=o*c;t[0]=l*h,t[4]=y-f*d,t[8]=x*d+p,t[1]=d,t[5]=a*h,t[9]=-o*h,t[2]=-c*h,t[6]=p*d+x,t[10]=f-y*d}else if(e.order==="XZY"){let f=a*l,p=a*c,x=o*l,y=o*c;t[0]=l*h,t[4]=-d,t[8]=c*h,t[1]=f*d+y,t[5]=a*h,t[9]=p*d-x,t[2]=x*d-p,t[6]=o*h,t[10]=y*d+f}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(Vv,e,Wv)}lookAt(e,t,n){let r=this.elements;return ri.subVectors(e,t),ri.lengthSq()===0&&(ri.z=1),ri.normalize(),Tr.crossVectors(n,ri),Tr.lengthSq()===0&&(Math.abs(n.z)===1?ri.x+=1e-4:ri.z+=1e-4,ri.normalize(),Tr.crossVectors(n,ri)),Tr.normalize(),Mc.crossVectors(ri,Tr),r[0]=Tr.x,r[4]=Mc.x,r[8]=ri.x,r[1]=Tr.y,r[5]=Mc.y,r[9]=ri.y,r[2]=Tr.z,r[6]=Mc.z,r[10]=ri.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,s=this.elements,a=n[0],o=n[4],l=n[8],c=n[12],h=n[1],d=n[5],f=n[9],p=n[13],x=n[2],y=n[6],b=n[10],g=n[14],S=n[3],A=n[7],T=n[11],N=n[15],P=r[0],U=r[4],v=r[8],I=r[12],B=r[1],k=r[5],V=r[9],J=r[13],L=r[2],E=r[6],D=r[10],O=r[14],H=r[3],Y=r[7],le=r[11],fe=r[15];return s[0]=a*P+o*B+l*L+c*H,s[4]=a*U+o*k+l*E+c*Y,s[8]=a*v+o*V+l*D+c*le,s[12]=a*I+o*J+l*O+c*fe,s[1]=h*P+d*B+f*L+p*H,s[5]=h*U+d*k+f*E+p*Y,s[9]=h*v+d*V+f*D+p*le,s[13]=h*I+d*J+f*O+p*fe,s[2]=x*P+y*B+b*L+g*H,s[6]=x*U+y*k+b*E+g*Y,s[10]=x*v+y*V+b*D+g*le,s[14]=x*I+y*J+b*O+g*fe,s[3]=S*P+A*B+T*L+N*H,s[7]=S*U+A*k+T*E+N*Y,s[11]=S*v+A*V+T*D+N*le,s[15]=S*I+A*J+T*O+N*fe,this}multiplyScalar(e){let 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(){let e=this.elements,t=e[0],n=e[4],r=e[8],s=e[12],a=e[1],o=e[5],l=e[9],c=e[13],h=e[2],d=e[6],f=e[10],p=e[14],x=e[3],y=e[7],b=e[11],g=e[15],S=l*p-c*f,A=o*p-c*d,T=o*f-l*d,N=a*p-c*h,P=a*f-l*h,U=a*d-o*h;return t*(y*S-b*A+g*T)-n*(x*S-b*N+g*P)+r*(x*A-y*N+g*U)-s*(x*T-y*P+b*U)}transpose(){let e=this.elements,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){let r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=n),this}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8],d=e[9],f=e[10],p=e[11],x=e[12],y=e[13],b=e[14],g=e[15],S=t*o-n*a,A=t*l-r*a,T=t*c-s*a,N=n*l-r*o,P=n*c-s*o,U=r*c-s*l,v=h*y-d*x,I=h*b-f*x,B=h*g-p*x,k=d*b-f*y,V=d*g-p*y,J=f*g-p*b,L=S*J-A*V+T*k+N*B-P*I+U*v;if(L===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let E=1/L;return e[0]=(o*J-l*V+c*k)*E,e[1]=(r*V-n*J-s*k)*E,e[2]=(y*U-b*P+g*N)*E,e[3]=(f*P-d*U-p*N)*E,e[4]=(l*B-a*J-c*I)*E,e[5]=(t*J-r*B+s*I)*E,e[6]=(b*T-x*U-g*A)*E,e[7]=(h*U-f*T+p*A)*E,e[8]=(a*V-o*B+c*v)*E,e[9]=(n*B-t*V-s*v)*E,e[10]=(x*P-y*T+g*S)*E,e[11]=(d*T-h*P-p*S)*E,e[12]=(o*I-a*k-l*v)*E,e[13]=(t*k-n*I+r*v)*E,e[14]=(y*A-x*N-b*S)*E,e[15]=(h*N-d*A+f*S)*E,this}scale(e){let t=this.elements,n=e.x,r=e.y,s=e.z;return t[0]*=n,t[4]*=r,t[8]*=s,t[1]*=n,t[5]*=r,t[9]*=s,t[2]*=n,t[6]*=r,t[10]*=s,t[3]*=n,t[7]*=r,t[11]*=s,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,r))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){let 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){let 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){let 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){let n=Math.cos(t),r=Math.sin(t),s=1-n,a=e.x,o=e.y,l=e.z,c=s*a,h=s*o;return this.set(c*a+n,c*o-r*l,c*l+r*o,0,c*o+r*l,h*o+n,h*l-r*a,0,c*l-r*o,h*l+r*a,s*l*l+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,r,s,a){return this.set(1,n,s,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){let r=this.elements,s=t._x,a=t._y,o=t._z,l=t._w,c=s+s,h=a+a,d=o+o,f=s*c,p=s*h,x=s*d,y=a*h,b=a*d,g=o*d,S=l*c,A=l*h,T=l*d,N=n.x,P=n.y,U=n.z;return r[0]=(1-(y+g))*N,r[1]=(p+T)*N,r[2]=(x-A)*N,r[3]=0,r[4]=(p-T)*P,r[5]=(1-(f+g))*P,r[6]=(b+S)*P,r[7]=0,r[8]=(x+A)*U,r[9]=(b-S)*U,r[10]=(1-(f+y))*U,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){let r=this.elements;e.x=r[12],e.y=r[13],e.z=r[14];let s=this.determinant();if(s===0)return n.set(1,1,1),t.identity(),this;let a=Ws.set(r[0],r[1],r[2]).length(),o=Ws.set(r[4],r[5],r[6]).length(),l=Ws.set(r[8],r[9],r[10]).length();s<0&&(a=-a),Ai.copy(this);let c=1/a,h=1/o,d=1/l;return Ai.elements[0]*=c,Ai.elements[1]*=c,Ai.elements[2]*=c,Ai.elements[4]*=h,Ai.elements[5]*=h,Ai.elements[6]*=h,Ai.elements[8]*=d,Ai.elements[9]*=d,Ai.elements[10]*=d,t.setFromRotationMatrix(Ai),n.x=a,n.y=o,n.z=l,this}makePerspective(e,t,n,r,s,a,o=Ci,l=!1){let c=this.elements,h=2*s/(t-e),d=2*s/(n-r),f=(t+e)/(t-e),p=(n+r)/(n-r),x,y;if(l)x=s/(a-s),y=a*s/(a-s);else if(o===Ci)x=-(a+s)/(a-s),y=-2*a*s/(a-s);else if(o===sa)x=-a/(a-s),y=-a*s/(a-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=h,c[4]=0,c[8]=f,c[12]=0,c[1]=0,c[5]=d,c[9]=p,c[13]=0,c[2]=0,c[6]=0,c[10]=x,c[14]=y,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,r,s,a,o=Ci,l=!1){let c=this.elements,h=2/(t-e),d=2/(n-r),f=-(t+e)/(t-e),p=-(n+r)/(n-r),x,y;if(l)x=1/(a-s),y=a/(a-s);else if(o===Ci)x=-2/(a-s),y=-(a+s)/(a-s);else if(o===sa)x=-1/(a-s),y=-s/(a-s);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=h,c[4]=0,c[8]=0,c[12]=f,c[1]=0,c[5]=d,c[9]=0,c[13]=p,c[2]=0,c[6]=0,c[10]=x,c[14]=y,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let r=0;r<16;r++)if(t[r]!==n[r])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){let 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}};El.prototype.isMatrix4=!0;ot=El,Ws=new W,Ai=new ot,Vv=new W(0,0,0),Wv=new W(1,1,1),Tr=new W,Mc=new W,ri=new W,fg=new ot,pg=new Pt,qi=class i{constructor(e=0,t=0,n=0,r=i.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=r}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,r=this._order){return this._x=e,this._y=t,this._z=n,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){let r=e.elements,s=r[0],a=r[4],o=r[8],l=r[1],c=r[5],h=r[9],d=r[2],f=r[6],p=r[10];switch(t){case"XYZ":this._y=Math.asin(bt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,p),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(f,c),this._z=0);break;case"YXZ":this._x=Math.asin(-bt(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,p),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-d,s),this._z=0);break;case"ZXY":this._x=Math.asin(bt(f,-1,1)),Math.abs(f)<.9999999?(this._y=Math.atan2(-d,p),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-bt(d,-1,1)),Math.abs(d)<.9999999?(this._x=Math.atan2(f,p),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-a,c));break;case"YZX":this._z=Math.asin(bt(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-h,c),this._y=Math.atan2(-d,s)):(this._x=0,this._y=Math.atan2(o,p));break;case"XZY":this._z=Math.asin(-bt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(f,c),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-h,p),this._y=0);break;default:Ke("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return fg.makeRotationFromQuaternion(e),this.setFromRotationMatrix(fg,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return pg.setFromEuler(this),this.setFromQuaternion(pg,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};qi.DEFAULT_ORDER="XYZ";la=class{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}},qv=0,mg=new W,qs=new Pt,ar=new ot,Ac=new W,Ga=new W,$v=new W,jv=new Pt,gg=new W(1,0,0),bg=new W(0,1,0),xg=new W(0,0,1),_g={type:"added"},Xv={type:"removed"},$s={type:"childadded",child:null},Hu={type:"childremoved",child:null},qt=class i extends Li{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:qv++}),this.uuid=Ii(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=i.DEFAULT_UP.clone();let e=new W,t=new qi,n=new Pt,r=new W(1,1,1);function s(){n.setFromEuler(t,!1)}function a(){t.setFromQuaternion(n,void 0,!1)}t._onChange(s),n._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new ot},normalMatrix:{value:new ct}}),this.matrix=new ot,this.matrixWorld=new ot,this.matrixAutoUpdate=i.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=i.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new la,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return qs.setFromAxisAngle(e,t),this.quaternion.multiply(qs),this}rotateOnWorldAxis(e,t){return qs.setFromAxisAngle(e,t),this.quaternion.premultiply(qs),this}rotateX(e){return this.rotateOnAxis(gg,e)}rotateY(e){return this.rotateOnAxis(bg,e)}rotateZ(e){return this.rotateOnAxis(xg,e)}translateOnAxis(e,t){return mg.copy(e).applyQuaternion(this.quaternion),this.position.add(mg.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(gg,e)}translateY(e){return this.translateOnAxis(bg,e)}translateZ(e){return this.translateOnAxis(xg,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(ar.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?Ac.copy(e):Ac.set(e,t,n);let r=this.parent;this.updateWorldMatrix(!0,!1),Ga.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?ar.lookAt(Ga,Ac,this.up):ar.lookAt(Ac,Ga,this.up),this.quaternion.setFromRotationMatrix(ar),r&&(ar.extractRotation(r.matrixWorld),qs.setFromRotationMatrix(ar),this.quaternion.premultiply(qs.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(et("Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(_g),$s.child=e,this.dispatchEvent($s),$s.child=null):et("Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}let t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(Xv),Hu.child=e,this.dispatchEvent(Hu),Hu.child=null),this}removeFromParent(){let e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),ar.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),ar.multiply(e.parent.matrixWorld)),e.applyMatrix4(ar),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(_g),$s.child=e,this.dispatchEvent($s),$s.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,r=this.children.length;n<r;n++){let a=this.children[n].getObjectByProperty(e,t);if(a!==void 0)return a}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);let r=this.children;for(let s=0,a=r.length;s<a;s++)r[s].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ga,e,$v),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ga,jv,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverseVisible(e)}traverseAncestors(e){let t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);let e=this.pivot;if(e!==null){let t=e.x,n=e.y,r=e.z,s=this.matrix.elements;s[12]+=t-s[0]*t-s[4]*n-s[8]*r,s[13]+=n-s[1]*t-s[5]*n-s[9]*r,s[14]+=r-s[2]*t-s[6]*n-s[10]*r}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t){let n=this.parent;if(e===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),t===!0){let r=this.children;for(let s=0,a=r.length;s<a;s++)r[s].updateWorldMatrix(!1,!0)}}toJSON(e){let t=e===void 0||typeof e=="string",n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});let r={};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.castShadow===!0&&(r.castShadow=!0),this.receiveShadow===!0&&(r.receiveShadow=!0),this.visible===!1&&(r.visible=!1),this.frustumCulled===!1&&(r.frustumCulled=!1),this.renderOrder!==0&&(r.renderOrder=this.renderOrder),this.static!==!1&&(r.static=this.static),Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.pivot!==null&&(r.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(r.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(r.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type="BatchedMesh",r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(o=>({...o})),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(e),r.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(r.boundingBox=this.boundingBox.toJSON()));function s(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=s(e.geometries,this.geometry);let o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){let l=o.shapes;if(Array.isArray(l))for(let c=0,h=l.length;c<h;c++){let d=l[c];s(e.shapes,d)}else s(e.shapes,l)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let o=[];for(let l=0,c=this.material.length;l<c;l++)o.push(s(e.materials,this.material[l]));r.material=o}else r.material=s(e.materials,this.material);if(this.children.length>0){r.children=[];for(let o=0;o<this.children.length;o++)r.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let o=0;o<this.animations.length;o++){let l=this.animations[o];r.animations.push(s(e.animations,l))}}if(t){let o=a(e.geometries),l=a(e.materials),c=a(e.textures),h=a(e.images),d=a(e.shapes),f=a(e.skeletons),p=a(e.animations),x=a(e.nodes);o.length>0&&(n.geometries=o),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),h.length>0&&(n.images=h),d.length>0&&(n.shapes=d),f.length>0&&(n.skeletons=f),p.length>0&&(n.animations=p),x.length>0&&(n.nodes=x)}return n.object=r,n;function a(o){let l=[];for(let c in o){let h=o[c];delete h.metadata,l.push(h)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot!==null?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){let r=e.children[n];this.add(r.clone())}return this}};qt.DEFAULT_UP=new W(0,1,0);qt.DEFAULT_MATRIX_AUTO_UPDATE=!0;qt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;pn=class extends qt{constructor(){super(),this.isGroup=!0,this.type="Group"}},Kv={type:"move"},ha=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new pn,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new pn,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new W,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new W),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new pn,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new W,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new W,this._grip.eventsEnabled=!1),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let r=null,s=null,a=null,o=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){a=!0;for(let y of e.hand.values()){let b=t.getJointPose(y,n),g=this._getHandJoint(c,y);b!==null&&(g.matrix.fromArray(b.transform.matrix),g.matrix.decompose(g.position,g.rotation,g.scale),g.matrixWorldNeedsUpdate=!0,g.jointRadius=b.radius),g.visible=b!==null}let h=c.joints["index-finger-tip"],d=c.joints["thumb-tip"],f=h.position.distanceTo(d.position),p=.02,x=.005;c.inputState.pinching&&f>p+x?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&f<=p-x&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,n),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1,l.eventsEnabled&&l.dispatchEvent({type:"gripUpdated",data:e,target:this})));o!==null&&(r=t.getPose(e.targetRaySpace,n),r===null&&s!==null&&(r=s),r!==null&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(Kv)))}return o!==null&&(o.visible=r!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let n=new pn;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}},C0={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},Er={h:0,s:0,l:0},Tc={h:0,s:0,l:0};Ve=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let r=e;r&&r.isColor?this.copy(r):typeof r=="number"?this.setHex(r):typeof r=="string"&&this.setStyle(r)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Xt){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,ut.colorSpaceToWorking(this,t),this}setRGB(e,t,n,r=ut.workingColorSpace){return this.r=e,this.g=t,this.b=n,ut.colorSpaceToWorking(this,r),this}setHSL(e,t,n,r=ut.workingColorSpace){if(e=zd(e,1),t=bt(t,0,1),n=bt(n,0,1),t===0)this.r=this.g=this.b=n;else{let s=n<=.5?n*(1+t):n+t-n*t,a=2*n-s;this.r=Gu(a,s,e+1/3),this.g=Gu(a,s,e),this.b=Gu(a,s,e-1/3)}return ut.colorSpaceToWorking(this,r),this}setStyle(e,t=Xt){function n(s){s!==void 0&&parseFloat(s)<1&&Ke("Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let s,a=r[1],o=r[2];switch(a){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,t);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:Ke("Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){let s=r[1],a=s.length;if(a===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(s,16),t);Ke("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Xt){let n=C0[e.toLowerCase()];return n!==void 0?this.setHex(n,t):Ke("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=fr(e.r),this.g=fr(e.g),this.b=fr(e.b),this}copyLinearToSRGB(e){return this.r=ia(e.r),this.g=ia(e.g),this.b=ia(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Xt){return ut.workingToColorSpace(Pn.copy(this),e),Math.round(bt(Pn.r*255,0,255))*65536+Math.round(bt(Pn.g*255,0,255))*256+Math.round(bt(Pn.b*255,0,255))}getHexString(e=Xt){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=ut.workingColorSpace){ut.workingToColorSpace(Pn.copy(this),t);let n=Pn.r,r=Pn.g,s=Pn.b,a=Math.max(n,r,s),o=Math.min(n,r,s),l,c,h=(o+a)/2;if(o===a)l=0,c=0;else{let d=a-o;switch(c=h<=.5?d/(a+o):d/(2-a-o),a){case n:l=(r-s)/d+(r<s?6:0);break;case r:l=(s-n)/d+2;break;case s:l=(n-r)/d+4;break}l/=6}return e.h=l,e.s=c,e.l=h,e}getRGB(e,t=ut.workingColorSpace){return ut.workingToColorSpace(Pn.copy(this),t),e.r=Pn.r,e.g=Pn.g,e.b=Pn.b,e}getStyle(e=Xt){ut.workingToColorSpace(Pn.copy(this),e);let t=Pn.r,n=Pn.g,r=Pn.b;return e!==Xt?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(r*255)})`}offsetHSL(e,t,n){return this.getHSL(Er),this.setHSL(Er.h+e,Er.s+t,Er.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(Er),e.getHSL(Tc);let n=Ja(Er.h,Tc.h,t),r=Ja(Er.s,Tc.s,t),s=Ja(Er.l,Tc.l,t);return this.setHSL(n,r,s),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,n=this.g,r=this.b,s=e.elements;return this.r=s[0]*t+s[3]*n+s[6]*r,this.g=s[1]*t+s[4]*n+s[7]*r,this.b=s[2]*t+s[5]*n+s[8]*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}},Pn=new Ve;Ve.NAMES=C0;no=class i{constructor(e,t=1,n=1e3){this.isFog=!0,this.name="",this.color=new Ve(e),this.near=t,this.far=n}clone(){return new i(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}},Or=class extends qt{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new qi,this.environmentIntensity=1,this.environmentRotation=new qi,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}},Ti=new W,or=new W,Vu=new W,cr=new W,js=new W,Xs=new W,yg=new W,Wu=new W,qu=new W,$u=new W,ju=new kt,Xu=new kt,Ku=new kt,Lr=class i{constructor(e=new W,t=new W,n=new W){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,r){r.subVectors(n,t),Ti.subVectors(e,t),r.cross(Ti);let s=r.lengthSq();return s>0?r.multiplyScalar(1/Math.sqrt(s)):r.set(0,0,0)}static getBarycoord(e,t,n,r,s){Ti.subVectors(r,t),or.subVectors(n,t),Vu.subVectors(e,t);let a=Ti.dot(Ti),o=Ti.dot(or),l=Ti.dot(Vu),c=or.dot(or),h=or.dot(Vu),d=a*c-o*o;if(d===0)return s.set(0,0,0),null;let f=1/d,p=(c*l-o*h)*f,x=(a*h-o*l)*f;return s.set(1-p-x,x,p)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,cr)===null?!1:cr.x>=0&&cr.y>=0&&cr.x+cr.y<=1}static getInterpolation(e,t,n,r,s,a,o,l){return this.getBarycoord(e,t,n,r,cr)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(s,cr.x),l.addScaledVector(a,cr.y),l.addScaledVector(o,cr.z),l)}static getInterpolatedAttribute(e,t,n,r,s,a){return ju.setScalar(0),Xu.setScalar(0),Ku.setScalar(0),ju.fromBufferAttribute(e,t),Xu.fromBufferAttribute(e,n),Ku.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(ju,s.x),a.addScaledVector(Xu,s.y),a.addScaledVector(Ku,s.z),a}static isFrontFacing(e,t,n,r){return Ti.subVectors(n,t),or.subVectors(e,t),Ti.cross(or).dot(r)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,n,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Ti.subVectors(this.c,this.b),or.subVectors(this.a,this.b),Ti.cross(or).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return i.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return i.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,r,s){return i.getInterpolation(e,this.a,this.b,this.c,t,n,r,s)}containsPoint(e){return i.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return i.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,r=this.b,s=this.c,a,o;js.subVectors(r,n),Xs.subVectors(s,n),Wu.subVectors(e,n);let l=js.dot(Wu),c=Xs.dot(Wu);if(l<=0&&c<=0)return t.copy(n);qu.subVectors(e,r);let h=js.dot(qu),d=Xs.dot(qu);if(h>=0&&d<=h)return t.copy(r);let f=l*d-h*c;if(f<=0&&l>=0&&h<=0)return a=l/(l-h),t.copy(n).addScaledVector(js,a);$u.subVectors(e,s);let p=js.dot($u),x=Xs.dot($u);if(x>=0&&p<=x)return t.copy(s);let y=p*c-l*x;if(y<=0&&c>=0&&x<=0)return o=c/(c-x),t.copy(n).addScaledVector(Xs,o);let b=h*x-p*d;if(b<=0&&d-h>=0&&p-x>=0)return yg.subVectors(s,r),o=(d-h)/(d-h+(p-x)),t.copy(r).addScaledVector(yg,o);let g=1/(b+y+f);return a=y*g,o=f*g,t.copy(n).addScaledVector(js,a).addScaledVector(Xs,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},rn=class{constructor(e=new W(1/0,1/0,1/0),t=new W(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(Ei.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(Ei.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let n=Ei.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);let n=e.geometry;if(n!==void 0){let s=n.getAttribute("position");if(t===!0&&s!==void 0&&e.isInstancedMesh!==!0)for(let a=0,o=s.count;a<o;a++)e.isMesh===!0?e.getVertexPosition(a,Ei):Ei.fromBufferAttribute(s,a),Ei.applyMatrix4(e.matrixWorld),this.expandByPoint(Ei);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Ec.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),Ec.copy(n.boundingBox)),Ec.applyMatrix4(e.matrixWorld),this.union(Ec)}let r=e.children;for(let s=0,a=r.length;s<a;s++)this.expandByObject(r[s],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,Ei),Ei.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(Va),Rc.subVectors(this.max,Va),Ks.subVectors(e.a,Va),Ys.subVectors(e.b,Va),Js.subVectors(e.c,Va),Rr.subVectors(Ys,Ks),Cr.subVectors(Js,Ys),ss.subVectors(Ks,Js);let t=[0,-Rr.z,Rr.y,0,-Cr.z,Cr.y,0,-ss.z,ss.y,Rr.z,0,-Rr.x,Cr.z,0,-Cr.x,ss.z,0,-ss.x,-Rr.y,Rr.x,0,-Cr.y,Cr.x,0,-ss.y,ss.x,0];return!Yu(t,Ks,Ys,Js,Rc)||(t=[1,0,0,0,1,0,0,0,1],!Yu(t,Ks,Ys,Js,Rc))?!1:(Cc.crossVectors(Rr,Cr),t=[Cc.x,Cc.y,Cc.z],Yu(t,Ks,Ys,Js,Rc))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Ei).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Ei).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(lr[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),lr[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),lr[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),lr[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),lr[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),lr[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),lr[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),lr[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(lr),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)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}},lr=[new W,new W,new W,new W,new W,new W,new W,new W],Ei=new W,Ec=new rn,Ks=new W,Ys=new W,Js=new W,Rr=new W,Cr=new W,ss=new W,Va=new W,Rc=new W,Cc=new W,as=new W;dr=Yv();Fr=class{static toHalfFloat(e){return Jv(e)}static fromHalfFloat(e){return Zv(e)}},fn=new W,Ic=new dt,Qv=0,Kt=class extends Li{constructor(e,t,n=!1){if(super(),Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Qv++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=sl,this.updateRanges=[],this.gpuType=Tn,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,s=this.itemSize;r<s;r++)this.array[e+r]=t.array[n+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)Ic.fromBufferAttribute(this,t),Ic.applyMatrix3(e),this.setXY(t,Ic.x,Ic.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)fn.fromBufferAttribute(this,t),fn.applyMatrix3(e),this.setXYZ(t,fn.x,fn.y,fn.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)fn.fromBufferAttribute(this,t),fn.applyMatrix4(e),this.setXYZ(t,fn.x,fn.y,fn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)fn.fromBufferAttribute(this,t),fn.applyNormalMatrix(e),this.setXYZ(t,fn.x,fn.y,fn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)fn.fromBufferAttribute(this,t),fn.transformDirection(e),this.setXYZ(t,fn.x,fn.y,fn.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=Ri(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=Nt(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=Ri(t,this.array)),t}setX(e,t){return this.normalized&&(t=Nt(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=Ri(t,this.array)),t}setY(e,t){return this.normalized&&(t=Nt(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=Ri(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Nt(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=Ri(t,this.array)),t}setW(e,t){return this.normalized&&(t=Nt(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=Nt(t,this.array),n=Nt(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=Nt(t,this.array),n=Nt(n,this.array),r=Nt(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this}setXYZW(e,t,n,r,s){return e*=this.itemSize,this.normalized&&(t=Nt(t,this.array),n=Nt(n,this.array),r=Nt(r,this.array),s=Nt(s,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this.array[e+3]=s,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let 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!==sl&&(e.usage=this.usage),e}dispose(){this.dispatchEvent({type:"dispose"})}},io=class extends Kt{constructor(e,t,n){super(new Uint16Array(e),t,n)}},ro=class extends Kt{constructor(e,t,n){super(new Uint32Array(e),t,n)}},Qt=class extends Kt{constructor(e,t,n){super(new Float32Array(e),t,n)}},eS=new rn,Wa=new W,Ju=new W,Yn=class{constructor(e=new W,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let n=this.center;t!==void 0?n.copy(t):eS.setFromPoints(e).getCenter(n);let r=0;for(let s=0,a=e.length;s<a;s++)r=Math.max(r,n.distanceToSquared(e[s]));return this.radius=Math.sqrt(r),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){let 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){let n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Wa.subVectors(e,this.center);let t=Wa.lengthSq();if(t>this.radius*this.radius){let n=Math.sqrt(t),r=(n-this.radius)*.5;this.center.addScaledVector(Wa,r/n),this.radius+=r}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(Ju.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Wa.copy(e.center).add(Ju)),this.expandByPoint(Wa.copy(e.center).sub(Ju))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}},tS=0,pi=new ot,Zu=new qt,Zs=new W,si=new rn,qa=new rn,vn=new W,mn=class i extends Li{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:tS++}),this.uuid=Ii(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,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(wv(e)?ro:io)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let s=new ct().getNormalMatrix(e);n.applyNormalMatrix(s),n.needsUpdate=!0}let r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return pi.makeRotationFromQuaternion(e),this.applyMatrix4(pi),this}rotateX(e){return pi.makeRotationX(e),this.applyMatrix4(pi),this}rotateY(e){return pi.makeRotationY(e),this.applyMatrix4(pi),this}rotateZ(e){return pi.makeRotationZ(e),this.applyMatrix4(pi),this}translate(e,t,n){return pi.makeTranslation(e,t,n),this.applyMatrix4(pi),this}scale(e,t,n){return pi.makeScale(e,t,n),this.applyMatrix4(pi),this}lookAt(e){return Zu.lookAt(e),Zu.updateMatrix(),this.applyMatrix4(Zu.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Zs).negate(),this.translate(Zs.x,Zs.y,Zs.z),this}setFromPoints(e){let t=this.getAttribute("position");if(t===void 0){let n=[];for(let r=0,s=e.length;r<s;r++){let a=e[r];n.push(a.x,a.y,a.z||0)}this.setAttribute("position",new Qt(n,3))}else{let n=Math.min(e.length,t.count);for(let r=0;r<n;r++){let s=e[r];t.setXYZ(r,s.x,s.y,s.z||0)}e.length>t.count&&Ke("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new rn);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){et("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new W(-1/0,-1/0,-1/0),new W(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,r=t.length;n<r;n++){let s=t[n];si.setFromBufferAttribute(s),this.morphTargetsRelative?(vn.addVectors(this.boundingBox.min,si.min),this.boundingBox.expandByPoint(vn),vn.addVectors(this.boundingBox.max,si.max),this.boundingBox.expandByPoint(vn)):(this.boundingBox.expandByPoint(si.min),this.boundingBox.expandByPoint(si.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&et('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Yn);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){et("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new W,1/0);return}if(e){let n=this.boundingSphere.center;if(si.setFromBufferAttribute(e),t)for(let s=0,a=t.length;s<a;s++){let o=t[s];qa.setFromBufferAttribute(o),this.morphTargetsRelative?(vn.addVectors(si.min,qa.min),si.expandByPoint(vn),vn.addVectors(si.max,qa.max),si.expandByPoint(vn)):(si.expandByPoint(qa.min),si.expandByPoint(qa.max))}si.getCenter(n);let r=0;for(let s=0,a=e.count;s<a;s++)vn.fromBufferAttribute(e,s),r=Math.max(r,n.distanceToSquared(vn));if(t)for(let s=0,a=t.length;s<a;s++){let o=t[s],l=this.morphTargetsRelative;for(let c=0,h=o.count;c<h;c++)vn.fromBufferAttribute(o,c),l&&(Zs.fromBufferAttribute(e,c),vn.add(Zs)),r=Math.max(r,n.distanceToSquared(vn))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&et('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){let e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){et("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let n=t.position,r=t.normal,s=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Kt(new Float32Array(4*n.count),4));let a=this.getAttribute("tangent"),o=[],l=[];for(let v=0;v<n.count;v++)o[v]=new W,l[v]=new W;let c=new W,h=new W,d=new W,f=new dt,p=new dt,x=new dt,y=new W,b=new W;function g(v,I,B){c.fromBufferAttribute(n,v),h.fromBufferAttribute(n,I),d.fromBufferAttribute(n,B),f.fromBufferAttribute(s,v),p.fromBufferAttribute(s,I),x.fromBufferAttribute(s,B),h.sub(c),d.sub(c),p.sub(f),x.sub(f);let k=1/(p.x*x.y-x.x*p.y);isFinite(k)&&(y.copy(h).multiplyScalar(x.y).addScaledVector(d,-p.y).multiplyScalar(k),b.copy(d).multiplyScalar(p.x).addScaledVector(h,-x.x).multiplyScalar(k),o[v].add(y),o[I].add(y),o[B].add(y),l[v].add(b),l[I].add(b),l[B].add(b))}let S=this.groups;S.length===0&&(S=[{start:0,count:e.count}]);for(let v=0,I=S.length;v<I;++v){let B=S[v],k=B.start,V=B.count;for(let J=k,L=k+V;J<L;J+=3)g(e.getX(J+0),e.getX(J+1),e.getX(J+2))}let A=new W,T=new W,N=new W,P=new W;function U(v){N.fromBufferAttribute(r,v),P.copy(N);let I=o[v];A.copy(I),A.sub(N.multiplyScalar(N.dot(I))).normalize(),T.crossVectors(P,I);let k=T.dot(l[v])<0?-1:1;a.setXYZW(v,A.x,A.y,A.z,k)}for(let v=0,I=S.length;v<I;++v){let B=S[v],k=B.start,V=B.count;for(let J=k,L=k+V;J<L;J+=3)U(e.getX(J+0)),U(e.getX(J+1)),U(e.getX(J+2))}}computeVertexNormals(){let e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new Kt(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let f=0,p=n.count;f<p;f++)n.setXYZ(f,0,0,0);let r=new W,s=new W,a=new W,o=new W,l=new W,c=new W,h=new W,d=new W;if(e)for(let f=0,p=e.count;f<p;f+=3){let x=e.getX(f+0),y=e.getX(f+1),b=e.getX(f+2);r.fromBufferAttribute(t,x),s.fromBufferAttribute(t,y),a.fromBufferAttribute(t,b),h.subVectors(a,s),d.subVectors(r,s),h.cross(d),o.fromBufferAttribute(n,x),l.fromBufferAttribute(n,y),c.fromBufferAttribute(n,b),o.add(h),l.add(h),c.add(h),n.setXYZ(x,o.x,o.y,o.z),n.setXYZ(y,l.x,l.y,l.z),n.setXYZ(b,c.x,c.y,c.z)}else for(let f=0,p=t.count;f<p;f+=3)r.fromBufferAttribute(t,f+0),s.fromBufferAttribute(t,f+1),a.fromBufferAttribute(t,f+2),h.subVectors(a,s),d.subVectors(r,s),h.cross(d),n.setXYZ(f+0,h.x,h.y,h.z),n.setXYZ(f+1,h.x,h.y,h.z),n.setXYZ(f+2,h.x,h.y,h.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)vn.fromBufferAttribute(e,t),vn.normalize(),e.setXYZ(t,vn.x,vn.y,vn.z)}toNonIndexed(){function e(o,l){let c=o.array,h=o.itemSize,d=o.normalized,f=new c.constructor(l.length*h),p=0,x=0;for(let y=0,b=l.length;y<b;y++){o.isInterleavedBufferAttribute?p=l[y]*o.data.stride+o.offset:p=l[y]*h;for(let g=0;g<h;g++)f[x++]=c[p++]}return new Kt(f,h,d)}if(this.index===null)return Ke("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new i,n=this.index.array,r=this.attributes;for(let o in r){let l=r[o],c=e(l,n);t.setAttribute(o,c)}let s=this.morphAttributes;for(let o in s){let l=[],c=s[o];for(let h=0,d=c.length;h<d;h++){let f=c[h],p=e(f,n);l.push(p)}t.morphAttributes[o]=l}t.morphTargetsRelative=this.morphTargetsRelative;let a=this.groups;for(let o=0,l=a.length;o<l;o++){let c=a[o];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){let e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){let l=this.parameters;for(let c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let n=this.attributes;for(let l in n){let c=n[l];e.data.attributes[l]=c.toJSON(e.data)}let r={},s=!1;for(let l in this.morphAttributes){let c=this.morphAttributes[l],h=[];for(let d=0,f=c.length;d<f;d++){let p=c[d];h.push(p.toJSON(e.data))}h.length>0&&(r[l]=h,s=!0)}s&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);let a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));let o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),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;let t={};this.name=e.name;let n=e.index;n!==null&&this.setIndex(n.clone());let r=e.attributes;for(let c in r){let h=r[c];this.setAttribute(c,h.clone(t))}let s=e.morphAttributes;for(let c in s){let h=[],d=s[c];for(let f=0,p=d.length;f<p;f++)h.push(d[f].clone(t));this.morphAttributes[c]=h}this.morphTargetsRelative=e.morphTargetsRelative;let a=e.groups;for(let c=0,h=a.length;c<h;c++){let d=a[c];this.addGroup(d.start,d.count,d.materialIndex)}let o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());let l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}},Ur=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=sl,this.updateRanges=[],this.version=0,this.uuid=Ii()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let r=0,s=this.stride;r<s;r++)this.array[e+r]=t.array[n+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Ii()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Ii()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}},zn=new W,kr=class i{constructor(e,t,n,r=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)zn.fromBufferAttribute(this,t),zn.applyMatrix4(e),this.setXYZ(t,zn.x,zn.y,zn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)zn.fromBufferAttribute(this,t),zn.applyNormalMatrix(e),this.setXYZ(t,zn.x,zn.y,zn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)zn.fromBufferAttribute(this,t),zn.transformDirection(e),this.setXYZ(t,zn.x,zn.y,zn.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=Ri(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=Nt(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=Nt(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=Nt(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=Nt(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=Nt(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=Ri(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=Ri(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=Ri(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=Ri(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=Nt(t,this.array),n=Nt(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=Nt(t,this.array),n=Nt(n,this.array),r=Nt(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this}setXYZW(e,t,n,r,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=Nt(t,this.array),n=Nt(n,this.array),r=Nt(r,this.array),s=Nt(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this.data.array[e+3]=s,this}clone(e){if(e===void 0){eo("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let n=0;n<this.count;n++){let r=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return new Kt(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new i(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){eo("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let n=0;n<this.count;n++){let r=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}},nS=0,Ln=class extends Li{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:nS++}),this.uuid=Ii(),this.name="",this.type="Material",this.blending=fs,this.side=Pi,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Yc,this.blendDst=Jc,this.blendEquation=Dr,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Ve(0,0,0),this.blendAlpha=0,this.depthFunc=ps,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=ud,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=ls,this.stencilZFail=ls,this.stencilZPass=ls,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(let t in e){let n=e[t];if(n===void 0){Ke(`Material: parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){Ke(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});let n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==fs&&(n.blending=this.blending),this.side!==Pi&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==Yc&&(n.blendSrc=this.blendSrc),this.blendDst!==Jc&&(n.blendDst=this.blendDst),this.blendEquation!==Dr&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==ps&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==ud&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==ls&&(n.stencilFail=this.stencilFail),this.stencilZFail!==ls&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==ls&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.allowOverride===!1&&(n.allowOverride=!1),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function r(s){let a=[];for(let o in s){let l=s[o];delete l.metadata,a.push(l)}return a}if(t){let s=r(e.textures),a=r(e.images);s.length>0&&(n.textures=s),a.length>0&&(n.images=a)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,n=null;if(t!==null){let r=t.length;n=new Array(r);for(let s=0;s!==r;++s)n[s]=t[s].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}},hr=new W,Qu=new W,Pc=new W,Ir=new W,ed=new W,Lc=new W,td=new W,Br=class{constructor(e=new W,t=new W(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,hr)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=hr.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(hr.copy(this.origin).addScaledVector(this.direction,t),hr.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){Qu.copy(e).add(t).multiplyScalar(.5),Pc.copy(t).sub(e).normalize(),Ir.copy(this.origin).sub(Qu);let s=e.distanceTo(t)*.5,a=-this.direction.dot(Pc),o=Ir.dot(this.direction),l=-Ir.dot(Pc),c=Ir.lengthSq(),h=Math.abs(1-a*a),d,f,p,x;if(h>0)if(d=a*l-o,f=a*o-l,x=s*h,d>=0)if(f>=-x)if(f<=x){let y=1/h;d*=y,f*=y,p=d*(d+a*f+2*o)+f*(a*d+f+2*l)+c}else f=s,d=Math.max(0,-(a*f+o)),p=-d*d+f*(f+2*l)+c;else f=-s,d=Math.max(0,-(a*f+o)),p=-d*d+f*(f+2*l)+c;else f<=-x?(d=Math.max(0,-(-a*s+o)),f=d>0?-s:Math.min(Math.max(-s,-l),s),p=-d*d+f*(f+2*l)+c):f<=x?(d=0,f=Math.min(Math.max(-s,-l),s),p=f*(f+2*l)+c):(d=Math.max(0,-(a*s+o)),f=d>0?s:Math.min(Math.max(-s,-l),s),p=-d*d+f*(f+2*l)+c);else f=a>0?-s:s,d=Math.max(0,-(a*f+o)),p=-d*d+f*(f+2*l)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,d),r&&r.copy(Qu).addScaledVector(Pc,f),p}intersectSphere(e,t){hr.subVectors(e.center,this.origin);let n=hr.dot(this.direction),r=hr.dot(hr)-n*n,s=e.radius*e.radius;if(r>s)return null;let a=Math.sqrt(s-r),o=n-a,l=n+a;return l<0?null:o<0?this.at(l,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,r,s,a,o,l,c=1/this.direction.x,h=1/this.direction.y,d=1/this.direction.z,f=this.origin;return c>=0?(n=(e.min.x-f.x)*c,r=(e.max.x-f.x)*c):(n=(e.max.x-f.x)*c,r=(e.min.x-f.x)*c),h>=0?(s=(e.min.y-f.y)*h,a=(e.max.y-f.y)*h):(s=(e.max.y-f.y)*h,a=(e.min.y-f.y)*h),n>a||s>r||((s>n||isNaN(n))&&(n=s),(a<r||isNaN(r))&&(r=a),d>=0?(o=(e.min.z-f.z)*d,l=(e.max.z-f.z)*d):(o=(e.max.z-f.z)*d,l=(e.min.z-f.z)*d),n>l||o>r)||((o>n||n!==n)&&(n=o),(l<r||r!==r)&&(r=l),r<0)?null:this.at(n>=0?n:r,t)}intersectsBox(e){return this.intersectBox(e,hr)!==null}intersectTriangle(e,t,n,r,s){ed.subVectors(t,e),Lc.subVectors(n,e),td.crossVectors(ed,Lc);let a=this.direction.dot(td),o;if(a>0){if(r)return null;o=1}else if(a<0)o=-1,a=-a;else return null;Ir.subVectors(this.origin,e);let l=o*this.direction.dot(Lc.crossVectors(Ir,Lc));if(l<0)return null;let c=o*this.direction.dot(ed.cross(Ir));if(c<0||l+c>a)return null;let h=-o*Ir.dot(td);return h<0?null:this.at(h/a,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},gn=class extends Ln{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Ve(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new qi,this.combine=Rl,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},vg=new ot,os=new Br,Dc=new Yn,Sg=new W,Nc=new W,Oc=new W,Fc=new W,nd=new W,Uc=new W,wg=new W,kc=new W,xt=class extends qt{constructor(e=new mn,t=new gn){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=r.length;s<a;s++){let o=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}getVertexPosition(e,t){let n=this.geometry,r=n.attributes.position,s=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(r,e);let o=this.morphTargetInfluences;if(s&&o){Uc.set(0,0,0);for(let l=0,c=s.length;l<c;l++){let h=o[l],d=s[l];h!==0&&(nd.fromBufferAttribute(d,e),a?Uc.addScaledVector(nd,h):Uc.addScaledVector(nd.sub(t),h))}t.add(Uc)}return t}raycast(e,t){let n=this.geometry,r=this.material,s=this.matrixWorld;r!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),Dc.copy(n.boundingSphere),Dc.applyMatrix4(s),os.copy(e.ray).recast(e.near),!(Dc.containsPoint(os.origin)===!1&&(os.intersectSphere(Dc,Sg)===null||os.origin.distanceToSquared(Sg)>(e.far-e.near)**2))&&(vg.copy(s).invert(),os.copy(e.ray).applyMatrix4(vg),!(n.boundingBox!==null&&os.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,os)))}_computeIntersections(e,t,n){let r,s=this.geometry,a=this.material,o=s.index,l=s.attributes.position,c=s.attributes.uv,h=s.attributes.uv1,d=s.attributes.normal,f=s.groups,p=s.drawRange;if(o!==null)if(Array.isArray(a))for(let x=0,y=f.length;x<y;x++){let b=f[x],g=a[b.materialIndex],S=Math.max(b.start,p.start),A=Math.min(o.count,Math.min(b.start+b.count,p.start+p.count));for(let T=S,N=A;T<N;T+=3){let P=o.getX(T),U=o.getX(T+1),v=o.getX(T+2);r=Bc(this,g,e,n,c,h,d,P,U,v),r&&(r.faceIndex=Math.floor(T/3),r.face.materialIndex=b.materialIndex,t.push(r))}}else{let x=Math.max(0,p.start),y=Math.min(o.count,p.start+p.count);for(let b=x,g=y;b<g;b+=3){let S=o.getX(b),A=o.getX(b+1),T=o.getX(b+2);r=Bc(this,a,e,n,c,h,d,S,A,T),r&&(r.faceIndex=Math.floor(b/3),t.push(r))}}else if(l!==void 0)if(Array.isArray(a))for(let x=0,y=f.length;x<y;x++){let b=f[x],g=a[b.materialIndex],S=Math.max(b.start,p.start),A=Math.min(l.count,Math.min(b.start+b.count,p.start+p.count));for(let T=S,N=A;T<N;T+=3){let P=T,U=T+1,v=T+2;r=Bc(this,g,e,n,c,h,d,P,U,v),r&&(r.faceIndex=Math.floor(T/3),r.face.materialIndex=b.materialIndex,t.push(r))}}else{let x=Math.max(0,p.start),y=Math.min(l.count,p.start+p.count);for(let b=x,g=y;b<g;b+=3){let S=b,A=b+1,T=b+2;r=Bc(this,a,e,n,c,h,d,S,A,T),r&&(r.faceIndex=Math.floor(b/3),t.push(r))}}}};$a=new kt,Mg=new kt,Ag=new kt,rS=new kt,Tg=new ot,zc=new W,id=new Yn,Eg=new ot,rd=new Br,so=class extends xt{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=ld,this.bindMatrix=new ot,this.bindMatrixInverse=new ot,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let e=this.geometry;this.boundingBox===null&&(this.boundingBox=new rn),this.boundingBox.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,zc),this.boundingBox.expandByPoint(zc)}computeBoundingSphere(){let e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new Yn),this.boundingSphere.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,zc),this.boundingSphere.expandByPoint(zc)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){let n=this.material,r=this.matrixWorld;n!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),id.copy(this.boundingSphere),id.applyMatrix4(r),e.ray.intersectsSphere(id)!==!1&&(Eg.copy(r).invert(),rd.copy(e.ray).applyMatrix4(Eg),!(this.boundingBox!==null&&rd.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,rd)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){let e=new kt,t=this.geometry.attributes.skinWeight;for(let n=0,r=t.count;n<r;n++){e.fromBufferAttribute(t,n);let s=1/e.manhattanLength();s!==1/0?e.multiplyScalar(s):e.set(1,0,0,0),t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===ld?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===p0?this.bindMatrixInverse.copy(this.bindMatrix).invert():Ke("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){let n=this.skeleton,r=this.geometry;Mg.fromBufferAttribute(r.attributes.skinIndex,e),Ag.fromBufferAttribute(r.attributes.skinWeight,e),t.isVector4?($a.copy(t),t.set(0,0,0,0)):($a.set(...t,1),t.set(0,0,0)),$a.applyMatrix4(this.bindMatrix);for(let s=0;s<4;s++){let a=Ag.getComponent(s);if(a!==0){let o=Mg.getComponent(s);Tg.multiplyMatrices(n.bones[o].matrixWorld,n.boneInverses[o]),t.addScaledVector(rS.copy($a).applyMatrix4(Tg),a)}}return t.isVector4&&(t.w=$a.w),t.applyMatrix4(this.bindMatrixInverse)}},ua=class extends qt{constructor(){super(),this.isBone=!0,this.type="Bone"}},xs=class extends xn{constructor(e=null,t=1,n=1,r,s,a,o,l,c=on,h=on,d,f){super(null,a,o,l,c,h,r,s,d,f),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},Rg=new ot,sS=new ot,ao=class i{constructor(e=[],t=[]){this.uuid=Ii(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.previousBoneMatrices=null,this.boneTexture=null,this.init()}init(){let e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){Ke("Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,r=this.bones.length;n<r;n++)this.boneInverses.push(new ot)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let n=new ot;this.bones[e]&&n.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(n)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){let n=this.bones[e];n&&n.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){let n=this.bones[e];n&&(n.parent&&n.parent.isBone?(n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld)):n.matrix.copy(n.matrixWorld),n.matrix.decompose(n.position,n.quaternion,n.scale))}}update(){let e=this.bones,t=this.boneInverses,n=this.boneMatrices,r=this.boneTexture;for(let s=0,a=e.length;s<a;s++){let o=e[s]?e[s].matrixWorld:sS;Rg.multiplyMatrices(o,t[s]),Rg.toArray(n,s*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new i(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);let t=new Float32Array(e*e*4);t.set(this.boneMatrices);let n=new xs(t,e,e,ci,Tn);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){let r=this.bones[t];if(r.name===e)return r}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,r=e.bones.length;n<r;n++){let s=e.bones[n],a=t[s];a===void 0&&(Ke("Skeleton: No bone found with UUID:",s),a=new ua),this.bones.push(a),this.boneInverses.push(new ot().fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){let e={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;let t=this.bones,n=this.boneInverses;for(let r=0,s=t.length;r<s;r++){let a=t[r];e.bones.push(a.uuid);let o=n[r];e.boneInverses.push(o.toArray())}return e}},zr=class extends Kt{constructor(e,t,n,r=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}},Qs=new ot,Cg=new ot,Hc=[],Ig=new rn,aS=new ot,ja=new xt,Xa=new Yn,_s=class extends xt{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new zr(new Float32Array(n*16),16),this.previousInstanceMatrix=null,this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let r=0;r<n;r++)this.setMatrixAt(r,aS)}computeBoundingBox(){let e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new rn),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Qs),Ig.copy(e.boundingBox).applyMatrix4(Qs),this.boundingBox.union(Ig)}computeBoundingSphere(){let e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new Yn),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Qs),Xa.copy(e.boundingSphere).applyMatrix4(Qs),this.boundingSphere.union(Xa)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.previousInstanceMatrix!==null&&(this.previousInstanceMatrix=e.previousInstanceMatrix.clone()),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){return this.instanceColor===null?t.setRGB(1,1,1):t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){return t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){let n=t.morphTargetInfluences,r=this.morphTexture.source.data.data,s=n.length+1,a=e*s+1;for(let o=0;o<n.length;o++)n[o]=r[a+o]}raycast(e,t){let n=this.matrixWorld,r=this.count;if(ja.geometry=this.geometry,ja.material=this.material,ja.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Xa.copy(this.boundingSphere),Xa.applyMatrix4(n),e.ray.intersectsSphere(Xa)!==!1))for(let s=0;s<r;s++){this.getMatrixAt(s,Qs),Cg.multiplyMatrices(n,Qs),ja.matrixWorld=Cg,ja.raycast(e,Hc);for(let a=0,o=Hc.length;a<o;a++){let l=Hc[a];l.instanceId=s,l.object=this,t.push(l)}Hc.length=0}}setColorAt(e,t){return this.instanceColor===null&&(this.instanceColor=new zr(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),t.toArray(this.instanceColor.array,e*3),this}setMatrixAt(e,t){return t.toArray(this.instanceMatrix.array,e*16),this}setMorphAt(e,t){let n=t.morphTargetInfluences,r=n.length+1;this.morphTexture===null&&(this.morphTexture=new xs(new Float32Array(r*this.count),r,this.count,Ol,Tn));let s=this.morphTexture.source.data.data,a=0;for(let c=0;c<n.length;c++)a+=n[c];let o=this.geometry.morphTargetsRelative?1:1-a,l=r*e;return s[l]=o,s.set(n,l+1),this}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}},sd=new W,oS=new W,cS=new ct,Gi=class{constructor(e=new W(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,r){return this.normal.set(e,t,n),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){let r=sd.subVectors(n,t).cross(oS.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t,n=!0){let r=e.delta(sd),s=this.normal.dot(r);if(s===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let a=-(e.start.dot(this.normal)+this.constant)/s;return n===!0&&(a<0||a>1)?null:t.copy(e.start).addScaledVector(r,a)}intersectsLine(e){let 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){let n=t||cS.getNormalMatrix(e),r=this.coplanarPoint(sd).applyMatrix4(e),s=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}},cs=new Yn,lS=new dt(.5,.5),Gc=new W,da=class{constructor(e=new Gi,t=new Gi,n=new Gi,r=new Gi,s=new Gi,a=new Gi){this.planes=[e,t,n,r,s,a]}set(e,t,n,r,s,a){let o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(r),o[4].copy(s),o[5].copy(a),this}copy(e){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=Ci,n=!1){let r=this.planes,s=e.elements,a=s[0],o=s[1],l=s[2],c=s[3],h=s[4],d=s[5],f=s[6],p=s[7],x=s[8],y=s[9],b=s[10],g=s[11],S=s[12],A=s[13],T=s[14],N=s[15];if(r[0].setComponents(c-a,p-h,g-x,N-S).normalize(),r[1].setComponents(c+a,p+h,g+x,N+S).normalize(),r[2].setComponents(c+o,p+d,g+y,N+A).normalize(),r[3].setComponents(c-o,p-d,g-y,N-A).normalize(),n)r[4].setComponents(l,f,b,T).normalize(),r[5].setComponents(c-l,p-f,g-b,N-T).normalize();else if(r[4].setComponents(c-l,p-f,g-b,N-T).normalize(),t===Ci)r[5].setComponents(c+l,p+f,g+b,N+T).normalize();else if(t===sa)r[5].setComponents(l,f,b,T).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),cs.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),cs.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(cs)}intersectsSprite(e){cs.center.set(0,0,0);let t=lS.distanceTo(e.center);return cs.radius=.7071067811865476+t,cs.applyMatrix4(e.matrixWorld),this.intersectsSphere(cs)}intersectsSphere(e){let t=this.planes,n=e.center,r=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(n)<r)return!1;return!0}intersectsBox(e){let t=this.planes;for(let n=0;n<6;n++){let r=t[n];if(Gc.x=r.normal.x>0?e.max.x:e.min.x,Gc.y=r.normal.y>0?e.max.y:e.min.y,Gc.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(Gc)<0)return!1}return!0}containsPoint(e){let 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)}},ys=class extends Ln{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Ve(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}},hl=new W,ul=new W,Pg=new ot,Ka=new Br,Vc=new Yn,ad=new W,Lg=new W,vs=class extends qt{constructor(e=new mn,t=new ys){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[0];for(let r=1,s=t.count;r<s;r++)hl.fromBufferAttribute(t,r-1),ul.fromBufferAttribute(t,r),n[r]=n[r-1],n[r]+=hl.distanceTo(ul);e.setAttribute("lineDistance",new Qt(n,1))}else Ke("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){let n=this.geometry,r=this.matrixWorld,s=e.params.Line.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Vc.copy(n.boundingSphere),Vc.applyMatrix4(r),Vc.radius+=s,e.ray.intersectsSphere(Vc)===!1)return;Pg.copy(r).invert(),Ka.copy(e.ray).applyMatrix4(Pg);let o=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=this.isLineSegments?2:1,h=n.index,f=n.attributes.position;if(h!==null){let p=Math.max(0,a.start),x=Math.min(h.count,a.start+a.count);for(let y=p,b=x-1;y<b;y+=c){let g=h.getX(y),S=h.getX(y+1),A=Wc(this,e,Ka,l,g,S,y);A&&t.push(A)}if(this.isLineLoop){let y=h.getX(x-1),b=h.getX(p),g=Wc(this,e,Ka,l,y,b,x-1);g&&t.push(g)}}else{let p=Math.max(0,a.start),x=Math.min(f.count,a.start+a.count);for(let y=p,b=x-1;y<b;y+=c){let g=Wc(this,e,Ka,l,y,y+1,y);g&&t.push(g)}if(this.isLineLoop){let y=Wc(this,e,Ka,l,x-1,p,x-1);y&&t.push(y)}}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=r.length;s<a;s++){let o=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}};Dg=new W,Ng=new W,fa=class extends vs{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[];for(let r=0,s=t.count;r<s;r+=2)Dg.fromBufferAttribute(t,r),Ng.fromBufferAttribute(t,r+1),n[r]=r===0?0:n[r-1],n[r+1]=n[r]+Dg.distanceTo(Ng);e.setAttribute("lineDistance",new Qt(n,1))}else Ke("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},oo=class extends vs{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}},pa=class extends Ln{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Ve(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}},Og=new ot,dd=new Br,qc=new Yn,$c=new W,co=class extends qt{constructor(e=new mn,t=new pa){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){let n=this.geometry,r=this.matrixWorld,s=e.params.Points.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),qc.copy(n.boundingSphere),qc.applyMatrix4(r),qc.radius+=s,e.ray.intersectsSphere(qc)===!1)return;Og.copy(r).invert(),dd.copy(e.ray).applyMatrix4(Og);let o=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=n.index,d=n.attributes.position;if(c!==null){let f=Math.max(0,a.start),p=Math.min(c.count,a.start+a.count);for(let x=f,y=p;x<y;x++){let b=c.getX(x);$c.fromBufferAttribute(d,b),Fg($c,b,l,r,e,t,this)}}else{let f=Math.max(0,a.start),p=Math.min(d.count,a.start+a.count);for(let x=f,y=p;x<y;x++)$c.fromBufferAttribute(d,x),Fg($c,x,l,r,e,t,this)}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=r.length;s<a;s++){let o=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}};lo=class extends xn{constructor(e=[],t=$r,n,r,s,a,o,l,c,h){super(e,t,n,r,s,a,o,l,c,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},Ss=class extends xn{constructor(e,t,n,r,s,a,o,l,c){super(e,t,n,r,s,a,o,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}},pr=class extends xn{constructor(e,t,n=Oi,r,s,a,o=on,l=on,c,h=Wi,d=1){if(h!==Wi&&h!==jr)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");let f={width:e,height:t,depth:d};super(f,r,s,a,o,l,h,n,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new ca(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}},dl=class extends pr{constructor(e,t=Oi,n=$r,r,s,a=on,o=on,l,c=Wi){let h={width:e,height:e,depth:1},d=[h,h,h,h,h,h];super(e,e,t,n,r,s,a,o,l,c),this.image=d,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}},ho=class extends xn{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}},Hr=class i extends mn{constructor(e=1,t=1,n=1,r=1,s=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:s,depthSegments:a};let o=this;r=Math.floor(r),s=Math.floor(s),a=Math.floor(a);let l=[],c=[],h=[],d=[],f=0,p=0;x("z","y","x",-1,-1,n,t,e,a,s,0),x("z","y","x",1,-1,n,t,-e,a,s,1),x("x","z","y",1,1,e,n,t,r,a,2),x("x","z","y",1,-1,e,n,-t,r,a,3),x("x","y","z",1,-1,e,t,n,r,s,4),x("x","y","z",-1,-1,e,t,-n,r,s,5),this.setIndex(l),this.setAttribute("position",new Qt(c,3)),this.setAttribute("normal",new Qt(h,3)),this.setAttribute("uv",new Qt(d,2));function x(y,b,g,S,A,T,N,P,U,v,I){let B=T/U,k=N/v,V=T/2,J=N/2,L=P/2,E=U+1,D=v+1,O=0,H=0,Y=new W;for(let le=0;le<D;le++){let fe=le*k-J;for(let be=0;be<E;be++){let Te=be*B-V;Y[y]=Te*S,Y[b]=fe*A,Y[g]=L,c.push(Y.x,Y.y,Y.z),Y[y]=0,Y[b]=0,Y[g]=P>0?1:-1,h.push(Y.x,Y.y,Y.z),d.push(be/U),d.push(1-le/v),O+=1}}for(let le=0;le<v;le++)for(let fe=0;fe<U;fe++){let be=f+fe+E*le,Te=f+fe+E*(le+1),Je=f+(fe+1)+E*(le+1),ke=f+(fe+1)+E*le;l.push(be,Te,ke),l.push(Te,Je,ke),H+=6}o.addGroup(p,H,I),p+=H,f+=O}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new i(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}},uo=class i extends mn{constructor(e=1,t=32,n=0,r=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:r},t=Math.max(3,t);let s=[],a=[],o=[],l=[],c=new W,h=new dt;a.push(0,0,0),o.push(0,0,1),l.push(.5,.5);for(let d=0,f=3;d<=t;d++,f+=3){let p=n+d/t*r;c.x=e*Math.cos(p),c.y=e*Math.sin(p),a.push(c.x,c.y,c.z),o.push(0,0,1),h.x=(a[f]/e+1)/2,h.y=(a[f+1]/e+1)/2,l.push(h.x,h.y)}for(let d=1;d<=t;d++)s.push(d,d+1,0);this.setIndex(s),this.setAttribute("position",new Qt(a,3)),this.setAttribute("normal",new Qt(o,3)),this.setAttribute("uv",new Qt(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new i(e.radius,e.segments,e.thetaStart,e.thetaLength)}},mi=class i extends mn{constructor(e=1,t=1,n=1,r=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:r};let s=e/2,a=t/2,o=Math.floor(n),l=Math.floor(r),c=o+1,h=l+1,d=e/o,f=t/l,p=[],x=[],y=[],b=[];for(let g=0;g<h;g++){let S=g*f-a;for(let A=0;A<c;A++){let T=A*d-s;x.push(T,-S,0),y.push(0,0,1),b.push(A/o),b.push(1-g/l)}}for(let g=0;g<l;g++)for(let S=0;S<o;S++){let A=S+c*g,T=S+c*(g+1),N=S+1+c*(g+1),P=S+1+c*g;p.push(A,T,P),p.push(T,N,P)}this.setIndex(p),this.setAttribute("position",new Qt(x,3)),this.setAttribute("normal",new Qt(y,3)),this.setAttribute("uv",new Qt(b,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new i(e.width,e.height,e.widthSegments,e.heightSegments)}},Gr=class i extends mn{constructor(e=.5,t=1,n=32,r=1,s=0,a=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:n,phiSegments:r,thetaStart:s,thetaLength:a},n=Math.max(3,n),r=Math.max(1,r);let o=[],l=[],c=[],h=[],d=e,f=(t-e)/r,p=new W,x=new dt;for(let y=0;y<=r;y++){for(let b=0;b<=n;b++){let g=s+b/n*a;p.x=d*Math.cos(g),p.y=d*Math.sin(g),l.push(p.x,p.y,p.z),c.push(0,0,1),x.x=(p.x/t+1)/2,x.y=(p.y/t+1)/2,h.push(x.x,x.y)}d+=f}for(let y=0;y<r;y++){let b=y*(n+1);for(let g=0;g<n;g++){let S=g+b,A=S,T=S+n+1,N=S+n+2,P=S+1;o.push(A,T,P),o.push(T,N,P)}}this.setIndex(o),this.setAttribute("position",new Qt(l,3)),this.setAttribute("normal",new Qt(c,3)),this.setAttribute("uv",new Qt(h,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new i(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}},fo=class extends Ln{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new Ve(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}};I0={clone:Es,merge:Nn},uS=`void main() {
+var _1=Object.create;var Cl=Object.defineProperty;var x1=Object.getOwnPropertyDescriptor;var y1=Object.getOwnPropertyNames;var v1=Object.getPrototypeOf,S1=Object.prototype.hasOwnProperty;var un=(i,e,t)=>()=>{if(t)throw t[0];try{return i&&(e=i(i=0)),e}catch(n){throw t=[n],n}};var xn=(i,e)=>()=>{try{return e||i((e={exports:{}}).exports,e),e.exports}catch(t){throw e=0,t}},er=(i,e)=>{for(var t in e)Cl(i,t,{get:e[t],enumerable:!0})},nb=(i,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of y1(e))!S1.call(i,s)&&s!==t&&Cl(i,s,{get:()=>e[s],enumerable:!(n=x1(e,s))||n.enumerable});return i};var w1=(i,e,t)=>(t=i!=null?_1(v1(i)):{},nb(e||!i||!i.__esModule?Cl(t,"default",{value:i,enumerable:!0}):t,i)),Aa=i=>nb(Cl({},"__esModule",{value:!0}),i);function M1(i){for(let e=i.length-1;e>=0;--e)if(i[e]>=65535)return!0;return!1}function v_(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}function $a(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function S_(){let i=$a("canvas");return i.style.display="block",i}function Xo(...i){let e="THREE."+i.shift();qa?qa("log",e,...i):console.log(e,...i)}function w_(i){let e=i[0];if(typeof e=="string"&&e.startsWith("TSL:")){let t=i[1];t&&t.isStackTrace?i[0]+=" "+t.getLocation():i[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return i}function tt(...i){i=w_(i);let e="THREE."+i.shift();if(qa)qa("warn",e,...i);else{let t=i[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...i)}}function st(...i){i=w_(i);let e="THREE."+i.shift();if(qa)qa("error",e,...i);else{let t=i[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...i)}}function $r(...i){let e=i.join(" ");e in ib||(ib[e]=!0,tt(...i))}function M_(i,e,t){return new Promise(function(n,s){function r(){switch(i.clientWaitSync(e,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:s();break;case i.TIMEOUT_EXPIRED:setTimeout(r,t);break;default:n()}}setTimeout(r,t)})}function Xi(){let i=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(Hn[i&255]+Hn[i>>8&255]+Hn[i>>16&255]+Hn[i>>24&255]+"-"+Hn[e&255]+Hn[e>>8&255]+"-"+Hn[e>>16&15|64]+Hn[e>>24&255]+"-"+Hn[t&63|128]+Hn[t>>8&255]+"-"+Hn[t>>16&255]+Hn[t>>24&255]+Hn[n&255]+Hn[n>>8&255]+Hn[n>>16&255]+Hn[n>>24&255]).toLowerCase()}function yt(i,e,t){return Math.max(e,Math.min(t,i))}function gp(i,e){return(i%e+e)%e}function E1(i,e,t,n,s){return n+(i-e)*(s-n)/(t-e)}function A1(i,e,t){return i!==e?(t-i)/(e-i):0}function Wo(i,e,t){return(1-t)*i+t*e}function T1(i,e,t,n){return Wo(i,e,1-Math.exp(-t*n))}function R1(i,e=1){return e-Math.abs(gp(i,e*2)-e)}function C1(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*(3-2*i))}function I1(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*i*(i*(i*6-15)+10))}function P1(i,e){return i+Math.floor(Math.random()*(e-i+1))}function L1(i,e){return i+Math.random()*(e-i)}function D1(i){return i*(.5-Math.random())}function N1(i){i!==void 0&&(sb=i);let e=sb+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function O1(i){return i*Go}function F1(i){return i*Xr}function k1(i){return i>0&&Number.isInteger(i)&&2**Math.round(Math.log2(i))===i}function U1(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function B1(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function z1(i,e,t,n,s){let r=Math.cos,a=Math.sin,o=r(t/2),c=a(t/2),l=r((e+n)/2),h=a((e+n)/2),u=r((e-n)/2),d=a((e-n)/2),p=r((n-e)/2),b=a((n-e)/2);switch(s){case"XYX":i.set(o*h,c*u,c*d,o*l);break;case"YZY":i.set(c*d,o*h,c*u,o*l);break;case"ZXZ":i.set(c*u,c*d,o*h,o*l);break;case"XZX":i.set(o*h,c*b,c*p,o*l);break;case"YXY":i.set(c*p,o*h,c*b,o*l);break;case"ZYZ":i.set(c*b,c*p,o*h,o*l);break;default:tt("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+s)}}function qi(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return i/4294967295;case Uint16Array:return i/65535;case Uint8Array:case Uint8ClampedArray:return i/255;case Int32Array:return Math.max(i/2147483647,-1);case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("THREE.MathUtils: Invalid component type.")}}function Vt(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return Math.round(i*4294967295);case Uint16Array:return Math.round(i*65535);case Uint8Array:case Uint8ClampedArray:return Math.round(i*255);case Int32Array:return Math.round(i*2147483647);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("THREE.MathUtils: Invalid component type.")}}function H1(){let i={enabled:!0,workingColorSpace:Mn,spaces:{},convert:function(s,r,a){return this.enabled===!1||r===a||!r||!a||(this.spaces[r].transfer===Bt&&(s.r=Us(s.r),s.g=Us(s.g),s.b=Us(s.b)),this.spaces[r].primaries!==this.spaces[a].primaries&&(s.applyMatrix3(this.spaces[r].toXYZ),s.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===Bt&&(s.r=Ha(s.r),s.g=Ha(s.g),s.b=Ha(s.b))),s},workingToColorSpace:function(s,r){return this.convert(s,this.workingColorSpace,r)},colorSpaceToWorking:function(s,r){return this.convert(s,r,this.workingColorSpace)},getPrimaries:function(s){return this.spaces[s].primaries},getTransfer:function(s){return s===Qi?jo:this.spaces[s].transfer},getToneMappingMode:function(s){return this.spaces[s].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(s,r=this.workingColorSpace){return s.fromArray(this.spaces[r].luminanceCoefficients)},define:function(s){Object.assign(this.spaces,s)},_getMatrix:function(s,r,a){return s.copy(this.spaces[r].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(s){return this.spaces[s].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(s=this.workingColorSpace){return this.spaces[s].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(s,r){return $r("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),i.workingToColorSpace(s,r)},toWorkingColorSpace:function(s,r){return $r("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),i.colorSpaceToWorking(s,r)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return i.define({[Mn]:{primaries:e,whitePoint:n,transfer:jo,toXYZ:ab,fromXYZ:ob,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:Jt},outputColorSpaceConfig:{drawingBufferColorSpace:Jt}},[Jt]:{primaries:e,whitePoint:n,transfer:Bt,toXYZ:ab,fromXYZ:ob,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:Jt}}}),i}function Us(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function Ha(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}function md(i){return typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap?hh.getDataURL(i):i.data?{data:Array.from(i.data),width:i.width,height:i.height,type:i.data.constructor.name}:(tt("Texture: Unable to serialize Texture."),{})}function _d(i,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?i+(e-i)*6*t:t<1/2?e:t<2/3?i+(e-i)*6*(2/3-t):i}function Ad(i,e,t,n,s){for(let r=0,a=i.length-3;r<=a;r+=3){zr.fromArray(i,r);let o=s.x*Math.abs(zr.x)+s.y*Math.abs(zr.y)+s.z*Math.abs(zr.z),c=e.dot(zr),l=t.dot(zr),h=n.dot(zr);if(Math.max(-Math.max(c,l,h),Math.min(c,l,h))>o)return!1}return!0}function J1(){let i=new ArrayBuffer(4),e=new Float32Array(i),t=new Uint32Array(i),n=new Uint32Array(512),s=new Uint32Array(512);for(let c=0;c<256;++c){let l=c-127;l<-27?(n[c]=0,n[c|256]=32768,s[c]=24,s[c|256]=24):l<-14?(n[c]=1024>>-l-14,n[c|256]=1024>>-l-14|32768,s[c]=-l-1,s[c|256]=-l-1):l<=15?(n[c]=l+15<<10,n[c|256]=l+15<<10|32768,s[c]=13,s[c|256]=13):l<128?(n[c]=31744,n[c|256]=64512,s[c]=24,s[c|256]=24):(n[c]=31744,n[c|256]=64512,s[c]=13,s[c|256]=13)}let r=new Uint32Array(2048),a=new Uint32Array(64),o=new Uint32Array(64);for(let c=1;c<1024;++c){let l=c<<13,h=0;for(;(l&8388608)===0;)l<<=1,h-=8388608;l&=-8388609,h+=947912704,r[c]=l|h}for(let c=1024;c<2048;++c)r[c]=939524096+(c-1024<<13);for(let c=1;c<31;++c)a[c]=c<<23;a[31]=1199570944,a[32]=2147483648;for(let c=33;c<63;++c)a[c]=2147483648+(c-32<<23);a[63]=3347054592;for(let c=1;c<64;++c)c!==32&&(o[c]=1024);return{floatView:e,uint32View:t,baseTable:n,shiftTable:s,mantissaTable:r,exponentTable:a,offsetTable:o}}function Z1(i){Math.abs(i)>65504&&tt("DataUtils.toHalfFloat(): Value out of range."),i=yt(i,-65504,65504),ks.floatView[0]=i;let e=ks.uint32View[0],t=e>>23&511;return ks.baseTable[t]+((e&8388607)>>ks.shiftTable[t])}function Q1(i){let e=i>>10;return ks.uint32View[0]=ks.mantissaTable[ks.offsetTable[e]+(i&1023)]+ks.exponentTable[e],ks.floatView[0]}function aM(i,e,t,n,s,r,a,o){let c;if(e.side===Nn?c=n.intersectTriangle(a,r,s,!0,o):c=n.intersectTriangle(s,r,a,e.side===gs,o),c===null)return null;Wl.copy(o),Wl.applyMatrix4(i.matrixWorld);let l=t.ray.origin.distanceTo(Wl);return l<t.near||l>t.far?null:{distance:l,point:Wl.clone(),object:i}}function $l(i,e,t,n,s,r,a,o,c,l){i.getVertexPosition(o,zl),i.getVertexPosition(c,Hl),i.getVertexPosition(l,Vl);let h=aM(i,e,t,n,zl,Hl,Vl,_b);if(h){let u=new j;ar.getBarycoord(_b,zl,Hl,Vl,u),s&&(h.uv=ar.getInterpolatedAttribute(s,o,c,l,u,new dt)),r&&(h.uv1=ar.getInterpolatedAttribute(r,o,c,l,u,new dt)),a&&(h.normal=ar.getInterpolatedAttribute(a,o,c,l,u,new j),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));let d={a:o,b:c,c:l,normal:new j,materialIndex:0};ar.getNormal(zl,Hl,Vl,d.normal),h.face=d,h.barycoord=u}return h}function Yl(i,e,t,n,s,r,a){let o=i.geometry.attributes.position;if(dh.fromBufferAttribute(o,s),ph.fromBufferAttribute(o,r),t.distanceSqToSegment(dh,ph,Nd,Tb)>n)return;Nd.applyMatrix4(i.matrixWorld);let l=e.ray.origin.distanceTo(Nd);if(!(l<e.near||l>e.far))return{distance:l,point:Tb.clone().applyMatrix4(i.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:i}}function Pb(i,e,t,n,s,r,a){let o=Bd.distanceSqToPoint(i);if(o<t){let c=new j;Bd.closestPointToPoint(i,c),c.applyMatrix4(n);let l=s.ray.origin.distanceTo(c);if(l<s.near||l>s.far)return;r.push({distance:l,distanceToRay:Math.sqrt(o),point:c,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}function sa(i){let e={};for(let t in i){e[t]={};for(let n in i[t]){let s=i[t][n];if(Lb(s))s.isRenderTargetTexture?(tt("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][n]=null):e[t][n]=s.clone();else if(Array.isArray(s))if(Lb(s[0])){let r=[];for(let a=0,o=s.length;a<o;a++)r[a]=s[a].clone();e[t][n]=r}else e[t][n]=s.slice();else e[t][n]=s}}return e}function jn(i){let e={};for(let t=0;t<i.length;t++){let n=sa(i[t]);for(let s in n)e[s]=n[s]}return e}function Lb(i){return i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)}function uM(i){let e=[];for(let t=0;t<i.length;t++)e.push(i[t].clone());return e}function _p(i){let e=i.getRenderTarget();return e===null?i.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:gt.workingColorSpace}function $i(i,e){return!i||i.constructor===e?i:typeof e.BYTES_PER_ELEMENT=="number"?new e(i):Array.prototype.slice.call(i)}function $o(i){return i!==void 0&&i.inTangents!==void 0&&i.outTangents!==void 0}function R_(i){function e(s,r){return i[s]-i[r]}let t=i.length,n=new Array(t);for(let s=0;s!==t;++s)n[s]=s;return n.sort(e),n}function zd(i,e,t){let n=i.length,s=new i.constructor(n);for(let r=0,a=0;a!==n;++r){let o=t[r]*e;for(let c=0;c!==e;++c)s[a++]=i[o+c]}return s}function C_(i,e,t,n){let s=1,r=i[0];for(;r!==void 0&&r[n]===void 0;)r=i[s++];if(r===void 0)return;let a=r[n];if(a!==void 0)if(Array.isArray(a))do a=r[n],a!==void 0&&(e.push(r.time),t.push(...a)),r=i[s++];while(r!==void 0);else if(a.toArray!==void 0)do a=r[n],a!==void 0&&(e.push(r.time),a.toArray(t,t.length)),r=i[s++];while(r!==void 0);else do a=r[n],a!==void 0&&(e.push(r.time),t.push(a)),r=i[s++];while(r!==void 0)}function pM(i,e,t,n,s=30){let r=i.clone();r.name=e;let a=[];for(let c=0;c<r.tracks.length;++c){let l=r.tracks[c],h=l.getValueSize(),u=[],d=[];for(let p=0;p<l.times.length;++p){let b=l.times[p]*s;if(!(b<t||b>=n)){u.push(l.times[p]);for(let v=0;v<h;++v)d.push(l.values[p*h+v])}}u.length!==0&&(l.times=$i(u,l.times.constructor),l.values=$i(d,l.values.constructor),a.push(l))}r.tracks=a;let o=1/0;for(let c=0;c<r.tracks.length;++c)o>r.tracks[c].times[0]&&(o=r.tracks[c].times[0]);for(let c=0;c<r.tracks.length;++c)r.tracks[c].shift(-1*o);return r.resetDuration(),r}function mM(i,e=0,t=i,n=30){n<=0&&(n=30);let s=t.tracks.length,r=e/n;for(let a=0;a<s;++a){let o=t.tracks[a],c=o.ValueTypeName;if(c==="bool"||c==="string")continue;let l=i.tracks.find(function(g){return g.name===o.name&&g.ValueTypeName===c});if(l===void 0)continue;let h=0,u=o.getValueSize();o.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(h=u/3);let d=0,p=l.getValueSize();l.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(d=p/3);let b=o.times.length-1,v;if(r<=o.times[0]){let g=h,E=u-h;v=o.values.slice(g,E)}else if(r>=o.times[b]){let g=b*u+h,E=g+u-h;v=o.values.slice(g,E)}else{let g=o.createInterpolant(),E=h,L=u-h;g.evaluate(r),v=g.resultBuffer.slice(E,L)}c==="quaternion"&&new Ft().fromArray(v).normalize().conjugate().toArray(v);let _=l.times.length;for(let g=0;g<_;++g){let E=g*p+d;if(c==="quaternion")Ft.multiplyQuaternionsFlat(l.values,E,v,0,l.values,E);else{let L=p-d*2;for(let S=0;S<L;++S)l.values[E+S]-=v[S]}}}return i.blendMode=Ic,i}function I_(i,e,t,n,s){let r=1-i;return r*r*r*e+3*r*r*i*t+3*r*i*i*n+i*i*i*s}function gM(i,e,t,n,s){let r=1-i;return 3*r*r*(t-e)+6*r*i*(n-t)+3*i*i*(s-n)}function bM(i,e,t,n,s){let r=(i-e)/(s-e);for(let a=0;a<8;a++){let o=I_(r,e,t,n,s)-i;if(Math.abs(o)<1e-10)break;let c=gM(r,e,t,n,s);if(Math.abs(c)<1e-10)break;r=Math.max(0,Math.min(1,r-o/c))}return r}function Db(i,e){for(let t=0,n=i.length;t!==n;t+=2)i[t]*=e}function _M(i){switch(i.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Hs;case"vector":case"vector2":case"vector3":case"vector4":return br;case"color":return uc;case"quaternion":return Vs;case"bool":case"boolean":return zs;case"string":return Gs}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+i)}function xM(i){if(i.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");let e=_M(i.type);if(i.times===void 0){let n=[],s=[];C_(i.keys,n,s,"value"),i.times=n,i.values=s}let t;return e.parse!==void 0?t=e.parse(i):t=new e(i.name,i.times,i.values,i.interpolation),$o(i.settings)&&(t.settings={inTangents:$i(i.settings.inTangents,Float32Array),outTangents:$i(i.settings.outTangents,Float32Array)}),t}function Nb(i){try{let e=i.slice(i.indexOf(":")+1);return new URL(e).protocol==="blob:"}catch{return!1}}function zb(i,e){return i.distance-e.distance}function qd(i,e,t,n){let s=!0;if(i.layers.test(e.layers)&&i.raycast(e,t)===!1&&(s=!1),s===!0&&n===!0){let r=i.children;for(let a=0,o=r.length;a<o;a++)qd(r[a],e,t,!0)}}function vp(i,e,t,n){let s=CM(n);switch(t){case up:return i*e;case Uh:return i*e/s.components*s.byteLength;case Bh:return i*e/s.components*s.byteLength;case wr:return i*e*2/s.components*s.byteLength;case zh:return i*e*2/s.components*s.byteLength;case fp:return i*e*3/s.components*s.byteLength;case yi:return i*e*4/s.components*s.byteLength;case Hh:return i*e*4/s.components*s.byteLength;case wc:case Mc:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case Ec:case Ac:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case Gh:case $h:return Math.max(i,16)*Math.max(e,8)/4;case Vh:case Wh:return Math.max(i,8)*Math.max(e,8)/2;case qh:case jh:case Kh:case Yh:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case Xh:case Tc:case Jh:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case Zh:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case Qh:return Math.floor((i+4)/5)*Math.floor((e+3)/4)*16;case eu:return Math.floor((i+4)/5)*Math.floor((e+4)/5)*16;case tu:return Math.floor((i+5)/6)*Math.floor((e+4)/5)*16;case nu:return Math.floor((i+5)/6)*Math.floor((e+5)/6)*16;case iu:return Math.floor((i+7)/8)*Math.floor((e+4)/5)*16;case su:return Math.floor((i+7)/8)*Math.floor((e+5)/6)*16;case ru:return Math.floor((i+7)/8)*Math.floor((e+7)/8)*16;case au:return Math.floor((i+9)/10)*Math.floor((e+4)/5)*16;case ou:return Math.floor((i+9)/10)*Math.floor((e+5)/6)*16;case cu:return Math.floor((i+9)/10)*Math.floor((e+7)/8)*16;case lu:return Math.floor((i+9)/10)*Math.floor((e+9)/10)*16;case hu:return Math.floor((i+11)/12)*Math.floor((e+9)/10)*16;case uu:return Math.floor((i+11)/12)*Math.floor((e+11)/12)*16;case fu:case du:case pu:return Math.ceil(i/4)*Math.ceil(e/4)*16;case mu:case gu:return Math.ceil(i/4)*Math.ceil(e/4)*8;case Rc:case bu:return Math.ceil(i/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function CM(i){switch(i){case oi:case op:return{byteLength:1,components:1};case so:case cp:case Zn:return{byteLength:2,components:1};case Fh:case kh:return{byteLength:2,components:4};case Zi:case Oh:case qn:return{byteLength:4,components:1};case lp:case hp:return{byteLength:4,components:3}}throw new Error(`THREE.TextureUtils: Unknown texture type ${i}.`)}var Hb,Xd,Vb,yc,Gb,yr,gs,Nn,$n,bs,no,Kd,Yd,Jd,Wb,ta,$b,qb,jb,Xb,Kb,Yb,Jb,Zb,Zd,Qd,Qb,e_,t_,n_,i_,s_,r_,a_,o_,ih,sh,rh,Va,ah,oh,ch,lh,Ph,c_,l_,Ji,ep,tp,np,vc,ip,sp,rp,kd,h_,ap,vr,na,Lh,Dh,Sc,or,ii,Ga,dn,Nh,ia,qt,io,Di,oi,op,cp,so,Oh,Zi,qn,Zn,Fh,kh,ro,lp,hp,up,fp,yi,fs,Sr,Uh,Bh,wr,zh,Hh,wc,Mc,Ec,Ac,Vh,Gh,Wh,$h,qh,jh,Xh,Kh,Yh,Tc,Jh,Zh,Qh,eu,tu,nu,iu,su,ru,au,ou,cu,lu,hu,uu,fu,du,pu,mu,gu,Rc,bu,ao,Cc,u_,qr,jr,th,Ud,Gr,Wr,qo,_u,Ic,dp,Pc,oo,f_,Lc,d_,Qi,Jt,Mn,jo,Bt,nh,p_,m_,g_,b_,xu,__,x_,yu,y_,pp,mp,ji,Wa,ib,qa,E_,Ki,Hn,sb,Go,Xr,bp,Sp,dt,Ft,wp,j,dd,rb,Mp,ut,pd,ab,ob,gt,Ta,hh,V1,ja,G1,gd,En,Ep,Gt,uh,Gn,Ko,fh,Ih,ht,Ra,Hi,W1,$1,tr,Il,mi,cb,lb,ds,Xa,q1,hb,Ca,Ps,Pl,Oo,j1,X1,ub,fb,db,pb,K1,Ia,bd,Yt,vn,Y1,Ka,A_,nr,Ll,He,Vn,Yo,cr,Vi,Ls,xd,Ds,Pa,La,mb,yd,vd,Sd,wd,Md,Ed,ar,ln,Ns,Gi,Dl,Da,Na,Oa,ir,sr,Br,Fo,Nl,Ol,zr,ks,lr,yn,Fl,eM,Qt,Jo,Zo,sn,tM,ko,Td,si,nM,Ci,Rd,Fa,gi,Uo,Rn,pn,hr,Jn,ur,Cd,iM,sM,Wi,rM,Wn,Os,Id,kl,Ul,fr,Sn,gb,Hr,Bl,bb,zl,Hl,Vl,Pd,Gl,_b,Wl,vt,Bo,xb,yb,oM,vb,ql,Ld,Sb,Dd,Qo,Ya,dr,wb,cM,ec,Bs,ka,Mb,jl,Eb,lM,zo,Ho,Kr,Vr,hM,Xl,Ja,Yr,dh,ph,Ab,Vo,Kl,Nd,Tb,Jr,Rb,Cb,Za,tc,Qa,Ib,Bd,Jl,Zl,nc,ic,Zr,pr,mh,sc,mr,rc,Ii,gr,ac,T_,fM,dM,bi,gh,Pi,ri,oc,bh,_h,lc,ps,xh,hc,yh,vh,ai,zs,uc,Hs,Sh,Vs,Gs,br,Li,us,wh,P_,_i,Fs,Hd,ms,Ua,Mh,fc,dc,_r,eo,Od,Ob,Fb,to,Ql,eh,hs,pc,rr,kb,Ub,fn,Vd,mc,Gd,Qr,xr,Wd,Yi,Eh,gc,xi,Fd,bc,Ba,za,Ah,Th,Rh,xp,yM,yp,vM,SM,wM,MM,EM,AM,TM,$d,Ot,Ch,RM,ea,Bb,_c,Ap,jd,xc,Tp=un(()=>{Hb=0,Xd=1,Vb=2,yc=1,Gb=2,yr=3,gs=0,Nn=1,$n=2,bs=0,no=1,Kd=2,Yd=3,Jd=4,Wb=5,ta=100,$b=101,qb=102,jb=103,Xb=104,Kb=200,Yb=201,Jb=202,Zb=203,Zd=204,Qd=205,Qb=206,e_=207,t_=208,n_=209,i_=210,s_=211,r_=212,a_=213,o_=214,ih=0,sh=1,rh=2,Va=3,ah=4,oh=5,ch=6,lh=7,Ph=0,c_=1,l_=2,Ji=0,ep=1,tp=2,np=3,vc=4,ip=5,sp=6,rp=7,kd="attached",h_="detached",ap=300,vr=301,na=302,Lh=303,Dh=304,Sc=306,or=1e3,ii=1001,Ga=1002,dn=1003,Nh=1004,ia=1005,qt=1006,io=1007,Di=1008,oi=1009,op=1010,cp=1011,so=1012,Oh=1013,Zi=1014,qn=1015,Zn=1016,Fh=1017,kh=1018,ro=1020,lp=35902,hp=35899,up=1021,fp=1022,yi=1023,fs=1026,Sr=1027,Uh=1028,Bh=1029,wr=1030,zh=1031,Hh=1033,wc=33776,Mc=33777,Ec=33778,Ac=33779,Vh=35840,Gh=35841,Wh=35842,$h=35843,qh=36196,jh=37492,Xh=37496,Kh=37488,Yh=37489,Tc=37490,Jh=37491,Zh=37808,Qh=37809,eu=37810,tu=37811,nu=37812,iu=37813,su=37814,ru=37815,au=37816,ou=37817,cu=37818,lu=37819,hu=37820,uu=37821,fu=36492,du=36494,pu=36495,mu=36283,gu=36284,Rc=36285,bu=36286,ao=2200,Cc=2201,u_=2202,qr=2300,jr=2301,th=2302,Ud=2303,Gr=2400,Wr=2401,qo=2402,_u=2500,Ic=2501,dp=0,Pc=1,oo=2,f_=3200,Lc=0,d_=1,Qi="",Jt="srgb",Mn="srgb-linear",jo="linear",Bt="srgb",nh=7680,p_=519,m_=512,g_=513,b_=514,xu=515,__=516,x_=517,yu=518,y_=519,pp=35044,mp="300 es",ji=2e3,Wa=2001;ib={},qa=null;E_={[ih]:sh,[rh]:ch,[ah]:lh,[Va]:oh,[sh]:ih,[ch]:rh,[lh]:ah,[oh]:Va},Ki=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){let n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners;if(n===void 0)return;let s=n[e];if(s!==void 0){let r=s.indexOf(t);r!==-1&&s.splice(r,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let n=t[e.type];if(n!==void 0){e.target=this;let s=n.slice(0);for(let r=0,a=s.length;r<a;r++)s[r].call(this,e);e.target=null}}},Hn=["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"],sb=1234567,Go=Math.PI/180,Xr=180/Math.PI;bp={DEG2RAD:Go,RAD2DEG:Xr,generateUUID:Xi,clamp:yt,euclideanModulo:gp,mapLinear:E1,inverseLerp:A1,lerp:Wo,damp:T1,pingpong:R1,smoothstep:C1,smootherstep:I1,randInt:P1,randFloat:L1,randFloatSpread:D1,seededRandom:N1,degToRad:O1,radToDeg:F1,isPowerOfTwo:k1,ceilPowerOfTwo:U1,floorPowerOfTwo:B1,setQuaternionFromProperEuler:z1,normalize:Vt,denormalize:qi},Sp=class Sp{constructor(e=0,t=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("THREE.Vector2: 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("THREE.Vector2: 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){let t=this.x,n=this.y,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6],this.y=s[1]*t+s[4]*n+s[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=yt(this.x,e.x,t.x),this.y=yt(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=yt(this.x,e,t),this.y=yt(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(yt(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(yt(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let 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){let n=Math.cos(t),s=Math.sin(t),r=this.x-e.x,a=this.y-e.y;return this.x=r*n-a*s+e.x,this.y=r*s+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}};Sp.prototype.isVector2=!0;dt=Sp,Ft=class{constructor(e=0,t=0,n=0,s=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=s}static slerpFlat(e,t,n,s,r,a,o){let c=n[s+0],l=n[s+1],h=n[s+2],u=n[s+3],d=r[a+0],p=r[a+1],b=r[a+2],v=r[a+3];if(u!==v||c!==d||l!==p||h!==b){let _=c*d+l*p+h*b+u*v;_<0&&(d=-d,p=-p,b=-b,v=-v,_=-_);let g=1-o;if(_<.9995){let E=Math.acos(_),L=Math.sin(E);g=Math.sin(g*E)/L,o=Math.sin(o*E)/L,c=c*g+d*o,l=l*g+p*o,h=h*g+b*o,u=u*g+v*o}else{c=c*g+d*o,l=l*g+p*o,h=h*g+b*o,u=u*g+v*o;let E=1/Math.sqrt(c*c+l*l+h*h+u*u);c*=E,l*=E,h*=E,u*=E}}e[t]=c,e[t+1]=l,e[t+2]=h,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,s,r,a){let o=n[s],c=n[s+1],l=n[s+2],h=n[s+3],u=r[a],d=r[a+1],p=r[a+2],b=r[a+3];return e[t]=o*b+h*u+c*p-l*d,e[t+1]=c*b+h*d+l*u-o*p,e[t+2]=l*b+h*p+o*d-c*u,e[t+3]=h*b-o*u-c*d-l*p,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,s){return this._x=e,this._y=t,this._z=n,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let n=e._x,s=e._y,r=e._z,a=e._order,o=Math.cos,c=Math.sin,l=o(n/2),h=o(s/2),u=o(r/2),d=c(n/2),p=c(s/2),b=c(r/2);switch(a){case"XYZ":this._x=d*h*u+l*p*b,this._y=l*p*u-d*h*b,this._z=l*h*b+d*p*u,this._w=l*h*u-d*p*b;break;case"YXZ":this._x=d*h*u+l*p*b,this._y=l*p*u-d*h*b,this._z=l*h*b-d*p*u,this._w=l*h*u+d*p*b;break;case"ZXY":this._x=d*h*u-l*p*b,this._y=l*p*u+d*h*b,this._z=l*h*b+d*p*u,this._w=l*h*u-d*p*b;break;case"ZYX":this._x=d*h*u-l*p*b,this._y=l*p*u+d*h*b,this._z=l*h*b-d*p*u,this._w=l*h*u+d*p*b;break;case"YZX":this._x=d*h*u+l*p*b,this._y=l*p*u+d*h*b,this._z=l*h*b-d*p*u,this._w=l*h*u-d*p*b;break;case"XZY":this._x=d*h*u-l*p*b,this._y=l*p*u-d*h*b,this._z=l*h*b+d*p*u,this._w=l*h*u+d*p*b;break;default:tt("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,s=Math.sin(n);return this._x=e.x*s,this._y=e.y*s,this._z=e.z*s,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],s=t[4],r=t[8],a=t[1],o=t[5],c=t[9],l=t[2],h=t[6],u=t[10],d=n+o+u;if(d>0){let p=.5/Math.sqrt(d+1);this._w=.25/p,this._x=(h-c)*p,this._y=(r-l)*p,this._z=(a-s)*p}else if(n>o&&n>u){let p=2*Math.sqrt(1+n-o-u);this._w=(h-c)/p,this._x=.25*p,this._y=(s+a)/p,this._z=(r+l)/p}else if(o>u){let p=2*Math.sqrt(1+o-n-u);this._w=(r-l)/p,this._x=(s+a)/p,this._y=.25*p,this._z=(c+h)/p}else{let p=2*Math.sqrt(1+u-n-o);this._w=(a-s)/p,this._x=(r+l)/p,this._y=(c+h)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(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(yt(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let s=Math.min(1,t/n);return this.slerp(e,s),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let n=e._x,s=e._y,r=e._z,a=e._w,o=t._x,c=t._y,l=t._z,h=t._w;return this._x=n*h+a*o+s*l-r*c,this._y=s*h+a*c+r*o-n*l,this._z=r*h+a*l+n*c-s*o,this._w=a*h-n*o-s*c-r*l,this._onChangeCallback(),this}slerp(e,t){let n=e._x,s=e._y,r=e._z,a=e._w,o=this.dot(e);o<0&&(n=-n,s=-s,r=-r,a=-a,o=-o);let c=1-t;if(o<.9995){let l=Math.acos(o),h=Math.sin(l);c=Math.sin(c*l)/h,t=Math.sin(t*l)/h,this._x=this._x*c+n*t,this._y=this._y*c+s*t,this._z=this._z*c+r*t,this._w=this._w*c+a*t,this._onChangeCallback()}else this._x=this._x*c+n*t,this._y=this._y*c+s*t,this._z=this._z*c+r*t,this._w=this._w*c+a*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),s=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(s*Math.sin(e),s*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},wp=class wp{constructor(e=0,t=0,n=0){this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("THREE.Vector3: 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("THREE.Vector3: 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(rb.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(rb.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*s,this.y=r[1]*t+r[4]*n+r[7]*s,this.z=r[2]*t+r[5]*n+r[8]*s,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,s=this.z,r=e.elements,a=1/(r[3]*t+r[7]*n+r[11]*s+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*s+r[12])*a,this.y=(r[1]*t+r[5]*n+r[9]*s+r[13])*a,this.z=(r[2]*t+r[6]*n+r[10]*s+r[14])*a,this}applyQuaternion(e){let t=this.x,n=this.y,s=this.z,r=e.x,a=e.y,o=e.z,c=e.w,l=2*(a*s-o*n),h=2*(o*t-r*s),u=2*(r*n-a*t);return this.x=t+c*l+a*u-o*h,this.y=n+c*h+o*l-r*u,this.z=s+c*u+r*h-a*l,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*s,this.y=r[1]*t+r[5]*n+r[9]*s,this.z=r[2]*t+r[6]*n+r[10]*s,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=yt(this.x,e.x,t.x),this.y=yt(this.y,e.y,t.y),this.z=yt(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=yt(this.x,e,t),this.y=yt(this.y,e,t),this.z=yt(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(yt(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let n=e.x,s=e.y,r=e.z,a=t.x,o=t.y,c=t.z;return this.x=s*c-r*o,this.y=r*a-n*c,this.z=n*o-s*a,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return dd.copy(this).projectOnVector(e),this.sub(dd)}reflect(e){return this.sub(dd.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(yt(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,s=this.z-e.z;return t*t+n*n+s*s}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){let s=Math.sin(t)*e;return this.x=s*Math.sin(n),this.y=Math.cos(t)*e,this.z=s*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),s=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=s,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};wp.prototype.isVector3=!0;j=wp,dd=new j,rb=new Ft,Mp=class Mp{constructor(e,t,n,s,r,a,o,c,l){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,s,r,a,o,c,l)}set(e,t,n,s,r,a,o,c,l){let h=this.elements;return h[0]=e,h[1]=s,h[2]=o,h[3]=t,h[4]=r,h[5]=c,h[6]=n,h[7]=a,h[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let 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){let 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){let n=e.elements,s=t.elements,r=this.elements,a=n[0],o=n[3],c=n[6],l=n[1],h=n[4],u=n[7],d=n[2],p=n[5],b=n[8],v=s[0],_=s[3],g=s[6],E=s[1],L=s[4],S=s[7],M=s[2],A=s[5],I=s[8];return r[0]=a*v+o*E+c*M,r[3]=a*_+o*L+c*A,r[6]=a*g+o*S+c*I,r[1]=l*v+h*E+u*M,r[4]=l*_+h*L+u*A,r[7]=l*g+h*S+u*I,r[2]=d*v+p*E+b*M,r[5]=d*_+p*L+b*A,r[8]=d*g+p*S+b*I,this}multiplyScalar(e){let 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(){let e=this.elements,t=e[0],n=e[1],s=e[2],r=e[3],a=e[4],o=e[5],c=e[6],l=e[7],h=e[8];return t*a*h-t*o*l-n*r*h+n*o*c+s*r*l-s*a*c}invert(){let e=this.elements,t=e[0],n=e[1],s=e[2],r=e[3],a=e[4],o=e[5],c=e[6],l=e[7],h=e[8],u=h*a-o*l,d=o*c-h*r,p=l*r-a*c,b=t*u+n*d+s*p;if(b===0)return this.set(0,0,0,0,0,0,0,0,0);let v=1/b;return e[0]=u*v,e[1]=(s*l-h*n)*v,e[2]=(o*n-s*a)*v,e[3]=d*v,e[4]=(h*t-s*c)*v,e[5]=(s*r-o*t)*v,e[6]=p*v,e[7]=(n*c-l*t)*v,e[8]=(a*t-n*r)*v,this}transpose(){let e,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){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,s,r,a,o){let c=Math.cos(r),l=Math.sin(r);return this.set(n*c,n*l,-n*(c*a+l*o)+a+e,-s*l,s*c,-s*(-l*a+c*o)+o+t,0,0,1),this}scale(e,t){return $r("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(pd.makeScale(e,t)),this}rotate(e){return $r("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(pd.makeRotation(-e)),this}translate(e,t){return $r("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(pd.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,n=e.elements;for(let s=0;s<9;s++)if(t[s]!==n[s])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let 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)}};Mp.prototype.isMatrix3=!0;ut=Mp,pd=new ut,ab=new ut().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),ob=new ut().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);gt=H1();hh=class{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{Ta===void 0&&(Ta=$a("canvas")),Ta.width=e.width,Ta.height=e.height;let s=Ta.getContext("2d");e instanceof ImageData?s.putImageData(e,0,0):s.drawImage(e,0,0,e.width,e.height),n=Ta}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){let t=$a("canvas");t.width=e.width,t.height=e.height;let n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);let s=n.getImageData(0,0,e.width,e.height),r=s.data;for(let a=0;a<r.length;a++)r[a]=Us(r[a]/255)*255;return n.putImageData(s,0,0),t}else if(e.data){let t=e.data.slice(0);for(let n=0;n<t.length;n++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[n]=Math.floor(Us(t[n]/255)*255):t[n]=Us(t[n]);return{data:t,width:e.width,height:e.height}}else return tt("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},V1=0,ja=class{constructor(e=null){this.isTextureSource=!0,Object.defineProperty(this,"id",{value:V1++}),this.uuid=Xi(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){let t=this.data;return typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):typeof VideoFrame<"u"&&t instanceof VideoFrame?e.set(t.displayWidth,t.displayHeight,0):t!==null?e.set(t.width,t.height,t.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){let t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let n={uuid:this.uuid,url:""},s=this.data;if(s!==null){let r;if(Array.isArray(s)){r=[];for(let a=0,o=s.length;a<o;a++)s[a].isDataTexture?r.push(md(s[a].image)):r.push(md(s[a]))}else r=md(s);n.url=r}return t||(e.images[this.uuid]=n),n}};G1=0,gd=new j,En=class i extends Ki{constructor(e=i.DEFAULT_IMAGE,t=i.DEFAULT_MAPPING,n=ii,s=ii,r=qt,a=Di,o=yi,c=oi,l=i.DEFAULT_ANISOTROPY,h=Qi){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:G1++}),this.uuid=Xi(),this.name="",this.source=new ja(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=s,this.magFilter=r,this.minFilter=a,this.anisotropy=l,this.format=o,this.internalFormat=null,this.type=c,this.offset=new dt(0,0),this.repeat=new dt(1,1),this.center=new dt(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new ut,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(gd).x}get height(){return this.source.getSize(gd).y}get depth(){return this.source.getSize(gd).z}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)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(let t in e){let n=e[t];if(n===void 0){tt(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let s=this[t];if(s===void 0){tt(`Texture.setValues(): property '${t}' does not exist.`);continue}s&&n&&s.isVector2&&n.isVector2||s&&n&&s.isVector3&&n.isVector3||s&&n&&s.isMatrix3&&n.isMatrix3?s.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==ap)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case or:e.x=e.x-Math.floor(e.x);break;case ii:e.x=e.x<0?0:1;break;case Ga:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case or:e.y=e.y-Math.floor(e.y);break;case ii:e.y=e.y<0?0:1;break;case Ga:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}};En.DEFAULT_IMAGE=null;En.DEFAULT_MAPPING=ap;En.DEFAULT_ANISOTROPY=1;Ep=class Ep{constructor(e=0,t=0,n=0,s=1){this.x=e,this.y=t,this.z=n,this.w=s}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,s){return this.x=e,this.y=t,this.z=n,this.w=s,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("THREE.Vector4: 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("THREE.Vector4: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,s=this.z,r=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*s+a[12]*r,this.y=a[1]*t+a[5]*n+a[9]*s+a[13]*r,this.z=a[2]*t+a[6]*n+a[10]*s+a[14]*r,this.w=a[3]*t+a[7]*n+a[11]*s+a[15]*r,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,s,r,c=e.elements,l=c[0],h=c[4],u=c[8],d=c[1],p=c[5],b=c[9],v=c[2],_=c[6],g=c[10];if(Math.abs(h-d)<.01&&Math.abs(u-v)<.01&&Math.abs(b-_)<.01){if(Math.abs(h+d)<.1&&Math.abs(u+v)<.1&&Math.abs(b+_)<.1&&Math.abs(l+p+g-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;let L=(l+1)/2,S=(p+1)/2,M=(g+1)/2,A=(h+d)/4,I=(u+v)/4,y=(b+_)/4;return L>S&&L>M?L<.01?(n=0,s=.707106781,r=.707106781):(n=Math.sqrt(L),s=A/n,r=I/n):S>M?S<.01?(n=.707106781,s=0,r=.707106781):(s=Math.sqrt(S),n=A/s,r=y/s):M<.01?(n=.707106781,s=.707106781,r=0):(r=Math.sqrt(M),n=I/r,s=y/r),this.set(n,s,r,t),this}let E=Math.sqrt((_-b)*(_-b)+(u-v)*(u-v)+(d-h)*(d-h));return Math.abs(E)<.001&&(E=1),this.x=(_-b)/E,this.y=(u-v)/E,this.z=(d-h)/E,this.w=Math.acos((l+p+g-1)/2),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=yt(this.x,e.x,t.x),this.y=yt(this.y,e.y,t.y),this.z=yt(this.z,e.z,t.z),this.w=yt(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=yt(this.x,e,t),this.y=yt(this.y,e,t),this.z=yt(this.z,e,t),this.w=yt(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(yt(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}};Ep.prototype.isVector4=!0;Gt=Ep,uh=class extends Ki{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:qt,depthBuffer:!0,stencilBuffer:!1,resolveColorBuffer:!0,resolveDepthBuffer:!0,resolveStencilBuffer:!0,storeMultisampledColorBuffer:!0,storeMultisampledDepthBuffer:!0,storeMultisampledStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new Gt(0,0,e,t),this.scissorTest=!1,this.viewport=new Gt(0,0,e,t),this.textures=[];let s={width:e,height:t,depth:n.depth},r=new En(s),a=n.count;for(let o=0;o<a;o++)this.textures[o]=r.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveColorBuffer=n.resolveColorBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this.storeMultisampledColorBuffer=n.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=n.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=n.storeMultisampledStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview,this.useArrayDepthTexture=n.useArrayDepthTexture}_setTextureOptions(e={}){let t={minFilter:qt,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let n=0;n<this.textures.length;n++)this.textures[n].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&this._depthTexture.renderTarget===this&&(this._depthTexture.renderTarget=null),e!==null&&e.renderTarget===null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let s=0,r=this.textures.length;s<r;s++)this.textures[s].image.width=e,this.textures[s].image.height=t,this.textures[s].image.depth=n,this.textures[s].isData3DTexture!==!0&&(this.textures[s].isArrayTexture=this.textures[s].image.depth>1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;let s=Object.assign({},e.textures[t].image);this.textures[t].source=new ja(s)}if(this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveColorBuffer=e.resolveColorBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,this.storeMultisampledColorBuffer=e.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=e.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=e.storeMultisampledStencilBuffer,e.depthTexture!==null)if(e.depthTexture.renderTarget===e){let t=e.depthTexture.clone();t.renderTarget=null,this.depthTexture=t}else this.depthTexture=e.depthTexture;return this.samples=e.samples,this.multiview=e.multiview,this.useArrayDepthTexture=e.useArrayDepthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}},Gn=class extends uh{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}},Ko=class extends En{constructor(e=null,t=1,n=1,s=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:s},this.magFilter=dn,this.minFilter=dn,this.wrapR=ii,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},fh=class extends En{constructor(e=null,t=1,n=1,s=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:s},this.magFilter=dn,this.minFilter=dn,this.wrapR=ii,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}},Ih=class Ih{constructor(e,t,n,s,r,a,o,c,l,h,u,d,p,b,v,_){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,n,s,r,a,o,c,l,h,u,d,p,b,v,_)}set(e,t,n,s,r,a,o,c,l,h,u,d,p,b,v,_){let g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=s,g[1]=r,g[5]=a,g[9]=o,g[13]=c,g[2]=l,g[6]=h,g[10]=u,g[14]=d,g[3]=p,g[7]=b,g[11]=v,g[15]=_,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 Ih().fromArray(this.elements)}copy(e){let 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){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let 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 this.determinantAffine()===0?(e.set(1,0,0),t.set(0,1,0),n.set(0,0,1),this):(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){if(e.determinantAffine()===0)return this.identity();let t=this.elements,n=e.elements,s=1/Ra.setFromMatrixColumn(e,0).length(),r=1/Ra.setFromMatrixColumn(e,1).length(),a=1/Ra.setFromMatrixColumn(e,2).length();return t[0]=n[0]*s,t[1]=n[1]*s,t[2]=n[2]*s,t[3]=0,t[4]=n[4]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,n=e.x,s=e.y,r=e.z,a=Math.cos(n),o=Math.sin(n),c=Math.cos(s),l=Math.sin(s),h=Math.cos(r),u=Math.sin(r);if(e.order==="XYZ"){let d=a*h,p=a*u,b=o*h,v=o*u;t[0]=c*h,t[4]=-c*u,t[8]=l,t[1]=p+b*l,t[5]=d-v*l,t[9]=-o*c,t[2]=v-d*l,t[6]=b+p*l,t[10]=a*c}else if(e.order==="YXZ"){let d=c*h,p=c*u,b=l*h,v=l*u;t[0]=d+v*o,t[4]=b*o-p,t[8]=a*l,t[1]=a*u,t[5]=a*h,t[9]=-o,t[2]=p*o-b,t[6]=v+d*o,t[10]=a*c}else if(e.order==="ZXY"){let d=c*h,p=c*u,b=l*h,v=l*u;t[0]=d-v*o,t[4]=-a*u,t[8]=b+p*o,t[1]=p+b*o,t[5]=a*h,t[9]=v-d*o,t[2]=-a*l,t[6]=o,t[10]=a*c}else if(e.order==="ZYX"){let d=a*h,p=a*u,b=o*h,v=o*u;t[0]=c*h,t[4]=b*l-p,t[8]=d*l+v,t[1]=c*u,t[5]=v*l+d,t[9]=p*l-b,t[2]=-l,t[6]=o*c,t[10]=a*c}else if(e.order==="YZX"){let d=a*c,p=a*l,b=o*c,v=o*l;t[0]=c*h,t[4]=v-d*u,t[8]=b*u+p,t[1]=u,t[5]=a*h,t[9]=-o*h,t[2]=-l*h,t[6]=p*u+b,t[10]=d-v*u}else if(e.order==="XZY"){let d=a*c,p=a*l,b=o*c,v=o*l;t[0]=c*h,t[4]=-u,t[8]=l*h,t[1]=d*u+v,t[5]=a*h,t[9]=p*u-b,t[2]=b*u-p,t[6]=o*h,t[10]=v*u+d}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(W1,e,$1)}lookAt(e,t,n){let s=this.elements;return mi.subVectors(e,t),mi.lengthSq()===0&&(mi.z=1),mi.normalize(),tr.crossVectors(n,mi),tr.lengthSq()===0&&(Math.abs(n.z)===1?mi.x+=1e-4:mi.z+=1e-4,mi.normalize(),tr.crossVectors(n,mi)),tr.normalize(),Il.crossVectors(mi,tr),s[0]=tr.x,s[4]=Il.x,s[8]=mi.x,s[1]=tr.y,s[5]=Il.y,s[9]=mi.y,s[2]=tr.z,s[6]=Il.z,s[10]=mi.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,s=t.elements,r=this.elements,a=n[0],o=n[4],c=n[8],l=n[12],h=n[1],u=n[5],d=n[9],p=n[13],b=n[2],v=n[6],_=n[10],g=n[14],E=n[3],L=n[7],S=n[11],M=n[15],A=s[0],I=s[4],y=s[8],C=s[12],k=s[1],z=s[5],$=s[9],K=s[13],P=s[2],N=s[6],O=s[10],F=s[14],H=s[3],V=s[7],Q=s[11],te=s[15];return r[0]=a*A+o*k+c*P+l*H,r[4]=a*I+o*z+c*N+l*V,r[8]=a*y+o*$+c*O+l*Q,r[12]=a*C+o*K+c*F+l*te,r[1]=h*A+u*k+d*P+p*H,r[5]=h*I+u*z+d*N+p*V,r[9]=h*y+u*$+d*O+p*Q,r[13]=h*C+u*K+d*F+p*te,r[2]=b*A+v*k+_*P+g*H,r[6]=b*I+v*z+_*N+g*V,r[10]=b*y+v*$+_*O+g*Q,r[14]=b*C+v*K+_*F+g*te,r[3]=E*A+L*k+S*P+M*H,r[7]=E*I+L*z+S*N+M*V,r[11]=E*y+L*$+S*O+M*Q,r[15]=E*C+L*K+S*F+M*te,this}multiplyScalar(e){let 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(){let e=this.elements,t=e[0],n=e[4],s=e[8],r=e[12],a=e[1],o=e[5],c=e[9],l=e[13],h=e[2],u=e[6],d=e[10],p=e[14],b=e[3],v=e[7],_=e[11],g=e[15],E=c*p-l*d,L=o*p-l*u,S=o*d-c*u,M=a*p-l*h,A=a*d-c*h,I=a*u-o*h;return t*(v*E-_*L+g*S)-n*(b*E-_*M+g*A)+s*(b*L-v*M+g*I)-r*(b*S-v*A+_*I)}determinantAffine(){let e=this.elements,t=e[0],n=e[4],s=e[8],r=e[1],a=e[5],o=e[9],c=e[2],l=e[6],h=e[10];return t*(a*h-o*l)-n*(r*h-o*c)+s*(r*l-a*c)}transpose(){let e=this.elements,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){let s=this.elements;return e.isVector3?(s[12]=e.x,s[13]=e.y,s[14]=e.z):(s[12]=e,s[13]=t,s[14]=n),this}invert(){let e=this.elements,t=e[0],n=e[1],s=e[2],r=e[3],a=e[4],o=e[5],c=e[6],l=e[7],h=e[8],u=e[9],d=e[10],p=e[11],b=e[12],v=e[13],_=e[14],g=e[15],E=t*o-n*a,L=t*c-s*a,S=t*l-r*a,M=n*c-s*o,A=n*l-r*o,I=s*l-r*c,y=h*v-u*b,C=h*_-d*b,k=h*g-p*b,z=u*_-d*v,$=u*g-p*v,K=d*g-p*_,P=E*K-L*$+S*z+M*k-A*C+I*y;if(P===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let N=1/P;return e[0]=(o*K-c*$+l*z)*N,e[1]=(s*$-n*K-r*z)*N,e[2]=(v*I-_*A+g*M)*N,e[3]=(d*A-u*I-p*M)*N,e[4]=(c*k-a*K-l*C)*N,e[5]=(t*K-s*k+r*C)*N,e[6]=(_*S-b*I-g*L)*N,e[7]=(h*I-d*S+p*L)*N,e[8]=(a*$-o*k+l*y)*N,e[9]=(n*k-t*$-r*y)*N,e[10]=(b*A-v*S+g*E)*N,e[11]=(u*S-h*A-p*E)*N,e[12]=(o*C-a*z-c*y)*N,e[13]=(t*z-n*C+s*y)*N,e[14]=(v*L-b*M-_*E)*N,e[15]=(h*M-u*L+d*E)*N,this}scale(e){let t=this.elements,n=e.x,s=e.y,r=e.z;return t[0]*=n,t[4]*=s,t[8]*=r,t[1]*=n,t[5]*=s,t[9]*=r,t[2]*=n,t[6]*=s,t[10]*=r,t[3]*=n,t[7]*=s,t[11]*=r,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],s=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,s))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){let 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){let 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){let 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){let n=Math.cos(t),s=Math.sin(t),r=1-n,a=e.x,o=e.y,c=e.z,l=r*a,h=r*o;return this.set(l*a+n,l*o-s*c,l*c+s*o,0,l*o+s*c,h*o+n,h*c-s*a,0,l*c-s*o,h*c+s*a,r*c*c+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,s,r,a){return this.set(1,n,r,0,e,1,a,0,t,s,1,0,0,0,0,1),this}compose(e,t,n){let s=this.elements,r=t._x,a=t._y,o=t._z,c=t._w,l=r+r,h=a+a,u=o+o,d=r*l,p=r*h,b=r*u,v=a*h,_=a*u,g=o*u,E=c*l,L=c*h,S=c*u,M=n.x,A=n.y,I=n.z;return s[0]=(1-(v+g))*M,s[1]=(p+S)*M,s[2]=(b-L)*M,s[3]=0,s[4]=(p-S)*A,s[5]=(1-(d+g))*A,s[6]=(_+E)*A,s[7]=0,s[8]=(b+L)*I,s[9]=(_-E)*I,s[10]=(1-(d+v))*I,s[11]=0,s[12]=e.x,s[13]=e.y,s[14]=e.z,s[15]=1,this}decompose(e,t,n){let s=this.elements;e.x=s[12],e.y=s[13],e.z=s[14];let r=this.determinantAffine();if(r===0)return n.set(1,1,1),t.identity(),this;let a=Ra.set(s[0],s[1],s[2]).length(),o=Ra.set(s[4],s[5],s[6]).length(),c=Ra.set(s[8],s[9],s[10]).length();r<0&&(a=-a),Hi.copy(this);let l=1/a,h=1/o,u=1/c;return Hi.elements[0]*=l,Hi.elements[1]*=l,Hi.elements[2]*=l,Hi.elements[4]*=h,Hi.elements[5]*=h,Hi.elements[6]*=h,Hi.elements[8]*=u,Hi.elements[9]*=u,Hi.elements[10]*=u,t.setFromRotationMatrix(Hi),n.x=a,n.y=o,n.z=c,this}makePerspective(e,t,n,s,r,a,o=ji,c=!1){let l=this.elements,h=2*r/(t-e),u=2*r/(n-s),d=(t+e)/(t-e),p=(n+s)/(n-s),b,v;if(c)b=r/(a-r),v=a*r/(a-r);else if(o===ji)b=-(a+r)/(a-r),v=-2*a*r/(a-r);else if(o===Wa)b=-a/(a-r),v=-a*r/(a-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=h,l[4]=0,l[8]=d,l[12]=0,l[1]=0,l[5]=u,l[9]=p,l[13]=0,l[2]=0,l[6]=0,l[10]=b,l[14]=v,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,t,n,s,r,a,o=ji,c=!1){let l=this.elements,h=2/(t-e),u=2/(n-s),d=-(t+e)/(t-e),p=-(n+s)/(n-s),b,v;if(c)b=1/(a-r),v=a/(a-r);else if(o===ji)b=-2/(a-r),v=-(a+r)/(a-r);else if(o===Wa)b=-1/(a-r),v=-r/(a-r);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=h,l[4]=0,l[8]=0,l[12]=d,l[1]=0,l[5]=u,l[9]=0,l[13]=p,l[2]=0,l[6]=0,l[10]=b,l[14]=v,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let s=0;s<16;s++)if(t[s]!==n[s])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let 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}};Ih.prototype.isMatrix4=!0;ht=Ih,Ra=new j,Hi=new ht,W1=new j(0,0,0),$1=new j(1,1,1),tr=new j,Il=new j,mi=new j,cb=new ht,lb=new Ft,ds=class i{constructor(e=0,t=0,n=0,s=i.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=s}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,s=this._order){return this._x=e,this._y=t,this._z=n,this._order=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){let s=e.elements,r=s[0],a=s[4],o=s[8],c=s[1],l=s[5],h=s[9],u=s[2],d=s[6],p=s[10];switch(t){case"XYZ":this._y=Math.asin(yt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,p),this._z=Math.atan2(-a,r)):(this._x=Math.atan2(d,l),this._z=0);break;case"YXZ":this._x=Math.asin(-yt(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,p),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-u,r),this._z=0);break;case"ZXY":this._x=Math.asin(yt(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,p),this._z=Math.atan2(-a,l)):(this._y=0,this._z=Math.atan2(c,r));break;case"ZYX":this._y=Math.asin(-yt(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,p),this._z=Math.atan2(c,r)):(this._x=0,this._z=Math.atan2(-a,l));break;case"YZX":this._z=Math.asin(yt(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-h,l),this._y=Math.atan2(-u,r)):(this._x=0,this._y=Math.atan2(o,p));break;case"XZY":this._z=Math.asin(-yt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,l),this._y=Math.atan2(o,r)):(this._x=Math.atan2(-h,p),this._y=0);break;default:tt("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return cb.makeRotationFromQuaternion(e),this.setFromRotationMatrix(cb,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return lb.setFromEuler(this),this.setFromQuaternion(lb,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};ds.DEFAULT_ORDER="XYZ";Xa=class{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}},q1=0,hb=new j,Ca=new Ft,Ps=new ht,Pl=new j,Oo=new j,j1=new j,X1=new Ft,ub=new j(1,0,0),fb=new j(0,1,0),db=new j(0,0,1),pb={type:"added"},K1={type:"removed"},Ia={type:"childadded",child:null},bd={type:"childremoved",child:null},Yt=class i extends Ki{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:q1++}),this.uuid=Xi(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=i.DEFAULT_UP.clone();let e=new j,t=new ds,n=new Ft,s=new j(1,1,1);function r(){n.setFromEuler(t,!1)}function a(){t.setFromQuaternion(n,void 0,!1)}t._onChange(r),n._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:s},modelViewMatrix:{value:new ht},normalMatrix:{value:new ut}}),this.matrix=new ht,this.matrixWorld=new ht,this.matrixAutoUpdate=i.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=i.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Xa,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return Ca.setFromAxisAngle(e,t),this.quaternion.multiply(Ca),this}rotateOnWorldAxis(e,t){return Ca.setFromAxisAngle(e,t),this.quaternion.premultiply(Ca),this}rotateX(e){return this.rotateOnAxis(ub,e)}rotateY(e){return this.rotateOnAxis(fb,e)}rotateZ(e){return this.rotateOnAxis(db,e)}translateOnAxis(e,t){return hb.copy(e).applyQuaternion(this.quaternion),this.position.add(hb.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(ub,e)}translateY(e){return this.translateOnAxis(fb,e)}translateZ(e){return this.translateOnAxis(db,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Ps.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?Pl.copy(e):Pl.set(e,t,n);let s=this.parent;this.updateWorldMatrix(!0,!1),Oo.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Ps.lookAt(Oo,Pl,this.up):Ps.lookAt(Pl,Oo,this.up),this.quaternion.setFromRotationMatrix(Ps),s&&(Ps.extractRotation(s.matrixWorld),Ca.setFromRotationMatrix(Ps),this.quaternion.premultiply(Ca.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(st("Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(pb),Ia.child=e,this.dispatchEvent(Ia),Ia.child=null):st("Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}let t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(K1),bd.child=e,this.dispatchEvent(bd),bd.child=null),this}removeFromParent(){let e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),Ps.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Ps.multiply(e.parent.matrixWorld)),e.applyMatrix4(Ps),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(pb),Ia.child=e,this.dispatchEvent(Ia),Ia.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,s=this.children.length;n<s;n++){let a=this.children[n].getObjectByProperty(e,t);if(a!==void 0)return a}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);let s=this.children;for(let r=0,a=s.length;r<a;r++)s[r].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Oo,e,j1),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Oo,X1,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}intersectsFrustum(){}traverse(e){e(this);let t=this.children;for(let n=0,s=t.length;n<s;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let n=0,s=t.length;n<s;n++)t[n].traverseVisible(e)}traverseAncestors(e){let t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);let e=this.pivot;if(e!==null){let t=e.x,n=e.y,s=e.z,r=this.matrix.elements;r[12]+=t-r[0]*t-r[4]*n-r[8]*s,r[13]+=n-r[1]*t-r[5]*n-r[9]*s,r[14]+=s-r[2]*t-r[6]*n-r[10]*s}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);let t=this.children;for(let n=0,s=t.length;n<s;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t,n=!1){let s=this.parent;if(e===!0&&s!==null&&s.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||n)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,n=!0),t===!0){let r=this.children;for(let a=0,o=r.length;a<o;a++)r[a].updateWorldMatrix(!1,!0,n)}}toJSON(e){let t=e===void 0||typeof e=="string",n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});let s={};s.uuid=this.uuid,s.type=this.type,s.name=this.name,s.castShadow=this.castShadow,s.receiveShadow=this.receiveShadow,s.visible=this.visible,s.frustumCulled=this.frustumCulled,s.renderOrder=this.renderOrder,s.static=this.static,s.matrixAutoUpdate=this.matrixAutoUpdate,Object.keys(this.userData).length>0&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),s.up=this.up.toArray(),this.pivot!==null&&(s.pivot=this.pivot.toArray()),this.morphTargetDictionary!==void 0&&(s.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(s.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(s.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(s.type="BatchedMesh",s.perObjectFrustumCulled=this.perObjectFrustumCulled,s.sortObjects=this.sortObjects,s.drawRanges=this._drawRanges,s.reservedRanges=this._reservedRanges,s.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),s.instanceInfo=this._instanceInfo.map(o=>({...o})),s.availableInstanceIds=this._availableInstanceIds.slice(),s.availableGeometryIds=this._availableGeometryIds.slice(),s.nextIndexStart=this._nextIndexStart,s.nextVertexStart=this._nextVertexStart,s.geometryCount=this._geometryCount,s.maxInstanceCount=this._maxInstanceCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.matricesTexture=this._matricesTexture.toJSON(e),s.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(s.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(s.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(s.boundingBox=this.boundingBox.toJSON()));function r(o,c){return o[c.uuid]===void 0&&(o[c.uuid]=c.toJSON(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=r(e.geometries,this.geometry);let o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){let c=o.shapes;if(Array.isArray(c))for(let l=0,h=c.length;l<h;l++){let u=c[l];r(e.shapes,u)}else r(e.shapes,c)}}if(this.isSkinnedMesh&&(s.bindMode=this.bindMode,s.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(r(e.skeletons,this.skeleton),s.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let o=[];for(let c=0,l=this.material.length;c<l;c++)o.push(r(e.materials,this.material[c]));s.material=o}else s.material=r(e.materials,this.material);if(this.children.length>0){s.children=[];for(let o=0;o<this.children.length;o++)s.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){s.animations=[];for(let o=0;o<this.animations.length;o++){let c=this.animations[o];s.animations.push(r(e.animations,c))}}if(t){let o=a(e.geometries),c=a(e.materials),l=a(e.textures),h=a(e.images),u=a(e.shapes),d=a(e.skeletons),p=a(e.animations),b=a(e.nodes);o.length>0&&(n.geometries=o),c.length>0&&(n.materials=c),l.length>0&&(n.textures=l),h.length>0&&(n.images=h),u.length>0&&(n.shapes=u),d.length>0&&(n.skeletons=d),p.length>0&&(n.animations=p),b.length>0&&(n.nodes=b)}return n.object=s,n;function a(o){let c=[];for(let l in o){let h=o[l];delete h.metadata,c.push(h)}return c}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot!==null?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){let s=e.children[n];this.add(s.clone())}return this}dispose(){this.dispatchEvent({type:"dispose"})}};Yt.DEFAULT_UP=new j(0,1,0);Yt.DEFAULT_MATRIX_AUTO_UPDATE=!0;Yt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;vn=class extends Yt{constructor(){super(),this.isGroup=!0,this.type="Group"}},Y1={type:"move"},Ka=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new vn,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new vn,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new j,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new j),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new vn,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new j,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new j,this._grip.eventsEnabled=!1),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let s=null,r=null,a=null,o=this._targetRay,c=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){a=!0;for(let v of e.hand.values()){let _=t.getJointPose(v,n),g=this._getHandJoint(l,v);_!==null&&(g.matrix.fromArray(_.transform.matrix),g.matrix.decompose(g.position,g.rotation,g.scale),g.matrixWorldNeedsUpdate=!0,g.jointRadius=_.radius),g.visible=_!==null}let h=l.joints["index-finger-tip"],u=l.joints["thumb-tip"],d=h.position.distanceTo(u.position),p=.02,b=.005;l.inputState.pinching&&d>p+b?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&d<=p-b&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(r=t.getPose(e.gripSpace,n),r!==null&&(c.matrix.fromArray(r.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,r.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(r.linearVelocity)):c.hasLinearVelocity=!1,r.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(r.angularVelocity)):c.hasAngularVelocity=!1,c.eventsEnabled&&c.dispatchEvent({type:"gripUpdated",data:e,target:this})));o!==null&&(s=t.getPose(e.targetRaySpace,n),s===null&&r!==null&&(s=r),s!==null&&(o.matrix.fromArray(s.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,s.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(s.linearVelocity)):o.hasLinearVelocity=!1,s.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(s.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(Y1)))}return o!==null&&(o.visible=s!==null),c!==null&&(c.visible=r!==null),l!==null&&(l.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let n=new vn;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}},A_={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},nr={h:0,s:0,l:0},Ll={h:0,s:0,l:0};He=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let s=e;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Jt){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,gt.colorSpaceToWorking(this,t),this}setRGB(e,t,n,s=gt.workingColorSpace){return this.r=e,this.g=t,this.b=n,gt.colorSpaceToWorking(this,s),this}setHSL(e,t,n,s=gt.workingColorSpace){if(e=gp(e,1),t=yt(t,0,1),n=yt(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+t):n+t-n*t,a=2*n-r;this.r=_d(a,r,e+1/3),this.g=_d(a,r,e),this.b=_d(a,r,e-1/3)}return gt.colorSpaceToWorking(this,s),this}setStyle(e,t=Jt){function n(r){r!==void 0&&parseFloat(r)<1&&tt("Color: Alpha component of "+e+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(e)){let r,a=s[1],o=s[2];switch(a){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:tt("Color: Unknown color model "+e)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(e)){let r=s[1],a=r.length;if(a===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(r,16),t);tt("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Jt){let n=A_[e.toLowerCase()];return n!==void 0?this.setHex(n,t):tt("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=Us(e.r),this.g=Us(e.g),this.b=Us(e.b),this}copyLinearToSRGB(e){return this.r=Ha(e.r),this.g=Ha(e.g),this.b=Ha(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Jt){return gt.workingToColorSpace(Vn.copy(this),e),Math.round(yt(Vn.r*255,0,255))*65536+Math.round(yt(Vn.g*255,0,255))*256+Math.round(yt(Vn.b*255,0,255))}getHexString(e=Jt){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=gt.workingColorSpace){gt.workingToColorSpace(Vn.copy(this),t);let n=Vn.r,s=Vn.g,r=Vn.b,a=Math.max(n,s,r),o=Math.min(n,s,r),c,l,h=(o+a)/2;if(o===a)c=0,l=0;else{let u=a-o;switch(l=h<=.5?u/(a+o):u/(2-a-o),a){case n:c=(s-r)/u+(s<r?6:0);break;case s:c=(r-n)/u+2;break;case r:c=(n-s)/u+4;break}c/=6}return e.h=c,e.s=l,e.l=h,e}getRGB(e,t=gt.workingColorSpace){return gt.workingToColorSpace(Vn.copy(this),t),e.r=Vn.r,e.g=Vn.g,e.b=Vn.b,e}getStyle(e=Jt){gt.workingToColorSpace(Vn.copy(this),e);let t=Vn.r,n=Vn.g,s=Vn.b;return e!==Jt?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${s.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(s*255)})`}offsetHSL(e,t,n){return this.getHSL(nr),this.setHSL(nr.h+e,nr.s+t,nr.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(nr),e.getHSL(Ll);let n=Wo(nr.h,Ll.h,t),s=Wo(nr.s,Ll.s,t),r=Wo(nr.l,Ll.l,t);return this.setHSL(n,s,r),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,n=this.g,s=this.b,r=e.elements;return this.r=r[0]*t+r[3]*n+r[6]*s,this.g=r[1]*t+r[4]*n+r[7]*s,this.b=r[2]*t+r[5]*n+r[8]*s,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}},Vn=new He;He.NAMES=A_;Yo=class i{constructor(e,t=1,n=1e3){this.isFog=!0,this.name="",this.color=new He(e),this.near=t,this.far=n}clone(){return new i(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}},cr=class extends Yt{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new ds,this.environmentIntensity=1,this.environmentRotation=new ds,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),t.object.backgroundBlurriness=this.backgroundBlurriness,t.object.backgroundIntensity=this.backgroundIntensity,t.object.backgroundRotation=this.backgroundRotation.toArray(),t.object.environmentIntensity=this.environmentIntensity,t.object.environmentRotation=this.environmentRotation.toArray(),t}},Vi=new j,Ls=new j,xd=new j,Ds=new j,Pa=new j,La=new j,mb=new j,yd=new j,vd=new j,Sd=new j,wd=new Gt,Md=new Gt,Ed=new Gt,ar=class i{constructor(e=new j,t=new j,n=new j){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,s){s.subVectors(n,t),Vi.subVectors(e,t),s.cross(Vi);let r=s.lengthSq();return r>0?s.multiplyScalar(1/Math.sqrt(r)):s.set(0,0,0)}static getBarycoord(e,t,n,s,r){Vi.subVectors(s,t),Ls.subVectors(n,t),xd.subVectors(e,t);let a=Vi.dot(Vi),o=Vi.dot(Ls),c=Vi.dot(xd),l=Ls.dot(Ls),h=Ls.dot(xd),u=a*l-o*o;if(u===0)return r.set(0,0,0),null;let d=1/u,p=(l*c-o*h)*d,b=(a*h-o*c)*d;return r.set(1-p-b,b,p)}static containsPoint(e,t,n,s){return this.getBarycoord(e,t,n,s,Ds)===null?!1:Ds.x>=0&&Ds.y>=0&&Ds.x+Ds.y<=1}static getInterpolation(e,t,n,s,r,a,o,c){return this.getBarycoord(e,t,n,s,Ds)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(r,Ds.x),c.addScaledVector(a,Ds.y),c.addScaledVector(o,Ds.z),c)}static getInterpolatedAttribute(e,t,n,s,r,a){return wd.setScalar(0),Md.setScalar(0),Ed.setScalar(0),wd.fromBufferAttribute(e,t),Md.fromBufferAttribute(e,n),Ed.fromBufferAttribute(e,s),a.setScalar(0),a.addScaledVector(wd,r.x),a.addScaledVector(Md,r.y),a.addScaledVector(Ed,r.z),a}static isFrontFacing(e,t,n,s){return Vi.subVectors(n,t),Ls.subVectors(e,t),Vi.cross(Ls).dot(s)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,s){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[s]),this}setFromAttributeAndIndices(e,t,n,s){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,s),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Vi.subVectors(this.c,this.b),Ls.subVectors(this.a,this.b),Vi.cross(Ls).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return i.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return i.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,s,r){return i.getInterpolation(e,this.a,this.b,this.c,t,n,s,r)}containsPoint(e){return i.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return i.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,s=this.b,r=this.c,a,o;Pa.subVectors(s,n),La.subVectors(r,n),yd.subVectors(e,n);let c=Pa.dot(yd),l=La.dot(yd);if(c<=0&&l<=0)return t.copy(n);vd.subVectors(e,s);let h=Pa.dot(vd),u=La.dot(vd);if(h>=0&&u<=h)return t.copy(s);let d=c*u-h*l;if(d<=0&&c>=0&&h<=0)return a=c/(c-h),t.copy(n).addScaledVector(Pa,a);Sd.subVectors(e,r);let p=Pa.dot(Sd),b=La.dot(Sd);if(b>=0&&p<=b)return t.copy(r);let v=p*l-c*b;if(v<=0&&l>=0&&b<=0)return o=l/(l-b),t.copy(n).addScaledVector(La,o);let _=h*b-p*u;if(_<=0&&u-h>=0&&p-b>=0)return mb.subVectors(r,s),o=(u-h)/(u-h+(p-b)),t.copy(s).addScaledVector(mb,o);let g=1/(_+v+d);return a=v*g,o=d*g,t.copy(n).addScaledVector(Pa,a).addScaledVector(La,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},ln=class{constructor(e=new j(1/0,1/0,1/0),t=new j(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(Gi.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(Gi.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let n=Gi.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);let n=e.geometry;if(n!==void 0){let r=n.getAttribute("position");if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let a=0,o=r.count;a<o;a++)e.isMesh===!0?e.getVertexPosition(a,Gi):Gi.fromBufferAttribute(r,a),Gi.applyMatrix4(e.matrixWorld),this.expandByPoint(Gi);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Dl.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),Dl.copy(n.boundingBox)),Dl.applyMatrix4(e.matrixWorld),this.union(Dl)}let s=e.children;for(let r=0,a=s.length;r<a;r++)this.expandByObject(s[r],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Gi),Gi.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(Fo),Nl.subVectors(this.max,Fo),Da.subVectors(e.a,Fo),Na.subVectors(e.b,Fo),Oa.subVectors(e.c,Fo),ir.subVectors(Na,Da),sr.subVectors(Oa,Na),Br.subVectors(Da,Oa);let t=[0,-ir.z,ir.y,0,-sr.z,sr.y,0,-Br.z,Br.y,ir.z,0,-ir.x,sr.z,0,-sr.x,Br.z,0,-Br.x,-ir.y,ir.x,0,-sr.y,sr.x,0,-Br.y,Br.x,0];return!Ad(t,Da,Na,Oa,Nl)||(t=[1,0,0,0,1,0,0,0,1],!Ad(t,Da,Na,Oa,Nl))?!1:(Ol.crossVectors(ir,sr),t=[Ol.x,Ol.y,Ol.z],Ad(t,Da,Na,Oa,Nl))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Gi).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Gi).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(Ns[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Ns[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Ns[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Ns[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Ns[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Ns[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Ns[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Ns[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Ns),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)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}},Ns=[new j,new j,new j,new j,new j,new j,new j,new j],Gi=new j,Dl=new ln,Da=new j,Na=new j,Oa=new j,ir=new j,sr=new j,Br=new j,Fo=new j,Nl=new j,Ol=new j,zr=new j;ks=J1();lr=class{static toHalfFloat(e){return Z1(e)}static fromHalfFloat(e){return Q1(e)}},yn=new j,Fl=new dt,eM=0,Qt=class extends Ki{constructor(e,t,n=!1){if(super(),Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:eM++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=pp,this.updateRanges=[],this.gpuType=qn,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let s=0,r=this.itemSize;s<r;s++)this.array[e+s]=t.array[n+s];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)Fl.fromBufferAttribute(this,t),Fl.applyMatrix3(e),this.setXY(t,Fl.x,Fl.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)yn.fromBufferAttribute(this,t),yn.applyMatrix3(e),this.setXYZ(t,yn.x,yn.y,yn.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)yn.fromBufferAttribute(this,t),yn.applyMatrix4(e),this.setXYZ(t,yn.x,yn.y,yn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)yn.fromBufferAttribute(this,t),yn.applyNormalMatrix(e),this.setXYZ(t,yn.x,yn.y,yn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)yn.fromBufferAttribute(this,t),yn.transformDirection(e),this.setXYZ(t,yn.x,yn.y,yn.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=qi(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=Vt(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=qi(t,this.array)),t}setX(e,t){return this.normalized&&(t=Vt(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=qi(t,this.array)),t}setY(e,t){return this.normalized&&(t=Vt(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=qi(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Vt(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=qi(t,this.array)),t}setW(e,t){return this.normalized&&(t=Vt(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=Vt(t,this.array),n=Vt(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,s){return e*=this.itemSize,this.normalized&&(t=Vt(t,this.array),n=Vt(n,this.array),s=Vt(s,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=s,this}setXYZW(e,t,n,s,r){return e*=this.itemSize,this.normalized&&(t=Vt(t,this.array),n=Vt(n,this.array),s=Vt(s,this.array),r=Vt(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=s,this.array[e+3]=r,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return e.name=this.name,e.usage=this.usage,e.gpuType=this.gpuType,e}dispose(){this.dispatchEvent({type:"dispose"})}},Jo=class extends Qt{constructor(e,t,n){super(new Uint16Array(e),t,n)}},Zo=class extends Qt{constructor(e,t,n){super(new Uint32Array(e),t,n)}},sn=class extends Qt{constructor(e,t,n){super(new Float32Array(e),t,n)}},tM=new ln,ko=new j,Td=new j,si=class{constructor(e=new j,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let n=this.center;t!==void 0?n.copy(t):tM.setFromPoints(e).getCenter(n);let s=0;for(let r=0,a=e.length;r<a;r++)s=Math.max(s,n.distanceToSquared(e[r]));return this.radius=Math.sqrt(s),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){let 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){let n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;ko.subVectors(e,this.center);let t=ko.lengthSq();if(t>this.radius*this.radius){let n=Math.sqrt(t),s=(n-this.radius)*.5;this.center.addScaledVector(ko,s/n),this.radius+=s}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(Td.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(ko.copy(e.center).add(Td)),this.expandByPoint(ko.copy(e.center).sub(Td))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}},nM=0,Ci=new ht,Rd=new Yt,Fa=new j,gi=new ln,Uo=new ln,Rn=new j,pn=class i extends Ki{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:nM++}),this.uuid=Xi(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(M1(e)?Zo:Jo)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let r=new ut().getNormalMatrix(e);n.applyNormalMatrix(r),n.needsUpdate=!0}let s=this.attributes.tangent;return s!==void 0&&(s.transformDirection(e),s.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(e){return Ci.makeRotationFromQuaternion(e),this.applyMatrix4(Ci),this}rotateX(e){return Ci.makeRotationX(e),this.applyMatrix4(Ci),this}rotateY(e){return Ci.makeRotationY(e),this.applyMatrix4(Ci),this}rotateZ(e){return Ci.makeRotationZ(e),this.applyMatrix4(Ci),this}translate(e,t,n){return Ci.makeTranslation(e,t,n),this.applyMatrix4(Ci),this}scale(e,t,n){return Ci.makeScale(e,t,n),this.applyMatrix4(Ci),this}lookAt(e){return Rd.lookAt(e),Rd.updateMatrix(),this.applyMatrix4(Rd.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Fa).negate(),this.translate(Fa.x,Fa.y,Fa.z),this}setFromPoints(e){let t=this.getAttribute("position");if(t===void 0){let n=[];for(let s=0,r=e.length;s<r;s++){let a=e[s];n.push(a.x,a.y,a.z||0)}this.setAttribute("position",new sn(n,3))}else{let n=Math.min(e.length,t.count);for(let s=0;s<n;s++){let r=e[s];t.setXYZ(s,r.x,r.y,r.z||0)}e.length>t.count&&tt("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ln);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){st("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new j(-1/0,-1/0,-1/0),new j(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,s=t.length;n<s;n++){let r=t[n];gi.setFromBufferAttribute(r),this.morphTargetsRelative?(Rn.addVectors(this.boundingBox.min,gi.min),this.boundingBox.expandByPoint(Rn),Rn.addVectors(this.boundingBox.max,gi.max),this.boundingBox.expandByPoint(Rn)):(this.boundingBox.expandByPoint(gi.min),this.boundingBox.expandByPoint(gi.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&st('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new si);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){st("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new j,1/0);return}if(e){let n=this.boundingSphere.center;if(gi.setFromBufferAttribute(e),t)for(let r=0,a=t.length;r<a;r++){let o=t[r];Uo.setFromBufferAttribute(o),this.morphTargetsRelative?(Rn.addVectors(gi.min,Uo.min),gi.expandByPoint(Rn),Rn.addVectors(gi.max,Uo.max),gi.expandByPoint(Rn)):(gi.expandByPoint(Uo.min),gi.expandByPoint(Uo.max))}gi.getCenter(n);let s=0;for(let r=0,a=e.count;r<a;r++)Rn.fromBufferAttribute(e,r),s=Math.max(s,n.distanceToSquared(Rn));if(t)for(let r=0,a=t.length;r<a;r++){let o=t[r],c=this.morphTargetsRelative;for(let l=0,h=o.count;l<h;l++)Rn.fromBufferAttribute(o,l),c&&(Fa.fromBufferAttribute(e,l),Rn.add(Fa)),s=Math.max(s,n.distanceToSquared(Rn))}this.boundingSphere.radius=Math.sqrt(s),isNaN(this.boundingSphere.radius)&&st('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){let e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){st("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let n=t.position,s=t.normal,r=t.uv,a=this.getAttribute("tangent");(a===void 0||a.count!==n.count)&&(a=new Qt(new Float32Array(4*n.count),4),this.setAttribute("tangent",a));let o=[],c=[];for(let y=0;y<n.count;y++)o[y]=new j,c[y]=new j;let l=new j,h=new j,u=new j,d=new dt,p=new dt,b=new dt,v=new j,_=new j;function g(y,C,k){l.fromBufferAttribute(n,y),h.fromBufferAttribute(n,C),u.fromBufferAttribute(n,k),d.fromBufferAttribute(r,y),p.fromBufferAttribute(r,C),b.fromBufferAttribute(r,k),h.sub(l),u.sub(l),p.sub(d),b.sub(d);let z=1/(p.x*b.y-b.x*p.y);isFinite(z)&&(v.copy(h).multiplyScalar(b.y).addScaledVector(u,-p.y).multiplyScalar(z),_.copy(u).multiplyScalar(p.x).addScaledVector(h,-b.x).multiplyScalar(z),o[y].add(v),o[C].add(v),o[k].add(v),c[y].add(_),c[C].add(_),c[k].add(_))}let E=this.groups;E.length===0&&(E=[{start:0,count:e.count}]);for(let y=0,C=E.length;y<C;++y){let k=E[y],z=k.start,$=k.count;for(let K=z,P=z+$;K<P;K+=3)g(e.getX(K+0),e.getX(K+1),e.getX(K+2))}let L=new j,S=new j,M=new j,A=new j;function I(y){M.fromBufferAttribute(s,y),A.copy(M);let C=o[y];L.copy(C),L.sub(M.multiplyScalar(M.dot(C))).normalize(),S.crossVectors(A,C);let z=S.dot(c[y])<0?-1:1;a.setXYZW(y,L.x,L.y,L.z,z)}for(let y=0,C=E.length;y<C;++y){let k=E[y],z=k.start,$=k.count;for(let K=z,P=z+$;K<P;K+=3)I(e.getX(K+0)),I(e.getX(K+1)),I(e.getX(K+2))}this._transformed=!0}computeVertexNormals(){let e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0||n.count!==t.count)n=new Qt(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let d=0,p=n.count;d<p;d++)n.setXYZ(d,0,0,0);let s=new j,r=new j,a=new j,o=new j,c=new j,l=new j,h=new j,u=new j;if(e)for(let d=0,p=e.count;d<p;d+=3){let b=e.getX(d+0),v=e.getX(d+1),_=e.getX(d+2);s.fromBufferAttribute(t,b),r.fromBufferAttribute(t,v),a.fromBufferAttribute(t,_),h.subVectors(a,r),u.subVectors(s,r),h.cross(u),o.fromBufferAttribute(n,b),c.fromBufferAttribute(n,v),l.fromBufferAttribute(n,_),o.add(h),c.add(h),l.add(h),n.setXYZ(b,o.x,o.y,o.z),n.setXYZ(v,c.x,c.y,c.z),n.setXYZ(_,l.x,l.y,l.z)}else for(let d=0,p=t.count;d<p;d+=3)s.fromBufferAttribute(t,d+0),r.fromBufferAttribute(t,d+1),a.fromBufferAttribute(t,d+2),h.subVectors(a,r),u.subVectors(s,r),h.cross(u),n.setXYZ(d+0,h.x,h.y,h.z),n.setXYZ(d+1,h.x,h.y,h.z),n.setXYZ(d+2,h.x,h.y,h.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)Rn.fromBufferAttribute(e,t),Rn.normalize(),e.setXYZ(t,Rn.x,Rn.y,Rn.z)}toNonIndexed(){function e(o,c){let l=o.array,h=o.itemSize,u=o.normalized,d=new l.constructor(c.length*h),p=0,b=0;for(let v=0,_=c.length;v<_;v++){o.isInterleavedBufferAttribute?p=c[v]*o.data.stride+o.offset:p=c[v]*h;for(let g=0;g<h;g++)d[b++]=l[p++]}return new Qt(d,h,u)}if(this.index===null)return tt("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new i,n=this.index.array,s=this.attributes;for(let o in s){let c=s[o],l=e(c,n);t.setAttribute(o,l)}let r=this.morphAttributes;for(let o in r){let c=[],l=r[o];for(let h=0,u=l.length;h<u;h++){let d=l[h],p=e(d,n);c.push(p)}t.morphAttributes[o]=c}t.morphTargetsRelative=this.morphTargetsRelative;let a=this.groups;for(let o=0,c=a.length;o<c;o++){let l=a[o];t.addGroup(l.start,l.count,l.materialIndex)}return t}toJSON(){let e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.parameters!==void 0&&this._transformed===!0?"BufferGeometry":this.type,e.name=this.name,Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){let c=this.parameters;for(let l in c)c[l]!==void 0&&(e[l]=c[l]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let n=this.attributes;for(let c in n){let l=n[c];e.data.attributes[c]=l.toJSON(e.data)}let s={},r=!1;for(let c in this.morphAttributes){let l=this.morphAttributes[c],h=[];for(let u=0,d=l.length;u<d;u++){let p=l[u];h.push(p.toJSON(e.data))}h.length>0&&(s[c]=h,r=!0)}r&&(e.data.morphAttributes=s,e.data.morphTargetsRelative=this.morphTargetsRelative);let a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));let o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),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;let t={};this.name=e.name;let n=e.index;n!==null&&this.setIndex(n.clone());let s=e.attributes;for(let l in s){let h=s[l];this.setAttribute(l,h.clone(t))}let r=e.morphAttributes;for(let l in r){let h=[],u=r[l];for(let d=0,p=u.length;d<p;d++)h.push(u[d].clone(t));this.morphAttributes[l]=h}this.morphTargetsRelative=e.morphTargetsRelative;let a=e.groups;for(let l=0,h=a.length;l<h;l++){let u=a[l];this.addGroup(u.start,u.count,u.materialIndex)}let o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());let c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this._transformed=e._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}},hr=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=pp,this.updateRanges=[],this.version=0,this.uuid=Xi()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let s=0,r=this.stride;s<r;s++)this.array[e+s]=t.array[n+s];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Xi()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let 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){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Xi()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer)));let t={uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride};return t.usage=this.usage,t}},Jn=new j,ur=class i{constructor(e,t,n,s=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=s}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)Jn.fromBufferAttribute(this,t),Jn.applyMatrix4(e),this.setXYZ(t,Jn.x,Jn.y,Jn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Jn.fromBufferAttribute(this,t),Jn.applyNormalMatrix(e),this.setXYZ(t,Jn.x,Jn.y,Jn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Jn.fromBufferAttribute(this,t),Jn.transformDirection(e),this.setXYZ(t,Jn.x,Jn.y,Jn.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=qi(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=Vt(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=Vt(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=Vt(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=Vt(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=Vt(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=qi(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=qi(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=qi(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=qi(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=Vt(t,this.array),n=Vt(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=Vt(t,this.array),n=Vt(n,this.array),s=Vt(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=s,this}setXYZW(e,t,n,s,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=Vt(t,this.array),n=Vt(n,this.array),s=Vt(s,this.array),r=Vt(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=s,this.data.array[e+3]=r,this}clone(e){if(e===void 0){Xo("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let n=0;n<this.count;n++){let s=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[s+r])}return new Qt(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new i(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){Xo("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let n=0;n<this.count;n++){let s=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[s+r])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}},Cd=new j,iM=new j,sM=new ut,Wi=class{constructor(e=new j(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,s){return this.normal.set(e,t,n),this.constant=s,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){let s=Cd.subVectors(n,t).cross(iM.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(s,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t,n=!0){let s=e.delta(Cd),r=this.normal.dot(s);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let a=-(e.start.dot(this.normal)+this.constant)/r;return n===!0&&(a<0||a>1)?null:t.copy(e.start).addScaledVector(s,a)}intersectsLine(e){let 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){let n=t||sM.getNormalMatrix(e),s=this.coplanarPoint(Cd).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-s.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}toJSON(){return{normal:this.normal.toArray(),constant:this.constant}}fromJSON(e){return this.normal.fromArray(e.normal),this.constant=e.constant,this}},rM=0,Wn=class extends Ki{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:rM++}),this.uuid=Xi(),this.name="",this.type="Material",this.blending=no,this.side=gs,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Zd,this.blendDst=Qd,this.blendEquation=ta,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new He(0,0,0),this.blendAlpha=0,this.depthFunc=Va,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=p_,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=nh,this.stencilZFail=nh,this.stencilZPass=nh,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(let t in e){let n=e[t];if(n===void 0){tt(`Material: parameter '${t}' has value of undefined.`);continue}let s=this[t];if(s===void 0){tt(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}s&&s.isColor?s.set(n):s&&s.isVector2&&n&&n.isVector2||s&&s.isEuler&&n&&n.isEuler||s&&s.isVector3&&n&&n.isVector3?s.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});let n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,n.blending=this.blending,n.side=this.side,n.shadowSide=this.shadowSide,n.vertexColors=this.vertexColors,n.opacity=this.opacity,n.transparent=this.transparent,n.blendSrc=this.blendSrc,n.blendDst=this.blendDst,n.blendEquation=this.blendEquation,n.blendSrcAlpha=this.blendSrcAlpha,n.blendDstAlpha=this.blendDstAlpha,n.blendEquationAlpha=this.blendEquationAlpha,n.blendColor=this.blendColor.getHex(),n.blendAlpha=this.blendAlpha,n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.clipIntersection=this.clipIntersection,n.clipShadows=this.clipShadows,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,n.stencilWrite=this.stencilWrite,n.polygonOffset=this.polygonOffset,n.polygonOffsetFactor=this.polygonOffsetFactor,n.polygonOffsetUnits=this.polygonOffsetUnits,n.dithering=this.dithering,n.alphaTest=this.alphaTest,n.alphaHash=this.alphaHash,n.alphaToCoverage=this.alphaToCoverage,n.premultipliedAlpha=this.premultipliedAlpha,n.forceSinglePass=this.forceSinglePass,n.allowOverride=this.allowOverride,n.visible=this.visible,n.toneMapped=this.toneMapped,n.name=this.name,this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.retroreflectivity!==void 0&&(n.retroreflectivity=this.retroreflectivity),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),Array.isArray(this.clippingPlanes)&&this.clippingPlanes.length>0&&(n.clippingPlanes=this.clippingPlanes.map(r=>r.toJSON())),this.rotation!==void 0&&(n.rotation=this.rotation),this.depthPacking!==void 0&&(n.depthPacking=this.depthPacking),this.linewidth!==void 0&&(n.linewidth=this.linewidth),this.linecap!==void 0&&(n.linecap=this.linecap),this.linejoin!==void 0&&(n.linejoin=this.linejoin),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.wireframe!==void 0&&(n.wireframe=this.wireframe),this.wireframeLinewidth!==void 0&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!==void 0&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!==void 0&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading!==void 0&&(n.flatShading=this.flatShading),this.fog!==void 0&&(n.fog=this.fog),Object.keys(this.userData).length>0&&(n.userData=this.userData);function s(r){let a=[];for(let o in r){let c=r[o];delete c.metadata,a.push(c)}return a}if(t){let r=s(e.textures),a=s(e.images);r.length>0&&(n.textures=r),a.length>0&&(n.images=a)}return n}fromJSON(e,t){if(e.uuid!==void 0&&(this.uuid=e.uuid),e.name!==void 0&&(this.name=e.name),e.color!==void 0&&this.color!==void 0&&this.color.setHex(e.color),e.roughness!==void 0&&(this.roughness=e.roughness),e.metalness!==void 0&&(this.metalness=e.metalness),e.sheen!==void 0&&(this.sheen=e.sheen),e.sheenColor!==void 0&&(this.sheenColor=new He().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(this.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&this.emissive!==void 0&&this.emissive.setHex(e.emissive),e.specular!==void 0&&this.specular!==void 0&&this.specular.setHex(e.specular),e.specularIntensity!==void 0&&(this.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&this.specularColor!==void 0&&this.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(this.shininess=e.shininess),e.clearcoat!==void 0&&(this.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(this.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(this.dispersion=e.dispersion),e.retroreflectivity!==void 0&&(this.retroreflectivity=e.retroreflectivity),e.iridescence!==void 0&&(this.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(this.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(this.transmission=e.transmission),e.thickness!==void 0&&(this.thickness=e.thickness),e.attenuationDistance!==void 0&&(this.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&this.attenuationColor!==void 0&&this.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(this.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(this.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(this.fog=e.fog),e.flatShading!==void 0&&(this.flatShading=e.flatShading),e.blending!==void 0&&(this.blending=e.blending),e.combine!==void 0&&(this.combine=e.combine),e.side!==void 0&&(this.side=e.side),e.shadowSide!==void 0&&(this.shadowSide=e.shadowSide),e.opacity!==void 0&&(this.opacity=e.opacity),e.transparent!==void 0&&(this.transparent=e.transparent),e.alphaTest!==void 0&&(this.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(this.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(this.depthFunc=e.depthFunc),e.depthTest!==void 0&&(this.depthTest=e.depthTest),e.depthWrite!==void 0&&(this.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(this.colorWrite=e.colorWrite),e.clippingPlanes!==void 0&&(this.clippingPlanes=e.clippingPlanes.map(n=>new Wi().fromJSON(n))),e.clipIntersection!==void 0&&(this.clipIntersection=e.clipIntersection),e.clipShadows!==void 0&&(this.clipShadows=e.clipShadows),e.depthPacking!==void 0&&(this.depthPacking=e.depthPacking),e.blendSrc!==void 0&&(this.blendSrc=e.blendSrc),e.blendDst!==void 0&&(this.blendDst=e.blendDst),e.blendEquation!==void 0&&(this.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(this.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(this.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(this.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&this.blendColor!==void 0&&this.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(this.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(this.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(this.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(this.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(this.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(this.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(this.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(this.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(this.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(this.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(this.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(this.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(this.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(this.rotation=e.rotation),e.linewidth!==void 0&&(this.linewidth=e.linewidth),e.linecap!==void 0&&(this.linecap=e.linecap),e.linejoin!==void 0&&(this.linejoin=e.linejoin),e.dashSize!==void 0&&(this.dashSize=e.dashSize),e.gapSize!==void 0&&(this.gapSize=e.gapSize),e.scale!==void 0&&(this.scale=e.scale),e.polygonOffset!==void 0&&(this.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(this.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(this.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(this.dithering=e.dithering),e.alphaToCoverage!==void 0&&(this.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(this.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(this.forceSinglePass=e.forceSinglePass),e.allowOverride!==void 0&&(this.allowOverride=e.allowOverride),e.visible!==void 0&&(this.visible=e.visible),e.toneMapped!==void 0&&(this.toneMapped=e.toneMapped),e.userData!==void 0&&(this.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?this.vertexColors=e.vertexColors>0:this.vertexColors=e.vertexColors),e.size!==void 0&&(this.size=e.size),e.sizeAttenuation!==void 0&&(this.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(this.map=t[e.map]||null),e.matcap!==void 0&&(this.matcap=t[e.matcap]||null),e.alphaMap!==void 0&&(this.alphaMap=t[e.alphaMap]||null),e.bumpMap!==void 0&&(this.bumpMap=t[e.bumpMap]||null),e.bumpScale!==void 0&&(this.bumpScale=e.bumpScale),e.normalMap!==void 0&&(this.normalMap=t[e.normalMap]||null),e.normalMapType!==void 0&&(this.normalMapType=e.normalMapType),e.normalScale!==void 0){let n=e.normalScale;Array.isArray(n)===!1&&(n=[n,n]),this.normalScale=new dt().fromArray(n)}return e.displacementMap!==void 0&&(this.displacementMap=t[e.displacementMap]||null),e.displacementScale!==void 0&&(this.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(this.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(this.roughnessMap=t[e.roughnessMap]||null),e.metalnessMap!==void 0&&(this.metalnessMap=t[e.metalnessMap]||null),e.emissiveMap!==void 0&&(this.emissiveMap=t[e.emissiveMap]||null),e.emissiveIntensity!==void 0&&(this.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(this.specularMap=t[e.specularMap]||null),e.specularIntensityMap!==void 0&&(this.specularIntensityMap=t[e.specularIntensityMap]||null),e.specularColorMap!==void 0&&(this.specularColorMap=t[e.specularColorMap]||null),e.envMap!==void 0&&(this.envMap=t[e.envMap]||null),e.envMapRotation!==void 0&&this.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(this.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(this.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(this.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(this.lightMap=t[e.lightMap]||null),e.lightMapIntensity!==void 0&&(this.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(this.aoMap=t[e.aoMap]||null),e.aoMapIntensity!==void 0&&(this.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(this.gradientMap=t[e.gradientMap]||null),e.clearcoatMap!==void 0&&(this.clearcoatMap=t[e.clearcoatMap]||null),e.clearcoatRoughnessMap!==void 0&&(this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null),e.clearcoatNormalMap!==void 0&&(this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null),e.clearcoatNormalScale!==void 0&&(this.clearcoatNormalScale=new dt().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(this.iridescenceMap=t[e.iridescenceMap]||null),e.iridescenceThicknessMap!==void 0&&(this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null),e.transmissionMap!==void 0&&(this.transmissionMap=t[e.transmissionMap]||null),e.thicknessMap!==void 0&&(this.thicknessMap=t[e.thicknessMap]||null),e.anisotropyMap!==void 0&&(this.anisotropyMap=t[e.anisotropyMap]||null),e.sheenColorMap!==void 0&&(this.sheenColorMap=t[e.sheenColorMap]||null),e.sheenRoughnessMap!==void 0&&(this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null),this}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,n=null;if(t!==null){let s=t.length;n=new Array(s);for(let r=0;r!==s;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}},Os=new j,Id=new j,kl=new j,Ul=new j,fr=class{constructor(e=new j,t=new j(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Os)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=Os.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Os.copy(this.origin).addScaledVector(this.direction,t),Os.distanceToSquared(e))}distanceSqToSegment(e,t,n,s){Id.copy(e).add(t).multiplyScalar(.5),kl.copy(t).sub(e).normalize(),Ul.copy(this.origin).sub(Id);let r=e.distanceTo(t)*.5,a=-this.direction.dot(kl),o=Ul.dot(this.direction),c=-Ul.dot(kl),l=Ul.lengthSq(),h=Math.abs(1-a*a),u,d,p,b;if(h>0)if(u=a*c-o,d=a*o-c,b=r*h,u>=0)if(d>=-b)if(d<=b){let v=1/h;u*=v,d*=v,p=u*(u+a*d+2*o)+d*(a*u+d+2*c)+l}else d=r,u=Math.max(0,-(a*d+o)),p=-u*u+d*(d+2*c)+l;else d=-r,u=Math.max(0,-(a*d+o)),p=-u*u+d*(d+2*c)+l;else d<=-b?(u=Math.max(0,-(-a*r+o)),d=u>0?-r:Math.min(Math.max(-r,-c),r),p=-u*u+d*(d+2*c)+l):d<=b?(u=0,d=Math.min(Math.max(-r,-c),r),p=d*(d+2*c)+l):(u=Math.max(0,-(a*r+o)),d=u>0?r:Math.min(Math.max(-r,-c),r),p=-u*u+d*(d+2*c)+l);else d=a>0?-r:r,u=Math.max(0,-(a*d+o)),p=-u*u+d*(d+2*c)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,u),s&&s.copy(Id).addScaledVector(kl,d),p}intersectSphere(e,t){if(e.radius<0)return null;Os.subVectors(e.center,this.origin);let n=Os.dot(this.direction),s=Os.dot(Os)-n*n,r=e.radius*e.radius;if(s>r)return null;let a=Math.sqrt(r-s),o=n-a,c=n+a;return c<0?null:o<0?this.at(c,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,s,r,a,o,c,l=1/this.direction.x,h=1/this.direction.y,u=1/this.direction.z,d=this.origin;return l>=0?(n=(e.min.x-d.x)*l,s=(e.max.x-d.x)*l):(n=(e.max.x-d.x)*l,s=(e.min.x-d.x)*l),h>=0?(r=(e.min.y-d.y)*h,a=(e.max.y-d.y)*h):(r=(e.max.y-d.y)*h,a=(e.min.y-d.y)*h),n>a||r>s||((r>n||isNaN(n))&&(n=r),(a<s||isNaN(s))&&(s=a),u>=0?(o=(e.min.z-d.z)*u,c=(e.max.z-d.z)*u):(o=(e.max.z-d.z)*u,c=(e.min.z-d.z)*u),n>c||o>s)||((o>n||n!==n)&&(n=o),(c<s||s!==s)&&(s=c),s<0)?null:this.at(n>=0?n:s,t)}intersectsBox(e){return this.intersectBox(e,Os)!==null}intersectTriangle(e,t,n,s,r){let a=this.origin,o=this.direction,c=o.x,l=o.y,h=o.z,u=e.x-a.x,d=e.y-a.y,p=e.z-a.z,b=t.x-a.x,v=t.y-a.y,_=t.z-a.z,g=n.x-a.x,E=n.y-a.y,L=n.z-a.z,S=Math.abs(c),M=Math.abs(l),A=Math.abs(h),I,y,C,k,z,$,K,P,N,O,F,H;if(S>=M&&S>=A?(C=c,$=u,N=b,H=g,c>=0?(I=l,y=h,k=d,z=p,K=v,P=_,O=E,F=L):(I=h,y=l,k=p,z=d,K=_,P=v,O=L,F=E)):M>=A?(C=l,$=d,N=v,H=E,l>=0?(I=h,y=c,k=p,z=u,K=_,P=b,O=L,F=g):(I=c,y=h,k=u,z=p,K=b,P=_,O=g,F=L)):(C=h,$=p,N=_,H=L,h>=0?(I=c,y=l,k=u,z=d,K=b,P=v,O=g,F=E):(I=l,y=c,k=d,z=u,K=v,P=b,O=E,F=g)),C===0)return null;let V=I/C,Q=y/C,te=1/C,Se=k-V*$,ve=z-Q*$,nt=K-V*N,je=P-Q*N,Qe=O-V*H,fe=F-Q*H,ge=Qe*je-fe*nt,Ve=Se*fe-ve*Qe,it=nt*ve-je*Se;if(s){if(ge<0||Ve<0||it<0)return null}else if((ge<0||Ve<0||it<0)&&(ge>0||Ve>0||it>0))return null;let Ue=ge+Ve+it;if(Ue===0)return null;let ct=te*(ge*$+Ve*N+it*H);return(Ue>0?ct<0:ct>0)?null:this.at(ct/Ue,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)}},Sn=class extends Wn{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new He(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ds,this.combine=Ph,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},gb=new ht,Hr=new fr,Bl=new si,bb=new j,zl=new j,Hl=new j,Vl=new j,Pd=new j,Gl=new j,_b=new j,Wl=new j,vt=class extends Yt{constructor(e=new pn,t=new Sn){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let s=t[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;r<a;r++){let o=s[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}getVertexPosition(e,t){let n=this.geometry,s=n.attributes.position,r=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(s,e);let o=this.morphTargetInfluences;if(r&&o){Gl.set(0,0,0);for(let c=0,l=r.length;c<l;c++){let h=o[c],u=r[c];h!==0&&(Pd.fromBufferAttribute(u,e),a?Gl.addScaledVector(Pd,h):Gl.addScaledVector(Pd.sub(t),h))}t.add(Gl)}return t}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,s=this.material,r=this.matrixWorld;s!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),Bl.copy(n.boundingSphere),Bl.applyMatrix4(r),Hr.copy(e.ray).recast(e.near),!(Bl.containsPoint(Hr.origin)===!1&&(Hr.intersectSphere(Bl,bb)===null||Hr.origin.distanceToSquared(bb)>(e.far-e.near)**2))&&(gb.copy(r).invert(),Hr.copy(e.ray).applyMatrix4(gb),!(n.boundingBox!==null&&Hr.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,Hr)))}_computeIntersections(e,t,n){let s,r=this.geometry,a=this.material,o=r.index,c=r.attributes.position,l=r.attributes.uv,h=r.attributes.uv1,u=r.attributes.normal,d=r.groups,p=r.drawRange;if(o!==null)if(Array.isArray(a))for(let b=0,v=d.length;b<v;b++){let _=d[b],g=a[_.materialIndex],E=Math.max(_.start,p.start),L=Math.min(o.count,Math.min(_.start+_.count,p.start+p.count));for(let S=E,M=L;S<M;S+=3){let A=o.getX(S),I=o.getX(S+1),y=o.getX(S+2);s=$l(this,g,e,n,l,h,u,A,I,y),s&&(s.faceIndex=Math.floor(S/3),s.face.materialIndex=_.materialIndex,t.push(s))}}else{let b=Math.max(0,p.start),v=Math.min(o.count,p.start+p.count);for(let _=b,g=v;_<g;_+=3){let E=o.getX(_),L=o.getX(_+1),S=o.getX(_+2);s=$l(this,a,e,n,l,h,u,E,L,S),s&&(s.faceIndex=Math.floor(_/3),t.push(s))}}else if(c!==void 0)if(Array.isArray(a))for(let b=0,v=d.length;b<v;b++){let _=d[b],g=a[_.materialIndex],E=Math.max(_.start,p.start),L=Math.min(c.count,Math.min(_.start+_.count,p.start+p.count));for(let S=E,M=L;S<M;S+=3){let A=S,I=S+1,y=S+2;s=$l(this,g,e,n,l,h,u,A,I,y),s&&(s.faceIndex=Math.floor(S/3),s.face.materialIndex=_.materialIndex,t.push(s))}}else{let b=Math.max(0,p.start),v=Math.min(c.count,p.start+p.count);for(let _=b,g=v;_<g;_+=3){let E=_,L=_+1,S=_+2;s=$l(this,a,e,n,l,h,u,E,L,S),s&&(s.faceIndex=Math.floor(_/3),t.push(s))}}}};Bo=new Gt,xb=new Gt,yb=new Gt,oM=new Gt,vb=new ht,ql=new j,Ld=new si,Sb=new ht,Dd=new fr,Qo=class extends vt{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=kd,this.bindMatrix=new ht,this.bindMatrixInverse=new ht,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let e=this.geometry;this.boundingBox===null&&(this.boundingBox=new ln),this.boundingBox.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,ql),this.boundingBox.expandByPoint(ql)}computeBoundingSphere(){let e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new si),this.boundingSphere.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,ql),this.boundingSphere.expandByPoint(ql)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){let n=this.material,s=this.matrixWorld;n!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Ld.copy(this.boundingSphere),Ld.applyMatrix4(s),e.ray.intersectsSphere(Ld)!==!1&&(Sb.copy(s).invert(),Dd.copy(e.ray).applyMatrix4(Sb),!(this.boundingBox!==null&&Dd.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,Dd)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){let e=new Gt,t=this.geometry.attributes.skinWeight;for(let n=0,s=t.count;n<s;n++){e.fromBufferAttribute(t,n);let r=1/e.manhattanLength();r!==1/0?e.multiplyScalar(r):e.set(1,0,0,0),t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===kd?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===h_?this.bindMatrixInverse.copy(this.bindMatrix).invert():tt("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){let n=this.skeleton,s=this.geometry;xb.fromBufferAttribute(s.attributes.skinIndex,e),yb.fromBufferAttribute(s.attributes.skinWeight,e),t.isVector4?(Bo.copy(t),t.set(0,0,0,0)):(Bo.set(...t,1),t.set(0,0,0)),Bo.applyMatrix4(this.bindMatrix);for(let r=0;r<4;r++){let a=yb.getComponent(r);if(a!==0){let o=xb.getComponent(r);vb.multiplyMatrices(n.bones[o].matrixWorld,n.boneInverses[o]),t.addScaledVector(oM.copy(Bo).applyMatrix4(vb),a)}}return t.isVector4&&(t.w=Bo.w),t.applyMatrix4(this.bindMatrixInverse)}},Ya=class extends Yt{constructor(){super(),this.isBone=!0,this.type="Bone"}},dr=class extends En{constructor(e=null,t=1,n=1,s,r,a,o,c,l=dn,h=dn,u,d){super(null,a,o,c,l,h,s,r,u,d),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},wb=new ht,cM=new ht,ec=class i{constructor(e=[],t=[]){this.uuid=Xi(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){let e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){tt("Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,s=this.bones.length;n<s;n++)this.boneInverses.push(new ht)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let n=new ht;this.bones[e]&&n.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(n)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){let n=this.bones[e];n&&n.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){let n=this.bones[e];n&&(n.parent&&n.parent.isBone?(n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld)):n.matrix.copy(n.matrixWorld),n.matrix.decompose(n.position,n.quaternion,n.scale))}}update(){let e=this.bones,t=this.boneInverses,n=this.boneMatrices,s=this.boneTexture;for(let r=0,a=e.length;r<a;r++){let o=e[r]?e[r].matrixWorld:cM;wb.multiplyMatrices(o,t[r]),wb.toArray(n,r*16)}s!==null&&(s.needsUpdate=!0)}clone(){return new i(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);let t=new Float32Array(e*e*4);t.set(this.boneMatrices);let n=new dr(t,e,e,yi,qn);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){let s=this.bones[t];if(s.name===e)return s}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,s=e.bones.length;n<s;n++){let r=e.bones[n],a=t[r];a===void 0&&(tt("Skeleton: No bone found with UUID:",r),a=new Ya),this.bones.push(a),this.boneInverses.push(new ht().fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){let e={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;let t=this.bones,n=this.boneInverses;for(let s=0,r=t.length;s<r;s++){let a=t[s];e.bones.push(a.uuid);let o=n[s];e.boneInverses.push(o.toArray())}return e}},Bs=class extends Qt{constructor(e,t,n,s=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=s}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}},ka=new ht,Mb=new ht,jl=[],Eb=new ln,lM=new ht,zo=new vt,Ho=new si,Kr=class extends vt{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new Bs(new Float32Array(n*16),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let s=0;s<n;s++)this.setMatrixAt(s,lM)}computeBoundingBox(){let e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new ln),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,ka),Eb.copy(e.boundingBox).applyMatrix4(ka),this.boundingBox.union(Eb)}computeBoundingSphere(){let e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new si),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,ka),Ho.copy(e.boundingSphere).applyMatrix4(ka),this.boundingSphere.union(Ho)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){return this.instanceColor===null?t.setRGB(1,1,1):t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){return t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){let n=t.morphTargetInfluences,s=this.morphTexture.source.data.data,r=n.length+1,a=e*r+1;for(let o=0;o<n.length;o++)n[o]=s[a+o]}raycast(e,t){let n=this.matrixWorld,s=this.count;if(zo.geometry=this.geometry,zo.material=this.material,zo.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Ho.copy(this.boundingSphere),Ho.applyMatrix4(n),e.ray.intersectsSphere(Ho)!==!1))for(let r=0;r<s;r++){this.getMatrixAt(r,ka),Mb.multiplyMatrices(n,ka),zo.matrixWorld=Mb,zo.raycast(e,jl);for(let a=0,o=jl.length;a<o;a++){let c=jl[a];c.instanceId=r,c.object=this,t.push(c)}jl.length=0}}setColorAt(e,t){return this.instanceColor===null&&(this.instanceColor=new Bs(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),t.toArray(this.instanceColor.array,e*3),this}setMatrixAt(e,t){return t.toArray(this.instanceMatrix.array,e*16),this}setMorphAt(e,t){let n=t.morphTargetInfluences,s=n.length+1;this.morphTexture===null&&(this.morphTexture=new dr(new Float32Array(s*this.count),s,this.count,Uh,qn));let r=this.morphTexture.source.data.data,a=0;for(let l=0;l<n.length;l++)a+=n[l];let o=this.geometry.morphTargetsRelative?1:1-a,c=s*e;return r[c]=o,r.set(n,c+1),this}updateMorphTargets(){}dispose(){super.dispose(),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}},Vr=new si,hM=new dt(.5,.5),Xl=new j,Ja=class{constructor(e=new Wi,t=new Wi,n=new Wi,s=new Wi,r=new Wi,a=new Wi){this.planes=[e,t,n,s,r,a]}set(e,t,n,s,r,a){let o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(s),o[4].copy(r),o[5].copy(a),this}copy(e){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=ji,n=!1){let s=this.planes,r=e.elements,a=r[0],o=r[1],c=r[2],l=r[3],h=r[4],u=r[5],d=r[6],p=r[7],b=r[8],v=r[9],_=r[10],g=r[11],E=r[12],L=r[13],S=r[14],M=r[15];if(s[0].setComponents(l-a,p-h,g-b,M-E).normalize(),s[1].setComponents(l+a,p+h,g+b,M+E).normalize(),s[2].setComponents(l+o,p+u,g+v,M+L).normalize(),s[3].setComponents(l-o,p-u,g-v,M-L).normalize(),n)s[4].setComponents(c,d,_,S).normalize(),s[5].setComponents(l-c,p-d,g-_,M-S).normalize();else if(s[4].setComponents(l-c,p-d,g-_,M-S).normalize(),t===ji)s[5].setComponents(l+c,p+d,g+_,M+S).normalize();else if(t===Wa)s[5].setComponents(c,d,_,S).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Vr.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Vr.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Vr)}intersectsSprite(e){Vr.center.set(0,0,0);let t=hM.distanceTo(e.center);return Vr.radius=.7071067811865476+t,Vr.applyMatrix4(e.matrixWorld),this.intersectsSphere(Vr)}intersectsSphere(e){let t=this.planes,n=e.center,s=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(n)<s)return!1;return!0}intersectsBox(e){let t=this.planes;for(let n=0;n<6;n++){let s=t[n];if(Xl.x=s.normal.x>0?e.max.x:e.min.x,Xl.y=s.normal.y>0?e.max.y:e.min.y,Xl.z=s.normal.z>0?e.max.z:e.min.z,s.distanceToPoint(Xl)<0)return!1}return!0}containsPoint(e){let 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)}},Yr=class extends Wn{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new He(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}},dh=new j,ph=new j,Ab=new ht,Vo=new fr,Kl=new si,Nd=new j,Tb=new j,Jr=class extends Yt{constructor(e=new pn,t=new Yr){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[0];for(let s=1,r=t.count;s<r;s++)dh.fromBufferAttribute(t,s-1),ph.fromBufferAttribute(t,s),n[s]=n[s-1],n[s]+=dh.distanceTo(ph);e.setAttribute("lineDistance",new sn(n,1))}else tt("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,s=this.matrixWorld,r=e.params.Line.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Kl.copy(n.boundingSphere),Kl.applyMatrix4(s),Kl.radius+=r,e.ray.intersectsSphere(Kl)===!1)return;Ab.copy(s).invert(),Vo.copy(e.ray).applyMatrix4(Ab);let o=r/((this.scale.x+this.scale.y+this.scale.z)/3),c=o*o,l=this.isLineSegments?2:1,h=n.index,d=n.attributes.position;if(h!==null){let p=Math.max(0,a.start),b=Math.min(h.count,a.start+a.count);for(let v=p,_=b-1;v<_;v+=l){let g=h.getX(v),E=h.getX(v+1),L=Yl(this,e,Vo,c,g,E,v);L&&t.push(L)}if(this.isLineLoop){let v=h.getX(b-1),_=h.getX(p),g=Yl(this,e,Vo,c,v,_,b-1);g&&t.push(g)}}else{let p=Math.max(0,a.start),b=Math.min(d.count,a.start+a.count);for(let v=p,_=b-1;v<_;v+=l){let g=Yl(this,e,Vo,c,v,v+1,v);g&&t.push(g)}if(this.isLineLoop){let v=Yl(this,e,Vo,c,b-1,p,b-1);v&&t.push(v)}}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let s=t[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;r<a;r++){let o=s[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}};Rb=new j,Cb=new j,Za=class extends Jr{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[];for(let s=0,r=t.count;s<r;s+=2)Rb.fromBufferAttribute(t,s),Cb.fromBufferAttribute(t,s+1),n[s]=s===0?0:n[s-1],n[s+1]=n[s]+Rb.distanceTo(Cb);e.setAttribute("lineDistance",new sn(n,1))}else tt("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},tc=class extends Jr{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}},Qa=class extends Wn{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new He(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}},Ib=new ht,Bd=new fr,Jl=new si,Zl=new j,nc=class extends Yt{constructor(e=new pn,t=new Qa){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,s=this.matrixWorld,r=e.params.Points.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Jl.copy(n.boundingSphere),Jl.applyMatrix4(s),Jl.radius+=r,e.ray.intersectsSphere(Jl)===!1)return;Ib.copy(s).invert(),Bd.copy(e.ray).applyMatrix4(Ib);let o=r/((this.scale.x+this.scale.y+this.scale.z)/3),c=o*o,l=n.index,u=n.attributes.position;if(l!==null){let d=Math.max(0,a.start),p=Math.min(l.count,a.start+a.count);for(let b=d,v=p;b<v;b++){let _=l.getX(b);Zl.fromBufferAttribute(u,_),Pb(Zl,_,c,s,e,t,this)}}else{let d=Math.max(0,a.start),p=Math.min(u.count,a.start+a.count);for(let b=d,v=p;b<v;b++)Zl.fromBufferAttribute(u,b),Pb(Zl,b,c,s,e,t,this)}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let s=t[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;r<a;r++){let o=s[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}};ic=class extends En{constructor(e=[],t=vr,n,s,r,a,o,c,l,h){super(e,t,n,s,r,a,o,c,l,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},Zr=class extends En{constructor(e,t,n,s,r,a,o,c,l){super(e,t,n,s,r,a,o,c,l),this.isCanvasTexture=!0,this.needsUpdate=!0}},pr=class extends En{constructor(e,t,n=Zi,s,r,a,o=dn,c=dn,l,h=fs,u=1){if(h!==fs&&h!==Sr)throw new Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");let d={width:e,height:t,depth:u};super(d,s,r,a,o,c,h,n,l),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new ja(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return t.compareFunction=this.compareFunction,t}},mh=class extends pr{constructor(e,t=Zi,n=vr,s,r,a=dn,o=dn,c,l=fs){let h={width:e,height:e,depth:1},u=[h,h,h,h,h,h];super(e,e,t,n,s,r,a,o,c,l),this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}},sc=class extends En{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}},mr=class i extends pn{constructor(e=1,t=1,n=1,s=1,r=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:s,heightSegments:r,depthSegments:a};let o=this;s=Math.floor(s),r=Math.floor(r),a=Math.floor(a);let c=[],l=[],h=[],u=[],d=0,p=0;b("z","y","x",-1,-1,n,t,e,a,r,0),b("z","y","x",1,-1,n,t,-e,a,r,1),b("x","z","y",1,1,e,n,t,s,a,2),b("x","z","y",1,-1,e,n,-t,s,a,3),b("x","y","z",1,-1,e,t,n,s,r,4),b("x","y","z",-1,-1,e,t,-n,s,r,5),this.setIndex(c),this.setAttribute("position",new sn(l,3)),this.setAttribute("normal",new sn(h,3)),this.setAttribute("uv",new sn(u,2));function b(v,_,g,E,L,S,M,A,I,y,C){let k=S/I,z=M/y,$=S/2,K=M/2,P=A/2,N=I+1,O=y+1,F=0,H=0,V=new j;for(let Q=0;Q<O;Q++){let te=Q*z-K;for(let Se=0;Se<N;Se++){let ve=Se*k-$;V[v]=ve*E,V[_]=te*L,V[g]=P,l.push(V.x,V.y,V.z),V[v]=0,V[_]=0,V[g]=A>0?1:-1,h.push(V.x,V.y,V.z),u.push(Se/I),u.push(1-Q/y),F+=1}}for(let Q=0;Q<y;Q++)for(let te=0;te<I;te++){let Se=d+te+N*Q,ve=d+te+N*(Q+1),nt=d+(te+1)+N*(Q+1),je=d+(te+1)+N*Q;c.push(Se,ve,je),c.push(ve,nt,je),H+=6}o.addGroup(p,H,C),p+=H,d+=F}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new i(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}},rc=class i extends pn{constructor(e=1,t=32,n=0,s=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:s},t=Math.max(3,t);let r=[],a=[],o=[],c=[],l=new j,h=new dt;a.push(0,0,0),o.push(0,0,1),c.push(.5,.5);for(let u=0,d=3;u<=t;u++,d+=3){let p=n+u/t*s;l.x=e*Math.cos(p),l.y=e*Math.sin(p),a.push(l.x,l.y,l.z),o.push(0,0,1),h.x=(a[d]/e+1)/2,h.y=(a[d+1]/e+1)/2,c.push(h.x,h.y)}for(let u=1;u<=t;u++)r.push(u,u+1,0);this.setIndex(r),this.setAttribute("position",new sn(a,3)),this.setAttribute("normal",new sn(o,3)),this.setAttribute("uv",new sn(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new i(e.radius,e.segments,e.thetaStart,e.thetaLength)}},Ii=class i extends pn{constructor(e=1,t=1,n=1,s=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:s};let r=e/2,a=t/2,o=Math.floor(n),c=Math.floor(s),l=o+1,h=c+1,u=e/o,d=t/c,p=[],b=[],v=[],_=[];for(let g=0;g<h;g++){let E=g*d-a;for(let L=0;L<l;L++){let S=L*u-r;b.push(S,-E,0),v.push(0,0,1),_.push(L/o),_.push(1-g/c)}}for(let g=0;g<c;g++)for(let E=0;E<o;E++){let L=E+l*g,S=E+l*(g+1),M=E+1+l*(g+1),A=E+1+l*g;p.push(L,S,A),p.push(S,M,A)}this.setIndex(p),this.setAttribute("position",new sn(b,3)),this.setAttribute("normal",new sn(v,3)),this.setAttribute("uv",new sn(_,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new i(e.width,e.height,e.widthSegments,e.heightSegments)}},gr=class i extends pn{constructor(e=.5,t=1,n=32,s=1,r=0,a=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:n,phiSegments:s,thetaStart:r,thetaLength:a},n=Math.max(3,n),s=Math.max(1,s);let o=[],c=[],l=[],h=[],u=e,d=(t-e)/s,p=new j,b=new dt;for(let v=0;v<=s;v++){for(let _=0;_<=n;_++){let g=r+_/n*a;p.x=u*Math.cos(g),p.y=u*Math.sin(g),c.push(p.x,p.y,p.z),l.push(0,0,1),b.x=(p.x/t+1)/2,b.y=(p.y/t+1)/2,h.push(b.x,b.y)}u+=d}for(let v=0;v<s;v++){let _=v*(n+1);for(let g=0;g<n;g++){let E=g+_,L=E,S=E+n+1,M=E+n+2,A=E+1;o.push(L,S,A),o.push(S,M,A)}}this.setIndex(o),this.setAttribute("position",new sn(c,3)),this.setAttribute("normal",new sn(l,3)),this.setAttribute("uv",new sn(h,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new i(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}},ac=class extends Wn{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new He(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}};T_={clone:sa,merge:jn},fM=`void main() {
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
-}`,dS=`void main() {
+}`,dM=`void main() {
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
-}`,ai=class extends Ln{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=uS,this.fragmentShader=dS,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Es(e.uniforms),this.uniformsGroups=hS(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.defaultAttributeValues=Object.assign({},e.defaultAttributeValues),this.index0AttributeName=e.index0AttributeName,this.uniformsNeedUpdate=e.uniformsNeedUpdate,this}toJSON(e){let t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(let r in this.uniforms){let a=this.uniforms[r].value;a&&a.isTexture?t.uniforms[r]={type:"t",value:a.toJSON(e).uuid}:a&&a.isColor?t.uniforms[r]={type:"c",value:a.getHex()}:a&&a.isVector2?t.uniforms[r]={type:"v2",value:a.toArray()}:a&&a.isVector3?t.uniforms[r]={type:"v3",value:a.toArray()}:a&&a.isVector4?t.uniforms[r]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?t.uniforms[r]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?t.uniforms[r]={type:"m4",value:a.toArray()}:t.uniforms[r]={value:a}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;let n={};for(let r in this.extensions)this.extensions[r]===!0&&(n[r]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}},fl=class extends ai{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}},gi=class extends Ln{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new Ve(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 Ve(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Bo,this.normalScale=new dt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new qi,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},Jn=class extends gi{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new dt(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return bt(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Ve(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new Ve(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Ve(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}},po=class extends Ln{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Ve(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ve(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Bo,this.normalScale=new dt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new qi,this.combine=Rl,this.reflectivity=1,this.envMapIntensity=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.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.envMapIntensity=e.envMapIntensity,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}},pl=class extends Ln{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=g0,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}},ml=class extends Ln{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}};mo=class{static convertArray(e,t){return ds(e,t)}static isTypedArray(e){return M0(e)}static getKeyframeOrder(e){return P0(e)}static sortedArray(e,t,n){return fd(e,t,n)}static flattenJSON(e,t,n,r){Vd(e,t,n,r)}static subclip(e,t,n,r,s=30){return fS(e,t,n,r,s)}static makeClipAdditive(e,t=0,n=e,r=30){return pS(e,t,n,r)}},$i=class{constructor(e,t,n,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r!==void 0?r:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,n=this._cachedIndex,r=t[n],s=t[n-1];e:{t:{let a;n:{i:if(!(e<r)){for(let o=n+2;;){if(r===void 0){if(e<s)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===o)break;if(s=r,r=t[++n],e<r)break t}a=t.length;break n}if(!(e>=s)){let o=t[1];e<o&&(n=2,s=o);for(let l=n-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===l)break;if(r=s,s=t[--n-1],e>=s)break t}a=n,n=0;break n}break e}for(;n<a;){let o=n+a>>>1;e<t[o]?a=o:n=o+1}if(r=t[n],s=t[n-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,s,r)}return this.interpolate_(n,s,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,r=this.valueSize,s=e*r;for(let a=0;a!==r;++a)t[a]=n[s+a];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},gl=class extends $i{constructor(e,t,n,r){super(e,t,n,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:hs,endingEnd:hs}}intervalChanged_(e,t,n){let r=this.parameterPositions,s=e-2,a=e+1,o=r[s],l=r[a];if(o===void 0)switch(this.getSettings_().endingStart){case us:s=e,o=2*t-n;break;case Za:s=r.length-2,o=t+r[s]-r[s+1];break;default:s=e,o=n}if(l===void 0)switch(this.getSettings_().endingEnd){case us:a=e,l=2*n-t;break;case Za:a=1,l=n+r[1]-r[0];break;default:a=e-1,l=t}let c=(n-t)*.5,h=this.valueSize;this._weightPrev=c/(t-o),this._weightNext=c/(l-n),this._offsetPrev=s*h,this._offsetNext=a*h}interpolate_(e,t,n,r){let s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,h=this._offsetPrev,d=this._offsetNext,f=this._weightPrev,p=this._weightNext,x=(n-t)/(r-t),y=x*x,b=y*x,g=-f*b+2*f*y-f*x,S=(1+f)*b+(-1.5-2*f)*y+(-.5+f)*x+1,A=(-1-p)*b+(1.5+p)*y+.5*x,T=p*b-p*y;for(let N=0;N!==o;++N)s[N]=g*a[h+N]+S*a[c+N]+A*a[l+N]+T*a[d+N];return s}},go=class extends $i{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){let s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,h=(n-t)/(r-t),d=1-h;for(let f=0;f!==o;++f)s[f]=a[c+f]*d+a[l+f]*h;return s}},bl=class extends $i{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e){return this.copySampleValue_(e-1)}},xl=class extends $i{interpolate_(e,t,n,r){let s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,h=this.settings||this.DefaultSettings_,d=h.inTangents,f=h.outTangents;if(!d||!f){let y=(n-t)/(r-t),b=1-y;for(let g=0;g!==o;++g)s[g]=a[c+g]*b+a[l+g]*y;return s}let p=o*2,x=e-1;for(let y=0;y!==o;++y){let b=a[c+y],g=a[l+y],S=x*p+y*2,A=f[S],T=f[S+1],N=e*p+y*2,P=d[N],U=d[N+1],v=(n-t)/(r-t),I,B,k,V,J;for(let L=0;L<8;L++){I=v*v,B=I*v,k=1-v,V=k*k,J=V*k;let D=J*t+3*V*v*A+3*k*I*P+B*r-n;if(Math.abs(D)<1e-10)break;let O=3*V*(A-t)+6*k*v*(P-A)+3*I*(r-P);if(Math.abs(O)<1e-10)break;v=v-D/O,v=Math.max(0,Math.min(1,v))}s[y]=J*b+3*V*v*T+3*k*I*U+B*g}return s}},Zn=class{constructor(e,t,n,r){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=ds(t,this.TimeBufferType),this.values=ds(n,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:ds(e.times,Array),values:ds(e.values,Array)};let r=e.getInterpolation();r!==e.DefaultInterpolation&&(n.interpolation=r)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new bl(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new go(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new gl(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){let t=new xl(this.times,this.values,this.getValueSize(),e);return this.settings&&(t.settings=this.settings),t}setInterpolation(e){let t;switch(e){case ms:t=this.InterpolantFactoryMethodDiscrete;break;case gs:t=this.InterpolantFactoryMethodLinear;break;case Kc:t=this.InterpolantFactoryMethodSmooth;break;case hd:t=this.InterpolantFactoryMethodBezier;break}if(t===void 0){let n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return Ke("KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return ms;case this.InterpolantFactoryMethodLinear:return gs;case this.InterpolantFactoryMethodSmooth:return Kc;case this.InterpolantFactoryMethodBezier:return hd}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let n=0,r=t.length;n!==r;++n)t[n]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let n=0,r=t.length;n!==r;++n)t[n]*=e}return this}trim(e,t){let n=this.times,r=n.length,s=0,a=r-1;for(;s!==r&&n[s]<e;)++s;for(;a!==-1&&n[a]>t;)--a;if(++a,s!==0||a!==r){s>=a&&(a=Math.max(a,1),s=a-1);let o=this.getValueSize();this.times=n.slice(s,a),this.values=this.values.slice(s*o,a*o)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(et("KeyframeTrack: Invalid value size in track.",this),e=!1);let n=this.times,r=this.values,s=n.length;s===0&&(et("KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let o=0;o!==s;o++){let l=n[o];if(typeof l=="number"&&isNaN(l)){et("KeyframeTrack: Time is not a valid number.",this,o,l),e=!1;break}if(a!==null&&a>l){et("KeyframeTrack: Out of order keys.",this,o,l,a),e=!1;break}a=l}if(r!==void 0&&M0(r))for(let o=0,l=r.length;o!==l;++o){let c=r[o];if(isNaN(c)){et("KeyframeTrack: Value is not a valid number.",this,o,c),e=!1;break}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),r=this.getInterpolation()===Kc,s=e.length-1,a=1;for(let o=1;o<s;++o){let l=!1,c=e[o],h=e[o+1];if(c!==h&&(o!==1||c!==e[0]))if(r)l=!0;else{let d=o*n,f=d-n,p=d+n;for(let x=0;x!==n;++x){let y=t[d+x];if(y!==t[f+x]||y!==t[p+x]){l=!0;break}}}if(l){if(o!==a){e[a]=e[o];let d=o*n,f=a*n;for(let p=0;p!==n;++p)t[f+p]=t[d+p]}++a}}if(s>0){e[a]=e[s];for(let o=s*n,l=a*n,c=0;c!==n;++c)t[l+c]=t[o+c];++a}return a!==e.length?(this.times=e.slice(0,a),this.values=t.slice(0,a*n)):(this.times=e,this.values=t),this}clone(){let e=this.times.slice(),t=this.values.slice(),n=this.constructor,r=new n(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}};Zn.prototype.ValueTypeName="";Zn.prototype.TimeBufferType=Float32Array;Zn.prototype.ValueBufferType=Float32Array;Zn.prototype.DefaultInterpolation=gs;mr=class extends Zn{constructor(e,t,n){super(e,t,n)}};mr.prototype.ValueTypeName="bool";mr.prototype.ValueBufferType=Array;mr.prototype.DefaultInterpolation=ms;mr.prototype.InterpolantFactoryMethodLinear=void 0;mr.prototype.InterpolantFactoryMethodSmooth=void 0;bo=class extends Zn{constructor(e,t,n,r){super(e,t,n,r)}};bo.prototype.ValueTypeName="color";ji=class extends Zn{constructor(e,t,n,r){super(e,t,n,r)}};ji.prototype.ValueTypeName="number";_l=class extends $i{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){let s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=(n-t)/(r-t),c=e*o;for(let h=c+o;c!==h;c+=4)Pt.slerpFlat(s,0,a,c-o,a,c,l);return s}},Xi=class extends Zn{constructor(e,t,n,r){super(e,t,n,r)}InterpolantFactoryMethodLinear(e){return new _l(this.times,this.values,this.getValueSize(),e)}};Xi.prototype.ValueTypeName="quaternion";Xi.prototype.InterpolantFactoryMethodSmooth=void 0;gr=class extends Zn{constructor(e,t,n){super(e,t,n)}};gr.prototype.ValueTypeName="string";gr.prototype.ValueBufferType=Array;gr.prototype.DefaultInterpolation=ms;gr.prototype.InterpolantFactoryMethodLinear=void 0;gr.prototype.InterpolantFactoryMethodSmooth=void 0;Ki=class extends Zn{constructor(e,t,n,r){super(e,t,n,r)}};Ki.prototype.ValueTypeName="vector";bi=class{constructor(e="",t=-1,n=[],r=mh){this.name=e,this.tracks=n,this.duration=t,this.blendMode=r,this.uuid=Ii(),this.userData={},this.duration<0&&this.resetDuration()}static parse(e){let t=[],n=e.tracks,r=1/(e.fps||1);for(let a=0,o=n.length;a!==o;++a)t.push(gS(n[a]).scale(r));let s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s.userData=JSON.parse(e.userData||"{}"),s}static toJSON(e){let t=[],n=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let s=0,a=n.length;s!==a;++s)t.push(Zn.toJSON(n[s]));return r}static CreateFromMorphTargetSequence(e,t,n,r){let s=t.length,a=[];for(let o=0;o<s;o++){let l=[],c=[];l.push((o+s-1)%s,o,(o+1)%s),c.push(0,1,0);let h=P0(l);l=fd(l,1,h),c=fd(c,1,h),!r&&l[0]===0&&(l.push(s),c.push(c[0])),a.push(new ji(".morphTargetInfluences["+t[o].name+"]",l,c).scale(1/n))}return new this(e,-1,a)}static findByName(e,t){let n=e;if(!Array.isArray(e)){let r=e;n=r.geometry&&r.geometry.animations||r.animations}for(let r=0;r<n.length;r++)if(n[r].name===t)return n[r];return null}static CreateClipsFromMorphTargetSequences(e,t,n){let r={},s=/^([\w-]*?)([\d]+)$/;for(let o=0,l=e.length;o<l;o++){let c=e[o],h=c.name.match(s);if(h&&h.length>1){let d=h[1],f=r[d];f||(r[d]=f=[]),f.push(c)}}let a=[];for(let o in r)a.push(this.CreateFromMorphTargetSequence(o,r[o],t,n));return a}static parseAnimation(e,t){if(Ke("AnimationClip: parseAnimation() is deprecated and will be removed with r185"),!e)return et("AnimationClip: No animation in JSONLoader data."),null;let n=function(d,f,p,x,y){if(p.length!==0){let b=[],g=[];Vd(p,b,g,x),b.length!==0&&y.push(new d(f,b,g))}},r=[],s=e.name||"default",a=e.fps||30,o=e.blendMode,l=e.length||-1,c=e.hierarchy||[];for(let d=0;d<c.length;d++){let f=c[d].keys;if(!(!f||f.length===0))if(f[0].morphTargets){let p={},x;for(x=0;x<f.length;x++)if(f[x].morphTargets)for(let y=0;y<f[x].morphTargets.length;y++)p[f[x].morphTargets[y]]=-1;for(let y in p){let b=[],g=[];for(let S=0;S!==f[x].morphTargets.length;++S){let A=f[x];b.push(A.time),g.push(A.morphTarget===y?1:0)}r.push(new ji(".morphTargetInfluence["+y+"]",b,g))}l=p.length*a}else{let p=".bones["+t[d].name+"]";n(Ki,p+".position",f,"pos",r),n(Xi,p+".quaternion",f,"rot",r),n(Ki,p+".scale",f,"scl",r)}}return r.length===0?null:new this(s,l,r,o)}resetDuration(){let e=this.tracks,t=0;for(let n=0,r=e.length;n!==r;++n){let s=this.tracks[n];t=Math.max(t,s.times[s.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){let e=[];for(let n=0;n<this.tracks.length;n++)e.push(this.tracks[n].clone());let t=new this.constructor(this.name,this.duration,e,this.blendMode);return t.userData=JSON.parse(JSON.stringify(this.userData)),t}toJSON(){return this.constructor.toJSON(this)}};Vi={enabled:!1,files:{},add:function(i,e){this.enabled!==!1&&(kg(i)||(this.files[i]=e))},get:function(i){if(this.enabled!==!1&&!kg(i))return this.files[i]},remove:function(i){delete this.files[i]},clear:function(){this.files={}}};yl=class{constructor(e,t,n){let r=this,s=!1,a=0,o=0,l,c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this._abortController=null,this.itemStart=function(h){o++,s===!1&&r.onStart!==void 0&&r.onStart(h,a,o),s=!0},this.itemEnd=function(h){a++,r.onProgress!==void 0&&r.onProgress(h,a,o),a===o&&(s=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(h){r.onError!==void 0&&r.onError(h)},this.resolveURL=function(h){return l?l(h):h},this.setURLModifier=function(h){return l=h,this},this.addHandler=function(h,d){return c.push(h,d),this},this.removeHandler=function(h){let d=c.indexOf(h);return d!==-1&&c.splice(d,2),this},this.getHandler=function(h){for(let d=0,f=c.length;d<f;d+=2){let p=c[d],x=c[d+1];if(p.global&&(p.lastIndex=0),p.test(h))return x}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){return this._abortController||(this._abortController=new AbortController),this._abortController}},L0=new yl,oi=class{constructor(e){this.manager=e!==void 0?e:L0,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}load(){}loadAsync(e,t){let n=this;return new Promise(function(r,s){n.load(e,r,t,s)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}abort(){return this}};oi.DEFAULT_MATERIAL_NAME="__DEFAULT";ur={},pd=class extends Error{constructor(e,t){super(e),this.response=t}},Yi=class extends oi{constructor(e){super(e),this.mimeType="",this.responseType="",this._abortController=new AbortController}load(e,t,n,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let s=Vi.get(`file:${e}`);if(s!==void 0){this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0);return}if(ur[e]!==void 0){ur[e].push({onLoad:t,onProgress:n,onError:r});return}ur[e]=[],ur[e].push({onLoad:t,onProgress:n,onError:r});let a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),o=this.mimeType,l=this.responseType;fetch(a).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&Ke("FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;let h=ur[e],d=c.body.getReader(),f=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),p=f?parseInt(f):0,x=p!==0,y=0,b=new ReadableStream({start(g){S();function S(){d.read().then(({done:A,value:T})=>{if(A)g.close();else{y+=T.byteLength;let N=new ProgressEvent("progress",{lengthComputable:x,loaded:y,total:p});for(let P=0,U=h.length;P<U;P++){let v=h[P];v.onProgress&&v.onProgress(N)}g.enqueue(T),S()}},A=>{g.error(A)})}}});return new Response(b)}else throw new pd(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then(c=>{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(h=>new DOMParser().parseFromString(h,o));case"json":return c.json();default:if(o==="")return c.text();{let d=/charset="?([^;"\s]*)"?/i.exec(o),f=d&&d[1]?d[1].toLowerCase():void 0,p=new TextDecoder(f);return c.arrayBuffer().then(x=>p.decode(x))}}}).then(c=>{Vi.add(`file:${e}`,c);let h=ur[e];delete ur[e];for(let d=0,f=h.length;d<f;d++){let p=h[d];p.onLoad&&p.onLoad(c)}}).catch(c=>{let h=ur[e];if(h===void 0)throw this.manager.itemError(e),c;delete ur[e];for(let d=0,f=h.length;d<f;d++){let p=h[d];p.onError&&p.onError(c)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}},ea=new WeakMap,vl=class extends oi{constructor(e){super(e)}load(e,t,n,r){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let s=this,a=Vi.get(`image:${e}`);if(a!==void 0){if(a.complete===!0)s.manager.itemStart(e),setTimeout(function(){t&&t(a),s.manager.itemEnd(e)},0);else{let d=ea.get(a);d===void 0&&(d=[],ea.set(a,d)),d.push({onLoad:t,onError:r})}return a}let o=aa("img");function l(){h(),t&&t(this);let d=ea.get(this)||[];for(let f=0;f<d.length;f++){let p=d[f];p.onLoad&&p.onLoad(this)}ea.delete(this),s.manager.itemEnd(e)}function c(d){h(),r&&r(d),Vi.remove(`image:${e}`);let f=ea.get(this)||[];for(let p=0;p<f.length;p++){let x=f[p];x.onError&&x.onError(d)}ea.delete(this),s.manager.itemError(e),s.manager.itemEnd(e)}function h(){o.removeEventListener("load",l,!1),o.removeEventListener("error",c,!1)}return o.addEventListener("load",l,!1),o.addEventListener("error",c,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(o.crossOrigin=this.crossOrigin),Vi.add(`image:${e}`,o),s.manager.itemStart(e),o.src=e,o}},xo=class extends oi{constructor(e){super(e)}load(e,t,n,r){let s=this,a=new xs,o=new Yi(this.manager);return o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setPath(this.path),o.setWithCredentials(s.withCredentials),o.load(e,function(l){let c;try{c=s.parse(l)}catch(h){r!==void 0?r(h):et(h);return}c.image!==void 0?a.image=c.image:c.data!==void 0&&(a.image.width=c.width,a.image.height=c.height,a.image.data=c.data),a.wrapS=c.wrapS!==void 0?c.wrapS:Kn,a.wrapT=c.wrapT!==void 0?c.wrapT:Kn,a.magFilter=c.magFilter!==void 0?c.magFilter:zt,a.minFilter=c.minFilter!==void 0?c.minFilter:zt,a.anisotropy=c.anisotropy!==void 0?c.anisotropy:1,c.colorSpace!==void 0&&(a.colorSpace=c.colorSpace),c.flipY!==void 0&&(a.flipY=c.flipY),c.format!==void 0&&(a.format=c.format),c.type!==void 0&&(a.type=c.type),c.mipmaps!==void 0&&(a.mipmaps=c.mipmaps,a.minFilter=xi),c.mipmapCount===1&&(a.minFilter=zt),c.generateMipmaps!==void 0&&(a.generateMipmaps=c.generateMipmaps),a.needsUpdate=!0,t&&t(a,c)},n,r),a}},_o=class extends oi{constructor(e){super(e)}load(e,t,n,r){let s=new xn,a=new vl(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(e,function(o){s.image=o,s.needsUpdate=!0,t!==void 0&&t(s)},n,r),s}},Vr=class extends qt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Ve(e),this.intensity=t}dispose(){this.dispatchEvent({type:"dispose"})}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,t}},ma=class extends Vr{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(qt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Ve(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}toJSON(e){let t=super.toJSON(e);return t.object.groundColor=this.groundColor.getHex(),t}},od=new ot,Bg=new W,zg=new W,yo=class{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new dt(512,512),this.mapType=Qn,this.map=null,this.mapPass=null,this.matrix=new ot,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new da,this._frameExtents=new dt(1,1),this._viewportCount=1,this._viewports=[new kt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera,n=this.matrix;Bg.setFromMatrixPosition(e.matrixWorld),t.position.copy(Bg),zg.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(zg),t.updateMatrixWorld(),od.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(od,t.coordinateSystem,t.reversedDepth),t.coordinateSystem===sa||t.reversedDepth?n.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(od)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this.biasNode=e.biasNode,this}clone(){return new this.constructor().copy(this)}toJSON(){let e={};return this.intensity!==1&&(e.intensity=this.intensity),this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}},jc=new W,Xc=new Pt,Hi=new W,vo=class extends qt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new ot,this.projectionMatrix=new ot,this.projectionMatrixInverse=new ot,this.coordinateSystem=Ci,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorld.decompose(jc,Xc,Hi),Hi.x===1&&Hi.y===1&&Hi.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(jc,Xc,Hi.set(1,1,1)).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorld.decompose(jc,Xc,Hi),Hi.x===1&&Hi.y===1&&Hi.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(jc,Xc,Hi.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}},Pr=new W,Hg=new dt,Gg=new dt,an=class extends vo{constructor(e=50,t=1,n=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=r,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){let t=.5*this.getFilmHeight()/e;this.fov=bs*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(Ya*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return bs*2*Math.atan(Math.tan(Ya*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){Pr.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(Pr.x,Pr.y).multiplyScalar(-e/Pr.z),Pr.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Pr.x,Pr.y).multiplyScalar(-e/Pr.z)}getViewSize(e,t){return this.getViewBounds(e,Hg,Gg),t.subVectors(Gg,Hg)}setViewOffset(e,t,n,r,s,a){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(Ya*.5*this.fov)/this.zoom,n=2*t,r=this.aspect*n,s=-.5*r,a=this.view;if(this.view!==null&&this.view.enabled){let l=a.fullWidth,c=a.fullHeight;s+=a.offsetX*r/l,t-=a.offsetY*n/c,r*=a.width/l,n*=a.height/c}let o=this.filmOffset;o!==0&&(s+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+r,t,t-n,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}},md=class extends yo{constructor(){super(new an(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){let t=this.camera,n=bs*2*e.angle*this.focus,r=this.mapSize.width/this.mapSize.height*this.aspect,s=e.distance||t.far;(n!==t.fov||r!==t.aspect||s!==t.far)&&(t.fov=n,t.aspect=r,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}},So=class extends Vr{constructor(e,t,n=0,r=Math.PI/3,s=0,a=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(qt.DEFAULT_UP),this.updateMatrix(),this.target=new qt,this.distance=n,this.angle=r,this.penumbra=s,this.decay=a,this.map=null,this.shadow=new md}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){super.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.map=e.map,this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);return t.object.distance=this.distance,t.object.angle=this.angle,t.object.decay=this.decay,t.object.penumbra=this.penumbra,t.object.target=this.target.uuid,this.map&&this.map.isTexture&&(t.object.map=this.map.toJSON(e).uuid),t.object.shadow=this.shadow.toJSON(),t}},gd=class extends yo{constructor(){super(new an(90,1,.5,500)),this.isPointLightShadow=!0}},ws=class extends Vr{constructor(e,t,n=0,r=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=r,this.shadow=new gd}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){super.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}toJSON(e){let t=super.toJSON(e);return t.object.distance=this.distance,t.object.decay=this.decay,t.object.shadow=this.shadow.toJSON(),t}},Wr=class extends vo{constructor(e=-1,t=1,n=1,r=-1,s=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=r,this.near=s,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,r,s,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,r=(this.top+this.bottom)/2,s=n-e,a=n+e,o=r+t,l=r-t;if(this.view!==null&&this.view.enabled){let c=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=c*this.view.offsetX,a=s+c*this.view.width,o-=h*this.view.offsetY,l=o-h*this.view.height}this.projectionMatrix.makeOrthographic(s,a,o,l,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}},bd=class extends yo{constructor(){super(new Wr(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},Di=class extends Vr{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(qt.DEFAULT_UP),this.updateMatrix(),this.target=new qt,this.shadow=new bd}dispose(){super.dispose(),this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);return t.object.shadow=this.shadow.toJSON(),t.object.target=this.target.uuid,t}},Sl=class{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new W)}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){let n=e.x,r=e.y,s=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.282095),t.addScaledVector(a[1],.488603*r),t.addScaledVector(a[2],.488603*s),t.addScaledVector(a[3],.488603*n),t.addScaledVector(a[4],1.092548*(n*r)),t.addScaledVector(a[5],1.092548*(r*s)),t.addScaledVector(a[6],.315392*(3*s*s-1)),t.addScaledVector(a[7],1.092548*(n*s)),t.addScaledVector(a[8],.546274*(n*n-r*r)),t}getIrradianceAt(e,t){let n=e.x,r=e.y,s=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.886227),t.addScaledVector(a[1],2*.511664*r),t.addScaledVector(a[2],2*.511664*s),t.addScaledVector(a[3],2*.511664*n),t.addScaledVector(a[4],2*.429043*n*r),t.addScaledVector(a[5],2*.429043*r*s),t.addScaledVector(a[6],.743125*s*s-.247708),t.addScaledVector(a[7],2*.429043*n*s),t.addScaledVector(a[8],.429043*(n*n-r*r)),t}add(e){for(let t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}addScaledSH(e,t){for(let n=0;n<9;n++)this.coefficients[n].addScaledVector(e.coefficients[n],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let n=0;n<9;n++)this.coefficients[n].lerp(e.coefficients[n],t);return this}equals(e){for(let t=0;t<9;t++)if(!this.coefficients[t].equals(e.coefficients[t]))return!1;return!0}copy(e){return this.set(e.coefficients)}clone(){return new this.constructor().copy(this)}fromArray(e,t=0){let n=this.coefficients;for(let r=0;r<9;r++)n[r].fromArray(e,t+r*3);return this}toArray(e=[],t=0){let n=this.coefficients;for(let r=0;r<9;r++)n[r].toArray(e,t+r*3);return e}static getBasisAt(e,t){let n=e.x,r=e.y,s=e.z;t[0]=.282095,t[1]=.488603*r,t[2]=.488603*s,t[3]=.488603*n,t[4]=1.092548*n*r,t[5]=1.092548*r*s,t[6]=.315392*(3*s*s-1),t[7]=1.092548*n*s,t[8]=.546274*(n*n-r*r)}},wo=class extends Vr{constructor(e=new Sl,t=1){super(void 0,t),this.isLightProbe=!0,this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}toJSON(e){let t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}},br=class{static extractUrlBase(e){let t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}},cd=new WeakMap,Mo=class extends oi{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&Ke("ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&Ke("ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(e){return this.options=e,this}load(e,t,n,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let s=this,a=Vi.get(`image-bitmap:${e}`);if(a!==void 0){if(s.manager.itemStart(e),a.then){a.then(c=>{cd.has(a)===!0?(r&&r(cd.get(a)),s.manager.itemError(e),s.manager.itemEnd(e)):(t&&t(c),s.manager.itemEnd(e))});return}setTimeout(function(){t&&t(a),s.manager.itemEnd(e)},0);return}let o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader,o.signal=typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;let l=fetch(e,o).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(c){Vi.add(`image-bitmap:${e}`,c),t&&t(c),s.manager.itemEnd(e)}).catch(function(c){r&&r(c),cd.set(l,c),Vi.remove(`image-bitmap:${e}`),s.manager.itemError(e),s.manager.itemEnd(e)});Vi.add(`image-bitmap:${e}`,l),s.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}},ta=-90,na=1,wl=class extends qt{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let r=new an(ta,na,e,t);r.layers=this.layers,this.add(r);let s=new an(ta,na,e,t);s.layers=this.layers,this.add(s);let a=new an(ta,na,e,t);a.layers=this.layers,this.add(a);let o=new an(ta,na,e,t);o.layers=this.layers,this.add(o);let l=new an(ta,na,e,t);l.layers=this.layers,this.add(l);let c=new an(ta,na,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[n,r,s,a,o,l]=t;for(let c of t)this.remove(c);if(e===Ci)n.up.set(0,1,0),n.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===sa)n.up.set(0,-1,0),n.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(let c of t)this.add(c),c.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();let{renderTarget:n,activeMipmapLevel:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());let[s,a,o,l,c,h]=this.children,d=e.getRenderTarget(),f=e.getActiveCubeFace(),p=e.getActiveMipmapLevel(),x=e.xr.enabled;e.xr.enabled=!1;let y=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let b=!1;e.isWebGLRenderer===!0?b=e.state.buffers.depth.getReversed():b=e.reversedDepthBuffer,e.setRenderTarget(n,0,r),b&&e.autoClear===!1&&e.clearDepth(),e.render(t,s),e.setRenderTarget(n,1,r),b&&e.autoClear===!1&&e.clearDepth(),e.render(t,a),e.setRenderTarget(n,2,r),b&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(n,3,r),b&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),e.setRenderTarget(n,4,r),b&&e.autoClear===!1&&e.clearDepth(),e.render(t,c),n.texture.generateMipmaps=y,e.setRenderTarget(n,5,r),b&&e.autoClear===!1&&e.clearDepth(),e.render(t,h),e.setRenderTarget(d,f,p),e.xr.enabled=x,n.texture.needsPMREMUpdate=!0}},Ml=class extends an{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}},Al=class{constructor(e,t,n){this.binding=e,this.valueSize=n;let r,s,a;switch(t){case"quaternion":r=this._slerp,s=this._slerpAdditive,a=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(n*6),this._workIndex=5;break;case"string":case"bool":r=this._select,s=this._select,a=this._setAdditiveIdentityOther,this.buffer=new Array(n*5);break;default:r=this._lerp,s=this._lerpAdditive,a=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(n*5)}this._mixBufferRegion=r,this._mixBufferRegionAdditive=s,this._setIdentity=a,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){let n=this.buffer,r=this.valueSize,s=e*r+r,a=this.cumulativeWeight;if(a===0){for(let o=0;o!==r;++o)n[s+o]=n[o];a=t}else{a+=t;let o=t/a;this._mixBufferRegion(n,s,0,o,r)}this.cumulativeWeight=a}accumulateAdditive(e){let t=this.buffer,n=this.valueSize,r=n*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,r,0,e,n),this.cumulativeWeightAdditive+=e}apply(e){let t=this.valueSize,n=this.buffer,r=e*t+t,s=this.cumulativeWeight,a=this.cumulativeWeightAdditive,o=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,s<1){let l=t*this._origIndex;this._mixBufferRegion(n,r,l,1-s,t)}a>0&&this._mixBufferRegionAdditive(n,r,this._addIndex*t,1,t);for(let l=t,c=t+t;l!==c;++l)if(n[l]!==n[l+t]){o.setValue(n,r);break}}saveOriginalState(){let e=this.binding,t=this.buffer,n=this.valueSize,r=n*this._origIndex;e.getValue(t,r);for(let s=n,a=r;s!==a;++s)t[s]=t[r+s%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){let 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(){let e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let n=0;n<this.valueSize;n++)this.buffer[t+n]=this.buffer[e+n]}_select(e,t,n,r,s){if(r>=.5)for(let a=0;a!==s;++a)e[t+a]=e[n+a]}_slerp(e,t,n,r){Pt.slerpFlat(e,t,e,t,e,n,r)}_slerpAdditive(e,t,n,r,s){let a=this._workIndex*s;Pt.multiplyQuaternionsFlat(e,a,e,t,e,n),Pt.slerpFlat(e,t,e,t,e,a,r)}_lerp(e,t,n,r,s){let a=1-r;for(let o=0;o!==s;++o){let l=t+o;e[l]=e[l]*a+e[n+o]*r}}_lerpAdditive(e,t,n,r,s){for(let a=0;a!==s;++a){let o=t+a;e[o]=e[o]+e[n+a]*r}}},Wd="\\[\\]\\.:\\/",bS=new RegExp("["+Wd+"]","g"),qd="[^"+Wd+"]",xS="[^"+Wd.replace("\\.","")+"]",_S=/((?:WC+[\/:])*)/.source.replace("WC",qd),yS=/(WCOD+)?/.source.replace("WCOD",xS),vS=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",qd),SS=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",qd),wS=new RegExp("^"+_S+yS+vS+SS+"$"),MS=["material","materials","bones","map"],xd=class{constructor(e,t,n){let r=n||Ut.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,r=this._bindings[n];r!==void 0&&r.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let r=this._targetGroup.nCachedObjects_,s=n.length;r!==s;++r)n[r].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}},Ut=class i{constructor(e,t,n){this.path=t,this.parsedPath=n||i.parseTrackName(t),this.node=i.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new i.Composite(e,t,n):new i(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(bS,"")}static parseTrackName(e){let t=wS.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);let n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=n.nodeName&&n.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){let s=n.nodeName.substring(r+1);MS.indexOf(s)!==-1&&(n.nodeName=n.nodeName.substring(0,r),n.objectName=s)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){let n=function(s){for(let a=0;a<s.length;a++){let o=s[a];if(o.name===t||o.uuid===t)return o;let l=n(o.children);if(l)return l}return null},r=n(e.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let n=this.resolvedProperty;for(let r=0,s=n.length;r!==s;++r)e[t++]=n[r]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let n=this.resolvedProperty;for(let r=0,s=n.length;r!==s;++r)n[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let n=this.resolvedProperty;for(let r=0,s=n.length;r!==s;++r)n[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let n=this.resolvedProperty;for(let r=0,s=n.length;r!==s;++r)n[r]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node,t=this.parsedPath,n=t.objectName,r=t.propertyName,s=t.propertyIndex;if(e||(e=i.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){Ke("PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let c=t.objectIndex;switch(n){case"materials":if(!e.material){et("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){et("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){et("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let h=0;h<e.length;h++)if(e[h].name===c){c=h;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){et("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){et("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[n]===void 0){et("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(c!==void 0){if(e[c]===void 0){et("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}let a=e[r];if(a===void 0){let c=t.nodeName;et("PropertyBinding: Trying to update property for track: "+c+"."+r+" but it wasn't found.",e);return}let o=this.Versioning.None;this.targetObject=e,e.isMaterial===!0?o=this.Versioning.NeedsUpdate:e.isObject3D===!0&&(o=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(s!==void 0){if(r==="morphTargetInfluences"){if(!e.geometry){et("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){et("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[s]!==void 0&&(s=e.morphTargetDictionary[s])}l=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=s}else a.fromArray!==void 0&&a.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(l=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=r;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};Ut.Composite=xd;Ut.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Ut.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Ut.prototype.GetterByBindingType=[Ut.prototype._getValue_direct,Ut.prototype._getValue_array,Ut.prototype._getValue_arrayElement,Ut.prototype._getValue_toArray];Ut.prototype.SetterByBindingTypeAndVersioning=[[Ut.prototype._setValue_direct,Ut.prototype._setValue_direct_setNeedsUpdate,Ut.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Ut.prototype._setValue_array,Ut.prototype._setValue_array_setNeedsUpdate,Ut.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Ut.prototype._setValue_arrayElement,Ut.prototype._setValue_arrayElement_setNeedsUpdate,Ut.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Ut.prototype._setValue_fromArray,Ut.prototype._setValue_fromArray_setNeedsUpdate,Ut.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];Tl=class{constructor(e,t,n=null,r=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=r;let s=t.tracks,a=s.length,o=new Array(a),l={endingStart:hs,endingEnd:hs};for(let c=0;c!==a;++c){let h=s[c].createInterpolant(null);o[c]=h,h.settings&&Object.assign(l,h.settings),h.settings=l}this._interpolantSettings=l,this._interpolants=o,this._propertyBindings=new Array(a),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=Fo,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,n=!1){if(e.fadeOut(t),this.fadeIn(t),n===!0){let r=this._clip.duration,s=e._clip.duration,a=s/r,o=r/s;e.warp(1,a,t),this.warp(o,1,t)}return this}crossFadeTo(e,t,n=!1){return e.crossFadeFrom(this,t,n)}stopFading(){let e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,n){let r=this._mixer,s=r.time,a=this.timeScale,o=this._timeScaleInterpolant;o===null&&(o=r._lendControlInterpolant(),this._timeScaleInterpolant=o);let l=o.parameterPositions,c=o.sampleValues;return l[0]=s,l[1]=s+n,c[0]=e/a,c[1]=t/a,this}stopWarping(){let e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,n,r){if(!this.enabled){this._updateWeight(e);return}let s=this._startTime;if(s!==null){let l=(e-s)*n;l<0||n===0?t=0:(this._startTime=null,t=n*l)}t*=this._updateTimeScale(e);let a=this._updateTime(t),o=this._updateWeight(e);if(o>0){let l=this._interpolants,c=this._propertyBindings;switch(this.blendMode){case Uo:for(let h=0,d=l.length;h!==d;++h)l[h].evaluate(a),c[h].accumulateAdditive(o);break;case mh:default:for(let h=0,d=l.length;h!==d;++h)l[h].evaluate(a),c[h].accumulate(r,o)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;let n=this._weightInterpolant;if(n!==null){let r=n.evaluate(e)[0];t*=r,e>n.parameterPositions[1]&&(this.stopFading(),r===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;let n=this._timeScaleInterpolant;if(n!==null){let r=n.evaluate(e)[0];t*=r,e>n.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){let t=this._clip.duration,n=this.loop,r=this.time+e,s=this._loopCount,a=n===m0;if(e===0)return s===-1?r:a&&(s&1)===1?t-r:r;if(n===_a){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(r>=t)r=t;else if(r<0)r=0;else{this.time=r;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(s===-1&&(e>=0?(s=0,this._setEndings(!0,this.repetitions===0,a)):this._setEndings(this.repetitions===0,!0,a)),r>=t||r<0){let o=Math.floor(r/t);r-=t*o,s+=Math.abs(o);let l=this.repetitions-s;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,r=e>0?t:0,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(l===1){let c=e<0;this._setEndings(c,!c,a)}else this._setEndings(!1,!1,a);this._loopCount=s,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this._loopCount=s,this.time=r;if(a&&(s&1)===1)return t-r}return r}_setEndings(e,t,n){let r=this._interpolantSettings;n?(r.endingStart=us,r.endingEnd=us):(e?r.endingStart=this.zeroSlopeAtStart?us:hs:r.endingStart=Za,t?r.endingEnd=this.zeroSlopeAtEnd?us:hs:r.endingEnd=Za)}_scheduleFading(e,t,n){let r=this._mixer,s=r.time,a=this._weightInterpolant;a===null&&(a=r._lendControlInterpolant(),this._weightInterpolant=a);let o=a.parameterPositions,l=a.sampleValues;return o[0]=s,l[0]=t,o[1]=s+e,l[1]=n,this}},AS=new Float32Array(1),Ms=class extends Li{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}_bindAction(e,t){let n=e._localRoot||this._root,r=e._clip.tracks,s=r.length,a=e._propertyBindings,o=e._interpolants,l=n.uuid,c=this._bindingsByRootAndName,h=c[l];h===void 0&&(h={},c[l]=h);for(let d=0;d!==s;++d){let f=r[d],p=f.name,x=h[p];if(x!==void 0)++x.referenceCount,a[d]=x;else{if(x=a[d],x!==void 0){x._cacheIndex===null&&(++x.referenceCount,this._addInactiveBinding(x,l,p));continue}let y=t&&t._propertyBindings[d].binding.parsedPath;x=new Al(Ut.create(n,p,y),f.ValueTypeName,f.getValueSize()),++x.referenceCount,this._addInactiveBinding(x,l,p),a[d]=x}o[d].resultBuffer=x.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){let n=(e._localRoot||this._root).uuid,r=e._clip.uuid,s=this._actionsByClip[r];this._bindAction(e,s&&s.knownActions[0]),this._addInactiveAction(e,r,n)}let t=e._propertyBindings;for(let n=0,r=t.length;n!==r;++n){let s=t[n];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){let t=e._propertyBindings;for(let n=0,r=t.length;n!==r;++n){let s=t[n];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let 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){let t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,n){let r=this._actions,s=this._actionsByClip,a=s[t];if(a===void 0)a={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,s[t]=a;else{let o=a.knownActions;e._byClipCacheIndex=o.length,o.push(e)}e._cacheIndex=r.length,r.push(e),a.actionByRoot[n]=e}_removeInactiveAction(e){let t=this._actions,n=t[t.length-1],r=e._cacheIndex;n._cacheIndex=r,t[r]=n,t.pop(),e._cacheIndex=null;let s=e._clip.uuid,a=this._actionsByClip,o=a[s],l=o.knownActions,c=l[l.length-1],h=e._byClipCacheIndex;c._byClipCacheIndex=h,l[h]=c,l.pop(),e._byClipCacheIndex=null;let d=o.actionByRoot,f=(e._localRoot||this._root).uuid;delete d[f],l.length===0&&delete a[s],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){let t=e._propertyBindings;for(let n=0,r=t.length;n!==r;++n){let s=t[n];--s.referenceCount===0&&this._removeInactiveBinding(s)}}_lendAction(e){let t=this._actions,n=e._cacheIndex,r=this._nActiveActions++,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=n,t[n]=s}_takeBackAction(e){let t=this._actions,n=e._cacheIndex,r=--this._nActiveActions,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=n,t[n]=s}_addInactiveBinding(e,t,n){let r=this._bindingsByRootAndName,s=this._bindings,a=r[t];a===void 0&&(a={},r[t]=a),a[n]=e,e._cacheIndex=s.length,s.push(e)}_removeInactiveBinding(e){let t=this._bindings,n=e.binding,r=n.rootNode.uuid,s=n.path,a=this._bindingsByRootAndName,o=a[r],l=t[t.length-1],c=e._cacheIndex;l._cacheIndex=c,t[c]=l,t.pop(),delete o[s],Object.keys(o).length===0&&delete a[r]}_lendBinding(e){let t=this._bindings,n=e._cacheIndex,r=this._nActiveBindings++,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=n,t[n]=s}_takeBackBinding(e){let t=this._bindings,n=e._cacheIndex,r=--this._nActiveBindings,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=n,t[n]=s}_lendControlInterpolant(){let e=this._controlInterpolants,t=this._nActiveControlInterpolants++,n=e[t];return n===void 0&&(n=new go(new Float32Array(2),new Float32Array(2),1,AS),n.__cacheIndex=t,e[t]=n),n}_takeBackControlInterpolant(e){let t=this._controlInterpolants,n=e.__cacheIndex,r=--this._nActiveControlInterpolants,s=t[r];e.__cacheIndex=r,t[r]=e,s.__cacheIndex=n,t[n]=s}clipAction(e,t,n){let r=t||this._root,s=r.uuid,a=typeof e=="string"?bi.findByName(r,e):e,o=a!==null?a.uuid:e,l=this._actionsByClip[o],c=null;if(n===void 0&&(a!==null?n=a.blendMode:n=mh),l!==void 0){let d=l.actionByRoot[s];if(d!==void 0&&d.blendMode===n)return d;c=l.knownActions[0],a===null&&(a=c._clip)}if(a===null)return null;let h=new Tl(this,a,t,n);return this._bindAction(h,c),this._addInactiveAction(h,o,s),h}existingAction(e,t){let n=t||this._root,r=n.uuid,s=typeof e=="string"?bi.findByName(n,e):e,a=s?s.uuid:e,o=this._actionsByClip[a];return o!==void 0&&o.actionByRoot[r]||null}stopAllAction(){let e=this._actions,t=this._nActiveActions;for(let n=t-1;n>=0;--n)e[n].stop();return this}update(e){e*=this.timeScale;let t=this._actions,n=this._nActiveActions,r=this.time+=e,s=Math.sign(e),a=this._accuIndex^=1;for(let c=0;c!==n;++c)t[c]._update(r,e,s,a);let o=this._bindings,l=this._nActiveBindings;for(let c=0;c!==l;++c)o[c].apply(a);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){let t=this._actions,n=e.uuid,r=this._actionsByClip,s=r[n];if(s!==void 0){let a=s.knownActions;for(let o=0,l=a.length;o!==l;++o){let c=a[o];this._deactivateAction(c);let h=c._cacheIndex,d=t[t.length-1];c._cacheIndex=null,c._byClipCacheIndex=null,d._cacheIndex=h,t[h]=d,t.pop(),this._removeInactiveBindingsForAction(c)}delete r[n]}}uncacheRoot(e){let t=e.uuid,n=this._actionsByClip;for(let a in n){let o=n[a].actionByRoot,l=o[t];l!==void 0&&(this._deactivateAction(l),this._removeInactiveAction(l))}let r=this._bindingsByRootAndName,s=r[t];if(s!==void 0)for(let a in s){let o=s[a];o.restoreOriginalState(),this._removeInactiveBinding(o)}}uncacheAction(e,t){let n=this.existingAction(e,t);n!==null&&(this._deactivateAction(n),this._removeInactiveAction(n))}},Vg=new ot,Ao=class{constructor(e,t,n=0,r=1/0){this.ray=new Br(e,t),this.near=n,this.far=r,this.camera=null,this.layers=new la,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):et("Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return Vg.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(Vg),this}intersectObject(e,t=!0,n=[]){return _d(e,this,n,t),n.sort(Wg),n}intersectObjects(e,t=!0,n=[]){for(let r=0,s=e.length;r<s;r++)_d(e[r],this,n,t);return n.sort(Wg),n}};Jd=class Jd{constructor(e,t,n,r){this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,n,r)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let n=0;n<4;n++)this.elements[n]=e[n+t];return this}set(e,t,n,r){let s=this.elements;return s[0]=e,s[2]=t,s[1]=n,s[3]=r,this}};Jd.prototype.isMatrix2=!0;yd=Jd,To=class extends fa{constructor(e=10,t=10,n=4473924,r=8947848){n=new Ve(n),r=new Ve(r);let s=t/2,a=e/t,o=e/2,l=[],c=[];for(let f=0,p=0,x=-o;f<=t;f++,x+=a){l.push(-o,0,x,o,0,x),l.push(x,0,-o,x,0,o);let y=f===s?n:r;y.toArray(c,p),p+=3,y.toArray(c,p),p+=3,y.toArray(c,p),p+=3,y.toArray(c,p),p+=3}let h=new mn;h.setAttribute("position",new Qt(l,3)),h.setAttribute("color",new Qt(c,3));let d=new ys({vertexColors:!0,toneMapped:!1});super(h,d),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}};typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"184"}}));typeof window<"u"&&(window.__THREE__?Ke("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="184")});function tb(){let i=null,e=!1,t=null,n=null;function r(s,a){t(s,a),n=i.requestAnimationFrame(r)}return{start:function(){e!==!0&&t!==null&&i!==null&&(n=i.requestAnimationFrame(r),e=!0)},stop:function(){i!==null&&i.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(s){t=s},setContext:function(s){i=s}}}function RS(i){let e=new WeakMap;function t(o,l){let c=o.array,h=o.usage,d=c.byteLength,f=i.createBuffer();i.bindBuffer(l,f),i.bufferData(l,c,h),o.onUploadCallback();let p;if(c instanceof Float32Array)p=i.FLOAT;else if(typeof Float16Array<"u"&&c instanceof Float16Array)p=i.HALF_FLOAT;else if(c instanceof Uint16Array)o.isFloat16BufferAttribute?p=i.HALF_FLOAT:p=i.UNSIGNED_SHORT;else if(c instanceof Int16Array)p=i.SHORT;else if(c instanceof Uint32Array)p=i.UNSIGNED_INT;else if(c instanceof Int32Array)p=i.INT;else if(c instanceof Int8Array)p=i.BYTE;else if(c instanceof Uint8Array)p=i.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)p=i.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:f,type:p,bytesPerElement:c.BYTES_PER_ELEMENT,version:o.version,size:d}}function n(o,l,c){let h=l.array,d=l.updateRanges;if(i.bindBuffer(c,o),d.length===0)i.bufferSubData(c,0,h);else{d.sort((p,x)=>p.start-x.start);let f=0;for(let p=1;p<d.length;p++){let x=d[f],y=d[p];y.start<=x.start+x.count+1?x.count=Math.max(x.count,y.start+y.count-x.start):(++f,d[f]=y)}d.length=f+1;for(let p=0,x=d.length;p<x;p++){let y=d[p];i.bufferSubData(c,y.start*h.BYTES_PER_ELEMENT,h,y.start,y.count)}l.clearUpdateRanges()}l.onUploadCallback()}function r(o){return o.isInterleavedBufferAttribute&&(o=o.data),e.get(o)}function s(o){o.isInterleavedBufferAttribute&&(o=o.data);let l=e.get(o);l&&(i.deleteBuffer(l.buffer),e.delete(o))}function a(o,l){if(o.isInterleavedBufferAttribute&&(o=o.data),o.isGLBufferAttribute){let h=e.get(o);(!h||h.version<o.version)&&e.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}let c=e.get(o);if(c===void 0)e.set(o,t(o,l));else if(c.version<o.version){if(c.size!==o.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");n(c.buffer,o,l),c.version=o.version}}return{get:r,remove:s,update:a}}function hM(i,e,t,n,r,s){let a=new Ve(0),o=r===!0?0:1,l,c,h=null,d=0,f=null;function p(S){let A=S.isScene===!0?S.background:null;if(A&&A.isTexture){let T=S.backgroundBlurriness>0;A=e.get(A,T)}return A}function x(S){let A=!1,T=p(S);T===null?b(a,o):T&&T.isColor&&(b(T,1),A=!0);let N=i.xr.getEnvironmentBlendMode();N==="additive"?t.buffers.color.setClear(0,0,0,1,s):N==="alpha-blend"&&t.buffers.color.setClear(0,0,0,0,s),(i.autoClear||A)&&(t.buffers.depth.setTest(!0),t.buffers.depth.setMask(!0),t.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function y(S,A){let T=p(A);T&&(T.isCubeTexture||T.mapping===Co)?(c===void 0&&(c=new xt(new Hr(1,1,1),new ai({name:"BackgroundCubeMaterial",uniforms:Es(Qi.backgroundCube.uniforms),vertexShader:Qi.backgroundCube.vertexShader,fragmentShader:Qi.backgroundCube.fragmentShader,side:An,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(N,P,U){this.matrixWorld.copyPosition(U.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(c)),c.material.uniforms.envMap.value=T,c.material.uniforms.backgroundBlurriness.value=A.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=A.backgroundIntensity,c.material.uniforms.backgroundRotation.value.setFromMatrix4(lM.makeRotationFromEuler(A.backgroundRotation)).transpose(),T.isCubeTexture&&T.isRenderTargetTexture===!1&&c.material.uniforms.backgroundRotation.value.premultiply(nb),c.material.toneMapped=ut.getTransfer(T.colorSpace)!==Dt,(h!==T||d!==T.version||f!==i.toneMapping)&&(c.material.needsUpdate=!0,h=T,d=T.version,f=i.toneMapping),c.layers.enableAll(),S.unshift(c,c.geometry,c.material,0,0,null)):T&&T.isTexture&&(l===void 0&&(l=new xt(new mi(2,2),new ai({name:"BackgroundMaterial",uniforms:Es(Qi.background.uniforms),vertexShader:Qi.background.vertexShader,fragmentShader:Qi.background.fragmentShader,side:Pi,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(l)),l.material.uniforms.t2D.value=T,l.material.uniforms.backgroundIntensity.value=A.backgroundIntensity,l.material.toneMapped=ut.getTransfer(T.colorSpace)!==Dt,T.matrixAutoUpdate===!0&&T.updateMatrix(),l.material.uniforms.uvTransform.value.copy(T.matrix),(h!==T||d!==T.version||f!==i.toneMapping)&&(l.material.needsUpdate=!0,h=T,d=T.version,f=i.toneMapping),l.layers.enableAll(),S.unshift(l,l.geometry,l.material,0,0,null))}function b(S,A){S.getRGB(xh,Gd(i)),t.buffers.color.setClear(xh.r,xh.g,xh.b,A,s)}function g(){c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0),l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0)}return{getClearColor:function(){return a},setClearColor:function(S,A=1){a.set(S),o=A,b(a,o)},getClearAlpha:function(){return o},setClearAlpha:function(S){o=S,b(a,o)},render:x,addToRenderList:y,dispose:g}}function uM(i,e){let t=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},r=f(null),s=r,a=!1;function o(k,V,J,L,E){let D=!1,O=d(k,L,J,V);s!==O&&(s=O,c(s.object)),D=p(k,L,J,E),D&&x(k,L,J,E),E!==null&&e.update(E,i.ELEMENT_ARRAY_BUFFER),(D||a)&&(a=!1,T(k,V,J,L),E!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.get(E).buffer))}function l(){return i.createVertexArray()}function c(k){return i.bindVertexArray(k)}function h(k){return i.deleteVertexArray(k)}function d(k,V,J,L){let E=L.wireframe===!0,D=n[V.id];D===void 0&&(D={},n[V.id]=D);let O=k.isInstancedMesh===!0?k.id:0,H=D[O];H===void 0&&(H={},D[O]=H);let Y=H[J.id];Y===void 0&&(Y={},H[J.id]=Y);let le=Y[E];return le===void 0&&(le=f(l()),Y[E]=le),le}function f(k){let V=[],J=[],L=[];for(let E=0;E<t;E++)V[E]=0,J[E]=0,L[E]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:V,enabledAttributes:J,attributeDivisors:L,object:k,attributes:{},index:null}}function p(k,V,J,L){let E=s.attributes,D=V.attributes,O=0,H=J.getAttributes();for(let Y in H)if(H[Y].location>=0){let fe=E[Y],be=D[Y];if(be===void 0&&(Y==="instanceMatrix"&&k.instanceMatrix&&(be=k.instanceMatrix),Y==="instanceColor"&&k.instanceColor&&(be=k.instanceColor)),fe===void 0||fe.attribute!==be||be&&fe.data!==be.data)return!0;O++}return s.attributesNum!==O||s.index!==L}function x(k,V,J,L){let E={},D=V.attributes,O=0,H=J.getAttributes();for(let Y in H)if(H[Y].location>=0){let fe=D[Y];fe===void 0&&(Y==="instanceMatrix"&&k.instanceMatrix&&(fe=k.instanceMatrix),Y==="instanceColor"&&k.instanceColor&&(fe=k.instanceColor));let be={};be.attribute=fe,fe&&fe.data&&(be.data=fe.data),E[Y]=be,O++}s.attributes=E,s.attributesNum=O,s.index=L}function y(){let k=s.newAttributes;for(let V=0,J=k.length;V<J;V++)k[V]=0}function b(k){g(k,0)}function g(k,V){let J=s.newAttributes,L=s.enabledAttributes,E=s.attributeDivisors;J[k]=1,L[k]===0&&(i.enableVertexAttribArray(k),L[k]=1),E[k]!==V&&(i.vertexAttribDivisor(k,V),E[k]=V)}function S(){let k=s.newAttributes,V=s.enabledAttributes;for(let J=0,L=V.length;J<L;J++)V[J]!==k[J]&&(i.disableVertexAttribArray(J),V[J]=0)}function A(k,V,J,L,E,D,O){O===!0?i.vertexAttribIPointer(k,V,J,E,D):i.vertexAttribPointer(k,V,J,L,E,D)}function T(k,V,J,L){y();let E=L.attributes,D=J.getAttributes(),O=V.defaultAttributeValues;for(let H in D){let Y=D[H];if(Y.location>=0){let le=E[H];if(le===void 0&&(H==="instanceMatrix"&&k.instanceMatrix&&(le=k.instanceMatrix),H==="instanceColor"&&k.instanceColor&&(le=k.instanceColor)),le!==void 0){let fe=le.normalized,be=le.itemSize,Te=e.get(le);if(Te===void 0)continue;let Je=Te.buffer,ke=Te.type,oe=Te.bytesPerElement,Ee=ke===i.INT||ke===i.UNSIGNED_INT||le.gpuType===Ll;if(le.isInterleavedBufferAttribute){let _e=le.data,Ze=_e.stride,tt=le.offset;if(_e.isInstancedInterleavedBuffer){for(let Qe=0;Qe<Y.locationSize;Qe++)g(Y.location+Qe,_e.meshPerAttribute);k.isInstancedMesh!==!0&&L._maxInstanceCount===void 0&&(L._maxInstanceCount=_e.meshPerAttribute*_e.count)}else for(let Qe=0;Qe<Y.locationSize;Qe++)b(Y.location+Qe);i.bindBuffer(i.ARRAY_BUFFER,Je);for(let Qe=0;Qe<Y.locationSize;Qe++)A(Y.location+Qe,be/Y.locationSize,ke,fe,Ze*oe,(tt+be/Y.locationSize*Qe)*oe,Ee)}else{if(le.isInstancedBufferAttribute){for(let _e=0;_e<Y.locationSize;_e++)g(Y.location+_e,le.meshPerAttribute);k.isInstancedMesh!==!0&&L._maxInstanceCount===void 0&&(L._maxInstanceCount=le.meshPerAttribute*le.count)}else for(let _e=0;_e<Y.locationSize;_e++)b(Y.location+_e);i.bindBuffer(i.ARRAY_BUFFER,Je);for(let _e=0;_e<Y.locationSize;_e++)A(Y.location+_e,be/Y.locationSize,ke,fe,be*oe,be/Y.locationSize*_e*oe,Ee)}}else if(O!==void 0){let fe=O[H];if(fe!==void 0)switch(fe.length){case 2:i.vertexAttrib2fv(Y.location,fe);break;case 3:i.vertexAttrib3fv(Y.location,fe);break;case 4:i.vertexAttrib4fv(Y.location,fe);break;default:i.vertexAttrib1fv(Y.location,fe)}}}}S()}function N(){I();for(let k in n){let V=n[k];for(let J in V){let L=V[J];for(let E in L){let D=L[E];for(let O in D)h(D[O].object),delete D[O];delete L[E]}}delete n[k]}}function P(k){if(n[k.id]===void 0)return;let V=n[k.id];for(let J in V){let L=V[J];for(let E in L){let D=L[E];for(let O in D)h(D[O].object),delete D[O];delete L[E]}}delete n[k.id]}function U(k){for(let V in n){let J=n[V];for(let L in J){let E=J[L];if(E[k.id]===void 0)continue;let D=E[k.id];for(let O in D)h(D[O].object),delete D[O];delete E[k.id]}}}function v(k){for(let V in n){let J=n[V],L=k.isInstancedMesh===!0?k.id:0,E=J[L];if(E!==void 0){for(let D in E){let O=E[D];for(let H in O)h(O[H].object),delete O[H];delete E[D]}delete J[L],Object.keys(J).length===0&&delete n[V]}}}function I(){B(),a=!0,s!==r&&(s=r,c(s.object))}function B(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:o,reset:I,resetDefaultState:B,dispose:N,releaseStatesOfGeometry:P,releaseStatesOfObject:v,releaseStatesOfProgram:U,initAttributes:y,enableAttribute:b,disableUnusedAttributes:S}}function dM(i,e,t){let n;function r(l){n=l}function s(l,c){i.drawArrays(n,l,c),t.update(c,n,1)}function a(l,c,h){h!==0&&(i.drawArraysInstanced(n,l,c,h),t.update(c,n,h))}function o(l,c,h){if(h===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,l,0,c,0,h);let f=0;for(let p=0;p<h;p++)f+=c[p];t.update(f,n,1)}this.setMode=r,this.render=s,this.renderInstances=a,this.renderMultiDraw=o}function fM(i,e,t,n){let r;function s(){if(r!==void 0)return r;if(e.has("EXT_texture_filter_anisotropic")===!0){let U=e.get("EXT_texture_filter_anisotropic");r=i.getParameter(U.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function a(U){return!(U!==ci&&n.convert(U)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(U){let v=U===Gn&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(U!==Qn&&n.convert(U)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_TYPE)&&U!==Tn&&!v)}function l(U){if(U==="highp"){if(i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.HIGH_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";U="mediump"}return U==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=t.precision!==void 0?t.precision:"highp",h=l(c);h!==c&&(Ke("WebGLRenderer:",c,"not supported, using",h,"instead."),c=h);let d=t.logarithmicDepthBuffer===!0,f=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control");t.reversedDepthBuffer===!0&&f===!1&&Ke("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");let p=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),x=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),y=i.getParameter(i.MAX_TEXTURE_SIZE),b=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),g=i.getParameter(i.MAX_VERTEX_ATTRIBS),S=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),A=i.getParameter(i.MAX_VARYING_VECTORS),T=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),N=i.getParameter(i.MAX_SAMPLES),P=i.getParameter(i.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:d,reversedDepthBuffer:f,maxTextures:p,maxVertexTextures:x,maxTextureSize:y,maxCubemapSize:b,maxAttributes:g,maxVertexUniforms:S,maxVaryings:A,maxFragmentUniforms:T,maxSamples:N,samples:P}}function pM(i){let e=this,t=null,n=0,r=!1,s=!1,a=new Gi,o=new ct,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(d,f){let p=d.length!==0||f||n!==0||r;return r=f,n=d.length,p},this.beginShadows=function(){s=!0,h(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(d,f){t=h(d,f,0)},this.setState=function(d,f,p){let x=d.clippingPlanes,y=d.clipIntersection,b=d.clipShadows,g=i.get(d);if(!r||x===null||x.length===0||s&&!b)s?h(null):c();else{let S=s?0:n,A=S*4,T=g.clippingState||null;l.value=T,T=h(x,f,A,p);for(let N=0;N!==A;++N)T[N]=t[N];g.clippingState=T,this.numIntersection=y?this.numPlanes:0,this.numPlanes+=S}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function h(d,f,p,x){let y=d!==null?d.length:0,b=null;if(y!==0){if(b=l.value,x!==!0||b===null){let g=p+y*4,S=f.matrixWorldInverse;o.getNormalMatrix(S),(b===null||b.length<g)&&(b=new Float32Array(g));for(let A=0,T=p;A!==y;++A,T+=4)a.copy(d[A]).applyMatrix4(S,o),a.normal.toArray(b,T),b[T+3]=a.constant}l.value=b,l.needsUpdate=!0}return e.numPlanes=y,e.numIntersection=0,b}}function bM(i){let e=[],t=[],n=[],r=i,s=i-Kr+1+D0.length;for(let a=0;a<s;a++){let o=Math.pow(2,r);e.push(o);let l=1/o;a>i-Kr?l=D0[a-i+Kr-1]:a===0&&(l=0),t.push(l);let c=1/(o-2),h=-c,d=1+c,f=[h,h,d,h,d,d,h,h,d,d,h,d],p=6,x=6,y=3,b=2,g=1,S=new Float32Array(y*x*p),A=new Float32Array(b*x*p),T=new Float32Array(g*x*p);for(let P=0;P<p;P++){let U=P%3*2/3-1,v=P>2?0:-1,I=[U,v,0,U+2/3,v,0,U+2/3,v+1,0,U,v,0,U+2/3,v+1,0,U,v+1,0];S.set(I,y*x*P),A.set(f,b*x*P);let B=[P,P,P,P,P,P];T.set(B,g*x*P)}let N=new mn;N.setAttribute("position",new Kt(S,y)),N.setAttribute("uv",new Kt(A,b)),N.setAttribute("faceIndex",new Kt(T,g)),n.push(new xt(N,null)),r>Kr&&r--}return{lodMeshes:n,sizeLods:e,sigmas:t}}function O0(i,e,t){let n=new Hn(i,e,t);return n.texture.mapping=Co,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function va(i,e,t,n,r){i.viewport.set(e,t,n,r),i.scissor.set(e,t,n,r)}function xM(i,e,t){return new ai({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:mM,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:vh(),fragmentShader:`
+}`,bi=class extends Wn{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=fM,this.fragmentShader=dM,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=sa(e.uniforms),this.uniformsGroups=uM(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.defaultAttributeValues=Object.assign({},e.defaultAttributeValues),this.index0AttributeName=e.index0AttributeName,this.uniformsNeedUpdate=e.uniformsNeedUpdate,this}toJSON(e){let t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(let s in this.uniforms){let a=this.uniforms[s].value;a&&a.isTexture?t.uniforms[s]={type:"t",value:a.toJSON(e).uuid}:a&&a.isColor?t.uniforms[s]={type:"c",value:a.getHex()}:a&&a.isVector2?t.uniforms[s]={type:"v2",value:a.toArray()}:a&&a.isVector3?t.uniforms[s]={type:"v3",value:a.toArray()}:a&&a.isVector4?t.uniforms[s]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?t.uniforms[s]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?t.uniforms[s]={type:"m4",value:a.toArray()}:t.uniforms[s]={value:a}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;let n={};for(let s in this.extensions)this.extensions[s]===!0&&(n[s]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(let n in e.uniforms){let s=e.uniforms[n];switch(this.uniforms[n]={},s.type){case"t":this.uniforms[n].value=t[s.value]||null;break;case"c":this.uniforms[n].value=new He().setHex(s.value);break;case"v2":this.uniforms[n].value=new dt().fromArray(s.value);break;case"v3":this.uniforms[n].value=new j().fromArray(s.value);break;case"v4":this.uniforms[n].value=new Gt().fromArray(s.value);break;case"m3":this.uniforms[n].value=new ut().fromArray(s.value);break;case"m4":this.uniforms[n].value=new ht().fromArray(s.value);break;default:this.uniforms[n].value=s.value}}if(e.defines!==void 0&&(this.defines=e.defines),e.vertexShader!==void 0&&(this.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(this.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(this.glslVersion=e.glslVersion),e.extensions!==void 0)for(let n in e.extensions)this.extensions[n]=e.extensions[n];return e.lights!==void 0&&(this.lights=e.lights),e.clipping!==void 0&&(this.clipping=e.clipping),this}},gh=class extends bi{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}},Pi=class extends Wn{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new He(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 He(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Lc,this.normalScale=new dt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ds,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},ri=class extends Pi{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new dt(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return yt(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new He(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new He(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new He(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._retroreflectivity=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get retroreflectivity(){return this._retroreflectivity}set retroreflectivity(e){this._retroreflectivity>0!=e>0&&this.version++,this._retroreflectivity=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.retroreflectivity=e.retroreflectivity,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}},oc=class extends Wn{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new He(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new He(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Lc,this.normalScale=new dt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ds,this.combine=Ph,this.reflectivity=1,this.envMapIntensity=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.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.envMapIntensity=e.envMapIntensity,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}},bh=class extends Wn{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=f_,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}},_h=class extends Wn{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}};lc=class{static convertArray(e,t){return $i(e,t)}static isTypedArray(e){return v_(e)}static hasTangents(e){return $o(e)}static getKeyframeOrder(e){return R_(e)}static sortedArray(e,t,n){return zd(e,t,n)}static flattenJSON(e,t,n,s){C_(e,t,n,s)}static subclip(e,t,n,s,r=30){return pM(e,t,n,s,r)}static makeClipAdditive(e,t=0,n=e,s=30){return mM(e,t,n,s)}},ps=class{constructor(e,t,n,s){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=s!==void 0?s:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,n=this._cachedIndex,s=t[n],r=t[n-1];e:{t:{let a;n:{i:if(!(e<s)){for(let o=n+2;;){if(s===void 0){if(e<r)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===o)break;if(r=s,s=t[++n],e<s)break t}a=t.length;break n}if(!(e>=r)){let o=t[1];e<o&&(n=2,r=o);for(let c=n-2;;){if(r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===c)break;if(s=r,r=t[--n-1],e>=r)break t}a=n,n=0;break n}break e}for(;n<a;){let o=n+a>>>1;e<t[o]?a=o:n=o+1}if(s=t[n],r=t[n-1],r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(s===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,r,s)}return this.interpolate_(n,r,e,s)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,s=this.valueSize,r=e*s;for(let a=0;a!==s;++a)t[a]=n[r+a];return t}interpolate_(){throw new Error("THREE.Interpolant: Call to abstract method.")}intervalChanged_(){}},xh=class extends ps{constructor(e,t,n,s){super(e,t,n,s),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Gr,endingEnd:Gr}}intervalChanged_(e,t,n){let s=this.parameterPositions,r=e-2,a=e+1,o=s[r],c=s[a];if(o===void 0)switch(this.getSettings_().endingStart){case Wr:r=e,o=2*t-n;break;case qo:r=s.length-2,o=t+s[r]-s[r+1];break;default:r=e,o=n}if(c===void 0)switch(this.getSettings_().endingEnd){case Wr:a=e,c=2*n-t;break;case qo:a=1,c=n+s[1]-s[0];break;default:a=e-1,c=t}let l=(n-t)*.5,h=this.valueSize;this._weightPrev=l/(t-o),this._weightNext=l/(c-n),this._offsetPrev=r*h,this._offsetNext=a*h}interpolate_(e,t,n,s){let r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=e*o,l=c-o,h=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,p=this._weightNext,b=(n-t)/(s-t),v=b*b,_=v*b,g=-d*_+2*d*v-d*b,E=(1+d)*_+(-1.5-2*d)*v+(-.5+d)*b+1,L=(-1-p)*_+(1.5+p)*v+.5*b,S=p*_-p*v;for(let M=0;M!==o;++M)r[M]=g*a[h+M]+E*a[l+M]+L*a[c+M]+S*a[u+M];return r}},hc=class extends ps{constructor(e,t,n,s){super(e,t,n,s)}interpolate_(e,t,n,s){let r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=e*o,l=c-o,h=(n-t)/(s-t),u=1-h;for(let d=0;d!==o;++d)r[d]=a[l+d]*u+a[c+d]*h;return r}},yh=class extends ps{constructor(e,t,n,s){super(e,t,n,s)}interpolate_(e){return this.copySampleValue_(e-1)}},vh=class extends ps{interpolate_(e,t,n,s){let r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=e*o,l=c-o,h=this.inTangents,u=this.outTangents;if(!h||!u){let b=(n-t)/(s-t),v=1-b;for(let _=0;_!==o;++_)r[_]=a[l+_]*v+a[c+_]*b;return r}let d=o*2,p=e-1;for(let b=0;b!==o;++b){let v=a[l+b],_=a[c+b],g=p*d+b*2,E=u[g],L=u[g+1],S=e*d+b*2,M=h[S],A=h[S+1],I=bM(n,t,E,M,s);r[b]=I_(I,v,L,A,_)}return r}};ai=class{constructor(e,t,n,s){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=$i(t,this.TimeBufferType),this.values=$i(n,this.ValueBufferType),this.setInterpolation(s||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:$i(e.times,Array),values:$i(e.values,Array)};let s=e.getInterpolation();s!==e.DefaultInterpolation&&(n.interpolation=s),$o(e.settings)&&(n.settings={inTangents:$i(e.settings.inTangents,Array),outTangents:$i(e.settings.outTangents,Array)})}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new yh(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new hc(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new xh(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){let t=new vh(this.times,this.values,this.getValueSize(),e);return this.settings&&(t.inTangents=this.settings.inTangents,t.outTangents=this.settings.outTangents),t}setInterpolation(e){let t;switch(e){case qr:t=this.InterpolantFactoryMethodDiscrete;break;case jr:t=this.InterpolantFactoryMethodLinear;break;case th:t=this.InterpolantFactoryMethodSmooth;break;case Ud:t=this.InterpolantFactoryMethodBezier;break}if(t===void 0){let n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return tt("KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return qr;case this.InterpolantFactoryMethodLinear:return jr;case this.InterpolantFactoryMethodSmooth:return th;case this.InterpolantFactoryMethodBezier:return Ud}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let n=0,s=t.length;n!==s;++n)t[n]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let n=0,s=t.length;n!==s;++n)t[n]*=e;$o(this.settings)&&(Db(this.settings.inTangents,e),Db(this.settings.outTangents,e))}return this}trim(e,t){let n=this.times,s=n.length,r=0,a=s-1;for(;r!==s&&n[r]<e;)++r;for(;a!==-1&&n[a]>t;)--a;if(++a,r!==0||a!==s){r>=a&&(a=Math.max(a,1),r=a-1);let o=this.getValueSize();this.times=n.slice(r,a),this.values=this.values.slice(r*o,a*o)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(st("KeyframeTrack: Invalid value size in track.",this),e=!1);let n=this.times,s=this.values,r=n.length;r===0&&(st("KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let o=0;o!==r;o++){let c=n[o];if(typeof c=="number"&&isNaN(c)){st("KeyframeTrack: Time is not a valid number.",this,o,c),e=!1;break}if(a!==null&&a>c){st("KeyframeTrack: Out of order keys.",this,o,c,a),e=!1;break}a=c}if(s!==void 0&&v_(s))for(let o=0,c=s.length;o!==c;++o){let l=s[o];if(isNaN(l)){st("KeyframeTrack: Value is not a valid number.",this,o,l),e=!1;break}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),s=this.getInterpolation()===th,r=e.length-1,a=1;for(let o=1;o<r;++o){let c=!1,l=e[o],h=e[o+1];if(l!==h&&(o!==1||l!==e[0]))if(s)c=!0;else{let u=o*n,d=u-n,p=u+n;for(let b=0;b!==n;++b){let v=t[u+b];if(v!==t[d+b]||v!==t[p+b]){c=!0;break}}}if(c){if(o!==a){e[a]=e[o];let u=o*n,d=a*n;for(let p=0;p!==n;++p)t[d+p]=t[u+p]}++a}}if(r>0){e[a]=e[r];for(let o=r*n,c=a*n,l=0;l!==n;++l)t[c+l]=t[o+l];++a}return a!==e.length?(this.times=e.slice(0,a),this.values=t.slice(0,a*n)):(this.times=e,this.values=t),this}clone(){let e=this.times.slice(),t=this.values.slice(),n=this.constructor,s=new n(this.name,e,t);return s.createInterpolant=this.createInterpolant,$o(this.settings)&&(s.settings={inTangents:this.settings.inTangents.slice(),outTangents:this.settings.outTangents.slice()}),s}};ai.prototype.ValueTypeName="";ai.prototype.TimeBufferType=Float32Array;ai.prototype.ValueBufferType=Float32Array;ai.prototype.DefaultInterpolation=jr;zs=class extends ai{constructor(e,t,n){super(e,t,n)}};zs.prototype.ValueTypeName="bool";zs.prototype.ValueBufferType=Array;zs.prototype.DefaultInterpolation=qr;zs.prototype.InterpolantFactoryMethodLinear=void 0;zs.prototype.InterpolantFactoryMethodSmooth=void 0;uc=class extends ai{constructor(e,t,n,s){super(e,t,n,s)}};uc.prototype.ValueTypeName="color";Hs=class extends ai{constructor(e,t,n,s){super(e,t,n,s)}};Hs.prototype.ValueTypeName="number";Sh=class extends ps{constructor(e,t,n,s){super(e,t,n,s)}interpolate_(e,t,n,s){let r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=(n-t)/(s-t),l=e*o;for(let h=l+o;l!==h;l+=4)Ft.slerpFlat(r,0,a,l-o,a,l,c);return r}},Vs=class extends ai{constructor(e,t,n,s){super(e,t,n,s)}InterpolantFactoryMethodLinear(e){return new Sh(this.times,this.values,this.getValueSize(),e)}};Vs.prototype.ValueTypeName="quaternion";Vs.prototype.InterpolantFactoryMethodSmooth=void 0;Gs=class extends ai{constructor(e,t,n){super(e,t,n)}};Gs.prototype.ValueTypeName="string";Gs.prototype.ValueBufferType=Array;Gs.prototype.DefaultInterpolation=qr;Gs.prototype.InterpolantFactoryMethodLinear=void 0;Gs.prototype.InterpolantFactoryMethodSmooth=void 0;br=class extends ai{constructor(e,t,n,s){super(e,t,n,s)}};br.prototype.ValueTypeName="vector";Li=class{constructor(e="",t=-1,n=[],s=_u){this.name=e,this.tracks=n,this.duration=t,this.blendMode=s,this.uuid=Xi(),this.userData={},this.duration<0&&this.resetDuration()}static parse(e){let t=[],n=e.tracks,s=1/(e.fps||1);for(let a=0,o=n.length;a!==o;++a)t.push(xM(n[a]).scale(s));let r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r.userData=JSON.parse(e.userData||"{}"),r}static toJSON(e){let t=[],n=e.tracks,s={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let r=0,a=n.length;r!==a;++r)t.push(ai.toJSON(n[r]));return s}static CreateFromMorphTargetSequence(e,t,n,s){let r=t.length,a=[];for(let o=0;o<r;o++){let c=[],l=[];c.push((o+r-1)%r,o,(o+1)%r),l.push(0,1,0);let h=R_(c);c=zd(c,1,h),l=zd(l,1,h),!s&&c[0]===0&&(c.push(r),l.push(l[0])),a.push(new Hs(".morphTargetInfluences["+t[o].name+"]",c,l).scale(1/n))}return new this(e,-1,a)}static findByName(e,t){let n=e;if(!Array.isArray(e)){let s=e;n=s.geometry&&s.geometry.animations||s.animations}for(let s=0;s<n.length;s++)if(n[s].name===t)return n[s];return null}static CreateClipsFromMorphTargetSequences(e,t,n){let s={},r=/^([\w-]*?)([\d]+)$/;for(let o=0,c=e.length;o<c;o++){let l=e[o],h=l.name.match(r);if(h&&h.length>1){let u=h[1],d=s[u];d||(s[u]=d=[]),d.push(l)}}let a=[];for(let o in s)a.push(this.CreateFromMorphTargetSequence(o,s[o],t,n));return a}resetDuration(){let e=this.tracks,t=0;for(let n=0,s=e.length;n!==s;++n){let r=this.tracks[n];t=Math.max(t,r.times[r.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){let e=[];for(let n=0;n<this.tracks.length;n++)e.push(this.tracks[n].clone());let t=new this.constructor(this.name,this.duration,e,this.blendMode);return t.userData=JSON.parse(JSON.stringify(this.userData)),t}toJSON(){return this.constructor.toJSON(this)}};us={enabled:!1,files:{},add:function(i,e){this.enabled!==!1&&(Nb(i)||(this.files[i]=e))},get:function(i){if(this.enabled!==!1&&!Nb(i))return this.files[i]},remove:function(i){delete this.files[i]},clear:function(){this.files={}}};wh=class{constructor(e,t,n){let s=this,r=!1,a=0,o=0,c,l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this._abortController=null,this.itemStart=function(h){o++,r===!1&&s.onStart!==void 0&&s.onStart(h,a,o),r=!0},this.itemEnd=function(h){a++,s.onProgress!==void 0&&s.onProgress(h,a,o),a===o&&(r=!1,s.onLoad!==void 0&&s.onLoad())},this.itemError=function(h){s.onError!==void 0&&s.onError(h)},this.resolveURL=function(h){return h=h.normalize("NFC"),c?c(h):h},this.setURLModifier=function(h){return c=h,this},this.addHandler=function(h,u){return l.push(h,u),this},this.removeHandler=function(h){let u=l.indexOf(h);return u!==-1&&l.splice(u,2),this},this.getHandler=function(h){for(let u=0,d=l.length;u<d;u+=2){let p=l[u],b=l[u+1];if(p.global&&(p.lastIndex=0),p.test(h))return b}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){return this._abortController||(this._abortController=new AbortController),this._abortController}},P_=new wh,_i=class{constructor(e){this.manager=e!==void 0?e:P_,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}load(){}loadAsync(e,t){let n=this;return new Promise(function(s,r){n.load(e,s,t,r)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}abort(){return this}};_i.DEFAULT_MATERIAL_NAME="__DEFAULT";Fs={},Hd=class extends Error{constructor(e,t){super(e),this.response=t}},ms=class extends _i{constructor(e){super(e),this.mimeType="",this.responseType="",this._abortController=new AbortController}load(e,t,n,s){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let r=us.get(`file:${e}`);if(r!==void 0){this.manager.itemStart(e),setTimeout(()=>{t&&t(r),this.manager.itemEnd(e)},0);return}if(Fs[e]!==void 0){Fs[e].push({onLoad:t,onProgress:n,onError:s});return}Fs[e]=[],Fs[e].push({onLoad:t,onProgress:n,onError:s});let a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),o=this.mimeType,c=this.responseType;fetch(a).then(l=>{if(l.status===200||l.status===0){if(l.status===0&&tt("FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||l.body===void 0||l.body.getReader===void 0)return l;let h=Fs[e],u=l.body.getReader(),d=l.headers.get("X-File-Size")||l.headers.get("Content-Length"),p=d?parseInt(d):0,b=p!==0,v=0,_=new ReadableStream({start(g){E();function E(){u.read().then(({done:L,value:S})=>{if(L)g.close();else{v+=S.byteLength;let M=new ProgressEvent("progress",{lengthComputable:b,loaded:v,total:p});for(let A=0,I=h.length;A<I;A++){let y=h[A];y.onProgress&&y.onProgress(M)}g.enqueue(S),E()}},L=>{g.error(L)})}}});return new Response(_)}else throw new Hd(`fetch for "${l.url}" responded with ${l.status}: ${l.statusText}`,l)}).then(l=>{switch(c){case"arraybuffer":return l.arrayBuffer();case"blob":return l.blob();case"document":return l.text().then(h=>new DOMParser().parseFromString(h,o));case"json":return l.json();default:if(o==="")return l.text();{let u=/charset="?([^;"\s]*)"?/i.exec(o),d=u&&u[1]?u[1].toLowerCase():void 0,p=new TextDecoder(d);return l.arrayBuffer().then(b=>p.decode(b))}}}).then(l=>{us.add(`file:${e}`,l);let h=Fs[e];delete Fs[e];for(let u=0,d=h.length;u<d;u++){let p=h[u];p.onLoad&&p.onLoad(l)}}).catch(l=>{let h=Fs[e];if(h===void 0)throw this.manager.itemError(e),l;delete Fs[e];for(let u=0,d=h.length;u<d;u++){let p=h[u];p.onError&&p.onError(l)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}},Ua=new WeakMap,Mh=class extends _i{constructor(e){super(e)}load(e,t,n,s){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let r=this,a=us.get(`image:${e}`);if(a!==void 0){if(a.complete===!0)r.manager.itemStart(e),setTimeout(function(){t&&t(a),r.manager.itemEnd(e)},0);else{let u=Ua.get(a);u===void 0&&(u=[],Ua.set(a,u)),u.push({onLoad:t,onError:s})}return a}let o=$a("img");function c(){h(),t&&t(this);let u=Ua.get(this)||[];for(let d=0;d<u.length;d++){let p=u[d];p.onLoad&&p.onLoad(this)}Ua.delete(this),r.manager.itemEnd(e)}function l(u){h(),s&&s(u),us.remove(`image:${e}`);let d=Ua.get(this)||[];for(let p=0;p<d.length;p++){let b=d[p];b.onError&&b.onError(u)}Ua.delete(this),r.manager.itemError(e),r.manager.itemEnd(e)}function h(){o.removeEventListener("load",c,!1),o.removeEventListener("error",l,!1)}return o.addEventListener("load",c,!1),o.addEventListener("error",l,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(o.crossOrigin=this.crossOrigin),us.add(`image:${e}`,o),r.manager.itemStart(e),o.src=e,o}},fc=class extends _i{constructor(e){super(e)}load(e,t,n,s){let r=this,a=new dr,o=new ms(this.manager);return o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setPath(this.path),o.setWithCredentials(r.withCredentials),o.load(e,function(c){let l;try{l=r.parse(c)}catch(h){s!==void 0?s(h):st(h);return}r._applyTexData(a,l),t&&t(a,l)},n,s),a}createDataTexture(e){let t=new dr;return this._applyTexData(t,this.parse(e)),t}_applyTexData(e,t){t.image!==void 0?e.image=t.image:t.data!==void 0&&(e.image.width=t.width,e.image.height=t.height,e.image.data=t.data),e.wrapS=t.wrapS!==void 0?t.wrapS:ii,e.wrapT=t.wrapT!==void 0?t.wrapT:ii,e.magFilter=t.magFilter!==void 0?t.magFilter:qt,e.minFilter=t.minFilter!==void 0?t.minFilter:qt,e.anisotropy=t.anisotropy!==void 0?t.anisotropy:1,t.colorSpace!==void 0&&(e.colorSpace=t.colorSpace),t.flipY!==void 0&&(e.flipY=t.flipY),t.format!==void 0&&(e.format=t.format),t.type!==void 0&&(e.type=t.type),t.mipmaps!==void 0&&(e.mipmaps=t.mipmaps,e.minFilter=Di),t.mipmapCount===1&&(e.minFilter=qt),t.generateMipmaps!==void 0&&(e.generateMipmaps=t.generateMipmaps),e.needsUpdate=!0}},dc=class extends _i{constructor(e){super(e)}load(e,t,n,s){let r=new En,a=new Mh(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(e,function(o){r.image=o,r.needsUpdate=!0,t!==void 0&&t(r)},n,s),r}},_r=class extends Yt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new He(e),this.intensity=t}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,t}},eo=class extends _r{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Yt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new He(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}toJSON(e){let t=super.toJSON(e);return t.object.groundColor=this.groundColor.getHex(),t}},Od=new ht,Ob=new j,Fb=new j,to=class{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new dt(512,512),this.mapType=oi,this.map=null,this.mapPass=null,this.matrix=new ht,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Ja,this._frameExtents=new dt(1,1),this._viewportCount=1,this._viewports=[new Gt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getCamera(){return this.camera}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera;Ob.setFromMatrixPosition(e.matrixWorld),t.position.copy(Ob),Fb.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(Fb),t.updateMatrixWorld(),this._updateMatrix(t,this.matrix,this._frustum)}_updateMatrix(e,t,n,s){Od.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),n.setFromProjectionMatrix(Od,e.coordinateSystem,e.reversedDepth);let r=this._frameExtents,a=s?s.z/r.x:1,o=s?s.w/r.y:1,c=s?s.x/r.x:0,l=s?s.y/r.y:0;e.coordinateSystem===Wa||e.reversedDepth?t.set(.5*a,0,0,.5*a+c,0,.5*o,0,.5*o+l,0,0,1,0,0,0,0,1):t.set(.5*a,0,0,.5*a+c,0,.5*o,0,.5*o+l,0,0,.5,.5,0,0,0,1),t.multiply(Od)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this.biasNode=e.biasNode,this}clone(){return new this.constructor().copy(this)}toJSON(){let e={};return e.intensity=this.intensity,e.bias=this.bias,e.normalBias=this.normalBias,e.radius=this.radius,e.blurSamples=this.blurSamples,e.mapSize=this.mapSize.toArray(),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}},Ql=new j,eh=new Ft,hs=new j,pc=class extends Yt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new ht,this.projectionMatrix=new ht,this.projectionMatrixInverse=new ht,this.coordinateSystem=ji,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorld.decompose(Ql,eh,hs),hs.x===1&&hs.y===1&&hs.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(Ql,eh,hs.set(1,1,1)).invert()}updateWorldMatrix(e,t,n=!1){super.updateWorldMatrix(e,t,n),this.matrixWorld.decompose(Ql,eh,hs),hs.x===1&&hs.y===1&&hs.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(Ql,eh,hs.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}},rr=new j,kb=new dt,Ub=new dt,fn=class extends pc{constructor(e=50,t=1,n=.1,s=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=s,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){let t=.5*this.getFilmHeight()/e;this.fov=Xr*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(Go*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Xr*2*Math.atan(Math.tan(Go*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){rr.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(rr.x,rr.y).multiplyScalar(-e/rr.z),rr.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(rr.x,rr.y).multiplyScalar(-e/rr.z)}getViewSize(e,t){return this.getViewBounds(e,kb,Ub),t.subVectors(Ub,kb)}setViewOffset(e,t,n,s,r,a){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=s,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(Go*.5*this.fov)/this.zoom,n=2*t,s=this.aspect*n,r=-.5*s,a=this.view;if(this.view!==null&&this.view.enabled){let c=a.fullWidth,l=a.fullHeight;r+=a.offsetX*s/c,t-=a.offsetY*n/l,s*=a.width/c,n*=a.height/l}let o=this.filmOffset;o!==0&&(r+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+s,t,t-n,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}},Vd=class extends to{constructor(){super(new fn(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){let t=this.camera,n=Xr*2*e.angle*this.focus,s=this.mapSize.width/this.mapSize.height*this.aspect,r=e.distance||t.far;(n!==t.fov||s!==t.aspect||r!==t.far)&&(t.fov=n,t.aspect=s,t.far=r,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this.aspect=e.aspect,this}toJSON(){let e=super.toJSON();return e.focus=this.focus,e.aspect=this.aspect,e}},mc=class extends _r{constructor(e,t,n=0,s=Math.PI/3,r=0,a=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Yt.DEFAULT_UP),this.updateMatrix(),this.target=new Yt,this.distance=n,this.angle=s,this.penumbra=r,this.decay=a,this.map=null,this.shadow=new Vd}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){super.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.map=e.map,this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);return t.object.distance=this.distance,t.object.angle=this.angle,t.object.decay=this.decay,t.object.penumbra=this.penumbra,t.object.target=this.target.uuid,this.map&&this.map.isTexture&&(t.object.map=this.map.toJSON(e).uuid),t.object.shadow=this.shadow.toJSON(),t}},Gd=class extends to{constructor(){super(new fn(90,1,.5,500)),this.isPointLightShadow=!0}},Qr=class extends _r{constructor(e,t,n=0,s=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=s,this.shadow=new Gd}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){super.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}toJSON(e){let t=super.toJSON(e);return t.object.distance=this.distance,t.object.decay=this.decay,t.object.shadow=this.shadow.toJSON(),t}},xr=class extends pc{constructor(e=-1,t=1,n=1,s=-1,r=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=s,this.near=r,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,s,r,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=s,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,s=(this.top+this.bottom)/2,r=n-e,a=n+e,o=s+t,c=s-t;if(this.view!==null&&this.view.enabled){let l=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=l*this.view.offsetX,a=r+l*this.view.width,o-=h*this.view.offsetY,c=o-h*this.view.height}this.projectionMatrix.makeOrthographic(r,a,o,c,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}},Wd=class extends to{constructor(){super(new xr(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},Yi=class extends _r{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Yt.DEFAULT_UP),this.updateMatrix(),this.target=new Yt,this.shadow=new Wd}dispose(){super.dispose(),this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);return t.object.shadow=this.shadow.toJSON(),t.object.target=this.target.uuid,t}},Eh=class{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new j)}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){let n=e.x,s=e.y,r=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.282095),t.addScaledVector(a[1],.488603*s),t.addScaledVector(a[2],.488603*r),t.addScaledVector(a[3],.488603*n),t.addScaledVector(a[4],1.092548*(n*s)),t.addScaledVector(a[5],1.092548*(s*r)),t.addScaledVector(a[6],.315392*(3*r*r-1)),t.addScaledVector(a[7],1.092548*(n*r)),t.addScaledVector(a[8],.546274*(n*n-s*s)),t}getIrradianceAt(e,t){let n=e.x,s=e.y,r=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.886227),t.addScaledVector(a[1],2*.511664*s),t.addScaledVector(a[2],2*.511664*r),t.addScaledVector(a[3],2*.511664*n),t.addScaledVector(a[4],2*.429043*n*s),t.addScaledVector(a[5],2*.429043*s*r),t.addScaledVector(a[6],.743125*r*r-.247708),t.addScaledVector(a[7],2*.429043*n*r),t.addScaledVector(a[8],.429043*(n*n-s*s)),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){let n=this.coefficients;for(let s=0;s<9;s++)n[s].fromArray(e,t+s*3);return this}toArray(e=[],t=0){let n=this.coefficients;for(let s=0;s<9;s++)n[s].toArray(e,t+s*3);return e}static getBasisAt(e,t){let n=e.x,s=e.y,r=e.z;t[0]=.282095,t[1]=.488603*s,t[2]=.488603*r,t[3]=.488603*n,t[4]=1.092548*n*s,t[5]=1.092548*s*r,t[6]=.315392*(3*r*r-1),t[7]=1.092548*n*r,t[8]=.546274*(n*n-s*s)}},gc=class extends _r{constructor(e=new Eh,t=1){super(void 0,t),this.isLightProbe=!0,this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}toJSON(e){let t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}},xi=class{static extractUrlBase(e){let t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}},Fd=new WeakMap,bc=class extends _i{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&tt("ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&tt("ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(e){return this.options=e,this}load(e,t,n,s){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let r=this,a=us.get(`image-bitmap:${e}`);if(a!==void 0){if(r.manager.itemStart(e),a.then){a.then(l=>{Fd.has(a)===!0?(s&&s(Fd.get(a)),r.manager.itemError(e),r.manager.itemEnd(e)):(t&&t(l),r.manager.itemEnd(e))});return}setTimeout(function(){t&&t(a),r.manager.itemEnd(e)},0);return}let o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader,o.signal=typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;let c=fetch(e,o).then(function(l){return l.blob()}).then(function(l){return createImageBitmap(l,Object.assign({},r.options,{colorSpaceConversion:"none"}))}).then(function(l){return us.add(`image-bitmap:${e}`,l),t&&t(l),r.manager.itemEnd(e),l}).catch(function(l){s&&s(l),Fd.set(c,l),us.remove(`image-bitmap:${e}`),r.manager.itemError(e),r.manager.itemEnd(e)});us.add(`image-bitmap:${e}`,c),r.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}},Ba=-90,za=1,Ah=class extends Yt{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let s=new fn(Ba,za,e,t);s.layers=this.layers,this.add(s);let r=new fn(Ba,za,e,t);r.layers=this.layers,this.add(r);let a=new fn(Ba,za,e,t);a.layers=this.layers,this.add(a);let o=new fn(Ba,za,e,t);o.layers=this.layers,this.add(o);let c=new fn(Ba,za,e,t);c.layers=this.layers,this.add(c);let l=new fn(Ba,za,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[n,s,r,a,o,c]=t;for(let l of t)this.remove(l);if(e===ji)n.up.set(0,1,0),n.lookAt(1,0,0),s.up.set(0,1,0),s.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(e===Wa)n.up.set(0,-1,0),n.lookAt(-1,0,0),s.up.set(0,-1,0),s.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(let l of t)this.add(l),l.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();let{renderTarget:n,activeMipmapLevel:s}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());let[r,a,o,c,l,h]=this.children,u=e.getRenderTarget(),d=e.getActiveCubeFace(),p=e.getActiveMipmapLevel(),b=e.xr.enabled;e.xr.enabled=!1;let v=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let _=!1;e.isWebGLRenderer===!0?_=e.state.buffers.depth.getReversed():_=e.reversedDepthBuffer,e.setRenderTarget(n,0,s),_&&e.autoClear===!1&&e.clearDepth(),e.render(t,r),e.setRenderTarget(n,1,s),_&&e.autoClear===!1&&e.clearDepth(),e.render(t,a),e.setRenderTarget(n,2,s),_&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(n,3,s),_&&e.autoClear===!1&&e.clearDepth(),e.render(t,c),e.setRenderTarget(n,4,s),_&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),n.texture.generateMipmaps=v,e.setRenderTarget(n,5,s),_&&e.autoClear===!1&&e.clearDepth(),e.render(t,h),e.setRenderTarget(u,d,p),e.xr.enabled=b,n.texture.needsPMREMUpdate=!0}},Th=class extends fn{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}},Rh=class{constructor(e,t,n){this.binding=e,this.valueSize=n;let s,r,a;switch(t){case"quaternion":s=this._slerp,r=this._slerpAdditive,a=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(n*6),this._workIndex=5;break;case"string":case"bool":s=this._select,r=this._select,a=this._setAdditiveIdentityOther,this.buffer=new Array(n*5);break;default:s=this._lerp,r=this._lerpAdditive,a=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(n*5)}this._mixBufferRegion=s,this._mixBufferRegionAdditive=r,this._setIdentity=a,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){let n=this.buffer,s=this.valueSize,r=e*s+s,a=this.cumulativeWeight;if(a===0){for(let o=0;o!==s;++o)n[r+o]=n[o];a=t}else{a+=t;let o=t/a;this._mixBufferRegion(n,r,0,o,s)}this.cumulativeWeight=a}accumulateAdditive(e){let t=this.buffer,n=this.valueSize,s=n*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,s,0,e,n),this.cumulativeWeightAdditive+=e}apply(e){let t=this.valueSize,n=this.buffer,s=e*t+t,r=this.cumulativeWeight,a=this.cumulativeWeightAdditive,o=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,r<1){let c=t*this._origIndex;this._mixBufferRegion(n,s,c,1-r,t)}a>0&&this._mixBufferRegionAdditive(n,s,this._addIndex*t,1,t);for(let c=t,l=t+t;c!==l;++c)if(n[c]!==n[c+t]){o.setValue(n,s);break}}saveOriginalState(){let e=this.binding,t=this.buffer,n=this.valueSize,s=n*this._origIndex;e.getValue(t,s);for(let r=n,a=s;r!==a;++r)t[r]=t[s+r%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){let 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(){let e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let n=0;n<this.valueSize;n++)this.buffer[t+n]=this.buffer[e+n]}_select(e,t,n,s,r){if(s>=.5)for(let a=0;a!==r;++a)e[t+a]=e[n+a]}_slerp(e,t,n,s){Ft.slerpFlat(e,t,e,t,e,n,s)}_slerpAdditive(e,t,n,s,r){let a=this._workIndex*r;Ft.multiplyQuaternionsFlat(e,a,e,t,e,n),Ft.slerpFlat(e,t,e,t,e,a,s)}_lerp(e,t,n,s,r){let a=1-s;for(let o=0;o!==r;++o){let c=t+o;e[c]=e[c]*a+e[n+o]*s}}_lerpAdditive(e,t,n,s,r){for(let a=0;a!==r;++a){let o=t+a;e[o]=e[o]+e[n+a]*s}}},xp="\\[\\]\\.:\\/",yM=new RegExp("["+xp+"]","g"),yp="[^"+xp+"]",vM="[^"+xp.replace("\\.","")+"]",SM=/((?:WC+[\/:])*)/.source.replace("WC",yp),wM=/(WCOD+)?/.source.replace("WCOD",vM),MM=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",yp),EM=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",yp),AM=new RegExp("^"+SM+wM+MM+EM+"$"),TM=["material","materials","bones","map"],$d=class{constructor(e,t,n){let s=n||Ot.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,s)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,s=this._bindings[n];s!==void 0&&s.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let s=this._targetGroup.nCachedObjects_,r=n.length;s!==r;++s)n[s].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}},Ot=class i{constructor(e,t,n){this.path=t,this.parsedPath=n||i.parseTrackName(t),this.node=i.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new i.Composite(e,t,n):new i(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(yM,"")}static parseTrackName(e){let t=AM.exec(e);if(t===null)throw new Error("THREE.PropertyBinding: Cannot parse trackName: "+e);let n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},s=n.nodeName&&n.nodeName.lastIndexOf(".");if(s!==void 0&&s!==-1){let r=n.nodeName.substring(s+1);TM.indexOf(r)!==-1&&(n.nodeName=n.nodeName.substring(0,s),n.objectName=r)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("THREE.PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){let n=function(r){for(let a=0;a<r.length;a++){let o=r[a];if(o.name===t||o.uuid===t)return o;let c=n(o.children);if(c)return c}return null},s=n(e.children);if(s)return s}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)e[t++]=n[s]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)n[s]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)n[s]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)n[s]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node,t=this.parsedPath,n=t.objectName,s=t.propertyName,r=t.propertyIndex;if(e||(e=i.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){tt("PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let l=t.objectIndex;switch(n){case"materials":if(!e.material){st("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){st("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){st("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let h=0;h<e.length;h++)if(e[h].name===l){l=h;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){st("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){st("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[n]===void 0){st("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(l!==void 0){if(e[l]===void 0){st("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[l]}}let a=e[s];if(a===void 0){let l=t.nodeName;st("PropertyBinding: Trying to update property for track: "+l+"."+s+" but it wasn't found.",e);return}let o=this.Versioning.None;this.targetObject=e,e.isMaterial===!0?o=this.Versioning.NeedsUpdate:e.isObject3D===!0&&(o=this.Versioning.MatrixWorldNeedsUpdate);let c=this.BindingType.Direct;if(r!==void 0){if(s==="morphTargetInfluences"){if(!e.geometry){st("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){st("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[r]!==void 0&&(r=e.morphTargetDictionary[r])}c=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=r}else a.fromArray!==void 0&&a.toArray!==void 0?(c=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(c=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=s;this.getValue=this.GetterByBindingType[c],this.setValue=this.SetterByBindingTypeAndVersioning[c][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};Ot.Composite=$d;Ot.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Ot.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Ot.prototype.GetterByBindingType=[Ot.prototype._getValue_direct,Ot.prototype._getValue_array,Ot.prototype._getValue_arrayElement,Ot.prototype._getValue_toArray];Ot.prototype.SetterByBindingTypeAndVersioning=[[Ot.prototype._setValue_direct,Ot.prototype._setValue_direct_setNeedsUpdate,Ot.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Ot.prototype._setValue_array,Ot.prototype._setValue_array_setNeedsUpdate,Ot.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Ot.prototype._setValue_arrayElement,Ot.prototype._setValue_arrayElement_setNeedsUpdate,Ot.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Ot.prototype._setValue_fromArray,Ot.prototype._setValue_fromArray_setNeedsUpdate,Ot.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];Ch=class{constructor(e,t,n=null,s=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=s;let r=t.tracks,a=r.length,o=new Array(a),c={endingStart:Gr,endingEnd:Gr};for(let l=0;l!==a;++l){let h=r[l].createInterpolant(null);o[l]=h,h.settings=c}this._interpolantSettings=c,this._interpolants=o,this._propertyBindings=new Array(a),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._restoreTimeScale=null,this._weightInterpolant=null,this.loop=Cc,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,n=!1){if(e.fadeOut(t),this.fadeIn(t),n===!0){let s=this._clip.duration,r=e._clip.duration,a=r/s,o=s/r;e._restoreTimeScale=e.timeScale,this._restoreTimeScale=this.timeScale,e.warp(1,a,t),this.warp(o,1,t)}return this}crossFadeTo(e,t,n=!1){return e.crossFadeFrom(this,t,n)}stopFading(){let e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,n){let s=this._mixer,r=s.time,a=this.timeScale,o=this._timeScaleInterpolant;o===null&&(o=s._lendControlInterpolant(),this._timeScaleInterpolant=o);let c=o.parameterPositions,l=o.sampleValues;return c[0]=r,c[1]=r+n,l[0]=e/a,l[1]=t/a,this}stopWarping(){let e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this._restoreTimeScale=null,this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,n,s){if(!this.enabled){this._updateWeight(e);return}let r=this._startTime;if(r!==null){let c=(e-r)*n;c<0||n===0?t=0:(this._startTime=null,t=n*c)}t*=this._updateTimeScale(e);let a=this._updateTime(t),o=this._updateWeight(e);if(o>0){let c=this._interpolants,l=this._propertyBindings;switch(this.blendMode){case Ic:for(let h=0,u=c.length;h!==u;++h)c[h].evaluate(a),l[h].accumulateAdditive(o);break;case _u:default:for(let h=0,u=c.length;h!==u;++h)c[h].evaluate(a),l[h].accumulate(s,o)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;let n=this._weightInterpolant;if(n!==null){let s=n.evaluate(e)[0];t*=s,e>n.parameterPositions[1]&&(this.stopFading(),s===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;let n=this._timeScaleInterpolant;if(n!==null){let s=n.evaluate(e)[0];t*=s,e>n.parameterPositions[1]&&(t===0?this.paused=!0:(this._restoreTimeScale!==null&&(t=this._restoreTimeScale),this.timeScale=t),this.stopWarping())}}return this._effectiveTimeScale=t,t}_updateTime(e){let t=this._clip.duration,n=this.loop,s=this.time+e,r=this._loopCount,a=n===u_;if(e===0)return r===-1?s:a&&(r&1)===1?t-s:s;if(n===ao){r===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(s>=t)s=t;else if(s<0)s=0;else{this.time=s;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=s,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(r===-1&&(e>=0?(r=0,this._setEndings(!0,this.repetitions===0,a)):this._setEndings(this.repetitions===0,!0,a)),s>=t||s<0){let o=Math.floor(s/t);s-=t*o,r+=Math.abs(o);let c=this.repetitions-r;if(c<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,s=e>0?t:0,this.time=s,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(c===1){let l=e<0;this._setEndings(l,!l,a)}else this._setEndings(!1,!1,a);this._loopCount=r,this.time=s,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this._loopCount=r,this.time=s;if(a&&(r&1)===1)return t-s}return s}_setEndings(e,t,n){let s=this._interpolantSettings;n?(s.endingStart=Wr,s.endingEnd=Wr):(e?s.endingStart=this.zeroSlopeAtStart?Wr:Gr:s.endingStart=qo,t?s.endingEnd=this.zeroSlopeAtEnd?Wr:Gr:s.endingEnd=qo)}_scheduleFading(e,t,n){let s=this._mixer,r=s.time,a=this._weightInterpolant;a===null&&(a=s._lendControlInterpolant(),this._weightInterpolant=a);let o=a.parameterPositions,c=a.sampleValues;return o[0]=r,c[0]=t,o[1]=r+e,c[1]=n,this}},RM=new Float32Array(1),ea=class extends Ki{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}_bindAction(e,t){let n=e._localRoot||this._root,s=e._clip.tracks,r=s.length,a=e._propertyBindings,o=e._interpolants,c=n.uuid,l=this._bindingsByRootAndName,h=l[c];h===void 0&&(h={},l[c]=h);for(let u=0;u!==r;++u){let d=s[u],p=d.name,b=h[p];if(b!==void 0)++b.referenceCount,a[u]=b;else{if(b=a[u],b!==void 0){b._cacheIndex===null&&(++b.referenceCount,this._addInactiveBinding(b,c,p));continue}let v=t&&t._propertyBindings[u].binding.parsedPath;b=new Rh(Ot.create(n,p,v),d.ValueTypeName,d.getValueSize()),++b.referenceCount,this._addInactiveBinding(b,c,p),a[u]=b}o[u].resultBuffer=b.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){let n=(e._localRoot||this._root).uuid,s=e._clip.uuid,r=this._actionsByClip[s];this._bindAction(e,r&&r.knownActions[0]),this._addInactiveAction(e,s,n)}let t=e._propertyBindings;for(let n=0,s=t.length;n!==s;++n){let r=t[n];r.useCount++===0&&(this._lendBinding(r),r.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){let t=e._propertyBindings;for(let n=0,s=t.length;n!==s;++n){let r=t[n];--r.useCount===0&&(r.restoreOriginalState(),this._takeBackBinding(r))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let 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){let t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,n){let s=this._actions,r=this._actionsByClip,a=r[t];if(a===void 0)a={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,r[t]=a;else{let o=a.knownActions;e._byClipCacheIndex=o.length,o.push(e)}e._cacheIndex=s.length,s.push(e),a.actionByRoot[n]=e}_removeInactiveAction(e){let t=this._actions,n=t[t.length-1],s=e._cacheIndex;n._cacheIndex=s,t[s]=n,t.pop(),e._cacheIndex=null;let r=e._clip.uuid,a=this._actionsByClip,o=a[r],c=o.knownActions,l=c[c.length-1],h=e._byClipCacheIndex;l._byClipCacheIndex=h,c[h]=l,c.pop(),e._byClipCacheIndex=null;let u=o.actionByRoot,d=(e._localRoot||this._root).uuid;delete u[d],c.length===0&&delete a[r],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){let t=e._propertyBindings;for(let n=0,s=t.length;n!==s;++n){let r=t[n];--r.referenceCount===0&&this._removeInactiveBinding(r)}}_lendAction(e){let t=this._actions,n=e._cacheIndex,s=this._nActiveActions++,r=t[s];e._cacheIndex=s,t[s]=e,r._cacheIndex=n,t[n]=r}_takeBackAction(e){let t=this._actions,n=e._cacheIndex,s=--this._nActiveActions,r=t[s];e._cacheIndex=s,t[s]=e,r._cacheIndex=n,t[n]=r}_addInactiveBinding(e,t,n){let s=this._bindingsByRootAndName,r=this._bindings,a=s[t];a===void 0&&(a={},s[t]=a),a[n]=e,e._cacheIndex=r.length,r.push(e)}_removeInactiveBinding(e){let t=this._bindings,n=e.binding,s=n.rootNode.uuid,r=n.path,a=this._bindingsByRootAndName,o=a[s],c=t[t.length-1],l=e._cacheIndex;c._cacheIndex=l,t[l]=c,t.pop(),delete o[r],Object.keys(o).length===0&&delete a[s]}_lendBinding(e){let t=this._bindings,n=e._cacheIndex,s=this._nActiveBindings++,r=t[s];e._cacheIndex=s,t[s]=e,r._cacheIndex=n,t[n]=r}_takeBackBinding(e){let t=this._bindings,n=e._cacheIndex,s=--this._nActiveBindings,r=t[s];e._cacheIndex=s,t[s]=e,r._cacheIndex=n,t[n]=r}_lendControlInterpolant(){let e=this._controlInterpolants,t=this._nActiveControlInterpolants++,n=e[t];return n===void 0&&(n=new hc(new Float32Array(2),new Float32Array(2),1,RM),n.__cacheIndex=t,e[t]=n),n}_takeBackControlInterpolant(e){let t=this._controlInterpolants,n=e.__cacheIndex,s=--this._nActiveControlInterpolants,r=t[s];e.__cacheIndex=s,t[s]=e,r.__cacheIndex=n,t[n]=r}clipAction(e,t,n){let s=t||this._root,r=s.uuid,a=typeof e=="string"?Li.findByName(s,e):e,o=a!==null?a.uuid:e,c=this._actionsByClip[o],l=null;if(n===void 0&&(a!==null?n=a.blendMode:n=_u),c!==void 0){let u=c.actionByRoot[r];if(u!==void 0&&u.blendMode===n)return u;l=c.knownActions[0],a===null&&(a=l._clip)}if(a===null)return null;let h=new Ch(this,a,t,n);return this._bindAction(h,l),this._addInactiveAction(h,o,r),h}existingAction(e,t){let n=t||this._root,s=n.uuid,r=typeof e=="string"?Li.findByName(n,e):e,a=r?r.uuid:e,o=this._actionsByClip[a];return o!==void 0&&o.actionByRoot[s]||null}stopAllAction(){let e=this._actions,t=this._nActiveActions;for(let n=t-1;n>=0;--n)e[n].stop();return this}update(e){e*=this.timeScale;let t=this._actions,n=this._nActiveActions,s=this.time+=e,r=Math.sign(e),a=this._accuIndex^=1;for(let l=0;l!==n;++l)t[l]._update(s,e,r,a);let o=this._bindings,c=this._nActiveBindings;for(let l=0;l!==c;++l)o[l].apply(a);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){let t=this._actions,n=e.uuid,s=this._actionsByClip,r=s[n];if(r!==void 0){let a=r.knownActions;for(let o=0,c=a.length;o!==c;++o){let l=a[o];this._deactivateAction(l);let h=l._cacheIndex,u=t[t.length-1];l._cacheIndex=null,l._byClipCacheIndex=null,u._cacheIndex=h,t[h]=u,t.pop(),this._removeInactiveBindingsForAction(l)}delete s[n]}}uncacheRoot(e){let t=e.uuid,n=this._actionsByClip;for(let a in n){let o=n[a].actionByRoot,c=o[t];c!==void 0&&(this._deactivateAction(c),this._removeInactiveAction(c))}let s=this._bindingsByRootAndName,r=s[t];if(r!==void 0)for(let a in r){let o=r[a];o.restoreOriginalState(),this._removeInactiveBinding(o)}}uncacheAction(e,t){let n=this.existingAction(e,t);n!==null&&(this._deactivateAction(n),this._removeInactiveAction(n))}},Bb=new ht,_c=class{constructor(e,t,n=0,s=1/0){this.ray=new fr(e,t),this.near=n,this.far=s,this.camera=null,this.layers=new Xa,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.projectionMatrix.elements[14]).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):st("Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return Bb.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(Bb),this}intersectObject(e,t=!0,n=[]){return qd(e,this,n,t),n.sort(zb),n}intersectObjects(e,t=!0,n=[]){for(let s=0,r=e.length;s<r;s++)qd(e[s],this,n,t);return n.sort(zb),n}};Ap=class Ap{constructor(e,t,n,s){this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,n,s)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let n=0;n<4;n++)this.elements[n]=e[n+t];return this}set(e,t,n,s){let r=this.elements;return r[0]=e,r[2]=t,r[1]=n,r[3]=s,this}};Ap.prototype.isMatrix2=!0;jd=Ap,xc=class extends Za{constructor(e=10,t=10,n=4473924,s=8947848){n=new He(n),s=new He(s);let r=t/2,a=e/t,o=e/2,c=[],l=[];for(let d=0,p=0,b=-o;d<=t;d++,b+=a){c.push(-o,0,b,o,0,b),c.push(b,0,-o,b,0,o);let v=d===r?n:s;v.toArray(l,p),p+=3,v.toArray(l,p),p+=3,v.toArray(l,p),p+=3,v.toArray(l,p),p+=3}let h=new pn;h.setAttribute("position",new sn(c,3)),h.setAttribute("color",new sn(l,3));let u=new Yr({vertexColors:!0,toneMapped:!1});super(h,u),this.type="GridHelper"}dispose(){super.dispose(),this.geometry.dispose(),this.material.dispose()}};typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"186"}}));typeof window<"u"&&(window.__THREE__?tt("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="186")});function Q_(){let i=null,e=!1,t=null,n=null;function s(r,a){n=i.requestAnimationFrame(s),t(r,a)}return{start:function(){e!==!0&&t!==null&&i!==null&&(n=i.requestAnimationFrame(s),e=!0)},stop:function(){i!==null&&i.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(r){t=r},setContext:function(r){i=r}}}function PM(i){let e=new WeakMap;function t(o,c){let l=o.array,h=o.usage,u=l.byteLength,d=i.createBuffer();i.bindBuffer(c,d),i.bufferData(c,l,h),o.onUploadCallback();let p;if(l instanceof Float32Array)p=i.FLOAT;else if(typeof Float16Array<"u"&&l instanceof Float16Array)p=i.HALF_FLOAT;else if(l instanceof Uint16Array)o.isFloat16BufferAttribute?p=i.HALF_FLOAT:p=i.UNSIGNED_SHORT;else if(l instanceof Int16Array)p=i.SHORT;else if(l instanceof Uint32Array)p=i.UNSIGNED_INT;else if(l instanceof Int32Array)p=i.INT;else if(l instanceof Int8Array)p=i.BYTE;else if(l instanceof Uint8Array)p=i.UNSIGNED_BYTE;else if(l instanceof Uint8ClampedArray)p=i.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+l);return{buffer:d,type:p,bytesPerElement:l.BYTES_PER_ELEMENT,version:o.version,size:u}}function n(o,c,l){let h=c.array,u=c.updateRanges;if(i.bindBuffer(l,o),u.length===0)i.bufferSubData(l,0,h);else{u.sort((p,b)=>p.start-b.start);let d=0;for(let p=1;p<u.length;p++){let b=u[d],v=u[p];v.start<=b.start+b.count+1?b.count=Math.max(b.count,v.start+v.count-b.start):(++d,u[d]=v)}u.length=d+1;for(let p=0,b=u.length;p<b;p++){let v=u[p];i.bufferSubData(l,v.start*h.BYTES_PER_ELEMENT,h,v.start,v.count)}c.clearUpdateRanges()}c.onUploadCallback()}function s(o){return o.isInterleavedBufferAttribute&&(o=o.data),e.get(o)}function r(o){o.isInterleavedBufferAttribute&&(o=o.data);let c=e.get(o);c&&(i.deleteBuffer(c.buffer),e.delete(o))}function a(o,c){if(o.isInterleavedBufferAttribute&&(o=o.data),o.isGLBufferAttribute){let h=e.get(o);(!h||h.version<o.version)&&e.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}let l=e.get(o);if(l===void 0)e.set(o,t(o,c));else if(l.version<o.version){if(l.size!==o.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");n(l.buffer,o,c),l.version=o.version}}return{get:s,remove:r,update:a}}function dT(i,e,t,n,s,r){let a=new He(0),o=s===!0?0:1,c,l,h=null,u=0,d=null;function p(E){let L=E.isScene===!0?E.background:null;if(L&&L.isTexture){let S=E.backgroundBlurriness>0;L=e.get(L,S)}return L}function b(E){let L=!1,S=p(E);S===null?_(a,o):S&&S.isColor&&(_(S,1),L=!0);let M=i.xr.getEnvironmentBlendMode();M==="additive"?t.buffers.color.setClear(0,0,0,1,r):M==="alpha-blend"&&t.buffers.color.setClear(0,0,0,0,r),(i.autoClear||L)&&(t.buffers.depth.setTest(!0),t.buffers.depth.setMask(!0),t.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function v(E,L){let S=p(L);S&&(S.isCubeTexture||S.mapping===Sc)?(l===void 0&&(l=new vt(new mr(1,1,1),new bi({name:"BackgroundCubeMaterial",uniforms:sa(xs.backgroundCube.uniforms),vertexShader:xs.backgroundCube.vertexShader,fragmentShader:xs.backgroundCube.fragmentShader,side:Nn,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(M,A,I){this.matrixWorld.copyPosition(I.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(l)),l.material.uniforms.envMap.value=S,l.material.uniforms.backgroundBlurriness.value=L.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=L.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(fT.makeRotationFromEuler(L.backgroundRotation)).transpose(),S.isCubeTexture&&S.isRenderTargetTexture===!1&&l.material.uniforms.backgroundRotation.value.premultiply(ex),l.material.toneMapped=gt.getTransfer(S.colorSpace)!==Bt,(h!==S||u!==S.version||d!==i.toneMapping)&&(l.material.needsUpdate=!0,h=S,u=S.version,d=i.toneMapping),l.layers.enableAll(),E.unshift(l,l.geometry,l.material,0,0,null)):S&&S.isTexture&&(c===void 0&&(c=new vt(new Ii(2,2),new bi({name:"BackgroundMaterial",uniforms:sa(xs.background.uniforms),vertexShader:xs.background.vertexShader,fragmentShader:xs.background.fragmentShader,side:gs,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(c)),c.material.uniforms.t2D.value=S,c.material.uniforms.backgroundIntensity.value=L.backgroundIntensity,c.material.toneMapped=gt.getTransfer(S.colorSpace)!==Bt,S.matrixAutoUpdate===!0&&S.updateMatrix(),c.material.uniforms.uvTransform.value.copy(S.matrix),(h!==S||u!==S.version||d!==i.toneMapping)&&(c.material.needsUpdate=!0,h=S,u=S.version,d=i.toneMapping),c.layers.enableAll(),E.unshift(c,c.geometry,c.material,0,0,null))}function _(E,L){E.getRGB(vu,_p(i)),t.buffers.color.setClear(vu.r,vu.g,vu.b,L,r)}function g(){l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0),c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0)}return{getClearColor:function(){return a},setClearColor:function(E,L=1){a.set(E),o=L,_(a,o)},getClearAlpha:function(){return o},setClearAlpha:function(E){o=E,_(a,o)},render:b,addToRenderList:v,dispose:g}}function pT(i,e){let t=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},s=d(null),r=s,a=!1;function o(z,$,K,P,N){let O=!1,F=u(z,P,K,$);r!==F&&(r=F,l(r.object)),O=p(z,P,K,N),O&&b(z,P,K,N),N!==null&&e.update(N,i.ELEMENT_ARRAY_BUFFER),(O||a)&&(a=!1,S(z,$,K,P),N!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.get(N).buffer))}function c(){return i.createVertexArray()}function l(z){return i.bindVertexArray(z)}function h(z){return i.deleteVertexArray(z)}function u(z,$,K,P){let N=P.wireframe===!0,O=n[$.id];O===void 0&&(O={},n[$.id]=O);let F=z.isInstancedMesh===!0?z.id:0,H=O[F];H===void 0&&(H={},O[F]=H);let V=H[K.id];V===void 0&&(V={},H[K.id]=V);let Q=V[N];return Q===void 0&&(Q=d(c()),V[N]=Q),Q}function d(z){let $=[],K=[],P=[];for(let N=0;N<t;N++)$[N]=0,K[N]=0,P[N]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:$,enabledAttributes:K,attributeDivisors:P,object:z,attributes:{},index:null}}function p(z,$,K,P){let N=r.attributes,O=$.attributes,F=0,H=K.getAttributes();for(let V in H)if(H[V].location>=0){let te=N[V],Se=O[V];if(Se===void 0&&(V==="instanceMatrix"&&z.instanceMatrix&&(Se=z.instanceMatrix),V==="instanceColor"&&z.instanceColor&&(Se=z.instanceColor)),te===void 0||te.attribute!==Se||Se&&te.data!==Se.data)return!0;F++}return r.attributesNum!==F||r.index!==P}function b(z,$,K,P){let N={},O=$.attributes,F=0,H=K.getAttributes();for(let V in H)if(H[V].location>=0){let te=O[V];te===void 0&&(V==="instanceMatrix"&&z.instanceMatrix&&(te=z.instanceMatrix),V==="instanceColor"&&z.instanceColor&&(te=z.instanceColor));let Se={};Se.attribute=te,te&&te.data&&(Se.data=te.data),N[V]=Se,F++}r.attributes=N,r.attributesNum=F,r.index=P}function v(){let z=r.newAttributes;for(let $=0,K=z.length;$<K;$++)z[$]=0}function _(z){g(z,0)}function g(z,$){let K=r.newAttributes,P=r.enabledAttributes,N=r.attributeDivisors;K[z]=1,P[z]===0&&(i.enableVertexAttribArray(z),P[z]=1),N[z]!==$&&(i.vertexAttribDivisor(z,$),N[z]=$)}function E(){let z=r.newAttributes,$=r.enabledAttributes;for(let K=0,P=$.length;K<P;K++)$[K]!==z[K]&&(i.disableVertexAttribArray(K),$[K]=0)}function L(z,$,K,P,N,O,F){F===!0?i.vertexAttribIPointer(z,$,K,N,O):i.vertexAttribPointer(z,$,K,P,N,O)}function S(z,$,K,P){v();let N=P.attributes,O=K.getAttributes(),F=$.defaultAttributeValues;for(let H in O){let V=O[H];if(V.location>=0){let Q=N[H];if(Q===void 0&&(H==="instanceMatrix"&&z.instanceMatrix&&(Q=z.instanceMatrix),H==="instanceColor"&&z.instanceColor&&(Q=z.instanceColor)),Q!==void 0){let te=Q.normalized,Se=Q.itemSize,ve=e.get(Q);if(ve===void 0)continue;let nt=ve.buffer,je=ve.type,Qe=ve.bytesPerElement,fe=je===i.INT||je===i.UNSIGNED_INT||Q.gpuType===Oh;if(Q.isInterleavedBufferAttribute){let ge=Q.data,Ve=ge.stride,it=Q.offset;if(ge.isInstancedInterleavedBuffer){for(let Ue=0;Ue<V.locationSize;Ue++)g(V.location+Ue,ge.meshPerAttribute);z.isInstancedMesh!==!0&&P._maxInstanceCount===void 0&&(P._maxInstanceCount=ge.meshPerAttribute*ge.count)}else for(let Ue=0;Ue<V.locationSize;Ue++)_(V.location+Ue);i.bindBuffer(i.ARRAY_BUFFER,nt);for(let Ue=0;Ue<V.locationSize;Ue++)L(V.location+Ue,Se/V.locationSize,je,te,Ve*Qe,(it+Se/V.locationSize*Ue)*Qe,fe)}else{if(Q.isInstancedBufferAttribute){for(let ge=0;ge<V.locationSize;ge++)g(V.location+ge,Q.meshPerAttribute);z.isInstancedMesh!==!0&&P._maxInstanceCount===void 0&&(P._maxInstanceCount=Q.meshPerAttribute*Q.count)}else for(let ge=0;ge<V.locationSize;ge++)_(V.location+ge);i.bindBuffer(i.ARRAY_BUFFER,nt);for(let ge=0;ge<V.locationSize;ge++)L(V.location+ge,Se/V.locationSize,je,te,Se*Qe,Se/V.locationSize*ge*Qe,fe)}}else if(F!==void 0){let te=F[H];if(te!==void 0)switch(te.length){case 2:i.vertexAttrib2fv(V.location,te);break;case 3:i.vertexAttrib3fv(V.location,te);break;case 4:i.vertexAttrib4fv(V.location,te);break;default:i.vertexAttrib1fv(V.location,te)}}}}E()}function M(){C();for(let z in n){let $=n[z];for(let K in $){let P=$[K];for(let N in P){let O=P[N];for(let F in O)h(O[F].object),delete O[F];delete P[N]}}delete n[z]}}function A(z){if(n[z.id]===void 0)return;let $=n[z.id];for(let K in $){let P=$[K];for(let N in P){let O=P[N];for(let F in O)h(O[F].object),delete O[F];delete P[N]}}delete n[z.id]}function I(z){for(let $ in n){let K=n[$];for(let P in K){let N=K[P];if(N[z.id]===void 0)continue;let O=N[z.id];for(let F in O)h(O[F].object),delete O[F];delete N[z.id]}}}function y(z){for(let $ in n){let K=n[$],P=z.isInstancedMesh===!0?z.id:0,N=K[P];if(N!==void 0){for(let O in N){let F=N[O];for(let H in F)h(F[H].object),delete F[H];delete N[O]}delete K[P],Object.keys(K).length===0&&delete n[$]}}}function C(){k(),a=!0,r!==s&&(r=s,l(r.object))}function k(){s.geometry=null,s.program=null,s.wireframe=!1}return{setup:o,reset:C,resetDefaultState:k,dispose:M,releaseStatesOfGeometry:A,releaseStatesOfObject:y,releaseStatesOfProgram:I,initAttributes:v,enableAttribute:_,disableUnusedAttributes:E}}function mT(i,e,t){let n;function s(c){n=c}function r(c,l){i.drawArrays(n,c,l),t.update(l,n,1)}function a(c,l,h){h!==0&&(i.drawArraysInstanced(n,c,l,h),t.update(l,n,h))}function o(c,l,h){if(h===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,c,0,l,0,h);let d=0;for(let p=0;p<h;p++)d+=l[p];t.update(d,n,1)}this.setMode=s,this.render=r,this.renderInstances=a,this.renderMultiDraw=o}function gT(i,e,t,n){let s;function r(){if(s!==void 0)return s;if(e.has("EXT_texture_filter_anisotropic")===!0){let I=e.get("EXT_texture_filter_anisotropic");s=i.getParameter(I.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else s=0;return s}function a(I){return!(I!==yi&&n.convert(I)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(I){let y=I===Zn&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(I!==oi&&I!==qn&&!y&&n.convert(I)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_TYPE))}function c(I){if(I==="highp"){if(i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.HIGH_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";I="mediump"}return I==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let l=t.precision!==void 0?t.precision:"highp",h=c(l);h!==l&&(tt("WebGLRenderer:",l,"not supported, using",h,"instead."),l=h);let u=t.logarithmicDepthBuffer===!0,d=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control");t.reversedDepthBuffer===!0&&d===!1&&tt("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");let p=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),b=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),v=i.getParameter(i.MAX_TEXTURE_SIZE),_=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),g=i.getParameter(i.MAX_VERTEX_ATTRIBS),E=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),L=i.getParameter(i.MAX_VARYING_VECTORS),S=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),M=i.getParameter(i.MAX_SAMPLES),A=i.getParameter(i.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:c,textureFormatReadable:a,textureTypeReadable:o,precision:l,logarithmicDepthBuffer:u,reversedDepthBuffer:d,maxTextures:p,maxVertexTextures:b,maxTextureSize:v,maxCubemapSize:_,maxAttributes:g,maxVertexUniforms:E,maxVaryings:L,maxFragmentUniforms:S,maxSamples:M,samples:A}}function bT(i){let e=this,t=null,n=0,s=!1,r=!1,a=new Wi,o=new ut,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(u,d){let p=u.length!==0||d||n!==0||s;return s=d,n=u.length,p},this.beginShadows=function(){r=!0,h(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(u,d){t=h(u,d,0)},this.setState=function(u,d,p){let b=u.clippingPlanes,v=u.clipIntersection,_=u.clipShadows,g=i.get(u);if(!s||b===null||b.length===0||r&&!_)r?h(null):l();else{let E=r?0:n,L=E*4,S=g.clippingState||null;c.value=S,S=h(b,d,L,p);for(let M=0;M!==L;++M)S[M]=t[M];g.clippingState=S,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=E}};function l(){c.value!==t&&(c.value=t,c.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function h(u,d,p,b){let v=u!==null?u.length:0,_=null;if(v!==0){if(_=c.value,b!==!0||_===null){let g=p+v*4,E=d.matrixWorldInverse;o.getNormalMatrix(E),(_===null||_.length<g)&&(_=new Float32Array(g));for(let L=0,S=p;L!==v;++L,S+=4)a.copy(u[L]).applyMatrix4(E,o),a.normal.toArray(_,S),_[S+3]=a.constant}c.value=_,c.needsUpdate=!0}return e.numPlanes=v,e.numIntersection=0,_}}function ST(i){let e=[],t=[],n=i,s=i-lo+1+_T;for(let r=0;r<s;r++){let a=Math.pow(2,n);e.push(a);let o=1/(a-2),c=-o,l=1+o,h=[c,c,l,c,l,l,c,c,l,l,c,l],u=6,d=6,p=3,b=new Float32Array(p*d*u),v=new Float32Array(p*d*u);for(let g=0;g<u;g++){let E=g%3*2/3-1,L=g>2?0:-1,S=[E,L,0,E+2/3,L,0,E+2/3,L+1,0,E,L,0,E+2/3,L+1,0,E,L+1,0];b.set(S,p*d*g);for(let M=0;M<d;M++){let A=h[M*2]*2-1,I=h[M*2+1]*2-1;g===0?ra.set(1,I,A):g===1?ra.set(-A,1,-I):g===2?ra.set(-A,I,1):g===3?ra.set(-1,I,-A):g===4?ra.set(-A,-1,I):ra.set(A,I,-1),ra.toArray(v,(g*d+M)*p)}}let _=new pn;_.setAttribute("position",new Qt(b,p)),_.setAttribute("outputDirection",new Qt(v,p)),t.push(new vt(_,null)),n>lo&&n--}return{lodMeshes:t,sizeLods:e}}function D_(i,e,t){let n=new Gn(i,e,t);return n.texture.mapping=Sc,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function co(i,e,t,n,s){i.viewport.set(e,t,n,s),i.scissor.set(e,t,n,s)}function wT(i,e,t){return new bi({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:yT,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:Mu(),fragmentShader:`
precision highp float;
precision highp int;
@@ -108,67 +108,67 @@ var xv=Object.create;var wc=Object.defineProperty;var _v=Object.getOwnPropertyDe
gl_FragColor = vec4(prefilteredColor, 1.0);
}
- `,blending:Ji,depthTest:!1,depthWrite:!1})}function _M(i,e,t){let n=new Float32Array(Rs),r=new W(0,1,0);return new ai({name:"SphericalGaussianBlur",defines:{n:Rs,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:vh(),fragmentShader:`
+ `,blending:bs,depthTest:!1,depthWrite:!1})}function MT(i,e,t){return new bi({name:"SphericalGaussianBlur",defines:{SAMPLES:xT,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},sigma:{value:0},mipInt:{value:0}},vertexShader:Mu(),fragmentShader:`
- precision mediump float;
- precision mediump int;
+ precision highp float;
+ precision highp int;
varying vec3 vOutputDirection;
uniform sampler2D envMap;
- uniform int samples;
- uniform float weights[ n ];
- uniform bool latitudinal;
- uniform float dTheta;
+ uniform float sigma;
uniform float mipInt;
- uniform vec3 poleAxis;
#define ENVMAP_TYPE_CUBE_UV
#include <cube_uv_reflection_fragment>
- vec3 getSample( float theta, vec3 axis ) {
-
- float cosTheta = cos( theta );
- // Rodrigues' axis-angle rotation
- vec3 sampleDirection = vOutputDirection * cosTheta
- + cross( axis, vOutputDirection ) * sin( theta )
- + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
-
- return bilinearCubeUV( envMap, sampleDirection, mipInt );
-
- }
+ #define PI 3.14159265359
+ #define GOLDEN_ANGLE 2.39996322973
void main() {
- vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
+ if ( sigma == 0.0 ) {
- if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
-
- axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
+ gl_FragColor = vec4( bilinearCubeUV( envMap, vOutputDirection, mipInt ), 1.0 );
+ return;
}
- axis = normalize( axis );
+ vec3 outputDirection = normalize( vOutputDirection );
- gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
- gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
+ vec3 up = abs( outputDirection.z ) < 0.999 ? vec3( 0.0, 0.0, 1.0 ) : vec3( 1.0, 0.0, 0.0 );
+ vec3 tangent = normalize( cross( up, outputDirection ) );
+ vec3 bitangent = cross( outputDirection, tangent );
- for ( int i = 1; i < n; i++ ) {
+ // Truncate the kernel at three standard deviations or at the antipode.
+ float thetaMax = min( 3.0 * sigma, PI );
+ float truncation = 1.0 - exp( - 0.5 * thetaMax * thetaMax / ( sigma * sigma ) );
- if ( i >= samples ) {
+ vec3 accumColor = vec3( 0.0 );
+ float accumWeight = 0.0;
- break;
+ for ( int i = 0; i < SAMPLES; i ++ ) {
- }
+ // Stratified inverse-CDF sampling of the Gaussian, placed on a golden-angle spiral.
+ float stratum = ( float( i ) + 0.5 ) / float( SAMPLES );
+ float theta = sigma * sqrt( - 2.0 * log( 1.0 - stratum * truncation ) );
+ float phi = float( i ) * GOLDEN_ANGLE;
+
+ vec3 offset = cos( phi ) * tangent + sin( phi ) * bitangent;
+ vec3 sampleDirection = cos( theta ) * outputDirection + sin( theta ) * offset;
- float theta = dTheta * float( i );
- gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
- gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
+ // Correct the planar sample density to solid angle.
+ float weight = sin( theta ) / theta;
+
+ accumColor += weight * bilinearCubeUV( envMap, sampleDirection, mipInt );
+ accumWeight += weight;
}
+ gl_FragColor = vec4( accumColor / accumWeight, 1.0 );
+
}
- `,blending:Ji,depthTest:!1,depthWrite:!1})}function F0(){return new ai({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:vh(),fragmentShader:`
+ `,blending:bs,depthTest:!1,depthWrite:!1})}function N_(){return new bi({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Mu(),fragmentShader:`
precision mediump float;
precision mediump int;
@@ -187,7 +187,7 @@ var xv=Object.create;var wc=Object.defineProperty;var _v=Object.getOwnPropertyDe
gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
}
- `,blending:Ji,depthTest:!1,depthWrite:!1})}function U0(){return new ai({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:vh(),fragmentShader:`
+ `,blending:bs,depthTest:!1,depthWrite:!1})}function O_(){return new bi({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Mu(),fragmentShader:`
precision mediump float;
precision mediump int;
@@ -203,62 +203,22 @@ var xv=Object.create;var wc=Object.defineProperty;var _v=Object.getOwnPropertyDe
gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
}
- `,blending:Ji,depthTest:!1,depthWrite:!1})}function vh(){return`
+ `,blending:bs,depthTest:!1,depthWrite:!1})}function Mu(){return`
precision mediump float;
precision mediump int;
- attribute float faceIndex;
+ attribute vec3 outputDirection;
varying vec3 vOutputDirection;
- // RH coordinate system; PMREM face-indexing convention
- vec3 getDirection( vec2 uv, float face ) {
-
- uv = 2.0 * uv - 1.0;
-
- vec3 direction = vec3( uv, 1.0 );
-
- if ( face == 0.0 ) {
-
- direction = direction.zyx; // ( 1, v, u ) pos x
-
- } else if ( face == 1.0 ) {
-
- direction = direction.xzy;
- direction.xz *= -1.0; // ( -u, 1, -v ) pos y
-
- } else if ( face == 2.0 ) {
-
- direction.x *= -1.0; // ( -u, v, 1 ) pos z
-
- } else if ( face == 3.0 ) {
-
- direction = direction.zyx;
- direction.xz *= -1.0; // ( -1, v, -u ) neg x
-
- } else if ( face == 4.0 ) {
-
- direction = direction.xzy;
- direction.xy *= -1.0; // ( -u, -1, v ) neg y
-
- } else if ( face == 5.0 ) {
-
- direction.z *= -1.0; // ( u, v, -1 ) neg z
-
- }
-
- return direction;
-
- }
-
void main() {
- vOutputDirection = getDirection( uv, faceIndex );
+ vOutputDirection = outputDirection;
gl_Position = vec4( position, 1.0 );
}
- `}function yM(i){let e=new WeakMap,t=new WeakMap,n=null;function r(f,p=!1){return f==null?null:p?a(f):s(f)}function s(f){if(f&&f.isTexture){let p=f.mapping;if(p===Cl||p===Il)if(e.has(f)){let x=e.get(f).texture;return o(x,f.mapping)}else{let x=f.image;if(x&&x.height>0){let y=new Ma(x.height);return y.fromEquirectangularTexture(i,f),e.set(f,y),f.addEventListener("dispose",c),o(y.texture,f.mapping)}else return null}}return f}function a(f){if(f&&f.isTexture){let p=f.mapping,x=p===Cl||p===Il,y=p===$r||p===As;if(x||y){let b=t.get(f),g=b!==void 0?b.texture.pmremVersion:0;if(f.isRenderTargetTexture&&f.pmremVersion!==g)return n===null&&(n=new wa(i)),b=x?n.fromEquirectangular(f,b):n.fromCubemap(f,b),b.texture.pmremVersion=f.pmremVersion,t.set(f,b),b.texture;if(b!==void 0)return b.texture;{let S=f.image;return x&&S&&S.height>0||y&&S&&l(S)?(n===null&&(n=new wa(i)),b=x?n.fromEquirectangular(f):n.fromCubemap(f),b.texture.pmremVersion=f.pmremVersion,t.set(f,b),f.addEventListener("dispose",h),b.texture):null}}}return f}function o(f,p){return p===Cl?f.mapping=$r:p===Il&&(f.mapping=As),f}function l(f){let p=0,x=6;for(let y=0;y<x;y++)f[y]!==void 0&&p++;return p===x}function c(f){let p=f.target;p.removeEventListener("dispose",c);let x=e.get(p);x!==void 0&&(e.delete(p),x.dispose())}function h(f){let p=f.target;p.removeEventListener("dispose",h);let x=t.get(p);x!==void 0&&(t.delete(p),x.dispose())}function d(){e=new WeakMap,t=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:r,dispose:d}}function vM(i){let e={};function t(n){if(e[n]!==void 0)return e[n];let r=i.getExtension(n);return e[n]=r,r}return{has:function(n){return t(n)!==null},init:function(){t("EXT_color_buffer_float"),t("WEBGL_clip_cull_distance"),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture"),t("WEBGL_render_shared_exponent")},get:function(n){let r=t(n);return r===null&&al("WebGLRenderer: "+n+" extension not supported."),r}}}function SM(i,e,t,n){let r={},s=new WeakMap;function a(d){let f=d.target;f.index!==null&&e.remove(f.index);for(let x in f.attributes)e.remove(f.attributes[x]);f.removeEventListener("dispose",a),delete r[f.id];let p=s.get(f);p&&(e.remove(p),s.delete(f)),n.releaseStatesOfGeometry(f),f.isInstancedBufferGeometry===!0&&delete f._maxInstanceCount,t.memory.geometries--}function o(d,f){return r[f.id]===!0||(f.addEventListener("dispose",a),r[f.id]=!0,t.memory.geometries++),f}function l(d){let f=d.attributes;for(let p in f)e.update(f[p],i.ARRAY_BUFFER)}function c(d){let f=[],p=d.index,x=d.attributes.position,y=0;if(x===void 0)return;if(p!==null){let S=p.array;y=p.version;for(let A=0,T=S.length;A<T;A+=3){let N=S[A+0],P=S[A+1],U=S[A+2];f.push(N,P,P,U,U,N)}}else{let S=x.array;y=x.version;for(let A=0,T=S.length/3-1;A<T;A+=3){let N=A+0,P=A+1,U=A+2;f.push(N,P,P,U,U,N)}}let b=new(x.count>=65535?ro:io)(f,1);b.version=y;let g=s.get(d);g&&e.remove(g),s.set(d,b)}function h(d){let f=s.get(d);if(f){let p=d.index;p!==null&&f.version<p.version&&c(d)}else c(d);return s.get(d)}return{get:o,update:l,getWireframeAttribute:h}}function wM(i,e,t){let n;function r(d){n=d}let s,a;function o(d){s=d.type,a=d.bytesPerElement}function l(d,f){i.drawElements(n,f,s,d*a),t.update(f,n,1)}function c(d,f,p){p!==0&&(i.drawElementsInstanced(n,f,s,d*a,p),t.update(f,n,p))}function h(d,f,p){if(p===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,f,0,s,d,0,p);let y=0;for(let b=0;b<p;b++)y+=f[b];t.update(y,n,1)}this.setMode=r,this.setIndex=o,this.render=l,this.renderInstances=c,this.renderMultiDraw=h}function MM(i){let e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function n(s,a,o){switch(t.calls++,a){case i.TRIANGLES:t.triangles+=o*(s/3);break;case i.LINES:t.lines+=o*(s/2);break;case i.LINE_STRIP:t.lines+=o*(s-1);break;case i.LINE_LOOP:t.lines+=o*s;break;case i.POINTS:t.points+=o*s;break;default:et("WebGLInfo: Unknown draw mode:",a);break}}function r(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:r,update:n}}function AM(i,e,t){let n=new WeakMap,r=new kt;function s(a,o,l){let c=a.morphTargetInfluences,h=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,d=h!==void 0?h.length:0,f=n.get(o);if(f===void 0||f.count!==d){let I=function(){U.dispose(),n.delete(o),o.removeEventListener("dispose",I)};f!==void 0&&f.texture.dispose();let p=o.morphAttributes.position!==void 0,x=o.morphAttributes.normal!==void 0,y=o.morphAttributes.color!==void 0,b=o.morphAttributes.position||[],g=o.morphAttributes.normal||[],S=o.morphAttributes.color||[],A=0;p===!0&&(A=1),x===!0&&(A=2),y===!0&&(A=3);let T=o.attributes.position.count*A,N=1;T>e.maxTextureSize&&(N=Math.ceil(T/e.maxTextureSize),T=e.maxTextureSize);let P=new Float32Array(T*N*4*d),U=new to(P,T,N,d);U.type=Tn,U.needsUpdate=!0;let v=A*4;for(let B=0;B<d;B++){let k=b[B],V=g[B],J=S[B],L=T*N*4*B;for(let E=0;E<k.count;E++){let D=E*v;p===!0&&(r.fromBufferAttribute(k,E),P[L+D+0]=r.x,P[L+D+1]=r.y,P[L+D+2]=r.z,P[L+D+3]=0),x===!0&&(r.fromBufferAttribute(V,E),P[L+D+4]=r.x,P[L+D+5]=r.y,P[L+D+6]=r.z,P[L+D+7]=0),y===!0&&(r.fromBufferAttribute(J,E),P[L+D+8]=r.x,P[L+D+9]=r.y,P[L+D+10]=r.z,P[L+D+11]=J.itemSize===4?r.w:1)}}f={count:d,texture:U,size:new dt(T,N)},n.set(o,f),o.addEventListener("dispose",I)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)l.getUniforms().setValue(i,"morphTexture",a.morphTexture,t);else{let p=0;for(let y=0;y<c.length;y++)p+=c[y];let x=o.morphTargetsRelative?1:1-p;l.getUniforms().setValue(i,"morphTargetBaseInfluence",x),l.getUniforms().setValue(i,"morphTargetInfluences",c)}l.getUniforms().setValue(i,"morphTargetsTexture",f.texture,t),l.getUniforms().setValue(i,"morphTargetsTextureSize",f.size)}return{update:s}}function TM(i,e,t,n,r){let s=new WeakMap;function a(c){let h=r.render.frame,d=c.geometry,f=e.get(c,d);if(s.get(f)!==h&&(e.update(f),s.set(f,h)),c.isInstancedMesh&&(c.hasEventListener("dispose",l)===!1&&c.addEventListener("dispose",l),s.get(c)!==h&&(t.update(c.instanceMatrix,i.ARRAY_BUFFER),c.instanceColor!==null&&t.update(c.instanceColor,i.ARRAY_BUFFER),s.set(c,h))),c.isSkinnedMesh){let p=c.skeleton;s.get(p)!==h&&(p.update(),s.set(p,h))}return f}function o(){s=new WeakMap}function l(c){let h=c.target;h.removeEventListener("dispose",l),n.releaseStatesOfObject(h),t.remove(h.instanceMatrix),h.instanceColor!==null&&t.remove(h.instanceColor)}return{update:a,dispose:o}}function RM(i,e,t,n,r){let s=new Hn(e,t,{type:i,depthBuffer:n,stencilBuffer:r,depthTexture:n?new pr(e,t):void 0}),a=new Hn(e,t,{type:Gn,depthBuffer:!1,stencilBuffer:!1}),o=new mn;o.setAttribute("position",new Qt([-1,3,0,-1,-1,0,3,-1,0],3)),o.setAttribute("uv",new Qt([0,2,0,0,2,0],2));let l=new fl({uniforms:{tDiffuse:{value:null}},vertexShader:`
+ `}function ET(i){let e=new WeakMap,t=new WeakMap,n=null;function s(d,p=!1){return d==null?null:p?a(d):r(d)}function r(d){if(d&&d.isTexture){let p=d.mapping;if(p===Lh||p===Dh)if(e.has(d)){let b=e.get(d).texture;return o(b,d.mapping)}else{let b=d.image;if(b&&b.height>0){let v=new fo(b.height);return v.fromEquirectangularTexture(i,d),e.set(d,v),d.addEventListener("dispose",l),o(v.texture,d.mapping)}else return null}}return d}function a(d){if(d&&d.isTexture){let p=d.mapping,b=p===Lh||p===Dh,v=p===vr||p===na;if(b||v){let _=t.get(d),g=_!==void 0?_.texture.pmremVersion:0;if(d.isRenderTargetTexture&&d.pmremVersion!==g)return n===null&&(n=new uo(i)),_=b?n.fromEquirectangular(d,_):n.fromCubemap(d,_),_.texture.pmremVersion=d.pmremVersion,t.set(d,_),_.texture;if(_!==void 0)return _.texture;{let E=d.image;return b&&E&&E.height>0||v&&E&&c(E)?(n===null&&(n=new uo(i)),_=b?n.fromEquirectangular(d):n.fromCubemap(d),_.texture.pmremVersion=d.pmremVersion,t.set(d,_),d.addEventListener("dispose",h),_.texture):null}}}return d}function o(d,p){return p===Lh?d.mapping=vr:p===Dh&&(d.mapping=na),d}function c(d){let p=0,b=6;for(let v=0;v<b;v++)d[v]!==void 0&&p++;return p===b}function l(d){let p=d.target;p.removeEventListener("dispose",l);let b=e.get(p);b!==void 0&&(e.delete(p),b.dispose())}function h(d){let p=d.target;p.removeEventListener("dispose",h);let b=t.get(p);b!==void 0&&(t.delete(p),b.dispose())}function u(){e=new WeakMap,t=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:s,dispose:u}}function AT(i){let e={};function t(n){if(e[n]!==void 0)return e[n];let s=i.getExtension(n);return e[n]=s,s}return{has:function(n){return t(n)!==null},init:function(){t("EXT_color_buffer_float"),t("WEBGL_clip_cull_distance"),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture"),t("WEBGL_render_shared_exponent")},get:function(n){let s=t(n);return s===null&&$r("WebGLRenderer: "+n+" extension not supported."),s}}}function TT(i,e,t,n){let s={},r=new WeakMap;function a(u){let d=u.target;d.index!==null&&e.remove(d.index);for(let b in d.attributes)e.remove(d.attributes[b]);d.removeEventListener("dispose",a),delete s[d.id];let p=r.get(d);p&&(e.remove(p),r.delete(d)),n.releaseStatesOfGeometry(d),d.isInstancedBufferGeometry===!0&&delete d._maxInstanceCount,t.memory.geometries--}function o(u,d){return s[d.id]===!0||(d.addEventListener("dispose",a),s[d.id]=!0,t.memory.geometries++),d}function c(u){let d=u.attributes;for(let p in d)e.update(d[p],i.ARRAY_BUFFER)}function l(u){let d=[],p=u.index,b=u.attributes.position,v=0;if(b===void 0)return;if(p!==null){let E=p.array;v=p.version;for(let L=0,S=E.length;L<S;L+=3){let M=E[L+0],A=E[L+1],I=E[L+2];d.push(M,A,A,I,I,M)}}else{let E=b.array;v=b.version;for(let L=0,S=E.length/3-1;L<S;L+=3){let M=L+0,A=L+1,I=L+2;d.push(M,A,A,I,I,M)}}let _=new(b.count>=65535?Zo:Jo)(d,1);_.version=v;let g=r.get(u);g&&e.remove(g),r.set(u,_)}function h(u){let d=r.get(u);if(d){let p=u.index;p!==null&&d.version<p.version&&l(u)}else l(u);return r.get(u)}return{get:o,update:c,getWireframeAttribute:h}}function RT(i,e,t){let n;function s(u){n=u}let r,a;function o(u){r=u.type,a=u.bytesPerElement}function c(u,d){i.drawElements(n,d,r,u*a),t.update(d,n,1)}function l(u,d,p){p!==0&&(i.drawElementsInstanced(n,d,r,u*a,p),t.update(d,n,p))}function h(u,d,p){if(p===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,d,0,r,u,0,p);let v=0;for(let _=0;_<p;_++)v+=d[_];t.update(v,n,1)}this.setMode=s,this.setIndex=o,this.render=c,this.renderInstances=l,this.renderMultiDraw=h}function CT(i){let e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function n(r,a,o){switch(t.calls++,a){case i.TRIANGLES:t.triangles+=o*(r/3);break;case i.LINES:t.lines+=o*(r/2);break;case i.LINE_STRIP:t.lines+=o*(r-1);break;case i.LINE_LOOP:t.lines+=o*r;break;case i.POINTS:t.points+=o*r;break;default:st("WebGLInfo: Unknown draw mode:",a);break}}function s(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:s,update:n}}function IT(i,e,t){let n=new WeakMap,s=new Gt;function r(a,o,c){let l=a.morphTargetInfluences,h=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,u=h!==void 0?h.length:0,d=n.get(o);if(d===void 0||d.count!==u){let C=function(){I.dispose(),n.delete(o),o.removeEventListener("dispose",C)};d!==void 0&&d.texture.dispose();let p=o.morphAttributes.position!==void 0,b=o.morphAttributes.normal!==void 0,v=o.morphAttributes.color!==void 0,_=o.morphAttributes.position||[],g=o.morphAttributes.normal||[],E=o.morphAttributes.color||[],L=0;p===!0&&(L=1),b===!0&&(L=2),v===!0&&(L=3);let S=o.attributes.position.count*L,M=1;S>e.maxTextureSize&&(M=Math.ceil(S/e.maxTextureSize),S=e.maxTextureSize);let A=new Float32Array(S*M*4*u),I=new Ko(A,S,M,u);I.type=qn,I.needsUpdate=!0;let y=L*4;for(let k=0;k<u;k++){let z=_[k],$=g[k],K=E[k],P=S*M*4*k;for(let N=0;N<z.count;N++){let O=N*y;p===!0&&(s.fromBufferAttribute(z,N),A[P+O+0]=s.x,A[P+O+1]=s.y,A[P+O+2]=s.z,A[P+O+3]=0),b===!0&&(s.fromBufferAttribute($,N),A[P+O+4]=s.x,A[P+O+5]=s.y,A[P+O+6]=s.z,A[P+O+7]=0),v===!0&&(s.fromBufferAttribute(K,N),A[P+O+8]=s.x,A[P+O+9]=s.y,A[P+O+10]=s.z,A[P+O+11]=K.itemSize===4?s.w:1)}}d={count:u,texture:I,size:new dt(S,M)},n.set(o,d),o.addEventListener("dispose",C)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)c.getUniforms().setValue(i,"morphTexture",a.morphTexture,t);else{let p=0;for(let v=0;v<l.length;v++)p+=l[v];let b=o.morphTargetsRelative?1:1-p;c.getUniforms().setValue(i,"morphTargetBaseInfluence",b),c.getUniforms().setValue(i,"morphTargetInfluences",l)}c.getUniforms().setValue(i,"morphTargetsTexture",d.texture,t),c.getUniforms().setValue(i,"morphTargetsTextureSize",d.size)}return{update:r}}function PT(i,e,t,n,s){let r=new WeakMap;function a(l){let h=s.render.frame,u=l.geometry,d=e.get(l,u);if(r.get(d)!==h&&(e.update(d),r.set(d,h)),l.isInstancedMesh&&(l.hasEventListener("dispose",c)===!1&&l.addEventListener("dispose",c),r.get(l)!==h&&(t.update(l.instanceMatrix,i.ARRAY_BUFFER),l.instanceColor!==null&&t.update(l.instanceColor,i.ARRAY_BUFFER),r.set(l,h))),l.isSkinnedMesh){let p=l.skeleton;r.get(p)!==h&&(p.update(),r.set(p,h))}return d}function o(){r=new WeakMap}function c(l){let h=l.target;h.removeEventListener("dispose",c),n.releaseStatesOfObject(h),t.remove(h.instanceMatrix),h.instanceColor!==null&&t.remove(h.instanceColor)}return{update:a,dispose:o}}function DT(i,e,t,n,s,r){let a=new Gn(e,t,{type:i,depthBuffer:s,stencilBuffer:r,samples:n?4:0,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,resolveDepthBuffer:!1,resolveStencilBuffer:!1}),o=null,c=null,l=new pn;l.setAttribute("position",new sn([-1,3,0,-1,-1,0,3,-1,0],3)),l.setAttribute("uv",new sn([0,2,0,0,2,0],2));let h=new gh({uniforms:{tDiffuse:{value:null}},vertexShader:`
precision highp float;
uniform mat4 modelViewMatrix;
@@ -304,17 +264,17 @@ var xv=Object.create;var wc=Object.defineProperty;var _v=Object.getOwnPropertyDe
#ifdef SRGB_TRANSFER
gl_FragColor = sRGBTransferOETF( gl_FragColor );
#endif
- }`,depthTest:!1,depthWrite:!1}),c=new xt(o,l),h=new Wr(-1,1,1,-1,0,1),d=null,f=null,p=!1,x,y=null,b=[],g=!1;this.setSize=function(S,A){s.setSize(S,A),a.setSize(S,A);for(let T=0;T<b.length;T++){let N=b[T];N.setSize&&N.setSize(S,A)}},this.setEffects=function(S){b=S,g=b.length>0&&b[0].isRenderPass===!0;let A=s.width,T=s.height;for(let N=0;N<b.length;N++){let P=b[N];P.setSize&&P.setSize(A,T)}},this.begin=function(S,A){if(p||S.toneMapping===Ni&&b.length===0)return!1;if(y=A,A!==null){let T=A.width,N=A.height;(s.width!==T||s.height!==N)&&this.setSize(T,N)}return g===!1&&S.setRenderTarget(s),x=S.toneMapping,S.toneMapping=Ni,!0},this.hasRenderPass=function(){return g},this.end=function(S,A){S.toneMapping=x,p=!0;let T=s,N=a;for(let P=0;P<b.length;P++){let U=b[P];if(U.enabled!==!1&&(U.render(S,N,T,A),U.needsSwap!==!1)){let v=T;T=N,N=v}}if(d!==S.outputColorSpace||f!==S.toneMapping){d=S.outputColorSpace,f=S.toneMapping,l.defines={},ut.getTransfer(d)===Dt&&(l.defines.SRGB_TRANSFER="");let P=EM[f];P&&(l.defines[P]=""),l.needsUpdate=!0}l.uniforms.tDiffuse.value=T.texture,S.setRenderTarget(y),S.render(c,h),y=null,p=!1},this.isCompositing=function(){return p},this.dispose=function(){s.depthTexture&&s.depthTexture.dispose(),s.dispose(),a.dispose(),o.dispose(),l.dispose()}}function Aa(i,e,t){let n=i[0];if(n<=0||n>0)return i;let r=e*t,s=k0[r];if(s===void 0&&(s=new Float32Array(r),k0[r]=s),e!==0){n.toArray(s,0);for(let a=1,o=0;a!==e;++a)o+=t,i[a].toArray(s,o)}return s}function _n(i,e){if(i.length!==e.length)return!1;for(let t=0,n=i.length;t<n;t++)if(i[t]!==e[t])return!1;return!0}function yn(i,e){for(let t=0,n=e.length;t<n;t++)i[t]=e[t]}function Sh(i,e){let t=B0[e];t===void 0&&(t=new Int32Array(e),B0[e]=t);for(let n=0;n!==e;++n)t[n]=i.allocateTextureUnit();return t}function CM(i,e){let t=this.cache;t[0]!==e&&(i.uniform1f(this.addr,e),t[0]=e)}function IM(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(_n(t,e))return;i.uniform2fv(this.addr,e),yn(t,e)}}function PM(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(i.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(_n(t,e))return;i.uniform3fv(this.addr,e),yn(t,e)}}function LM(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(_n(t,e))return;i.uniform4fv(this.addr,e),yn(t,e)}}function DM(i,e){let t=this.cache,n=e.elements;if(n===void 0){if(_n(t,e))return;i.uniformMatrix2fv(this.addr,!1,e),yn(t,e)}else{if(_n(t,n))return;G0.set(n),i.uniformMatrix2fv(this.addr,!1,G0),yn(t,n)}}function NM(i,e){let t=this.cache,n=e.elements;if(n===void 0){if(_n(t,e))return;i.uniformMatrix3fv(this.addr,!1,e),yn(t,e)}else{if(_n(t,n))return;H0.set(n),i.uniformMatrix3fv(this.addr,!1,H0),yn(t,n)}}function OM(i,e){let t=this.cache,n=e.elements;if(n===void 0){if(_n(t,e))return;i.uniformMatrix4fv(this.addr,!1,e),yn(t,e)}else{if(_n(t,n))return;z0.set(n),i.uniformMatrix4fv(this.addr,!1,z0),yn(t,n)}}function FM(i,e){let t=this.cache;t[0]!==e&&(i.uniform1i(this.addr,e),t[0]=e)}function UM(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(_n(t,e))return;i.uniform2iv(this.addr,e),yn(t,e)}}function kM(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(_n(t,e))return;i.uniform3iv(this.addr,e),yn(t,e)}}function BM(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.uniform4i(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(_n(t,e))return;i.uniform4iv(this.addr,e),yn(t,e)}}function zM(i,e){let t=this.cache;t[0]!==e&&(i.uniform1ui(this.addr,e),t[0]=e)}function HM(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(_n(t,e))return;i.uniform2uiv(this.addr,e),yn(t,e)}}function GM(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(_n(t,e))return;i.uniform3uiv(this.addr,e),yn(t,e)}}function VM(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.uniform4ui(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(_n(t,e))return;i.uniform4uiv(this.addr,e),yn(t,e)}}function WM(i,e,t){let n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r);let s;this.type===i.SAMPLER_2D_SHADOW?(af.compareFunction=t.isReversedDepthBuffer()?bh:gh,s=af):s=ib,t.setTexture2D(e||s,r)}function qM(i,e,t){let n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),t.setTexture3D(e||sb,r)}function $M(i,e,t){let n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),t.setTextureCube(e||ab,r)}function jM(i,e,t){let n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),t.setTexture2DArray(e||rb,r)}function XM(i){switch(i){case 5126:return CM;case 35664:return IM;case 35665:return PM;case 35666:return LM;case 35674:return DM;case 35675:return NM;case 35676:return OM;case 5124:case 35670:return FM;case 35667:case 35671:return UM;case 35668:case 35672:return kM;case 35669:case 35673:return BM;case 5125:return zM;case 36294:return HM;case 36295:return GM;case 36296:return VM;case 35678:case 36198:case 36298:case 36306:case 35682:return WM;case 35679:case 36299:case 36307:return qM;case 35680:case 36300:case 36308:case 36293:return $M;case 36289:case 36303:case 36311:case 36292:return jM}}function KM(i,e){i.uniform1fv(this.addr,e)}function YM(i,e){let t=Aa(e,this.size,2);i.uniform2fv(this.addr,t)}function JM(i,e){let t=Aa(e,this.size,3);i.uniform3fv(this.addr,t)}function ZM(i,e){let t=Aa(e,this.size,4);i.uniform4fv(this.addr,t)}function QM(i,e){let t=Aa(e,this.size,4);i.uniformMatrix2fv(this.addr,!1,t)}function eA(i,e){let t=Aa(e,this.size,9);i.uniformMatrix3fv(this.addr,!1,t)}function tA(i,e){let t=Aa(e,this.size,16);i.uniformMatrix4fv(this.addr,!1,t)}function nA(i,e){i.uniform1iv(this.addr,e)}function iA(i,e){i.uniform2iv(this.addr,e)}function rA(i,e){i.uniform3iv(this.addr,e)}function sA(i,e){i.uniform4iv(this.addr,e)}function aA(i,e){i.uniform1uiv(this.addr,e)}function oA(i,e){i.uniform2uiv(this.addr,e)}function cA(i,e){i.uniform3uiv(this.addr,e)}function lA(i,e){i.uniform4uiv(this.addr,e)}function hA(i,e,t){let n=this.cache,r=e.length,s=Sh(t,r);_n(n,s)||(i.uniform1iv(this.addr,s),yn(n,s));let a;this.type===i.SAMPLER_2D_SHADOW?a=af:a=ib;for(let o=0;o!==r;++o)t.setTexture2D(e[o]||a,s[o])}function uA(i,e,t){let n=this.cache,r=e.length,s=Sh(t,r);_n(n,s)||(i.uniform1iv(this.addr,s),yn(n,s));for(let a=0;a!==r;++a)t.setTexture3D(e[a]||sb,s[a])}function dA(i,e,t){let n=this.cache,r=e.length,s=Sh(t,r);_n(n,s)||(i.uniform1iv(this.addr,s),yn(n,s));for(let a=0;a!==r;++a)t.setTextureCube(e[a]||ab,s[a])}function fA(i,e,t){let n=this.cache,r=e.length,s=Sh(t,r);_n(n,s)||(i.uniform1iv(this.addr,s),yn(n,s));for(let a=0;a!==r;++a)t.setTexture2DArray(e[a]||rb,s[a])}function pA(i){switch(i){case 5126:return KM;case 35664:return YM;case 35665:return JM;case 35666:return ZM;case 35674:return QM;case 35675:return eA;case 35676:return tA;case 5124:case 35670:return nA;case 35667:case 35671:return iA;case 35668:case 35672:return rA;case 35669:case 35673:return sA;case 5125:return aA;case 36294:return oA;case 36295:return cA;case 36296:return lA;case 35678:case 36198:case 36298:case 36306:case 35682:return hA;case 35679:case 36299:case 36307:return uA;case 35680:case 36300:case 36308:case 36293:return dA;case 36289:case 36303:case 36311:case 36292:return fA}}function V0(i,e){i.seq.push(e),i.map[e.id]=e}function mA(i,e,t){let n=i.name,r=n.length;for(rf.lastIndex=0;;){let s=rf.exec(n),a=rf.lastIndex,o=s[1],l=s[2]==="]",c=s[3];if(l&&(o=o|0),c===void 0||c==="["&&a+2===r){V0(t,c===void 0?new of(o,i,e):new cf(o,i,e));break}else{let d=t.map[o];d===void 0&&(d=new lf(o),V0(t,d)),t=d}}}function W0(i,e,t){let n=i.createShader(e);return i.shaderSource(n,t),i.compileShader(n),n}function xA(i,e){let t=i.split(`
-`),n=[],r=Math.max(e-6,0),s=Math.min(e+6,t.length);for(let a=r;a<s;a++){let o=a+1;n.push(`${o===e?">":" "} ${o}: ${t[a]}`)}return n.join(`
-`)}function _A(i){ut._getMatrix(q0,ut.workingColorSpace,i);let e=`mat3( ${q0.elements.map(t=>t.toFixed(4))} )`;switch(ut.getTransfer(i)){case Qa:return[e,"LinearTransferOETF"];case Dt:return[e,"sRGBTransferOETF"];default:return Ke("WebGLProgram: Unsupported color space: ",i),[e,"LinearTransferOETF"]}}function $0(i,e,t){let n=i.getShaderParameter(e,i.COMPILE_STATUS),s=(i.getShaderInfoLog(e)||"").trim();if(n&&s==="")return"";let a=/ERROR: 0:(\d+)/.exec(s);if(a){let o=parseInt(a[1]);return t.toUpperCase()+`
+ }`,depthTest:!1,depthWrite:!1}),u=new vt(l,h),d=new xr(-1,1,1,-1,0,1),p=null,b=null,v=!1,_,g=null,E=[],L=!1;this.setSize=function(S,M){a.setSize(S,M),o!==null&&o.setSize(S,M),c!==null&&c.setSize(S,M);for(let A=0;A<E.length;A++){let I=E[A];I.setSize&&I.setSize(S,M)}},this.setEffects=function(S){E=S,L=E.length>0&&E[0].isRenderPass===!0;let M=a.width,A=a.height;E.length>0&&o===null&&(o=new Gn(M,A,{type:Zn,depthBuffer:!1,stencilBuffer:!1}),c=new Gn(M,A,{type:Zn,depthBuffer:!1,stencilBuffer:!1}));for(let I=0;I<E.length;I++){let y=E[I];y.setSize&&y.setSize(M,A)}},this.begin=function(S,M){if(v||S.toneMapping===Ji&&E.length===0)return!1;if(g=M,M!==null){let A=M.width,I=M.height;(a.width!==A||a.height!==I)&&this.setSize(A,I)}return L===!1&&S.setRenderTarget(a),_=S.toneMapping,S.toneMapping=Ji,!0},this.hasRenderPass=function(){return L},this.end=function(S,M){S.toneMapping=_,v=!0;let A=a,I=o;for(let y=0;y<E.length;y++){let C=E[y];C.enabled!==!1&&(C.render(S,I,A,M),C.needsSwap!==!1&&(A=I,I=I===o?c:o))}if(p!==S.outputColorSpace||b!==S.toneMapping){p=S.outputColorSpace,b=S.toneMapping,h.defines={},gt.getTransfer(p)===Bt&&(h.defines.SRGB_TRANSFER="");let y=LT[b];y&&(h.defines[y]=""),h.needsUpdate=!0}h.uniforms.tDiffuse.value=A.texture,S.setRenderTarget(g),S.render(u,d),g=null,v=!1},this.isCompositing=function(){return v},this.dispose=function(){a.dispose(),o!==null&&o.dispose(),c!==null&&c.dispose(),l.dispose(),h.dispose()}}function po(i,e,t){let n=i[0];if(n<=0||n>0)return i;let s=e*t,r=F_[s];if(r===void 0&&(r=new Float32Array(s),F_[s]=r),e!==0){n.toArray(r,0);for(let a=1,o=0;a!==e;++a)o+=t,i[a].toArray(r,o)}return r}function An(i,e){if(i.length!==e.length)return!1;for(let t=0,n=i.length;t<n;t++)if(i[t]!==e[t])return!1;return!0}function Tn(i,e){for(let t=0,n=e.length;t<n;t++)i[t]=e[t]}function Eu(i,e){let t=k_[e];t===void 0&&(t=new Int32Array(e),k_[e]=t);for(let n=0;n!==e;++n)t[n]=i.allocateTextureUnit();return t}function NT(i,e){let t=this.cache;t[0]!==e&&(i.uniform1f(this.addr,e),t[0]=e)}function OT(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(An(t,e))return;i.uniform2fv(this.addr,e),Tn(t,e)}}function FT(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(i.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(An(t,e))return;i.uniform3fv(this.addr,e),Tn(t,e)}}function kT(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(An(t,e))return;i.uniform4fv(this.addr,e),Tn(t,e)}}function UT(i,e){let t=this.cache,n=e.elements;if(n===void 0){if(An(t,e))return;i.uniformMatrix2fv(this.addr,!1,e),Tn(t,e)}else{if(An(t,n))return;z_.set(n),i.uniformMatrix2fv(this.addr,!1,z_),Tn(t,n)}}function BT(i,e){let t=this.cache,n=e.elements;if(n===void 0){if(An(t,e))return;i.uniformMatrix3fv(this.addr,!1,e),Tn(t,e)}else{if(An(t,n))return;B_.set(n),i.uniformMatrix3fv(this.addr,!1,B_),Tn(t,n)}}function zT(i,e){let t=this.cache,n=e.elements;if(n===void 0){if(An(t,e))return;i.uniformMatrix4fv(this.addr,!1,e),Tn(t,e)}else{if(An(t,n))return;U_.set(n),i.uniformMatrix4fv(this.addr,!1,U_),Tn(t,n)}}function HT(i,e){let t=this.cache;t[0]!==e&&(i.uniform1i(this.addr,e),t[0]=e)}function VT(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(An(t,e))return;i.uniform2iv(this.addr,e),Tn(t,e)}}function GT(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(An(t,e))return;i.uniform3iv(this.addr,e),Tn(t,e)}}function WT(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.uniform4i(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(An(t,e))return;i.uniform4iv(this.addr,e),Tn(t,e)}}function $T(i,e){let t=this.cache;t[0]!==e&&(i.uniform1ui(this.addr,e),t[0]=e)}function qT(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(An(t,e))return;i.uniform2uiv(this.addr,e),Tn(t,e)}}function jT(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(An(t,e))return;i.uniform3uiv(this.addr,e),Tn(t,e)}}function XT(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.uniform4ui(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(An(t,e))return;i.uniform4uiv(this.addr,e),Tn(t,e)}}function KT(i,e,t){let n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s);let r;this.type===i.SAMPLER_2D_SHADOW?(Np.compareFunction=t.isReversedDepthBuffer()?yu:xu,r=Np):r=tx,t.setTexture2D(e||r,s)}function YT(i,e,t){let n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),t.setTexture3D(e||ix,s)}function JT(i,e,t){let n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),t.setTextureCube(e||sx,s)}function ZT(i,e,t){let n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),t.setTexture2DArray(e||nx,s)}function QT(i){switch(i){case 5126:return NT;case 35664:return OT;case 35665:return FT;case 35666:return kT;case 35674:return UT;case 35675:return BT;case 35676:return zT;case 5124:case 35670:return HT;case 35667:case 35671:return VT;case 35668:case 35672:return GT;case 35669:case 35673:return WT;case 5125:return $T;case 36294:return qT;case 36295:return jT;case 36296:return XT;case 35678:case 36198:case 36298:case 36306:case 35682:return KT;case 35679:case 36299:case 36307:return YT;case 35680:case 36300:case 36308:case 36293:return JT;case 36289:case 36303:case 36311:case 36292:return ZT}}function eR(i,e){i.uniform1fv(this.addr,e)}function tR(i,e){let t=po(e,this.size,2);i.uniform2fv(this.addr,t)}function nR(i,e){let t=po(e,this.size,3);i.uniform3fv(this.addr,t)}function iR(i,e){let t=po(e,this.size,4);i.uniform4fv(this.addr,t)}function sR(i,e){let t=po(e,this.size,4);i.uniformMatrix2fv(this.addr,!1,t)}function rR(i,e){let t=po(e,this.size,9);i.uniformMatrix3fv(this.addr,!1,t)}function aR(i,e){let t=po(e,this.size,16);i.uniformMatrix4fv(this.addr,!1,t)}function oR(i,e){i.uniform1iv(this.addr,e)}function cR(i,e){i.uniform2iv(this.addr,e)}function lR(i,e){i.uniform3iv(this.addr,e)}function hR(i,e){i.uniform4iv(this.addr,e)}function uR(i,e){i.uniform1uiv(this.addr,e)}function fR(i,e){i.uniform2uiv(this.addr,e)}function dR(i,e){i.uniform3uiv(this.addr,e)}function pR(i,e){i.uniform4uiv(this.addr,e)}function mR(i,e,t){let n=this.cache,s=e.length,r=Eu(t,s);An(n,r)||(i.uniform1iv(this.addr,r),Tn(n,r));let a;this.type===i.SAMPLER_2D_SHADOW?a=Np:a=tx;for(let o=0;o!==s;++o)t.setTexture2D(e[o]||a,r[o])}function gR(i,e,t){let n=this.cache,s=e.length,r=Eu(t,s);An(n,r)||(i.uniform1iv(this.addr,r),Tn(n,r));for(let a=0;a!==s;++a)t.setTexture3D(e[a]||ix,r[a])}function bR(i,e,t){let n=this.cache,s=e.length,r=Eu(t,s);An(n,r)||(i.uniform1iv(this.addr,r),Tn(n,r));for(let a=0;a!==s;++a)t.setTextureCube(e[a]||sx,r[a])}function _R(i,e,t){let n=this.cache,s=e.length,r=Eu(t,s);An(n,r)||(i.uniform1iv(this.addr,r),Tn(n,r));for(let a=0;a!==s;++a)t.setTexture2DArray(e[a]||nx,r[a])}function xR(i){switch(i){case 5126:return eR;case 35664:return tR;case 35665:return nR;case 35666:return iR;case 35674:return sR;case 35675:return rR;case 35676:return aR;case 5124:case 35670:return oR;case 35667:case 35671:return cR;case 35668:case 35672:return lR;case 35669:case 35673:return hR;case 5125:return uR;case 36294:return fR;case 36295:return dR;case 36296:return pR;case 35678:case 36198:case 36298:case 36306:case 35682:return mR;case 35679:case 36299:case 36307:return gR;case 35680:case 36300:case 36308:case 36293:return bR;case 36289:case 36303:case 36311:case 36292:return _R}}function H_(i,e){i.seq.push(e),i.map[e.id]=e}function yR(i,e,t){let n=i.name,s=n.length;for(Lp.lastIndex=0;;){let r=Lp.exec(n),a=Lp.lastIndex,o=r[1],c=r[2]==="]",l=r[3];if(c&&(o=o|0),l===void 0||l==="["&&a+2===s){H_(t,l===void 0?new Op(o,i,e):new Fp(o,i,e));break}else{let u=t.map[o];u===void 0&&(u=new kp(o),H_(t,u)),t=u}}}function V_(i,e,t){let n=i.createShader(e);return i.shaderSource(n,t),i.compileShader(n),n}function wR(i,e){let t=i.split(`
+`),n=[],s=Math.max(e-6,0),r=Math.min(e+6,t.length);for(let a=s;a<r;a++){let o=a+1;n.push(`${o===e?">":" "} ${o}: ${t[a]}`)}return n.join(`
+`)}function MR(i){gt._getMatrix(G_,gt.workingColorSpace,i);let e=`mat3( ${G_.elements.map(t=>t.toFixed(4))} )`;switch(gt.getTransfer(i)){case jo:return[e,"LinearTransferOETF"];case Bt:return[e,"sRGBTransferOETF"];default:return tt("WebGLProgram: Unsupported color space: ",i),[e,"LinearTransferOETF"]}}function W_(i,e,t){let n=i.getShaderParameter(e,i.COMPILE_STATUS),r=(i.getShaderInfoLog(e)||"").trim();if(n&&r==="")return"";let a=/ERROR: 0:(\d+)/.exec(r);if(a){let o=parseInt(a[1]);return t.toUpperCase()+`
-`+s+`
+`+r+`
-`+xA(i.getShaderSource(e),o)}else return s}function yA(i,e){let t=_A(e);return[`vec4 ${i}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(`
-`)}function SA(i,e){let t=vA[e];return t===void 0?(Ke("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+i+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+i+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}function wA(){ut.getLuminanceCoefficients(_h);let i=_h.x.toFixed(4),e=_h.y.toFixed(4),t=_h.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${i}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(`
-`)}function MA(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Go).join(`
-`)}function AA(i){let e=[];for(let t in i){let n=i[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(`
-`)}function TA(i,e){let t={},n=i.getProgramParameter(e,i.ACTIVE_ATTRIBUTES);for(let r=0;r<n;r++){let s=i.getActiveAttrib(e,r),a=s.name,o=1;s.type===i.FLOAT_MAT2&&(o=2),s.type===i.FLOAT_MAT3&&(o=3),s.type===i.FLOAT_MAT4&&(o=4),t[a]={type:s.type,location:i.getAttribLocation(e,a),locationSize:o}}return t}function Go(i){return i!==""}function j0(i,e){let t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return i.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,t).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function X0(i,e){return i.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}function hf(i){return i.replace(EA,CA)}function CA(i,e){let t=ft[e];if(t===void 0){let n=RA.get(e);if(n!==void 0)t=ft[n],Ke('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,n);else throw new Error("Can not resolve #include <"+e+">")}return hf(t)}function K0(i){return i.replace(IA,PA)}function PA(i,e,t,n){let r="";for(let s=parseInt(e);s<parseInt(t);s++)r+=n.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return r}function Y0(i){let e=`precision ${i.precision} float;
+`+wR(i.getShaderSource(e),o)}else return r}function ER(i,e){let t=MR(e);return[`vec4 ${i}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(`
+`)}function TR(i,e){let t=AR[e];return t===void 0?(tt("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+i+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+i+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}function RR(){gt.getLuminanceCoefficients(Su);let i=Su.x.toFixed(4),e=Su.y.toFixed(4),t=Su.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${i}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(`
+`)}function CR(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Oc).join(`
+`)}function IR(i){let e=[];for(let t in i){let n=i[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(`
+`)}function PR(i,e){let t={},n=i.getProgramParameter(e,i.ACTIVE_ATTRIBUTES);for(let s=0;s<n;s++){let r=i.getActiveAttrib(e,s),a=r.name,o=1;r.type===i.FLOAT_MAT2&&(o=2),r.type===i.FLOAT_MAT3&&(o=3),r.type===i.FLOAT_MAT4&&(o=4),t[a]={type:r.type,location:i.getAttribLocation(e,a),locationSize:o}}return t}function Oc(i){return i!==""}function $_(i,e){let t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return i.replace(/NUM_SUN_LIGHTS/g,e.numSunLights).replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,t).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_SUN_LIGHT_SHADOWS/g,e.numSunLightShadows).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function q_(i,e){return i.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}function Up(i){return i.replace(LR,NR)}function NR(i,e){let t=_t[e];if(t===void 0){let n=DR.get(e);if(n!==void 0)t=_t[n],tt('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,n);else throw new Error("THREE.WebGLProgram: Can not resolve #include <"+e+">")}return Up(t)}function j_(i){return i.replace(OR,FR)}function FR(i,e,t,n){let s="";for(let r=parseInt(e);r<parseInt(t);r++)s+=n.replace(/\[\s*i\s*\]/g,"[ "+r+" ]").replace(/UNROLLED_LOOP_INDEX/g,r);return s}function X_(i){let e=`precision ${i.precision} float;
precision ${i.precision} int;
precision ${i.precision} sampler2D;
precision ${i.precision} samplerCube;
@@ -334,30 +294,30 @@ var xv=Object.create;var wc=Object.defineProperty;var _v=Object.getOwnPropertyDe
`;return i.precision==="highp"?e+=`
#define HIGH_PRECISION`:i.precision==="mediump"?e+=`
#define MEDIUM_PRECISION`:i.precision==="lowp"&&(e+=`
-#define LOW_PRECISION`),e}function DA(i){return LA[i.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}function OA(i){return i.envMap===!1?"ENVMAP_TYPE_CUBE":NA[i.envMapMode]||"ENVMAP_TYPE_CUBE"}function UA(i){return i.envMap===!1?"ENVMAP_MODE_REFLECTION":FA[i.envMapMode]||"ENVMAP_MODE_REFLECTION"}function BA(i){return i.envMap===!1?"ENVMAP_BLENDING_NONE":kA[i.combine]||"ENVMAP_BLENDING_NONE"}function zA(i){let e=i.envMapCubeUVHeight;if(e===null)return null;let t=Math.log2(e)-2,n=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),112)),texelHeight:n,maxMip:t}}function HA(i,e,t,n){let r=i.getContext(),s=t.defines,a=t.vertexShader,o=t.fragmentShader,l=DA(t),c=OA(t),h=UA(t),d=BA(t),f=zA(t),p=MA(t),x=AA(s),y=r.createProgram(),b,g,S=t.glslVersion?"#version "+t.glslVersion+`
-`:"";t.isRawShaderMaterial?(b=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,x].filter(Go).join(`
-`),b.length>0&&(b+=`
-`),g=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,x].filter(Go).join(`
+#define LOW_PRECISION`),e}function UR(i){return kR[i.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}function zR(i){return i.envMap===!1?"ENVMAP_TYPE_CUBE":BR[i.envMapMode]||"ENVMAP_TYPE_CUBE"}function VR(i){return i.envMap===!1?"ENVMAP_MODE_REFLECTION":HR[i.envMapMode]||"ENVMAP_MODE_REFLECTION"}function WR(i){return i.envMap===!1?"ENVMAP_BLENDING_NONE":GR[i.combine]||"ENVMAP_BLENDING_NONE"}function $R(i){let e=i.envMapCubeUVHeight;if(e===null)return null;let t=Math.log2(e)-2,n=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),112)),texelHeight:n,maxMip:t}}function qR(i,e,t,n){let s=i.getContext(),r=t.defines,a=t.vertexShader,o=t.fragmentShader,c=UR(t),l=zR(t),h=VR(t),u=WR(t),d=$R(t),p=CR(t),b=IR(r),v=s.createProgram(),_,g,E=t.glslVersion?"#version "+t.glslVersion+`
+`:"";t.isRawShaderMaterial?(_=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,b].filter(Oc).join(`
+`),_.length>0&&(_+=`
+`),g=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,b].filter(Oc).join(`
`),g.length>0&&(g+=`
-`)):(b=[Y0(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,x,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+h:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexNormals?"#define HAS_NORMAL":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
-`].filter(Go).join(`
-`),g=[Y0(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,x,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+c:"",t.envMap?"#define "+h:"",t.envMap?"#define "+d:"",f?"#define CUBEUV_TEXEL_WIDTH "+f.texelWidth:"",f?"#define CUBEUV_TEXEL_HEIGHT "+f.texelHeight:"",f?"#define CUBEUV_MAX_MIP "+f.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas||t.batchingColor?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==Ni?"#define TONE_MAPPING":"",t.toneMapping!==Ni?ft.tonemapping_pars_fragment:"",t.toneMapping!==Ni?SA("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",ft.colorspace_pars_fragment,yA("linearToOutputTexel",t.outputColorSpace),wA(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
-`].filter(Go).join(`
-`)),a=hf(a),a=j0(a,t),a=X0(a,t),o=hf(o),o=j0(o,t),o=X0(o,t),a=K0(a),o=K0(o),t.isRawShaderMaterial!==!0&&(S=`#version 300 es
-`,b=[p,"#define attribute in","#define varying out","#define texture2D texture"].join(`
+`)):(_=[X_(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,b,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+h:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexNormals?"#define HAS_NORMAL":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+c:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
+`].filter(Oc).join(`
+`),g=[X_(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,b,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+l:"",t.envMap?"#define "+h:"",t.envMap?"#define "+u:"",d?"#define CUBEUV_TEXEL_WIDTH "+d.texelWidth:"",d?"#define CUBEUV_TEXEL_HEIGHT "+d.texelHeight:"",d?"#define CUBEUV_MAX_MIP "+d.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.retroreflection?"#define USE_RETROREFLECTION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas||t.batchingColor?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+c:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==Ji?"#define TONE_MAPPING":"",t.toneMapping!==Ji?_t.tonemapping_pars_fragment:"",t.toneMapping!==Ji?TR("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",_t.colorspace_pars_fragment,ER("linearToOutputTexel",t.outputColorSpace),RR(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
+`].filter(Oc).join(`
+`)),a=Up(a),a=$_(a,t),a=q_(a,t),o=Up(o),o=$_(o,t),o=q_(o,t),a=j_(a),o=j_(o),t.isRawShaderMaterial!==!0&&(E=`#version 300 es
+`,_=[p,"#define attribute in","#define varying out","#define texture2D texture"].join(`
`)+`
-`+b,g=["#define varying in",t.glslVersion===Bd?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===Bd?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`
+`+_,g=["#define varying in",t.glslVersion===mp?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===mp?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`
`)+`
-`+g);let A=S+b+a,T=S+g+o,N=W0(r,r.VERTEX_SHADER,A),P=W0(r,r.FRAGMENT_SHADER,T);r.attachShader(y,N),r.attachShader(y,P),t.index0AttributeName!==void 0?r.bindAttribLocation(y,0,t.index0AttributeName):t.morphTargets===!0&&r.bindAttribLocation(y,0,"position"),r.linkProgram(y);function U(k){if(i.debug.checkShaderErrors){let V=r.getProgramInfoLog(y)||"",J=r.getShaderInfoLog(N)||"",L=r.getShaderInfoLog(P)||"",E=V.trim(),D=J.trim(),O=L.trim(),H=!0,Y=!0;if(r.getProgramParameter(y,r.LINK_STATUS)===!1)if(H=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(r,y,N,P);else{let le=$0(r,N,"vertex"),fe=$0(r,P,"fragment");et("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(y,r.VALIDATE_STATUS)+`
+`+g);let L=E+_+a,S=E+g+o,M=V_(s,s.VERTEX_SHADER,L),A=V_(s,s.FRAGMENT_SHADER,S);s.attachShader(v,M),s.attachShader(v,A),t.index0AttributeName!==void 0?s.bindAttribLocation(v,0,t.index0AttributeName):t.hasPositionAttribute===!0&&s.bindAttribLocation(v,0,"position"),s.linkProgram(v);function I(z){if(i.debug.checkShaderErrors){let $=s.getProgramInfoLog(v)||"",K=s.getShaderInfoLog(M)||"",P=s.getShaderInfoLog(A)||"",N=$.trim(),O=K.trim(),F=P.trim(),H=!0,V=!0;if(s.getProgramParameter(v,s.LINK_STATUS)===!1)if(H=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(s,v,M,A);else{let Q=W_(s,M,"vertex"),te=W_(s,A,"fragment");st("WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(v,s.VALIDATE_STATUS)+`
-Material Name: `+k.name+`
-Material Type: `+k.type+`
+Material Name: `+z.name+`
+Material Type: `+z.type+`
-Program Info Log: `+E+`
-`+le+`
-`+fe)}else E!==""?Ke("WebGLProgram: Program Info Log:",E):(D===""||O==="")&&(Y=!1);Y&&(k.diagnostics={runnable:H,programLog:E,vertexShader:{log:D,prefix:b},fragmentShader:{log:O,prefix:g}})}r.deleteShader(N),r.deleteShader(P),v=new Sa(r,y),I=TA(r,y)}let v;this.getUniforms=function(){return v===void 0&&U(this),v};let I;this.getAttributes=function(){return I===void 0&&U(this),I};let B=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return B===!1&&(B=r.getProgramParameter(y,gA)),B},this.destroy=function(){n.releaseStatesOfProgram(this),r.deleteProgram(y),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=bA++,this.cacheKey=e,this.usedTimes=1,this.program=y,this.vertexShader=N,this.fragmentShader=P,this}function VA(i){return i===Xr||i===No||i===Oo}function WA(i,e,t,n,r,s){let a=new la,o=new uf,l=new Set,c=[],h=new Map,d=n.logarithmicDepthBuffer,f=n.precision,p={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function x(v){return l.add(v),v===0?"uv":`uv${v}`}function y(v,I,B,k,V,J){let L=k.fog,E=V.geometry,D=v.isMeshStandardMaterial||v.isMeshLambertMaterial||v.isMeshPhongMaterial?k.environment:null,O=v.isMeshStandardMaterial||v.isMeshLambertMaterial&&!v.envMap||v.isMeshPhongMaterial&&!v.envMap,H=e.get(v.envMap||D,O),Y=H&&H.mapping===Co?H.image.height:null,le=p[v.type];v.precision!==null&&(f=n.getMaxPrecision(v.precision),f!==v.precision&&Ke("WebGLProgram.getParameters:",v.precision,"not supported, using",f,"instead."));let fe=E.morphAttributes.position||E.morphAttributes.normal||E.morphAttributes.color,be=fe!==void 0?fe.length:0,Te=0;E.morphAttributes.position!==void 0&&(Te=1),E.morphAttributes.normal!==void 0&&(Te=2),E.morphAttributes.color!==void 0&&(Te=3);let Je,ke,oe,Ee;if(le){let rt=Qi[le];Je=rt.vertexShader,ke=rt.fragmentShader}else Je=v.vertexShader,ke=v.fragmentShader,o.update(v),oe=o.getVertexShaderID(v),Ee=o.getFragmentShaderID(v);let _e=i.getRenderTarget(),Ze=i.state.buffers.depth.getReversed(),tt=V.isInstancedMesh===!0,Qe=V.isBatchedMesh===!0,Et=!!v.map,it=!!v.matcap,mt=!!H,wt=!!v.aoMap,lt=!!v.lightMap,Bt=!!v.bumpMap,gt=!!v.normalMap,Yt=!!v.displacementMap,q=!!v.emissiveMap,$t=!!v.metalnessMap,ht=!!v.roughnessMap,Tt=v.anisotropy>0,Pe=v.clearcoat>0,Ot=v.dispersion>0,F=v.iridescence>0,M=v.sheen>0,Z=v.transmission>0,pe=Tt&&!!v.anisotropyMap,ge=Pe&&!!v.clearcoatMap,Se=Pe&&!!v.clearcoatNormalMap,Ce=Pe&&!!v.clearcoatRoughnessMap,ce=F&&!!v.iridescenceMap,me=F&&!!v.iridescenceThicknessMap,Be=M&&!!v.sheenColorMap,Le=M&&!!v.sheenRoughnessMap,ve=!!v.specularMap,Me=!!v.specularColorMap,je=!!v.specularIntensityMap,nt=Z&&!!v.transmissionMap,pt=Z&&!!v.thicknessMap,G=!!v.gradientMap,we=!!v.alphaMap,de=v.alphaTest>0,He=!!v.alphaHash,Ae=!!v.extensions,xe=Ni;v.toneMapped&&(_e===null||_e.isXRRenderTarget===!0)&&(xe=i.toneMapping);let Xe={shaderID:le,shaderType:v.type,shaderName:v.name,vertexShader:Je,fragmentShader:ke,defines:v.defines,customVertexShaderID:oe,customFragmentShaderID:Ee,isRawShaderMaterial:v.isRawShaderMaterial===!0,glslVersion:v.glslVersion,precision:f,batching:Qe,batchingColor:Qe&&V._colorsTexture!==null,instancing:tt,instancingColor:tt&&V.instanceColor!==null,instancingMorph:tt&&V.morphTexture!==null,outputColorSpace:_e===null?i.outputColorSpace:_e.isXRRenderTarget===!0?_e.texture.colorSpace:ut.workingColorSpace,alphaToCoverage:!!v.alphaToCoverage,map:Et,matcap:it,envMap:mt,envMapMode:mt&&H.mapping,envMapCubeUVHeight:Y,aoMap:wt,lightMap:lt,bumpMap:Bt,normalMap:gt,displacementMap:Yt,emissiveMap:q,normalMapObjectSpace:gt&&v.normalMapType===b0,normalMapTangentSpace:gt&&v.normalMapType===Bo,packedNormalMap:gt&&v.normalMapType===Bo&&VA(v.normalMap.format),metalnessMap:$t,roughnessMap:ht,anisotropy:Tt,anisotropyMap:pe,clearcoat:Pe,clearcoatMap:ge,clearcoatNormalMap:Se,clearcoatRoughnessMap:Ce,dispersion:Ot,iridescence:F,iridescenceMap:ce,iridescenceThicknessMap:me,sheen:M,sheenColorMap:Be,sheenRoughnessMap:Le,specularMap:ve,specularColorMap:Me,specularIntensityMap:je,transmission:Z,transmissionMap:nt,thicknessMap:pt,gradientMap:G,opaque:v.transparent===!1&&v.blending===fs&&v.alphaToCoverage===!1,alphaMap:we,alphaTest:de,alphaHash:He,combine:v.combine,mapUv:Et&&x(v.map.channel),aoMapUv:wt&&x(v.aoMap.channel),lightMapUv:lt&&x(v.lightMap.channel),bumpMapUv:Bt&&x(v.bumpMap.channel),normalMapUv:gt&&x(v.normalMap.channel),displacementMapUv:Yt&&x(v.displacementMap.channel),emissiveMapUv:q&&x(v.emissiveMap.channel),metalnessMapUv:$t&&x(v.metalnessMap.channel),roughnessMapUv:ht&&x(v.roughnessMap.channel),anisotropyMapUv:pe&&x(v.anisotropyMap.channel),clearcoatMapUv:ge&&x(v.clearcoatMap.channel),clearcoatNormalMapUv:Se&&x(v.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Ce&&x(v.clearcoatRoughnessMap.channel),iridescenceMapUv:ce&&x(v.iridescenceMap.channel),iridescenceThicknessMapUv:me&&x(v.iridescenceThicknessMap.channel),sheenColorMapUv:Be&&x(v.sheenColorMap.channel),sheenRoughnessMapUv:Le&&x(v.sheenRoughnessMap.channel),specularMapUv:ve&&x(v.specularMap.channel),specularColorMapUv:Me&&x(v.specularColorMap.channel),specularIntensityMapUv:je&&x(v.specularIntensityMap.channel),transmissionMapUv:nt&&x(v.transmissionMap.channel),thicknessMapUv:pt&&x(v.thicknessMap.channel),alphaMapUv:we&&x(v.alphaMap.channel),vertexTangents:!!E.attributes.tangent&&(gt||Tt),vertexNormals:!!E.attributes.normal,vertexColors:v.vertexColors,vertexAlphas:v.vertexColors===!0&&!!E.attributes.color&&E.attributes.color.itemSize===4,pointsUvs:V.isPoints===!0&&!!E.attributes.uv&&(Et||we),fog:!!L,useFog:v.fog===!0,fogExp2:!!L&&L.isFogExp2,flatShading:v.wireframe===!1&&(v.flatShading===!0||E.attributes.normal===void 0&&gt===!1&&(v.isMeshLambertMaterial||v.isMeshPhongMaterial||v.isMeshStandardMaterial||v.isMeshPhysicalMaterial)),sizeAttenuation:v.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:Ze,skinning:V.isSkinnedMesh===!0,morphTargets:E.morphAttributes.position!==void 0,morphNormals:E.morphAttributes.normal!==void 0,morphColors:E.morphAttributes.color!==void 0,morphTargetsCount:be,morphTextureStride:Te,numDirLights:I.directional.length,numPointLights:I.point.length,numSpotLights:I.spot.length,numSpotLightMaps:I.spotLightMap.length,numRectAreaLights:I.rectArea.length,numHemiLights:I.hemi.length,numDirLightShadows:I.directionalShadowMap.length,numPointLightShadows:I.pointShadowMap.length,numSpotLightShadows:I.spotShadowMap.length,numSpotLightShadowsWithMaps:I.numSpotLightShadowsWithMaps,numLightProbes:I.numLightProbes,numLightProbeGrids:J.length,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:v.dithering,shadowMapEnabled:i.shadowMap.enabled&&B.length>0,shadowMapType:i.shadowMap.type,toneMapping:xe,decodeVideoTexture:Et&&v.map.isVideoTexture===!0&&ut.getTransfer(v.map.colorSpace)===Dt,decodeVideoTextureEmissive:q&&v.emissiveMap.isVideoTexture===!0&&ut.getTransfer(v.emissiveMap.colorSpace)===Dt,premultipliedAlpha:v.premultipliedAlpha,doubleSided:v.side===Dn,flipSided:v.side===An,useDepthPacking:v.depthPacking>=0,depthPacking:v.depthPacking||0,index0AttributeName:v.index0AttributeName,extensionClipCullDistance:Ae&&v.extensions.clipCullDistance===!0&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Ae&&v.extensions.multiDraw===!0||Qe)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:v.customProgramCacheKey()};return Xe.vertexUv1s=l.has(1),Xe.vertexUv2s=l.has(2),Xe.vertexUv3s=l.has(3),l.clear(),Xe}function b(v){let I=[];if(v.shaderID?I.push(v.shaderID):(I.push(v.customVertexShaderID),I.push(v.customFragmentShaderID)),v.defines!==void 0)for(let B in v.defines)I.push(B),I.push(v.defines[B]);return v.isRawShaderMaterial===!1&&(g(I,v),S(I,v),I.push(i.outputColorSpace)),I.push(v.customProgramCacheKey),I.join()}function g(v,I){v.push(I.precision),v.push(I.outputColorSpace),v.push(I.envMapMode),v.push(I.envMapCubeUVHeight),v.push(I.mapUv),v.push(I.alphaMapUv),v.push(I.lightMapUv),v.push(I.aoMapUv),v.push(I.bumpMapUv),v.push(I.normalMapUv),v.push(I.displacementMapUv),v.push(I.emissiveMapUv),v.push(I.metalnessMapUv),v.push(I.roughnessMapUv),v.push(I.anisotropyMapUv),v.push(I.clearcoatMapUv),v.push(I.clearcoatNormalMapUv),v.push(I.clearcoatRoughnessMapUv),v.push(I.iridescenceMapUv),v.push(I.iridescenceThicknessMapUv),v.push(I.sheenColorMapUv),v.push(I.sheenRoughnessMapUv),v.push(I.specularMapUv),v.push(I.specularColorMapUv),v.push(I.specularIntensityMapUv),v.push(I.transmissionMapUv),v.push(I.thicknessMapUv),v.push(I.combine),v.push(I.fogExp2),v.push(I.sizeAttenuation),v.push(I.morphTargetsCount),v.push(I.morphAttributeCount),v.push(I.numDirLights),v.push(I.numPointLights),v.push(I.numSpotLights),v.push(I.numSpotLightMaps),v.push(I.numHemiLights),v.push(I.numRectAreaLights),v.push(I.numDirLightShadows),v.push(I.numPointLightShadows),v.push(I.numSpotLightShadows),v.push(I.numSpotLightShadowsWithMaps),v.push(I.numLightProbes),v.push(I.shadowMapType),v.push(I.toneMapping),v.push(I.numClippingPlanes),v.push(I.numClipIntersection),v.push(I.depthPacking)}function S(v,I){a.disableAll(),I.instancing&&a.enable(0),I.instancingColor&&a.enable(1),I.instancingMorph&&a.enable(2),I.matcap&&a.enable(3),I.envMap&&a.enable(4),I.normalMapObjectSpace&&a.enable(5),I.normalMapTangentSpace&&a.enable(6),I.clearcoat&&a.enable(7),I.iridescence&&a.enable(8),I.alphaTest&&a.enable(9),I.vertexColors&&a.enable(10),I.vertexAlphas&&a.enable(11),I.vertexUv1s&&a.enable(12),I.vertexUv2s&&a.enable(13),I.vertexUv3s&&a.enable(14),I.vertexTangents&&a.enable(15),I.anisotropy&&a.enable(16),I.alphaHash&&a.enable(17),I.batching&&a.enable(18),I.dispersion&&a.enable(19),I.batchingColor&&a.enable(20),I.gradientMap&&a.enable(21),I.packedNormalMap&&a.enable(22),I.vertexNormals&&a.enable(23),v.push(a.mask),a.disableAll(),I.fog&&a.enable(0),I.useFog&&a.enable(1),I.flatShading&&a.enable(2),I.logarithmicDepthBuffer&&a.enable(3),I.reversedDepthBuffer&&a.enable(4),I.skinning&&a.enable(5),I.morphTargets&&a.enable(6),I.morphNormals&&a.enable(7),I.morphColors&&a.enable(8),I.premultipliedAlpha&&a.enable(9),I.shadowMapEnabled&&a.enable(10),I.doubleSided&&a.enable(11),I.flipSided&&a.enable(12),I.useDepthPacking&&a.enable(13),I.dithering&&a.enable(14),I.transmission&&a.enable(15),I.sheen&&a.enable(16),I.opaque&&a.enable(17),I.pointsUvs&&a.enable(18),I.decodeVideoTexture&&a.enable(19),I.decodeVideoTextureEmissive&&a.enable(20),I.alphaToCoverage&&a.enable(21),I.numLightProbeGrids>0&&a.enable(22),v.push(a.mask)}function A(v){let I=p[v.type],B;if(I){let k=Qi[I];B=I0.clone(k.uniforms)}else B=v.uniforms;return B}function T(v,I){let B=h.get(I);return B!==void 0?++B.usedTimes:(B=new HA(i,I,v,r),c.push(B),h.set(I,B)),B}function N(v){if(--v.usedTimes===0){let I=c.indexOf(v);c[I]=c[c.length-1],c.pop(),h.delete(v.cacheKey),v.destroy()}}function P(v){o.remove(v)}function U(){o.dispose()}return{getParameters:y,getProgramCacheKey:b,getUniforms:A,acquireProgram:T,releaseProgram:N,releaseShaderCache:P,programs:c,dispose:U}}function qA(){let i=new WeakMap;function e(a){return i.has(a)}function t(a){let o=i.get(a);return o===void 0&&(o={},i.set(a,o)),o}function n(a){i.delete(a)}function r(a,o,l){i.get(a)[o]=l}function s(){i=new WeakMap}return{has:e,get:t,remove:n,update:r,dispose:s}}function $A(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.material.id!==e.material.id?i.material.id-e.material.id:i.materialVariant!==e.materialVariant?i.materialVariant-e.materialVariant:i.z!==e.z?i.z-e.z:i.id-e.id}function J0(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.z!==e.z?e.z-i.z:i.id-e.id}function Z0(){let i=[],e=0,t=[],n=[],r=[];function s(){e=0,t.length=0,n.length=0,r.length=0}function a(f){let p=0;return f.isInstancedMesh&&(p+=2),f.isSkinnedMesh&&(p+=1),p}function o(f,p,x,y,b,g){let S=i[e];return S===void 0?(S={id:f.id,object:f,geometry:p,material:x,materialVariant:a(f),groupOrder:y,renderOrder:f.renderOrder,z:b,group:g},i[e]=S):(S.id=f.id,S.object=f,S.geometry=p,S.material=x,S.materialVariant=a(f),S.groupOrder=y,S.renderOrder=f.renderOrder,S.z=b,S.group=g),e++,S}function l(f,p,x,y,b,g){let S=o(f,p,x,y,b,g);x.transmission>0?n.push(S):x.transparent===!0?r.push(S):t.push(S)}function c(f,p,x,y,b,g){let S=o(f,p,x,y,b,g);x.transmission>0?n.unshift(S):x.transparent===!0?r.unshift(S):t.unshift(S)}function h(f,p){t.length>1&&t.sort(f||$A),n.length>1&&n.sort(p||J0),r.length>1&&r.sort(p||J0)}function d(){for(let f=e,p=i.length;f<p;f++){let x=i[f];if(x.id===null)break;x.id=null,x.object=null,x.geometry=null,x.material=null,x.group=null}}return{opaque:t,transmissive:n,transparent:r,init:s,push:l,unshift:c,finish:d,sort:h}}function jA(){let i=new WeakMap;function e(n,r){let s=i.get(n),a;return s===void 0?(a=new Z0,i.set(n,[a])):r>=s.length?(a=new Z0,s.push(a)):a=s[r],a}function t(){i=new WeakMap}return{get:e,dispose:t}}function XA(){let i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new W,color:new Ve};break;case"SpotLight":t={position:new W,direction:new W,color:new Ve,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new W,color:new Ve,distance:0,decay:0};break;case"HemisphereLight":t={direction:new W,skyColor:new Ve,groundColor:new Ve};break;case"RectAreaLight":t={color:new Ve,position:new W,halfWidth:new W,halfHeight:new W};break}return i[e.id]=t,t}}}function KA(){let i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new dt};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new dt};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new dt,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[e.id]=t,t}}}function JA(i,e){return(e.castShadow?2:0)-(i.castShadow?2:0)+(e.map?1:0)-(i.map?1:0)}function ZA(i){let e=new XA,t=KA(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let c=0;c<9;c++)n.probe.push(new W);let r=new W,s=new ot,a=new ot;function o(c){let h=0,d=0,f=0;for(let I=0;I<9;I++)n.probe[I].set(0,0,0);let p=0,x=0,y=0,b=0,g=0,S=0,A=0,T=0,N=0,P=0,U=0;c.sort(JA);for(let I=0,B=c.length;I<B;I++){let k=c[I],V=k.color,J=k.intensity,L=k.distance,E=null;if(k.shadow&&k.shadow.map&&(k.shadow.map.texture.format===Xr?E=k.shadow.map.texture:E=k.shadow.map.depthTexture||k.shadow.map.texture),k.isAmbientLight)h+=V.r*J,d+=V.g*J,f+=V.b*J;else if(k.isLightProbe){for(let D=0;D<9;D++)n.probe[D].addScaledVector(k.sh.coefficients[D],J);U++}else if(k.isDirectionalLight){let D=e.get(k);if(D.color.copy(k.color).multiplyScalar(k.intensity),k.castShadow){let O=k.shadow,H=t.get(k);H.shadowIntensity=O.intensity,H.shadowBias=O.bias,H.shadowNormalBias=O.normalBias,H.shadowRadius=O.radius,H.shadowMapSize=O.mapSize,n.directionalShadow[p]=H,n.directionalShadowMap[p]=E,n.directionalShadowMatrix[p]=k.shadow.matrix,S++}n.directional[p]=D,p++}else if(k.isSpotLight){let D=e.get(k);D.position.setFromMatrixPosition(k.matrixWorld),D.color.copy(V).multiplyScalar(J),D.distance=L,D.coneCos=Math.cos(k.angle),D.penumbraCos=Math.cos(k.angle*(1-k.penumbra)),D.decay=k.decay,n.spot[y]=D;let O=k.shadow;if(k.map&&(n.spotLightMap[N]=k.map,N++,O.updateMatrices(k),k.castShadow&&P++),n.spotLightMatrix[y]=O.matrix,k.castShadow){let H=t.get(k);H.shadowIntensity=O.intensity,H.shadowBias=O.bias,H.shadowNormalBias=O.normalBias,H.shadowRadius=O.radius,H.shadowMapSize=O.mapSize,n.spotShadow[y]=H,n.spotShadowMap[y]=E,T++}y++}else if(k.isRectAreaLight){let D=e.get(k);D.color.copy(V).multiplyScalar(J),D.halfWidth.set(k.width*.5,0,0),D.halfHeight.set(0,k.height*.5,0),n.rectArea[b]=D,b++}else if(k.isPointLight){let D=e.get(k);if(D.color.copy(k.color).multiplyScalar(k.intensity),D.distance=k.distance,D.decay=k.decay,k.castShadow){let O=k.shadow,H=t.get(k);H.shadowIntensity=O.intensity,H.shadowBias=O.bias,H.shadowNormalBias=O.normalBias,H.shadowRadius=O.radius,H.shadowMapSize=O.mapSize,H.shadowCameraNear=O.camera.near,H.shadowCameraFar=O.camera.far,n.pointShadow[x]=H,n.pointShadowMap[x]=E,n.pointShadowMatrix[x]=k.shadow.matrix,A++}n.point[x]=D,x++}else if(k.isHemisphereLight){let D=e.get(k);D.skyColor.copy(k.color).multiplyScalar(J),D.groundColor.copy(k.groundColor).multiplyScalar(J),n.hemi[g]=D,g++}}b>0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=Ue.LTC_FLOAT_1,n.rectAreaLTC2=Ue.LTC_FLOAT_2):(n.rectAreaLTC1=Ue.LTC_HALF_1,n.rectAreaLTC2=Ue.LTC_HALF_2)),n.ambient[0]=h,n.ambient[1]=d,n.ambient[2]=f;let v=n.hash;(v.directionalLength!==p||v.pointLength!==x||v.spotLength!==y||v.rectAreaLength!==b||v.hemiLength!==g||v.numDirectionalShadows!==S||v.numPointShadows!==A||v.numSpotShadows!==T||v.numSpotMaps!==N||v.numLightProbes!==U)&&(n.directional.length=p,n.spot.length=y,n.rectArea.length=b,n.point.length=x,n.hemi.length=g,n.directionalShadow.length=S,n.directionalShadowMap.length=S,n.pointShadow.length=A,n.pointShadowMap.length=A,n.spotShadow.length=T,n.spotShadowMap.length=T,n.directionalShadowMatrix.length=S,n.pointShadowMatrix.length=A,n.spotLightMatrix.length=T+N-P,n.spotLightMap.length=N,n.numSpotLightShadowsWithMaps=P,n.numLightProbes=U,v.directionalLength=p,v.pointLength=x,v.spotLength=y,v.rectAreaLength=b,v.hemiLength=g,v.numDirectionalShadows=S,v.numPointShadows=A,v.numSpotShadows=T,v.numSpotMaps=N,v.numLightProbes=U,n.version=YA++)}function l(c,h){let d=0,f=0,p=0,x=0,y=0,b=h.matrixWorldInverse;for(let g=0,S=c.length;g<S;g++){let A=c[g];if(A.isDirectionalLight){let T=n.directional[d];T.direction.setFromMatrixPosition(A.matrixWorld),r.setFromMatrixPosition(A.target.matrixWorld),T.direction.sub(r),T.direction.transformDirection(b),d++}else if(A.isSpotLight){let T=n.spot[p];T.position.setFromMatrixPosition(A.matrixWorld),T.position.applyMatrix4(b),T.direction.setFromMatrixPosition(A.matrixWorld),r.setFromMatrixPosition(A.target.matrixWorld),T.direction.sub(r),T.direction.transformDirection(b),p++}else if(A.isRectAreaLight){let T=n.rectArea[x];T.position.setFromMatrixPosition(A.matrixWorld),T.position.applyMatrix4(b),a.identity(),s.copy(A.matrixWorld),s.premultiply(b),a.extractRotation(s),T.halfWidth.set(A.width*.5,0,0),T.halfHeight.set(0,A.height*.5,0),T.halfWidth.applyMatrix4(a),T.halfHeight.applyMatrix4(a),x++}else if(A.isPointLight){let T=n.point[f];T.position.setFromMatrixPosition(A.matrixWorld),T.position.applyMatrix4(b),f++}else if(A.isHemisphereLight){let T=n.hemi[y];T.direction.setFromMatrixPosition(A.matrixWorld),T.direction.transformDirection(b),y++}}}return{setup:o,setupView:l,state:n}}function Q0(i){let e=new ZA(i),t=[],n=[],r=[];function s(f){d.camera=f,t.length=0,n.length=0,r.length=0}function a(f){t.push(f)}function o(f){n.push(f)}function l(f){r.push(f)}function c(){e.setup(t)}function h(f){e.setupView(t,f)}let d={lightsArray:t,shadowsArray:n,lightProbeGridArray:r,camera:null,lights:e,transmissionRenderTarget:{},textureUnits:0};return{init:s,state:d,setupLights:c,setupLightsView:h,pushLight:a,pushShadow:o,pushLightProbeGrid:l}}function QA(i){let e=new WeakMap;function t(r,s=0){let a=e.get(r),o;return a===void 0?(o=new Q0(i),e.set(r,[o])):s>=a.length?(o=new Q0(i),a.push(o)):o=a[s],o}function n(){e=new WeakMap}return{get:t,dispose:n}}function rT(i,e,t){let n=new da,r=new dt,s=new dt,a=new kt,o=new pl,l=new ml,c={},h=t.maxTextureSize,d={[Pi]:An,[An]:Pi,[Dn]:Dn},f=new ai({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new dt},radius:{value:4}},vertexShader:eT,fragmentShader:tT}),p=f.clone();p.defines.HORIZONTAL_PASS=1;let x=new mn;x.setAttribute("position",new Kt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let y=new xt(x,f),b=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Eo;let g=this.type;this.render=function(P,U,v){if(b.enabled===!1||b.autoUpdate===!1&&b.needsUpdate===!1||P.length===0)return;this.type===jg&&(Ke("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=Eo);let I=i.getRenderTarget(),B=i.getActiveCubeFace(),k=i.getActiveMipmapLevel(),V=i.state;V.setBlending(Ji),V.buffers.depth.getReversed()===!0?V.buffers.color.setClear(0,0,0,0):V.buffers.color.setClear(1,1,1,1),V.buffers.depth.setTest(!0),V.setScissorTest(!1);let J=g!==this.type;J&&U.traverse(function(L){L.material&&(Array.isArray(L.material)?L.material.forEach(E=>E.needsUpdate=!0):L.material.needsUpdate=!0)});for(let L=0,E=P.length;L<E;L++){let D=P[L],O=D.shadow;if(O===void 0){Ke("WebGLShadowMap:",D,"has no shadow.");continue}if(O.autoUpdate===!1&&O.needsUpdate===!1)continue;r.copy(O.mapSize);let H=O.getFrameExtents();r.multiply(H),s.copy(O.mapSize),(r.x>h||r.y>h)&&(r.x>h&&(s.x=Math.floor(h/H.x),r.x=s.x*H.x,O.mapSize.x=s.x),r.y>h&&(s.y=Math.floor(h/H.y),r.y=s.y*H.y,O.mapSize.y=s.y));let Y=i.state.buffers.depth.getReversed();if(O.camera._reversedDepth=Y,O.map===null||J===!0){if(O.map!==null&&(O.map.depthTexture!==null&&(O.map.depthTexture.dispose(),O.map.depthTexture=null),O.map.dispose()),this.type===qr){if(D.isPointLight){Ke("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}O.map=new Hn(r.x,r.y,{format:Xr,type:Gn,minFilter:zt,magFilter:zt,generateMipmaps:!1}),O.map.texture.name=D.name+".shadowMap",O.map.depthTexture=new pr(r.x,r.y,Tn),O.map.depthTexture.name=D.name+".shadowMapDepth",O.map.depthTexture.format=Wi,O.map.depthTexture.compareFunction=null,O.map.depthTexture.minFilter=on,O.map.depthTexture.magFilter=on}else D.isPointLight?(O.map=new Ma(r.x),O.map.depthTexture=new dl(r.x,Oi)):(O.map=new Hn(r.x,r.y),O.map.depthTexture=new pr(r.x,r.y,Oi)),O.map.depthTexture.name=D.name+".shadowMap",O.map.depthTexture.format=Wi,this.type===Eo?(O.map.depthTexture.compareFunction=Y?bh:gh,O.map.depthTexture.minFilter=zt,O.map.depthTexture.magFilter=zt):(O.map.depthTexture.compareFunction=null,O.map.depthTexture.minFilter=on,O.map.depthTexture.magFilter=on);O.camera.updateProjectionMatrix()}let le=O.map.isWebGLCubeRenderTarget?6:1;for(let fe=0;fe<le;fe++){if(O.map.isWebGLCubeRenderTarget)i.setRenderTarget(O.map,fe),i.clear();else{fe===0&&(i.setRenderTarget(O.map),i.clear());let be=O.getViewport(fe);a.set(s.x*be.x,s.y*be.y,s.x*be.z,s.y*be.w),V.viewport(a)}if(D.isPointLight){let be=O.camera,Te=O.matrix,Je=D.distance||be.far;Je!==be.far&&(be.far=Je,be.updateProjectionMatrix()),Ho.setFromMatrixPosition(D.matrixWorld),be.position.copy(Ho),sf.copy(be.position),sf.add(nT[fe]),be.up.copy(iT[fe]),be.lookAt(sf),be.updateMatrixWorld(),Te.makeTranslation(-Ho.x,-Ho.y,-Ho.z),eb.multiplyMatrices(be.projectionMatrix,be.matrixWorldInverse),O._frustum.setFromProjectionMatrix(eb,be.coordinateSystem,be.reversedDepth)}else O.updateMatrices(D);n=O.getFrustum(),T(U,v,O.camera,D,this.type)}O.isPointLightShadow!==!0&&this.type===qr&&S(O,v),O.needsUpdate=!1}g=this.type,b.needsUpdate=!1,i.setRenderTarget(I,B,k)};function S(P,U){let v=e.update(y);f.defines.VSM_SAMPLES!==P.blurSamples&&(f.defines.VSM_SAMPLES=P.blurSamples,p.defines.VSM_SAMPLES=P.blurSamples,f.needsUpdate=!0,p.needsUpdate=!0),P.mapPass===null&&(P.mapPass=new Hn(r.x,r.y,{format:Xr,type:Gn})),f.uniforms.shadow_pass.value=P.map.depthTexture,f.uniforms.resolution.value=P.mapSize,f.uniforms.radius.value=P.radius,i.setRenderTarget(P.mapPass),i.clear(),i.renderBufferDirect(U,null,v,f,y,null),p.uniforms.shadow_pass.value=P.mapPass.texture,p.uniforms.resolution.value=P.mapSize,p.uniforms.radius.value=P.radius,i.setRenderTarget(P.map),i.clear(),i.renderBufferDirect(U,null,v,p,y,null)}function A(P,U,v,I){let B=null,k=v.isPointLight===!0?P.customDistanceMaterial:P.customDepthMaterial;if(k!==void 0)B=k;else if(B=v.isPointLight===!0?l:o,i.localClippingEnabled&&U.clipShadows===!0&&Array.isArray(U.clippingPlanes)&&U.clippingPlanes.length!==0||U.displacementMap&&U.displacementScale!==0||U.alphaMap&&U.alphaTest>0||U.map&&U.alphaTest>0||U.alphaToCoverage===!0){let V=B.uuid,J=U.uuid,L=c[V];L===void 0&&(L={},c[V]=L);let E=L[J];E===void 0&&(E=B.clone(),L[J]=E,U.addEventListener("dispose",N)),B=E}if(B.visible=U.visible,B.wireframe=U.wireframe,I===qr?B.side=U.shadowSide!==null?U.shadowSide:U.side:B.side=U.shadowSide!==null?U.shadowSide:d[U.side],B.alphaMap=U.alphaMap,B.alphaTest=U.alphaToCoverage===!0?.5:U.alphaTest,B.map=U.map,B.clipShadows=U.clipShadows,B.clippingPlanes=U.clippingPlanes,B.clipIntersection=U.clipIntersection,B.displacementMap=U.displacementMap,B.displacementScale=U.displacementScale,B.displacementBias=U.displacementBias,B.wireframeLinewidth=U.wireframeLinewidth,B.linewidth=U.linewidth,v.isPointLight===!0&&B.isMeshDistanceMaterial===!0){let V=i.properties.get(B);V.light=v}return B}function T(P,U,v,I,B){if(P.visible===!1)return;if(P.layers.test(U.layers)&&(P.isMesh||P.isLine||P.isPoints)&&(P.castShadow||P.receiveShadow&&B===qr)&&(!P.frustumCulled||n.intersectsObject(P))){P.modelViewMatrix.multiplyMatrices(v.matrixWorldInverse,P.matrixWorld);let J=e.update(P),L=P.material;if(Array.isArray(L)){let E=J.groups;for(let D=0,O=E.length;D<O;D++){let H=E[D],Y=L[H.materialIndex];if(Y&&Y.visible){let le=A(P,Y,I,B);P.onBeforeShadow(i,P,U,v,J,le,H),i.renderBufferDirect(v,null,J,le,P,H),P.onAfterShadow(i,P,U,v,J,le,H)}}}else if(L.visible){let E=A(P,L,I,B);P.onBeforeShadow(i,P,U,v,J,E,null),i.renderBufferDirect(v,null,J,E,P,null),P.onAfterShadow(i,P,U,v,J,E,null)}}let V=P.children;for(let J=0,L=V.length;J<L;J++)T(V[J],U,v,I,B)}function N(P){P.target.removeEventListener("dispose",N);for(let v in c){let I=c[v],B=P.target.uuid;B in I&&(I[B].dispose(),delete I[B])}}}function sT(i,e){function t(){let G=!1,we=new kt,de=null,He=new kt(0,0,0,0);return{setMask:function(Ae){de!==Ae&&!G&&(i.colorMask(Ae,Ae,Ae,Ae),de=Ae)},setLocked:function(Ae){G=Ae},setClear:function(Ae,xe,Xe,rt,jt){jt===!0&&(Ae*=rt,xe*=rt,Xe*=rt),we.set(Ae,xe,Xe,rt),He.equals(we)===!1&&(i.clearColor(Ae,xe,Xe,rt),He.copy(we))},reset:function(){G=!1,de=null,He.set(-1,0,0,0)}}}function n(){let G=!1,we=!1,de=null,He=null,Ae=null;return{setReversed:function(xe){if(we!==xe){let Xe=e.get("EXT_clip_control");xe?Xe.clipControlEXT(Xe.LOWER_LEFT_EXT,Xe.ZERO_TO_ONE_EXT):Xe.clipControlEXT(Xe.LOWER_LEFT_EXT,Xe.NEGATIVE_ONE_TO_ONE_EXT),we=xe;let rt=Ae;Ae=null,this.setClear(rt)}},getReversed:function(){return we},setTest:function(xe){xe?_e(i.DEPTH_TEST):Ze(i.DEPTH_TEST)},setMask:function(xe){de!==xe&&!G&&(i.depthMask(xe),de=xe)},setFunc:function(xe){if(we&&(xe=R0[xe]),He!==xe){switch(xe){case Zc:i.depthFunc(i.NEVER);break;case Qc:i.depthFunc(i.ALWAYS);break;case el:i.depthFunc(i.LESS);break;case ps:i.depthFunc(i.LEQUAL);break;case tl:i.depthFunc(i.EQUAL);break;case nl:i.depthFunc(i.GEQUAL);break;case il:i.depthFunc(i.GREATER);break;case rl:i.depthFunc(i.NOTEQUAL);break;default:i.depthFunc(i.LEQUAL)}He=xe}},setLocked:function(xe){G=xe},setClear:function(xe){Ae!==xe&&(Ae=xe,we&&(xe=1-xe),i.clearDepth(xe))},reset:function(){G=!1,de=null,He=null,Ae=null,we=!1}}}function r(){let G=!1,we=null,de=null,He=null,Ae=null,xe=null,Xe=null,rt=null,jt=null;return{setTest:function(Rt){G||(Rt?_e(i.STENCIL_TEST):Ze(i.STENCIL_TEST))},setMask:function(Rt){we!==Rt&&!G&&(i.stencilMask(Rt),we=Rt)},setFunc:function(Rt,$n,ui){(de!==Rt||He!==$n||Ae!==ui)&&(i.stencilFunc(Rt,$n,ui),de=Rt,He=$n,Ae=ui)},setOp:function(Rt,$n,ui){(xe!==Rt||Xe!==$n||rt!==ui)&&(i.stencilOp(Rt,$n,ui),xe=Rt,Xe=$n,rt=ui)},setLocked:function(Rt){G=Rt},setClear:function(Rt){jt!==Rt&&(i.clearStencil(Rt),jt=Rt)},reset:function(){G=!1,we=null,de=null,He=null,Ae=null,xe=null,Xe=null,rt=null,jt=null}}}let s=new t,a=new n,o=new r,l=new WeakMap,c=new WeakMap,h={},d={},f={},p=new WeakMap,x=[],y=null,b=!1,g=null,S=null,A=null,T=null,N=null,P=null,U=null,v=new Ve(0,0,0),I=0,B=!1,k=null,V=null,J=null,L=null,E=null,D=i.getParameter(i.MAX_COMBINED_TEXTURE_IMAGE_UNITS),O=!1,H=0,Y=i.getParameter(i.VERSION);Y.indexOf("WebGL")!==-1?(H=parseFloat(/^WebGL (\d)/.exec(Y)[1]),O=H>=1):Y.indexOf("OpenGL ES")!==-1&&(H=parseFloat(/^OpenGL ES (\d)/.exec(Y)[1]),O=H>=2);let le=null,fe={},be=i.getParameter(i.SCISSOR_BOX),Te=i.getParameter(i.VIEWPORT),Je=new kt().fromArray(be),ke=new kt().fromArray(Te);function oe(G,we,de,He){let Ae=new Uint8Array(4),xe=i.createTexture();i.bindTexture(G,xe),i.texParameteri(G,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(G,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let Xe=0;Xe<de;Xe++)G===i.TEXTURE_3D||G===i.TEXTURE_2D_ARRAY?i.texImage3D(we,0,i.RGBA,1,1,He,0,i.RGBA,i.UNSIGNED_BYTE,Ae):i.texImage2D(we+Xe,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,Ae);return xe}let Ee={};Ee[i.TEXTURE_2D]=oe(i.TEXTURE_2D,i.TEXTURE_2D,1),Ee[i.TEXTURE_CUBE_MAP]=oe(i.TEXTURE_CUBE_MAP,i.TEXTURE_CUBE_MAP_POSITIVE_X,6),Ee[i.TEXTURE_2D_ARRAY]=oe(i.TEXTURE_2D_ARRAY,i.TEXTURE_2D_ARRAY,1,1),Ee[i.TEXTURE_3D]=oe(i.TEXTURE_3D,i.TEXTURE_3D,1,1),s.setClear(0,0,0,1),a.setClear(1),o.setClear(0),_e(i.DEPTH_TEST),a.setFunc(ps),Bt(!1),gt(vd),_e(i.CULL_FACE),wt(Ji);function _e(G){h[G]!==!0&&(i.enable(G),h[G]=!0)}function Ze(G){h[G]!==!1&&(i.disable(G),h[G]=!1)}function tt(G,we){return f[G]!==we?(i.bindFramebuffer(G,we),f[G]=we,G===i.DRAW_FRAMEBUFFER&&(f[i.FRAMEBUFFER]=we),G===i.FRAMEBUFFER&&(f[i.DRAW_FRAMEBUFFER]=we),!0):!1}function Qe(G,we){let de=x,He=!1;if(G){de=p.get(we),de===void 0&&(de=[],p.set(we,de));let Ae=G.textures;if(de.length!==Ae.length||de[0]!==i.COLOR_ATTACHMENT0){for(let xe=0,Xe=Ae.length;xe<Xe;xe++)de[xe]=i.COLOR_ATTACHMENT0+xe;de.length=Ae.length,He=!0}}else de[0]!==i.BACK&&(de[0]=i.BACK,He=!0);He&&i.drawBuffers(de)}function Et(G){return y!==G?(i.useProgram(G),y=G,!0):!1}let it={[Dr]:i.FUNC_ADD,[Kg]:i.FUNC_SUBTRACT,[Yg]:i.FUNC_REVERSE_SUBTRACT};it[Jg]=i.MIN,it[Zg]=i.MAX;let mt={[Qg]:i.ZERO,[e0]:i.ONE,[t0]:i.SRC_COLOR,[Yc]:i.SRC_ALPHA,[o0]:i.SRC_ALPHA_SATURATE,[s0]:i.DST_COLOR,[i0]:i.DST_ALPHA,[n0]:i.ONE_MINUS_SRC_COLOR,[Jc]:i.ONE_MINUS_SRC_ALPHA,[a0]:i.ONE_MINUS_DST_COLOR,[r0]:i.ONE_MINUS_DST_ALPHA,[c0]:i.CONSTANT_COLOR,[l0]:i.ONE_MINUS_CONSTANT_COLOR,[h0]:i.CONSTANT_ALPHA,[u0]:i.ONE_MINUS_CONSTANT_ALPHA};function wt(G,we,de,He,Ae,xe,Xe,rt,jt,Rt){if(G===Ji){b===!0&&(Ze(i.BLEND),b=!1);return}if(b===!1&&(_e(i.BLEND),b=!0),G!==Xg){if(G!==g||Rt!==B){if((S!==Dr||N!==Dr)&&(i.blendEquation(i.FUNC_ADD),S=Dr,N=Dr),Rt)switch(G){case fs:i.blendFuncSeparate(i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case Sd:i.blendFunc(i.ONE,i.ONE);break;case wd:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case Md:i.blendFuncSeparate(i.DST_COLOR,i.ONE_MINUS_SRC_ALPHA,i.ZERO,i.ONE);break;default:et("WebGLState: Invalid blending: ",G);break}else switch(G){case fs:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case Sd:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE,i.ONE,i.ONE);break;case wd:et("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case Md:et("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:et("WebGLState: Invalid blending: ",G);break}A=null,T=null,P=null,U=null,v.set(0,0,0),I=0,g=G,B=Rt}return}Ae=Ae||we,xe=xe||de,Xe=Xe||He,(we!==S||Ae!==N)&&(i.blendEquationSeparate(it[we],it[Ae]),S=we,N=Ae),(de!==A||He!==T||xe!==P||Xe!==U)&&(i.blendFuncSeparate(mt[de],mt[He],mt[xe],mt[Xe]),A=de,T=He,P=xe,U=Xe),(rt.equals(v)===!1||jt!==I)&&(i.blendColor(rt.r,rt.g,rt.b,jt),v.copy(rt),I=jt),g=G,B=!1}function lt(G,we){G.side===Dn?Ze(i.CULL_FACE):_e(i.CULL_FACE);let de=G.side===An;we&&(de=!de),Bt(de),G.blending===fs&&G.transparent===!1?wt(Ji):wt(G.blending,G.blendEquation,G.blendSrc,G.blendDst,G.blendEquationAlpha,G.blendSrcAlpha,G.blendDstAlpha,G.blendColor,G.blendAlpha,G.premultipliedAlpha),a.setFunc(G.depthFunc),a.setTest(G.depthTest),a.setMask(G.depthWrite),s.setMask(G.colorWrite);let He=G.stencilWrite;o.setTest(He),He&&(o.setMask(G.stencilWriteMask),o.setFunc(G.stencilFunc,G.stencilRef,G.stencilFuncMask),o.setOp(G.stencilFail,G.stencilZFail,G.stencilZPass)),q(G.polygonOffset,G.polygonOffsetFactor,G.polygonOffsetUnits),G.alphaToCoverage===!0?_e(i.SAMPLE_ALPHA_TO_COVERAGE):Ze(i.SAMPLE_ALPHA_TO_COVERAGE)}function Bt(G){k!==G&&(G?i.frontFace(i.CW):i.frontFace(i.CCW),k=G)}function gt(G){G!==qg?(_e(i.CULL_FACE),G!==V&&(G===vd?i.cullFace(i.BACK):G===$g?i.cullFace(i.FRONT):i.cullFace(i.FRONT_AND_BACK))):Ze(i.CULL_FACE),V=G}function Yt(G){G!==J&&(O&&i.lineWidth(G),J=G)}function q(G,we,de){G?(_e(i.POLYGON_OFFSET_FILL),(L!==we||E!==de)&&(L=we,E=de,a.getReversed()&&(we=-we),i.polygonOffset(we,de))):Ze(i.POLYGON_OFFSET_FILL)}function $t(G){G?_e(i.SCISSOR_TEST):Ze(i.SCISSOR_TEST)}function ht(G){G===void 0&&(G=i.TEXTURE0+D-1),le!==G&&(i.activeTexture(G),le=G)}function Tt(G,we,de){de===void 0&&(le===null?de=i.TEXTURE0+D-1:de=le);let He=fe[de];He===void 0&&(He={type:void 0,texture:void 0},fe[de]=He),(He.type!==G||He.texture!==we)&&(le!==de&&(i.activeTexture(de),le=de),i.bindTexture(G,we||Ee[G]),He.type=G,He.texture=we)}function Pe(){let G=fe[le];G!==void 0&&G.type!==void 0&&(i.bindTexture(G.type,null),G.type=void 0,G.texture=void 0)}function Ot(){try{i.compressedTexImage2D(...arguments)}catch(G){et("WebGLState:",G)}}function F(){try{i.compressedTexImage3D(...arguments)}catch(G){et("WebGLState:",G)}}function M(){try{i.texSubImage2D(...arguments)}catch(G){et("WebGLState:",G)}}function Z(){try{i.texSubImage3D(...arguments)}catch(G){et("WebGLState:",G)}}function pe(){try{i.compressedTexSubImage2D(...arguments)}catch(G){et("WebGLState:",G)}}function ge(){try{i.compressedTexSubImage3D(...arguments)}catch(G){et("WebGLState:",G)}}function Se(){try{i.texStorage2D(...arguments)}catch(G){et("WebGLState:",G)}}function Ce(){try{i.texStorage3D(...arguments)}catch(G){et("WebGLState:",G)}}function ce(){try{i.texImage2D(...arguments)}catch(G){et("WebGLState:",G)}}function me(){try{i.texImage3D(...arguments)}catch(G){et("WebGLState:",G)}}function Be(G){return d[G]!==void 0?d[G]:i.getParameter(G)}function Le(G,we){d[G]!==we&&(i.pixelStorei(G,we),d[G]=we)}function ve(G){Je.equals(G)===!1&&(i.scissor(G.x,G.y,G.z,G.w),Je.copy(G))}function Me(G){ke.equals(G)===!1&&(i.viewport(G.x,G.y,G.z,G.w),ke.copy(G))}function je(G,we){let de=c.get(we);de===void 0&&(de=new WeakMap,c.set(we,de));let He=de.get(G);He===void 0&&(He=i.getUniformBlockIndex(we,G.name),de.set(G,He))}function nt(G,we){let He=c.get(we).get(G);l.get(we)!==He&&(i.uniformBlockBinding(we,He,G.__bindingPointIndex),l.set(we,He))}function pt(){i.disable(i.BLEND),i.disable(i.CULL_FACE),i.disable(i.DEPTH_TEST),i.disable(i.POLYGON_OFFSET_FILL),i.disable(i.SCISSOR_TEST),i.disable(i.STENCIL_TEST),i.disable(i.SAMPLE_ALPHA_TO_COVERAGE),i.blendEquation(i.FUNC_ADD),i.blendFunc(i.ONE,i.ZERO),i.blendFuncSeparate(i.ONE,i.ZERO,i.ONE,i.ZERO),i.blendColor(0,0,0,0),i.colorMask(!0,!0,!0,!0),i.clearColor(0,0,0,0),i.depthMask(!0),i.depthFunc(i.LESS),a.setReversed(!1),i.clearDepth(1),i.stencilMask(4294967295),i.stencilFunc(i.ALWAYS,0,4294967295),i.stencilOp(i.KEEP,i.KEEP,i.KEEP),i.clearStencil(0),i.cullFace(i.BACK),i.frontFace(i.CCW),i.polygonOffset(0,0),i.activeTexture(i.TEXTURE0),i.bindFramebuffer(i.FRAMEBUFFER,null),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),i.bindFramebuffer(i.READ_FRAMEBUFFER,null),i.useProgram(null),i.lineWidth(1),i.scissor(0,0,i.canvas.width,i.canvas.height),i.viewport(0,0,i.canvas.width,i.canvas.height),i.pixelStorei(i.PACK_ALIGNMENT,4),i.pixelStorei(i.UNPACK_ALIGNMENT,4),i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,!1),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,i.BROWSER_DEFAULT_WEBGL),i.pixelStorei(i.PACK_ROW_LENGTH,0),i.pixelStorei(i.PACK_SKIP_PIXELS,0),i.pixelStorei(i.PACK_SKIP_ROWS,0),i.pixelStorei(i.UNPACK_ROW_LENGTH,0),i.pixelStorei(i.UNPACK_IMAGE_HEIGHT,0),i.pixelStorei(i.UNPACK_SKIP_PIXELS,0),i.pixelStorei(i.UNPACK_SKIP_ROWS,0),i.pixelStorei(i.UNPACK_SKIP_IMAGES,0),h={},d={},le=null,fe={},f={},p=new WeakMap,x=[],y=null,b=!1,g=null,S=null,A=null,T=null,N=null,P=null,U=null,v=new Ve(0,0,0),I=0,B=!1,k=null,V=null,J=null,L=null,E=null,Je.set(0,0,i.canvas.width,i.canvas.height),ke.set(0,0,i.canvas.width,i.canvas.height),s.reset(),a.reset(),o.reset()}return{buffers:{color:s,depth:a,stencil:o},enable:_e,disable:Ze,bindFramebuffer:tt,drawBuffers:Qe,useProgram:Et,setBlending:wt,setMaterial:lt,setFlipSided:Bt,setCullFace:gt,setLineWidth:Yt,setPolygonOffset:q,setScissorTest:$t,activeTexture:ht,bindTexture:Tt,unbindTexture:Pe,compressedTexImage2D:Ot,compressedTexImage3D:F,texImage2D:ce,texImage3D:me,pixelStorei:Le,getParameter:Be,updateUBOMapping:je,uniformBlockBinding:nt,texStorage2D:Se,texStorage3D:Ce,texSubImage2D:M,texSubImage3D:Z,compressedTexSubImage2D:pe,compressedTexSubImage3D:ge,scissor:ve,viewport:Me,reset:pt}}function aT(i,e,t,n,r,s,a){let o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new dt,h=new WeakMap,d=new Set,f,p=new WeakMap,x=!1;try{x=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function y(F,M){return x?new OffscreenCanvas(F,M):aa("canvas")}function b(F,M,Z){let pe=1,ge=Ot(F);if((ge.width>Z||ge.height>Z)&&(pe=Z/Math.max(ge.width,ge.height)),pe<1)if(typeof HTMLImageElement<"u"&&F instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&F instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&F instanceof ImageBitmap||typeof VideoFrame<"u"&&F instanceof VideoFrame){let Se=Math.floor(pe*ge.width),Ce=Math.floor(pe*ge.height);f===void 0&&(f=y(Se,Ce));let ce=M?y(Se,Ce):f;return ce.width=Se,ce.height=Ce,ce.getContext("2d").drawImage(F,0,0,Se,Ce),Ke("WebGLRenderer: Texture has been resized from ("+ge.width+"x"+ge.height+") to ("+Se+"x"+Ce+")."),ce}else return"data"in F&&Ke("WebGLRenderer: Image in DataTexture is too big ("+ge.width+"x"+ge.height+")."),F;return F}function g(F){return F.generateMipmaps}function S(F){i.generateMipmap(F)}function A(F){return F.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:F.isWebGL3DRenderTarget?i.TEXTURE_3D:F.isWebGLArrayRenderTarget||F.isCompressedArrayTexture?i.TEXTURE_2D_ARRAY:i.TEXTURE_2D}function T(F,M,Z,pe,ge,Se=!1){if(F!==null){if(i[F]!==void 0)return i[F];Ke("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+F+"'")}let Ce;pe&&(Ce=e.get("EXT_texture_norm16"),Ce||Ke("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let ce=M;if(M===i.RED&&(Z===i.FLOAT&&(ce=i.R32F),Z===i.HALF_FLOAT&&(ce=i.R16F),Z===i.UNSIGNED_BYTE&&(ce=i.R8),Z===i.UNSIGNED_SHORT&&Ce&&(ce=Ce.R16_EXT),Z===i.SHORT&&Ce&&(ce=Ce.R16_SNORM_EXT)),M===i.RED_INTEGER&&(Z===i.UNSIGNED_BYTE&&(ce=i.R8UI),Z===i.UNSIGNED_SHORT&&(ce=i.R16UI),Z===i.UNSIGNED_INT&&(ce=i.R32UI),Z===i.BYTE&&(ce=i.R8I),Z===i.SHORT&&(ce=i.R16I),Z===i.INT&&(ce=i.R32I)),M===i.RG&&(Z===i.FLOAT&&(ce=i.RG32F),Z===i.HALF_FLOAT&&(ce=i.RG16F),Z===i.UNSIGNED_BYTE&&(ce=i.RG8),Z===i.UNSIGNED_SHORT&&Ce&&(ce=Ce.RG16_EXT),Z===i.SHORT&&Ce&&(ce=Ce.RG16_SNORM_EXT)),M===i.RG_INTEGER&&(Z===i.UNSIGNED_BYTE&&(ce=i.RG8UI),Z===i.UNSIGNED_SHORT&&(ce=i.RG16UI),Z===i.UNSIGNED_INT&&(ce=i.RG32UI),Z===i.BYTE&&(ce=i.RG8I),Z===i.SHORT&&(ce=i.RG16I),Z===i.INT&&(ce=i.RG32I)),M===i.RGB_INTEGER&&(Z===i.UNSIGNED_BYTE&&(ce=i.RGB8UI),Z===i.UNSIGNED_SHORT&&(ce=i.RGB16UI),Z===i.UNSIGNED_INT&&(ce=i.RGB32UI),Z===i.BYTE&&(ce=i.RGB8I),Z===i.SHORT&&(ce=i.RGB16I),Z===i.INT&&(ce=i.RGB32I)),M===i.RGBA_INTEGER&&(Z===i.UNSIGNED_BYTE&&(ce=i.RGBA8UI),Z===i.UNSIGNED_SHORT&&(ce=i.RGBA16UI),Z===i.UNSIGNED_INT&&(ce=i.RGBA32UI),Z===i.BYTE&&(ce=i.RGBA8I),Z===i.SHORT&&(ce=i.RGBA16I),Z===i.INT&&(ce=i.RGBA32I)),M===i.RGB&&(Z===i.UNSIGNED_SHORT&&Ce&&(ce=Ce.RGB16_EXT),Z===i.SHORT&&Ce&&(ce=Ce.RGB16_SNORM_EXT),Z===i.UNSIGNED_INT_5_9_9_9_REV&&(ce=i.RGB9_E5),Z===i.UNSIGNED_INT_10F_11F_11F_REV&&(ce=i.R11F_G11F_B10F)),M===i.RGBA){let me=Se?Qa:ut.getTransfer(ge);Z===i.FLOAT&&(ce=i.RGBA32F),Z===i.HALF_FLOAT&&(ce=i.RGBA16F),Z===i.UNSIGNED_BYTE&&(ce=me===Dt?i.SRGB8_ALPHA8:i.RGBA8),Z===i.UNSIGNED_SHORT&&Ce&&(ce=Ce.RGBA16_EXT),Z===i.SHORT&&Ce&&(ce=Ce.RGBA16_SNORM_EXT),Z===i.UNSIGNED_SHORT_4_4_4_4&&(ce=i.RGBA4),Z===i.UNSIGNED_SHORT_5_5_5_1&&(ce=i.RGB5_A1)}return(ce===i.R16F||ce===i.R32F||ce===i.RG16F||ce===i.RG32F||ce===i.RGBA16F||ce===i.RGBA32F)&&e.get("EXT_color_buffer_float"),ce}function N(F,M){let Z;return F?M===null||M===Oi||M===xa?Z=i.DEPTH24_STENCIL8:M===Tn?Z=i.DEPTH32F_STENCIL8:M===ba&&(Z=i.DEPTH24_STENCIL8,Ke("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):M===null||M===Oi||M===xa?Z=i.DEPTH_COMPONENT24:M===Tn?Z=i.DEPTH_COMPONENT32F:M===ba&&(Z=i.DEPTH_COMPONENT16),Z}function P(F,M){return g(F)===!0||F.isFramebufferTexture&&F.minFilter!==on&&F.minFilter!==zt?Math.log2(Math.max(M.width,M.height))+1:F.mipmaps!==void 0&&F.mipmaps.length>0?F.mipmaps.length:F.isCompressedTexture&&Array.isArray(F.image)?M.mipmaps.length:1}function U(F){let M=F.target;M.removeEventListener("dispose",U),I(M),M.isVideoTexture&&h.delete(M),M.isHTMLTexture&&d.delete(M)}function v(F){let M=F.target;M.removeEventListener("dispose",v),k(M)}function I(F){let M=n.get(F);if(M.__webglInit===void 0)return;let Z=F.source,pe=p.get(Z);if(pe){let ge=pe[M.__cacheKey];ge.usedTimes--,ge.usedTimes===0&&B(F),Object.keys(pe).length===0&&p.delete(Z)}n.remove(F)}function B(F){let M=n.get(F);i.deleteTexture(M.__webglTexture);let Z=F.source,pe=p.get(Z);delete pe[M.__cacheKey],a.memory.textures--}function k(F){let M=n.get(F);if(F.depthTexture&&(F.depthTexture.dispose(),n.remove(F.depthTexture)),F.isWebGLCubeRenderTarget)for(let pe=0;pe<6;pe++){if(Array.isArray(M.__webglFramebuffer[pe]))for(let ge=0;ge<M.__webglFramebuffer[pe].length;ge++)i.deleteFramebuffer(M.__webglFramebuffer[pe][ge]);else i.deleteFramebuffer(M.__webglFramebuffer[pe]);M.__webglDepthbuffer&&i.deleteRenderbuffer(M.__webglDepthbuffer[pe])}else{if(Array.isArray(M.__webglFramebuffer))for(let pe=0;pe<M.__webglFramebuffer.length;pe++)i.deleteFramebuffer(M.__webglFramebuffer[pe]);else i.deleteFramebuffer(M.__webglFramebuffer);if(M.__webglDepthbuffer&&i.deleteRenderbuffer(M.__webglDepthbuffer),M.__webglMultisampledFramebuffer&&i.deleteFramebuffer(M.__webglMultisampledFramebuffer),M.__webglColorRenderbuffer)for(let pe=0;pe<M.__webglColorRenderbuffer.length;pe++)M.__webglColorRenderbuffer[pe]&&i.deleteRenderbuffer(M.__webglColorRenderbuffer[pe]);M.__webglDepthRenderbuffer&&i.deleteRenderbuffer(M.__webglDepthRenderbuffer)}let Z=F.textures;for(let pe=0,ge=Z.length;pe<ge;pe++){let Se=n.get(Z[pe]);Se.__webglTexture&&(i.deleteTexture(Se.__webglTexture),a.memory.textures--),n.remove(Z[pe])}n.remove(F)}let V=0;function J(){V=0}function L(){return V}function E(F){V=F}function D(){let F=V;return F>=r.maxTextures&&Ke("WebGLTextures: Trying to use "+F+" texture units while this GPU supports only "+r.maxTextures),V+=1,F}function O(F){let M=[];return M.push(F.wrapS),M.push(F.wrapT),M.push(F.wrapR||0),M.push(F.magFilter),M.push(F.minFilter),M.push(F.anisotropy),M.push(F.internalFormat),M.push(F.format),M.push(F.type),M.push(F.generateMipmaps),M.push(F.premultiplyAlpha),M.push(F.flipY),M.push(F.unpackAlignment),M.push(F.colorSpace),M.join()}function H(F,M){let Z=n.get(F);if(F.isVideoTexture&&Tt(F),F.isRenderTargetTexture===!1&&F.isExternalTexture!==!0&&F.version>0&&Z.__version!==F.version){let pe=F.image;if(pe===null)Ke("WebGLRenderer: Texture marked for update but no image data found.");else if(pe.complete===!1)Ke("WebGLRenderer: Texture marked for update but image is incomplete");else{Ze(Z,F,M);return}}else F.isExternalTexture&&(Z.__webglTexture=F.sourceTexture?F.sourceTexture:null);t.bindTexture(i.TEXTURE_2D,Z.__webglTexture,i.TEXTURE0+M)}function Y(F,M){let Z=n.get(F);if(F.isRenderTargetTexture===!1&&F.version>0&&Z.__version!==F.version){Ze(Z,F,M);return}else F.isExternalTexture&&(Z.__webglTexture=F.sourceTexture?F.sourceTexture:null);t.bindTexture(i.TEXTURE_2D_ARRAY,Z.__webglTexture,i.TEXTURE0+M)}function le(F,M){let Z=n.get(F);if(F.isRenderTargetTexture===!1&&F.version>0&&Z.__version!==F.version){Ze(Z,F,M);return}t.bindTexture(i.TEXTURE_3D,Z.__webglTexture,i.TEXTURE0+M)}function fe(F,M){let Z=n.get(F);if(F.isCubeDepthTexture!==!0&&F.version>0&&Z.__version!==F.version){tt(Z,F,M);return}t.bindTexture(i.TEXTURE_CUBE_MAP,Z.__webglTexture,i.TEXTURE0+M)}let be={[Nr]:i.REPEAT,[Kn]:i.CLAMP_TO_EDGE,[ra]:i.MIRRORED_REPEAT},Te={[on]:i.NEAREST,[Pl]:i.NEAREST_MIPMAP_NEAREST,[Ts]:i.NEAREST_MIPMAP_LINEAR,[zt]:i.LINEAR,[ga]:i.LINEAR_MIPMAP_NEAREST,[xi]:i.LINEAR_MIPMAP_LINEAR},Je={[x0]:i.NEVER,[w0]:i.ALWAYS,[_0]:i.LESS,[gh]:i.LEQUAL,[y0]:i.EQUAL,[bh]:i.GEQUAL,[v0]:i.GREATER,[S0]:i.NOTEQUAL};function ke(F,M){if(M.type===Tn&&e.has("OES_texture_float_linear")===!1&&(M.magFilter===zt||M.magFilter===ga||M.magFilter===Ts||M.magFilter===xi||M.minFilter===zt||M.minFilter===ga||M.minFilter===Ts||M.minFilter===xi)&&Ke("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(F,i.TEXTURE_WRAP_S,be[M.wrapS]),i.texParameteri(F,i.TEXTURE_WRAP_T,be[M.wrapT]),(F===i.TEXTURE_3D||F===i.TEXTURE_2D_ARRAY)&&i.texParameteri(F,i.TEXTURE_WRAP_R,be[M.wrapR]),i.texParameteri(F,i.TEXTURE_MAG_FILTER,Te[M.magFilter]),i.texParameteri(F,i.TEXTURE_MIN_FILTER,Te[M.minFilter]),M.compareFunction&&(i.texParameteri(F,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(F,i.TEXTURE_COMPARE_FUNC,Je[M.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(M.magFilter===on||M.minFilter!==Ts&&M.minFilter!==xi||M.type===Tn&&e.has("OES_texture_float_linear")===!1)return;if(M.anisotropy>1||n.get(M).__currentAnisotropy){let Z=e.get("EXT_texture_filter_anisotropic");i.texParameterf(F,Z.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(M.anisotropy,r.getMaxAnisotropy())),n.get(M).__currentAnisotropy=M.anisotropy}}}function oe(F,M){let Z=!1;F.__webglInit===void 0&&(F.__webglInit=!0,M.addEventListener("dispose",U));let pe=M.source,ge=p.get(pe);ge===void 0&&(ge={},p.set(pe,ge));let Se=O(M);if(Se!==F.__cacheKey){ge[Se]===void 0&&(ge[Se]={texture:i.createTexture(),usedTimes:0},a.memory.textures++,Z=!0),ge[Se].usedTimes++;let Ce=ge[F.__cacheKey];Ce!==void 0&&(ge[F.__cacheKey].usedTimes--,Ce.usedTimes===0&&B(M)),F.__cacheKey=Se,F.__webglTexture=ge[Se].texture}return Z}function Ee(F,M,Z){return Math.floor(Math.floor(F/Z)/M)}function _e(F,M,Z,pe){let Se=F.updateRanges;if(Se.length===0)t.texSubImage2D(i.TEXTURE_2D,0,0,0,M.width,M.height,Z,pe,M.data);else{Se.sort((Le,ve)=>Le.start-ve.start);let Ce=0;for(let Le=1;Le<Se.length;Le++){let ve=Se[Ce],Me=Se[Le],je=ve.start+ve.count,nt=Ee(Me.start,M.width,4),pt=Ee(ve.start,M.width,4);Me.start<=je+1&&nt===pt&&Ee(Me.start+Me.count-1,M.width,4)===nt?ve.count=Math.max(ve.count,Me.start+Me.count-ve.start):(++Ce,Se[Ce]=Me)}Se.length=Ce+1;let ce=t.getParameter(i.UNPACK_ROW_LENGTH),me=t.getParameter(i.UNPACK_SKIP_PIXELS),Be=t.getParameter(i.UNPACK_SKIP_ROWS);t.pixelStorei(i.UNPACK_ROW_LENGTH,M.width);for(let Le=0,ve=Se.length;Le<ve;Le++){let Me=Se[Le],je=Math.floor(Me.start/4),nt=Math.ceil(Me.count/4),pt=je%M.width,G=Math.floor(je/M.width),we=nt,de=1;t.pixelStorei(i.UNPACK_SKIP_PIXELS,pt),t.pixelStorei(i.UNPACK_SKIP_ROWS,G),t.texSubImage2D(i.TEXTURE_2D,0,pt,G,we,de,Z,pe,M.data)}F.clearUpdateRanges(),t.pixelStorei(i.UNPACK_ROW_LENGTH,ce),t.pixelStorei(i.UNPACK_SKIP_PIXELS,me),t.pixelStorei(i.UNPACK_SKIP_ROWS,Be)}}function Ze(F,M,Z){let pe=i.TEXTURE_2D;(M.isDataArrayTexture||M.isCompressedArrayTexture)&&(pe=i.TEXTURE_2D_ARRAY),M.isData3DTexture&&(pe=i.TEXTURE_3D);let ge=oe(F,M),Se=M.source;t.bindTexture(pe,F.__webglTexture,i.TEXTURE0+Z);let Ce=n.get(Se);if(Se.version!==Ce.__version||ge===!0){if(t.activeTexture(i.TEXTURE0+Z),(typeof ImageBitmap<"u"&&M.image instanceof ImageBitmap)===!1){let de=ut.getPrimaries(ut.workingColorSpace),He=M.colorSpace===Fi?null:ut.getPrimaries(M.colorSpace),Ae=M.colorSpace===Fi||de===He?i.NONE:i.BROWSER_DEFAULT_WEBGL;t.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,M.flipY),t.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,M.premultiplyAlpha),t.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ae)}t.pixelStorei(i.UNPACK_ALIGNMENT,M.unpackAlignment);let me=b(M.image,!1,r.maxTextureSize);me=Pe(M,me);let Be=s.convert(M.format,M.colorSpace),Le=s.convert(M.type),ve=T(M.internalFormat,Be,Le,M.normalized,M.colorSpace,M.isVideoTexture);ke(pe,M);let Me,je=M.mipmaps,nt=M.isVideoTexture!==!0,pt=Ce.__version===void 0||ge===!0,G=Se.dataReady,we=P(M,me);if(M.isDepthTexture)ve=N(M.format===jr,M.type),pt&&(nt?t.texStorage2D(i.TEXTURE_2D,1,ve,me.width,me.height):t.texImage2D(i.TEXTURE_2D,0,ve,me.width,me.height,0,Be,Le,null));else if(M.isDataTexture)if(je.length>0){nt&&pt&&t.texStorage2D(i.TEXTURE_2D,we,ve,je[0].width,je[0].height);for(let de=0,He=je.length;de<He;de++)Me=je[de],nt?G&&t.texSubImage2D(i.TEXTURE_2D,de,0,0,Me.width,Me.height,Be,Le,Me.data):t.texImage2D(i.TEXTURE_2D,de,ve,Me.width,Me.height,0,Be,Le,Me.data);M.generateMipmaps=!1}else nt?(pt&&t.texStorage2D(i.TEXTURE_2D,we,ve,me.width,me.height),G&&_e(M,me,Be,Le)):t.texImage2D(i.TEXTURE_2D,0,ve,me.width,me.height,0,Be,Le,me.data);else if(M.isCompressedTexture)if(M.isCompressedArrayTexture){nt&&pt&&t.texStorage3D(i.TEXTURE_2D_ARRAY,we,ve,je[0].width,je[0].height,me.depth);for(let de=0,He=je.length;de<He;de++)if(Me=je[de],M.format!==ci)if(Be!==null)if(nt){if(G)if(M.layerUpdates.size>0){let Ae=$d(Me.width,Me.height,M.format,M.type);for(let xe of M.layerUpdates){let Xe=Me.data.subarray(xe*Ae/Me.data.BYTES_PER_ELEMENT,(xe+1)*Ae/Me.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,de,0,0,xe,Me.width,Me.height,1,Be,Xe)}M.clearLayerUpdates()}else t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,de,0,0,0,Me.width,Me.height,me.depth,Be,Me.data)}else t.compressedTexImage3D(i.TEXTURE_2D_ARRAY,de,ve,Me.width,Me.height,me.depth,0,Me.data,0,0);else Ke("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else nt?G&&t.texSubImage3D(i.TEXTURE_2D_ARRAY,de,0,0,0,Me.width,Me.height,me.depth,Be,Le,Me.data):t.texImage3D(i.TEXTURE_2D_ARRAY,de,ve,Me.width,Me.height,me.depth,0,Be,Le,Me.data)}else{nt&&pt&&t.texStorage2D(i.TEXTURE_2D,we,ve,je[0].width,je[0].height);for(let de=0,He=je.length;de<He;de++)Me=je[de],M.format!==ci?Be!==null?nt?G&&t.compressedTexSubImage2D(i.TEXTURE_2D,de,0,0,Me.width,Me.height,Be,Me.data):t.compressedTexImage2D(i.TEXTURE_2D,de,ve,Me.width,Me.height,0,Me.data):Ke("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):nt?G&&t.texSubImage2D(i.TEXTURE_2D,de,0,0,Me.width,Me.height,Be,Le,Me.data):t.texImage2D(i.TEXTURE_2D,de,ve,Me.width,Me.height,0,Be,Le,Me.data)}else if(M.isDataArrayTexture)if(nt){if(pt&&t.texStorage3D(i.TEXTURE_2D_ARRAY,we,ve,me.width,me.height,me.depth),G)if(M.layerUpdates.size>0){let de=$d(me.width,me.height,M.format,M.type);for(let He of M.layerUpdates){let Ae=me.data.subarray(He*de/me.data.BYTES_PER_ELEMENT,(He+1)*de/me.data.BYTES_PER_ELEMENT);t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,He,me.width,me.height,1,Be,Le,Ae)}M.clearLayerUpdates()}else t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,me.width,me.height,me.depth,Be,Le,me.data)}else t.texImage3D(i.TEXTURE_2D_ARRAY,0,ve,me.width,me.height,me.depth,0,Be,Le,me.data);else if(M.isData3DTexture)nt?(pt&&t.texStorage3D(i.TEXTURE_3D,we,ve,me.width,me.height,me.depth),G&&t.texSubImage3D(i.TEXTURE_3D,0,0,0,0,me.width,me.height,me.depth,Be,Le,me.data)):t.texImage3D(i.TEXTURE_3D,0,ve,me.width,me.height,me.depth,0,Be,Le,me.data);else if(M.isFramebufferTexture){if(pt)if(nt)t.texStorage2D(i.TEXTURE_2D,we,ve,me.width,me.height);else{let de=me.width,He=me.height;for(let Ae=0;Ae<we;Ae++)t.texImage2D(i.TEXTURE_2D,Ae,ve,de,He,0,Be,Le,null),de>>=1,He>>=1}}else if(M.isHTMLTexture){if("texElementImage2D"in i){let de=i.canvas;if(de.hasAttribute("layoutsubtree")||de.setAttribute("layoutsubtree","true"),me.parentNode!==de){de.appendChild(me),d.add(M),de.onpaint=rt=>{let jt=rt.changedElements;for(let Rt of d)jt.includes(Rt.image)&&(Rt.needsUpdate=!0)},de.requestPaint();return}let He=0,Ae=i.RGBA,xe=i.RGBA,Xe=i.UNSIGNED_BYTE;i.texElementImage2D(i.TEXTURE_2D,He,Ae,xe,Xe,me),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE)}}else if(je.length>0){if(nt&&pt){let de=Ot(je[0]);t.texStorage2D(i.TEXTURE_2D,we,ve,de.width,de.height)}for(let de=0,He=je.length;de<He;de++)Me=je[de],nt?G&&t.texSubImage2D(i.TEXTURE_2D,de,0,0,Be,Le,Me):t.texImage2D(i.TEXTURE_2D,de,ve,Be,Le,Me);M.generateMipmaps=!1}else if(nt){if(pt){let de=Ot(me);t.texStorage2D(i.TEXTURE_2D,we,ve,de.width,de.height)}G&&t.texSubImage2D(i.TEXTURE_2D,0,0,0,Be,Le,me)}else t.texImage2D(i.TEXTURE_2D,0,ve,Be,Le,me);g(M)&&S(pe),Ce.__version=Se.version,M.onUpdate&&M.onUpdate(M)}F.__version=M.version}function tt(F,M,Z){if(M.image.length!==6)return;let pe=oe(F,M),ge=M.source;t.bindTexture(i.TEXTURE_CUBE_MAP,F.__webglTexture,i.TEXTURE0+Z);let Se=n.get(ge);if(ge.version!==Se.__version||pe===!0){t.activeTexture(i.TEXTURE0+Z);let Ce=ut.getPrimaries(ut.workingColorSpace),ce=M.colorSpace===Fi?null:ut.getPrimaries(M.colorSpace),me=M.colorSpace===Fi||Ce===ce?i.NONE:i.BROWSER_DEFAULT_WEBGL;t.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,M.flipY),t.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,M.premultiplyAlpha),t.pixelStorei(i.UNPACK_ALIGNMENT,M.unpackAlignment),t.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,me);let Be=M.isCompressedTexture||M.image[0].isCompressedTexture,Le=M.image[0]&&M.image[0].isDataTexture,ve=[];for(let xe=0;xe<6;xe++)!Be&&!Le?ve[xe]=b(M.image[xe],!0,r.maxCubemapSize):ve[xe]=Le?M.image[xe].image:M.image[xe],ve[xe]=Pe(M,ve[xe]);let Me=ve[0],je=s.convert(M.format,M.colorSpace),nt=s.convert(M.type),pt=T(M.internalFormat,je,nt,M.normalized,M.colorSpace),G=M.isVideoTexture!==!0,we=Se.__version===void 0||pe===!0,de=ge.dataReady,He=P(M,Me);ke(i.TEXTURE_CUBE_MAP,M);let Ae;if(Be){G&&we&&t.texStorage2D(i.TEXTURE_CUBE_MAP,He,pt,Me.width,Me.height);for(let xe=0;xe<6;xe++){Ae=ve[xe].mipmaps;for(let Xe=0;Xe<Ae.length;Xe++){let rt=Ae[Xe];M.format!==ci?je!==null?G?de&&t.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+xe,Xe,0,0,rt.width,rt.height,je,rt.data):t.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+xe,Xe,pt,rt.width,rt.height,0,rt.data):Ke("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):G?de&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+xe,Xe,0,0,rt.width,rt.height,je,nt,rt.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+xe,Xe,pt,rt.width,rt.height,0,je,nt,rt.data)}}}else{if(Ae=M.mipmaps,G&&we){Ae.length>0&&He++;let xe=Ot(ve[0]);t.texStorage2D(i.TEXTURE_CUBE_MAP,He,pt,xe.width,xe.height)}for(let xe=0;xe<6;xe++)if(Le){G?de&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+xe,0,0,0,ve[xe].width,ve[xe].height,je,nt,ve[xe].data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+xe,0,pt,ve[xe].width,ve[xe].height,0,je,nt,ve[xe].data);for(let Xe=0;Xe<Ae.length;Xe++){let jt=Ae[Xe].image[xe].image;G?de&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+xe,Xe+1,0,0,jt.width,jt.height,je,nt,jt.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+xe,Xe+1,pt,jt.width,jt.height,0,je,nt,jt.data)}}else{G?de&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+xe,0,0,0,je,nt,ve[xe]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+xe,0,pt,je,nt,ve[xe]);for(let Xe=0;Xe<Ae.length;Xe++){let rt=Ae[Xe];G?de&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+xe,Xe+1,0,0,je,nt,rt.image[xe]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+xe,Xe+1,pt,je,nt,rt.image[xe])}}}g(M)&&S(i.TEXTURE_CUBE_MAP),Se.__version=ge.version,M.onUpdate&&M.onUpdate(M)}F.__version=M.version}function Qe(F,M,Z,pe,ge,Se){let Ce=s.convert(Z.format,Z.colorSpace),ce=s.convert(Z.type),me=T(Z.internalFormat,Ce,ce,Z.normalized,Z.colorSpace),Be=n.get(M),Le=n.get(Z);if(Le.__renderTarget=M,!Be.__hasExternalTextures){let ve=Math.max(1,M.width>>Se),Me=Math.max(1,M.height>>Se);ge===i.TEXTURE_3D||ge===i.TEXTURE_2D_ARRAY?t.texImage3D(ge,Se,me,ve,Me,M.depth,0,Ce,ce,null):t.texImage2D(ge,Se,me,ve,Me,0,Ce,ce,null)}t.bindFramebuffer(i.FRAMEBUFFER,F),ht(M)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,pe,ge,Le.__webglTexture,0,$t(M)):(ge===i.TEXTURE_2D||ge>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&ge<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,pe,ge,Le.__webglTexture,Se),t.bindFramebuffer(i.FRAMEBUFFER,null)}function Et(F,M,Z){if(i.bindRenderbuffer(i.RENDERBUFFER,F),M.depthBuffer){let pe=M.depthTexture,ge=pe&&pe.isDepthTexture?pe.type:null,Se=N(M.stencilBuffer,ge),Ce=M.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;ht(M)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,$t(M),Se,M.width,M.height):Z?i.renderbufferStorageMultisample(i.RENDERBUFFER,$t(M),Se,M.width,M.height):i.renderbufferStorage(i.RENDERBUFFER,Se,M.width,M.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,Ce,i.RENDERBUFFER,F)}else{let pe=M.textures;for(let ge=0;ge<pe.length;ge++){let Se=pe[ge],Ce=s.convert(Se.format,Se.colorSpace),ce=s.convert(Se.type),me=T(Se.internalFormat,Ce,ce,Se.normalized,Se.colorSpace);ht(M)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,$t(M),me,M.width,M.height):Z?i.renderbufferStorageMultisample(i.RENDERBUFFER,$t(M),me,M.width,M.height):i.renderbufferStorage(i.RENDERBUFFER,me,M.width,M.height)}}i.bindRenderbuffer(i.RENDERBUFFER,null)}function it(F,M,Z){let pe=M.isWebGLCubeRenderTarget===!0;if(t.bindFramebuffer(i.FRAMEBUFFER,F),!(M.depthTexture&&M.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");let ge=n.get(M.depthTexture);if(ge.__renderTarget=M,(!ge.__webglTexture||M.depthTexture.image.width!==M.width||M.depthTexture.image.height!==M.height)&&(M.depthTexture.image.width=M.width,M.depthTexture.image.height=M.height,M.depthTexture.needsUpdate=!0),pe){if(ge.__webglInit===void 0&&(ge.__webglInit=!0,M.depthTexture.addEventListener("dispose",U)),ge.__webglTexture===void 0){ge.__webglTexture=i.createTexture(),t.bindTexture(i.TEXTURE_CUBE_MAP,ge.__webglTexture),ke(i.TEXTURE_CUBE_MAP,M.depthTexture);let Be=s.convert(M.depthTexture.format),Le=s.convert(M.depthTexture.type),ve;M.depthTexture.format===Wi?ve=i.DEPTH_COMPONENT24:M.depthTexture.format===jr&&(ve=i.DEPTH24_STENCIL8);for(let Me=0;Me<6;Me++)i.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Me,0,ve,M.width,M.height,0,Be,Le,null)}}else H(M.depthTexture,0);let Se=ge.__webglTexture,Ce=$t(M),ce=pe?i.TEXTURE_CUBE_MAP_POSITIVE_X+Z:i.TEXTURE_2D,me=M.depthTexture.format===jr?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;if(M.depthTexture.format===Wi)ht(M)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,me,ce,Se,0,Ce):i.framebufferTexture2D(i.FRAMEBUFFER,me,ce,Se,0);else if(M.depthTexture.format===jr)ht(M)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,me,ce,Se,0,Ce):i.framebufferTexture2D(i.FRAMEBUFFER,me,ce,Se,0);else throw new Error("Unknown depthTexture format")}function mt(F){let M=n.get(F),Z=F.isWebGLCubeRenderTarget===!0;if(M.__boundDepthTexture!==F.depthTexture){let pe=F.depthTexture;if(M.__depthDisposeCallback&&M.__depthDisposeCallback(),pe){let ge=()=>{delete M.__boundDepthTexture,delete M.__depthDisposeCallback,pe.removeEventListener("dispose",ge)};pe.addEventListener("dispose",ge),M.__depthDisposeCallback=ge}M.__boundDepthTexture=pe}if(F.depthTexture&&!M.__autoAllocateDepthBuffer)if(Z)for(let pe=0;pe<6;pe++)it(M.__webglFramebuffer[pe],F,pe);else{let pe=F.texture.mipmaps;pe&&pe.length>0?it(M.__webglFramebuffer[0],F,0):it(M.__webglFramebuffer,F,0)}else if(Z){M.__webglDepthbuffer=[];for(let pe=0;pe<6;pe++)if(t.bindFramebuffer(i.FRAMEBUFFER,M.__webglFramebuffer[pe]),M.__webglDepthbuffer[pe]===void 0)M.__webglDepthbuffer[pe]=i.createRenderbuffer(),Et(M.__webglDepthbuffer[pe],F,!1);else{let ge=F.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,Se=M.__webglDepthbuffer[pe];i.bindRenderbuffer(i.RENDERBUFFER,Se),i.framebufferRenderbuffer(i.FRAMEBUFFER,ge,i.RENDERBUFFER,Se)}}else{let pe=F.texture.mipmaps;if(pe&&pe.length>0?t.bindFramebuffer(i.FRAMEBUFFER,M.__webglFramebuffer[0]):t.bindFramebuffer(i.FRAMEBUFFER,M.__webglFramebuffer),M.__webglDepthbuffer===void 0)M.__webglDepthbuffer=i.createRenderbuffer(),Et(M.__webglDepthbuffer,F,!1);else{let ge=F.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,Se=M.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,Se),i.framebufferRenderbuffer(i.FRAMEBUFFER,ge,i.RENDERBUFFER,Se)}}t.bindFramebuffer(i.FRAMEBUFFER,null)}function wt(F,M,Z){let pe=n.get(F);M!==void 0&&Qe(pe.__webglFramebuffer,F,F.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),Z!==void 0&&mt(F)}function lt(F){let M=F.texture,Z=n.get(F),pe=n.get(M);F.addEventListener("dispose",v);let ge=F.textures,Se=F.isWebGLCubeRenderTarget===!0,Ce=ge.length>1;if(Ce||(pe.__webglTexture===void 0&&(pe.__webglTexture=i.createTexture()),pe.__version=M.version,a.memory.textures++),Se){Z.__webglFramebuffer=[];for(let ce=0;ce<6;ce++)if(M.mipmaps&&M.mipmaps.length>0){Z.__webglFramebuffer[ce]=[];for(let me=0;me<M.mipmaps.length;me++)Z.__webglFramebuffer[ce][me]=i.createFramebuffer()}else Z.__webglFramebuffer[ce]=i.createFramebuffer()}else{if(M.mipmaps&&M.mipmaps.length>0){Z.__webglFramebuffer=[];for(let ce=0;ce<M.mipmaps.length;ce++)Z.__webglFramebuffer[ce]=i.createFramebuffer()}else Z.__webglFramebuffer=i.createFramebuffer();if(Ce)for(let ce=0,me=ge.length;ce<me;ce++){let Be=n.get(ge[ce]);Be.__webglTexture===void 0&&(Be.__webglTexture=i.createTexture(),a.memory.textures++)}if(F.samples>0&&ht(F)===!1){Z.__webglMultisampledFramebuffer=i.createFramebuffer(),Z.__webglColorRenderbuffer=[],t.bindFramebuffer(i.FRAMEBUFFER,Z.__webglMultisampledFramebuffer);for(let ce=0;ce<ge.length;ce++){let me=ge[ce];Z.__webglColorRenderbuffer[ce]=i.createRenderbuffer(),i.bindRenderbuffer(i.RENDERBUFFER,Z.__webglColorRenderbuffer[ce]);let Be=s.convert(me.format,me.colorSpace),Le=s.convert(me.type),ve=T(me.internalFormat,Be,Le,me.normalized,me.colorSpace,F.isXRRenderTarget===!0),Me=$t(F);i.renderbufferStorageMultisample(i.RENDERBUFFER,Me,ve,F.width,F.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+ce,i.RENDERBUFFER,Z.__webglColorRenderbuffer[ce])}i.bindRenderbuffer(i.RENDERBUFFER,null),F.depthBuffer&&(Z.__webglDepthRenderbuffer=i.createRenderbuffer(),Et(Z.__webglDepthRenderbuffer,F,!0)),t.bindFramebuffer(i.FRAMEBUFFER,null)}}if(Se){t.bindTexture(i.TEXTURE_CUBE_MAP,pe.__webglTexture),ke(i.TEXTURE_CUBE_MAP,M);for(let ce=0;ce<6;ce++)if(M.mipmaps&&M.mipmaps.length>0)for(let me=0;me<M.mipmaps.length;me++)Qe(Z.__webglFramebuffer[ce][me],F,M,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+ce,me);else Qe(Z.__webglFramebuffer[ce],F,M,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+ce,0);g(M)&&S(i.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(Ce){for(let ce=0,me=ge.length;ce<me;ce++){let Be=ge[ce],Le=n.get(Be),ve=i.TEXTURE_2D;(F.isWebGL3DRenderTarget||F.isWebGLArrayRenderTarget)&&(ve=F.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(ve,Le.__webglTexture),ke(ve,Be),Qe(Z.__webglFramebuffer,F,Be,i.COLOR_ATTACHMENT0+ce,ve,0),g(Be)&&S(ve)}t.unbindTexture()}else{let ce=i.TEXTURE_2D;if((F.isWebGL3DRenderTarget||F.isWebGLArrayRenderTarget)&&(ce=F.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(ce,pe.__webglTexture),ke(ce,M),M.mipmaps&&M.mipmaps.length>0)for(let me=0;me<M.mipmaps.length;me++)Qe(Z.__webglFramebuffer[me],F,M,i.COLOR_ATTACHMENT0,ce,me);else Qe(Z.__webglFramebuffer,F,M,i.COLOR_ATTACHMENT0,ce,0);g(M)&&S(ce),t.unbindTexture()}F.depthBuffer&&mt(F)}function Bt(F){let M=F.textures;for(let Z=0,pe=M.length;Z<pe;Z++){let ge=M[Z];if(g(ge)){let Se=A(F),Ce=n.get(ge).__webglTexture;t.bindTexture(Se,Ce),S(Se),t.unbindTexture()}}}let gt=[],Yt=[];function q(F){if(F.samples>0){if(ht(F)===!1){let M=F.textures,Z=F.width,pe=F.height,ge=i.COLOR_BUFFER_BIT,Se=F.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,Ce=n.get(F),ce=M.length>1;if(ce)for(let Be=0;Be<M.length;Be++)t.bindFramebuffer(i.FRAMEBUFFER,Ce.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+Be,i.RENDERBUFFER,null),t.bindFramebuffer(i.FRAMEBUFFER,Ce.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+Be,i.TEXTURE_2D,null,0);t.bindFramebuffer(i.READ_FRAMEBUFFER,Ce.__webglMultisampledFramebuffer);let me=F.texture.mipmaps;me&&me.length>0?t.bindFramebuffer(i.DRAW_FRAMEBUFFER,Ce.__webglFramebuffer[0]):t.bindFramebuffer(i.DRAW_FRAMEBUFFER,Ce.__webglFramebuffer);for(let Be=0;Be<M.length;Be++){if(F.resolveDepthBuffer&&(F.depthBuffer&&(ge|=i.DEPTH_BUFFER_BIT),F.stencilBuffer&&F.resolveStencilBuffer&&(ge|=i.STENCIL_BUFFER_BIT)),ce){i.framebufferRenderbuffer(i.READ_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,Ce.__webglColorRenderbuffer[Be]);let Le=n.get(M[Be]).__webglTexture;i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,Le,0)}i.blitFramebuffer(0,0,Z,pe,0,0,Z,pe,ge,i.NEAREST),l===!0&&(gt.length=0,Yt.length=0,gt.push(i.COLOR_ATTACHMENT0+Be),F.depthBuffer&&F.resolveDepthBuffer===!1&&(gt.push(Se),Yt.push(Se),i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,Yt)),i.invalidateFramebuffer(i.READ_FRAMEBUFFER,gt))}if(t.bindFramebuffer(i.READ_FRAMEBUFFER,null),t.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),ce)for(let Be=0;Be<M.length;Be++){t.bindFramebuffer(i.FRAMEBUFFER,Ce.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+Be,i.RENDERBUFFER,Ce.__webglColorRenderbuffer[Be]);let Le=n.get(M[Be]).__webglTexture;t.bindFramebuffer(i.FRAMEBUFFER,Ce.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+Be,i.TEXTURE_2D,Le,0)}t.bindFramebuffer(i.DRAW_FRAMEBUFFER,Ce.__webglMultisampledFramebuffer)}else if(F.depthBuffer&&F.resolveDepthBuffer===!1&&l){let M=F.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,[M])}}}function $t(F){return Math.min(r.maxSamples,F.samples)}function ht(F){let M=n.get(F);return F.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&M.__useRenderToTexture!==!1}function Tt(F){let M=a.render.frame;h.get(F)!==M&&(h.set(F,M),F.update())}function Pe(F,M){let Z=F.colorSpace,pe=F.format,ge=F.type;return F.isCompressedTexture===!0||F.isVideoTexture===!0||Z!==bn&&Z!==Fi&&(ut.getTransfer(Z)===Dt?(pe!==ci||ge!==Qn)&&Ke("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):et("WebGLTextures: Unsupported texture color space:",Z)),M}function Ot(F){return typeof HTMLImageElement<"u"&&F instanceof HTMLImageElement?(c.width=F.naturalWidth||F.width,c.height=F.naturalHeight||F.height):typeof VideoFrame<"u"&&F instanceof VideoFrame?(c.width=F.displayWidth,c.height=F.displayHeight):(c.width=F.width,c.height=F.height),c}this.allocateTextureUnit=D,this.resetTextureUnits=J,this.getTextureUnits=L,this.setTextureUnits=E,this.setTexture2D=H,this.setTexture2DArray=Y,this.setTexture3D=le,this.setTextureCube=fe,this.rebindTextures=wt,this.setupRenderTarget=lt,this.updateRenderTargetMipmap=Bt,this.updateMultisampleRenderTarget=q,this.setupDepthRenderbuffer=mt,this.setupFrameBufferTexture=Qe,this.useMultisampledRTT=ht,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function oT(i,e){function t(n,r=Fi){let s,a=ut.getTransfer(r);if(n===Qn)return i.UNSIGNED_BYTE;if(n===Dl)return i.UNSIGNED_SHORT_4_4_4_4;if(n===Nl)return i.UNSIGNED_SHORT_5_5_5_1;if(n===Nd)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===Od)return i.UNSIGNED_INT_10F_11F_11F_REV;if(n===Ld)return i.BYTE;if(n===Dd)return i.SHORT;if(n===ba)return i.UNSIGNED_SHORT;if(n===Ll)return i.INT;if(n===Oi)return i.UNSIGNED_INT;if(n===Tn)return i.FLOAT;if(n===Gn)return i.HALF_FLOAT;if(n===Fd)return i.ALPHA;if(n===Ud)return i.RGB;if(n===ci)return i.RGBA;if(n===Wi)return i.DEPTH_COMPONENT;if(n===jr)return i.DEPTH_STENCIL;if(n===Ol)return i.RED;if(n===Fl)return i.RED_INTEGER;if(n===Xr)return i.RG;if(n===Ul)return i.RG_INTEGER;if(n===kl)return i.RGBA_INTEGER;if(n===Io||n===Po||n===Lo||n===Do)if(a===Dt)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(n===Io)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Po)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Lo)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Do)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(n===Io)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Po)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Lo)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Do)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===Bl||n===zl||n===Hl||n===Gl)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(n===Bl)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===zl)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===Hl)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Gl)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===Vl||n===Wl||n===ql||n===$l||n===jl||n===No||n===Xl)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(n===Vl||n===Wl)return a===Dt?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(n===ql)return a===Dt?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC;if(n===$l)return s.COMPRESSED_R11_EAC;if(n===jl)return s.COMPRESSED_SIGNED_R11_EAC;if(n===No)return s.COMPRESSED_RG11_EAC;if(n===Xl)return s.COMPRESSED_SIGNED_RG11_EAC}else return null;if(n===Kl||n===Yl||n===Jl||n===Zl||n===Ql||n===eh||n===th||n===nh||n===ih||n===rh||n===sh||n===ah||n===oh||n===ch)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(n===Kl)return a===Dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Yl)return a===Dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===Jl)return a===Dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===Zl)return a===Dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Ql)return a===Dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===eh)return a===Dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===th)return a===Dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===nh)return a===Dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===ih)return a===Dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===rh)return a===Dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===sh)return a===Dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===ah)return a===Dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===oh)return a===Dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===ch)return a===Dt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===lh||n===hh||n===uh)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(n===lh)return a===Dt?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===hh)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===uh)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===dh||n===fh||n===Oo||n===ph)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(n===dh)return s.COMPRESSED_RED_RGTC1_EXT;if(n===fh)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===Oo)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===ph)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===xa?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:t}}function uT(i,e){function t(b,g){b.matrixAutoUpdate===!0&&b.updateMatrix(),g.value.copy(b.matrix)}function n(b,g){g.color.getRGB(b.fogColor.value,Gd(i)),g.isFog?(b.fogNear.value=g.near,b.fogFar.value=g.far):g.isFogExp2&&(b.fogDensity.value=g.density)}function r(b,g,S,A,T){g.isNodeMaterial?g.uniformsNeedUpdate=!1:g.isMeshBasicMaterial?s(b,g):g.isMeshLambertMaterial?(s(b,g),g.envMap&&(b.envMapIntensity.value=g.envMapIntensity)):g.isMeshToonMaterial?(s(b,g),d(b,g)):g.isMeshPhongMaterial?(s(b,g),h(b,g),g.envMap&&(b.envMapIntensity.value=g.envMapIntensity)):g.isMeshStandardMaterial?(s(b,g),f(b,g),g.isMeshPhysicalMaterial&&p(b,g,T)):g.isMeshMatcapMaterial?(s(b,g),x(b,g)):g.isMeshDepthMaterial?s(b,g):g.isMeshDistanceMaterial?(s(b,g),y(b,g)):g.isMeshNormalMaterial?s(b,g):g.isLineBasicMaterial?(a(b,g),g.isLineDashedMaterial&&o(b,g)):g.isPointsMaterial?l(b,g,S,A):g.isSpriteMaterial?c(b,g):g.isShadowMaterial?(b.color.value.copy(g.color),b.opacity.value=g.opacity):g.isShaderMaterial&&(g.uniformsNeedUpdate=!1)}function s(b,g){b.opacity.value=g.opacity,g.color&&b.diffuse.value.copy(g.color),g.emissive&&b.emissive.value.copy(g.emissive).multiplyScalar(g.emissiveIntensity),g.map&&(b.map.value=g.map,t(g.map,b.mapTransform)),g.alphaMap&&(b.alphaMap.value=g.alphaMap,t(g.alphaMap,b.alphaMapTransform)),g.bumpMap&&(b.bumpMap.value=g.bumpMap,t(g.bumpMap,b.bumpMapTransform),b.bumpScale.value=g.bumpScale,g.side===An&&(b.bumpScale.value*=-1)),g.normalMap&&(b.normalMap.value=g.normalMap,t(g.normalMap,b.normalMapTransform),b.normalScale.value.copy(g.normalScale),g.side===An&&b.normalScale.value.negate()),g.displacementMap&&(b.displacementMap.value=g.displacementMap,t(g.displacementMap,b.displacementMapTransform),b.displacementScale.value=g.displacementScale,b.displacementBias.value=g.displacementBias),g.emissiveMap&&(b.emissiveMap.value=g.emissiveMap,t(g.emissiveMap,b.emissiveMapTransform)),g.specularMap&&(b.specularMap.value=g.specularMap,t(g.specularMap,b.specularMapTransform)),g.alphaTest>0&&(b.alphaTest.value=g.alphaTest);let S=e.get(g),A=S.envMap,T=S.envMapRotation;A&&(b.envMap.value=A,b.envMapRotation.value.setFromMatrix4(hT.makeRotationFromEuler(T)).transpose(),A.isCubeTexture&&A.isRenderTargetTexture===!1&&b.envMapRotation.value.premultiply(ob),b.reflectivity.value=g.reflectivity,b.ior.value=g.ior,b.refractionRatio.value=g.refractionRatio),g.lightMap&&(b.lightMap.value=g.lightMap,b.lightMapIntensity.value=g.lightMapIntensity,t(g.lightMap,b.lightMapTransform)),g.aoMap&&(b.aoMap.value=g.aoMap,b.aoMapIntensity.value=g.aoMapIntensity,t(g.aoMap,b.aoMapTransform))}function a(b,g){b.diffuse.value.copy(g.color),b.opacity.value=g.opacity,g.map&&(b.map.value=g.map,t(g.map,b.mapTransform))}function o(b,g){b.dashSize.value=g.dashSize,b.totalSize.value=g.dashSize+g.gapSize,b.scale.value=g.scale}function l(b,g,S,A){b.diffuse.value.copy(g.color),b.opacity.value=g.opacity,b.size.value=g.size*S,b.scale.value=A*.5,g.map&&(b.map.value=g.map,t(g.map,b.uvTransform)),g.alphaMap&&(b.alphaMap.value=g.alphaMap,t(g.alphaMap,b.alphaMapTransform)),g.alphaTest>0&&(b.alphaTest.value=g.alphaTest)}function c(b,g){b.diffuse.value.copy(g.color),b.opacity.value=g.opacity,b.rotation.value=g.rotation,g.map&&(b.map.value=g.map,t(g.map,b.mapTransform)),g.alphaMap&&(b.alphaMap.value=g.alphaMap,t(g.alphaMap,b.alphaMapTransform)),g.alphaTest>0&&(b.alphaTest.value=g.alphaTest)}function h(b,g){b.specular.value.copy(g.specular),b.shininess.value=Math.max(g.shininess,1e-4)}function d(b,g){g.gradientMap&&(b.gradientMap.value=g.gradientMap)}function f(b,g){b.metalness.value=g.metalness,g.metalnessMap&&(b.metalnessMap.value=g.metalnessMap,t(g.metalnessMap,b.metalnessMapTransform)),b.roughness.value=g.roughness,g.roughnessMap&&(b.roughnessMap.value=g.roughnessMap,t(g.roughnessMap,b.roughnessMapTransform)),g.envMap&&(b.envMapIntensity.value=g.envMapIntensity)}function p(b,g,S){b.ior.value=g.ior,g.sheen>0&&(b.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),b.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap&&(b.sheenColorMap.value=g.sheenColorMap,t(g.sheenColorMap,b.sheenColorMapTransform)),g.sheenRoughnessMap&&(b.sheenRoughnessMap.value=g.sheenRoughnessMap,t(g.sheenRoughnessMap,b.sheenRoughnessMapTransform))),g.clearcoat>0&&(b.clearcoat.value=g.clearcoat,b.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap&&(b.clearcoatMap.value=g.clearcoatMap,t(g.clearcoatMap,b.clearcoatMapTransform)),g.clearcoatRoughnessMap&&(b.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap,t(g.clearcoatRoughnessMap,b.clearcoatRoughnessMapTransform)),g.clearcoatNormalMap&&(b.clearcoatNormalMap.value=g.clearcoatNormalMap,t(g.clearcoatNormalMap,b.clearcoatNormalMapTransform),b.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),g.side===An&&b.clearcoatNormalScale.value.negate())),g.dispersion>0&&(b.dispersion.value=g.dispersion),g.iridescence>0&&(b.iridescence.value=g.iridescence,b.iridescenceIOR.value=g.iridescenceIOR,b.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],b.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap&&(b.iridescenceMap.value=g.iridescenceMap,t(g.iridescenceMap,b.iridescenceMapTransform)),g.iridescenceThicknessMap&&(b.iridescenceThicknessMap.value=g.iridescenceThicknessMap,t(g.iridescenceThicknessMap,b.iridescenceThicknessMapTransform))),g.transmission>0&&(b.transmission.value=g.transmission,b.transmissionSamplerMap.value=S.texture,b.transmissionSamplerSize.value.set(S.width,S.height),g.transmissionMap&&(b.transmissionMap.value=g.transmissionMap,t(g.transmissionMap,b.transmissionMapTransform)),b.thickness.value=g.thickness,g.thicknessMap&&(b.thicknessMap.value=g.thicknessMap,t(g.thicknessMap,b.thicknessMapTransform)),b.attenuationDistance.value=g.attenuationDistance,b.attenuationColor.value.copy(g.attenuationColor)),g.anisotropy>0&&(b.anisotropyVector.value.set(g.anisotropy*Math.cos(g.anisotropyRotation),g.anisotropy*Math.sin(g.anisotropyRotation)),g.anisotropyMap&&(b.anisotropyMap.value=g.anisotropyMap,t(g.anisotropyMap,b.anisotropyMapTransform))),b.specularIntensity.value=g.specularIntensity,b.specularColor.value.copy(g.specularColor),g.specularColorMap&&(b.specularColorMap.value=g.specularColorMap,t(g.specularColorMap,b.specularColorMapTransform)),g.specularIntensityMap&&(b.specularIntensityMap.value=g.specularIntensityMap,t(g.specularIntensityMap,b.specularIntensityMapTransform))}function x(b,g){g.matcap&&(b.matcap.value=g.matcap)}function y(b,g){let S=e.get(g).light;b.referencePosition.value.setFromMatrixPosition(S.matrixWorld),b.nearDistance.value=S.shadow.camera.near,b.farDistance.value=S.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:r}}function dT(i,e,t,n){let r={},s={},a=[],o=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function l(S,A){let T=A.program;n.uniformBlockBinding(S,T)}function c(S,A){let T=r[S.id];T===void 0&&(x(S),T=h(S),r[S.id]=T,S.addEventListener("dispose",b));let N=A.program;n.updateUBOMapping(S,N);let P=e.render.frame;s[S.id]!==P&&(f(S),s[S.id]=P)}function h(S){let A=d();S.__bindingPointIndex=A;let T=i.createBuffer(),N=S.__size,P=S.usage;return i.bindBuffer(i.UNIFORM_BUFFER,T),i.bufferData(i.UNIFORM_BUFFER,N,P),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,A,T),T}function d(){for(let S=0;S<o;S++)if(a.indexOf(S)===-1)return a.push(S),S;return et("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function f(S){let A=r[S.id],T=S.uniforms,N=S.__cache;i.bindBuffer(i.UNIFORM_BUFFER,A);for(let P=0,U=T.length;P<U;P++){let v=Array.isArray(T[P])?T[P]:[T[P]];for(let I=0,B=v.length;I<B;I++){let k=v[I];if(p(k,P,I,N)===!0){let V=k.__offset,J=Array.isArray(k.value)?k.value:[k.value],L=0;for(let E=0;E<J.length;E++){let D=J[E],O=y(D);typeof D=="number"||typeof D=="boolean"?(k.__data[0]=D,i.bufferSubData(i.UNIFORM_BUFFER,V+L,k.__data)):D.isMatrix3?(k.__data[0]=D.elements[0],k.__data[1]=D.elements[1],k.__data[2]=D.elements[2],k.__data[3]=0,k.__data[4]=D.elements[3],k.__data[5]=D.elements[4],k.__data[6]=D.elements[5],k.__data[7]=0,k.__data[8]=D.elements[6],k.__data[9]=D.elements[7],k.__data[10]=D.elements[8],k.__data[11]=0):ArrayBuffer.isView(D)?k.__data.set(new D.constructor(D.buffer,D.byteOffset,k.__data.length)):(D.toArray(k.__data,L),L+=O.storage/Float32Array.BYTES_PER_ELEMENT)}i.bufferSubData(i.UNIFORM_BUFFER,V,k.__data)}}}i.bindBuffer(i.UNIFORM_BUFFER,null)}function p(S,A,T,N){let P=S.value,U=A+"_"+T;if(N[U]===void 0)return typeof P=="number"||typeof P=="boolean"?N[U]=P:ArrayBuffer.isView(P)?N[U]=P.slice():N[U]=P.clone(),!0;{let v=N[U];if(typeof P=="number"||typeof P=="boolean"){if(v!==P)return N[U]=P,!0}else{if(ArrayBuffer.isView(P))return!0;if(v.equals(P)===!1)return v.copy(P),!0}}return!1}function x(S){let A=S.uniforms,T=0,N=16;for(let U=0,v=A.length;U<v;U++){let I=Array.isArray(A[U])?A[U]:[A[U]];for(let B=0,k=I.length;B<k;B++){let V=I[B],J=Array.isArray(V.value)?V.value:[V.value];for(let L=0,E=J.length;L<E;L++){let D=J[L],O=y(D),H=T%N,Y=H%O.boundary,le=H+Y;T+=Y,le!==0&&N-le<O.storage&&(T+=N-le),V.__data=new Float32Array(O.storage/Float32Array.BYTES_PER_ELEMENT),V.__offset=T,T+=O.storage}}}let P=T%N;return P>0&&(T+=N-P),S.__size=T,S.__cache={},this}function y(S){let A={boundary:0,storage:0};return typeof S=="number"||typeof S=="boolean"?(A.boundary=4,A.storage=4):S.isVector2?(A.boundary=8,A.storage=8):S.isVector3||S.isColor?(A.boundary=16,A.storage=12):S.isVector4?(A.boundary=16,A.storage=16):S.isMatrix3?(A.boundary=48,A.storage=48):S.isMatrix4?(A.boundary=64,A.storage=64):S.isTexture?Ke("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(S)?(A.boundary=16,A.storage=S.byteLength):Ke("WebGLRenderer: Unsupported uniform value type.",S),A}function b(S){let A=S.target;A.removeEventListener("dispose",b);let T=a.indexOf(A.__bindingPointIndex);a.splice(T,1),i.deleteBuffer(r[A.id]),delete r[A.id],delete s[A.id]}function g(){for(let S in r)i.deleteBuffer(r[S]);a=[],r={},s={}}return{bind:l,update:c,dispose:g}}function pT(){return Zi===null&&(Zi=new xs(fT,16,16,Xr,Gn),Zi.name="DFG_LUT",Zi.minFilter=zt,Zi.magFilter=zt,Zi.wrapS=Kn,Zi.wrapT=Kn,Zi.generateMipmaps=!1,Zi.needsUpdate=!0),Zi}var CS,IS,PS,LS,DS,NS,OS,FS,US,kS,BS,zS,HS,GS,VS,WS,qS,$S,jS,XS,KS,YS,JS,ZS,QS,ew,tw,nw,iw,rw,sw,aw,ow,cw,lw,hw,uw,dw,fw,pw,mw,gw,bw,xw,_w,yw,vw,Sw,ww,Mw,Aw,Tw,Ew,Rw,Cw,Iw,Pw,Lw,Dw,Nw,Ow,Fw,Uw,kw,Bw,zw,Hw,Gw,Vw,Ww,qw,$w,jw,Xw,Kw,Yw,Jw,Zw,Qw,e1,t1,n1,i1,r1,s1,a1,o1,c1,l1,h1,u1,d1,f1,p1,m1,g1,b1,x1,_1,y1,v1,S1,w1,M1,A1,T1,E1,R1,C1,I1,P1,L1,D1,N1,O1,F1,U1,k1,B1,z1,H1,G1,V1,W1,q1,$1,j1,X1,K1,Y1,J1,Z1,Q1,eM,tM,nM,iM,rM,sM,aM,oM,cM,ft,Ue,Qi,xh,lM,nb,Kr,D0,Rs,mM,zo,N0,Qd,ef,tf,nf,gM,wa,Ma,EM,ib,af,rb,sb,ab,k0,B0,z0,H0,G0,of,cf,lf,rf,Sa,gA,bA,q0,vA,_h,EA,RA,IA,LA,NA,FA,kA,GA,uf,df,YA,eT,tT,nT,iT,eb,Ho,sf,cT,lT,ff,pf,hT,ob,fT,Zi,yh,Vn=un(()=>{Zd();Zd();CS=`#ifdef USE_ALPHAHASH
+Program Info Log: `+N+`
+`+Q+`
+`+te)}else N!==""?tt("WebGLProgram: Program Info Log:",N):(O===""||F==="")&&(V=!1);V&&(z.diagnostics={runnable:H,programLog:N,vertexShader:{log:O,prefix:_},fragmentShader:{log:F,prefix:g}})}s.deleteShader(M),s.deleteShader(A),y=new ho(s,v),C=PR(s,v)}let y;this.getUniforms=function(){return y===void 0&&I(this),y};let C;this.getAttributes=function(){return C===void 0&&I(this),C};let k=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return k===!1&&(k=s.getProgramParameter(v,vR)),k},this.destroy=function(){n.releaseStatesOfProgram(this),s.deleteProgram(v),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=SR++,this.cacheKey=e,this.usedTimes=1,this.program=v,this.vertexShader=M,this.fragmentShader=A,this}function XR(i){return i===wr||i===Tc||i===Rc}function KR(i,e,t,n,s,r){let a=new Xa,o=new Bp,c=new Set,l=[],h=new Map,u=n.logarithmicDepthBuffer,d=n.precision,p={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function b(y){return c.add(y),y===0?"uv":`uv${y}`}function v(y,C,k,z,$,K){let P=z.fog,N=$.geometry,O=y.isMeshStandardMaterial||y.isMeshLambertMaterial||y.isMeshPhongMaterial?z.environment:null,F=y.isMeshStandardMaterial||y.isMeshLambertMaterial&&!y.envMap||y.isMeshPhongMaterial&&!y.envMap,H=e.get(y.envMap||O,F),V=H&&H.mapping===Sc?H.image.height:null,Q=p[y.type];y.precision!==null&&(d=n.getMaxPrecision(y.precision),d!==y.precision&&tt("WebGLProgram.getParameters:",y.precision,"not supported, using",d,"instead."));let te=N.morphAttributes.position||N.morphAttributes.normal||N.morphAttributes.color,Se=te!==void 0?te.length:0,ve=0;N.morphAttributes.position!==void 0&&(ve=1),N.morphAttributes.normal!==void 0&&(ve=2),N.morphAttributes.color!==void 0&&(ve=3);let nt,je,Qe,fe;if(Q){let Ut=xs[Q];nt=Ut.vertexShader,je=Ut.fragmentShader}else{nt=y.vertexShader,je=y.fragmentShader;let Ut=o.getVertexShaderStage(y),Pt=o.getFragmentShaderStage(y);o.update(y,Ut,Pt),Qe=Ut.id,fe=Pt.id}let ge=i.getRenderTarget(),Ve=i.state.buffers.depth.getReversed(),it=$.isInstancedMesh===!0,Ue=$.isBatchedMesh===!0,ct=!!y.map,zt=!!y.matcap,ot=!!H,mt=!!y.aoMap,Lt=!!y.lightMap,ft=!!y.bumpMap&&y.wireframe===!1,xt=!!y.normalMap,Wt=!!y.displacementMap,_n=!!y.emissiveMap,Ht=!!y.metalnessMap,Kt=!!y.roughnessMap,q=y.anisotropy>0,hn=y.clearcoat>0,Et=y.dispersion>0,U=y.retroreflectivity>0,w=y.iridescence>0,ee=y.sheen>0,re=y.transmission>0,ce=q&&!!y.anisotropyMap,Ee=hn&&!!y.clearcoatMap,Ce=hn&&!!y.clearcoatNormalMap,de=hn&&!!y.clearcoatRoughnessMap,xe=w&&!!y.iridescenceMap,Pe=w&&!!y.iridescenceThicknessMap,qe=ee&&!!y.sheenColorMap,Ae=ee&&!!y.sheenRoughnessMap,Le=!!y.specularMap,Fe=!!y.specularColorMap,Je=!!y.specularIntensityMap,at=re&&!!y.transmissionMap,G=re&&!!y.thicknessMap,Ie=!!y.gradientMap,be=!!y.alphaMap,Re=y.alphaTest>0,Be=!!y.alphaHash,ye=!!y.extensions,et=Ji;y.toneMapped&&(ge===null||ge.isXRRenderTarget===!0)&&(et=i.toneMapping);let Ye={shaderID:Q,shaderType:y.type,shaderName:y.name,vertexShader:nt,fragmentShader:je,defines:y.defines,customVertexShaderID:Qe,customFragmentShaderID:fe,isRawShaderMaterial:y.isRawShaderMaterial===!0,glslVersion:y.glslVersion,precision:d,batching:Ue,batchingColor:Ue&&$._colorsTexture!==null,instancing:it,instancingColor:it&&$.instanceColor!==null,instancingMorph:it&&$.morphTexture!==null,outputColorSpace:ge===null?i.outputColorSpace:ge.isXRRenderTarget===!0?ge.texture.colorSpace:gt.workingColorSpace,alphaToCoverage:!!y.alphaToCoverage,map:ct,matcap:zt,envMap:ot,envMapMode:ot&&H.mapping,envMapCubeUVHeight:V,aoMap:mt,lightMap:Lt,bumpMap:ft,normalMap:xt,displacementMap:Wt,emissiveMap:_n,normalMapObjectSpace:xt&&y.normalMapType===d_,normalMapTangentSpace:xt&&y.normalMapType===Lc,packedNormalMap:xt&&y.normalMapType===Lc&&XR(y.normalMap.format),metalnessMap:Ht,roughnessMap:Kt,anisotropy:q,anisotropyMap:ce,clearcoat:hn,clearcoatMap:Ee,clearcoatNormalMap:Ce,clearcoatRoughnessMap:de,dispersion:Et,retroreflection:U,iridescence:w,iridescenceMap:xe,iridescenceThicknessMap:Pe,sheen:ee,sheenColorMap:qe,sheenRoughnessMap:Ae,specularMap:Le,specularColorMap:Fe,specularIntensityMap:Je,transmission:re,transmissionMap:at,thicknessMap:G,gradientMap:Ie,opaque:y.transparent===!1&&y.blending===no&&y.alphaToCoverage===!1,alphaMap:be,alphaTest:Re,alphaHash:Be,combine:y.combine,mapUv:ct&&b(y.map.channel),aoMapUv:mt&&b(y.aoMap.channel),lightMapUv:Lt&&b(y.lightMap.channel),bumpMapUv:ft&&b(y.bumpMap.channel),normalMapUv:xt&&b(y.normalMap.channel),displacementMapUv:Wt&&b(y.displacementMap.channel),emissiveMapUv:_n&&b(y.emissiveMap.channel),metalnessMapUv:Ht&&b(y.metalnessMap.channel),roughnessMapUv:Kt&&b(y.roughnessMap.channel),anisotropyMapUv:ce&&b(y.anisotropyMap.channel),clearcoatMapUv:Ee&&b(y.clearcoatMap.channel),clearcoatNormalMapUv:Ce&&b(y.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:de&&b(y.clearcoatRoughnessMap.channel),iridescenceMapUv:xe&&b(y.iridescenceMap.channel),iridescenceThicknessMapUv:Pe&&b(y.iridescenceThicknessMap.channel),sheenColorMapUv:qe&&b(y.sheenColorMap.channel),sheenRoughnessMapUv:Ae&&b(y.sheenRoughnessMap.channel),specularMapUv:Le&&b(y.specularMap.channel),specularColorMapUv:Fe&&b(y.specularColorMap.channel),specularIntensityMapUv:Je&&b(y.specularIntensityMap.channel),transmissionMapUv:at&&b(y.transmissionMap.channel),thicknessMapUv:G&&b(y.thicknessMap.channel),alphaMapUv:be&&b(y.alphaMap.channel),vertexTangents:!!N.attributes.tangent&&(xt||q),vertexNormals:!!N.attributes.normal,vertexColors:y.vertexColors,vertexAlphas:y.vertexColors===!0&&!!N.attributes.color&&N.attributes.color.itemSize===4,pointsUvs:$.isPoints===!0&&!!N.attributes.uv&&(ct||be),fog:!!P,useFog:y.fog===!0,fogExp2:!!P&&P.isFogExp2,flatShading:y.wireframe===!1&&(y.flatShading===!0||N.attributes.normal===void 0&&xt===!1&&(y.isMeshLambertMaterial||y.isMeshPhongMaterial||y.isMeshStandardMaterial||y.isMeshPhysicalMaterial)),sizeAttenuation:y.sizeAttenuation===!0,logarithmicDepthBuffer:u,reversedDepthBuffer:Ve,skinning:$.isSkinnedMesh===!0,hasPositionAttribute:N.attributes.position!==void 0,morphTargets:N.morphAttributes.position!==void 0,morphNormals:N.morphAttributes.normal!==void 0,morphColors:N.morphAttributes.color!==void 0,morphTargetsCount:Se,morphTextureStride:ve,numSunLights:C.sun.length,numDirLights:C.directional.length,numPointLights:C.point.length,numSpotLights:C.spot.length,numSpotLightMaps:C.spotLightMap.length,numRectAreaLights:C.rectArea.length,numHemiLights:C.hemi.length,numSunLightShadows:C.sunShadowMap.length,numDirLightShadows:C.directionalShadowMap.length,numPointLightShadows:C.pointShadowMap.length,numSpotLightShadows:C.spotShadowMap.length,numSpotLightShadowsWithMaps:C.numSpotLightShadowsWithMaps,numLightProbes:C.numLightProbes,numLightProbeGrids:K.length,numClippingPlanes:r.numPlanes,numClipIntersection:r.numIntersection,dithering:y.dithering,shadowMapEnabled:i.shadowMap.enabled&&k.length>0,shadowMapType:i.shadowMap.type,toneMapping:et,decodeVideoTexture:ct&&y.map.isVideoTexture===!0&&gt.getTransfer(y.map.colorSpace)===Bt,decodeVideoTextureEmissive:_n&&y.emissiveMap.isVideoTexture===!0&&gt.getTransfer(y.emissiveMap.colorSpace)===Bt,premultipliedAlpha:y.premultipliedAlpha,doubleSided:y.side===$n,flipSided:y.side===Nn,useDepthPacking:y.depthPacking>=0,depthPacking:y.depthPacking||0,index0AttributeName:y.index0AttributeName,extensionClipCullDistance:ye&&y.extensions.clipCullDistance===!0&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ye&&y.extensions.multiDraw===!0||Ue)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:y.customProgramCacheKey()};return Ye.vertexUv1s=c.has(1),Ye.vertexUv2s=c.has(2),Ye.vertexUv3s=c.has(3),c.clear(),Ye}function _(y){let C=[];if(y.shaderID?C.push(y.shaderID):(C.push(y.customVertexShaderID),C.push(y.customFragmentShaderID)),y.defines!==void 0)for(let k in y.defines)C.push(k),C.push(y.defines[k]);return y.isRawShaderMaterial===!1&&(g(C,y),E(C,y),C.push(i.outputColorSpace)),C.push(y.customProgramCacheKey),C.join()}function g(y,C){y.push(C.precision),y.push(C.outputColorSpace),y.push(C.envMapMode),y.push(C.envMapCubeUVHeight),y.push(C.mapUv),y.push(C.alphaMapUv),y.push(C.lightMapUv),y.push(C.aoMapUv),y.push(C.bumpMapUv),y.push(C.normalMapUv),y.push(C.displacementMapUv),y.push(C.emissiveMapUv),y.push(C.metalnessMapUv),y.push(C.roughnessMapUv),y.push(C.anisotropyMapUv),y.push(C.clearcoatMapUv),y.push(C.clearcoatNormalMapUv),y.push(C.clearcoatRoughnessMapUv),y.push(C.iridescenceMapUv),y.push(C.iridescenceThicknessMapUv),y.push(C.sheenColorMapUv),y.push(C.sheenRoughnessMapUv),y.push(C.specularMapUv),y.push(C.specularColorMapUv),y.push(C.specularIntensityMapUv),y.push(C.transmissionMapUv),y.push(C.thicknessMapUv),y.push(C.combine),y.push(C.fogExp2),y.push(C.sizeAttenuation),y.push(C.morphTargetsCount),y.push(C.morphAttributeCount),y.push(C.numSunLights),y.push(C.numDirLights),y.push(C.numPointLights),y.push(C.numSpotLights),y.push(C.numSpotLightMaps),y.push(C.numHemiLights),y.push(C.numRectAreaLights),y.push(C.numSunLightShadows),y.push(C.numDirLightShadows),y.push(C.numPointLightShadows),y.push(C.numSpotLightShadows),y.push(C.numSpotLightShadowsWithMaps),y.push(C.numLightProbes),y.push(C.shadowMapType),y.push(C.toneMapping),y.push(C.numClippingPlanes),y.push(C.numClipIntersection),y.push(C.depthPacking)}function E(y,C){a.disableAll(),C.instancing&&a.enable(0),C.instancingColor&&a.enable(1),C.instancingMorph&&a.enable(2),C.matcap&&a.enable(3),C.envMap&&a.enable(4),C.normalMapObjectSpace&&a.enable(5),C.normalMapTangentSpace&&a.enable(6),C.clearcoat&&a.enable(7),C.iridescence&&a.enable(8),C.alphaTest&&a.enable(9),C.vertexColors&&a.enable(10),C.vertexAlphas&&a.enable(11),C.vertexUv1s&&a.enable(12),C.vertexUv2s&&a.enable(13),C.vertexUv3s&&a.enable(14),C.vertexTangents&&a.enable(15),C.anisotropy&&a.enable(16),C.alphaHash&&a.enable(17),C.batching&&a.enable(18),C.dispersion&&a.enable(19),C.retroreflection&&a.enable(24),C.batchingColor&&a.enable(20),C.gradientMap&&a.enable(21),C.packedNormalMap&&a.enable(22),C.vertexNormals&&a.enable(23),y.push(a.mask),a.disableAll(),C.fog&&a.enable(0),C.useFog&&a.enable(1),C.flatShading&&a.enable(2),C.logarithmicDepthBuffer&&a.enable(3),C.reversedDepthBuffer&&a.enable(4),C.skinning&&a.enable(5),C.morphTargets&&a.enable(6),C.morphNormals&&a.enable(7),C.morphColors&&a.enable(8),C.premultipliedAlpha&&a.enable(9),C.shadowMapEnabled&&a.enable(10),C.doubleSided&&a.enable(11),C.flipSided&&a.enable(12),C.useDepthPacking&&a.enable(13),C.dithering&&a.enable(14),C.transmission&&a.enable(15),C.sheen&&a.enable(16),C.opaque&&a.enable(17),C.pointsUvs&&a.enable(18),C.decodeVideoTexture&&a.enable(19),C.decodeVideoTextureEmissive&&a.enable(20),C.alphaToCoverage&&a.enable(21),C.numLightProbeGrids>0&&a.enable(22),C.hasPositionAttribute&&a.enable(23),y.push(a.mask)}function L(y){let C=p[y.type],k;if(C){let z=xs[C];k=T_.clone(z.uniforms)}else k=y.uniforms;return k}function S(y,C){let k=h.get(C);return k!==void 0?++k.usedTimes:(k=new qR(i,C,y,s),l.push(k),h.set(C,k)),k}function M(y){if(--y.usedTimes===0){let C=l.indexOf(y);l[C]=l[l.length-1],l.pop(),h.delete(y.cacheKey),y.destroy()}}function A(y){o.remove(y)}function I(){o.dispose()}return{getParameters:v,getProgramCacheKey:_,getUniforms:L,acquireProgram:S,releaseProgram:M,releaseShaderCache:A,programs:l,dispose:I}}function YR(){let i=new WeakMap;function e(a){return i.has(a)}function t(a){let o=i.get(a);return o===void 0&&(o={},i.set(a,o)),o}function n(a){i.delete(a)}function s(a,o,c){i.get(a)[o]=c}function r(){i=new WeakMap}return{has:e,get:t,remove:n,update:s,dispose:r}}function JR(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.material.id!==e.material.id?i.material.id-e.material.id:i.materialVariant!==e.materialVariant?i.materialVariant-e.materialVariant:i.z!==e.z?i.z-e.z:i.id-e.id}function K_(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.z!==e.z?e.z-i.z:i.id-e.id}function Y_(){let i=[],e=0,t=[],n=[],s=[];function r(){e=0,t.length=0,n.length=0,s.length=0}function a(d){let p=0;return d.isInstancedMesh&&(p+=2),d.isSkinnedMesh&&(p+=1),p}function o(d,p,b,v,_,g){let E=i[e];return E===void 0?(E={id:d.id,object:d,geometry:p,material:b,materialVariant:a(d),groupOrder:v,renderOrder:d.renderOrder,z:_,group:g},i[e]=E):(E.id=d.id,E.object=d,E.geometry=p,E.material=b,E.materialVariant=a(d),E.groupOrder=v,E.renderOrder=d.renderOrder,E.z=_,E.group=g),e++,E}function c(d,p,b,v,_,g,E){E.reversedDepth===!0&&(_=-_);let L=o(d,p,b,v,_,g);b.transmission>0?n.push(L):b.transparent===!0?s.push(L):t.push(L)}function l(d,p,b,v,_,g){let E=o(d,p,b,v,_,g);b.transmission>0?n.unshift(E):b.transparent===!0?s.unshift(E):t.unshift(E)}function h(d,p){t.length>1&&t.sort(d||JR),n.length>1&&n.sort(p||K_),s.length>1&&s.sort(p||K_)}function u(){for(let d=e,p=i.length;d<p;d++){let b=i[d];if(b.id===null)break;b.id=null,b.object=null,b.geometry=null,b.material=null,b.group=null}}return{opaque:t,transmissive:n,transparent:s,init:r,push:c,unshift:l,finish:u,sort:h}}function ZR(){let i=new WeakMap;function e(n,s){let r=i.get(n),a;return r===void 0?(a=new Y_,i.set(n,[a])):s>=r.length?(a=new Y_,r.push(a)):a=r[s],a}function t(){i=new WeakMap}return{get:e,dispose:t}}function QR(){let i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"SunLight":case"DirectionalLight":t={direction:new j,color:new He};break;case"SpotLight":t={position:new j,direction:new j,color:new He,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new j,color:new He,distance:0,decay:0};break;case"HemisphereLight":t={direction:new j,skyColor:new He,groundColor:new He};break;case"RectAreaLight":t={color:new He,position:new j,halfWidth:new j,halfHeight:new j};break}return i[e.id]=t,t}}}function eC(){let i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"SunLight":case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new dt};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new dt};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new dt,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[e.id]=t,t}}}function nC(i,e){return(e.castShadow?2:0)-(i.castShadow?2:0)+(e.map?1:0)-(i.map?1:0)}function iC(i){let e=new QR,t=eC(),n={version:0,hash:{sunLength:-1,directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numSunShadows:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],sun:[],sunShadow:[],sunShadowMap:[],sunShadowMatrix:[],sunShadowCascade:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let l=0;l<9;l++)n.probe.push(new j);let s=new j,r=new ht,a=new ht;function o(l){let h=0,u=0,d=0;for(let $=0;$<9;$++)n.probe[$].set(0,0,0);let p=0,b=0,v=0,_=0,g=0,E=0,L=0,S=0,M=0,A=0,I=0,y=0,C=0,k=0;l.sort(nC);for(let $=0,K=l.length;$<K;$++){let P=l[$],N=P.color,O=P.intensity,F=P.distance,H=null;if(P.shadow&&P.shadow.map&&(P.shadow.map.texture.format===wr?H=P.shadow.map.texture:H=P.shadow.map.depthTexture||P.shadow.map.texture),P.isAmbientLight)h+=N.r*O,u+=N.g*O,d+=N.b*O;else if(P.isLightProbe){for(let V=0;V<9;V++)n.probe[V].addScaledVector(P.sh.coefficients[V],O);k++}else if(P.isSunLight){let V=e.get(P);if(V.color.copy(P.color).multiplyScalar(P.intensity),P.castShadow){let Q=P.shadow,te=t.get(P);te.shadowIntensity=Q.intensity,te.shadowBias=Q.bias,te.shadowNormalBias=Q.normalBias,te.shadowRadius=Q.radius,te.shadowMapSize.copy(Q.mapSize).multiply(Q.getFrameExtents()),n.sunShadow[b]=te,n.sunShadowMap[b]=H;let Se=Q.getViewportCount();for(let ve=0;ve<Se;ve++)n.sunShadowMatrix[v+ve]=Q.getMatrix(ve),n.sunShadowCascade[v+ve]=Q._cascadeData[ve];v+=Se,b++}n.sun[p]=V,p++}else if(P.isDirectionalLight){let V=e.get(P);if(V.color.copy(P.color).multiplyScalar(P.intensity),P.castShadow){let Q=P.shadow,te=t.get(P);te.shadowIntensity=Q.intensity,te.shadowBias=Q.bias,te.shadowNormalBias=Q.normalBias,te.shadowRadius=Q.radius,te.shadowMapSize=Q.mapSize,n.directionalShadow[_]=te,n.directionalShadowMap[_]=H,n.directionalShadowMatrix[_]=P.shadow.matrix,M++}n.directional[_]=V,_++}else if(P.isSpotLight){let V=e.get(P);V.position.setFromMatrixPosition(P.matrixWorld),V.color.copy(N).multiplyScalar(O),V.distance=F,V.coneCos=Math.cos(P.angle),V.penumbraCos=Math.cos(P.angle*(1-P.penumbra)),V.decay=P.decay,n.spot[E]=V;let Q=P.shadow;if(P.map&&(n.spotLightMap[y]=P.map,y++,Q.updateMatrices(P),P.castShadow&&C++),n.spotLightMatrix[E]=Q.matrix,P.castShadow){let te=t.get(P);te.shadowIntensity=Q.intensity,te.shadowBias=Q.bias,te.shadowNormalBias=Q.normalBias,te.shadowRadius=Q.radius,te.shadowMapSize=Q.mapSize,n.spotShadow[E]=te,n.spotShadowMap[E]=H,I++}E++}else if(P.isRectAreaLight){let V=e.get(P);V.color.copy(N).multiplyScalar(O),V.halfWidth.set(P.width*.5,0,0),V.halfHeight.set(0,P.height*.5,0),n.rectArea[L]=V,L++}else if(P.isPointLight){let V=e.get(P);if(V.color.copy(P.color).multiplyScalar(P.intensity),V.distance=P.distance,V.decay=P.decay,P.castShadow){let Q=P.shadow,te=t.get(P);te.shadowIntensity=Q.intensity,te.shadowBias=Q.bias,te.shadowNormalBias=Q.normalBias,te.shadowRadius=Q.radius,te.shadowMapSize=Q.mapSize,te.shadowCameraNear=Q.camera.near,te.shadowCameraFar=Q.camera.far,n.pointShadow[g]=te,n.pointShadowMap[g]=H,n.pointShadowMatrix[g]=P.shadow.matrix,A++}n.point[g]=V,g++}else if(P.isHemisphereLight){let V=e.get(P);V.skyColor.copy(P.color).multiplyScalar(O),V.groundColor.copy(P.groundColor).multiplyScalar(O),n.hemi[S]=V,S++}}L>0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=ke.LTC_FLOAT_1,n.rectAreaLTC2=ke.LTC_FLOAT_2):(n.rectAreaLTC1=ke.LTC_HALF_1,n.rectAreaLTC2=ke.LTC_HALF_2)),n.ambient[0]=h,n.ambient[1]=u,n.ambient[2]=d;let z=n.hash;(z.sunLength!==p||z.directionalLength!==_||z.pointLength!==g||z.spotLength!==E||z.rectAreaLength!==L||z.hemiLength!==S||z.numSunShadows!==b||z.numDirectionalShadows!==M||z.numPointShadows!==A||z.numSpotShadows!==I||z.numSpotMaps!==y||z.numLightProbes!==k)&&(n.sun.length=p,n.directional.length=_,n.spot.length=E,n.rectArea.length=L,n.point.length=g,n.hemi.length=S,n.sunShadow.length=b,n.sunShadowMap.length=b,n.sunShadowMatrix.length=v,n.sunShadowCascade.length=v,n.directionalShadow.length=M,n.directionalShadowMap.length=M,n.directionalShadowMatrix.length=M,n.pointShadow.length=A,n.pointShadowMap.length=A,n.pointShadowMatrix.length=A,n.spotShadow.length=I,n.spotShadowMap.length=I,n.spotLightMatrix.length=I+y-C,n.spotLightMap.length=y,n.numSpotLightShadowsWithMaps=C,n.numLightProbes=k,z.sunLength=p,z.directionalLength=_,z.pointLength=g,z.spotLength=E,z.rectAreaLength=L,z.hemiLength=S,z.numSunShadows=b,z.numDirectionalShadows=M,z.numPointShadows=A,z.numSpotShadows=I,z.numSpotMaps=y,z.numLightProbes=k,n.version=tC++)}function c(l,h){let u=0,d=0,p=0,b=0,v=0,_=0,g=h.matrixWorldInverse;for(let E=0,L=l.length;E<L;E++){let S=l[E];if(S.isSunLight){let M=n.sun[u];M.direction.setFromMatrixPosition(S.matrixWorld),M.direction.transformDirection(g),u++}else if(S.isDirectionalLight){let M=n.directional[d];M.direction.setFromMatrixPosition(S.matrixWorld),s.setFromMatrixPosition(S.target.matrixWorld),M.direction.sub(s),M.direction.transformDirection(g),d++}else if(S.isSpotLight){let M=n.spot[b];M.position.setFromMatrixPosition(S.matrixWorld),M.position.applyMatrix4(g),M.direction.setFromMatrixPosition(S.matrixWorld),s.setFromMatrixPosition(S.target.matrixWorld),M.direction.sub(s),M.direction.transformDirection(g),b++}else if(S.isRectAreaLight){let M=n.rectArea[v];M.position.setFromMatrixPosition(S.matrixWorld),M.position.applyMatrix4(g),a.identity(),r.copy(S.matrixWorld),r.premultiply(g),a.extractRotation(r),M.halfWidth.set(S.width*.5,0,0),M.halfHeight.set(0,S.height*.5,0),M.halfWidth.applyMatrix4(a),M.halfHeight.applyMatrix4(a),v++}else if(S.isPointLight){let M=n.point[p];M.position.setFromMatrixPosition(S.matrixWorld),M.position.applyMatrix4(g),p++}else if(S.isHemisphereLight){let M=n.hemi[_];M.direction.setFromMatrixPosition(S.matrixWorld),M.direction.transformDirection(g),_++}}}return{setup:o,setupView:c,state:n}}function J_(i){let e=new iC(i),t=[],n=[],s=[];function r(d){u.camera=d,t.length=0,n.length=0,s.length=0}function a(d){t.push(d)}function o(d){n.push(d)}function c(d){s.push(d)}function l(){e.setup(t)}function h(d){e.setupView(t,d)}let u={lightsArray:t,shadowsArray:n,lightProbeGridArray:s,camera:null,lights:e,transmissionRenderTarget:{},textureUnits:0};return{init:r,state:u,setupLights:l,setupLightsView:h,pushLight:a,pushShadow:o,pushLightProbeGrid:c}}function sC(i){let e=new WeakMap;function t(s,r=0){let a=e.get(s),o;return a===void 0?(o=new J_(i),e.set(s,[o])):r>=a.length?(o=new J_(i),a.push(o)):o=a[r],o}function n(){e=new WeakMap}return{get:t,dispose:n}}function lC(i,e,t){let n=new Ja,s=new dt,r=new dt,a=new Gt,o=new bh,c=new _h,l={},h=t.maxTextureSize,u={[gs]:Nn,[Nn]:gs,[$n]:$n},d=new bi({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new dt},radius:{value:4}},vertexShader:rC,fragmentShader:aC}),p=d.clone();p.defines.HORIZONTAL_PASS=1;let b=new pn;b.setAttribute("position",new Qt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let v=new vt(b,d),_=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=yc;let g=this.type;this.render=function(A,I,y){if(_.enabled===!1||_.autoUpdate===!1&&_.needsUpdate===!1||A.length===0)return;this.type===Gb&&(tt("WebGLShadowMap: PCFSoftShadowMap has been removed. Using PCFShadowMap instead."),this.type=yc);let C=i.getRenderTarget(),k=i.getActiveCubeFace(),z=i.getActiveMipmapLevel(),$=i.state;$.setBlending(bs),$.buffers.depth.getReversed()===!0?$.buffers.color.setClear(0,0,0,0):$.buffers.color.setClear(1,1,1,1),$.buffers.depth.setTest(!0),$.setScissorTest(!1);let K=g!==this.type;K&&I.traverse(function(P){P.material&&(Array.isArray(P.material)?P.material.forEach(N=>N.needsUpdate=!0):P.material.needsUpdate=!0)});for(let P=0,N=A.length;P<N;P++){let O=A[P],F=O.shadow;if(F===void 0){tt("WebGLShadowMap:",O,"has no shadow.");continue}if(F.autoUpdate===!1&&F.needsUpdate===!1)continue;s.copy(F.mapSize);let H=F.getFrameExtents();s.multiply(H),r.copy(F.mapSize),(s.x>h||s.y>h)&&(s.x>h&&(r.x=Math.floor(h/H.x),s.x=r.x*H.x,F.mapSize.x=r.x),s.y>h&&(r.y=Math.floor(h/H.y),s.y=r.y*H.y,F.mapSize.y=r.y));let V=i.state.buffers.depth.getReversed();if(F.camera._reversedDepth=V,F.map===null||K===!0){if(F.map!==null&&(F.map.depthTexture!==null&&(F.map.depthTexture.dispose(),F.map.depthTexture=null),F.map.dispose()),this.type===yr){if(O.isPointLight){tt("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}F.map=new Gn(s.x,s.y,{format:wr,type:Zn,minFilter:qt,magFilter:qt,generateMipmaps:!1}),F.map.texture.name=O.name+".shadowMap",F.map.depthTexture=new pr(s.x,s.y,qn),F.map.depthTexture.name=O.name+".shadowMapDepth",F.map.depthTexture.format=fs,F.map.depthTexture.compareFunction=null,F.map.depthTexture.minFilter=dn,F.map.depthTexture.magFilter=dn}else O.isPointLight?(F.map=new fo(s.x),F.map.depthTexture=new mh(s.x,Zi)):(F.map=new Gn(s.x,s.y),F.map.depthTexture=new pr(s.x,s.y,Zi)),F.map.depthTexture.name=O.name+".shadowMap",F.map.depthTexture.format=fs,this.type===yc?(F.map.depthTexture.compareFunction=V?yu:xu,F.map.depthTexture.minFilter=qt,F.map.depthTexture.magFilter=qt):(F.map.depthTexture.compareFunction=null,F.map.depthTexture.minFilter=dn,F.map.depthTexture.magFilter=dn);F.camera.updateProjectionMatrix()}F.map.isWebGLCubeRenderTarget!==!0&&(F.map.width!==s.x||F.map.height!==s.y)&&F.map.setSize(s.x,s.y);let Q=F.map.isWebGLCubeRenderTarget?6:F.getViewportCount();O.isPointLight!==!0&&F.updateMatrices(O,y);for(let te=0;te<Q;te++){let Se=F.getCamera(te);if(O.isPointLight){let ve=F.camera,nt=F.matrix,je=O.distance||ve.far;je!==ve.far&&(ve.far=je,ve.updateProjectionMatrix()),Nc.setFromMatrixPosition(O.matrixWorld),ve.position.copy(Nc),Dp.copy(ve.position),Dp.add(oC[te]),ve.up.copy(cC[te]),ve.lookAt(Dp),ve.updateMatrixWorld(),nt.makeTranslation(-Nc.x,-Nc.y,-Nc.z),Z_.multiplyMatrices(ve.projectionMatrix,ve.matrixWorldInverse),F._frustum.setFromProjectionMatrix(Z_,ve.coordinateSystem,ve.reversedDepth)}if(F.map.isWebGLCubeRenderTarget)i.setRenderTarget(F.map,te),i.clear();else{te===0&&(i.setRenderTarget(F.map),i.clear());let ve=F.getViewport(te);a.set(r.x*ve.x,r.y*ve.y,r.x*ve.z,r.y*ve.w),$.viewport(a)}n=F.getFrustum(te),S(I,y,Se,O,this.type)}F.isPointLightShadow!==!0&&this.type===yr&&E(F,y),F.needsUpdate=!1}g=this.type,_.needsUpdate=!1,i.setRenderTarget(C,k,z)};function E(A,I){let y=e.update(v);d.defines.VSM_SAMPLES!==A.blurSamples&&(d.defines.VSM_SAMPLES=A.blurSamples,p.defines.VSM_SAMPLES=A.blurSamples,d.needsUpdate=!0,p.needsUpdate=!0),A.mapPass===null?A.mapPass=new Gn(s.x,s.y,{format:wr,type:Zn}):(A.mapPass.width!==A.map.width||A.mapPass.height!==A.map.height)&&A.mapPass.setSize(A.map.width,A.map.height),d.uniforms.shadow_pass.value=A.map.depthTexture,d.uniforms.resolution.value.set(A.map.width,A.map.height),d.uniforms.radius.value=A.radius,i.setRenderTarget(A.mapPass),i.clear(),i.renderBufferDirect(I,null,y,d,v,null),p.uniforms.shadow_pass.value=A.mapPass.texture,p.uniforms.resolution.value.set(A.map.width,A.map.height),p.uniforms.radius.value=A.radius,i.setRenderTarget(A.map),i.clear(),i.renderBufferDirect(I,null,y,p,v,null)}function L(A,I,y,C){let k=null,z=y.isPointLight===!0?A.customDistanceMaterial:A.customDepthMaterial;if(z!==void 0)k=z;else if(k=y.isPointLight===!0?c:o,i.localClippingEnabled&&I.clipShadows===!0&&Array.isArray(I.clippingPlanes)&&I.clippingPlanes.length!==0||I.displacementMap&&I.displacementScale!==0||I.alphaMap&&I.alphaTest>0||I.map&&I.alphaTest>0||I.alphaToCoverage===!0){let $=k.uuid,K=I.uuid,P=l[$];P===void 0&&(P={},l[$]=P);let N=P[K];N===void 0&&(N=k.clone(),P[K]=N,I.addEventListener("dispose",M)),k=N}if(k.visible=I.visible,k.wireframe=I.wireframe,C===yr?k.side=I.shadowSide!==null?I.shadowSide:I.side:k.side=I.shadowSide!==null?I.shadowSide:u[I.side],k.alphaMap=I.alphaMap,k.alphaTest=I.alphaToCoverage===!0?.5:I.alphaTest,k.map=I.map,k.clipShadows=I.clipShadows,k.clippingPlanes=I.clippingPlanes,k.clipIntersection=I.clipIntersection,k.displacementMap=I.displacementMap,k.displacementScale=I.displacementScale,k.displacementBias=I.displacementBias,k.wireframeLinewidth=I.wireframeLinewidth,k.linewidth=I.linewidth,y.isPointLight===!0&&k.isMeshDistanceMaterial===!0){let $=i.properties.get(k);$.light=y}return k}function S(A,I,y,C,k){if(A.visible===!1)return;if(A.layers.test(I.layers)&&(A.isMesh||A.isLine||A.isPoints)&&(A.castShadow||A.receiveShadow&&k===yr)&&(!A.frustumCulled||A.intersectsFrustum(n))){A.modelViewMatrix.multiplyMatrices(y.matrixWorldInverse,A.matrixWorld);let K=e.update(A),P=A.material;if(Array.isArray(P)){let N=K.groups;for(let O=0,F=N.length;O<F;O++){let H=N[O],V=P[H.materialIndex];if(V&&V.visible){let Q=L(A,V,C,k);A.onBeforeShadow(i,A,I,y,K,Q,H),i.renderBufferDirect(y,null,K,Q,A,H),A.onAfterShadow(i,A,I,y,K,Q,H)}}}else if(P.visible){let N=L(A,P,C,k);A.onBeforeShadow(i,A,I,y,K,N,null),i.renderBufferDirect(y,null,K,N,A,null),A.onAfterShadow(i,A,I,y,K,N,null)}}let $=A.children;for(let K=0,P=$.length;K<P;K++)S($[K],I,y,C,k)}function M(A){A.target.removeEventListener("dispose",M);for(let y in l){let C=l[y],k=A.target.uuid;k in C&&(C[k].dispose(),delete C[k])}}}function hC(i,e){function t(){let G=!1,Ie=new Gt,be=null,Re=new Gt(0,0,0,0);return{setMask:function(Be){be!==Be&&!G&&(i.colorMask(Be,Be,Be,Be),be=Be)},setLocked:function(Be){G=Be},setClear:function(Be,ye,et,Ye,Ut){Ut===!0&&(Be*=Ye,ye*=Ye,et*=Ye),Ie.set(Be,ye,et,Ye),Re.equals(Ie)===!1&&(i.clearColor(Be,ye,et,Ye),Re.copy(Ie))},reset:function(){G=!1,be=null,Re.set(-1,0,0,0)}}}function n(){let G=!1,Ie=!1,be=null,Re=null,Be=null;return{setReversed:function(ye){if(Ie!==ye){let et=e.get("EXT_clip_control");ye?et.clipControlEXT(et.LOWER_LEFT_EXT,et.ZERO_TO_ONE_EXT):et.clipControlEXT(et.LOWER_LEFT_EXT,et.NEGATIVE_ONE_TO_ONE_EXT),Ie=ye;let Ye=Be;Be=null,this.setClear(Ye)}},getReversed:function(){return Ie},setTest:function(ye){ye?ge(i.DEPTH_TEST):Ve(i.DEPTH_TEST)},setMask:function(ye){be!==ye&&!G&&(i.depthMask(ye),be=ye)},setFunc:function(ye){if(Ie&&(ye=E_[ye]),Re!==ye){switch(ye){case ih:i.depthFunc(i.NEVER);break;case sh:i.depthFunc(i.ALWAYS);break;case rh:i.depthFunc(i.LESS);break;case Va:i.depthFunc(i.LEQUAL);break;case ah:i.depthFunc(i.EQUAL);break;case oh:i.depthFunc(i.GEQUAL);break;case ch:i.depthFunc(i.GREATER);break;case lh:i.depthFunc(i.NOTEQUAL);break;default:i.depthFunc(i.LEQUAL)}Re=ye}},setLocked:function(ye){G=ye},setClear:function(ye){Be!==ye&&(Be=ye,Ie&&(ye=1-ye),i.clearDepth(ye))},reset:function(){G=!1,be=null,Re=null,Be=null,Ie=!1}}}function s(){let G=!1,Ie=null,be=null,Re=null,Be=null,ye=null,et=null,Ye=null,Ut=null;return{setTest:function(Pt){G||(Pt?ge(i.STENCIL_TEST):Ve(i.STENCIL_TEST))},setMask:function(Pt){Ie!==Pt&&!G&&(i.stencilMask(Pt),Ie=Pt)},setFunc:function(Pt,zn,Ai){(be!==Pt||Re!==zn||Be!==Ai)&&(i.stencilFunc(Pt,zn,Ai),be=Pt,Re=zn,Be=Ai)},setOp:function(Pt,zn,Ai){(ye!==Pt||et!==zn||Ye!==Ai)&&(i.stencilOp(Pt,zn,Ai),ye=Pt,et=zn,Ye=Ai)},setLocked:function(Pt){G=Pt},setClear:function(Pt){Ut!==Pt&&(i.clearStencil(Pt),Ut=Pt)},reset:function(){G=!1,Ie=null,be=null,Re=null,Be=null,ye=null,et=null,Ye=null,Ut=null}}}let r=new t,a=new n,o=new s,c=new WeakMap,l=new WeakMap,h={},u={},d={},p=new WeakMap,b=[],v=null,_=!1,g=null,E=null,L=null,S=null,M=null,A=null,I=null,y=new He(0,0,0),C=0,k=!1,z=null,$=null,K=null,P=null,N=null,O=i.getParameter(i.MAX_COMBINED_TEXTURE_IMAGE_UNITS),F=!1,H=0,V=i.getParameter(i.VERSION);V.indexOf("WebGL")!==-1?(H=parseFloat(/^WebGL (\d)/.exec(V)[1]),F=H>=1):V.indexOf("OpenGL ES")!==-1&&(H=parseFloat(/^OpenGL ES (\d)/.exec(V)[1]),F=H>=2);let Q=null,te={},Se=i.getParameter(i.SCISSOR_BOX),ve=i.getParameter(i.VIEWPORT),nt=new Gt().fromArray(Se),je=new Gt().fromArray(ve);function Qe(G,Ie,be,Re){let Be=new Uint8Array(4),ye=i.createTexture();i.bindTexture(G,ye),i.texParameteri(G,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(G,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let et=0;et<be;et++)G===i.TEXTURE_3D||G===i.TEXTURE_2D_ARRAY?i.texImage3D(Ie,0,i.RGBA,1,1,Re,0,i.RGBA,i.UNSIGNED_BYTE,Be):i.texImage2D(Ie+et,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,Be);return ye}let fe={};fe[i.TEXTURE_2D]=Qe(i.TEXTURE_2D,i.TEXTURE_2D,1),fe[i.TEXTURE_CUBE_MAP]=Qe(i.TEXTURE_CUBE_MAP,i.TEXTURE_CUBE_MAP_POSITIVE_X,6),fe[i.TEXTURE_2D_ARRAY]=Qe(i.TEXTURE_2D_ARRAY,i.TEXTURE_2D_ARRAY,1,1),fe[i.TEXTURE_3D]=Qe(i.TEXTURE_3D,i.TEXTURE_3D,1,1),r.setClear(0,0,0,1),a.setClear(1),o.setClear(0),ge(i.DEPTH_TEST),a.setFunc(Va),ft(!1),xt(Xd),ge(i.CULL_FACE),mt(bs);function ge(G){h[G]!==!0&&(i.enable(G),h[G]=!0)}function Ve(G){h[G]!==!1&&(i.disable(G),h[G]=!1)}function it(G,Ie){return d[G]!==Ie?(i.bindFramebuffer(G,Ie),d[G]=Ie,G===i.DRAW_FRAMEBUFFER&&(d[i.FRAMEBUFFER]=Ie),G===i.FRAMEBUFFER&&(d[i.DRAW_FRAMEBUFFER]=Ie),!0):!1}function Ue(G,Ie){let be=b,Re=!1;if(G){be=p.get(Ie),be===void 0&&(be=[],p.set(Ie,be));let Be=G.textures;if(be.length!==Be.length||be[0]!==i.COLOR_ATTACHMENT0){for(let ye=0,et=Be.length;ye<et;ye++)be[ye]=i.COLOR_ATTACHMENT0+ye;be.length=Be.length,Re=!0}}else be[0]!==i.BACK&&(be[0]=i.BACK,Re=!0);Re&&i.drawBuffers(be)}function ct(G){return v!==G?(i.useProgram(G),v=G,!0):!1}let zt={[ta]:i.FUNC_ADD,[$b]:i.FUNC_SUBTRACT,[qb]:i.FUNC_REVERSE_SUBTRACT};zt[jb]=i.MIN,zt[Xb]=i.MAX;let ot={[Kb]:i.ZERO,[Yb]:i.ONE,[Jb]:i.SRC_COLOR,[Zd]:i.SRC_ALPHA,[i_]:i.SRC_ALPHA_SATURATE,[t_]:i.DST_COLOR,[Qb]:i.DST_ALPHA,[Zb]:i.ONE_MINUS_SRC_COLOR,[Qd]:i.ONE_MINUS_SRC_ALPHA,[n_]:i.ONE_MINUS_DST_COLOR,[e_]:i.ONE_MINUS_DST_ALPHA,[s_]:i.CONSTANT_COLOR,[r_]:i.ONE_MINUS_CONSTANT_COLOR,[a_]:i.CONSTANT_ALPHA,[o_]:i.ONE_MINUS_CONSTANT_ALPHA};function mt(G,Ie,be,Re,Be,ye,et,Ye,Ut,Pt){if(G===bs){_===!0&&(Ve(i.BLEND),_=!1);return}if(_===!1&&(ge(i.BLEND),_=!0),G!==Wb){if(G!==g||Pt!==k){if((E!==ta||M!==ta)&&(i.blendEquation(i.FUNC_ADD),E=ta,M=ta),Pt)switch(G){case no:i.blendFuncSeparate(i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case Kd:i.blendFunc(i.ONE,i.ONE);break;case Yd:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case Jd:i.blendFuncSeparate(i.DST_COLOR,i.ONE_MINUS_SRC_ALPHA,i.ZERO,i.ONE);break;default:st("WebGLState: Invalid blending: ",G);break}else switch(G){case no:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case Kd:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE,i.ONE,i.ONE);break;case Yd:st("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case Jd:st("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:st("WebGLState: Invalid blending: ",G);break}L=null,S=null,A=null,I=null,y.set(0,0,0),C=0,g=G,k=Pt}return}Be=Be||Ie,ye=ye||be,et=et||Re,(Ie!==E||Be!==M)&&(i.blendEquationSeparate(zt[Ie],zt[Be]),E=Ie,M=Be),(be!==L||Re!==S||ye!==A||et!==I)&&(i.blendFuncSeparate(ot[be],ot[Re],ot[ye],ot[et]),L=be,S=Re,A=ye,I=et),(Ye.equals(y)===!1||Ut!==C)&&(i.blendColor(Ye.r,Ye.g,Ye.b,Ut),y.copy(Ye),C=Ut),g=G,k=!1}function Lt(G,Ie){G.side===$n?Ve(i.CULL_FACE):ge(i.CULL_FACE);let be=G.side===Nn;Ie&&(be=!be),ft(be),G.blending===no&&G.transparent===!1?mt(bs):mt(G.blending,G.blendEquation,G.blendSrc,G.blendDst,G.blendEquationAlpha,G.blendSrcAlpha,G.blendDstAlpha,G.blendColor,G.blendAlpha,G.premultipliedAlpha),a.setFunc(G.depthFunc),a.setTest(G.depthTest),a.setMask(G.depthWrite),r.setMask(G.colorWrite);let Re=G.stencilWrite;o.setTest(Re),Re&&(o.setMask(G.stencilWriteMask),o.setFunc(G.stencilFunc,G.stencilRef,G.stencilFuncMask),o.setOp(G.stencilFail,G.stencilZFail,G.stencilZPass)),_n(G.polygonOffset,G.polygonOffsetFactor,G.polygonOffsetUnits),G.alphaToCoverage===!0?ge(i.SAMPLE_ALPHA_TO_COVERAGE):Ve(i.SAMPLE_ALPHA_TO_COVERAGE)}function ft(G){z!==G&&(G?i.frontFace(i.CW):i.frontFace(i.CCW),z=G)}function xt(G){G!==Hb?(ge(i.CULL_FACE),G!==$&&(G===Xd?i.cullFace(i.BACK):G===Vb?i.cullFace(i.FRONT):i.cullFace(i.FRONT_AND_BACK))):Ve(i.CULL_FACE),$=G}function Wt(G){G!==K&&(F&&i.lineWidth(G),K=G)}function _n(G,Ie,be){G?(ge(i.POLYGON_OFFSET_FILL),(P!==Ie||N!==be)&&(P=Ie,N=be,a.getReversed()&&(Ie=-Ie),i.polygonOffset(Ie,be))):Ve(i.POLYGON_OFFSET_FILL)}function Ht(G){G?ge(i.SCISSOR_TEST):Ve(i.SCISSOR_TEST)}function Kt(G){G===void 0&&(G=i.TEXTURE0+O-1),Q!==G&&(i.activeTexture(G),Q=G)}function q(G,Ie,be){be===void 0&&(Q===null?be=i.TEXTURE0+O-1:be=Q);let Re=te[be];Re===void 0&&(Re={type:void 0,texture:void 0},te[be]=Re),(Re.type!==G||Re.texture!==Ie)&&(Q!==be&&(i.activeTexture(be),Q=be),i.bindTexture(G,Ie||fe[G]),Re.type=G,Re.texture=Ie)}function hn(){let G=te[Q];G!==void 0&&G.type!==void 0&&(i.bindTexture(G.type,null),G.type=void 0,G.texture=void 0)}function Et(){try{i.compressedTexImage2D(...arguments)}catch(G){st("WebGLState:",G)}}function U(){try{i.compressedTexImage3D(...arguments)}catch(G){st("WebGLState:",G)}}function w(){try{i.texSubImage2D(...arguments)}catch(G){st("WebGLState:",G)}}function ee(){try{i.texSubImage3D(...arguments)}catch(G){st("WebGLState:",G)}}function re(){try{i.compressedTexSubImage2D(...arguments)}catch(G){st("WebGLState:",G)}}function ce(){try{i.compressedTexSubImage3D(...arguments)}catch(G){st("WebGLState:",G)}}function Ee(){try{i.texStorage2D(...arguments)}catch(G){st("WebGLState:",G)}}function Ce(){try{i.texStorage3D(...arguments)}catch(G){st("WebGLState:",G)}}function de(){try{i.texImage2D(...arguments)}catch(G){st("WebGLState:",G)}}function xe(){try{i.texImage3D(...arguments)}catch(G){st("WebGLState:",G)}}function Pe(G){return u[G]!==void 0?u[G]:i.getParameter(G)}function qe(G,Ie){u[G]!==Ie&&(i.pixelStorei(G,Ie),u[G]=Ie)}function Ae(G){nt.equals(G)===!1&&(i.scissor(G.x,G.y,G.z,G.w),nt.copy(G))}function Le(G){je.equals(G)===!1&&(i.viewport(G.x,G.y,G.z,G.w),je.copy(G))}function Fe(G,Ie){let be=l.get(Ie);be===void 0&&(be=new WeakMap,l.set(Ie,be));let Re=be.get(G);Re===void 0&&(Re=i.getUniformBlockIndex(Ie,G.name),be.set(G,Re))}function Je(G,Ie){let Re=l.get(Ie).get(G);c.get(Ie)!==Re&&(i.uniformBlockBinding(Ie,Re,G.__bindingPointIndex),c.set(Ie,Re))}function at(){i.disable(i.BLEND),i.disable(i.CULL_FACE),i.disable(i.DEPTH_TEST),i.disable(i.POLYGON_OFFSET_FILL),i.disable(i.SCISSOR_TEST),i.disable(i.STENCIL_TEST),i.disable(i.SAMPLE_ALPHA_TO_COVERAGE),i.blendEquation(i.FUNC_ADD),i.blendFunc(i.ONE,i.ZERO),i.blendFuncSeparate(i.ONE,i.ZERO,i.ONE,i.ZERO),i.blendColor(0,0,0,0),i.colorMask(!0,!0,!0,!0),i.clearColor(0,0,0,0),i.depthMask(!0),i.depthFunc(i.LESS),a.setReversed(!1),i.clearDepth(1),i.stencilMask(4294967295),i.stencilFunc(i.ALWAYS,0,4294967295),i.stencilOp(i.KEEP,i.KEEP,i.KEEP),i.clearStencil(0),i.cullFace(i.BACK),i.frontFace(i.CCW),i.polygonOffset(0,0),i.activeTexture(i.TEXTURE0),i.bindFramebuffer(i.FRAMEBUFFER,null),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),i.bindFramebuffer(i.READ_FRAMEBUFFER,null),i.useProgram(null),i.lineWidth(1),i.scissor(0,0,i.canvas.width,i.canvas.height),i.viewport(0,0,i.canvas.width,i.canvas.height),i.pixelStorei(i.PACK_ALIGNMENT,4),i.pixelStorei(i.UNPACK_ALIGNMENT,4),i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,!1),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,i.BROWSER_DEFAULT_WEBGL),i.pixelStorei(i.PACK_ROW_LENGTH,0),i.pixelStorei(i.PACK_SKIP_PIXELS,0),i.pixelStorei(i.PACK_SKIP_ROWS,0),i.pixelStorei(i.UNPACK_ROW_LENGTH,0),i.pixelStorei(i.UNPACK_IMAGE_HEIGHT,0),i.pixelStorei(i.UNPACK_SKIP_PIXELS,0),i.pixelStorei(i.UNPACK_SKIP_ROWS,0),i.pixelStorei(i.UNPACK_SKIP_IMAGES,0),h={},u={},Q=null,te={},d={},p=new WeakMap,b=[],v=null,_=!1,g=null,E=null,L=null,S=null,M=null,A=null,I=null,y=new He(0,0,0),C=0,k=!1,z=null,$=null,K=null,P=null,N=null,nt.set(0,0,i.canvas.width,i.canvas.height),je.set(0,0,i.canvas.width,i.canvas.height),r.reset(),a.reset(),o.reset()}return{buffers:{color:r,depth:a,stencil:o},enable:ge,disable:Ve,bindFramebuffer:it,drawBuffers:Ue,useProgram:ct,setBlending:mt,setMaterial:Lt,setFlipSided:ft,setCullFace:xt,setLineWidth:Wt,setPolygonOffset:_n,setScissorTest:Ht,activeTexture:Kt,bindTexture:q,unbindTexture:hn,compressedTexImage2D:Et,compressedTexImage3D:U,texImage2D:de,texImage3D:xe,pixelStorei:qe,getParameter:Pe,updateUBOMapping:Fe,uniformBlockBinding:Je,texStorage2D:Ee,texStorage3D:Ce,texSubImage2D:w,texSubImage3D:ee,compressedTexSubImage2D:re,compressedTexSubImage3D:ce,scissor:Ae,viewport:Le,reset:at}}function uC(i,e,t,n,s,r,a){let o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new dt,h=new WeakMap,u=new Set,d,p=new WeakMap,b=!1;try{b=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function v(U,w){return b?new OffscreenCanvas(U,w):$a("canvas")}function _(U,w,ee){let re=1,ce=Et(U);if((ce.width>ee||ce.height>ee)&&(re=ee/Math.max(ce.width,ce.height)),re<1)if(typeof HTMLImageElement<"u"&&U instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&U instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&U instanceof ImageBitmap||typeof VideoFrame<"u"&&U instanceof VideoFrame){let Ee=Math.floor(re*ce.width),Ce=Math.floor(re*ce.height);d===void 0&&(d=v(Ee,Ce));let de=w?v(Ee,Ce):d;return de.width=Ee,de.height=Ce,de.getContext("2d").drawImage(U,0,0,Ee,Ce),tt("WebGLRenderer: Texture has been resized from ("+ce.width+"x"+ce.height+") to ("+Ee+"x"+Ce+")."),de}else return"data"in U&&tt("WebGLRenderer: Image in DataTexture is too big ("+ce.width+"x"+ce.height+")."),U;return U}function g(U){return U.generateMipmaps}function E(U){i.generateMipmap(U)}function L(U){return U.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:U.isWebGL3DRenderTarget?i.TEXTURE_3D:U.isWebGLArrayRenderTarget||U.isCompressedArrayTexture?i.TEXTURE_2D_ARRAY:i.TEXTURE_2D}function S(U,w,ee,re,ce,Ee=!1){if(U!==null){if(i[U]!==void 0)return i[U];tt("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+U+"'")}let Ce;re&&(Ce=e.get("EXT_texture_norm16"),Ce||tt("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let de=w;if(w===i.RED&&(ee===i.FLOAT&&(de=i.R32F),ee===i.HALF_FLOAT&&(de=i.R16F),ee===i.UNSIGNED_BYTE&&(de=i.R8),ee===i.UNSIGNED_SHORT&&Ce&&(de=Ce.R16_EXT),ee===i.SHORT&&Ce&&(de=Ce.R16_SNORM_EXT)),w===i.RED_INTEGER&&(ee===i.UNSIGNED_BYTE&&(de=i.R8UI),ee===i.UNSIGNED_SHORT&&(de=i.R16UI),ee===i.UNSIGNED_INT&&(de=i.R32UI),ee===i.BYTE&&(de=i.R8I),ee===i.SHORT&&(de=i.R16I),ee===i.INT&&(de=i.R32I)),w===i.RG&&(ee===i.FLOAT&&(de=i.RG32F),ee===i.HALF_FLOAT&&(de=i.RG16F),ee===i.UNSIGNED_BYTE&&(de=i.RG8),ee===i.UNSIGNED_SHORT&&Ce&&(de=Ce.RG16_EXT),ee===i.SHORT&&Ce&&(de=Ce.RG16_SNORM_EXT)),w===i.RG_INTEGER&&(ee===i.UNSIGNED_BYTE&&(de=i.RG8UI),ee===i.UNSIGNED_SHORT&&(de=i.RG16UI),ee===i.UNSIGNED_INT&&(de=i.RG32UI),ee===i.BYTE&&(de=i.RG8I),ee===i.SHORT&&(de=i.RG16I),ee===i.INT&&(de=i.RG32I)),w===i.RGB_INTEGER&&(ee===i.UNSIGNED_BYTE&&(de=i.RGB8UI),ee===i.UNSIGNED_SHORT&&(de=i.RGB16UI),ee===i.UNSIGNED_INT&&(de=i.RGB32UI),ee===i.BYTE&&(de=i.RGB8I),ee===i.SHORT&&(de=i.RGB16I),ee===i.INT&&(de=i.RGB32I)),w===i.RGBA_INTEGER&&(ee===i.UNSIGNED_BYTE&&(de=i.RGBA8UI),ee===i.UNSIGNED_SHORT&&(de=i.RGBA16UI),ee===i.UNSIGNED_INT&&(de=i.RGBA32UI),ee===i.BYTE&&(de=i.RGBA8I),ee===i.SHORT&&(de=i.RGBA16I),ee===i.INT&&(de=i.RGBA32I)),w===i.RGB&&(ee===i.UNSIGNED_SHORT&&Ce&&(de=Ce.RGB16_EXT),ee===i.SHORT&&Ce&&(de=Ce.RGB16_SNORM_EXT),ee===i.UNSIGNED_INT_5_9_9_9_REV&&(de=i.RGB9_E5),ee===i.UNSIGNED_INT_10F_11F_11F_REV&&(de=i.R11F_G11F_B10F)),w===i.RGBA){let xe=Ee?jo:gt.getTransfer(ce);ee===i.FLOAT&&(de=i.RGBA32F),ee===i.HALF_FLOAT&&(de=i.RGBA16F),ee===i.UNSIGNED_BYTE&&(de=xe===Bt?i.SRGB8_ALPHA8:i.RGBA8),ee===i.UNSIGNED_SHORT&&Ce&&(de=Ce.RGBA16_EXT),ee===i.SHORT&&Ce&&(de=Ce.RGBA16_SNORM_EXT),ee===i.UNSIGNED_SHORT_4_4_4_4&&(de=i.RGBA4),ee===i.UNSIGNED_SHORT_5_5_5_1&&(de=i.RGB5_A1)}return(de===i.R16F||de===i.R32F||de===i.RG16F||de===i.RG32F||de===i.RGBA16F||de===i.RGBA32F)&&e.get("EXT_color_buffer_float"),de}function M(U,w){let ee;return U?w===null||w===Zi||w===ro?ee=i.DEPTH24_STENCIL8:w===qn?ee=i.DEPTH32F_STENCIL8:w===so&&(ee=i.DEPTH24_STENCIL8,tt("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):w===null||w===Zi||w===ro?ee=i.DEPTH_COMPONENT24:w===qn?ee=i.DEPTH_COMPONENT32F:w===so&&(ee=i.DEPTH_COMPONENT16),ee}function A(U,w){return g(U)===!0||U.isFramebufferTexture&&U.minFilter!==dn&&U.minFilter!==qt?Math.log2(Math.max(w.width,w.height))+1:U.mipmaps!==void 0&&U.mipmaps.length>0?U.mipmaps.length:U.isCompressedTexture&&Array.isArray(U.image)?w.mipmaps.length:1}function I(U){let w=U.target;w.removeEventListener("dispose",I),C(w),w.isVideoTexture&&h.delete(w),w.isHTMLTexture&&u.delete(w)}function y(U){let w=U.target;w.removeEventListener("dispose",y),z(w)}function C(U){let w=n.get(U);if(w.__webglInit===void 0)return;let ee=U.source,re=p.get(ee);if(re){let ce=re[w.__cacheKey];ce.usedTimes--,ce.usedTimes===0&&k(U),Object.keys(re).length===0&&p.delete(ee)}n.remove(U)}function k(U){let w=n.get(U);i.deleteTexture(w.__webglTexture);let ee=U.source,re=p.get(ee);delete re[w.__cacheKey],a.memory.textures--}function z(U){let w=n.get(U);if(U.depthTexture&&(U.depthTexture.dispose(),n.remove(U.depthTexture)),U.isWebGLCubeRenderTarget)for(let re=0;re<6;re++){if(Array.isArray(w.__webglFramebuffer[re]))for(let ce=0;ce<w.__webglFramebuffer[re].length;ce++)i.deleteFramebuffer(w.__webglFramebuffer[re][ce]);else i.deleteFramebuffer(w.__webglFramebuffer[re]);w.__webglDepthbuffer&&i.deleteRenderbuffer(w.__webglDepthbuffer[re])}else{if(Array.isArray(w.__webglFramebuffer))for(let re=0;re<w.__webglFramebuffer.length;re++)i.deleteFramebuffer(w.__webglFramebuffer[re]);else i.deleteFramebuffer(w.__webglFramebuffer);if(w.__webglDepthbuffer&&i.deleteRenderbuffer(w.__webglDepthbuffer),w.__webglMultisampledFramebuffer&&i.deleteFramebuffer(w.__webglMultisampledFramebuffer),w.__webglColorRenderbuffer)for(let re=0;re<w.__webglColorRenderbuffer.length;re++)w.__webglColorRenderbuffer[re]&&i.deleteRenderbuffer(w.__webglColorRenderbuffer[re]);w.__webglDepthRenderbuffer&&i.deleteRenderbuffer(w.__webglDepthRenderbuffer)}let ee=U.textures;for(let re=0,ce=ee.length;re<ce;re++){let Ee=n.get(ee[re]);Ee.__webglTexture&&(i.deleteTexture(Ee.__webglTexture),a.memory.textures--),n.remove(ee[re])}n.remove(U)}let $=0;function K(){$=0}function P(){return $}function N(U){$=U}function O(){let U=$;return U>=s.maxTextures&&tt("WebGLTextures: Trying to use "+(U+1)+" texture units while this GPU supports only "+s.maxTextures),$+=1,U}function F(U){let w=[];return w.push(U.wrapS),w.push(U.wrapT),w.push(U.wrapR||0),w.push(U.magFilter),w.push(U.minFilter),w.push(U.anisotropy),w.push(U.internalFormat),w.push(U.format),w.push(U.type),w.push(U.generateMipmaps),w.push(U.premultiplyAlpha),w.push(U.flipY),w.push(U.unpackAlignment),w.push(U.colorSpace),w.join()}function H(U,w){let ee=n.get(U);if(U.isVideoTexture&&q(U),U.isRenderTargetTexture===!1&&U.isExternalTexture!==!0&&U.version>0&&ee.__version!==U.version){let re=U.image;if(re===null)tt("WebGLRenderer: Texture marked for update but no image data found.");else if(re.complete===!1)tt("WebGLRenderer: Texture marked for update but image is incomplete");else{Ve(ee,U,w);return}}else U.isExternalTexture&&(ee.__webglTexture=U.sourceTexture?U.sourceTexture:null);t.bindTexture(i.TEXTURE_2D,ee.__webglTexture,i.TEXTURE0+w)}function V(U,w){let ee=n.get(U);if(U.isRenderTargetTexture===!1&&U.version>0&&ee.__version!==U.version){Ve(ee,U,w);return}else U.isExternalTexture&&(ee.__webglTexture=U.sourceTexture?U.sourceTexture:null);t.bindTexture(i.TEXTURE_2D_ARRAY,ee.__webglTexture,i.TEXTURE0+w)}function Q(U,w){let ee=n.get(U);if(U.isRenderTargetTexture===!1&&U.version>0&&ee.__version!==U.version){Ve(ee,U,w);return}t.bindTexture(i.TEXTURE_3D,ee.__webglTexture,i.TEXTURE0+w)}function te(U,w){let ee=n.get(U);if(U.isCubeDepthTexture!==!0&&U.version>0&&ee.__version!==U.version){it(ee,U,w);return}t.bindTexture(i.TEXTURE_CUBE_MAP,ee.__webglTexture,i.TEXTURE0+w)}let Se={[or]:i.REPEAT,[ii]:i.CLAMP_TO_EDGE,[Ga]:i.MIRRORED_REPEAT},ve={[dn]:i.NEAREST,[Nh]:i.NEAREST_MIPMAP_NEAREST,[ia]:i.NEAREST_MIPMAP_LINEAR,[qt]:i.LINEAR,[io]:i.LINEAR_MIPMAP_NEAREST,[Di]:i.LINEAR_MIPMAP_LINEAR},nt={[m_]:i.NEVER,[y_]:i.ALWAYS,[g_]:i.LESS,[xu]:i.LEQUAL,[b_]:i.EQUAL,[yu]:i.GEQUAL,[__]:i.GREATER,[x_]:i.NOTEQUAL};function je(U,w){if(w.type===qn&&e.has("OES_texture_float_linear")===!1&&(w.magFilter===qt||w.magFilter===io||w.magFilter===ia||w.magFilter===Di||w.minFilter===qt||w.minFilter===io||w.minFilter===ia||w.minFilter===Di)&&tt("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(U,i.TEXTURE_WRAP_S,Se[w.wrapS]),i.texParameteri(U,i.TEXTURE_WRAP_T,Se[w.wrapT]),(U===i.TEXTURE_3D||U===i.TEXTURE_2D_ARRAY)&&i.texParameteri(U,i.TEXTURE_WRAP_R,Se[w.wrapR]),i.texParameteri(U,i.TEXTURE_MAG_FILTER,ve[w.magFilter]),i.texParameteri(U,i.TEXTURE_MIN_FILTER,ve[w.minFilter]),w.compareFunction&&(i.texParameteri(U,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(U,i.TEXTURE_COMPARE_FUNC,nt[w.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(w.magFilter===dn||w.minFilter!==ia&&w.minFilter!==Di||w.type===qn&&e.has("OES_texture_float_linear")===!1)return;if(w.anisotropy>1||n.get(w).__currentAnisotropy){let ee=e.get("EXT_texture_filter_anisotropic");i.texParameterf(U,ee.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(w.anisotropy,s.getMaxAnisotropy())),n.get(w).__currentAnisotropy=w.anisotropy}}}function Qe(U,w){let ee=!1;U.__webglInit===void 0&&(U.__webglInit=!0,w.addEventListener("dispose",I));let re=w.source,ce=p.get(re);ce===void 0&&(ce={},p.set(re,ce));let Ee=F(w);if(Ee!==U.__cacheKey){ce[Ee]===void 0&&(ce[Ee]={texture:i.createTexture(),usedTimes:0},a.memory.textures++,ee=!0),ce[Ee].usedTimes++;let Ce=ce[U.__cacheKey];Ce!==void 0&&(ce[U.__cacheKey].usedTimes--,Ce.usedTimes===0&&k(w)),U.__cacheKey=Ee,U.__webglTexture=ce[Ee].texture}return ee}function fe(U,w,ee){return Math.floor(Math.floor(U/ee)/w)}function ge(U,w,ee,re){let Ee=U.updateRanges;if(Ee.length===0)t.texSubImage2D(i.TEXTURE_2D,0,0,0,w.width,w.height,ee,re,w.data);else{Ee.sort((qe,Ae)=>qe.start-Ae.start);let Ce=0;for(let qe=1;qe<Ee.length;qe++){let Ae=Ee[Ce],Le=Ee[qe],Fe=Ae.start+Ae.count,Je=fe(Le.start,w.width,4),at=fe(Ae.start,w.width,4);Le.start<=Fe+1&&Je===at&&fe(Le.start+Le.count-1,w.width,4)===Je?Ae.count=Math.max(Ae.count,Le.start+Le.count-Ae.start):(++Ce,Ee[Ce]=Le)}Ee.length=Ce+1;let de=t.getParameter(i.UNPACK_ROW_LENGTH),xe=t.getParameter(i.UNPACK_SKIP_PIXELS),Pe=t.getParameter(i.UNPACK_SKIP_ROWS);t.pixelStorei(i.UNPACK_ROW_LENGTH,w.width);for(let qe=0,Ae=Ee.length;qe<Ae;qe++){let Le=Ee[qe],Fe=Math.floor(Le.start/4),Je=Math.ceil(Le.count/4),at=Fe%w.width,G=Math.floor(Fe/w.width),Ie=Je,be=1;t.pixelStorei(i.UNPACK_SKIP_PIXELS,at),t.pixelStorei(i.UNPACK_SKIP_ROWS,G),t.texSubImage2D(i.TEXTURE_2D,0,at,G,Ie,be,ee,re,w.data)}U.clearUpdateRanges(),t.pixelStorei(i.UNPACK_ROW_LENGTH,de),t.pixelStorei(i.UNPACK_SKIP_PIXELS,xe),t.pixelStorei(i.UNPACK_SKIP_ROWS,Pe)}}function Ve(U,w,ee){let re=i.TEXTURE_2D;(w.isDataArrayTexture||w.isCompressedArrayTexture)&&(re=i.TEXTURE_2D_ARRAY),w.isData3DTexture&&(re=i.TEXTURE_3D);let ce=Qe(U,w),Ee=w.source;t.bindTexture(re,U.__webglTexture,i.TEXTURE0+ee);let Ce=n.get(Ee);if(Ee.version!==Ce.__version||ce===!0){if(t.activeTexture(i.TEXTURE0+ee),(typeof ImageBitmap<"u"&&w.image instanceof ImageBitmap)===!1){let be=gt.getPrimaries(gt.workingColorSpace),Re=w.colorSpace===Qi?null:gt.getPrimaries(w.colorSpace),Be=w.colorSpace===Qi||be===Re?i.NONE:i.BROWSER_DEFAULT_WEBGL;t.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,w.flipY),t.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,w.premultiplyAlpha),t.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,Be)}t.pixelStorei(i.UNPACK_ALIGNMENT,w.unpackAlignment);let xe=_(w.image,!1,s.maxTextureSize);xe=hn(w,xe);let Pe=r.convert(w.format,w.colorSpace),qe=r.convert(w.type),Ae=S(w.internalFormat,Pe,qe,w.normalized,w.colorSpace,w.isVideoTexture);je(re,w);let Le,Fe=w.mipmaps,Je=w.isVideoTexture!==!0,at=Ce.__version===void 0||ce===!0,G=Ee.dataReady,Ie=A(w,xe);if(w.isDepthTexture)Ae=M(w.format===Sr,w.type),at&&(Je?t.texStorage2D(i.TEXTURE_2D,1,Ae,xe.width,xe.height):t.texImage2D(i.TEXTURE_2D,0,Ae,xe.width,xe.height,0,Pe,qe,null));else if(w.isDataTexture)if(Fe.length>0){Je&&at&&t.texStorage2D(i.TEXTURE_2D,Ie,Ae,Fe[0].width,Fe[0].height);for(let be=0,Re=Fe.length;be<Re;be++)Le=Fe[be],Je?G&&t.texSubImage2D(i.TEXTURE_2D,be,0,0,Le.width,Le.height,Pe,qe,Le.data):t.texImage2D(i.TEXTURE_2D,be,Ae,Le.width,Le.height,0,Pe,qe,Le.data);w.generateMipmaps=!1}else Je?(at&&t.texStorage2D(i.TEXTURE_2D,Ie,Ae,xe.width,xe.height),G&&ge(w,xe,Pe,qe)):t.texImage2D(i.TEXTURE_2D,0,Ae,xe.width,xe.height,0,Pe,qe,xe.data);else if(w.isCompressedTexture)if(w.isCompressedArrayTexture){Je&&at&&t.texStorage3D(i.TEXTURE_2D_ARRAY,Ie,Ae,Fe[0].width,Fe[0].height,xe.depth);for(let be=0,Re=Fe.length;be<Re;be++)if(Le=Fe[be],w.format!==yi)if(Pe!==null)if(Je){if(G)if(w.layerUpdates.size>0){let Be=vp(Le.width,Le.height,w.format,w.type);for(let ye of w.layerUpdates){let et=Le.data.subarray(ye*Be/Le.data.BYTES_PER_ELEMENT,(ye+1)*Be/Le.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,be,0,0,ye,Le.width,Le.height,1,Pe,et)}}else t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,be,0,0,0,Le.width,Le.height,xe.depth,Pe,Le.data)}else t.compressedTexImage3D(i.TEXTURE_2D_ARRAY,be,Ae,Le.width,Le.height,xe.depth,0,Le.data,0,0);else tt("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Je?G&&t.texSubImage3D(i.TEXTURE_2D_ARRAY,be,0,0,0,Le.width,Le.height,xe.depth,Pe,qe,Le.data):t.texImage3D(i.TEXTURE_2D_ARRAY,be,Ae,Le.width,Le.height,xe.depth,0,Pe,qe,Le.data);w.layerUpdates.size>0&&w.clearLayerUpdates()}else{Je&&at&&t.texStorage2D(i.TEXTURE_2D,Ie,Ae,Fe[0].width,Fe[0].height);for(let be=0,Re=Fe.length;be<Re;be++)Le=Fe[be],w.format!==yi?Pe!==null?Je?G&&t.compressedTexSubImage2D(i.TEXTURE_2D,be,0,0,Le.width,Le.height,Pe,Le.data):t.compressedTexImage2D(i.TEXTURE_2D,be,Ae,Le.width,Le.height,0,Le.data):tt("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Je?G&&t.texSubImage2D(i.TEXTURE_2D,be,0,0,Le.width,Le.height,Pe,qe,Le.data):t.texImage2D(i.TEXTURE_2D,be,Ae,Le.width,Le.height,0,Pe,qe,Le.data)}else if(w.isDataArrayTexture)if(Je){if(at&&t.texStorage3D(i.TEXTURE_2D_ARRAY,Ie,Ae,xe.width,xe.height,xe.depth),G)if(w.layerUpdates.size>0){let be=vp(xe.width,xe.height,w.format,w.type);for(let Re of w.layerUpdates){let Be=xe.data.subarray(Re*be/xe.data.BYTES_PER_ELEMENT,(Re+1)*be/xe.data.BYTES_PER_ELEMENT);t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,Re,xe.width,xe.height,1,Pe,qe,Be)}w.clearLayerUpdates()}else t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,xe.width,xe.height,xe.depth,Pe,qe,xe.data)}else t.texImage3D(i.TEXTURE_2D_ARRAY,0,Ae,xe.width,xe.height,xe.depth,0,Pe,qe,xe.data);else if(w.isData3DTexture)Je?(at&&t.texStorage3D(i.TEXTURE_3D,Ie,Ae,xe.width,xe.height,xe.depth),G&&t.texSubImage3D(i.TEXTURE_3D,0,0,0,0,xe.width,xe.height,xe.depth,Pe,qe,xe.data)):t.texImage3D(i.TEXTURE_3D,0,Ae,xe.width,xe.height,xe.depth,0,Pe,qe,xe.data);else if(w.isFramebufferTexture){if(at)if(Je)t.texStorage2D(i.TEXTURE_2D,Ie,Ae,xe.width,xe.height);else{let be=xe.width,Re=xe.height;for(let Be=0;Be<Ie;Be++)t.texImage2D(i.TEXTURE_2D,Be,Ae,be,Re,0,Pe,qe,null),be>>=1,Re>>=1}}else if(w.isHTMLTexture){if("texElementImage2D"in i){let be=i.canvas;if(be.hasAttribute("layoutsubtree")||be.setAttribute("layoutsubtree","true"),xe.parentNode!==be){be.appendChild(xe),u.add(w),be.onpaint=Re=>{let Be=Re.changedElements;for(let ye of u)Be.includes(ye.image)&&(ye.needsUpdate=!0)},be.requestPaint();return}if(i.texElementImage2D.length===3)i.texElementImage2D(i.TEXTURE_2D,i.RGBA8,xe);else{let Be=i.RGBA,ye=i.RGBA,et=i.UNSIGNED_BYTE;i.texElementImage2D(i.TEXTURE_2D,0,Be,ye,et,xe)}i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE)}}else if(Fe.length>0){if(Je&&at){let be=Et(Fe[0]);t.texStorage2D(i.TEXTURE_2D,Ie,Ae,be.width,be.height)}for(let be=0,Re=Fe.length;be<Re;be++)Le=Fe[be],Je?G&&t.texSubImage2D(i.TEXTURE_2D,be,0,0,Pe,qe,Le):t.texImage2D(i.TEXTURE_2D,be,Ae,Pe,qe,Le);w.generateMipmaps=!1}else if(Je){if(at){let be=Et(xe);t.texStorage2D(i.TEXTURE_2D,Ie,Ae,be.width,be.height)}G&&t.texSubImage2D(i.TEXTURE_2D,0,0,0,Pe,qe,xe)}else t.texImage2D(i.TEXTURE_2D,0,Ae,Pe,qe,xe);g(w)&&E(re),Ce.__version=Ee.version,w.onUpdate&&w.onUpdate(w)}U.__version=w.version}function it(U,w,ee){if(w.image.length!==6)return;let re=Qe(U,w),ce=w.source;t.bindTexture(i.TEXTURE_CUBE_MAP,U.__webglTexture,i.TEXTURE0+ee);let Ee=n.get(ce);if(ce.version!==Ee.__version||re===!0){t.activeTexture(i.TEXTURE0+ee);let Ce=gt.getPrimaries(gt.workingColorSpace),de=w.colorSpace===Qi?null:gt.getPrimaries(w.colorSpace),xe=w.colorSpace===Qi||Ce===de?i.NONE:i.BROWSER_DEFAULT_WEBGL;t.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,w.flipY),t.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,w.premultiplyAlpha),t.pixelStorei(i.UNPACK_ALIGNMENT,w.unpackAlignment),t.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,xe);let Pe=w.isCompressedTexture||w.image[0].isCompressedTexture,qe=w.image[0]&&w.image[0].isDataTexture,Ae=[];for(let ye=0;ye<6;ye++)!Pe&&!qe?Ae[ye]=_(w.image[ye],!0,s.maxCubemapSize):Ae[ye]=qe?w.image[ye].image:w.image[ye],Ae[ye]=hn(w,Ae[ye]);let Le=Ae[0],Fe=r.convert(w.format,w.colorSpace),Je=r.convert(w.type),at=S(w.internalFormat,Fe,Je,w.normalized,w.colorSpace),G=w.isVideoTexture!==!0,Ie=Ee.__version===void 0||re===!0,be=ce.dataReady,Re=A(w,Le);je(i.TEXTURE_CUBE_MAP,w);let Be;if(Pe){G&&Ie&&t.texStorage2D(i.TEXTURE_CUBE_MAP,Re,at,Le.width,Le.height);for(let ye=0;ye<6;ye++){Be=Ae[ye].mipmaps;for(let et=0;et<Be.length;et++){let Ye=Be[et];w.format!==yi?Fe!==null?G?be&&t.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ye,et,0,0,Ye.width,Ye.height,Fe,Ye.data):t.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ye,et,at,Ye.width,Ye.height,0,Ye.data):tt("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):G?be&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ye,et,0,0,Ye.width,Ye.height,Fe,Je,Ye.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ye,et,at,Ye.width,Ye.height,0,Fe,Je,Ye.data)}}}else{if(Be=w.mipmaps,G&&Ie){Be.length>0&&Re++;let ye=Et(Ae[0]);t.texStorage2D(i.TEXTURE_CUBE_MAP,Re,at,ye.width,ye.height)}for(let ye=0;ye<6;ye++)if(qe){G?be&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ye,0,0,0,Ae[ye].width,Ae[ye].height,Fe,Je,Ae[ye].data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ye,0,at,Ae[ye].width,Ae[ye].height,0,Fe,Je,Ae[ye].data);for(let et=0;et<Be.length;et++){let Ut=Be[et].image[ye].image;G?be&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ye,et+1,0,0,Ut.width,Ut.height,Fe,Je,Ut.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ye,et+1,at,Ut.width,Ut.height,0,Fe,Je,Ut.data)}}else{G?be&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ye,0,0,0,Fe,Je,Ae[ye]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ye,0,at,Fe,Je,Ae[ye]);for(let et=0;et<Be.length;et++){let Ye=Be[et];G?be&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ye,et+1,0,0,Fe,Je,Ye.image[ye]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ye,et+1,at,Fe,Je,Ye.image[ye])}}}g(w)&&E(i.TEXTURE_CUBE_MAP),Ee.__version=ce.version,w.onUpdate&&w.onUpdate(w)}U.__version=w.version}function Ue(U,w,ee,re,ce,Ee){let Ce=r.convert(ee.format,ee.colorSpace),de=r.convert(ee.type),xe=S(ee.internalFormat,Ce,de,ee.normalized,ee.colorSpace),Pe=n.get(w),qe=n.get(ee);if(qe.__renderTarget=w,!Pe.__hasExternalTextures){let Ae=Math.max(1,w.width>>Ee),Le=Math.max(1,w.height>>Ee);ce===i.TEXTURE_3D||ce===i.TEXTURE_2D_ARRAY?t.texImage3D(ce,Ee,xe,Ae,Le,w.depth,0,Ce,de,null):t.texImage2D(ce,Ee,xe,Ae,Le,0,Ce,de,null)}t.bindFramebuffer(i.FRAMEBUFFER,U),Kt(w)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,re,ce,qe.__webglTexture,0,Ht(w)):(ce===i.TEXTURE_2D||ce>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&ce<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,re,ce,qe.__webglTexture,Ee),t.bindFramebuffer(i.FRAMEBUFFER,null)}function ct(U,w,ee){if(i.bindRenderbuffer(i.RENDERBUFFER,U),w.depthBuffer){let re=w.depthTexture,ce=re&&re.isDepthTexture?re.type:null,Ee=M(w.stencilBuffer,ce),Ce=w.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;Kt(w)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,Ht(w),Ee,w.width,w.height):ee?i.renderbufferStorageMultisample(i.RENDERBUFFER,Ht(w),Ee,w.width,w.height):i.renderbufferStorage(i.RENDERBUFFER,Ee,w.width,w.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,Ce,i.RENDERBUFFER,U)}else{let re=w.textures;for(let ce=0;ce<re.length;ce++){let Ee=re[ce],Ce=r.convert(Ee.format,Ee.colorSpace),de=r.convert(Ee.type),xe=S(Ee.internalFormat,Ce,de,Ee.normalized,Ee.colorSpace);Kt(w)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,Ht(w),xe,w.width,w.height):ee?i.renderbufferStorageMultisample(i.RENDERBUFFER,Ht(w),xe,w.width,w.height):i.renderbufferStorage(i.RENDERBUFFER,xe,w.width,w.height)}}i.bindRenderbuffer(i.RENDERBUFFER,null)}function zt(U,w,ee){let re=w.isWebGLCubeRenderTarget===!0;if(t.bindFramebuffer(i.FRAMEBUFFER,U),!(w.depthTexture&&w.depthTexture.isDepthTexture))throw new Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");let ce=n.get(w.depthTexture);if(ce.__renderTarget=w,(!ce.__webglTexture||w.depthTexture.image.width!==w.width||w.depthTexture.image.height!==w.height)&&(w.depthTexture.image.width=w.width,w.depthTexture.image.height=w.height,w.depthTexture.needsUpdate=!0),re){if(ce.__webglInit===void 0&&(ce.__webglInit=!0,w.depthTexture.addEventListener("dispose",I)),ce.__webglTexture===void 0){ce.__webglTexture=i.createTexture(),t.bindTexture(i.TEXTURE_CUBE_MAP,ce.__webglTexture),je(i.TEXTURE_CUBE_MAP,w.depthTexture);let Pe=r.convert(w.depthTexture.format),qe=r.convert(w.depthTexture.type),Ae;w.depthTexture.format===fs?Ae=i.DEPTH_COMPONENT24:w.depthTexture.format===Sr&&(Ae=i.DEPTH24_STENCIL8);for(let Le=0;Le<6;Le++)i.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Le,0,Ae,w.width,w.height,0,Pe,qe,null)}}else H(w.depthTexture,0);let Ee=ce.__webglTexture,Ce=Ht(w),de=re?i.TEXTURE_CUBE_MAP_POSITIVE_X+ee:i.TEXTURE_2D,xe=w.depthTexture.format===Sr?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;if(w.depthTexture.format===fs)Kt(w)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,xe,de,Ee,0,Ce):i.framebufferTexture2D(i.FRAMEBUFFER,xe,de,Ee,0);else if(w.depthTexture.format===Sr)Kt(w)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,xe,de,Ee,0,Ce):i.framebufferTexture2D(i.FRAMEBUFFER,xe,de,Ee,0);else throw new Error("THREE.WebGLTextures: Unknown depthTexture format.")}function ot(U){let w=n.get(U),ee=U.isWebGLCubeRenderTarget===!0;if(w.__boundDepthTexture!==U.depthTexture){let re=U.depthTexture;if(w.__depthDisposeCallback&&w.__depthDisposeCallback(),re){let ce=()=>{delete w.__boundDepthTexture,delete w.__depthDisposeCallback,re.removeEventListener("dispose",ce)};re.addEventListener("dispose",ce),w.__depthDisposeCallback=ce}w.__boundDepthTexture=re}if(U.depthTexture&&!w.__autoAllocateDepthBuffer)if(ee)for(let re=0;re<6;re++)zt(w.__webglFramebuffer[re],U,re);else{let re=U.texture.mipmaps;re&&re.length>0?zt(w.__webglFramebuffer[0],U,0):zt(w.__webglFramebuffer,U,0)}else if(ee){w.__webglDepthbuffer=[];for(let re=0;re<6;re++)if(t.bindFramebuffer(i.FRAMEBUFFER,w.__webglFramebuffer[re]),w.__webglDepthbuffer[re]===void 0)w.__webglDepthbuffer[re]=i.createRenderbuffer(),ct(w.__webglDepthbuffer[re],U,!1);else{let ce=U.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,Ee=w.__webglDepthbuffer[re];i.bindRenderbuffer(i.RENDERBUFFER,Ee),i.framebufferRenderbuffer(i.FRAMEBUFFER,ce,i.RENDERBUFFER,Ee)}}else{let re=U.texture.mipmaps;if(re&&re.length>0?t.bindFramebuffer(i.FRAMEBUFFER,w.__webglFramebuffer[0]):t.bindFramebuffer(i.FRAMEBUFFER,w.__webglFramebuffer),w.__webglDepthbuffer===void 0)w.__webglDepthbuffer=i.createRenderbuffer(),ct(w.__webglDepthbuffer,U,!1);else{let ce=U.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,Ee=w.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,Ee),i.framebufferRenderbuffer(i.FRAMEBUFFER,ce,i.RENDERBUFFER,Ee)}}t.bindFramebuffer(i.FRAMEBUFFER,null)}function mt(U,w,ee){let re=n.get(U);w!==void 0&&Ue(re.__webglFramebuffer,U,U.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),ee!==void 0&&ot(U)}function Lt(U){let w=U.texture,ee=n.get(U),re=n.get(w);U.addEventListener("dispose",y);let ce=U.textures,Ee=U.isWebGLCubeRenderTarget===!0,Ce=ce.length>1;if(Ce||(re.__webglTexture===void 0&&(re.__webglTexture=i.createTexture()),re.__version=w.version,a.memory.textures++),Ee){ee.__webglFramebuffer=[];for(let de=0;de<6;de++)if(w.mipmaps&&w.mipmaps.length>0){ee.__webglFramebuffer[de]=[];for(let xe=0;xe<w.mipmaps.length;xe++)ee.__webglFramebuffer[de][xe]=i.createFramebuffer()}else ee.__webglFramebuffer[de]=i.createFramebuffer()}else{if(w.mipmaps&&w.mipmaps.length>0){ee.__webglFramebuffer=[];for(let de=0;de<w.mipmaps.length;de++)ee.__webglFramebuffer[de]=i.createFramebuffer()}else ee.__webglFramebuffer=i.createFramebuffer();if(Ce)for(let de=0,xe=ce.length;de<xe;de++){let Pe=n.get(ce[de]);Pe.__webglTexture===void 0&&(Pe.__webglTexture=i.createTexture(),a.memory.textures++)}if(U.samples>0&&Kt(U)===!1){ee.__webglMultisampledFramebuffer=i.createFramebuffer(),ee.__webglColorRenderbuffer=[],t.bindFramebuffer(i.FRAMEBUFFER,ee.__webglMultisampledFramebuffer);for(let de=0;de<ce.length;de++){let xe=ce[de];ee.__webglColorRenderbuffer[de]=i.createRenderbuffer(),i.bindRenderbuffer(i.RENDERBUFFER,ee.__webglColorRenderbuffer[de]);let Pe=r.convert(xe.format,xe.colorSpace),qe=r.convert(xe.type),Ae=S(xe.internalFormat,Pe,qe,xe.normalized,xe.colorSpace,U.isXRRenderTarget===!0),Le=Ht(U);i.renderbufferStorageMultisample(i.RENDERBUFFER,Le,Ae,U.width,U.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+de,i.RENDERBUFFER,ee.__webglColorRenderbuffer[de])}i.bindRenderbuffer(i.RENDERBUFFER,null),U.depthBuffer&&(ee.__webglDepthRenderbuffer=i.createRenderbuffer(),ct(ee.__webglDepthRenderbuffer,U,!0)),t.bindFramebuffer(i.FRAMEBUFFER,null)}}if(Ee){t.bindTexture(i.TEXTURE_CUBE_MAP,re.__webglTexture),je(i.TEXTURE_CUBE_MAP,w);for(let de=0;de<6;de++)if(w.mipmaps&&w.mipmaps.length>0)for(let xe=0;xe<w.mipmaps.length;xe++)Ue(ee.__webglFramebuffer[de][xe],U,w,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+de,xe);else Ue(ee.__webglFramebuffer[de],U,w,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+de,0);g(w)&&E(i.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(Ce){for(let de=0,xe=ce.length;de<xe;de++){let Pe=ce[de],qe=n.get(Pe),Ae=i.TEXTURE_2D;(U.isWebGL3DRenderTarget||U.isWebGLArrayRenderTarget)&&(Ae=U.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(Ae,qe.__webglTexture),je(Ae,Pe),Ue(ee.__webglFramebuffer,U,Pe,i.COLOR_ATTACHMENT0+de,Ae,0),g(Pe)&&E(Ae)}t.unbindTexture()}else{let de=i.TEXTURE_2D;if((U.isWebGL3DRenderTarget||U.isWebGLArrayRenderTarget)&&(de=U.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(de,re.__webglTexture),je(de,w),w.mipmaps&&w.mipmaps.length>0)for(let xe=0;xe<w.mipmaps.length;xe++)Ue(ee.__webglFramebuffer[xe],U,w,i.COLOR_ATTACHMENT0,de,xe);else Ue(ee.__webglFramebuffer,U,w,i.COLOR_ATTACHMENT0,de,0);g(w)&&E(de),t.unbindTexture()}U.depthBuffer&&ot(U)}function ft(U){let w=U.textures;for(let ee=0,re=w.length;ee<re;ee++){let ce=w[ee];if(g(ce)){let Ee=L(U),Ce=n.get(ce).__webglTexture;t.bindTexture(Ee,Ce),E(Ee),t.unbindTexture()}}}let xt=[],Wt=[];function _n(U){if(U.samples>0){if(Kt(U)===!1){let w=U.textures,ee=U.width,re=U.height,ce=i.COLOR_BUFFER_BIT,Ee=U.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,Ce=n.get(U),de=w.length>1;if(de)for(let Pe=0;Pe<w.length;Pe++)t.bindFramebuffer(i.FRAMEBUFFER,Ce.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+Pe,i.RENDERBUFFER,null),t.bindFramebuffer(i.FRAMEBUFFER,Ce.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+Pe,i.TEXTURE_2D,null,0);t.bindFramebuffer(i.READ_FRAMEBUFFER,Ce.__webglMultisampledFramebuffer);let xe=U.texture.mipmaps;xe&&xe.length>0?t.bindFramebuffer(i.DRAW_FRAMEBUFFER,Ce.__webglFramebuffer[0]):t.bindFramebuffer(i.DRAW_FRAMEBUFFER,Ce.__webglFramebuffer);for(let Pe=0;Pe<w.length;Pe++){if(U.resolveDepthBuffer&&(U.depthBuffer&&(ce|=i.DEPTH_BUFFER_BIT),U.stencilBuffer&&U.resolveStencilBuffer&&(ce|=i.STENCIL_BUFFER_BIT)),de){i.framebufferRenderbuffer(i.READ_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,Ce.__webglColorRenderbuffer[Pe]);let qe=n.get(w[Pe]).__webglTexture;i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,qe,0)}i.blitFramebuffer(0,0,ee,re,0,0,ee,re,ce,i.NEAREST),c===!0&&(xt.length=0,Wt.length=0,xt.push(i.COLOR_ATTACHMENT0+Pe),U.depthBuffer&&U.storeMultisampledDepthBuffer===!1&&(xt.push(Ee),Wt.push(Ee),i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,Wt)),i.invalidateFramebuffer(i.READ_FRAMEBUFFER,xt))}if(t.bindFramebuffer(i.READ_FRAMEBUFFER,null),t.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),de)for(let Pe=0;Pe<w.length;Pe++){t.bindFramebuffer(i.FRAMEBUFFER,Ce.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+Pe,i.RENDERBUFFER,Ce.__webglColorRenderbuffer[Pe]);let qe=n.get(w[Pe]).__webglTexture;t.bindFramebuffer(i.FRAMEBUFFER,Ce.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+Pe,i.TEXTURE_2D,qe,0)}t.bindFramebuffer(i.DRAW_FRAMEBUFFER,Ce.__webglMultisampledFramebuffer)}else if(U.depthBuffer&&U.storeMultisampledDepthBuffer===!1&&c){let w=U.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,[w])}}}function Ht(U){return Math.min(s.maxSamples,U.samples)}function Kt(U){let w=n.get(U);return U.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&w.__useRenderToTexture!==!1}function q(U){let w=a.render.frame;h.get(U)!==w&&(h.set(U,w),U.update())}function hn(U,w){let ee=U.colorSpace,re=U.format,ce=U.type;return U.isCompressedTexture===!0||U.isVideoTexture===!0||ee!==Mn&&ee!==Qi&&(gt.getTransfer(ee)===Bt?(re!==yi||ce!==oi)&&tt("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):st("WebGLTextures: Unsupported texture color space:",ee)),w}function Et(U){return typeof HTMLImageElement<"u"&&U instanceof HTMLImageElement?(l.width=U.naturalWidth||U.width,l.height=U.naturalHeight||U.height):typeof VideoFrame<"u"&&U instanceof VideoFrame?(l.width=U.displayWidth,l.height=U.displayHeight):(l.width=U.width,l.height=U.height),l}this.allocateTextureUnit=O,this.resetTextureUnits=K,this.getTextureUnits=P,this.setTextureUnits=N,this.setTexture2D=H,this.setTexture2DArray=V,this.setTexture3D=Q,this.setTextureCube=te,this.rebindTextures=mt,this.setupRenderTarget=Lt,this.updateRenderTargetMipmap=ft,this.updateMultisampleRenderTarget=_n,this.setupDepthRenderbuffer=ot,this.setupFrameBufferTexture=Ue,this.useMultisampledRTT=Kt,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function fC(i,e){function t(n,s=Qi){let r,a=gt.getTransfer(s);if(n===oi)return i.UNSIGNED_BYTE;if(n===Fh)return i.UNSIGNED_SHORT_4_4_4_4;if(n===kh)return i.UNSIGNED_SHORT_5_5_5_1;if(n===lp)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===hp)return i.UNSIGNED_INT_10F_11F_11F_REV;if(n===op)return i.BYTE;if(n===cp)return i.SHORT;if(n===so)return i.UNSIGNED_SHORT;if(n===Oh)return i.INT;if(n===Zi)return i.UNSIGNED_INT;if(n===qn)return i.FLOAT;if(n===Zn)return i.HALF_FLOAT;if(n===up)return i.ALPHA;if(n===fp)return i.RGB;if(n===yi)return i.RGBA;if(n===fs)return i.DEPTH_COMPONENT;if(n===Sr)return i.DEPTH_STENCIL;if(n===Uh)return i.RED;if(n===Bh)return i.RED_INTEGER;if(n===wr)return i.RG;if(n===zh)return i.RG_INTEGER;if(n===Hh)return i.RGBA_INTEGER;if(n===wc||n===Mc||n===Ec||n===Ac)if(a===Bt)if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===wc)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Mc)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Ec)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Ac)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=e.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===wc)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Mc)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Ec)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Ac)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===Vh||n===Gh||n===Wh||n===$h)if(r=e.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(n===Vh)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===Gh)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===Wh)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===$h)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===qh||n===jh||n===Xh||n===Kh||n===Yh||n===Tc||n===Jh)if(r=e.get("WEBGL_compressed_texture_etc"),r!==null){if(n===qh||n===jh)return a===Bt?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===Xh)return a===Bt?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(n===Kh)return r.COMPRESSED_R11_EAC;if(n===Yh)return r.COMPRESSED_SIGNED_R11_EAC;if(n===Tc)return r.COMPRESSED_RG11_EAC;if(n===Jh)return r.COMPRESSED_SIGNED_RG11_EAC}else return null;if(n===Zh||n===Qh||n===eu||n===tu||n===nu||n===iu||n===su||n===ru||n===au||n===ou||n===cu||n===lu||n===hu||n===uu)if(r=e.get("WEBGL_compressed_texture_astc"),r!==null){if(n===Zh)return a===Bt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Qh)return a===Bt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===eu)return a===Bt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===tu)return a===Bt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===nu)return a===Bt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===iu)return a===Bt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===su)return a===Bt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===ru)return a===Bt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===au)return a===Bt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===ou)return a===Bt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===cu)return a===Bt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===lu)return a===Bt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===hu)return a===Bt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===uu)return a===Bt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===fu||n===du||n===pu)if(r=e.get("EXT_texture_compression_bptc"),r!==null){if(n===fu)return a===Bt?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===du)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===pu)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===mu||n===gu||n===Rc||n===bu)if(r=e.get("EXT_texture_compression_rgtc"),r!==null){if(n===mu)return r.COMPRESSED_RED_RGTC1_EXT;if(n===gu)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===Rc)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===bu)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===ro?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:t}}function gC(i,e){function t(_,g){_.matrixAutoUpdate===!0&&_.updateMatrix(),g.value.copy(_.matrix)}function n(_,g){g.color.getRGB(_.fogColor.value,_p(i)),g.isFog?(_.fogNear.value=g.near,_.fogFar.value=g.far):g.isFogExp2&&(_.fogDensity.value=g.density)}function s(_,g,E,L,S){g.isNodeMaterial?g.uniformsNeedUpdate=!1:g.isMeshBasicMaterial?r(_,g):g.isMeshLambertMaterial?(r(_,g),g.envMap&&(_.envMapIntensity.value=g.envMapIntensity)):g.isMeshToonMaterial?(r(_,g),u(_,g)):g.isMeshPhongMaterial?(r(_,g),h(_,g),g.envMap&&(_.envMapIntensity.value=g.envMapIntensity)):g.isMeshStandardMaterial?(r(_,g),d(_,g),g.isMeshPhysicalMaterial&&p(_,g,S)):g.isMeshMatcapMaterial?(r(_,g),b(_,g)):g.isMeshDepthMaterial?r(_,g):g.isMeshDistanceMaterial?(r(_,g),v(_,g)):g.isMeshNormalMaterial?r(_,g):g.isLineBasicMaterial?(a(_,g),g.isLineDashedMaterial&&o(_,g)):g.isPointsMaterial?c(_,g,E,L):g.isSpriteMaterial?l(_,g):g.isShadowMaterial?(_.color.value.copy(g.color),_.opacity.value=g.opacity):g.isShaderMaterial&&(g.uniformsNeedUpdate=!1)}function r(_,g){_.opacity.value=g.opacity,g.color&&_.diffuse.value.copy(g.color),g.emissive&&_.emissive.value.copy(g.emissive).multiplyScalar(g.emissiveIntensity),g.map&&(_.map.value=g.map,t(g.map,_.mapTransform)),g.alphaMap&&(_.alphaMap.value=g.alphaMap,t(g.alphaMap,_.alphaMapTransform)),g.bumpMap&&(_.bumpMap.value=g.bumpMap,t(g.bumpMap,_.bumpMapTransform),_.bumpScale.value=g.bumpScale,g.side===Nn&&(_.bumpScale.value*=-1)),g.normalMap&&(_.normalMap.value=g.normalMap,t(g.normalMap,_.normalMapTransform),_.normalScale.value.copy(g.normalScale),g.side===Nn&&_.normalScale.value.negate()),g.displacementMap&&(_.displacementMap.value=g.displacementMap,t(g.displacementMap,_.displacementMapTransform),_.displacementScale.value=g.displacementScale,_.displacementBias.value=g.displacementBias),g.emissiveMap&&(_.emissiveMap.value=g.emissiveMap,t(g.emissiveMap,_.emissiveMapTransform)),g.specularMap&&(_.specularMap.value=g.specularMap,t(g.specularMap,_.specularMapTransform)),g.alphaTest>0&&(_.alphaTest.value=g.alphaTest);let E=e.get(g),L=E.envMap,S=E.envMapRotation;L&&(_.envMap.value=L,_.envMapRotation.value.setFromMatrix4(mC.makeRotationFromEuler(S)).transpose(),L.isCubeTexture&&L.isRenderTargetTexture===!1&&_.envMapRotation.value.premultiply(rx),_.reflectivity.value=g.reflectivity,_.ior.value=g.ior,_.refractionRatio.value=g.refractionRatio),g.lightMap&&(_.lightMap.value=g.lightMap,_.lightMapIntensity.value=g.lightMapIntensity,t(g.lightMap,_.lightMapTransform)),g.aoMap&&(_.aoMap.value=g.aoMap,_.aoMapIntensity.value=g.aoMapIntensity,t(g.aoMap,_.aoMapTransform))}function a(_,g){_.diffuse.value.copy(g.color),_.opacity.value=g.opacity,g.map&&(_.map.value=g.map,t(g.map,_.mapTransform))}function o(_,g){_.dashSize.value=g.dashSize,_.totalSize.value=g.dashSize+g.gapSize,_.scale.value=g.scale}function c(_,g,E,L){_.diffuse.value.copy(g.color),_.opacity.value=g.opacity,_.size.value=g.size*E,_.scale.value=L*.5,g.map&&(_.map.value=g.map,t(g.map,_.uvTransform)),g.alphaMap&&(_.alphaMap.value=g.alphaMap,t(g.alphaMap,_.alphaMapTransform)),g.alphaTest>0&&(_.alphaTest.value=g.alphaTest)}function l(_,g){_.diffuse.value.copy(g.color),_.opacity.value=g.opacity,_.rotation.value=g.rotation,g.map&&(_.map.value=g.map,t(g.map,_.mapTransform)),g.alphaMap&&(_.alphaMap.value=g.alphaMap,t(g.alphaMap,_.alphaMapTransform)),g.alphaTest>0&&(_.alphaTest.value=g.alphaTest)}function h(_,g){_.specular.value.copy(g.specular),_.shininess.value=Math.max(g.shininess,1e-4)}function u(_,g){g.gradientMap&&(_.gradientMap.value=g.gradientMap)}function d(_,g){_.metalness.value=g.metalness,g.metalnessMap&&(_.metalnessMap.value=g.metalnessMap,t(g.metalnessMap,_.metalnessMapTransform)),_.roughness.value=g.roughness,g.roughnessMap&&(_.roughnessMap.value=g.roughnessMap,t(g.roughnessMap,_.roughnessMapTransform)),g.envMap&&(_.envMapIntensity.value=g.envMapIntensity)}function p(_,g,E){_.ior.value=g.ior,g.sheen>0&&(_.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),_.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap&&(_.sheenColorMap.value=g.sheenColorMap,t(g.sheenColorMap,_.sheenColorMapTransform)),g.sheenRoughnessMap&&(_.sheenRoughnessMap.value=g.sheenRoughnessMap,t(g.sheenRoughnessMap,_.sheenRoughnessMapTransform))),g.clearcoat>0&&(_.clearcoat.value=g.clearcoat,_.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap&&(_.clearcoatMap.value=g.clearcoatMap,t(g.clearcoatMap,_.clearcoatMapTransform)),g.clearcoatRoughnessMap&&(_.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap,t(g.clearcoatRoughnessMap,_.clearcoatRoughnessMapTransform)),g.clearcoatNormalMap&&(_.clearcoatNormalMap.value=g.clearcoatNormalMap,t(g.clearcoatNormalMap,_.clearcoatNormalMapTransform),_.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),g.side===Nn&&_.clearcoatNormalScale.value.negate())),g.dispersion>0&&(_.dispersion.value=g.dispersion),g.retroreflectivity>0&&(_.retroreflectivity.value=g.retroreflectivity),g.iridescence>0&&(_.iridescence.value=g.iridescence,_.iridescenceIOR.value=g.iridescenceIOR,_.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],_.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap&&(_.iridescenceMap.value=g.iridescenceMap,t(g.iridescenceMap,_.iridescenceMapTransform)),g.iridescenceThicknessMap&&(_.iridescenceThicknessMap.value=g.iridescenceThicknessMap,t(g.iridescenceThicknessMap,_.iridescenceThicknessMapTransform))),g.transmission>0&&(_.transmission.value=g.transmission,_.transmissionSamplerMap.value=E.texture,_.transmissionSamplerSize.value.set(E.width,E.height),g.transmissionMap&&(_.transmissionMap.value=g.transmissionMap,t(g.transmissionMap,_.transmissionMapTransform)),_.thickness.value=g.thickness,g.thicknessMap&&(_.thicknessMap.value=g.thicknessMap,t(g.thicknessMap,_.thicknessMapTransform)),_.attenuationDistance.value=g.attenuationDistance,_.attenuationColor.value.copy(g.attenuationColor)),g.anisotropy>0&&(_.anisotropyVector.value.set(g.anisotropy*Math.cos(g.anisotropyRotation),g.anisotropy*Math.sin(g.anisotropyRotation)),g.anisotropyMap&&(_.anisotropyMap.value=g.anisotropyMap,t(g.anisotropyMap,_.anisotropyMapTransform))),_.specularIntensity.value=g.specularIntensity,_.specularColor.value.copy(g.specularColor),g.specularColorMap&&(_.specularColorMap.value=g.specularColorMap,t(g.specularColorMap,_.specularColorMapTransform)),g.specularIntensityMap&&(_.specularIntensityMap.value=g.specularIntensityMap,t(g.specularIntensityMap,_.specularIntensityMapTransform))}function b(_,g){g.matcap&&(_.matcap.value=g.matcap)}function v(_,g){let E=e.get(g).light;_.referencePosition.value.setFromMatrixPosition(E.matrixWorld),_.nearDistance.value=E.shadow.camera.near,_.farDistance.value=E.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:s}}function bC(i,e,t,n){let s={},r={},a=[],o=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function c(S,M){let A=M.program;n.uniformBlockBinding(S,A)}function l(S,M){let A=s[S.id];A===void 0&&(_(S),A=h(S),s[S.id]=A,S.addEventListener("dispose",E));let I=M.program;n.updateUBOMapping(S,I);let y=e.render.frame;r[S.id]!==y&&(d(S),r[S.id]=y)}function h(S){let M=u();S.__bindingPointIndex=M;let A=i.createBuffer(),I=S.__size,y=S.usage;return i.bindBuffer(i.UNIFORM_BUFFER,A),i.bufferData(i.UNIFORM_BUFFER,I,y),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,M,A),A}function u(){for(let S=0;S<o;S++)if(a.indexOf(S)===-1)return a.push(S),S;return st("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(S){let M=s[S.id],A=S.uniforms,I=S.__cache;i.bindBuffer(i.UNIFORM_BUFFER,M);for(let y=0,C=A.length;y<C;y++){let k=A[y];if(Array.isArray(k))for(let z=0,$=k.length;z<$;z++)p(k[z],y,z,I);else p(k,y,0,I)}i.bindBuffer(i.UNIFORM_BUFFER,null)}function p(S,M,A,I){if(v(S,M,A,I)===!0){let y=S.__offset,C=S.value;if(Array.isArray(C)){let k=0;for(let z=0;z<C.length;z++){let $=C[z],K=g($);b($,S.__data,k),typeof $!="number"&&typeof $!="boolean"&&!$.isMatrix3&&!ArrayBuffer.isView($)&&(k+=K.storage/Float32Array.BYTES_PER_ELEMENT)}}else b(C,S.__data,0);i.bufferSubData(i.UNIFORM_BUFFER,y,S.__data)}}function b(S,M,A){typeof S=="number"||typeof S=="boolean"?M[0]=S:S.isMatrix3?(M[0]=S.elements[0],M[1]=S.elements[1],M[2]=S.elements[2],M[3]=0,M[4]=S.elements[3],M[5]=S.elements[4],M[6]=S.elements[5],M[7]=0,M[8]=S.elements[6],M[9]=S.elements[7],M[10]=S.elements[8],M[11]=0):ArrayBuffer.isView(S)?M.set(new S.constructor(S.buffer,S.byteOffset,M.length)):S.toArray(M,A)}function v(S,M,A,I){let y=S.value,C=M+"_"+A;if(I[C]===void 0)return typeof y=="number"||typeof y=="boolean"?I[C]=y:ArrayBuffer.isView(y)?I[C]=y.slice():I[C]=y.clone(),!0;{let k=I[C];if(typeof y=="number"||typeof y=="boolean"){if(k!==y)return I[C]=y,!0}else{if(ArrayBuffer.isView(y))return!0;if(k.equals(y)===!1)return k.copy(y),!0}}return!1}function _(S){let M=S.uniforms,A=0,I=16;for(let C=0,k=M.length;C<k;C++){let z=Array.isArray(M[C])?M[C]:[M[C]];for(let $=0,K=z.length;$<K;$++){let P=z[$],N=Array.isArray(P.value)?P.value:[P.value];for(let O=0,F=N.length;O<F;O++){let H=N[O],V=g(H),Q=A%I,te=Q%V.boundary,Se=Q+te;A+=te,Se!==0&&I-Se<V.storage&&(A+=I-Se),P.__data=new Float32Array(V.storage/Float32Array.BYTES_PER_ELEMENT),P.__offset=A,A+=V.storage}}}let y=A%I;return y>0&&(A+=I-y),S.__size=A,S.__cache={},this}function g(S){let M={boundary:0,storage:0};return typeof S=="number"||typeof S=="boolean"?(M.boundary=4,M.storage=4):S.isVector2?(M.boundary=8,M.storage=8):S.isVector3||S.isColor?(M.boundary=16,M.storage=12):S.isVector4?(M.boundary=16,M.storage=16):S.isMatrix3?(M.boundary=48,M.storage=48):S.isMatrix4?(M.boundary=64,M.storage=64):S.isTexture?tt("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(S)?(M.boundary=16,M.storage=S.byteLength):tt("WebGLRenderer: Unsupported uniform value type.",S),M}function E(S){let M=S.target;M.removeEventListener("dispose",E);let A=a.indexOf(M.__bindingPointIndex);a.splice(A,1),i.deleteBuffer(s[M.id]),delete s[M.id],delete r[M.id]}function L(){for(let S in s)i.deleteBuffer(s[S]);a=[],s={},r={}}return{bind:c,update:l,dispose:L}}function xC(){return _s===null&&(_s=new dr(_C,16,16,wr,Zn),_s.name="DFG_LUT",_s.minFilter=qt,_s.magFilter=qt,_s.wrapS=ii,_s.wrapT=ii,_s.generateMipmaps=!1,_s.needsUpdate=!0),_s}var LM,DM,NM,OM,FM,kM,UM,BM,zM,HM,VM,GM,WM,$M,qM,jM,XM,KM,YM,JM,ZM,QM,eE,tE,nE,iE,sE,rE,aE,oE,cE,lE,hE,uE,fE,dE,pE,mE,gE,bE,_E,xE,yE,vE,SE,wE,ME,EE,AE,TE,RE,CE,IE,PE,LE,DE,NE,OE,FE,kE,UE,BE,zE,HE,VE,GE,WE,$E,qE,jE,XE,KE,YE,JE,ZE,QE,eA,tA,nA,iA,sA,rA,aA,oA,cA,lA,hA,uA,fA,dA,pA,mA,gA,bA,_A,xA,yA,vA,SA,wA,MA,EA,AA,TA,RA,CA,IA,PA,LA,DA,NA,OA,FA,kA,UA,BA,zA,HA,VA,GA,WA,$A,qA,jA,XA,KA,YA,JA,ZA,QA,eT,tT,nT,iT,sT,rT,aT,oT,cT,lT,hT,uT,_t,ke,xs,vu,fT,ex,lo,_T,xT,yT,Dc,L_,Rp,Cp,Ip,Pp,vT,ra,uo,fo,LT,tx,Np,nx,ix,sx,F_,k_,U_,B_,z_,Op,Fp,kp,Lp,ho,vR,SR,G_,AR,Su,LR,DR,OR,kR,BR,HR,GR,jR,Bp,zp,tC,rC,aC,oC,cC,Z_,Nc,Dp,dC,pC,Hp,Vp,mC,rx,_C,_s,wu,Qn=un(()=>{Tp();Tp();LM=`#ifdef USE_ALPHAHASH
if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
-#endif`,IS=`#ifdef USE_ALPHAHASH
+#endif`,DM=`#ifdef USE_ALPHAHASH
const float ALPHA_HASH_SCALE = 0.05;
float hash2D( vec2 value ) {
return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
@@ -392,20 +352,20 @@ Program Info Log: `+E+`
: cases.z;
return clamp( threshold , 1.0e-6, 1.0 );
}
-#endif`,PS=`#ifdef USE_ALPHAMAP
+#endif`,NM=`#ifdef USE_ALPHAMAP
diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
-#endif`,LS=`#ifdef USE_ALPHAMAP
+#endif`,OM=`#ifdef USE_ALPHAMAP
uniform sampler2D alphaMap;
-#endif`,DS=`#ifdef USE_ALPHATEST
+#endif`,FM=`#ifdef USE_ALPHATEST
#ifdef ALPHA_TO_COVERAGE
diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
if ( diffuseColor.a == 0.0 ) discard;
#else
if ( diffuseColor.a < alphaTest ) discard;
#endif
-#endif`,NS=`#ifdef USE_ALPHATEST
+#endif`,kM=`#ifdef USE_ALPHATEST
uniform float alphaTest;
-#endif`,OS=`#ifdef USE_AOMAP
+#endif`,UM=`#ifdef USE_AOMAP
float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
reflectedLight.indirectDiffuse *= ambientOcclusion;
#if defined( USE_CLEARCOAT )
@@ -418,10 +378,10 @@ Program Info Log: `+E+`
float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
#endif
-#endif`,FS=`#ifdef USE_AOMAP
+#endif`,BM=`#ifdef USE_AOMAP
uniform sampler2D aoMap;
uniform float aoMapIntensity;
-#endif`,US=`#ifdef USE_BATCHING
+#endif`,zM=`#ifdef USE_BATCHING
#if ! defined( GL_ANGLE_multi_draw )
#define gl_DrawID _gl_DrawID
uniform int _gl_DrawID;
@@ -455,15 +415,15 @@ Program Info Log: `+E+`
int y = j / size;
return texelFetch( batchingColorTexture, ivec2( x, y ), 0 );
}
-#endif`,kS=`#ifdef USE_BATCHING
+#endif`,HM=`#ifdef USE_BATCHING
mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
-#endif`,BS=`vec3 transformed = vec3( position );
+#endif`,VM=`vec3 transformed = vec3( position );
#ifdef USE_ALPHAHASH
vPosition = vec3( position );
-#endif`,zS=`vec3 objectNormal = vec3( normal );
+#endif`,GM=`vec3 objectNormal = vec3( normal );
#ifdef USE_TANGENT
vec3 objectTangent = vec3( tangent.xyz );
-#endif`,HS=`float G_BlinnPhong_Implicit( ) {
+#endif`,WM=`float G_BlinnPhong_Implicit( ) {
return 0.25;
}
float D_BlinnPhong( const in float shininess, const in float dotNH ) {
@@ -477,7 +437,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
float G = G_BlinnPhong_Implicit( );
float D = D_BlinnPhong( shininess, dotNH );
return F * ( G * D );
-} // validated`,GS=`#ifdef USE_IRIDESCENCE
+} // validated`,$M=`#ifdef USE_IRIDESCENCE
const mat3 XYZ_TO_REC709 = mat3(
3.2404542, -0.9692660, 0.0556434,
-1.5371385, 1.8760108, -0.2040259,
@@ -540,7 +500,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
}
return max( I, vec3( 0.0 ) );
}
-#endif`,VS=`#ifdef USE_BUMPMAP
+#endif`,qM=`#ifdef USE_BUMPMAP
uniform sampler2D bumpMap;
uniform float bumpScale;
vec2 dHdxy_fwd() {
@@ -561,7 +521,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
return normalize( abs( fDet ) * surf_norm - vGrad );
}
-#endif`,WS=`#if NUM_CLIPPING_PLANES > 0
+#endif`,jM=`#if NUM_CLIPPING_PLANES > 0
vec4 plane;
#ifdef ALPHA_TO_COVERAGE
float distanceToPlane, distanceGradient;
@@ -607,20 +567,20 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
if ( clipped ) discard;
#endif
#endif
-#endif`,qS=`#if NUM_CLIPPING_PLANES > 0
+#endif`,XM=`#if NUM_CLIPPING_PLANES > 0
varying vec3 vClipPosition;
uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
-#endif`,$S=`#if NUM_CLIPPING_PLANES > 0
+#endif`,KM=`#if NUM_CLIPPING_PLANES > 0
varying vec3 vClipPosition;
-#endif`,jS=`#if NUM_CLIPPING_PLANES > 0
+#endif`,YM=`#if NUM_CLIPPING_PLANES > 0
vClipPosition = - mvPosition.xyz;
-#endif`,XS=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
+#endif`,JM=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
diffuseColor *= vColor;
-#endif`,KS=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
+#endif`,ZM=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
varying vec4 vColor;
-#endif`,YS=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
+#endif`,QM=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
varying vec4 vColor;
-#endif`,JS=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
+#endif`,eE=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
vColor = vec4( 1.0 );
#endif
#ifdef USE_COLOR_ALPHA
@@ -633,7 +593,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
#endif
#ifdef USE_BATCHING_COLOR
vColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) );
-#endif`,ZS=`#define PI 3.141592653589793
+#endif`,tE=`#define PI 3.141592653589793
#define PI2 6.283185307179586
#define PI_HALF 1.5707963267948966
#define RECIPROCAL_PI 0.3183098861837907
@@ -679,8 +639,12 @@ struct ReflectedLight {
vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
}
-vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
- return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
+#define inverseTransformDirection transformDirectionByInverseViewMatrix
+vec3 transformNormalByInverseViewMatrix( in vec3 normal, in mat4 viewMatrix ) {
+ return normalize( ( vec4( normal, 0.0 ) * viewMatrix ).xyz );
+}
+vec3 transformDirectionByInverseViewMatrix( in vec3 dir, in mat4 viewMatrix ) {
+ return normalize( ( vec4( dir, 0.0 ) * viewMatrix ).xyz );
}
bool isPerspectiveMatrix( mat4 m ) {
return m[ 2 ][ 3 ] == - 1.0;
@@ -700,7 +664,7 @@ vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
-} // validated`,QS=`#ifdef ENVMAP_TYPE_CUBE_UV
+} // validated`,nE=`#ifdef ENVMAP_TYPE_CUBE_UV
#define cubeUV_minMipLevel 4.0
#define cubeUV_minTileSize 16.0
float getFace( vec3 direction ) {
@@ -793,7 +757,7 @@ float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
return vec4( mix( color0, color1, mipF ), 1.0 );
}
}
-#endif`,ew=`vec3 transformedNormal = objectNormal;
+#endif`,iE=`vec3 transformedNormal = objectNormal;
#ifdef USE_TANGENT
vec3 transformedTangent = objectTangent;
#endif
@@ -819,24 +783,21 @@ transformedNormal = normalMatrix * transformedNormal;
#endif
#ifdef USE_TANGENT
transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
- #ifdef FLIP_SIDED
- transformedTangent = - transformedTangent;
- #endif
-#endif`,tw=`#ifdef USE_DISPLACEMENTMAP
+#endif`,sE=`#ifdef USE_DISPLACEMENTMAP
uniform sampler2D displacementMap;
uniform float displacementScale;
uniform float displacementBias;
-#endif`,nw=`#ifdef USE_DISPLACEMENTMAP
+#endif`,rE=`#ifdef USE_DISPLACEMENTMAP
transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
-#endif`,iw=`#ifdef USE_EMISSIVEMAP
+#endif`,aE=`#ifdef USE_EMISSIVEMAP
vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
emissiveColor = sRGBTransferEOTF( emissiveColor );
#endif
totalEmissiveRadiance *= emissiveColor.rgb;
-#endif`,rw=`#ifdef USE_EMISSIVEMAP
+#endif`,oE=`#ifdef USE_EMISSIVEMAP
uniform sampler2D emissiveMap;
-#endif`,sw="gl_FragColor = linearToOutputTexel( gl_FragColor );",aw=`vec4 LinearTransferOETF( in vec4 value ) {
+#endif`,cE="gl_FragColor = linearToOutputTexel( gl_FragColor );",lE=`vec4 LinearTransferOETF( in vec4 value ) {
return value;
}
vec4 sRGBTransferEOTF( in vec4 value ) {
@@ -844,7 +805,7 @@ vec4 sRGBTransferEOTF( in vec4 value ) {
}
vec4 sRGBTransferOETF( in vec4 value ) {
return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
-}`,ow=`#ifdef USE_ENVMAP
+}`,hE=`#ifdef USE_ENVMAP
#ifdef ENV_WORLDPOS
vec3 cameraToFrag;
if ( isOrthographic ) {
@@ -852,7 +813,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
} else {
cameraToFrag = normalize( vWorldPosition - cameraPosition );
}
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
+ vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix );
#ifdef ENVMAP_MODE_REFLECTION
vec3 reflectVec = reflect( cameraToFrag, worldNormal );
#else
@@ -871,7 +832,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
outgoingLight += envColor.xyz * specularStrength * reflectivity;
#endif
#endif
-#endif`,cw=`#ifdef USE_ENVMAP
+#endif`,uE=`#ifdef USE_ENVMAP
uniform float envMapIntensity;
uniform mat3 envMapRotation;
#ifdef ENVMAP_TYPE_CUBE
@@ -879,7 +840,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
#else
uniform sampler2D envMap;
#endif
-#endif`,lw=`#ifdef USE_ENVMAP
+#endif`,fE=`#ifdef USE_ENVMAP
uniform float reflectivity;
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
#define ENV_WORLDPOS
@@ -890,7 +851,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
#else
varying vec3 vReflect;
#endif
-#endif`,hw=`#ifdef USE_ENVMAP
+#endif`,dE=`#ifdef USE_ENVMAP
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
#define ENV_WORLDPOS
#endif
@@ -901,7 +862,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
varying vec3 vReflect;
uniform float refractionRatio;
#endif
-#endif`,uw=`#ifdef USE_ENVMAP
+#endif`,pE=`#ifdef USE_ENVMAP
#ifdef ENV_WORLDPOS
vWorldPosition = worldPosition.xyz;
#else
@@ -911,25 +872,25 @@ vec4 sRGBTransferOETF( in vec4 value ) {
} else {
cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
}
- vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
+ vec3 worldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix );
#ifdef ENVMAP_MODE_REFLECTION
vReflect = reflect( cameraToVertex, worldNormal );
#else
vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
#endif
#endif
-#endif`,dw=`#ifdef USE_FOG
+#endif`,mE=`#ifdef USE_FOG
vFogDepth = - mvPosition.z;
-#endif`,fw=`#ifdef USE_FOG
+#endif`,gE=`#ifdef USE_FOG
varying float vFogDepth;
-#endif`,pw=`#ifdef USE_FOG
+#endif`,bE=`#ifdef USE_FOG
#ifdef FOG_EXP2
float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
#else
float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
#endif
gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
-#endif`,mw=`#ifdef USE_FOG
+#endif`,_E=`#ifdef USE_FOG
uniform vec3 fogColor;
varying float vFogDepth;
#ifdef FOG_EXP2
@@ -938,7 +899,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
uniform float fogNear;
uniform float fogFar;
#endif
-#endif`,gw=`#ifdef USE_GRADIENTMAP
+#endif`,xE=`#ifdef USE_GRADIENTMAP
uniform sampler2D gradientMap;
#endif
vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
@@ -950,12 +911,12 @@ vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
vec2 fw = fwidth( coord ) * 0.5;
return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
#endif
-}`,bw=`#ifdef USE_LIGHTMAP
+}`,yE=`#ifdef USE_LIGHTMAP
uniform sampler2D lightMap;
uniform float lightMapIntensity;
-#endif`,xw=`LambertMaterial material;
+#endif`,vE=`LambertMaterial material;
material.diffuseColor = diffuseColor.rgb;
-material.specularStrength = specularStrength;`,_w=`varying vec3 vViewPosition;
+material.specularStrength = specularStrength;`,SE=`varying vec3 vViewPosition;
struct LambertMaterial {
vec3 diffuseColor;
float specularStrength;
@@ -969,7 +930,7 @@ void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometr
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
#define RE_Direct RE_Direct_Lambert
-#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,yw=`uniform bool receiveShadow;
+#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,wE=`uniform bool receiveShadow;
uniform vec3 ambientLightColor;
#if defined( USE_LIGHT_PROBES )
uniform vec3 lightProbe[ 9 ];
@@ -988,7 +949,7 @@ vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
return result;
}
vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
+ vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix );
vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
return irradiance;
}
@@ -1006,6 +967,18 @@ float getDistanceAttenuation( const in float lightDistance, const in float cutof
float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
return smoothstep( coneCosine, penumbraCosine, angleCosine );
}
+#if NUM_SUN_LIGHTS > 0
+ struct SunLight {
+ vec3 direction;
+ vec3 color;
+ };
+ uniform SunLight sunLights[ NUM_SUN_LIGHTS ];
+ void getSunLightInfo( const in SunLight sunLight, out IncidentLight light ) {
+ light.color = sunLight.color;
+ light.direction = sunLight.direction;
+ light.visible = true;
+ }
+#endif
#if NUM_DIR_LIGHTS > 0
struct DirectionalLight {
vec3 direction;
@@ -1086,10 +1059,10 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
return irradiance;
}
#endif
-#include <lightprobes_pars_fragment>`,vw=`#ifdef USE_ENVMAP
+#include <lightprobes_pars_fragment>`,ME=`#ifdef USE_ENVMAP
vec3 getIBLIrradiance( const in vec3 normal ) {
#ifdef ENVMAP_TYPE_CUBE_UV
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
+ vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix );
vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );
return PI * envMapColor.rgb * envMapIntensity;
#else
@@ -1100,13 +1073,25 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
#ifdef ENVMAP_TYPE_CUBE_UV
vec3 reflectVec = reflect( - viewDir, normal );
reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) );
- reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
+ reflectVec = transformDirectionByInverseViewMatrix( reflectVec, viewMatrix );
vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );
return envMapColor.rgb * envMapIntensity;
#else
return vec3( 0.0 );
#endif
}
+ #ifdef USE_RETROREFLECTION
+ vec3 getIBLRetroRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
+ #ifdef ENVMAP_TYPE_CUBE_UV
+ vec3 retroVec = normalize( mix( viewDir, normal, pow4( roughness ) ) );
+ retroVec = transformDirectionByInverseViewMatrix( retroVec, viewMatrix );
+ vec4 envMapColor = textureCubeUV( envMap, envMapRotation * retroVec, roughness );
+ return envMapColor.rgb * envMapIntensity;
+ #else
+ return vec3( 0.0 );
+ #endif
+ }
+ #endif
#ifdef USE_ANISOTROPY
vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
#ifdef ENVMAP_TYPE_CUBE_UV
@@ -1118,9 +1103,21 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
return vec3( 0.0 );
#endif
}
+ #ifdef USE_RETROREFLECTION
+ vec3 getIBLAnisotropyRetroRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
+ #ifdef ENVMAP_TYPE_CUBE_UV
+ vec3 bentNormal = cross( bitangent, viewDir );
+ bentNormal = normalize( cross( bentNormal, bitangent ) );
+ bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
+ return getIBLRetroRadiance( viewDir, bentNormal, roughness );
+ #else
+ return vec3( 0.0 );
+ #endif
+ }
+ #endif
#endif
-#endif`,Sw=`ToonMaterial material;
-material.diffuseColor = diffuseColor.rgb;`,ww=`varying vec3 vViewPosition;
+#endif`,EE=`ToonMaterial material;
+material.diffuseColor = diffuseColor.rgb;`,AE=`varying vec3 vViewPosition;
struct ToonMaterial {
vec3 diffuseColor;
};
@@ -1132,11 +1129,11 @@ void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPo
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
#define RE_Direct RE_Direct_Toon
-#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,Mw=`BlinnPhongMaterial material;
+#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,TE=`BlinnPhongMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularColor = specular;
material.specularShininess = shininess;
-material.specularStrength = specularStrength;`,Aw=`varying vec3 vViewPosition;
+material.specularStrength = specularStrength;`,RE=`varying vec3 vViewPosition;
struct BlinnPhongMaterial {
vec3 diffuseColor;
vec3 specularColor;
@@ -1153,7 +1150,7 @@ void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geom
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
#define RE_Direct RE_Direct_BlinnPhong
-#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,Tw=`PhysicalMaterial material;
+#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,CE=`PhysicalMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor );
material.metalness = metalnessFactor;
@@ -1203,6 +1200,9 @@ material.roughness = min( material.roughness, 1.0 );
#ifdef USE_DISPERSION
material.dispersion = dispersion;
#endif
+#ifdef USE_RETROREFLECTION
+ material.retroreflectivity = retroreflectivity;
+#endif
#ifdef USE_IRIDESCENCE
material.iridescence = iridescence;
material.iridescenceIOR = iridescenceIOR;
@@ -1243,7 +1243,7 @@ material.roughness = min( material.roughness, 1.0 );
material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
-#endif`,Ew=`uniform sampler2D dfgLUT;
+#endif`,IE=`uniform sampler2D dfgLUT;
struct PhysicalMaterial {
vec3 diffuseColor;
vec3 diffuseContribution;
@@ -1253,6 +1253,11 @@ struct PhysicalMaterial {
float metalness;
float specularF90;
float dispersion;
+ vec2 dfg;
+ vec3 multiScatteringCompensation;
+ #ifdef USE_RETROREFLECTION
+ float retroreflectivity;
+ #endif
#ifdef USE_CLEARCOAT
float clearcoat;
float clearcoatRoughness;
@@ -1264,9 +1269,8 @@ struct PhysicalMaterial {
float iridescenceIOR;
float iridescenceThickness;
vec3 iridescenceFresnel;
- vec3 iridescenceF0;
- vec3 iridescenceFresnelDielectric;
- vec3 iridescenceFresnelMetallic;
+ vec3 iridescenceF0Dielectric;
+ vec3 iridescenceF0Metallic;
#endif
#ifdef USE_SHEEN
vec3 sheenColor;
@@ -1454,12 +1458,10 @@ vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3
return specularColor * fab.x + specularF90 * fab.y;
}
#ifdef USE_IRIDESCENCE
-void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
+void computeMultiscatteringIridescence( const in vec2 fab, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, inout vec3 singleScatter, inout vec3 multiScatter ) {
#else
-void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
+void computeMultiscattering( const in vec2 fab, const in vec3 specularColor, const in float specularF90, inout vec3 singleScatter, inout vec3 multiScatter ) {
#endif
- float dotNV = saturate( dot( normal, viewDir ) );
- vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;
#ifdef USE_IRIDESCENCE
vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
#else
@@ -1472,24 +1474,6 @@ void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const
singleScatter += FssEss;
multiScatter += Fms * Ems;
}
-vec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
- vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- vec2 dfgV = texture2D( dfgLUT, vec2( material.roughness, dotNV ) ).rg;
- vec2 dfgL = texture2D( dfgLUT, vec2( material.roughness, dotNL ) ).rg;
- vec3 FssEss_V = material.specularColorBlended * dfgV.x + material.specularF90 * dfgV.y;
- vec3 FssEss_L = material.specularColorBlended * dfgL.x + material.specularF90 * dfgL.y;
- float Ess_V = dfgV.x + dfgV.y;
- float Ess_L = dfgL.x + dfgL.y;
- float Ems_V = 1.0 - Ess_V;
- float Ems_L = 1.0 - Ess_L;
- vec3 Favg = material.specularColorBlended + ( 1.0 - material.specularColorBlended ) * 0.047619;
- vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg + EPSILON );
- float compensationFactor = Ems_V * Ems_L;
- vec3 multiScatter = Fms * compensationFactor;
- return singleScatter + multiScatter;
-}
#if NUM_RECT_AREA_LIGHTS > 0
void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
vec3 normal = geometryNormal;
@@ -1550,13 +1534,36 @@ void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geome
irradiance *= sheenEnergyComp;
#endif
- reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseContribution );
+ vec3 specularBRDF = BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );
+ #ifdef USE_RETROREFLECTION
+ vec3 retroViewDir = reflect( - geometryViewDir, geometryNormal );
+ vec3 retroSpecularBRDF = BRDF_GGX( directLight.direction, retroViewDir, geometryNormal, material );
+ specularBRDF = mix( specularBRDF, retroSpecularBRDF, saturate( material.retroreflectivity ) );
+ #endif
+ reflectedLight.directSpecular += irradiance * specularBRDF * material.multiScatteringCompensation;
+ vec3 halfDir = normalize( directLight.direction + geometryViewDir );
+ float dotVH = saturate( dot( geometryViewDir, halfDir ) );
+ vec3 F = F_Schlick( material.specularColor, material.specularF90, dotVH );
+ #ifdef USE_RETROREFLECTION
+ vec3 retroHalfDir = normalize( directLight.direction + retroViewDir );
+ float dotRetroVH = saturate( dot( retroViewDir, retroHalfDir ) );
+ vec3 retroF = F_Schlick( material.specularColor, material.specularF90, dotRetroVH );
+ F = mix( F, retroF, saturate( material.retroreflectivity ) );
+ #endif
+ reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseContribution ) * ( 1.0 - F );
}
void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
- vec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution );
+ vec3 singleScattering = vec3( 0.0 );
+ vec3 multiScattering = vec3( 0.0 );
+ #ifdef USE_IRIDESCENCE
+ computeMultiscatteringIridescence( material.dfg, material.specularColor, material.specularF90, material.iridescence, material.iridescenceF0Dielectric, singleScattering, multiScattering );
+ #else
+ computeMultiscattering( material.dfg, material.specularColor, material.specularF90, singleScattering, multiScattering );
+ #endif
+ vec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution ) * ( 1.0 - singleScattering - multiScattering );
#ifdef USE_SHEEN
float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
+ sheenSpecularIndirect += irradiance * material.sheenColor * sheenAlbedo * RECIPROCAL_PI;
float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;
diffuse *= sheenEnergyComp;
#endif
@@ -1574,11 +1581,11 @@ void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradia
vec3 singleScatteringMetallic = vec3( 0.0 );
vec3 multiScatteringMetallic = vec3( 0.0 );
#ifdef USE_IRIDESCENCE
- computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnelDielectric, material.roughness, singleScatteringDielectric, multiScatteringDielectric );
- computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceFresnelMetallic, material.roughness, singleScatteringMetallic, multiScatteringMetallic );
+ computeMultiscatteringIridescence( material.dfg, material.specularColor, material.specularF90, material.iridescence, material.iridescenceF0Dielectric, singleScatteringDielectric, multiScatteringDielectric );
+ computeMultiscatteringIridescence( material.dfg, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceF0Metallic, singleScatteringMetallic, multiScatteringMetallic );
#else
- computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScatteringDielectric, multiScatteringDielectric );
- computeMultiscattering( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.roughness, singleScatteringMetallic, multiScatteringMetallic );
+ computeMultiscattering( material.dfg, material.specularColor, material.specularF90, singleScatteringDielectric, multiScatteringDielectric );
+ computeMultiscattering( material.dfg, material.diffuseColor, material.specularF90, singleScatteringMetallic, multiScatteringMetallic );
#endif
vec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness );
vec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness );
@@ -1603,7 +1610,7 @@ void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradia
#define RE_IndirectSpecular RE_IndirectSpecular_Physical
float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
-}`,Rw=`
+}`,PE=`
vec3 geometryPosition = - vViewPosition;
vec3 geometryNormal = normal;
vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
@@ -1619,12 +1626,21 @@ vec3 geometryClearcoatNormal = vec3( 0.0 );
material.iridescence = saturate( material.iridescence );
}
if ( material.iridescence > 0.0 ) {
- material.iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
- material.iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor );
- material.iridescenceFresnel = mix( material.iridescenceFresnelDielectric, material.iridescenceFresnelMetallic, material.metalness );
- material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
+ vec3 iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
+ vec3 iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor );
+ material.iridescenceFresnel = mix( iridescenceFresnelDielectric, iridescenceFresnelMetallic, material.metalness );
+ material.iridescenceF0Dielectric = Schlick_to_F0( iridescenceFresnelDielectric, 1.0, dotNVi );
+ material.iridescenceF0Metallic = Schlick_to_F0( iridescenceFresnelMetallic, 1.0, dotNVi );
}
#endif
+#ifdef STANDARD
+ float dotNVms = saturate( dot( geometryNormal, geometryViewDir ) );
+ material.dfg = texture2D( dfgLUT, vec2( material.roughness, dotNVms ) ).rg;
+ #if ( NUM_SUN_LIGHTS > 0 || NUM_DIR_LIGHTS > 0 || NUM_POINT_LIGHTS > 0 || NUM_SPOT_LIGHTS > 0 )
+ float EssMs = material.dfg.x + material.dfg.y;
+ material.multiScatteringCompensation = 1.0 + material.specularColorBlended * ( 1.0 / EssMs - 1.0 );
+ #endif
+#endif
IncidentLight directLight;
#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
PointLight pointLight;
@@ -1677,6 +1693,23 @@ IncidentLight directLight;
}
#pragma unroll_loop_end
#endif
+#if ( NUM_SUN_LIGHTS > 0 ) && defined( RE_Direct )
+ SunLight sunLight;
+ #if defined( USE_SHADOWMAP ) && NUM_SUN_LIGHT_SHADOWS > 0
+ SunLightShadow sunLightShadow;
+ #endif
+ #pragma unroll_loop_start
+ for ( int i = 0; i < NUM_SUN_LIGHTS; i ++ ) {
+ sunLight = sunLights[ i ];
+ getSunLightInfo( sunLight, directLight );
+ #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SUN_LIGHT_SHADOWS )
+ sunLightShadow = sunLightShadows[ i ];
+ directLight.color *= ( directLight.visible && receiveShadow ) ? getSunShadow( sunShadowMap[ i ], sunLightShadow, UNROLLED_LOOP_INDEX ) : 1.0;
+ #endif
+ RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
+ }
+ #pragma unroll_loop_end
+#endif
#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
DirectionalLight directionalLight;
#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
@@ -1718,14 +1751,14 @@ IncidentLight directLight;
#endif
#ifdef USE_LIGHT_PROBES_GRID
vec3 probeWorldPos = ( ( vec4( geometryPosition, 1.0 ) - viewMatrix[ 3 ] ) * viewMatrix ).xyz;
- vec3 probeWorldNormal = inverseTransformDirection( geometryNormal, viewMatrix );
+ vec3 probeWorldNormal = transformNormalByInverseViewMatrix( geometryNormal, viewMatrix );
irradiance += getLightProbeGridIrradiance( probeWorldPos, probeWorldNormal );
#endif
#endif
#if defined( RE_IndirectSpecular )
vec3 radiance = vec3( 0.0 );
vec3 clearcoatRadiance = vec3( 0.0 );
-#endif`,Cw=`#if defined( RE_IndirectDiffuse )
+#endif`,LE=`#if defined( RE_IndirectDiffuse )
#ifdef USE_LIGHTMAP
vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
@@ -1739,14 +1772,23 @@ IncidentLight directLight;
#endif
#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
#ifdef USE_ANISOTROPY
- radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
+ vec3 iblRadiance = getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
#else
- radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
+ vec3 iblRadiance = getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
#endif
+ #ifdef USE_RETROREFLECTION
+ #ifdef USE_ANISOTROPY
+ vec3 retroIBLRadiance = getIBLAnisotropyRetroRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
+ #else
+ vec3 retroIBLRadiance = getIBLRetroRadiance( geometryViewDir, geometryNormal, material.roughness );
+ #endif
+ iblRadiance = mix( iblRadiance, retroIBLRadiance, saturate( material.retroreflectivity ) );
+ #endif
+ radiance += iblRadiance;
#ifdef USE_CLEARCOAT
clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
#endif
-#endif`,Iw=`#if defined( RE_IndirectDiffuse )
+#endif`,DE=`#if defined( RE_IndirectDiffuse )
#if defined( LAMBERT ) || defined( PHONG )
irradiance += iblIrradiance;
#endif
@@ -1754,7 +1796,7 @@ IncidentLight directLight;
#endif
#if defined( RE_IndirectSpecular )
RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
-#endif`,Pw=`#ifdef USE_LIGHT_PROBES_GRID
+#endif`,NE=`#ifdef USE_LIGHT_PROBES_GRID
uniform highp sampler3D probesSH;
uniform vec3 probesMin;
uniform vec3 probesMax;
@@ -1799,27 +1841,27 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
result += c8 * 0.429043 * ( x * x - y * y );
return max( result, vec3( 0.0 ) );
}
-#endif`,Lw=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
+#endif`,OE=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
-#endif`,Dw=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
+#endif`,FE=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
uniform float logDepthBufFC;
varying float vFragDepth;
varying float vIsPerspective;
-#endif`,Nw=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
+#endif`,kE=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
varying float vFragDepth;
varying float vIsPerspective;
-#endif`,Ow=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
+#endif`,UE=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
vFragDepth = 1.0 + gl_Position.w;
vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
-#endif`,Fw=`#ifdef USE_MAP
+#endif`,BE=`#ifdef USE_MAP
vec4 sampledDiffuseColor = texture2D( map, vMapUv );
#ifdef DECODE_VIDEO_TEXTURE
sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
#endif
diffuseColor *= sampledDiffuseColor;
-#endif`,Uw=`#ifdef USE_MAP
+#endif`,zE=`#ifdef USE_MAP
uniform sampler2D map;
-#endif`,kw=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
+#endif`,HE=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
#if defined( USE_POINTS_UV )
vec2 uv = vUv;
#else
@@ -1831,7 +1873,7 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
#endif
#ifdef USE_ALPHAMAP
diffuseColor.a *= texture2D( alphaMap, uv ).g;
-#endif`,Bw=`#if defined( USE_POINTS_UV )
+#endif`,VE=`#if defined( USE_POINTS_UV )
varying vec2 vUv;
#else
#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
@@ -1843,19 +1885,19 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
#endif
#ifdef USE_ALPHAMAP
uniform sampler2D alphaMap;
-#endif`,zw=`float metalnessFactor = metalness;
+#endif`,GE=`float metalnessFactor = metalness;
#ifdef USE_METALNESSMAP
vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
metalnessFactor *= texelMetalness.b;
-#endif`,Hw=`#ifdef USE_METALNESSMAP
+#endif`,WE=`#ifdef USE_METALNESSMAP
uniform sampler2D metalnessMap;
-#endif`,Gw=`#ifdef USE_INSTANCING_MORPH
+#endif`,$E=`#ifdef USE_INSTANCING_MORPH
float morphTargetInfluences[ MORPHTARGETS_COUNT ];
float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
}
-#endif`,Vw=`#if defined( USE_MORPHCOLORS )
+#endif`,qE=`#if defined( USE_MORPHCOLORS )
vColor *= morphTargetBaseInfluence;
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
#if defined( USE_COLOR_ALPHA )
@@ -1864,12 +1906,12 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
#endif
}
-#endif`,Ww=`#ifdef USE_MORPHNORMALS
+#endif`,jE=`#ifdef USE_MORPHNORMALS
objectNormal *= morphTargetBaseInfluence;
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
}
-#endif`,qw=`#ifdef USE_MORPHTARGETS
+#endif`,XE=`#ifdef USE_MORPHTARGETS
#ifndef USE_INSTANCING_MORPH
uniform float morphTargetBaseInfluence;
uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
@@ -1883,12 +1925,12 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
ivec3 morphUV = ivec3( x, y, morphTargetIndex );
return texelFetch( morphTargetsTexture, morphUV, 0 );
}
-#endif`,$w=`#ifdef USE_MORPHTARGETS
+#endif`,KE=`#ifdef USE_MORPHTARGETS
transformed *= morphTargetBaseInfluence;
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
}
-#endif`,jw=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
+#endif`,YE=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
#ifdef FLAT_SHADED
vec3 fdx = dFdx( vViewPosition );
vec3 fdy = dFdy( vViewPosition );
@@ -1913,7 +1955,7 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
#endif
);
#endif
- #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
+ #ifdef DOUBLE_SIDED
tbn[0] *= faceDirection;
tbn[1] *= faceDirection;
#endif
@@ -1924,12 +1966,12 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
#else
mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
#endif
- #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
+ #ifdef DOUBLE_SIDED
tbn2[0] *= faceDirection;
tbn2[1] *= faceDirection;
#endif
#endif
-vec3 nonPerturbedNormal = normal;`,Xw=`#ifdef USE_NORMALMAP_OBJECTSPACE
+vec3 nonPerturbedNormal = normal;`,JE=`#ifdef USE_NORMALMAP_OBJECTSPACE
normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
#ifdef FLIP_SIDED
normal = - normal;
@@ -1947,25 +1989,28 @@ vec3 nonPerturbedNormal = normal;`,Xw=`#ifdef USE_NORMALMAP_OBJECTSPACE
normal = normalize( tbn * mapN );
#elif defined( USE_BUMPMAP )
normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
-#endif`,Kw=`#ifndef FLAT_SHADED
+#endif`,ZE=`#ifndef FLAT_SHADED
varying vec3 vNormal;
#ifdef USE_TANGENT
varying vec3 vTangent;
varying vec3 vBitangent;
#endif
-#endif`,Yw=`#ifndef FLAT_SHADED
+#endif`,QE=`#ifndef FLAT_SHADED
varying vec3 vNormal;
#ifdef USE_TANGENT
varying vec3 vTangent;
varying vec3 vBitangent;
#endif
-#endif`,Jw=`#ifndef FLAT_SHADED
+#endif`,eA=`#ifndef FLAT_SHADED
vNormal = normalize( transformedNormal );
#ifdef USE_TANGENT
vTangent = normalize( transformedTangent );
vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
+ #ifdef FLIP_SIDED
+ vBitangent = - vBitangent;
+ #endif
#endif
-#endif`,Zw=`#ifdef USE_NORMALMAP
+#endif`,tA=`#ifdef USE_NORMALMAP
uniform sampler2D normalMap;
uniform vec2 normalScale;
#endif
@@ -1987,13 +2032,13 @@ vec3 nonPerturbedNormal = normal;`,Xw=`#ifdef USE_NORMALMAP_OBJECTSPACE
float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
return mat3( T * scale, B * scale, N );
}
-#endif`,Qw=`#ifdef USE_CLEARCOAT
+#endif`,nA=`#ifdef USE_CLEARCOAT
vec3 clearcoatNormal = nonPerturbedNormal;
-#endif`,e1=`#ifdef USE_CLEARCOAT_NORMALMAP
+#endif`,iA=`#ifdef USE_CLEARCOAT_NORMALMAP
vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
clearcoatMapN.xy *= clearcoatNormalScale;
clearcoatNormal = normalize( tbn2 * clearcoatMapN );
-#endif`,t1=`#ifdef USE_CLEARCOATMAP
+#endif`,sA=`#ifdef USE_CLEARCOATMAP
uniform sampler2D clearcoatMap;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
@@ -2002,18 +2047,18 @@ vec3 nonPerturbedNormal = normal;`,Xw=`#ifdef USE_NORMALMAP_OBJECTSPACE
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
uniform sampler2D clearcoatRoughnessMap;
-#endif`,n1=`#ifdef USE_IRIDESCENCEMAP
+#endif`,rA=`#ifdef USE_IRIDESCENCEMAP
uniform sampler2D iridescenceMap;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
uniform sampler2D iridescenceThicknessMap;
-#endif`,i1=`#ifdef OPAQUE
+#endif`,aA=`#ifdef OPAQUE
diffuseColor.a = 1.0;
#endif
#ifdef USE_TRANSMISSION
diffuseColor.a *= material.transmissionAlpha;
#endif
-gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,r1=`vec3 packNormalToRGB( const in vec3 normal ) {
+gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,oA=`vec3 packNormalToRGB( const in vec3 normal ) {
return normalize( normal ) * 0.5 + 0.5;
}
vec3 unpackRGBToNormal( const in vec3 rgb ) {
@@ -2092,9 +2137,9 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const
#else
return ( near * far ) / ( ( far - near ) * depth - far );
#endif
-}`,s1=`#ifdef PREMULTIPLIED_ALPHA
+}`,cA=`#ifdef PREMULTIPLIED_ALPHA
gl_FragColor.rgb *= gl_FragColor.a;
-#endif`,a1=`vec4 mvPosition = vec4( transformed, 1.0 );
+#endif`,lA=`vec4 mvPosition = vec4( transformed, 1.0 );
#ifdef USE_BATCHING
mvPosition = batchingMatrix * mvPosition;
#endif
@@ -2102,28 +2147,48 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const
mvPosition = instanceMatrix * mvPosition;
#endif
mvPosition = modelViewMatrix * mvPosition;
-gl_Position = projectionMatrix * mvPosition;`,o1=`#ifdef DITHERING
+gl_Position = projectionMatrix * mvPosition;`,hA=`#ifdef DITHERING
gl_FragColor.rgb = dithering( gl_FragColor.rgb );
-#endif`,c1=`#ifdef DITHERING
+#endif`,uA=`#ifdef DITHERING
vec3 dithering( vec3 color ) {
float grid_position = rand( gl_FragCoord.xy );
vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
return color + dither_shift_RGB;
}
-#endif`,l1=`float roughnessFactor = roughness;
+#endif`,fA=`float roughnessFactor = roughness;
#ifdef USE_ROUGHNESSMAP
vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
roughnessFactor *= texelRoughness.g;
-#endif`,h1=`#ifdef USE_ROUGHNESSMAP
+#endif`,dA=`#ifdef USE_ROUGHNESSMAP
uniform sampler2D roughnessMap;
-#endif`,u1=`#if NUM_SPOT_LIGHT_COORDS > 0
+#endif`,pA=`#if NUM_SPOT_LIGHT_COORDS > 0
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
#endif
#if NUM_SPOT_LIGHT_MAPS > 0
uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
#endif
#ifdef USE_SHADOWMAP
+ #if NUM_SUN_LIGHT_SHADOWS > 0
+ #define SUN_LIGHT_CASCADES 2
+ #if defined( SHADOWMAP_TYPE_PCF )
+ uniform sampler2DShadow sunShadowMap[ NUM_SUN_LIGHT_SHADOWS ];
+ #else
+ uniform sampler2D sunShadowMap[ NUM_SUN_LIGHT_SHADOWS ];
+ #endif
+ uniform mat4 sunShadowMatrix[ NUM_SUN_LIGHT_SHADOWS * SUN_LIGHT_CASCADES ];
+ uniform vec4 sunShadowCascade[ NUM_SUN_LIGHT_SHADOWS * SUN_LIGHT_CASCADES ];
+ varying vec4 vSunShadowWorldPosition;
+ varying vec3 vSunShadowWorldNormal;
+ struct SunLightShadow {
+ float shadowIntensity;
+ float shadowBias;
+ float shadowNormalBias;
+ float shadowRadius;
+ vec2 shadowMapSize;
+ };
+ uniform SunLightShadow sunLightShadows[ NUM_SUN_LIGHT_SHADOWS ];
+ #endif
#if NUM_DIR_LIGHT_SHADOWS > 0
#if defined( SHADOWMAP_TYPE_PCF )
uniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
@@ -2260,6 +2325,37 @@ gl_Position = projectionMatrix * mvPosition;`,o1=`#ifdef DITHERING
return mix( 1.0, shadow, shadowIntensity );
}
#endif
+ #if NUM_SUN_LIGHT_SHADOWS > 0
+ float getSunShadow(
+ #if defined( SHADOWMAP_TYPE_PCF )
+ sampler2DShadow shadowMap,
+ #else
+ sampler2D shadowMap,
+ #endif
+ SunLightShadow sunLightShadow,
+ int shadowIndex
+ ) {
+ vec4 shadowWorldPosition = vec4( vSunShadowWorldPosition.xyz + vSunShadowWorldNormal * sunLightShadow.shadowNormalBias, 1.0 );
+ float viewDepth = vSunShadowWorldPosition.w;
+ int cascadeOffset = shadowIndex * SUN_LIGHT_CASCADES;
+ float shadow = 1.0;
+ for ( int i = SUN_LIGHT_CASCADES - 1; i >= 0; i -- ) {
+ vec4 cascade = sunShadowCascade[ cascadeOffset + i ];
+ if ( viewDepth >= cascade.x && viewDepth < cascade.y ) {
+ float cascadeShadow = getShadow(
+ shadowMap,
+ sunLightShadow.shadowMapSize,
+ sunLightShadow.shadowIntensity,
+ sunLightShadow.shadowBias,
+ sunLightShadow.shadowRadius,
+ sunShadowMatrix[ cascadeOffset + i ] * shadowWorldPosition
+ );
+ shadow = mix( cascadeShadow, shadow, smoothstep( cascade.z, cascade.y, viewDepth ) );
+ }
+ }
+ return shadow;
+ }
+ #endif
#if NUM_POINT_LIGHT_SHADOWS > 0
#if defined( SHADOWMAP_TYPE_PCF )
float getPointShadow( samplerCubeShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
@@ -2317,11 +2413,15 @@ gl_Position = projectionMatrix * mvPosition;`,o1=`#ifdef DITHERING
}
#endif
#endif
-#endif`,d1=`#if NUM_SPOT_LIGHT_COORDS > 0
+#endif`,mA=`#if NUM_SPOT_LIGHT_COORDS > 0
uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
#endif
#ifdef USE_SHADOWMAP
+ #if NUM_SUN_LIGHT_SHADOWS > 0
+ varying vec4 vSunShadowWorldPosition;
+ varying vec3 vSunShadowWorldNormal;
+ #endif
#if NUM_DIR_LIGHT_SHADOWS > 0
uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
@@ -2358,15 +2458,19 @@ gl_Position = projectionMatrix * mvPosition;`,o1=`#ifdef DITHERING
};
uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
#endif
-#endif`,f1=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
+#endif`,gA=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SUN_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
#ifdef HAS_NORMAL
- vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
+ vec3 shadowWorldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix );
#else
vec3 shadowWorldNormal = vec3( 0.0 );
#endif
vec4 shadowWorldPosition;
#endif
#if defined( USE_SHADOWMAP )
+ #if NUM_SUN_LIGHT_SHADOWS > 0
+ vSunShadowWorldPosition = vec4( worldPosition.xyz, - mvPosition.z );
+ vSunShadowWorldNormal = shadowWorldNormal;
+ #endif
#if NUM_DIR_LIGHT_SHADOWS > 0
#pragma unroll_loop_start
for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
@@ -2394,9 +2498,18 @@ gl_Position = projectionMatrix * mvPosition;`,o1=`#ifdef DITHERING
vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
}
#pragma unroll_loop_end
-#endif`,p1=`float getShadowMask() {
+#endif`,bA=`float getShadowMask() {
float shadow = 1.0;
#ifdef USE_SHADOWMAP
+ #if NUM_SUN_LIGHT_SHADOWS > 0
+ SunLightShadow sunLight;
+ #pragma unroll_loop_start
+ for ( int i = 0; i < NUM_SUN_LIGHT_SHADOWS; i ++ ) {
+ sunLight = sunLightShadows[ i ];
+ shadow *= receiveShadow ? getSunShadow( sunShadowMap[ i ], sunLight, UNROLLED_LOOP_INDEX ) : 1.0;
+ }
+ #pragma unroll_loop_end
+ #endif
#if NUM_DIR_LIGHT_SHADOWS > 0
DirectionalLightShadow directionalLight;
#pragma unroll_loop_start
@@ -2426,12 +2539,12 @@ gl_Position = projectionMatrix * mvPosition;`,o1=`#ifdef DITHERING
#endif
#endif
return shadow;
-}`,m1=`#ifdef USE_SKINNING
+}`,_A=`#ifdef USE_SKINNING
mat4 boneMatX = getBoneMatrix( skinIndex.x );
mat4 boneMatY = getBoneMatrix( skinIndex.y );
mat4 boneMatZ = getBoneMatrix( skinIndex.z );
mat4 boneMatW = getBoneMatrix( skinIndex.w );
-#endif`,g1=`#ifdef USE_SKINNING
+#endif`,xA=`#ifdef USE_SKINNING
uniform mat4 bindMatrix;
uniform mat4 bindMatrixInverse;
uniform highp sampler2D boneTexture;
@@ -2446,7 +2559,7 @@ gl_Position = projectionMatrix * mvPosition;`,o1=`#ifdef DITHERING
vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
return mat4( v1, v2, v3, v4 );
}
-#endif`,b1=`#ifdef USE_SKINNING
+#endif`,yA=`#ifdef USE_SKINNING
vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
vec4 skinned = vec4( 0.0 );
skinned += boneMatX * skinVertex * skinWeight.x;
@@ -2454,7 +2567,7 @@ gl_Position = projectionMatrix * mvPosition;`,o1=`#ifdef DITHERING
skinned += boneMatZ * skinVertex * skinWeight.z;
skinned += boneMatW * skinVertex * skinWeight.w;
transformed = ( bindMatrixInverse * skinned ).xyz;
-#endif`,x1=`#ifdef USE_SKINNING
+#endif`,vA=`#ifdef USE_SKINNING
mat4 skinMatrix = mat4( 0.0 );
skinMatrix += skinWeight.x * boneMatX;
skinMatrix += skinWeight.y * boneMatY;
@@ -2465,17 +2578,17 @@ gl_Position = projectionMatrix * mvPosition;`,o1=`#ifdef DITHERING
#ifdef USE_TANGENT
objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
#endif
-#endif`,_1=`float specularStrength;
+#endif`,SA=`float specularStrength;
#ifdef USE_SPECULARMAP
vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
specularStrength = texelSpecular.r;
#else
specularStrength = 1.0;
-#endif`,y1=`#ifdef USE_SPECULARMAP
+#endif`,wA=`#ifdef USE_SPECULARMAP
uniform sampler2D specularMap;
-#endif`,v1=`#if defined( TONE_MAPPING )
+#endif`,MA=`#if defined( TONE_MAPPING )
gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
-#endif`,S1=`#ifndef saturate
+#endif`,EA=`#ifndef saturate
#define saturate( a ) clamp( a, 0.0, 1.0 )
#endif
uniform float toneMappingExposure;
@@ -2572,7 +2685,7 @@ vec3 NeutralToneMapping( vec3 color ) {
float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
return mix( color, vec3( newPeak ), g );
}
-vec3 CustomToneMapping( vec3 color ) { return color; }`,w1=`#ifdef USE_TRANSMISSION
+vec3 CustomToneMapping( vec3 color ) { return color; }`,AA=`#ifdef USE_TRANSMISSION
material.transmission = transmission;
material.transmissionAlpha = 1.0;
material.thickness = thickness;
@@ -2586,14 +2699,14 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,w1=`#ifdef USE_TRANSMISS
#endif
vec3 pos = vWorldPosition;
vec3 v = normalize( cameraPosition - pos );
- vec3 n = inverseTransformDirection( normal, viewMatrix );
+ vec3 n = transformNormalByInverseViewMatrix( normal, viewMatrix );
vec4 transmitted = getIBLVolumeRefraction(
n, v, material.roughness, material.diffuseContribution, material.specularColorBlended, material.specularF90,
pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,
material.attenuationColor, material.attenuationDistance );
material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
-#endif`,M1=`#ifdef USE_TRANSMISSION
+#endif`,TA=`#ifdef USE_TRANSMISSION
uniform float transmission;
uniform float thickness;
uniform float attenuationDistance;
@@ -2719,7 +2832,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,w1=`#ifdef USE_TRANSMISS
float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
}
-#endif`,A1=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
+#endif`,RA=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
varying vec2 vUv;
#endif
#ifdef USE_MAP
@@ -2789,7 +2902,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,w1=`#ifdef USE_TRANSMISS
#ifdef USE_THICKNESSMAP
uniform mat3 thicknessMapTransform;
varying vec2 vThicknessMapUv;
-#endif`,T1=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
+#endif`,CA=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
varying vec2 vUv;
#endif
#ifdef USE_MAP
@@ -2883,7 +2996,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,w1=`#ifdef USE_TRANSMISS
#ifdef USE_THICKNESSMAP
uniform mat3 thicknessMapTransform;
varying vec2 vThicknessMapUv;
-#endif`,E1=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
+#endif`,IA=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
vUv = vec3( uv, 1 ).xy;
#endif
#ifdef USE_MAP
@@ -2954,7 +3067,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,w1=`#ifdef USE_TRANSMISS
#endif
#ifdef USE_THICKNESSMAP
vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
-#endif`,R1=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
+#endif`,PA=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
vec4 worldPosition = vec4( transformed, 1.0 );
#ifdef USE_BATCHING
worldPosition = batchingMatrix * worldPosition;
@@ -2963,12 +3076,12 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,w1=`#ifdef USE_TRANSMISS
worldPosition = instanceMatrix * worldPosition;
#endif
worldPosition = modelMatrix * worldPosition;
-#endif`,C1=`varying vec2 vUv;
+#endif`,LA=`varying vec2 vUv;
uniform mat3 uvTransform;
void main() {
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
gl_Position = vec4( position.xy, 1.0, 1.0 );
-}`,I1=`uniform sampler2D t2D;
+}`,DA=`uniform sampler2D t2D;
uniform float backgroundIntensity;
varying vec2 vUv;
void main() {
@@ -2980,14 +3093,14 @@ void main() {
gl_FragColor = texColor;
#include <tonemapping_fragment>
#include <colorspace_fragment>
-}`,P1=`varying vec3 vWorldDirection;
+}`,NA=`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
gl_Position.z = gl_Position.w;
-}`,L1=`#ifdef ENVMAP_TYPE_CUBE
+}`,OA=`#ifdef ENVMAP_TYPE_CUBE
uniform samplerCube envMap;
#elif defined( ENVMAP_TYPE_CUBE_UV )
uniform sampler2D envMap;
@@ -3009,14 +3122,14 @@ void main() {
gl_FragColor = texColor;
#include <tonemapping_fragment>
#include <colorspace_fragment>
-}`,D1=`varying vec3 vWorldDirection;
+}`,FA=`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
gl_Position.z = gl_Position.w;
-}`,N1=`uniform samplerCube tCube;
+}`,kA=`uniform samplerCube tCube;
uniform float tFlip;
uniform float opacity;
varying vec3 vWorldDirection;
@@ -3026,7 +3139,7 @@ void main() {
gl_FragColor.a *= opacity;
#include <tonemapping_fragment>
#include <colorspace_fragment>
-}`,O1=`#include <common>
+}`,UA=`#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
@@ -3053,7 +3166,7 @@ void main() {
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
vHighPrecisionZW = gl_Position.zw;
-}`,F1=`#if DEPTH_PACKING == 3200
+}`,BA=`#if DEPTH_PACKING == 3200
uniform float opacity;
#endif
#include <common>
@@ -3091,7 +3204,7 @@ void main() {
#elif DEPTH_PACKING == 3203
gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
#endif
-}`,U1=`#define DISTANCE
+}`,zA=`#define DISTANCE
varying vec3 vWorldPosition;
#include <common>
#include <batching_pars_vertex>
@@ -3118,7 +3231,7 @@ void main() {
#include <worldpos_vertex>
#include <clipping_planes_vertex>
vWorldPosition = worldPosition.xyz;
-}`,k1=`#define DISTANCE
+}`,HA=`#define DISTANCE
uniform vec3 referencePosition;
uniform float nearDistance;
uniform float farDistance;
@@ -3130,7 +3243,7 @@ varying vec3 vWorldPosition;
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <clipping_planes_pars_fragment>
-void main () {
+void main() {
vec4 diffuseColor = vec4( 1.0 );
#include <clipping_planes_fragment>
#include <map_fragment>
@@ -3141,13 +3254,13 @@ void main () {
dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
dist = saturate( dist );
gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 );
-}`,B1=`varying vec3 vWorldDirection;
+}`,VA=`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
-}`,z1=`uniform sampler2D tEquirect;
+}`,GA=`uniform sampler2D tEquirect;
varying vec3 vWorldDirection;
#include <common>
void main() {
@@ -3156,7 +3269,7 @@ void main() {
gl_FragColor = texture2D( tEquirect, sampleUV );
#include <tonemapping_fragment>
#include <colorspace_fragment>
-}`,H1=`uniform float scale;
+}`,WA=`uniform float scale;
attribute float lineDistance;
varying float vLineDistance;
#include <common>
@@ -3178,7 +3291,7 @@ void main() {
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
#include <fog_vertex>
-}`,G1=`uniform vec3 diffuse;
+}`,$A=`uniform vec3 diffuse;
uniform float opacity;
uniform float dashSize;
uniform float totalSize;
@@ -3206,7 +3319,7 @@ void main() {
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
-}`,V1=`#include <common>
+}`,qA=`#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <envmap_pars_vertex>
@@ -3238,7 +3351,7 @@ void main() {
#include <worldpos_vertex>
#include <envmap_vertex>
#include <fog_vertex>
-}`,W1=`uniform vec3 diffuse;
+}`,jA=`uniform vec3 diffuse;
uniform float opacity;
#ifndef FLAT_SHADED
varying vec3 vNormal;
@@ -3286,7 +3399,7 @@ void main() {
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
-}`,q1=`#define LAMBERT
+}`,XA=`#define LAMBERT
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
@@ -3325,7 +3438,7 @@ void main() {
#include <envmap_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>
-}`,$1=`#define LAMBERT
+}`,KA=`#define LAMBERT
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float opacity;
@@ -3383,7 +3496,7 @@ void main() {
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
-}`,j1=`#define MATCAP
+}`,YA=`#define MATCAP
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
@@ -3417,7 +3530,7 @@ void main() {
#include <clipping_planes_vertex>
#include <fog_vertex>
vViewPosition = - mvPosition.xyz;
-}`,X1=`#define MATCAP
+}`,JA=`#define MATCAP
uniform vec3 diffuse;
uniform float opacity;
uniform sampler2D matcap;
@@ -3463,7 +3576,7 @@ void main() {
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
-}`,K1=`#define NORMAL
+}`,ZA=`#define NORMAL
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
varying vec3 vViewPosition;
#endif
@@ -3496,7 +3609,7 @@ void main() {
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
vViewPosition = - mvPosition.xyz;
#endif
-}`,Y1=`#define NORMAL
+}`,QA=`#define NORMAL
uniform float opacity;
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
varying vec3 vViewPosition;
@@ -3517,7 +3630,7 @@ void main() {
#ifdef OPAQUE
gl_FragColor.a = 1.0;
#endif
-}`,J1=`#define PHONG
+}`,eT=`#define PHONG
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
@@ -3556,7 +3669,7 @@ void main() {
#include <envmap_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>
-}`,Z1=`#define PHONG
+}`,tT=`#define PHONG
uniform vec3 diffuse;
uniform vec3 emissive;
uniform vec3 specular;
@@ -3616,7 +3729,7 @@ void main() {
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
-}`,Q1=`#define STANDARD
+}`,nT=`#define STANDARD
varying vec3 vViewPosition;
#ifdef USE_TRANSMISSION
varying vec3 vWorldPosition;
@@ -3659,7 +3772,7 @@ void main() {
#ifdef USE_TRANSMISSION
vWorldPosition = worldPosition.xyz;
#endif
-}`,eM=`#define STANDARD
+}`,iT=`#define STANDARD
#ifdef PHYSICAL
#define IOR
#define USE_SPECULAR
@@ -3689,6 +3802,9 @@ uniform float opacity;
#ifdef USE_DISPERSION
uniform float dispersion;
#endif
+#ifdef USE_RETROREFLECTION
+ uniform float retroreflectivity;
+#endif
#ifdef USE_IRIDESCENCE
uniform float iridescence;
uniform float iridescenceIOR;
@@ -3784,7 +3900,7 @@ void main() {
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
-}`,tM=`#define TOON
+}`,sT=`#define TOON
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
@@ -3821,7 +3937,7 @@ void main() {
#include <worldpos_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>
-}`,nM=`#define TOON
+}`,rT=`#define TOON
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float opacity;
@@ -3873,7 +3989,7 @@ void main() {
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
-}`,iM=`uniform float size;
+}`,aT=`uniform float size;
uniform float scale;
#include <common>
#include <color_pars_vertex>
@@ -3904,7 +4020,7 @@ void main() {
#include <clipping_planes_vertex>
#include <worldpos_vertex>
#include <fog_vertex>
-}`,rM=`uniform vec3 diffuse;
+}`,oT=`uniform vec3 diffuse;
uniform float opacity;
#include <common>
#include <color_pars_fragment>
@@ -3929,7 +4045,7 @@ void main() {
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
-}`,sM=`#include <common>
+}`,cT=`#include <common>
#include <batching_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
@@ -3952,7 +4068,7 @@ void main() {
#include <worldpos_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>
-}`,aM=`uniform vec3 color;
+}`,lT=`uniform vec3 color;
uniform float opacity;
#include <common>
#include <fog_pars_fragment>
@@ -3968,7 +4084,7 @@ void main() {
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
-}`,oM=`uniform float rotation;
+}`,hT=`uniform float rotation;
uniform vec2 center;
#include <common>
#include <uv_pars_vertex>
@@ -3992,7 +4108,7 @@ void main() {
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
#include <fog_vertex>
-}`,cM=`uniform vec3 diffuse;
+}`,uT=`uniform vec3 diffuse;
uniform float opacity;
#include <common>
#include <uv_pars_fragment>
@@ -4017,7 +4133,7 @@ void main() {
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
-}`,ft={alphahash_fragment:CS,alphahash_pars_fragment:IS,alphamap_fragment:PS,alphamap_pars_fragment:LS,alphatest_fragment:DS,alphatest_pars_fragment:NS,aomap_fragment:OS,aomap_pars_fragment:FS,batching_pars_vertex:US,batching_vertex:kS,begin_vertex:BS,beginnormal_vertex:zS,bsdfs:HS,iridescence_fragment:GS,bumpmap_pars_fragment:VS,clipping_planes_fragment:WS,clipping_planes_pars_fragment:qS,clipping_planes_pars_vertex:$S,clipping_planes_vertex:jS,color_fragment:XS,color_pars_fragment:KS,color_pars_vertex:YS,color_vertex:JS,common:ZS,cube_uv_reflection_fragment:QS,defaultnormal_vertex:ew,displacementmap_pars_vertex:tw,displacementmap_vertex:nw,emissivemap_fragment:iw,emissivemap_pars_fragment:rw,colorspace_fragment:sw,colorspace_pars_fragment:aw,envmap_fragment:ow,envmap_common_pars_fragment:cw,envmap_pars_fragment:lw,envmap_pars_vertex:hw,envmap_physical_pars_fragment:vw,envmap_vertex:uw,fog_vertex:dw,fog_pars_vertex:fw,fog_fragment:pw,fog_pars_fragment:mw,gradientmap_pars_fragment:gw,lightmap_pars_fragment:bw,lights_lambert_fragment:xw,lights_lambert_pars_fragment:_w,lights_pars_begin:yw,lights_toon_fragment:Sw,lights_toon_pars_fragment:ww,lights_phong_fragment:Mw,lights_phong_pars_fragment:Aw,lights_physical_fragment:Tw,lights_physical_pars_fragment:Ew,lights_fragment_begin:Rw,lights_fragment_maps:Cw,lights_fragment_end:Iw,lightprobes_pars_fragment:Pw,logdepthbuf_fragment:Lw,logdepthbuf_pars_fragment:Dw,logdepthbuf_pars_vertex:Nw,logdepthbuf_vertex:Ow,map_fragment:Fw,map_pars_fragment:Uw,map_particle_fragment:kw,map_particle_pars_fragment:Bw,metalnessmap_fragment:zw,metalnessmap_pars_fragment:Hw,morphinstance_vertex:Gw,morphcolor_vertex:Vw,morphnormal_vertex:Ww,morphtarget_pars_vertex:qw,morphtarget_vertex:$w,normal_fragment_begin:jw,normal_fragment_maps:Xw,normal_pars_fragment:Kw,normal_pars_vertex:Yw,normal_vertex:Jw,normalmap_pars_fragment:Zw,clearcoat_normal_fragment_begin:Qw,clearcoat_normal_fragment_maps:e1,clearcoat_pars_fragment:t1,iridescence_pars_fragment:n1,opaque_fragment:i1,packing:r1,premultiplied_alpha_fragment:s1,project_vertex:a1,dithering_fragment:o1,dithering_pars_fragment:c1,roughnessmap_fragment:l1,roughnessmap_pars_fragment:h1,shadowmap_pars_fragment:u1,shadowmap_pars_vertex:d1,shadowmap_vertex:f1,shadowmask_pars_fragment:p1,skinbase_vertex:m1,skinning_pars_vertex:g1,skinning_vertex:b1,skinnormal_vertex:x1,specularmap_fragment:_1,specularmap_pars_fragment:y1,tonemapping_fragment:v1,tonemapping_pars_fragment:S1,transmission_fragment:w1,transmission_pars_fragment:M1,uv_pars_fragment:A1,uv_pars_vertex:T1,uv_vertex:E1,worldpos_vertex:R1,background_vert:C1,background_frag:I1,backgroundCube_vert:P1,backgroundCube_frag:L1,cube_vert:D1,cube_frag:N1,depth_vert:O1,depth_frag:F1,distance_vert:U1,distance_frag:k1,equirect_vert:B1,equirect_frag:z1,linedashed_vert:H1,linedashed_frag:G1,meshbasic_vert:V1,meshbasic_frag:W1,meshlambert_vert:q1,meshlambert_frag:$1,meshmatcap_vert:j1,meshmatcap_frag:X1,meshnormal_vert:K1,meshnormal_frag:Y1,meshphong_vert:J1,meshphong_frag:Z1,meshphysical_vert:Q1,meshphysical_frag:eM,meshtoon_vert:tM,meshtoon_frag:nM,points_vert:iM,points_frag:rM,shadow_vert:sM,shadow_frag:aM,sprite_vert:oM,sprite_frag:cM},Ue={common:{diffuse:{value:new Ve(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new ct},alphaMap:{value:null},alphaMapTransform:{value:new ct},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new ct}},envmap:{envMap:{value:null},envMapRotation:{value:new ct},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new ct}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new ct}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new ct},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new ct},normalScale:{value:new dt(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new ct},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new ct}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new ct}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new ct}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Ve(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new W},probesMax:{value:new W},probesResolution:{value:new W}},points:{diffuse:{value:new Ve(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new ct},alphaTest:{value:0},uvTransform:{value:new ct}},sprite:{diffuse:{value:new Ve(16777215)},opacity:{value:1},center:{value:new dt(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new ct},alphaMap:{value:null},alphaMapTransform:{value:new ct},alphaTest:{value:0}}},Qi={basic:{uniforms:Nn([Ue.common,Ue.specularmap,Ue.envmap,Ue.aomap,Ue.lightmap,Ue.fog]),vertexShader:ft.meshbasic_vert,fragmentShader:ft.meshbasic_frag},lambert:{uniforms:Nn([Ue.common,Ue.specularmap,Ue.envmap,Ue.aomap,Ue.lightmap,Ue.emissivemap,Ue.bumpmap,Ue.normalmap,Ue.displacementmap,Ue.fog,Ue.lights,{emissive:{value:new Ve(0)},envMapIntensity:{value:1}}]),vertexShader:ft.meshlambert_vert,fragmentShader:ft.meshlambert_frag},phong:{uniforms:Nn([Ue.common,Ue.specularmap,Ue.envmap,Ue.aomap,Ue.lightmap,Ue.emissivemap,Ue.bumpmap,Ue.normalmap,Ue.displacementmap,Ue.fog,Ue.lights,{emissive:{value:new Ve(0)},specular:{value:new Ve(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:ft.meshphong_vert,fragmentShader:ft.meshphong_frag},standard:{uniforms:Nn([Ue.common,Ue.envmap,Ue.aomap,Ue.lightmap,Ue.emissivemap,Ue.bumpmap,Ue.normalmap,Ue.displacementmap,Ue.roughnessmap,Ue.metalnessmap,Ue.fog,Ue.lights,{emissive:{value:new Ve(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:ft.meshphysical_vert,fragmentShader:ft.meshphysical_frag},toon:{uniforms:Nn([Ue.common,Ue.aomap,Ue.lightmap,Ue.emissivemap,Ue.bumpmap,Ue.normalmap,Ue.displacementmap,Ue.gradientmap,Ue.fog,Ue.lights,{emissive:{value:new Ve(0)}}]),vertexShader:ft.meshtoon_vert,fragmentShader:ft.meshtoon_frag},matcap:{uniforms:Nn([Ue.common,Ue.bumpmap,Ue.normalmap,Ue.displacementmap,Ue.fog,{matcap:{value:null}}]),vertexShader:ft.meshmatcap_vert,fragmentShader:ft.meshmatcap_frag},points:{uniforms:Nn([Ue.points,Ue.fog]),vertexShader:ft.points_vert,fragmentShader:ft.points_frag},dashed:{uniforms:Nn([Ue.common,Ue.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:ft.linedashed_vert,fragmentShader:ft.linedashed_frag},depth:{uniforms:Nn([Ue.common,Ue.displacementmap]),vertexShader:ft.depth_vert,fragmentShader:ft.depth_frag},normal:{uniforms:Nn([Ue.common,Ue.bumpmap,Ue.normalmap,Ue.displacementmap,{opacity:{value:1}}]),vertexShader:ft.meshnormal_vert,fragmentShader:ft.meshnormal_frag},sprite:{uniforms:Nn([Ue.sprite,Ue.fog]),vertexShader:ft.sprite_vert,fragmentShader:ft.sprite_frag},background:{uniforms:{uvTransform:{value:new ct},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:ft.background_vert,fragmentShader:ft.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new ct}},vertexShader:ft.backgroundCube_vert,fragmentShader:ft.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:ft.cube_vert,fragmentShader:ft.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:ft.equirect_vert,fragmentShader:ft.equirect_frag},distance:{uniforms:Nn([Ue.common,Ue.displacementmap,{referencePosition:{value:new W},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:ft.distance_vert,fragmentShader:ft.distance_frag},shadow:{uniforms:Nn([Ue.lights,Ue.fog,{color:{value:new Ve(0)},opacity:{value:1}}]),vertexShader:ft.shadow_vert,fragmentShader:ft.shadow_frag}};Qi.physical={uniforms:Nn([Qi.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new ct},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new ct},clearcoatNormalScale:{value:new dt(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new ct},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new ct},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new ct},sheen:{value:0},sheenColor:{value:new Ve(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new ct},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new ct},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new ct},transmissionSamplerSize:{value:new dt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new ct},attenuationDistance:{value:0},attenuationColor:{value:new Ve(0)},specularColor:{value:new Ve(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new ct},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new ct},anisotropyVector:{value:new dt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new ct}}]),vertexShader:ft.meshphysical_vert,fragmentShader:ft.meshphysical_frag};xh={r:0,b:0,g:0},lM=new ot,nb=new ct;nb.set(-1,0,0,0,1,0,0,0,1);Kr=4,D0=[.125,.215,.35,.446,.526,.582],Rs=20,mM=256,zo=new Wr,N0=new Ve,Qd=null,ef=0,tf=0,nf=!1,gM=new W,wa=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,t=0,n=.1,r=100,s={}){let{size:a=256,position:o=gM}=s;Qd=this._renderer.getRenderTarget(),ef=this._renderer.getActiveCubeFace(),tf=this._renderer.getActiveMipmapLevel(),nf=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);let l=this._allocateTargets();return l.depthBuffer=!0,this._sceneToCubeUV(e,n,r,l,o),t>0&&this._blur(l,0,0,t),this._applyPMREM(l),this._cleanup(l),l}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=U0(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=F0(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(Qd,ef,tf),this._renderer.xr.enabled=nf,e.scissorTest=!1,va(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===$r||e.mapping===As?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Qd=this._renderer.getRenderTarget(),ef=this._renderer.getActiveCubeFace(),tf=this._renderer.getActiveMipmapLevel(),nf=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;let n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){let e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:zt,minFilter:zt,generateMipmaps:!1,type:Gn,format:ci,colorSpace:bn,depthBuffer:!1},r=O0(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=O0(e,t,n);let{_lodMax:s}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=bM(s)),this._blurMaterial=_M(s,e,t),this._ggxMaterial=xM(s,e,t)}return r}_compileMaterial(e){let t=new xt(new mn,e);this._renderer.compile(t,zo)}_sceneToCubeUV(e,t,n,r,s){let l=new an(90,1,t,n),c=[1,-1,1,1,1,1],h=[1,1,1,-1,-1,-1],d=this._renderer,f=d.autoClear,p=d.toneMapping;d.getClearColor(N0),d.toneMapping=Ni,d.autoClear=!1,d.state.buffers.depth.getReversed()&&(d.setRenderTarget(r),d.clearDepth(),d.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new xt(new Hr,new gn({name:"PMREM.Background",side:An,depthWrite:!1,depthTest:!1})));let y=this._backgroundBox,b=y.material,g=!1,S=e.background;S?S.isColor&&(b.color.copy(S),e.background=null,g=!0):(b.color.copy(N0),g=!0);for(let A=0;A<6;A++){let T=A%3;T===0?(l.up.set(0,c[A],0),l.position.set(s.x,s.y,s.z),l.lookAt(s.x+h[A],s.y,s.z)):T===1?(l.up.set(0,0,c[A]),l.position.set(s.x,s.y,s.z),l.lookAt(s.x,s.y+h[A],s.z)):(l.up.set(0,c[A],0),l.position.set(s.x,s.y,s.z),l.lookAt(s.x,s.y,s.z+h[A]));let N=this._cubeSize;va(r,T*N,A>2?N:0,N,N),d.setRenderTarget(r),g&&d.render(y,l),d.render(e,l)}d.toneMapping=p,d.autoClear=f,e.background=S}_textureToCubeUV(e,t){let n=this._renderer,r=e.mapping===$r||e.mapping===As;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=U0()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=F0());let s=r?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=s;let o=s.uniforms;o.envMap.value=e;let l=this._cubeSize;va(t,0,0,3*l,2*l),n.setRenderTarget(t),n.render(a,zo)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;let r=this._lodMeshes.length;for(let s=1;s<r;s++)this._applyGGXFilter(e,s-1,s);t.autoClear=n}_applyGGXFilter(e,t,n){let r=this._renderer,s=this._pingPongRenderTarget,a=this._ggxMaterial,o=this._lodMeshes[n];o.material=a;let l=a.uniforms,c=n/(this._lodMeshes.length-1),h=t/(this._lodMeshes.length-1),d=Math.sqrt(c*c-h*h),f=0+c*1.25,p=d*f,{_lodMax:x}=this,y=this._sizeLods[n],b=3*y*(n>x-Kr?n-x+Kr:0),g=4*(this._cubeSize-y);l.envMap.value=e.texture,l.roughness.value=p,l.mipInt.value=x-t,va(s,b,g,3*y,2*y),r.setRenderTarget(s),r.render(o,zo),l.envMap.value=s.texture,l.roughness.value=0,l.mipInt.value=x-n,va(e,b,g,3*y,2*y),r.setRenderTarget(e),r.render(o,zo)}_blur(e,t,n,r,s){let a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,r,"latitudinal",s),this._halfBlur(a,e,n,n,r,"longitudinal",s)}_halfBlur(e,t,n,r,s,a,o){let l=this._renderer,c=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&et("blur direction must be either latitudinal or longitudinal!");let h=3,d=this._lodMeshes[r];d.material=c;let f=c.uniforms,p=this._sizeLods[n]-1,x=isFinite(s)?Math.PI/(2*p):2*Math.PI/(2*Rs-1),y=s/x,b=isFinite(s)?1+Math.floor(h*y):Rs;b>Rs&&Ke(`sigmaRadians, ${s}, is too large and will clip, as it requested ${b} samples when the maximum is set to ${Rs}`);let g=[],S=0;for(let U=0;U<Rs;++U){let v=U/y,I=Math.exp(-v*v/2);g.push(I),U===0?S+=I:U<b&&(S+=2*I)}for(let U=0;U<g.length;U++)g[U]=g[U]/S;f.envMap.value=e.texture,f.samples.value=b,f.weights.value=g,f.latitudinal.value=a==="latitudinal",o&&(f.poleAxis.value=o);let{_lodMax:A}=this;f.dTheta.value=x,f.mipInt.value=A-n;let T=this._sizeLods[r],N=3*T*(r>A-Kr?r-A+Kr:0),P=4*(this._cubeSize-T);va(t,N,P,3*T,2*T),l.setRenderTarget(t),l.render(d,zo)}};Ma=class extends Hn{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;let n={width:e,height:e,depth:1},r=[n,n,n,n,n,n];this.texture=new lo(r),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;let n={uniforms:{tEquirect:{value:null}},vertexShader:`
+}`,_t={alphahash_fragment:LM,alphahash_pars_fragment:DM,alphamap_fragment:NM,alphamap_pars_fragment:OM,alphatest_fragment:FM,alphatest_pars_fragment:kM,aomap_fragment:UM,aomap_pars_fragment:BM,batching_pars_vertex:zM,batching_vertex:HM,begin_vertex:VM,beginnormal_vertex:GM,bsdfs:WM,iridescence_fragment:$M,bumpmap_pars_fragment:qM,clipping_planes_fragment:jM,clipping_planes_pars_fragment:XM,clipping_planes_pars_vertex:KM,clipping_planes_vertex:YM,color_fragment:JM,color_pars_fragment:ZM,color_pars_vertex:QM,color_vertex:eE,common:tE,cube_uv_reflection_fragment:nE,defaultnormal_vertex:iE,displacementmap_pars_vertex:sE,displacementmap_vertex:rE,emissivemap_fragment:aE,emissivemap_pars_fragment:oE,colorspace_fragment:cE,colorspace_pars_fragment:lE,envmap_fragment:hE,envmap_common_pars_fragment:uE,envmap_pars_fragment:fE,envmap_pars_vertex:dE,envmap_physical_pars_fragment:ME,envmap_vertex:pE,fog_vertex:mE,fog_pars_vertex:gE,fog_fragment:bE,fog_pars_fragment:_E,gradientmap_pars_fragment:xE,lightmap_pars_fragment:yE,lights_lambert_fragment:vE,lights_lambert_pars_fragment:SE,lights_pars_begin:wE,lights_toon_fragment:EE,lights_toon_pars_fragment:AE,lights_phong_fragment:TE,lights_phong_pars_fragment:RE,lights_physical_fragment:CE,lights_physical_pars_fragment:IE,lights_fragment_begin:PE,lights_fragment_maps:LE,lights_fragment_end:DE,lightprobes_pars_fragment:NE,logdepthbuf_fragment:OE,logdepthbuf_pars_fragment:FE,logdepthbuf_pars_vertex:kE,logdepthbuf_vertex:UE,map_fragment:BE,map_pars_fragment:zE,map_particle_fragment:HE,map_particle_pars_fragment:VE,metalnessmap_fragment:GE,metalnessmap_pars_fragment:WE,morphinstance_vertex:$E,morphcolor_vertex:qE,morphnormal_vertex:jE,morphtarget_pars_vertex:XE,morphtarget_vertex:KE,normal_fragment_begin:YE,normal_fragment_maps:JE,normal_pars_fragment:ZE,normal_pars_vertex:QE,normal_vertex:eA,normalmap_pars_fragment:tA,clearcoat_normal_fragment_begin:nA,clearcoat_normal_fragment_maps:iA,clearcoat_pars_fragment:sA,iridescence_pars_fragment:rA,opaque_fragment:aA,packing:oA,premultiplied_alpha_fragment:cA,project_vertex:lA,dithering_fragment:hA,dithering_pars_fragment:uA,roughnessmap_fragment:fA,roughnessmap_pars_fragment:dA,shadowmap_pars_fragment:pA,shadowmap_pars_vertex:mA,shadowmap_vertex:gA,shadowmask_pars_fragment:bA,skinbase_vertex:_A,skinning_pars_vertex:xA,skinning_vertex:yA,skinnormal_vertex:vA,specularmap_fragment:SA,specularmap_pars_fragment:wA,tonemapping_fragment:MA,tonemapping_pars_fragment:EA,transmission_fragment:AA,transmission_pars_fragment:TA,uv_pars_fragment:RA,uv_pars_vertex:CA,uv_vertex:IA,worldpos_vertex:PA,background_vert:LA,background_frag:DA,backgroundCube_vert:NA,backgroundCube_frag:OA,cube_vert:FA,cube_frag:kA,depth_vert:UA,depth_frag:BA,distance_vert:zA,distance_frag:HA,equirect_vert:VA,equirect_frag:GA,linedashed_vert:WA,linedashed_frag:$A,meshbasic_vert:qA,meshbasic_frag:jA,meshlambert_vert:XA,meshlambert_frag:KA,meshmatcap_vert:YA,meshmatcap_frag:JA,meshnormal_vert:ZA,meshnormal_frag:QA,meshphong_vert:eT,meshphong_frag:tT,meshphysical_vert:nT,meshphysical_frag:iT,meshtoon_vert:sT,meshtoon_frag:rT,points_vert:aT,points_frag:oT,shadow_vert:cT,shadow_frag:lT,sprite_vert:hT,sprite_frag:uT},ke={common:{diffuse:{value:new He(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new ut},alphaMap:{value:null},alphaMapTransform:{value:new ut},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new ut}},envmap:{envMap:{value:null},envMapRotation:{value:new ut},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new ut}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new ut}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new ut},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new ut},normalScale:{value:new dt(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new ut},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new ut}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new ut}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new ut}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new He(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},sunLights:{value:[],properties:{direction:{},color:{}}},sunLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},sunShadowMatrix:{value:[]},sunShadowCascade:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new j},probesMax:{value:new j},probesResolution:{value:new j}},points:{diffuse:{value:new He(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new ut},alphaTest:{value:0},uvTransform:{value:new ut}},sprite:{diffuse:{value:new He(16777215)},opacity:{value:1},center:{value:new dt(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new ut},alphaMap:{value:null},alphaMapTransform:{value:new ut},alphaTest:{value:0}}},xs={basic:{uniforms:jn([ke.common,ke.specularmap,ke.envmap,ke.aomap,ke.lightmap,ke.fog]),vertexShader:_t.meshbasic_vert,fragmentShader:_t.meshbasic_frag},lambert:{uniforms:jn([ke.common,ke.specularmap,ke.envmap,ke.aomap,ke.lightmap,ke.emissivemap,ke.bumpmap,ke.normalmap,ke.displacementmap,ke.fog,ke.lights,{emissive:{value:new He(0)},envMapIntensity:{value:1}}]),vertexShader:_t.meshlambert_vert,fragmentShader:_t.meshlambert_frag},phong:{uniforms:jn([ke.common,ke.specularmap,ke.envmap,ke.aomap,ke.lightmap,ke.emissivemap,ke.bumpmap,ke.normalmap,ke.displacementmap,ke.fog,ke.lights,{emissive:{value:new He(0)},specular:{value:new He(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:_t.meshphong_vert,fragmentShader:_t.meshphong_frag},standard:{uniforms:jn([ke.common,ke.envmap,ke.aomap,ke.lightmap,ke.emissivemap,ke.bumpmap,ke.normalmap,ke.displacementmap,ke.roughnessmap,ke.metalnessmap,ke.fog,ke.lights,{emissive:{value:new He(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:_t.meshphysical_vert,fragmentShader:_t.meshphysical_frag},toon:{uniforms:jn([ke.common,ke.aomap,ke.lightmap,ke.emissivemap,ke.bumpmap,ke.normalmap,ke.displacementmap,ke.gradientmap,ke.fog,ke.lights,{emissive:{value:new He(0)}}]),vertexShader:_t.meshtoon_vert,fragmentShader:_t.meshtoon_frag},matcap:{uniforms:jn([ke.common,ke.bumpmap,ke.normalmap,ke.displacementmap,ke.fog,{matcap:{value:null}}]),vertexShader:_t.meshmatcap_vert,fragmentShader:_t.meshmatcap_frag},points:{uniforms:jn([ke.points,ke.fog]),vertexShader:_t.points_vert,fragmentShader:_t.points_frag},dashed:{uniforms:jn([ke.common,ke.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:_t.linedashed_vert,fragmentShader:_t.linedashed_frag},depth:{uniforms:jn([ke.common,ke.displacementmap]),vertexShader:_t.depth_vert,fragmentShader:_t.depth_frag},normal:{uniforms:jn([ke.common,ke.bumpmap,ke.normalmap,ke.displacementmap,{opacity:{value:1}}]),vertexShader:_t.meshnormal_vert,fragmentShader:_t.meshnormal_frag},sprite:{uniforms:jn([ke.sprite,ke.fog]),vertexShader:_t.sprite_vert,fragmentShader:_t.sprite_frag},background:{uniforms:{uvTransform:{value:new ut},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:_t.background_vert,fragmentShader:_t.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new ut}},vertexShader:_t.backgroundCube_vert,fragmentShader:_t.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:_t.cube_vert,fragmentShader:_t.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:_t.equirect_vert,fragmentShader:_t.equirect_frag},distance:{uniforms:jn([ke.common,ke.displacementmap,{referencePosition:{value:new j},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:_t.distance_vert,fragmentShader:_t.distance_frag},shadow:{uniforms:jn([ke.lights,ke.fog,{color:{value:new He(0)},opacity:{value:1}}]),vertexShader:_t.shadow_vert,fragmentShader:_t.shadow_frag}};xs.physical={uniforms:jn([xs.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new ut},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new ut},clearcoatNormalScale:{value:new dt(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new ut},dispersion:{value:0},retroreflectivity:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new ut},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new ut},sheen:{value:0},sheenColor:{value:new He(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new ut},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new ut},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new ut},transmissionSamplerSize:{value:new dt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new ut},attenuationDistance:{value:0},attenuationColor:{value:new He(0)},specularColor:{value:new He(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new ut},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new ut},anisotropyVector:{value:new dt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new ut}}]),vertexShader:_t.meshphysical_vert,fragmentShader:_t.meshphysical_frag};vu={r:0,b:0,g:0},fT=new ht,ex=new ut;ex.set(-1,0,0,0,1,0,0,0,1);lo=4,_T=6,xT=20,yT=256,Dc=new xr,L_=new He,Rp=null,Cp=0,Ip=0,Pp=!1,vT=new j,ra=new j,uo=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,t=0,n=.1,s=100,r={}){let{size:a=256,position:o=vT}=r;Rp=this._renderer.getRenderTarget(),Cp=this._renderer.getActiveCubeFace(),Ip=this._renderer.getActiveMipmapLevel(),Pp=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);let c=this._allocateTargets();return c.depthBuffer=!0,this._sceneToCubeUV(e,n,s,c,o),t>0&&this._blur(c,0,0,t),this._applyPMREM(c),this._cleanup(c),c}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=O_(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=N_(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(Rp,Cp,Ip),this._renderer.xr.enabled=Pp,e.scissorTest=!1,co(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===vr||e.mapping===na?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Rp=this._renderer.getRenderTarget(),Cp=this._renderer.getActiveCubeFace(),Ip=this._renderer.getActiveMipmapLevel(),Pp=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;let n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){let e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:qt,minFilter:qt,generateMipmaps:!1,type:Zn,format:yi,colorSpace:Mn,depthBuffer:!1},s=D_(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=D_(e,t,n);let{_lodMax:r}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods}=ST(r)),this._blurMaterial=MT(r,e,t),this._ggxMaterial=wT(r,e,t)}return s}_compileMaterial(e){let t=new vt(new pn,e);this._renderer.compile(t,Dc)}_sceneToCubeUV(e,t,n,s,r){let c=new fn(90,1,t,n),l=[1,-1,1,1,1,1],h=[1,1,1,-1,-1,-1],u=this._renderer,d=u.autoClear,p=u.toneMapping;u.getClearColor(L_),u.toneMapping=Ji,u.autoClear=!1,u.state.buffers.depth.getReversed()&&(u.setRenderTarget(s),u.clearDepth(),u.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new vt(new mr,new Sn({name:"PMREM.Background",side:Nn,depthWrite:!1,depthTest:!1})));let v=this._backgroundBox,_=v.material,g=!1,E=e.background;E?E.isColor&&(_.color.copy(E),e.background=null,g=!0):(_.color.copy(L_),g=!0);for(let L=0;L<6;L++){let S=L%3;S===0?(c.up.set(0,l[L],0),c.position.set(r.x,r.y,r.z),c.lookAt(r.x+h[L],r.y,r.z)):S===1?(c.up.set(0,0,l[L]),c.position.set(r.x,r.y,r.z),c.lookAt(r.x,r.y+h[L],r.z)):(c.up.set(0,l[L],0),c.position.set(r.x,r.y,r.z),c.lookAt(r.x,r.y,r.z+h[L]));let M=this._cubeSize;co(s,S*M,L>2?M:0,M,M),u.setRenderTarget(s),g&&u.render(v,c),u.render(e,c)}u.toneMapping=p,u.autoClear=d,e.background=E}_textureToCubeUV(e,t){let n=this._renderer,s=e.mapping===vr||e.mapping===na;s?(this._cubemapMaterial===null&&(this._cubemapMaterial=O_()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=N_());let r=s?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=r;let o=r.uniforms;o.envMap.value=e;let c=this._cubeSize;co(t,0,0,3*c,2*c),n.setRenderTarget(t),n.render(a,Dc)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;let s=this._lodMeshes.length;for(let r=1;r<s;r++)this._applyGGXFilter(e,r-1,r);t.autoClear=n}_applyGGXFilter(e,t,n){let s=this._renderer,r=this._pingPongRenderTarget,a=this._ggxMaterial,o=this._lodMeshes[n];o.material=a;let c=a.uniforms,l=n/(this._lodMeshes.length-1),h=t/(this._lodMeshes.length-1),u=Math.sqrt(l*l-h*h),d=l*1.25,p=u*d,{_lodMax:b}=this,v=this._sizeLods[n],_=3*v*(n>b-lo?n-b+lo:0),g=4*(this._cubeSize-v);c.envMap.value=e.texture,c.roughness.value=p,c.mipInt.value=b-t,co(r,_,g,3*v,2*v),s.setRenderTarget(r),s.render(o,Dc),c.envMap.value=r.texture,c.roughness.value=0,c.mipInt.value=b-n,co(e,_,g,3*v,2*v),s.setRenderTarget(e),s.render(o,Dc)}_blur(e,t,n,s){let r=this._pingPongRenderTarget,a=Math.min(s,Math.PI)/Math.SQRT2;this._blurPass(e,r,t,n,a),this._blurPass(r,e,n,n,a)}_blurPass(e,t,n,s,r){let a=this._renderer,o=this._blurMaterial,c=this._lodMeshes[s];c.material=o;let l=o.uniforms;l.envMap.value=e.texture,l.sigma.value=r,l.mipInt.value=this._lodMax-n;let h=this._sizeLods[s],u=3*h*(s>this._lodMax-lo?s-this._lodMax+lo:0),d=4*(this._cubeSize-h);co(t,u,d,3*h,2*h),a.setRenderTarget(t),a.render(c,Dc)}};fo=class extends Gn{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;let n={width:e,height:e,depth:1},s=[n,n,n,n,n,n];this.texture=new ic(s),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;let n={uniforms:{tEquirect:{value:null}},vertexShader:`
varying vec3 vWorldDirection;
@@ -4052,9 +4168,9 @@ void main() {
gl_FragColor = texture2D( tEquirect, sampleUV );
}
- `},r=new Hr(5,5,5),s=new ai({name:"CubemapFromEquirect",uniforms:Es(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:An,blending:Ji});s.uniforms.tEquirect.value=t;let a=new xt(r,s),o=t.minFilter;return t.minFilter===xi&&(t.minFilter=zt),new wl(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t=!0,n=!0,r=!0){let s=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,n,r);e.setRenderTarget(s)}};EM={[Ad]:"LINEAR_TONE_MAPPING",[Td]:"REINHARD_TONE_MAPPING",[Ed]:"CINEON_TONE_MAPPING",[Ro]:"ACES_FILMIC_TONE_MAPPING",[Cd]:"AGX_TONE_MAPPING",[Id]:"NEUTRAL_TONE_MAPPING",[Rd]:"CUSTOM_TONE_MAPPING"};ib=new xn,af=new pr(1,1),rb=new to,sb=new ll,ab=new lo,k0=[],B0=[],z0=new Float32Array(16),H0=new Float32Array(9),G0=new Float32Array(4);of=class{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=XM(t.type)}},cf=class{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=pA(t.type)}},lf=class{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){let r=this.seq;for(let s=0,a=r.length;s!==a;++s){let o=r[s];o.setValue(e,t[o.id],n)}}},rf=/(\w+)(\])?(\[|\.)?/g;Sa=class{constructor(e,t){this.seq=[],this.map={};let n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let a=0;a<n;++a){let o=e.getActiveUniform(t,a),l=e.getUniformLocation(t,o.name);mA(o,l,this)}let r=[],s=[];for(let a of this.seq)a.type===e.SAMPLER_2D_SHADOW||a.type===e.SAMPLER_CUBE_SHADOW||a.type===e.SAMPLER_2D_ARRAY_SHADOW?r.push(a):s.push(a);r.length>0&&(this.seq=r.concat(s))}setValue(e,t,n,r){let s=this.map[t];s!==void 0&&s.setValue(e,n,r)}setOptional(e,t,n){let r=t[n];r!==void 0&&this.setValue(e,n,r)}static upload(e,t,n,r){for(let s=0,a=t.length;s!==a;++s){let o=t[s],l=n[o.id];l.needsUpdate!==!1&&o.setValue(e,l.value,r)}}static seqWithValue(e,t){let n=[];for(let r=0,s=e.length;r!==s;++r){let a=e[r];a.id in t&&n.push(a)}return n}};gA=37297,bA=0;q0=new ct;vA={[Ad]:"Linear",[Td]:"Reinhard",[Ed]:"Cineon",[Ro]:"ACESFilmic",[Cd]:"AgX",[Id]:"Neutral",[Rd]:"Custom"};_h=new W;EA=/^[ \t]*#include +<([\w\d./]+)>/gm;RA=new Map;IA=/#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;LA={[Eo]:"SHADOWMAP_TYPE_PCF",[qr]:"SHADOWMAP_TYPE_VSM"};NA={[$r]:"ENVMAP_TYPE_CUBE",[As]:"ENVMAP_TYPE_CUBE",[Co]:"ENVMAP_TYPE_CUBE_UV"};FA={[As]:"ENVMAP_MODE_REFRACTION"};kA={[Rl]:"ENVMAP_BLENDING_MULTIPLY",[d0]:"ENVMAP_BLENDING_MIX",[f0]:"ENVMAP_BLENDING_ADD"};GA=0,uf=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){let t=e.vertexShader,n=e.fragmentShader,r=this._getShaderStage(t),s=this._getShaderStage(n),a=this._getShaderCacheForMaterial(e);return a.has(r)===!1&&(a.add(r),r.usedTimes++),a.has(s)===!1&&(a.add(s),s.usedTimes++),this}remove(e){let t=this.materialCache.get(e);for(let n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){let t=this.materialCache,n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){let t=this.shaderCache,n=t.get(e);return n===void 0&&(n=new df(e),t.set(e,n)),n}},df=class{constructor(e){this.id=GA++,this.code=e,this.usedTimes=0}};YA=0;eT=`void main() {
+ `},s=new mr(5,5,5),r=new bi({name:"CubemapFromEquirect",uniforms:sa(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Nn,blending:bs});r.uniforms.tEquirect.value=t;let a=new vt(s,r),o=t.minFilter;return t.minFilter===Di&&(t.minFilter=qt),new Ah(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t=!0,n=!0,s=!0){let r=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,n,s);e.setRenderTarget(r)}};LT={[ep]:"LINEAR_TONE_MAPPING",[tp]:"REINHARD_TONE_MAPPING",[np]:"CINEON_TONE_MAPPING",[vc]:"ACES_FILMIC_TONE_MAPPING",[sp]:"AGX_TONE_MAPPING",[rp]:"NEUTRAL_TONE_MAPPING",[ip]:"CUSTOM_TONE_MAPPING"};tx=new En,Np=new pr(1,1),nx=new Ko,ix=new fh,sx=new ic,F_=[],k_=[],U_=new Float32Array(16),B_=new Float32Array(9),z_=new Float32Array(4);Op=class{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=QT(t.type)}},Fp=class{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=xR(t.type)}},kp=class{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){let s=this.seq;for(let r=0,a=s.length;r!==a;++r){let o=s[r];o.setValue(e,t[o.id],n)}}},Lp=/(\w+)(\])?(\[|\.)?/g;ho=class{constructor(e,t){this.seq=[],this.map={};let n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let a=0;a<n;++a){let o=e.getActiveUniform(t,a),c=e.getUniformLocation(t,o.name);yR(o,c,this)}let s=[],r=[];for(let a of this.seq)a.type===e.SAMPLER_2D_SHADOW||a.type===e.SAMPLER_CUBE_SHADOW||a.type===e.SAMPLER_2D_ARRAY_SHADOW?s.push(a):r.push(a);s.length>0&&(this.seq=s.concat(r))}setValue(e,t,n,s){let r=this.map[t];r!==void 0&&r.setValue(e,n,s)}setOptional(e,t,n){let s=t[n];s!==void 0&&this.setValue(e,n,s)}static upload(e,t,n,s){for(let r=0,a=t.length;r!==a;++r){let o=t[r],c=n[o.id];c.needsUpdate!==!1&&o.setValue(e,c.value,s)}}static seqWithValue(e,t){let n=[];for(let s=0,r=e.length;s!==r;++s){let a=e[s];a.id in t&&n.push(a)}return n}};vR=37297,SR=0;G_=new ut;AR={[ep]:"Linear",[tp]:"Reinhard",[np]:"Cineon",[vc]:"ACESFilmic",[sp]:"AgX",[rp]:"Neutral",[ip]:"Custom"};Su=new j;LR=/^[ \t]*#include +<([\w\d./]+)>/gm;DR=new Map;OR=/#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;kR={[yc]:"SHADOWMAP_TYPE_PCF",[yr]:"SHADOWMAP_TYPE_VSM"};BR={[vr]:"ENVMAP_TYPE_CUBE",[na]:"ENVMAP_TYPE_CUBE",[Sc]:"ENVMAP_TYPE_CUBE_UV"};HR={[na]:"ENVMAP_MODE_REFRACTION"};GR={[Ph]:"ENVMAP_BLENDING_MULTIPLY",[c_]:"ENVMAP_BLENDING_MIX",[l_]:"ENVMAP_BLENDING_ADD"};jR=0,Bp=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,n){let s=this._getShaderCacheForMaterial(e);return s.has(t)===!1&&(s.add(t),t.usedTimes++),s.has(n)===!1&&(s.add(n),n.usedTimes++),this}remove(e){let t=this.materialCache.get(e);for(let n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderStage(e){return this._getShaderStage(e.vertexShader)}getFragmentShaderStage(e){return this._getShaderStage(e.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){let t=this.materialCache,n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){let t=this.shaderCache,n=t.get(e);return n===void 0&&(n=new zp(e),t.set(e,n)),n}},zp=class{constructor(e){this.id=jR++,this.code=e,this.usedTimes=0}};tC=0;rC=`void main() {
gl_Position = vec4( position, 1.0 );
-}`,tT=`uniform sampler2D shadow_pass;
+}`,aC=`uniform sampler2D shadow_pass;
uniform vec2 resolution;
uniform float radius;
void main() {
@@ -4079,12 +4195,12 @@ void main() {
squared_mean = squared_mean / samples;
float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) );
gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );
-}`,nT=[new W(1,0,0),new W(-1,0,0),new W(0,1,0),new W(0,-1,0),new W(0,0,1),new W(0,0,-1)],iT=[new W(0,-1,0),new W(0,-1,0),new W(0,0,1),new W(0,0,-1),new W(0,-1,0),new W(0,-1,0)],eb=new ot,Ho=new W,sf=new W;cT=`
+}`,oC=[new j(1,0,0),new j(-1,0,0),new j(0,1,0),new j(0,-1,0),new j(0,0,1),new j(0,0,-1)],cC=[new j(0,-1,0),new j(0,-1,0),new j(0,0,1),new j(0,0,-1),new j(0,-1,0),new j(0,-1,0)],Z_=new ht,Nc=new j,Dp=new j;dC=`
void main() {
gl_Position = vec4( position, 1.0 );
-}`,lT=`
+}`,pC=`
uniform sampler2DArray depthColor;
uniform float depthWidth;
uniform float depthHeight;
@@ -4103,63 +4219,87 @@ void main() {
}
-}`,ff=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let n=new ho(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=n}}getMesh(e){if(this.texture!==null&&this.mesh===null){let t=e.cameras[0].viewport,n=new ai({vertexShader:cT,fragmentShader:lT,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new xt(new mi(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},pf=class extends Li{constructor(e,t){super();let n=this,r=null,s=1,a=null,o="local-floor",l=1,c=null,h=null,d=null,f=null,p=null,x=null,y=typeof XRWebGLBinding<"u",b=new ff,g={},S=t.getContextAttributes(),A=null,T=null,N=[],P=[],U=new dt,v=null,I=new an;I.viewport=new kt;let B=new an;B.viewport=new kt;let k=[I,B],V=new Ml,J=null,L=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(oe){let Ee=N[oe];return Ee===void 0&&(Ee=new ha,N[oe]=Ee),Ee.getTargetRaySpace()},this.getControllerGrip=function(oe){let Ee=N[oe];return Ee===void 0&&(Ee=new ha,N[oe]=Ee),Ee.getGripSpace()},this.getHand=function(oe){let Ee=N[oe];return Ee===void 0&&(Ee=new ha,N[oe]=Ee),Ee.getHandSpace()};function E(oe){let Ee=P.indexOf(oe.inputSource);if(Ee===-1)return;let _e=N[Ee];_e!==void 0&&(_e.update(oe.inputSource,oe.frame,c||a),_e.dispatchEvent({type:oe.type,data:oe.inputSource}))}function D(){r.removeEventListener("select",E),r.removeEventListener("selectstart",E),r.removeEventListener("selectend",E),r.removeEventListener("squeeze",E),r.removeEventListener("squeezestart",E),r.removeEventListener("squeezeend",E),r.removeEventListener("end",D),r.removeEventListener("inputsourceschange",O);for(let oe=0;oe<N.length;oe++){let Ee=P[oe];Ee!==null&&(P[oe]=null,N[oe].disconnect(Ee))}J=null,L=null,b.reset();for(let oe in g)delete g[oe];e.setRenderTarget(A),p=null,f=null,d=null,r=null,T=null,ke.stop(),n.isPresenting=!1,e.setPixelRatio(v),e.setSize(U.width,U.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(oe){s=oe,n.isPresenting===!0&&Ke("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(oe){o=oe,n.isPresenting===!0&&Ke("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function(oe){c=oe},this.getBaseLayer=function(){return f!==null?f:p},this.getBinding=function(){return d===null&&y&&(d=new XRWebGLBinding(r,t)),d},this.getFrame=function(){return x},this.getSession=function(){return r},this.setSession=async function(oe){if(r=oe,r!==null){if(A=e.getRenderTarget(),r.addEventListener("select",E),r.addEventListener("selectstart",E),r.addEventListener("selectend",E),r.addEventListener("squeeze",E),r.addEventListener("squeezestart",E),r.addEventListener("squeezeend",E),r.addEventListener("end",D),r.addEventListener("inputsourceschange",O),S.xrCompatible!==!0&&await t.makeXRCompatible(),v=e.getPixelRatio(),e.getSize(U),y&&"createProjectionLayer"in XRWebGLBinding.prototype){let _e=null,Ze=null,tt=null;S.depth&&(tt=S.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,_e=S.stencil?jr:Wi,Ze=S.stencil?xa:Oi);let Qe={colorFormat:t.RGBA8,depthFormat:tt,scaleFactor:s};d=this.getBinding(),f=d.createProjectionLayer(Qe),r.updateRenderState({layers:[f]}),e.setPixelRatio(1),e.setSize(f.textureWidth,f.textureHeight,!1),T=new Hn(f.textureWidth,f.textureHeight,{format:ci,type:Qn,depthTexture:new pr(f.textureWidth,f.textureHeight,Ze,void 0,void 0,void 0,void 0,void 0,void 0,_e),stencilBuffer:S.stencil,colorSpace:e.outputColorSpace,samples:S.antialias?4:0,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1})}else{let _e={antialias:S.antialias,alpha:!0,depth:S.depth,stencil:S.stencil,framebufferScaleFactor:s};p=new XRWebGLLayer(r,t,_e),r.updateRenderState({baseLayer:p}),e.setPixelRatio(1),e.setSize(p.framebufferWidth,p.framebufferHeight,!1),T=new Hn(p.framebufferWidth,p.framebufferHeight,{format:ci,type:Qn,colorSpace:e.outputColorSpace,stencilBuffer:S.stencil,resolveDepthBuffer:p.ignoreDepthValues===!1,resolveStencilBuffer:p.ignoreDepthValues===!1})}T.isXRRenderTarget=!0,this.setFoveation(l),c=null,a=await r.requestReferenceSpace(o),ke.setContext(r),ke.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode},this.getDepthTexture=function(){return b.getDepthTexture()};function O(oe){for(let Ee=0;Ee<oe.removed.length;Ee++){let _e=oe.removed[Ee],Ze=P.indexOf(_e);Ze>=0&&(P[Ze]=null,N[Ze].disconnect(_e))}for(let Ee=0;Ee<oe.added.length;Ee++){let _e=oe.added[Ee],Ze=P.indexOf(_e);if(Ze===-1){for(let Qe=0;Qe<N.length;Qe++)if(Qe>=P.length){P.push(_e),Ze=Qe;break}else if(P[Qe]===null){P[Qe]=_e,Ze=Qe;break}if(Ze===-1)break}let tt=N[Ze];tt&&tt.connect(_e)}}let H=new W,Y=new W;function le(oe,Ee,_e){H.setFromMatrixPosition(Ee.matrixWorld),Y.setFromMatrixPosition(_e.matrixWorld);let Ze=H.distanceTo(Y),tt=Ee.projectionMatrix.elements,Qe=_e.projectionMatrix.elements,Et=tt[14]/(tt[10]-1),it=tt[14]/(tt[10]+1),mt=(tt[9]+1)/tt[5],wt=(tt[9]-1)/tt[5],lt=(tt[8]-1)/tt[0],Bt=(Qe[8]+1)/Qe[0],gt=Et*lt,Yt=Et*Bt,q=Ze/(-lt+Bt),$t=q*-lt;if(Ee.matrixWorld.decompose(oe.position,oe.quaternion,oe.scale),oe.translateX($t),oe.translateZ(q),oe.matrixWorld.compose(oe.position,oe.quaternion,oe.scale),oe.matrixWorldInverse.copy(oe.matrixWorld).invert(),tt[10]===-1)oe.projectionMatrix.copy(Ee.projectionMatrix),oe.projectionMatrixInverse.copy(Ee.projectionMatrixInverse);else{let ht=Et+q,Tt=it+q,Pe=gt-$t,Ot=Yt+(Ze-$t),F=mt*it/Tt*ht,M=wt*it/Tt*ht;oe.projectionMatrix.makePerspective(Pe,Ot,F,M,ht,Tt),oe.projectionMatrixInverse.copy(oe.projectionMatrix).invert()}}function fe(oe,Ee){Ee===null?oe.matrixWorld.copy(oe.matrix):oe.matrixWorld.multiplyMatrices(Ee.matrixWorld,oe.matrix),oe.matrixWorldInverse.copy(oe.matrixWorld).invert()}this.updateCamera=function(oe){if(r===null)return;let Ee=oe.near,_e=oe.far;b.texture!==null&&(b.depthNear>0&&(Ee=b.depthNear),b.depthFar>0&&(_e=b.depthFar)),V.near=B.near=I.near=Ee,V.far=B.far=I.far=_e,(J!==V.near||L!==V.far)&&(r.updateRenderState({depthNear:V.near,depthFar:V.far}),J=V.near,L=V.far),V.layers.mask=oe.layers.mask|6,I.layers.mask=V.layers.mask&-5,B.layers.mask=V.layers.mask&-3;let Ze=oe.parent,tt=V.cameras;fe(V,Ze);for(let Qe=0;Qe<tt.length;Qe++)fe(tt[Qe],Ze);tt.length===2?le(V,I,B):V.projectionMatrix.copy(I.projectionMatrix),be(oe,V,Ze)};function be(oe,Ee,_e){_e===null?oe.matrix.copy(Ee.matrixWorld):(oe.matrix.copy(_e.matrixWorld),oe.matrix.invert(),oe.matrix.multiply(Ee.matrixWorld)),oe.matrix.decompose(oe.position,oe.quaternion,oe.scale),oe.updateMatrixWorld(!0),oe.projectionMatrix.copy(Ee.projectionMatrix),oe.projectionMatrixInverse.copy(Ee.projectionMatrixInverse),oe.isPerspectiveCamera&&(oe.fov=bs*2*Math.atan(1/oe.projectionMatrix.elements[5]),oe.zoom=1)}this.getCamera=function(){return V},this.getFoveation=function(){if(!(f===null&&p===null))return l},this.setFoveation=function(oe){l=oe,f!==null&&(f.fixedFoveation=oe),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=oe)},this.hasDepthSensing=function(){return b.texture!==null},this.getDepthSensingMesh=function(){return b.getMesh(V)},this.getCameraTexture=function(oe){return g[oe]};let Te=null;function Je(oe,Ee){if(h=Ee.getViewerPose(c||a),x=Ee,h!==null){let _e=h.views;p!==null&&(e.setRenderTargetFramebuffer(T,p.framebuffer),e.setRenderTarget(T));let Ze=!1;_e.length!==V.cameras.length&&(V.cameras.length=0,Ze=!0);for(let it=0;it<_e.length;it++){let mt=_e[it],wt=null;if(p!==null)wt=p.getViewport(mt);else{let Bt=d.getViewSubImage(f,mt);wt=Bt.viewport,it===0&&(e.setRenderTargetTextures(T,Bt.colorTexture,Bt.depthStencilTexture),e.setRenderTarget(T))}let lt=k[it];lt===void 0&&(lt=new an,lt.layers.enable(it),lt.viewport=new kt,k[it]=lt),lt.matrix.fromArray(mt.transform.matrix),lt.matrix.decompose(lt.position,lt.quaternion,lt.scale),lt.projectionMatrix.fromArray(mt.projectionMatrix),lt.projectionMatrixInverse.copy(lt.projectionMatrix).invert(),lt.viewport.set(wt.x,wt.y,wt.width,wt.height),it===0&&(V.matrix.copy(lt.matrix),V.matrix.decompose(V.position,V.quaternion,V.scale)),Ze===!0&&V.cameras.push(lt)}let tt=r.enabledFeatures;if(tt&&tt.includes("depth-sensing")&&r.depthUsage=="gpu-optimized"&&y){d=n.getBinding();let it=d.getDepthInformation(_e[0]);it&&it.isValid&&it.texture&&b.init(it,r.renderState)}if(tt&&tt.includes("camera-access")&&y){e.state.unbindTexture(),d=n.getBinding();for(let it=0;it<_e.length;it++){let mt=_e[it].camera;if(mt){let wt=g[mt];wt||(wt=new ho,g[mt]=wt);let lt=d.getCameraImage(mt);wt.sourceTexture=lt}}}}for(let _e=0;_e<N.length;_e++){let Ze=P[_e],tt=N[_e];Ze!==null&&tt!==void 0&&tt.update(Ze,Ee,c||a)}Te&&Te(oe,Ee),Ee.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:Ee}),x=null}let ke=new tb;ke.setAnimationLoop(Je),this.setAnimationLoop=function(oe){Te=oe},this.dispose=function(){}}},hT=new ot,ob=new ct;ob.set(-1,0,0,0,1,0,0,0,1);fT=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]),Zi=null;yh=class{constructor(e={}){let{canvas:t=A0(),context:n=null,depth:r=!0,stencil:s=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:d=!1,reversedDepthBuffer:f=!1,outputBufferType:p=Qn}=e;this.isWebGLRenderer=!0;let x;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");x=n.getContextAttributes().alpha}else x=a;let y=p,b=new Set([kl,Ul,Fl]),g=new Set([Qn,Oi,ba,xa,Dl,Nl]),S=new Uint32Array(4),A=new Int32Array(4),T=new W,N=null,P=null,U=[],v=[],I=null;this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=Ni,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let B=this,k=!1,V=null;this._outputColorSpace=Xt;let J=0,L=0,E=null,D=-1,O=null,H=new kt,Y=new kt,le=null,fe=new Ve(0),be=0,Te=t.width,Je=t.height,ke=1,oe=null,Ee=null,_e=new kt(0,0,Te,Je),Ze=new kt(0,0,Te,Je),tt=!1,Qe=new da,Et=!1,it=!1,mt=new ot,wt=new W,lt=new kt,Bt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},gt=!1;function Yt(){return E===null?ke:1}let q=n;function $t(C,j){return t.getContext(C,j)}try{let C={alpha:!0,depth:r,stencil:s,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:d};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${"184"}`),t.addEventListener("webglcontextlost",xe,!1),t.addEventListener("webglcontextrestored",Xe,!1),t.addEventListener("webglcontextcreationerror",rt,!1),q===null){let j="webgl2";if(q=$t(j,C),q===null)throw $t(j)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(C){throw et("WebGLRenderer: "+C.message),C}let ht,Tt,Pe,Ot,F,M,Z,pe,ge,Se,Ce,ce,me,Be,Le,ve,Me,je,nt,pt,G,we,de;function He(){ht=new vM(q),ht.init(),G=new oT(q,ht),Tt=new fM(q,ht,e,G),Pe=new sT(q,ht),Tt.reversedDepthBuffer&&f&&Pe.buffers.depth.setReversed(!0),Ot=new MM(q),F=new qA,M=new aT(q,ht,Pe,F,Tt,G,Ot),Z=new yM(B),pe=new RS(q),we=new uM(q,pe),ge=new SM(q,pe,Ot,we),Se=new TM(q,ge,pe,we,Ot),je=new AM(q,Tt,M),Le=new pM(F),Ce=new WA(B,Z,ht,Tt,we,Le),ce=new uT(B,F),me=new jA,Be=new QA(ht),Me=new hM(B,Z,Pe,Se,x,l),ve=new rT(B,Se,Tt),de=new dT(q,Ot,Tt,Pe),nt=new dM(q,ht,Ot),pt=new wM(q,ht,Ot),Ot.programs=Ce.programs,B.capabilities=Tt,B.extensions=ht,B.properties=F,B.renderLists=me,B.shadowMap=ve,B.state=Pe,B.info=Ot}He(),y!==Qn&&(I=new RM(y,t.width,t.height,r,s));let Ae=new pf(B,q);this.xr=Ae,this.getContext=function(){return q},this.getContextAttributes=function(){return q.getContextAttributes()},this.forceContextLoss=function(){let C=ht.get("WEBGL_lose_context");C&&C.loseContext()},this.forceContextRestore=function(){let C=ht.get("WEBGL_lose_context");C&&C.restoreContext()},this.getPixelRatio=function(){return ke},this.setPixelRatio=function(C){C!==void 0&&(ke=C,this.setSize(Te,Je,!1))},this.getSize=function(C){return C.set(Te,Je)},this.setSize=function(C,j,ie=!0){if(Ae.isPresenting){Ke("WebGLRenderer: Can't change size while VR device is presenting.");return}Te=C,Je=j,t.width=Math.floor(C*ke),t.height=Math.floor(j*ke),ie===!0&&(t.style.width=C+"px",t.style.height=j+"px"),I!==null&&I.setSize(t.width,t.height),this.setViewport(0,0,C,j)},this.getDrawingBufferSize=function(C){return C.set(Te*ke,Je*ke).floor()},this.setDrawingBufferSize=function(C,j,ie){Te=C,Je=j,ke=ie,t.width=Math.floor(C*ie),t.height=Math.floor(j*ie),this.setViewport(0,0,C,j)},this.setEffects=function(C){if(y===Qn){et("THREE.WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(C){for(let j=0;j<C.length;j++)if(C[j].isOutputPass===!0){Ke("THREE.WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}I.setEffects(C||[])},this.getCurrentViewport=function(C){return C.copy(H)},this.getViewport=function(C){return C.copy(_e)},this.setViewport=function(C,j,ie,ee){C.isVector4?_e.set(C.x,C.y,C.z,C.w):_e.set(C,j,ie,ee),Pe.viewport(H.copy(_e).multiplyScalar(ke).round())},this.getScissor=function(C){return C.copy(Ze)},this.setScissor=function(C,j,ie,ee){C.isVector4?Ze.set(C.x,C.y,C.z,C.w):Ze.set(C,j,ie,ee),Pe.scissor(Y.copy(Ze).multiplyScalar(ke).round())},this.getScissorTest=function(){return tt},this.setScissorTest=function(C){Pe.setScissorTest(tt=C)},this.setOpaqueSort=function(C){oe=C},this.setTransparentSort=function(C){Ee=C},this.getClearColor=function(C){return C.copy(Me.getClearColor())},this.setClearColor=function(){Me.setClearColor(...arguments)},this.getClearAlpha=function(){return Me.getClearAlpha()},this.setClearAlpha=function(){Me.setClearAlpha(...arguments)},this.clear=function(C=!0,j=!0,ie=!0){let ee=0;if(C){let Q=!1;if(E!==null){let Fe=E.texture.format;Q=b.has(Fe)}if(Q){let Fe=E.texture.type,We=g.has(Fe),De=Me.getClearColor(),Ie=Me.getClearAlpha(),qe=De.r,st=De.g,at=De.b;We?(S[0]=qe,S[1]=st,S[2]=at,S[3]=Ie,q.clearBufferuiv(q.COLOR,0,S)):(A[0]=qe,A[1]=st,A[2]=at,A[3]=Ie,q.clearBufferiv(q.COLOR,0,A))}else ee|=q.COLOR_BUFFER_BIT}j&&(ee|=q.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),ie&&(ee|=q.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),ee!==0&&q.clear(ee)},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.setNodesHandler=function(C){C.setRenderer(this),V=C},this.dispose=function(){t.removeEventListener("webglcontextlost",xe,!1),t.removeEventListener("webglcontextrestored",Xe,!1),t.removeEventListener("webglcontextcreationerror",rt,!1),Me.dispose(),me.dispose(),Be.dispose(),F.dispose(),Z.dispose(),Se.dispose(),we.dispose(),de.dispose(),Ce.dispose(),Ae.dispose(),Ae.removeEventListener("sessionstart",ns),Ae.removeEventListener("sessionend",ka),zi.stop()};function xe(C){C.preventDefault(),eo("WebGLRenderer: Context Lost."),k=!0}function Xe(){eo("WebGLRenderer: Context Restored."),k=!1;let C=Ot.autoReset,j=ve.enabled,ie=ve.autoUpdate,ee=ve.needsUpdate,Q=ve.type;He(),Ot.autoReset=C,ve.enabled=j,ve.autoUpdate=ie,ve.needsUpdate=ee,ve.type=Q}function rt(C){et("WebGLRenderer: A WebGL context could not be created. Reason: ",C.statusMessage)}function jt(C){let j=C.target;j.removeEventListener("dispose",jt),Rt(j)}function Rt(C){$n(C),F.remove(C)}function $n(C){let j=F.get(C).programs;j!==void 0&&(j.forEach(function(ie){Ce.releaseProgram(ie)}),C.isShaderMaterial&&Ce.releaseShaderCache(C))}this.renderBufferDirect=function(C,j,ie,ee,Q,Fe){j===null&&(j=Bt);let We=Q.isMesh&&Q.matrixWorld.determinant()<0,De=yc(C,j,ie,ee,Q);Pe.setMaterial(ee,We);let Ie=ie.index,qe=1;if(ee.wireframe===!0){if(Ie=ge.getWireframeAttribute(ie),Ie===void 0)return;qe=2}let st=ie.drawRange,at=ie.attributes.position,Ye=st.start*qe,Ct=(st.start+st.count)*qe;Fe!==null&&(Ye=Math.max(Ye,Fe.start*qe),Ct=Math.min(Ct,(Fe.start+Fe.count)*qe)),Ie!==null?(Ye=Math.max(Ye,0),Ct=Math.min(Ct,Ie.count)):at!=null&&(Ye=Math.max(Ye,0),Ct=Math.min(Ct,at.count));let Jt=Ct-Ye;if(Jt<0||Jt===1/0)return;we.setup(Q,ee,De,ie,Ie);let Wt,Mt=nt;if(Ie!==null&&(Wt=pe.get(Ie),Mt=pt,Mt.setIndex(Wt)),Q.isMesh)ee.wireframe===!0?(Pe.setLineWidth(ee.wireframeLinewidth*Yt()),Mt.setMode(q.LINES)):Mt.setMode(q.TRIANGLES);else if(Q.isLine){let Zt=ee.linewidth;Zt===void 0&&(Zt=1),Pe.setLineWidth(Zt*Yt()),Q.isLineSegments?Mt.setMode(q.LINES):Q.isLineLoop?Mt.setMode(q.LINE_LOOP):Mt.setMode(q.LINE_STRIP)}else Q.isPoints?Mt.setMode(q.POINTS):Q.isSprite&&Mt.setMode(q.TRIANGLES);if(Q.isBatchedMesh)if(ht.get("WEBGL_multi_draw"))Mt.renderMultiDraw(Q._multiDrawStarts,Q._multiDrawCounts,Q._multiDrawCount);else{let Zt=Q._multiDrawStarts,ze=Q._multiDrawCounts,Un=Q._multiDrawCount,vt=Ie?pe.get(Ie).bytesPerElement:1,Xn=F.get(ee).currentProgram.getUniforms();for(let sn=0;sn<Un;sn++)Xn.setValue(q,"_gl_DrawID",sn),Mt.render(Zt[sn]/vt,ze[sn])}else if(Q.isInstancedMesh)Mt.renderInstances(Ye,Jt,Q.count);else if(ie.isInstancedBufferGeometry){let Zt=ie._maxInstanceCount!==void 0?ie._maxInstanceCount:1/0,ze=Math.min(ie.instanceCount,Zt);Mt.renderInstances(Ye,Jt,ze)}else Mt.render(Ye,Jt)};function ui(C,j,ie){C.transparent===!0&&C.side===Dn&&C.forceSinglePass===!1?(C.side=An,C.needsUpdate=!0,rs(C,j,ie),C.side=Pi,C.needsUpdate=!0,rs(C,j,ie),C.side=Dn):rs(C,j,ie)}this.compile=function(C,j,ie=null){ie===null&&(ie=C),P=Be.get(ie),P.init(j),v.push(P),ie.traverseVisible(function(Q){Q.isLight&&Q.layers.test(j.layers)&&(P.pushLight(Q),Q.castShadow&&P.pushShadow(Q))}),C!==ie&&C.traverseVisible(function(Q){Q.isLight&&Q.layers.test(j.layers)&&(P.pushLight(Q),Q.castShadow&&P.pushShadow(Q))}),P.setupLights();let ee=new Set;return C.traverse(function(Q){if(!(Q.isMesh||Q.isPoints||Q.isLine||Q.isSprite))return;let Fe=Q.material;if(Fe)if(Array.isArray(Fe))for(let We=0;We<Fe.length;We++){let De=Fe[We];ui(De,ie,Q),ee.add(De)}else ui(Fe,ie,Q),ee.add(Fe)}),P=v.pop(),ee},this.compileAsync=function(C,j,ie=null){let ee=this.compile(C,j,ie);return new Promise(Q=>{function Fe(){if(ee.forEach(function(We){F.get(We).currentProgram.isReady()&&ee.delete(We)}),ee.size===0){Q(C);return}setTimeout(Fe,10)}ht.get("KHR_parallel_shader_compile")!==null?Fe():setTimeout(Fe,10)})};let Hs=null;function Ou(C){Hs&&Hs(C)}function ns(){zi.stop()}function ka(){zi.start()}let zi=new tb;zi.setAnimationLoop(Ou),typeof self<"u"&&zi.setContext(self),this.setAnimationLoop=function(C){Hs=C,Ae.setAnimationLoop(C),C===null?zi.stop():zi.start()},Ae.addEventListener("sessionstart",ns),Ae.addEventListener("sessionend",ka),this.render=function(C,j){if(j!==void 0&&j.isCamera!==!0){et("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(k===!0)return;V!==null&&V.renderStart(C,j);let ie=Ae.enabled===!0&&Ae.isPresenting===!0,ee=I!==null&&(E===null||ie)&&I.begin(B,E);if(C.matrixWorldAutoUpdate===!0&&C.updateMatrixWorld(),j.parent===null&&j.matrixWorldAutoUpdate===!0&&j.updateMatrixWorld(),Ae.enabled===!0&&Ae.isPresenting===!0&&(I===null||I.isCompositing()===!1)&&(Ae.cameraAutoUpdate===!0&&Ae.updateCamera(j),j=Ae.getCamera()),C.isScene===!0&&C.onBeforeRender(B,C,j,E),P=Be.get(C,v.length),P.init(j),P.state.textureUnits=M.getTextureUnits(),v.push(P),mt.multiplyMatrices(j.projectionMatrix,j.matrixWorldInverse),Qe.setFromProjectionMatrix(mt,Ci,j.reversedDepth),it=this.localClippingEnabled,Et=Le.init(this.clippingPlanes,it),N=me.get(C,U.length),N.init(),U.push(N),Ae.enabled===!0&&Ae.isPresenting===!0){let We=B.xr.getDepthSensingMesh();We!==null&&Ba(We,j,-1/0,B.sortObjects)}Ba(C,j,0,B.sortObjects),N.finish(),B.sortObjects===!0&&N.sort(oe,Ee),gt=Ae.enabled===!1||Ae.isPresenting===!1||Ae.hasDepthSensing()===!1,gt&&Me.addToRenderList(N,C),this.info.render.frame++,Et===!0&&Le.beginShadows();let Q=P.state.shadowsArray;if(ve.render(Q,C,j),Et===!0&&Le.endShadows(),this.info.autoReset===!0&&this.info.reset(),(ee&&I.hasRenderPass())===!1){let We=N.opaque,De=N.transmissive;if(P.setupLights(),j.isArrayCamera){let Ie=j.cameras;if(De.length>0)for(let qe=0,st=Ie.length;qe<st;qe++){let at=Ie[qe];za(We,De,C,at)}gt&&Me.render(C);for(let qe=0,st=Ie.length;qe<st;qe++){let at=Ie[qe];jn(N,C,at,at.viewport)}}else De.length>0&&za(We,De,C,j),gt&&Me.render(C),jn(N,C,j)}E!==null&&L===0&&(M.updateMultisampleRenderTarget(E),M.updateRenderTargetMipmap(E)),ee&&I.end(B),C.isScene===!0&&C.onAfterRender(B,C,j),we.resetDefaultState(),D=-1,O=null,v.pop(),v.length>0?(P=v[v.length-1],M.setTextureUnits(P.state.textureUnits),Et===!0&&Le.setGlobalState(B.clippingPlanes,P.state.camera)):P=null,U.pop(),U.length>0?N=U[U.length-1]:N=null,V!==null&&V.renderEnd()};function Ba(C,j,ie,ee){if(C.visible===!1)return;if(C.layers.test(j.layers)){if(C.isGroup)ie=C.renderOrder;else if(C.isLOD)C.autoUpdate===!0&&C.update(j);else if(C.isLightProbeGrid)P.pushLightProbeGrid(C);else if(C.isLight)P.pushLight(C),C.castShadow&&P.pushShadow(C);else if(C.isSprite){if(!C.frustumCulled||Qe.intersectsSprite(C)){ee&&lt.setFromMatrixPosition(C.matrixWorld).applyMatrix4(mt);let We=Se.update(C),De=C.material;De.visible&&N.push(C,We,De,ie,lt.z,null)}}else if((C.isMesh||C.isLine||C.isPoints)&&(!C.frustumCulled||Qe.intersectsObject(C))){let We=Se.update(C),De=C.material;if(ee&&(C.boundingSphere!==void 0?(C.boundingSphere===null&&C.computeBoundingSphere(),lt.copy(C.boundingSphere.center)):(We.boundingSphere===null&&We.computeBoundingSphere(),lt.copy(We.boundingSphere.center)),lt.applyMatrix4(C.matrixWorld).applyMatrix4(mt)),Array.isArray(De)){let Ie=We.groups;for(let qe=0,st=Ie.length;qe<st;qe++){let at=Ie[qe],Ye=De[at.materialIndex];Ye&&Ye.visible&&N.push(C,We,Ye,ie,lt.z,at)}}else De.visible&&N.push(C,We,De,ie,lt.z,null)}}let Fe=C.children;for(let We=0,De=Fe.length;We<De;We++)Ba(Fe[We],j,ie,ee)}function jn(C,j,ie,ee){let{opaque:Q,transmissive:Fe,transparent:We}=C;P.setupLightsView(ie),Et===!0&&Le.setGlobalState(B.clippingPlanes,ie),ee&&Pe.viewport(H.copy(ee)),Q.length>0&&is(Q,j,ie),Fe.length>0&&is(Fe,j,ie),We.length>0&&is(We,j,ie),Pe.buffers.depth.setTest(!0),Pe.buffers.depth.setMask(!0),Pe.buffers.color.setMask(!0),Pe.setPolygonOffset(!1)}function za(C,j,ie,ee){if((ie.isScene===!0?ie.overrideMaterial:null)!==null)return;if(P.state.transmissionRenderTarget[ee.id]===void 0){let Ye=ht.has("EXT_color_buffer_half_float")||ht.has("EXT_color_buffer_float");P.state.transmissionRenderTarget[ee.id]=new Hn(1,1,{generateMipmaps:!0,type:Ye?Gn:Qn,minFilter:xi,samples:Math.max(4,Tt.samples),stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:ut.workingColorSpace})}let Fe=P.state.transmissionRenderTarget[ee.id],We=ee.viewport||H;Fe.setSize(We.z*B.transmissionResolutionScale,We.w*B.transmissionResolutionScale);let De=B.getRenderTarget(),Ie=B.getActiveCubeFace(),qe=B.getActiveMipmapLevel();B.setRenderTarget(Fe),B.getClearColor(fe),be=B.getClearAlpha(),be<1&&B.setClearColor(16777215,.5),B.clear(),gt&&Me.render(ie);let st=B.toneMapping;B.toneMapping=Ni;let at=ee.viewport;if(ee.viewport!==void 0&&(ee.viewport=void 0),P.setupLightsView(ee),Et===!0&&Le.setGlobalState(B.clippingPlanes,ee),is(C,ie,ee),M.updateMultisampleRenderTarget(Fe),M.updateRenderTargetMipmap(Fe),ht.has("WEBGL_multisampled_render_to_texture")===!1){let Ye=!1;for(let Ct=0,Jt=j.length;Ct<Jt;Ct++){let Wt=j[Ct],{object:Mt,geometry:Zt,material:ze,group:Un}=Wt;if(ze.side===Dn&&Mt.layers.test(ee.layers)){let vt=ze.side;ze.side=An,ze.needsUpdate=!0,di(Mt,ie,ee,Zt,ze,Un),ze.side=vt,ze.needsUpdate=!0,Ye=!0}}Ye===!0&&(M.updateMultisampleRenderTarget(Fe),M.updateRenderTargetMipmap(Fe))}B.setRenderTarget(De,Ie,qe),B.setClearColor(fe,be),at!==void 0&&(ee.viewport=at),B.toneMapping=st}function is(C,j,ie){let ee=j.isScene===!0?j.overrideMaterial:null;for(let Q=0,Fe=C.length;Q<Fe;Q++){let We=C[Q],{object:De,geometry:Ie,group:qe}=We,st=We.material;st.allowOverride===!0&&ee!==null&&(st=ee),De.layers.test(ie.layers)&&di(De,j,ie,Ie,st,qe)}}function di(C,j,ie,ee,Q,Fe){C.onBeforeRender(B,j,ie,ee,Q,Fe),C.modelViewMatrix.multiplyMatrices(ie.matrixWorldInverse,C.matrixWorld),C.normalMatrix.getNormalMatrix(C.modelViewMatrix),Q.onBeforeRender(B,j,ie,ee,C,Fe),Q.transparent===!0&&Q.side===Dn&&Q.forceSinglePass===!1?(Q.side=An,Q.needsUpdate=!0,B.renderBufferDirect(ie,j,ee,Q,C,Fe),Q.side=Pi,Q.needsUpdate=!0,B.renderBufferDirect(ie,j,ee,Q,C,Fe),Q.side=Dn):B.renderBufferDirect(ie,j,ee,Q,C,Fe),C.onAfterRender(B,j,ie,ee,Q,Fe)}function rs(C,j,ie){j.isScene!==!0&&(j=Bt);let ee=F.get(C),Q=P.state.lights,Fe=P.state.shadowsArray,We=Q.state.version,De=Ce.getParameters(C,Q.state,Fe,j,ie,P.state.lightProbeGridArray),Ie=Ce.getProgramCacheKey(De),qe=ee.programs;ee.environment=C.isMeshStandardMaterial||C.isMeshLambertMaterial||C.isMeshPhongMaterial?j.environment:null,ee.fog=j.fog;let st=C.isMeshStandardMaterial||C.isMeshLambertMaterial&&!C.envMap||C.isMeshPhongMaterial&&!C.envMap;ee.envMap=Z.get(C.envMap||ee.environment,st),ee.envMapRotation=ee.environment!==null&&C.envMap===null?j.environmentRotation:C.envMapRotation,qe===void 0&&(C.addEventListener("dispose",jt),qe=new Map,ee.programs=qe);let at=qe.get(Ie);if(at!==void 0){if(ee.currentProgram===at&&ee.lightsStateVersion===We)return sr(C,De),at}else De.uniforms=Ce.getUniforms(C),V!==null&&C.isNodeMaterial&&V.build(C,ie,De),C.onBeforeCompile(De,B),at=Ce.acquireProgram(De,Ie),qe.set(Ie,at),ee.uniforms=De.uniforms;let Ye=ee.uniforms;return(!C.isShaderMaterial&&!C.isRawShaderMaterial||C.clipping===!0)&&(Ye.clippingPlanes=Le.uniform),sr(C,De),ee.needsLights=Mi(C),ee.lightsStateVersion=We,ee.needsLights&&(Ye.ambientLightColor.value=Q.state.ambient,Ye.lightProbe.value=Q.state.probe,Ye.directionalLights.value=Q.state.directional,Ye.directionalLightShadows.value=Q.state.directionalShadow,Ye.spotLights.value=Q.state.spot,Ye.spotLightShadows.value=Q.state.spotShadow,Ye.rectAreaLights.value=Q.state.rectArea,Ye.ltc_1.value=Q.state.rectAreaLTC1,Ye.ltc_2.value=Q.state.rectAreaLTC2,Ye.pointLights.value=Q.state.point,Ye.pointLightShadows.value=Q.state.pointShadow,Ye.hemisphereLights.value=Q.state.hemi,Ye.directionalShadowMatrix.value=Q.state.directionalShadowMatrix,Ye.spotLightMatrix.value=Q.state.spotLightMatrix,Ye.spotLightMap.value=Q.state.spotLightMap,Ye.pointShadowMatrix.value=Q.state.pointShadowMatrix),ee.lightProbeGrid=P.state.lightProbeGridArray.length>0,ee.currentProgram=at,ee.uniformsList=null,at}function Ha(C){if(C.uniformsList===null){let j=C.currentProgram.getUniforms();C.uniformsList=Sa.seqWithValue(j.seq,C.uniforms)}return C.uniformsList}function sr(C,j){let ie=F.get(C);ie.outputColorSpace=j.outputColorSpace,ie.batching=j.batching,ie.batchingColor=j.batchingColor,ie.instancing=j.instancing,ie.instancingColor=j.instancingColor,ie.instancingMorph=j.instancingMorph,ie.skinning=j.skinning,ie.morphTargets=j.morphTargets,ie.morphNormals=j.morphNormals,ie.morphColors=j.morphColors,ie.morphTargetsCount=j.morphTargetsCount,ie.numClippingPlanes=j.numClippingPlanes,ie.numIntersection=j.numClipIntersection,ie.vertexAlphas=j.vertexAlphas,ie.vertexTangents=j.vertexTangents,ie.toneMapping=j.toneMapping}function _c(C,j){if(C.length===0)return null;if(C.length===1)return C[0].texture!==null?C[0]:null;T.setFromMatrixPosition(j.matrixWorld);for(let ie=0,ee=C.length;ie<ee;ie++){let Q=C[ie];if(Q.texture!==null&&Q.boundingBox.containsPoint(T))return Q}return null}function yc(C,j,ie,ee,Q){j.isScene!==!0&&(j=Bt),M.resetTextureUnits();let Fe=j.fog,We=ee.isMeshStandardMaterial||ee.isMeshLambertMaterial||ee.isMeshPhongMaterial?j.environment:null,De=E===null?B.outputColorSpace:E.isXRRenderTarget===!0?E.texture.colorSpace:ut.workingColorSpace,Ie=ee.isMeshStandardMaterial||ee.isMeshLambertMaterial&&!ee.envMap||ee.isMeshPhongMaterial&&!ee.envMap,qe=Z.get(ee.envMap||We,Ie),st=ee.vertexColors===!0&&!!ie.attributes.color&&ie.attributes.color.itemSize===4,at=!!ie.attributes.tangent&&(!!ee.normalMap||ee.anisotropy>0),Ye=!!ie.morphAttributes.position,Ct=!!ie.morphAttributes.normal,Jt=!!ie.morphAttributes.color,Wt=Ni;ee.toneMapped&&(E===null||E.isXRRenderTarget===!0)&&(Wt=B.toneMapping);let Mt=ie.morphAttributes.position||ie.morphAttributes.normal||ie.morphAttributes.color,Zt=Mt!==void 0?Mt.length:0,ze=F.get(ee),Un=P.state.lights;if(Et===!0&&(it===!0||C!==O)){let It=C===O&&ee.id===D;Le.setState(ee,C,It)}let vt=!1;ee.version===ze.__version?(ze.needsLights&&ze.lightsStateVersion!==Un.state.version||ze.outputColorSpace!==De||Q.isBatchedMesh&&ze.batching===!1||!Q.isBatchedMesh&&ze.batching===!0||Q.isBatchedMesh&&ze.batchingColor===!0&&Q.colorTexture===null||Q.isBatchedMesh&&ze.batchingColor===!1&&Q.colorTexture!==null||Q.isInstancedMesh&&ze.instancing===!1||!Q.isInstancedMesh&&ze.instancing===!0||Q.isSkinnedMesh&&ze.skinning===!1||!Q.isSkinnedMesh&&ze.skinning===!0||Q.isInstancedMesh&&ze.instancingColor===!0&&Q.instanceColor===null||Q.isInstancedMesh&&ze.instancingColor===!1&&Q.instanceColor!==null||Q.isInstancedMesh&&ze.instancingMorph===!0&&Q.morphTexture===null||Q.isInstancedMesh&&ze.instancingMorph===!1&&Q.morphTexture!==null||ze.envMap!==qe||ee.fog===!0&&ze.fog!==Fe||ze.numClippingPlanes!==void 0&&(ze.numClippingPlanes!==Le.numPlanes||ze.numIntersection!==Le.numIntersection)||ze.vertexAlphas!==st||ze.vertexTangents!==at||ze.morphTargets!==Ye||ze.morphNormals!==Ct||ze.morphColors!==Jt||ze.toneMapping!==Wt||ze.morphTargetsCount!==Zt||!!ze.lightProbeGrid!=P.state.lightProbeGridArray.length>0)&&(vt=!0):(vt=!0,ze.__version=ee.version);let Xn=ze.currentProgram;vt===!0&&(Xn=rs(ee,j,Q),V&&ee.isNodeMaterial&&V.onUpdateProgram(ee,Xn,ze));let sn=!1,hn=!1,kn=!1,At=Xn.getUniforms(),Ft=ze.uniforms;if(Pe.useProgram(Xn.program)&&(sn=!0,hn=!0,kn=!0),ee.id!==D&&(D=ee.id,hn=!0),ze.needsLights){let It=_c(P.state.lightProbeGridArray,Q);ze.lightProbeGrid!==It&&(ze.lightProbeGrid=It,hn=!0)}if(sn||O!==C){Pe.buffers.depth.getReversed()&&C.reversedDepth!==!0&&(C._reversedDepth=!0,C.updateProjectionMatrix()),At.setValue(q,"projectionMatrix",C.projectionMatrix),At.setValue(q,"viewMatrix",C.matrixWorldInverse);let R=At.map.cameraPosition;R!==void 0&&R.setValue(q,wt.setFromMatrixPosition(C.matrixWorld)),Tt.logarithmicDepthBuffer&&At.setValue(q,"logDepthBufFC",2/(Math.log(C.far+1)/Math.LN2)),(ee.isMeshPhongMaterial||ee.isMeshToonMaterial||ee.isMeshLambertMaterial||ee.isMeshBasicMaterial||ee.isMeshStandardMaterial||ee.isShaderMaterial)&&At.setValue(q,"isOrthographic",C.isOrthographicCamera===!0),O!==C&&(O=C,hn=!0,kn=!0)}if(ze.needsLights&&(Un.state.directionalShadowMap.length>0&&At.setValue(q,"directionalShadowMap",Un.state.directionalShadowMap,M),Un.state.spotShadowMap.length>0&&At.setValue(q,"spotShadowMap",Un.state.spotShadowMap,M),Un.state.pointShadowMap.length>0&&At.setValue(q,"pointShadowMap",Un.state.pointShadowMap,M)),Q.isSkinnedMesh){At.setOptional(q,Q,"bindMatrix"),At.setOptional(q,Q,"bindMatrixInverse");let It=Q.skeleton;It&&(It.boneTexture===null&&It.computeBoneTexture(),At.setValue(q,"boneTexture",It.boneTexture,M))}Q.isBatchedMesh&&(At.setOptional(q,Q,"batchingTexture"),At.setValue(q,"batchingTexture",Q._matricesTexture,M),At.setOptional(q,Q,"batchingIdTexture"),At.setValue(q,"batchingIdTexture",Q._indirectTexture,M),At.setOptional(q,Q,"batchingColorTexture"),Q._colorsTexture!==null&&At.setValue(q,"batchingColorTexture",Q._colorsTexture,M));let Bn=ie.morphAttributes;if((Bn.position!==void 0||Bn.normal!==void 0||Bn.color!==void 0)&&je.update(Q,ie,Xn),(hn||ze.receiveShadow!==Q.receiveShadow)&&(ze.receiveShadow=Q.receiveShadow,At.setValue(q,"receiveShadow",Q.receiveShadow)),(ee.isMeshStandardMaterial||ee.isMeshLambertMaterial||ee.isMeshPhongMaterial)&&ee.envMap===null&&j.environment!==null&&(Ft.envMapIntensity.value=j.environmentIntensity),Ft.dfgLUT!==void 0&&(Ft.dfgLUT.value=pT()),hn){if(At.setValue(q,"toneMappingExposure",B.toneMappingExposure),ze.needsLights&&wr(Ft,kn),Fe&&ee.fog===!0&&ce.refreshFogUniforms(Ft,Fe),ce.refreshMaterialUniforms(Ft,ee,ke,Je,P.state.transmissionRenderTarget[C.id]),ze.needsLights&&ze.lightProbeGrid){let It=ze.lightProbeGrid;Ft.probesSH.value=It.texture,Ft.probesMin.value.copy(It.boundingBox.min),Ft.probesMax.value.copy(It.boundingBox.max),Ft.probesResolution.value.copy(It.resolution)}Sa.upload(q,Ha(ze),Ft,M)}if(ee.isShaderMaterial&&ee.uniformsNeedUpdate===!0&&(Sa.upload(q,Ha(ze),Ft,M),ee.uniformsNeedUpdate=!1),ee.isSpriteMaterial&&At.setValue(q,"center",Q.center),At.setValue(q,"modelViewMatrix",Q.modelViewMatrix),At.setValue(q,"normalMatrix",Q.normalMatrix),At.setValue(q,"modelMatrix",Q.matrixWorld),ee.uniformsGroups!==void 0){let It=ee.uniformsGroups;for(let R=0,u=It.length;R<u;R++){let m=It[R];de.update(m,Xn),de.bind(m,Xn)}}return Xn}function wr(C,j){C.ambientLightColor.needsUpdate=j,C.lightProbe.needsUpdate=j,C.directionalLights.needsUpdate=j,C.directionalLightShadows.needsUpdate=j,C.pointLights.needsUpdate=j,C.pointLightShadows.needsUpdate=j,C.spotLights.needsUpdate=j,C.spotLightShadows.needsUpdate=j,C.rectAreaLights.needsUpdate=j,C.hemisphereLights.needsUpdate=j}function Mi(C){return C.isMeshLambertMaterial||C.isMeshToonMaterial||C.isMeshPhongMaterial||C.isMeshStandardMaterial||C.isShadowMaterial||C.isShaderMaterial&&C.lights===!0}this.getActiveCubeFace=function(){return J},this.getActiveMipmapLevel=function(){return L},this.getRenderTarget=function(){return E},this.setRenderTargetTextures=function(C,j,ie){let ee=F.get(C);ee.__autoAllocateDepthBuffer=C.resolveDepthBuffer===!1,ee.__autoAllocateDepthBuffer===!1&&(ee.__useRenderToTexture=!1),F.get(C.texture).__webglTexture=j,F.get(C.depthTexture).__webglTexture=ee.__autoAllocateDepthBuffer?void 0:ie,ee.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(C,j){let ie=F.get(C);ie.__webglFramebuffer=j,ie.__useDefaultFramebuffer=j===void 0};let Fu=q.createFramebuffer();this.setRenderTarget=function(C,j=0,ie=0){E=C,J=j,L=ie;let ee=null,Q=!1,Fe=!1;if(C){let De=F.get(C);if(De.__useDefaultFramebuffer!==void 0){Pe.bindFramebuffer(q.FRAMEBUFFER,De.__webglFramebuffer),H.copy(C.viewport),Y.copy(C.scissor),le=C.scissorTest,Pe.viewport(H),Pe.scissor(Y),Pe.setScissorTest(le),D=-1;return}else if(De.__webglFramebuffer===void 0)M.setupRenderTarget(C);else if(De.__hasExternalTextures)M.rebindTextures(C,F.get(C.texture).__webglTexture,F.get(C.depthTexture).__webglTexture);else if(C.depthBuffer){let st=C.depthTexture;if(De.__boundDepthTexture!==st){if(st!==null&&F.has(st)&&(C.width!==st.image.width||C.height!==st.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");M.setupDepthRenderbuffer(C)}}let Ie=C.texture;(Ie.isData3DTexture||Ie.isDataArrayTexture||Ie.isCompressedArrayTexture)&&(Fe=!0);let qe=F.get(C).__webglFramebuffer;C.isWebGLCubeRenderTarget?(Array.isArray(qe[j])?ee=qe[j][ie]:ee=qe[j],Q=!0):C.samples>0&&M.useMultisampledRTT(C)===!1?ee=F.get(C).__webglMultisampledFramebuffer:Array.isArray(qe)?ee=qe[ie]:ee=qe,H.copy(C.viewport),Y.copy(C.scissor),le=C.scissorTest}else H.copy(_e).multiplyScalar(ke).floor(),Y.copy(Ze).multiplyScalar(ke).floor(),le=tt;if(ie!==0&&(ee=Fu),Pe.bindFramebuffer(q.FRAMEBUFFER,ee)&&Pe.drawBuffers(C,ee),Pe.viewport(H),Pe.scissor(Y),Pe.setScissorTest(le),Q){let De=F.get(C.texture);q.framebufferTexture2D(q.FRAMEBUFFER,q.COLOR_ATTACHMENT0,q.TEXTURE_CUBE_MAP_POSITIVE_X+j,De.__webglTexture,ie)}else if(Fe){let De=j;for(let Ie=0;Ie<C.textures.length;Ie++){let qe=F.get(C.textures[Ie]);q.framebufferTextureLayer(q.FRAMEBUFFER,q.COLOR_ATTACHMENT0+Ie,qe.__webglTexture,ie,De)}}else if(C!==null&&ie!==0){let De=F.get(C.texture);q.framebufferTexture2D(q.FRAMEBUFFER,q.COLOR_ATTACHMENT0,q.TEXTURE_2D,De.__webglTexture,ie)}D=-1},this.readRenderTargetPixels=function(C,j,ie,ee,Q,Fe,We,De=0){if(!(C&&C.isWebGLRenderTarget)){et("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Ie=F.get(C).__webglFramebuffer;if(C.isWebGLCubeRenderTarget&&We!==void 0&&(Ie=Ie[We]),Ie){Pe.bindFramebuffer(q.FRAMEBUFFER,Ie);try{let qe=C.textures[De],st=qe.format,at=qe.type;if(C.textures.length>1&&q.readBuffer(q.COLOR_ATTACHMENT0+De),!Tt.textureFormatReadable(st)){et("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!Tt.textureTypeReadable(at)){et("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}j>=0&&j<=C.width-ee&&ie>=0&&ie<=C.height-Q&&q.readPixels(j,ie,ee,Q,G.convert(st),G.convert(at),Fe)}finally{let qe=E!==null?F.get(E).__webglFramebuffer:null;Pe.bindFramebuffer(q.FRAMEBUFFER,qe)}}},this.readRenderTargetPixelsAsync=async function(C,j,ie,ee,Q,Fe,We,De=0){if(!(C&&C.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Ie=F.get(C).__webglFramebuffer;if(C.isWebGLCubeRenderTarget&&We!==void 0&&(Ie=Ie[We]),Ie)if(j>=0&&j<=C.width-ee&&ie>=0&&ie<=C.height-Q){Pe.bindFramebuffer(q.FRAMEBUFFER,Ie);let qe=C.textures[De],st=qe.format,at=qe.type;if(C.textures.length>1&&q.readBuffer(q.COLOR_ATTACHMENT0+De),!Tt.textureFormatReadable(st))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!Tt.textureTypeReadable(at))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let Ye=q.createBuffer();q.bindBuffer(q.PIXEL_PACK_BUFFER,Ye),q.bufferData(q.PIXEL_PACK_BUFFER,Fe.byteLength,q.STREAM_READ),q.readPixels(j,ie,ee,Q,G.convert(st),G.convert(at),0);let Ct=E!==null?F.get(E).__webglFramebuffer:null;Pe.bindFramebuffer(q.FRAMEBUFFER,Ct);let Jt=q.fenceSync(q.SYNC_GPU_COMMANDS_COMPLETE,0);return q.flush(),await E0(q,Jt,4),q.bindBuffer(q.PIXEL_PACK_BUFFER,Ye),q.getBufferSubData(q.PIXEL_PACK_BUFFER,0,Fe),q.deleteBuffer(Ye),q.deleteSync(Jt),Fe}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(C,j=null,ie=0){let ee=Math.pow(2,-ie),Q=Math.floor(C.image.width*ee),Fe=Math.floor(C.image.height*ee),We=j!==null?j.x:0,De=j!==null?j.y:0;M.setTexture2D(C,0),q.copyTexSubImage2D(q.TEXTURE_2D,ie,0,0,We,De,Q,Fe),Pe.unbindTexture()};let vc=q.createFramebuffer(),ni=q.createFramebuffer();this.copyTextureToTexture=function(C,j,ie=null,ee=null,Q=0,Fe=0){let We,De,Ie,qe,st,at,Ye,Ct,Jt,Wt=C.isCompressedTexture?C.mipmaps[Fe]:C.image;if(ie!==null)We=ie.max.x-ie.min.x,De=ie.max.y-ie.min.y,Ie=ie.isBox3?ie.max.z-ie.min.z:1,qe=ie.min.x,st=ie.min.y,at=ie.isBox3?ie.min.z:0;else{let Ft=Math.pow(2,-Q);We=Math.floor(Wt.width*Ft),De=Math.floor(Wt.height*Ft),C.isDataArrayTexture?Ie=Wt.depth:C.isData3DTexture?Ie=Math.floor(Wt.depth*Ft):Ie=1,qe=0,st=0,at=0}ee!==null?(Ye=ee.x,Ct=ee.y,Jt=ee.z):(Ye=0,Ct=0,Jt=0);let Mt=G.convert(j.format),Zt=G.convert(j.type),ze;j.isData3DTexture?(M.setTexture3D(j,0),ze=q.TEXTURE_3D):j.isDataArrayTexture||j.isCompressedArrayTexture?(M.setTexture2DArray(j,0),ze=q.TEXTURE_2D_ARRAY):(M.setTexture2D(j,0),ze=q.TEXTURE_2D),Pe.activeTexture(q.TEXTURE0),Pe.pixelStorei(q.UNPACK_FLIP_Y_WEBGL,j.flipY),Pe.pixelStorei(q.UNPACK_PREMULTIPLY_ALPHA_WEBGL,j.premultiplyAlpha),Pe.pixelStorei(q.UNPACK_ALIGNMENT,j.unpackAlignment);let Un=Pe.getParameter(q.UNPACK_ROW_LENGTH),vt=Pe.getParameter(q.UNPACK_IMAGE_HEIGHT),Xn=Pe.getParameter(q.UNPACK_SKIP_PIXELS),sn=Pe.getParameter(q.UNPACK_SKIP_ROWS),hn=Pe.getParameter(q.UNPACK_SKIP_IMAGES);Pe.pixelStorei(q.UNPACK_ROW_LENGTH,Wt.width),Pe.pixelStorei(q.UNPACK_IMAGE_HEIGHT,Wt.height),Pe.pixelStorei(q.UNPACK_SKIP_PIXELS,qe),Pe.pixelStorei(q.UNPACK_SKIP_ROWS,st),Pe.pixelStorei(q.UNPACK_SKIP_IMAGES,at);let kn=C.isDataArrayTexture||C.isData3DTexture,At=j.isDataArrayTexture||j.isData3DTexture;if(C.isDepthTexture){let Ft=F.get(C),Bn=F.get(j),It=F.get(Ft.__renderTarget),R=F.get(Bn.__renderTarget);Pe.bindFramebuffer(q.READ_FRAMEBUFFER,It.__webglFramebuffer),Pe.bindFramebuffer(q.DRAW_FRAMEBUFFER,R.__webglFramebuffer);for(let u=0;u<Ie;u++)kn&&(q.framebufferTextureLayer(q.READ_FRAMEBUFFER,q.COLOR_ATTACHMENT0,F.get(C).__webglTexture,Q,at+u),q.framebufferTextureLayer(q.DRAW_FRAMEBUFFER,q.COLOR_ATTACHMENT0,F.get(j).__webglTexture,Fe,Jt+u)),q.blitFramebuffer(qe,st,We,De,Ye,Ct,We,De,q.DEPTH_BUFFER_BIT,q.NEAREST);Pe.bindFramebuffer(q.READ_FRAMEBUFFER,null),Pe.bindFramebuffer(q.DRAW_FRAMEBUFFER,null)}else if(Q!==0||C.isRenderTargetTexture||F.has(C)){let Ft=F.get(C),Bn=F.get(j);Pe.bindFramebuffer(q.READ_FRAMEBUFFER,vc),Pe.bindFramebuffer(q.DRAW_FRAMEBUFFER,ni);for(let It=0;It<Ie;It++)kn?q.framebufferTextureLayer(q.READ_FRAMEBUFFER,q.COLOR_ATTACHMENT0,Ft.__webglTexture,Q,at+It):q.framebufferTexture2D(q.READ_FRAMEBUFFER,q.COLOR_ATTACHMENT0,q.TEXTURE_2D,Ft.__webglTexture,Q),At?q.framebufferTextureLayer(q.DRAW_FRAMEBUFFER,q.COLOR_ATTACHMENT0,Bn.__webglTexture,Fe,Jt+It):q.framebufferTexture2D(q.DRAW_FRAMEBUFFER,q.COLOR_ATTACHMENT0,q.TEXTURE_2D,Bn.__webglTexture,Fe),Q!==0?q.blitFramebuffer(qe,st,We,De,Ye,Ct,We,De,q.COLOR_BUFFER_BIT,q.NEAREST):At?q.copyTexSubImage3D(ze,Fe,Ye,Ct,Jt+It,qe,st,We,De):q.copyTexSubImage2D(ze,Fe,Ye,Ct,qe,st,We,De);Pe.bindFramebuffer(q.READ_FRAMEBUFFER,null),Pe.bindFramebuffer(q.DRAW_FRAMEBUFFER,null)}else At?C.isDataTexture||C.isData3DTexture?q.texSubImage3D(ze,Fe,Ye,Ct,Jt,We,De,Ie,Mt,Zt,Wt.data):j.isCompressedArrayTexture?q.compressedTexSubImage3D(ze,Fe,Ye,Ct,Jt,We,De,Ie,Mt,Wt.data):q.texSubImage3D(ze,Fe,Ye,Ct,Jt,We,De,Ie,Mt,Zt,Wt):C.isDataTexture?q.texSubImage2D(q.TEXTURE_2D,Fe,Ye,Ct,We,De,Mt,Zt,Wt.data):C.isCompressedTexture?q.compressedTexSubImage2D(q.TEXTURE_2D,Fe,Ye,Ct,Wt.width,Wt.height,Mt,Wt.data):q.texSubImage2D(q.TEXTURE_2D,Fe,Ye,Ct,We,De,Mt,Zt,Wt);Pe.pixelStorei(q.UNPACK_ROW_LENGTH,Un),Pe.pixelStorei(q.UNPACK_IMAGE_HEIGHT,vt),Pe.pixelStorei(q.UNPACK_SKIP_PIXELS,Xn),Pe.pixelStorei(q.UNPACK_SKIP_ROWS,sn),Pe.pixelStorei(q.UNPACK_SKIP_IMAGES,hn),Fe===0&&j.generateMipmaps&&q.generateMipmap(ze),Pe.unbindTexture()},this.initRenderTarget=function(C){F.get(C).__webglFramebuffer===void 0&&M.setupRenderTarget(C)},this.initTexture=function(C){C.isCubeTexture?M.setTextureCube(C,0):C.isData3DTexture?M.setTexture3D(C,0):C.isDataArrayTexture||C.isCompressedArrayTexture?M.setTexture2DArray(C,0):M.setTexture2D(C,0),Pe.unbindTexture()},this.resetState=function(){J=0,L=0,E=null,Pe.reset(),we.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Ci}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=ut._getDrawingBufferColorSpace(e),t.unpackColorSpace=ut._getUnpackColorSpace()}}});function Cs(i){let e=new Map,t=new Map,n=i.clone();return cb(i,n,function(r,s){e.set(s,r),t.set(r,s)}),n.traverse(function(r){if(!r.isSkinnedMesh)return;let s=r,a=e.get(r),o=a.skeleton.bones;s.skeleton=a.skeleton.clone(),s.bindMatrix.copy(a.bindMatrix),s.skeleton.bones=o.map(function(l){return t.get(l)}),s.bind(s.skeleton,s.bindMatrix)}),n}function cb(i,e,t){t(i,e);for(let n=0;n<i.children.length;n++)cb(i.children[n],e.children[n],t)}var wh=un(()=>{});var Mb={};Ar(Mb,{HDRLoader:()=>Df});var Df,Ab=un(()=>{Vn();Df=class extends xo{constructor(e){super(e),this.type=Gn}parse(e){let a=function(v,I){switch(v){case 1:throw new Error("THREE.HDRLoader: Read Error: "+(I||""));case 2:throw new Error("THREE.HDRLoader: Write Error: "+(I||""));case 3:throw new Error("THREE.HDRLoader: Bad File Format: "+(I||""));default:case 4:throw new Error("THREE.HDRLoader: Memory Error: "+(I||""))}},d=function(v,I,B){I=I||1024;let V=v.pos,J=-1,L=0,E="",D=String.fromCharCode.apply(null,new Uint16Array(v.subarray(V,V+128)));for(;0>(J=D.indexOf(`
-`))&&L<I&&V<v.byteLength;)E+=D,L+=D.length,V+=128,D=String.fromCharCode.apply(null,new Uint16Array(v.subarray(V,V+128)));return-1<J?(B!==!1&&(v.pos+=L+J+1),E+D.slice(0,J)):!1},f=function(v){let I=/^#\?(\S+)/,B=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,k=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,V=/^\s*FORMAT=(\S+)\s*$/,J=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,L={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0},E,D;for((v.pos>=v.byteLength||!(E=d(v)))&&a(1,"no header found"),(D=E.match(I))||a(3,"bad initial token"),L.valid|=1,L.programtype=D[1],L.string+=E+`
-`;E=d(v),E!==!1;){if(L.string+=E+`
-`,E.charAt(0)==="#"){L.comments+=E+`
-`;continue}if((D=E.match(B))&&(L.gamma=parseFloat(D[1])),(D=E.match(k))&&(L.exposure=parseFloat(D[1])),(D=E.match(V))&&(L.valid|=2,L.format=D[1]),(D=E.match(J))&&(L.valid|=4,L.height=parseInt(D[1],10),L.width=parseInt(D[2],10)),L.valid&2&&L.valid&4)break}return L.valid&2||a(3,"missing format specifier"),L.valid&4||a(3,"missing image size specifier"),L},p=function(v,I,B){let k=I;if(k<8||k>32767||v[0]!==2||v[1]!==2||v[2]&128)return new Uint8Array(v);k!==(v[2]<<8|v[3])&&a(3,"wrong scanline width");let V=new Uint8Array(4*I*B);V.length||a(4,"unable to allocate buffer space");let J=0,L=0,E=4*k,D=new Uint8Array(4),O=new Uint8Array(E),H=B;for(;H>0&&L<v.byteLength;){L+4>v.byteLength&&a(1),D[0]=v[L++],D[1]=v[L++],D[2]=v[L++],D[3]=v[L++],(D[0]!=2||D[1]!=2||(D[2]<<8|D[3])!=k)&&a(3,"bad rgbe scanline format");let Y=0,le;for(;Y<E&&L<v.byteLength;){le=v[L++];let be=le>128;if(be&&(le-=128),(le===0||Y+le>E)&&a(3,"bad scanline data"),be){let Te=v[L++];for(let Je=0;Je<le;Je++)O[Y++]=Te}else O.set(v.subarray(L,L+le),Y),Y+=le,L+=le}let fe=k;for(let be=0;be<fe;be++){let Te=0;V[J]=O[be+Te],Te+=k,V[J+1]=O[be+Te],Te+=k,V[J+2]=O[be+Te],Te+=k,V[J+3]=O[be+Te],J+=4}H--}return V},x=function(v,I,B,k){let V=v[I+3],J=Math.pow(2,V-128)/255;B[k+0]=v[I+0]*J,B[k+1]=v[I+1]*J,B[k+2]=v[I+2]*J,B[k+3]=1},y=function(v,I,B,k){let V=v[I+3],J=Math.pow(2,V-128)/255;B[k+0]=Fr.toHalfFloat(Math.min(v[I+0]*J,65504)),B[k+1]=Fr.toHalfFloat(Math.min(v[I+1]*J,65504)),B[k+2]=Fr.toHalfFloat(Math.min(v[I+2]*J,65504)),B[k+3]=Fr.toHalfFloat(1)},b=new Uint8Array(e);b.pos=0;let g=f(b),S=g.width,A=g.height,T=p(b.subarray(b.pos),S,A),N,P,U;switch(this.type){case Tn:U=T.length/4;let v=new Float32Array(U*4);for(let B=0;B<U;B++)x(T,B*4,v,B*4);N=v,P=Tn;break;case Gn:U=T.length/4;let I=new Uint16Array(U*4);for(let B=0;B<U;B++)y(T,B*4,I,B*4);N=I,P=Gn;break;default:throw new Error("THREE.HDRLoader: Unsupported type: "+this.type)}return{width:S,height:A,data:N,header:g.string,gamma:g.gamma,exposure:g.exposure,type:P}}setDataType(e){return this.type=e,this}load(e,t,n,r){function s(a,o){switch(a.type){case Tn:case Gn:a.colorSpace=bn,a.minFilter=zt,a.magFilter=zt,a.generateMipmaps=!1,a.flipY=!0;break}t&&t(a,o)}return super.load(e,s,n,r)}}});function Bf(i,e){if(e===kd)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),i;if(e===ya||e===ko){let t=i.getIndex();if(t===null){let a=[],o=i.getAttribute("position");if(o!==void 0){for(let l=0;l<o.count;l++)a.push(l);i.setIndex(a),t=i.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),i}let n=t.count-2,r=[];if(e===ya)for(let a=1;a<=n;a++)r.push(t.getX(0)),r.push(t.getX(a)),r.push(t.getX(a+1));else for(let a=0;a<n;a++)a%2===0?(r.push(t.getX(a)),r.push(t.getX(a+1)),r.push(t.getX(a+2))):(r.push(t.getX(a+2)),r.push(t.getX(a+1)),r.push(t.getX(a)));r.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");let s=i.clone();return s.setIndex(r),s.clearGroups(),s}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),i}var Fb=un(()=>{Vn()});function nE(){let i={};return{get:function(e){return i[e]},add:function(e,t){i[e]=t},remove:function(e){delete i[e]},removeAll:function(){i={}}}}function cn(i,e,t){let n=i.json.materials[e];return n.extensions&&n.extensions[t]?n.extensions[t]:null}function sE(i){return i.DefaultMaterial===void 0&&(i.DefaultMaterial=new gi({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:Pi})),i.DefaultMaterial}function Ds(i,e,t){for(let n in t.extensions)i[n]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=t.extensions[n])}function nr(i,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(i.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function aE(i,e,t){let n=!1,r=!1,s=!1;for(let c=0,h=e.length;c<h;c++){let d=e[c];if(d.POSITION!==void 0&&(n=!0),d.NORMAL!==void 0&&(r=!0),d.COLOR_0!==void 0&&(s=!0),n&&r&&s)break}if(!n&&!r&&!s)return Promise.resolve(i);let a=[],o=[],l=[];for(let c=0,h=e.length;c<h;c++){let d=e[c];if(n){let f=d.POSITION!==void 0?t.getDependency("accessor",d.POSITION):i.attributes.position;a.push(f)}if(r){let f=d.NORMAL!==void 0?t.getDependency("accessor",d.NORMAL):i.attributes.normal;o.push(f)}if(s){let f=d.COLOR_0!==void 0?t.getDependency("accessor",d.COLOR_0):i.attributes.color;l.push(f)}}return Promise.all([Promise.all(a),Promise.all(o),Promise.all(l)]).then(function(c){let h=c[0],d=c[1],f=c[2];return n&&(i.morphAttributes.position=h),r&&(i.morphAttributes.normal=d),s&&(i.morphAttributes.color=f),i.morphTargetsRelative=!0,i})}function oE(i,e){if(i.updateMorphTargets(),e.weights!==void 0)for(let t=0,n=e.weights.length;t<n;t++)i.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){let t=e.extras.targetNames;if(i.morphTargetInfluences.length===t.length){i.morphTargetDictionary={};for(let n=0,r=t.length;n<r;n++)i.morphTargetDictionary[t[n]]=n}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function cE(i){let e,t=i.extensions&&i.extensions[_t.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+Gf(t.attributes):e=i.indices+":"+Gf(i.attributes)+":"+i.mode,i.targets!==void 0)for(let n=0,r=i.targets.length;n<r;n++)e+=":"+Gf(i.targets[n]);return e}function Gf(i){let e="",t=Object.keys(i).sort();for(let n=0,r=t.length;n<r;n++)e+=t[n]+":"+i[t[n]]+";";return e}function dp(i){switch(i){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function lE(i){return i.search(/\.jpe?g($|\?)/i)>0||i.search(/^data\:image\/jpeg/)===0?"image/jpeg":i.search(/\.webp($|\?)/i)>0||i.search(/^data\:image\/webp/)===0?"image/webp":i.search(/\.ktx2($|\?)/i)>0||i.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}function uE(i,e,t){let n=e.attributes,r=new rn;if(n.POSITION!==void 0){let o=t.json.accessors[n.POSITION],l=o.min,c=o.max;if(l!==void 0&&c!==void 0){if(r.set(new W(l[0],l[1],l[2]),new W(c[0],c[1],c[2])),o.normalized){let h=dp(Pa[o.componentType]);r.min.multiplyScalar(h),r.max.multiplyScalar(h)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;let s=e.targets;if(s!==void 0){let o=new W,l=new W;for(let c=0,h=s.length;c<h;c++){let d=s[c];if(d.POSITION!==void 0){let f=t.json.accessors[d.POSITION],p=f.min,x=f.max;if(p!==void 0&&x!==void 0){if(l.setX(Math.max(Math.abs(p[0]),Math.abs(x[0]))),l.setY(Math.max(Math.abs(p[1]),Math.abs(x[1]))),l.setZ(Math.max(Math.abs(p[2]),Math.abs(x[2]))),f.normalized){let y=dp(Pa[f.componentType]);l.multiplyScalar(y)}o.max(l)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}r.expandByVector(o)}i.boundingBox=r;let a=new Yn;r.getCenter(a.center),a.radius=r.min.distanceTo(r.max)/2,i.boundingSphere=a}function zb(i,e,t){let n=e.attributes,r=[];function s(a,o){return t.getDependency("accessor",a).then(function(l){i.setAttribute(o,l)})}for(let a in n){let o=up[a]||a.toLowerCase();o in i.attributes||r.push(s(n[a],o))}if(e.indices!==void 0&&!i.index){let a=t.getDependency("accessor",e.indices).then(function(o){i.setIndex(o)});r.push(a)}return ut.workingColorSpace!==bn&&"COLOR_0"in n&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${ut.workingColorSpace}" not supported.`),nr(i,e),uE(i,e,t),Promise.all(r).then(function(){return e.targets!==void 0?aE(i,e.targets,t):i})}var kh,_t,Vf,Wf,qf,$f,jf,Xf,Kf,Yf,Jf,Zf,Qf,ep,tp,np,ip,rp,Bh,sp,Hb,jo,Ub,ap,op,cp,lp,zh,iE,hp,_i,Pa,kb,Bb,zf,up,Yr,rE,Hf,hE,fp,Gb=un(()=>{Vn();Fb();wh();kh=class extends oi{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new $f(t)}),this.register(function(t){return new jf(t)}),this.register(function(t){return new np(t)}),this.register(function(t){return new ip(t)}),this.register(function(t){return new rp(t)}),this.register(function(t){return new Kf(t)}),this.register(function(t){return new Yf(t)}),this.register(function(t){return new Jf(t)}),this.register(function(t){return new Zf(t)}),this.register(function(t){return new qf(t)}),this.register(function(t){return new Qf(t)}),this.register(function(t){return new Xf(t)}),this.register(function(t){return new tp(t)}),this.register(function(t){return new ep(t)}),this.register(function(t){return new Vf(t)}),this.register(function(t){return new Bh(t,_t.EXT_MESHOPT_COMPRESSION)}),this.register(function(t){return new Bh(t,_t.KHR_MESHOPT_COMPRESSION)}),this.register(function(t){return new sp(t)})}load(e,t,n,r){let s=this,a;if(this.resourcePath!=="")a=this.resourcePath;else if(this.path!==""){let c=br.extractUrlBase(e);a=br.resolveURL(c,this.path)}else a=br.extractUrlBase(e);this.manager.itemStart(e);let o=function(c){r?r(c):console.error(c),s.manager.itemError(e),s.manager.itemEnd(e)},l=new Yi(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(this.withCredentials),l.load(e,function(c){try{s.parse(c,a,function(h){t(h),s.manager.itemEnd(e)},o)}catch(h){o(h)}},n,o)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,r){let s,a={},o={},l=new TextDecoder;if(typeof e=="string")s=JSON.parse(e);else if(e instanceof ArrayBuffer)if(l.decode(new Uint8Array(e,0,4))===Hb){try{a[_t.KHR_BINARY_GLTF]=new ap(e)}catch(d){r&&r(d);return}s=JSON.parse(a[_t.KHR_BINARY_GLTF].content)}else s=JSON.parse(l.decode(e));else s=e;if(s.asset===void 0||s.asset.version[0]<2){r&&r(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}let c=new fp(s,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let h=0;h<this.pluginCallbacks.length;h++){let d=this.pluginCallbacks[h](c);d.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),o[d.name]=d,a[d.name]=!0}if(s.extensionsUsed)for(let h=0;h<s.extensionsUsed.length;++h){let d=s.extensionsUsed[h],f=s.extensionsRequired||[];switch(d){case _t.KHR_MATERIALS_UNLIT:a[d]=new Wf;break;case _t.KHR_DRACO_MESH_COMPRESSION:a[d]=new op(s,this.dracoLoader);break;case _t.KHR_TEXTURE_TRANSFORM:a[d]=new cp;break;case _t.KHR_MESH_QUANTIZATION:a[d]=new lp;break;default:f.indexOf(d)>=0&&o[d]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+d+'".')}}c.setExtensions(a),c.setPlugins(o),c.parse(n,r)}parseAsync(e,t){let n=this;return new Promise(function(r,s){n.parse(e,t,r,s)})}};_t={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",KHR_MESHOPT_COMPRESSION:"KHR_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"},Vf=class{constructor(e){this.parser=e,this.name=_t.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let n=0,r=t.length;n<r;n++){let s=t[n];s.extensions&&s.extensions[this.name]&&s.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,s.extensions[this.name].light)}}_loadLight(e){let t=this.parser,n="light:"+e,r=t.cache.get(n);if(r)return r;let s=t.json,l=((s.extensions&&s.extensions[this.name]||{}).lights||[])[e],c,h=new Ve(16777215);l.color!==void 0&&h.setRGB(l.color[0],l.color[1],l.color[2],bn);let d=l.range!==void 0?l.range:0;switch(l.type){case"directional":c=new Di(h),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new ws(h),c.distance=d;break;case"spot":c=new So(h),c.distance=d,l.spot=l.spot||{},l.spot.innerConeAngle=l.spot.innerConeAngle!==void 0?l.spot.innerConeAngle:0,l.spot.outerConeAngle=l.spot.outerConeAngle!==void 0?l.spot.outerConeAngle:Math.PI/4,c.angle=l.spot.outerConeAngle,c.penumbra=1-l.spot.innerConeAngle/l.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+l.type)}return c.position.set(0,0,0),nr(c,l),l.intensity!==void 0&&(c.intensity=l.intensity),c.name=t.createUniqueName(l.name||"light_"+e),r=Promise.resolve(c),t.cache.add(n,r),r}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){let t=this,n=this.parser,s=n.json.nodes[e],o=(s.extensions&&s.extensions[this.name]||{}).light;return o===void 0?null:this._loadLight(o).then(function(l){return n._getNodeRef(t.cache,o,l)})}},Wf=class{constructor(){this.name=_t.KHR_MATERIALS_UNLIT}getMaterialType(){return gn}extendParams(e,t,n){let r=[];e.color=new Ve(1,1,1),e.opacity=1;let s=t.pbrMetallicRoughness;if(s){if(Array.isArray(s.baseColorFactor)){let a=s.baseColorFactor;e.color.setRGB(a[0],a[1],a[2],bn),e.opacity=a[3]}s.baseColorTexture!==void 0&&r.push(n.assignTexture(e,"map",s.baseColorTexture,Xt))}return Promise.all(r)}},qf=class{constructor(e){this.parser=e,this.name=_t.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){let n=cn(this.parser,e,this.name);return n===null||n.emissiveStrength!==void 0&&(t.emissiveIntensity=n.emissiveStrength),Promise.resolve()}},$f=class{constructor(e){this.parser=e,this.name=_t.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){return cn(this.parser,e,this.name)!==null?Jn:null}extendMaterialParams(e,t){let n=cn(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];if(n.clearcoatFactor!==void 0&&(t.clearcoat=n.clearcoatFactor),n.clearcoatTexture!==void 0&&r.push(this.parser.assignTexture(t,"clearcoatMap",n.clearcoatTexture)),n.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=n.clearcoatRoughnessFactor),n.clearcoatRoughnessTexture!==void 0&&r.push(this.parser.assignTexture(t,"clearcoatRoughnessMap",n.clearcoatRoughnessTexture)),n.clearcoatNormalTexture!==void 0&&(r.push(this.parser.assignTexture(t,"clearcoatNormalMap",n.clearcoatNormalTexture)),n.clearcoatNormalTexture.scale!==void 0)){let s=n.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new dt(s,s)}return Promise.all(r)}},jf=class{constructor(e){this.parser=e,this.name=_t.KHR_MATERIALS_DISPERSION}getMaterialType(e){return cn(this.parser,e,this.name)!==null?Jn:null}extendMaterialParams(e,t){let n=cn(this.parser,e,this.name);return n===null||(t.dispersion=n.dispersion!==void 0?n.dispersion:0),Promise.resolve()}},Xf=class{constructor(e){this.parser=e,this.name=_t.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){return cn(this.parser,e,this.name)!==null?Jn:null}extendMaterialParams(e,t){let n=cn(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];return n.iridescenceFactor!==void 0&&(t.iridescence=n.iridescenceFactor),n.iridescenceTexture!==void 0&&r.push(this.parser.assignTexture(t,"iridescenceMap",n.iridescenceTexture)),n.iridescenceIor!==void 0&&(t.iridescenceIOR=n.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),n.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=n.iridescenceThicknessMinimum),n.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=n.iridescenceThicknessMaximum),n.iridescenceThicknessTexture!==void 0&&r.push(this.parser.assignTexture(t,"iridescenceThicknessMap",n.iridescenceThicknessTexture)),Promise.all(r)}},Kf=class{constructor(e){this.parser=e,this.name=_t.KHR_MATERIALS_SHEEN}getMaterialType(e){return cn(this.parser,e,this.name)!==null?Jn:null}extendMaterialParams(e,t){let n=cn(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];if(t.sheenColor=new Ve(0,0,0),t.sheenRoughness=0,t.sheen=1,n.sheenColorFactor!==void 0){let s=n.sheenColorFactor;t.sheenColor.setRGB(s[0],s[1],s[2],bn)}return n.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=n.sheenRoughnessFactor),n.sheenColorTexture!==void 0&&r.push(this.parser.assignTexture(t,"sheenColorMap",n.sheenColorTexture,Xt)),n.sheenRoughnessTexture!==void 0&&r.push(this.parser.assignTexture(t,"sheenRoughnessMap",n.sheenRoughnessTexture)),Promise.all(r)}},Yf=class{constructor(e){this.parser=e,this.name=_t.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){return cn(this.parser,e,this.name)!==null?Jn:null}extendMaterialParams(e,t){let n=cn(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];return n.transmissionFactor!==void 0&&(t.transmission=n.transmissionFactor),n.transmissionTexture!==void 0&&r.push(this.parser.assignTexture(t,"transmissionMap",n.transmissionTexture)),Promise.all(r)}},Jf=class{constructor(e){this.parser=e,this.name=_t.KHR_MATERIALS_VOLUME}getMaterialType(e){return cn(this.parser,e,this.name)!==null?Jn:null}extendMaterialParams(e,t){let n=cn(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];t.thickness=n.thicknessFactor!==void 0?n.thicknessFactor:0,n.thicknessTexture!==void 0&&r.push(this.parser.assignTexture(t,"thicknessMap",n.thicknessTexture)),t.attenuationDistance=n.attenuationDistance||1/0;let s=n.attenuationColor||[1,1,1];return t.attenuationColor=new Ve().setRGB(s[0],s[1],s[2],bn),Promise.all(r)}},Zf=class{constructor(e){this.parser=e,this.name=_t.KHR_MATERIALS_IOR}getMaterialType(e){return cn(this.parser,e,this.name)!==null?Jn:null}extendMaterialParams(e,t){let n=cn(this.parser,e,this.name);return n===null||(t.ior=n.ior!==void 0?n.ior:1.5,t.ior===0&&(t.ior=1e3)),Promise.resolve()}},Qf=class{constructor(e){this.parser=e,this.name=_t.KHR_MATERIALS_SPECULAR}getMaterialType(e){return cn(this.parser,e,this.name)!==null?Jn:null}extendMaterialParams(e,t){let n=cn(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];t.specularIntensity=n.specularFactor!==void 0?n.specularFactor:1,n.specularTexture!==void 0&&r.push(this.parser.assignTexture(t,"specularIntensityMap",n.specularTexture));let s=n.specularColorFactor||[1,1,1];return t.specularColor=new Ve().setRGB(s[0],s[1],s[2],bn),n.specularColorTexture!==void 0&&r.push(this.parser.assignTexture(t,"specularColorMap",n.specularColorTexture,Xt)),Promise.all(r)}},ep=class{constructor(e){this.parser=e,this.name=_t.EXT_MATERIALS_BUMP}getMaterialType(e){return cn(this.parser,e,this.name)!==null?Jn:null}extendMaterialParams(e,t){let n=cn(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];return t.bumpScale=n.bumpFactor!==void 0?n.bumpFactor:1,n.bumpTexture!==void 0&&r.push(this.parser.assignTexture(t,"bumpMap",n.bumpTexture)),Promise.all(r)}},tp=class{constructor(e){this.parser=e,this.name=_t.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){return cn(this.parser,e,this.name)!==null?Jn:null}extendMaterialParams(e,t){let n=cn(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];return n.anisotropyStrength!==void 0&&(t.anisotropy=n.anisotropyStrength),n.anisotropyRotation!==void 0&&(t.anisotropyRotation=n.anisotropyRotation),n.anisotropyTexture!==void 0&&r.push(this.parser.assignTexture(t,"anisotropyMap",n.anisotropyTexture)),Promise.all(r)}},np=class{constructor(e){this.parser=e,this.name=_t.KHR_TEXTURE_BASISU}loadTexture(e){let t=this.parser,n=t.json,r=n.textures[e];if(!r.extensions||!r.extensions[this.name])return null;let s=r.extensions[this.name],a=t.options.ktx2Loader;if(!a){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,s.source,a)}},ip=class{constructor(e){this.parser=e,this.name=_t.EXT_TEXTURE_WEBP}loadTexture(e){let t=this.name,n=this.parser,r=n.json,s=r.textures[e];if(!s.extensions||!s.extensions[t])return null;let a=s.extensions[t],o=r.images[a.source],l=n.textureLoader;if(o.uri){let c=n.options.manager.getHandler(o.uri);c!==null&&(l=c)}return n.loadTextureImage(e,a.source,l)}},rp=class{constructor(e){this.parser=e,this.name=_t.EXT_TEXTURE_AVIF}loadTexture(e){let t=this.name,n=this.parser,r=n.json,s=r.textures[e];if(!s.extensions||!s.extensions[t])return null;let a=s.extensions[t],o=r.images[a.source],l=n.textureLoader;if(o.uri){let c=n.options.manager.getHandler(o.uri);c!==null&&(l=c)}return n.loadTextureImage(e,a.source,l)}},Bh=class{constructor(e,t){this.name=t,this.parser=e}loadBufferView(e){let t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){let r=n.extensions[this.name],s=this.parser.getDependency("buffer",r.buffer),a=this.parser.options.meshoptDecoder;if(!a||!a.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return s.then(function(o){let l=r.byteOffset||0,c=r.byteLength||0,h=r.count,d=r.byteStride,f=new Uint8Array(o,l,c);return a.decodeGltfBufferAsync?a.decodeGltfBufferAsync(h,d,f,r.mode,r.filter).then(function(p){return p.buffer}):a.ready.then(function(){let p=new ArrayBuffer(h*d);return a.decodeGltfBuffer(new Uint8Array(p),h,d,f,r.mode,r.filter),p})})}else return null}},sp=class{constructor(e){this.name=_t.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){let t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;let r=t.meshes[n.mesh];for(let c of r.primitives)if(c.mode!==_i.TRIANGLES&&c.mode!==_i.TRIANGLE_STRIP&&c.mode!==_i.TRIANGLE_FAN&&c.mode!==void 0)return null;let a=n.extensions[this.name].attributes,o=[],l={};for(let c in a)o.push(this.parser.getDependency("accessor",a[c]).then(h=>(l[c]=h,l[c])));return o.length<1?null:(o.push(this.parser.createNodeMesh(e)),Promise.all(o).then(c=>{let h=c.pop(),d=h.isGroup?h.children:[h],f=c[0].count,p=[];for(let x of d){let y=new ot,b=new W,g=new Pt,S=new W(1,1,1),A=new _s(x.geometry,x.material,f);for(let T=0;T<f;T++)l.TRANSLATION&&b.fromBufferAttribute(l.TRANSLATION,T),l.ROTATION&&g.fromBufferAttribute(l.ROTATION,T),l.SCALE&&S.fromBufferAttribute(l.SCALE,T),A.setMatrixAt(T,y.compose(b,g,S));for(let T in l)if(T==="_COLOR_0"){let N=l[T];A.instanceColor=new zr(N.array,N.itemSize,N.normalized)}else T!=="TRANSLATION"&&T!=="ROTATION"&&T!=="SCALE"&&x.geometry.setAttribute(T,l[T]);qt.prototype.copy.call(A,x),this.parser.assignFinalMaterial(A),p.push(A)}return h.isGroup?(h.clear(),h.add(...p),h):p[0]}))}},Hb="glTF",jo=12,Ub={JSON:1313821514,BIN:5130562},ap=class{constructor(e){this.name=_t.KHR_BINARY_GLTF,this.content=null,this.body=null;let t=new DataView(e,0,jo),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Hb)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");let r=this.header.length-jo,s=new DataView(e,jo),a=0;for(;a<r;){let o=s.getUint32(a,!0);a+=4;let l=s.getUint32(a,!0);if(a+=4,l===Ub.JSON){let c=new Uint8Array(e,jo+a,o);this.content=n.decode(c)}else if(l===Ub.BIN){let c=jo+a;this.body=e.slice(c,c+o)}a+=o}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}},op=class{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=_t.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){let n=this.json,r=this.dracoLoader,s=e.extensions[this.name].bufferView,a=e.extensions[this.name].attributes,o={},l={},c={};for(let h in a){let d=up[h]||h.toLowerCase();o[d]=a[h]}for(let h in e.attributes){let d=up[h]||h.toLowerCase();if(a[h]!==void 0){let f=n.accessors[e.attributes[h]],p=Pa[f.componentType];c[d]=p.name,l[d]=f.normalized===!0}}return t.getDependency("bufferView",s).then(function(h){return new Promise(function(d,f){r.decodeDracoFile(h,function(p){for(let x in p.attributes){let y=p.attributes[x],b=l[x];b!==void 0&&(y.normalized=b)}d(p)},o,c,bn,f)})})}},cp=class{constructor(){this.name=_t.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0||(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}},lp=class{constructor(){this.name=_t.KHR_MESH_QUANTIZATION}},zh=class extends $i{constructor(e,t,n,r){super(e,t,n,r)}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,r=this.valueSize,s=e*r*3+r;for(let a=0;a!==r;a++)t[a]=n[s+a];return t}interpolate_(e,t,n,r){let s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=o*2,c=o*3,h=r-t,d=(n-t)/h,f=d*d,p=f*d,x=e*c,y=x-c,b=-2*p+3*f,g=p-f,S=1-b,A=g-f+d;for(let T=0;T!==o;T++){let N=a[y+T+o],P=a[y+T+l]*h,U=a[x+T+o],v=a[x+T]*h;s[T]=S*N+A*P+b*U+g*v}return s}},iE=new Pt,hp=class extends zh{interpolate_(e,t,n,r){let s=super.interpolate_(e,t,n,r);return iE.fromArray(s).normalize().toArray(s),s}},_i={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},Pa={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},kb={9728:on,9729:zt,9984:Pl,9985:ga,9986:Ts,9987:xi},Bb={33071:Kn,33648:ra,10497:Nr},zf={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},up={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},Yr={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},rE={CUBICSPLINE:void 0,LINEAR:gs,STEP:ms},Hf={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};hE=new ot,fp=class{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new nE,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,r=-1,s=!1,a=-1;if(typeof navigator<"u"&&typeof navigator.userAgent<"u"){let o=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(o)===!0;let l=o.match(/Version\/(\d+)/);r=n&&l?parseInt(l[1],10):-1,s=o.indexOf("Firefox")>-1,a=s?o.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||n&&r<17||s&&a<98?this.textureLoader=new _o(this.options.manager):this.textureLoader=new Mo(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Yi(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){let n=this,r=this.json,s=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(a){return a._markDefs&&a._markDefs()}),Promise.all(this._invokeAll(function(a){return a.beforeRoot&&a.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(a){let o={scene:a[0][r.scene||0],scenes:a[0],animations:a[1],cameras:a[2],asset:r.asset,parser:n,userData:{}};return Ds(s,o,r),nr(o,r),Promise.all(n._invokeAll(function(l){return l.afterRoot&&l.afterRoot(o)})).then(function(){for(let l of o.scenes)l.updateMatrixWorld();e(o)})}).catch(t)}_markDefs(){let e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let r=0,s=t.length;r<s;r++){let a=t[r].joints;for(let o=0,l=a.length;o<l;o++)e[a[o]].isBone=!0}for(let r=0,s=e.length;r<s;r++){let a=e[r];a.mesh!==void 0&&(this._addNodeRef(this.meshCache,a.mesh),a.skin!==void 0&&(n[a.mesh].isSkinnedMesh=!0)),a.camera!==void 0&&this._addNodeRef(this.cameraCache,a.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;let r=n.clone(),s=(a,o)=>{let l=this.associations.get(a);l!=null&&this.associations.set(o,l);for(let[c,h]of a.children.entries())s(h,o.children[c])};return s(n,r),r.name+="_instance_"+e.uses[t]++,r}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){let r=e(t[n]);if(r)return r}return null}_invokeAll(e){let t=Object.values(this.plugins);t.unshift(this);let n=[];for(let r=0;r<t.length;r++){let s=e(t[r]);s&&n.push(s)}return n}getDependency(e,t){let n=e+":"+t,r=this.cache.get(n);if(!r){switch(e){case"scene":r=this.loadScene(t);break;case"node":r=this._invokeOne(function(s){return s.loadNode&&s.loadNode(t)});break;case"mesh":r=this._invokeOne(function(s){return s.loadMesh&&s.loadMesh(t)});break;case"accessor":r=this.loadAccessor(t);break;case"bufferView":r=this._invokeOne(function(s){return s.loadBufferView&&s.loadBufferView(t)});break;case"buffer":r=this.loadBuffer(t);break;case"material":r=this._invokeOne(function(s){return s.loadMaterial&&s.loadMaterial(t)});break;case"texture":r=this._invokeOne(function(s){return s.loadTexture&&s.loadTexture(t)});break;case"skin":r=this.loadSkin(t);break;case"animation":r=this._invokeOne(function(s){return s.loadAnimation&&s.loadAnimation(t)});break;case"camera":r=this.loadCamera(t);break;default:if(r=this._invokeOne(function(s){return s!=this&&s.getDependency&&s.getDependency(e,t)}),!r)throw new Error("Unknown type: "+e);break}this.cache.add(n,r)}return r}getDependencies(e){let t=this.cache.get(e);if(!t){let n=this,r=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(r.map(function(s,a){return n.getDependency(e,a)})),this.cache.add(e,t)}return t}loadBuffer(e){let t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[_t.KHR_BINARY_GLTF].body);let r=this.options;return new Promise(function(s,a){n.load(br.resolveURL(t.uri,r.path),s,void 0,function(){a(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){let t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(n){let r=t.byteLength||0,s=t.byteOffset||0;return n.slice(s,s+r)})}loadAccessor(e){let t=this,n=this.json,r=this.json.accessors[e];if(r.bufferView===void 0&&r.sparse===void 0){let a=zf[r.type],o=Pa[r.componentType],l=r.normalized===!0,c=new o(r.count*a);return Promise.resolve(new Kt(c,a,l))}let s=[];return r.bufferView!==void 0?s.push(this.getDependency("bufferView",r.bufferView)):s.push(null),r.sparse!==void 0&&(s.push(this.getDependency("bufferView",r.sparse.indices.bufferView)),s.push(this.getDependency("bufferView",r.sparse.values.bufferView))),Promise.all(s).then(function(a){let o=a[0],l=zf[r.type],c=Pa[r.componentType],h=c.BYTES_PER_ELEMENT,d=h*l,f=r.byteOffset||0,p=r.bufferView!==void 0?n.bufferViews[r.bufferView].byteStride:void 0,x=r.normalized===!0,y,b;if(p&&p!==d){let g=Math.floor(f/p),S="InterleavedBuffer:"+r.bufferView+":"+r.componentType+":"+g+":"+r.count,A=t.cache.get(S);A||(y=new c(o,g*p,r.count*p/h),A=new Ur(y,p/h),t.cache.add(S,A)),b=new kr(A,l,f%p/h,x)}else o===null?y=new c(r.count*l):y=new c(o,f,r.count*l),b=new Kt(y,l,x);if(r.sparse!==void 0){let g=zf.SCALAR,S=Pa[r.sparse.indices.componentType],A=r.sparse.indices.byteOffset||0,T=r.sparse.values.byteOffset||0,N=new S(a[1],A,r.sparse.count*g),P=new c(a[2],T,r.sparse.count*l);o!==null&&(b=new Kt(b.array.slice(),b.itemSize,b.normalized)),b.normalized=!1;for(let U=0,v=N.length;U<v;U++){let I=N[U];if(b.setX(I,P[U*l]),l>=2&&b.setY(I,P[U*l+1]),l>=3&&b.setZ(I,P[U*l+2]),l>=4&&b.setW(I,P[U*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}b.normalized=x}return b})}loadTexture(e){let t=this.json,n=this.options,s=t.textures[e].source,a=t.images[s],o=this.textureLoader;if(a.uri){let l=n.manager.getHandler(a.uri);l!==null&&(o=l)}return this.loadTextureImage(e,s,o)}loadTextureImage(e,t,n){let r=this,s=this.json,a=s.textures[e],o=s.images[t],l=(o.uri||o.bufferView)+":"+a.sampler;if(this.textureCache[l])return this.textureCache[l];let c=this.loadImageSource(t,n).then(function(h){h.flipY=!1,h.name=a.name||o.name||"",h.name===""&&typeof o.uri=="string"&&o.uri.startsWith("data:image/")===!1&&(h.name=o.uri);let f=(s.samplers||{})[a.sampler]||{};return h.magFilter=kb[f.magFilter]||zt,h.minFilter=kb[f.minFilter]||xi,h.wrapS=Bb[f.wrapS]||Nr,h.wrapT=Bb[f.wrapT]||Nr,h.generateMipmaps=!h.isCompressedTexture&&h.minFilter!==on&&h.minFilter!==zt,r.associations.set(h,{textures:e}),h}).catch(function(){return null});return this.textureCache[l]=c,c}loadImageSource(e,t){let n=this,r=this.json,s=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(d=>d.clone());let a=r.images[e],o=self.URL||self.webkitURL,l=a.uri||"",c=!1;if(a.bufferView!==void 0)l=n.getDependency("bufferView",a.bufferView).then(function(d){c=!0;let f=new Blob([d],{type:a.mimeType});return l=o.createObjectURL(f),l});else if(a.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");let h=Promise.resolve(l).then(function(d){return new Promise(function(f,p){let x=f;t.isImageBitmapLoader===!0&&(x=function(y){let b=new xn(y);b.needsUpdate=!0,f(b)}),t.load(br.resolveURL(d,s.path),x,void 0,p)})}).then(function(d){return c===!0&&o.revokeObjectURL(l),nr(d,a),d.userData.mimeType=a.mimeType||lE(a.uri),d}).catch(function(d){throw console.error("THREE.GLTFLoader: Couldn't load texture",l),d});return this.sourceCache[e]=h,h}assignTexture(e,t,n,r){let s=this;return this.getDependency("texture",n.index).then(function(a){if(!a)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(a=a.clone(),a.channel=n.texCoord),s.extensions[_t.KHR_TEXTURE_TRANSFORM]){let o=n.extensions!==void 0?n.extensions[_t.KHR_TEXTURE_TRANSFORM]:void 0;if(o){let l=s.associations.get(a);a=s.extensions[_t.KHR_TEXTURE_TRANSFORM].extendTexture(a,o),s.associations.set(a,l)}}return r!==void 0&&(a.colorSpace=r),e[t]=a,a})}assignFinalMaterial(e){let t=e.geometry,n=e.material,r=t.attributes.tangent===void 0,s=t.attributes.color!==void 0,a=t.attributes.normal===void 0;if(e.isPoints){let o="PointsMaterial:"+n.uuid,l=this.cache.get(o);l||(l=new pa,Ln.prototype.copy.call(l,n),l.color.copy(n.color),l.map=n.map,l.sizeAttenuation=!1,this.cache.add(o,l)),n=l}else if(e.isLine){let o="LineBasicMaterial:"+n.uuid,l=this.cache.get(o);l||(l=new ys,Ln.prototype.copy.call(l,n),l.color.copy(n.color),l.map=n.map,this.cache.add(o,l)),n=l}if(r||s||a){let o="ClonedMaterial:"+n.uuid+":";r&&(o+="derivative-tangents:"),s&&(o+="vertex-colors:"),a&&(o+="flat-shading:");let l=this.cache.get(o);l||(l=n.clone(),s&&(l.vertexColors=!0),a&&(l.flatShading=!0),r&&(l.normalScale&&(l.normalScale.y*=-1),l.clearcoatNormalScale&&(l.clearcoatNormalScale.y*=-1)),this.cache.add(o,l),this.associations.set(l,this.associations.get(n))),n=l}e.material=n}getMaterialType(){return gi}loadMaterial(e){let t=this,n=this.json,r=this.extensions,s=n.materials[e],a,o={},l=s.extensions||{},c=[];if(l[_t.KHR_MATERIALS_UNLIT]){let d=r[_t.KHR_MATERIALS_UNLIT];a=d.getMaterialType(),c.push(d.extendParams(o,s,t))}else{let d=s.pbrMetallicRoughness||{};if(o.color=new Ve(1,1,1),o.opacity=1,Array.isArray(d.baseColorFactor)){let f=d.baseColorFactor;o.color.setRGB(f[0],f[1],f[2],bn),o.opacity=f[3]}d.baseColorTexture!==void 0&&c.push(t.assignTexture(o,"map",d.baseColorTexture,Xt)),o.metalness=d.metallicFactor!==void 0?d.metallicFactor:1,o.roughness=d.roughnessFactor!==void 0?d.roughnessFactor:1,d.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(o,"metalnessMap",d.metallicRoughnessTexture)),c.push(t.assignTexture(o,"roughnessMap",d.metallicRoughnessTexture))),a=this._invokeOne(function(f){return f.getMaterialType&&f.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(f){return f.extendMaterialParams&&f.extendMaterialParams(e,o)})))}s.doubleSided===!0&&(o.side=Dn);let h=s.alphaMode||Hf.OPAQUE;if(h===Hf.BLEND?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,h===Hf.MASK&&(o.alphaTest=s.alphaCutoff!==void 0?s.alphaCutoff:.5)),s.normalTexture!==void 0&&a!==gn&&(c.push(t.assignTexture(o,"normalMap",s.normalTexture)),o.normalScale=new dt(1,1),s.normalTexture.scale!==void 0)){let d=s.normalTexture.scale;o.normalScale.set(d,d)}if(s.occlusionTexture!==void 0&&a!==gn&&(c.push(t.assignTexture(o,"aoMap",s.occlusionTexture)),s.occlusionTexture.strength!==void 0&&(o.aoMapIntensity=s.occlusionTexture.strength)),s.emissiveFactor!==void 0&&a!==gn){let d=s.emissiveFactor;o.emissive=new Ve().setRGB(d[0],d[1],d[2],bn)}return s.emissiveTexture!==void 0&&a!==gn&&c.push(t.assignTexture(o,"emissiveMap",s.emissiveTexture,Xt)),Promise.all(c).then(function(){let d=new a(o);return s.name&&(d.name=s.name),nr(d,s),t.associations.set(d,{materials:e}),s.extensions&&Ds(r,d,s),d})}createUniqueName(e){let t=Ut.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){let t=this,n=this.extensions,r=this.primitiveCache;function s(o){return n[_t.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(o,t).then(function(l){return zb(l,o,t)})}let a=[];for(let o=0,l=e.length;o<l;o++){let c=e[o],h=cE(c),d=r[h];if(d)a.push(d.promise);else{let f;c.extensions&&c.extensions[_t.KHR_DRACO_MESH_COMPRESSION]?f=s(c):f=zb(new mn,c,t),r[h]={primitive:c,promise:f},a.push(f)}}return Promise.all(a)}loadMesh(e){let t=this,n=this.json,r=this.extensions,s=n.meshes[e],a=s.primitives,o=[];for(let l=0,c=a.length;l<c;l++){let h=a[l].material===void 0?sE(this.cache):this.getDependency("material",a[l].material);o.push(h)}return o.push(t.loadGeometries(a)),Promise.all(o).then(function(l){let c=l.slice(0,l.length-1),h=l[l.length-1],d=[];for(let p=0,x=h.length;p<x;p++){let y=h[p],b=a[p],g,S=c[p];if(b.mode===_i.TRIANGLES||b.mode===_i.TRIANGLE_STRIP||b.mode===_i.TRIANGLE_FAN||b.mode===void 0)g=s.isSkinnedMesh===!0?new so(y,S):new xt(y,S),g.isSkinnedMesh===!0&&g.normalizeSkinWeights(),b.mode===_i.TRIANGLE_STRIP?g.geometry=Bf(g.geometry,ko):b.mode===_i.TRIANGLE_FAN&&(g.geometry=Bf(g.geometry,ya));else if(b.mode===_i.LINES)g=new fa(y,S);else if(b.mode===_i.LINE_STRIP)g=new vs(y,S);else if(b.mode===_i.LINE_LOOP)g=new oo(y,S);else if(b.mode===_i.POINTS)g=new co(y,S);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+b.mode);Object.keys(g.geometry.morphAttributes).length>0&&oE(g,s),g.name=t.createUniqueName(s.name||"mesh_"+e),nr(g,s),b.extensions&&Ds(r,g,b),t.assignFinalMaterial(g),d.push(g)}for(let p=0,x=d.length;p<x;p++)t.associations.set(d[p],{meshes:e,primitives:p});if(d.length===1)return s.extensions&&Ds(r,d[0],s),d[0];let f=new pn;s.extensions&&Ds(r,f,s),t.associations.set(f,{meshes:e});for(let p=0,x=d.length;p<x;p++)f.add(d[p]);return f})}loadCamera(e){let t,n=this.json.cameras[e],r=n[n.type];if(!r){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return n.type==="perspective"?t=new an(Hd.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):n.type==="orthographic"&&(t=new Wr(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),nr(t,n),Promise.resolve(t)}loadSkin(e){let t=this.json.skins[e],n=[];for(let r=0,s=t.joints.length;r<s;r++)n.push(this._loadNodeShallow(t.joints[r]));return t.inverseBindMatrices!==void 0?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then(function(r){let s=r.pop(),a=r,o=[],l=[];for(let c=0,h=a.length;c<h;c++){let d=a[c];if(d){o.push(d);let f=new ot;s!==null&&f.fromArray(s.array,c*16),l.push(f)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[c])}return new ao(o,l)})}loadAnimation(e){let t=this.json,n=this,r=t.animations[e],s=r.name?r.name:"animation_"+e,a=[],o=[],l=[],c=[],h=[];for(let d=0,f=r.channels.length;d<f;d++){let p=r.channels[d],x=r.samplers[p.sampler],y=p.target,b=y.node,g=r.parameters!==void 0?r.parameters[x.input]:x.input,S=r.parameters!==void 0?r.parameters[x.output]:x.output;y.node!==void 0&&(a.push(this.getDependency("node",b)),o.push(this.getDependency("accessor",g)),l.push(this.getDependency("accessor",S)),c.push(x),h.push(y))}return Promise.all([Promise.all(a),Promise.all(o),Promise.all(l),Promise.all(c),Promise.all(h)]).then(function(d){let f=d[0],p=d[1],x=d[2],y=d[3],b=d[4],g=[];for(let A=0,T=f.length;A<T;A++){let N=f[A],P=p[A],U=x[A],v=y[A],I=b[A];if(N===void 0)continue;N.updateMatrix&&N.updateMatrix();let B=n._createAnimationTracks(N,P,U,v,I);if(B)for(let k=0;k<B.length;k++)g.push(B[k])}let S=new bi(s,void 0,g);return nr(S,r),S})}createNodeMesh(e){let t=this.json,n=this,r=t.nodes[e];return r.mesh===void 0?null:n.getDependency("mesh",r.mesh).then(function(s){let a=n._getNodeRef(n.meshCache,r.mesh,s);return r.weights!==void 0&&a.traverse(function(o){if(o.isMesh)for(let l=0,c=r.weights.length;l<c;l++)o.morphTargetInfluences[l]=r.weights[l]}),a})}loadNode(e){let t=this.json,n=this,r=t.nodes[e],s=n._loadNodeShallow(e),a=[],o=r.children||[];for(let c=0,h=o.length;c<h;c++)a.push(n.getDependency("node",o[c]));let l=r.skin===void 0?Promise.resolve(null):n.getDependency("skin",r.skin);return Promise.all([s,Promise.all(a),l]).then(function(c){let h=c[0],d=c[1],f=c[2];f!==null&&h.traverse(function(p){p.isSkinnedMesh&&p.bind(f,hE)});for(let p=0,x=d.length;p<x;p++)h.add(d[p]);if(h.userData.pivot!==void 0&&d.length>0){let p=h.userData.pivot,x=d[0];h.pivot=new W().fromArray(p),h.position.x-=p[0],h.position.y-=p[1],h.position.z-=p[2],x.position.set(0,0,0),delete h.userData.pivot}return h})}_loadNodeShallow(e){let t=this.json,n=this.extensions,r=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];let s=t.nodes[e],a=s.name?r.createUniqueName(s.name):"",o=[],l=r._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});return l&&o.push(l),s.camera!==void 0&&o.push(r.getDependency("camera",s.camera).then(function(c){return r._getNodeRef(r.cameraCache,s.camera,c)})),r._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)}).forEach(function(c){o.push(c)}),this.nodeCache[e]=Promise.all(o).then(function(c){let h;if(s.isBone===!0?h=new ua:c.length>1?h=new pn:c.length===1?h=c[0]:h=new qt,h!==c[0])for(let d=0,f=c.length;d<f;d++)h.add(c[d]);if(s.name&&(h.userData.name=s.name,h.name=a),nr(h,s),s.extensions&&Ds(n,h,s),s.matrix!==void 0){let d=new ot;d.fromArray(s.matrix),h.applyMatrix4(d)}else s.translation!==void 0&&h.position.fromArray(s.translation),s.rotation!==void 0&&h.quaternion.fromArray(s.rotation),s.scale!==void 0&&h.scale.fromArray(s.scale);if(!r.associations.has(h))r.associations.set(h,{});else if(s.mesh!==void 0&&r.meshCache.refs[s.mesh]>1){let d=r.associations.get(h);r.associations.set(h,{...d})}return r.associations.get(h).nodes=e,h}),this.nodeCache[e]}loadScene(e){let t=this.extensions,n=this.json.scenes[e],r=this,s=new pn;n.name&&(s.name=r.createUniqueName(n.name)),nr(s,n),n.extensions&&Ds(t,s,n);let a=n.nodes||[],o=[];for(let l=0,c=a.length;l<c;l++)o.push(r.getDependency("node",a[l]));return Promise.all(o).then(function(l){for(let h=0,d=l.length;h<d;h++){let f=l[h];f.parent!==null?s.add(Cs(f)):s.add(f)}let c=h=>{let d=new Map;for(let[f,p]of r.associations)(f instanceof Ln||f instanceof xn)&&d.set(f,p);return h.traverse(f=>{let p=r.associations.get(f);p!=null&&d.set(f,p)}),d};return r.associations=c(s),s})}_createAnimationTracks(e,t,n,r,s){let a=[],o=e.name?e.name:e.uuid,l=[];function c(p){p.morphTargetInfluences&&l.push(p.name?p.name:p.uuid)}Yr[s.path]===Yr.weights?(c(e),e.isGroup&&e.children.forEach(c)):l.push(o);let h;switch(Yr[s.path]){case Yr.weights:h=ji;break;case Yr.rotation:h=Xi;break;case Yr.translation:case Yr.scale:h=Ki;break;default:n.itemSize===1?h=ji:h=Ki;break}let d=r.interpolation!==void 0?rE[r.interpolation]:gs,f=this._getArrayFromAccessor(n);for(let p=0,x=l.length;p<x;p++){let y=new h(l[p]+"."+Yr[s.path],t.array,f,d);r.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(y),a.push(y)}return a}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){let n=dp(t.constructor),r=new Float32Array(t.length);for(let s=0,a=t.length;s<a;s++)r[s]=t[s]*n;t=r}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){let r=this instanceof Xi?hp:zh;return new r(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}});function dE(){let i,e;onmessage=function(a){let o=a.data;switch(o.type){case"init":i=o.decoderConfig,e=new Promise(function(h){i.onModuleLoaded=function(d){h({draco:d})},DracoDecoderModule(i)});break;case"decode":let l=o.buffer,c=o.taskConfig;e.then(h=>{let d=h.draco,f=new d.Decoder;try{let p=t(d,f,new Int8Array(l),c),x=p.attributes.map(y=>y.array.buffer);p.index&&x.push(p.index.array.buffer),self.postMessage({type:"decode",id:o.id,geometry:p},x)}catch(p){console.error(p),self.postMessage({type:"error",id:o.id,error:p.message})}finally{d.destroy(f)}});break}};function t(a,o,l,c){let h=c.attributeIDs,d=c.attributeTypes,f,p,x=o.GetEncodedGeometryType(l);if(x===a.TRIANGULAR_MESH)f=new a.Mesh,p=o.DecodeArrayToMesh(l,l.byteLength,f);else if(x===a.POINT_CLOUD)f=new a.PointCloud,p=o.DecodeArrayToPointCloud(l,l.byteLength,f);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!p.ok()||f.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+p.error_msg());let y={index:null,attributes:[]};for(let b in h){let g=self[d[b]],S,A;if(c.useUniqueIDs)A=h[b],S=o.GetAttributeByUniqueId(f,A);else{if(A=o.GetAttributeId(f,a[h[b]]),A===-1)continue;S=o.GetAttribute(f,A)}let T=r(a,o,f,b,g,S);b==="color"&&(T.vertexColorSpace=c.vertexColorSpace),y.attributes.push(T)}return x===a.TRIANGULAR_MESH&&(y.index=n(a,o,f)),a.destroy(f),y}function n(a,o,l){let h=l.num_faces()*3,d=h*4,f=a._malloc(d);o.GetTrianglesUInt32Array(l,d,f);let p=new Uint32Array(a.HEAPF32.buffer,f,h).slice();return a._free(f),{array:p,itemSize:1}}function r(a,o,l,c,h,d){let f=l.num_points(),p=d.num_components(),x=s(a,h),y=p*h.BYTES_PER_ELEMENT,b=Math.ceil(y/4)*4,g=b/h.BYTES_PER_ELEMENT,S=f*y,A=f*b,T=a._malloc(S);o.GetAttributeDataArrayForAllPoints(l,d,x,S,T);let N=new h(a.HEAPF32.buffer,T,S/h.BYTES_PER_ELEMENT),P;if(y===b)P=N.slice();else{P=new h(A/h.BYTES_PER_ELEMENT);let U=0;for(let v=0,I=N.length;v<I;v++){for(let B=0;B<p;B++)P[U+B]=N[v*p+B];U+=g}}return a._free(T),{name:c,count:f,itemSize:p,array:P,stride:g}}function s(a,o){switch(o){case Float32Array:return a.DT_FLOAT32;case Int8Array:return a.DT_INT8;case Int16Array:return a.DT_INT16;case Int32Array:return a.DT_INT32;case Uint8Array:return a.DT_UINT8;case Uint16Array:return a.DT_UINT16;case Uint32Array:return a.DT_UINT32}}}var pp,Hh,Vb=un(()=>{Vn();pp=new WeakMap,Hh=class extends oi{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,n,r){let s=new Yi(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,a=>{this.parse(a,t,r)},n,r)}parse(e,t,n=()=>{}){this.decodeDracoFile(e,t,null,null,Xt,n).catch(n)}decodeDracoFile(e,t,n,r,s=bn,a=()=>{}){let o={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:r||this.defaultAttributeTypes,useUniqueIDs:!!n,vertexColorSpace:s};return this.decodeGeometry(e,o).then(t).catch(a)}decodeGeometry(e,t){let n=JSON.stringify(t);if(pp.has(e)){let l=pp.get(e);if(l.key===n)return l.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let r,s=this.workerNextTaskID++,a=e.byteLength,o=this._getWorker(s,a).then(l=>(r=l,new Promise((c,h)=>{r._callbacks[s]={resolve:c,reject:h},r.postMessage({type:"decode",id:s,taskConfig:t,buffer:e},[e])}))).then(l=>this._createGeometry(l.geometry));return o.catch(()=>!0).then(()=>{r&&s&&this._releaseTask(r,s)}),pp.set(e,{key:n,promise:o}),o}_createGeometry(e){let t=new mn;e.index&&t.setIndex(new Kt(e.index.array,1));for(let n=0;n<e.attributes.length;n++){let{name:r,array:s,itemSize:a,stride:o,vertexColorSpace:l}=e.attributes[n],c;if(a===o)c=new Kt(s,a);else{let h=new Ur(s,o);c=new kr(h,a,0)}r==="color"&&(this._assignVertexColorSpace(c,l),c.normalized=!(s instanceof Float32Array)),t.setAttribute(r,c)}return t}_assignVertexColorSpace(e,t){if(t!==Xt)return;let n=new Ve;for(let r=0,s=e.count;r<s;r++)n.fromBufferAttribute(e,r),ut.colorSpaceToWorking(n,Xt),e.setXYZ(r,n.r,n.g,n.b)}_loadLibrary(e,t){let n=new Yi(this.manager);return n.setPath(this.decoderPath),n.setResponseType(t),n.setWithCredentials(this.withCredentials),new Promise((r,s)=>{n.load(e,r,void 0,s)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;let e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(n=>{let r=n[0];e||(this.decoderConfig.wasmBinary=n[1]);let s=dE.toString(),a=["/* draco decoder */",r,"","/* worker */",s.substring(s.indexOf("{")+1,s.lastIndexOf("}"))].join(`
-`);this.workerSourceURL=URL.createObjectURL(new Blob([a]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){let r=new Worker(this.workerSourceURL);r._callbacks={},r._taskCosts={},r._taskLoad=0,r.postMessage({type:"init",decoderConfig:this.decoderConfig}),r.onmessage=function(s){let a=s.data;switch(a.type){case"decode":r._callbacks[a.id].resolve(a);break;case"error":r._callbacks[a.id].reject(a);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+a.type+'"')}},this.workerPool.push(r)}else this.workerPool.sort(function(r,s){return r._taskLoad>s._taskLoad?-1:1});let n=this.workerPool[this.workerPool.length-1];return n._taskCosts[e]=t,n._taskLoad+=t,n})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}}});var Wb={};Ar(Wb,{MeshoptDecoder:()=>fE});var fE,qb=un(()=>{fE=(function(){var i="b9H79Tebbbe8Fv9Gbb9Gvuuuuueu9Giuuub9Geueu9Giuuueuixkbeeeddddillviebeoweuecj:Gdkr;Neqo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbeY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVbdE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbiL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtblK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949WboY9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVJ9V29VVbrl79IV9Rbwq:VZkdbk:XYi5ud9:du8Jjjjjbcj;kb9Rgv8Kjjjjbc9:hodnalTmbcuhoaiRbbgrc;WeGc:Ge9hmbarcsGgwce0mbc9:hoalcufadcd4cbawEgDadfgrcKcaawEgqaraq0Egk6mbaicefhxcj;abad9Uc;WFbGcjdadca0EhmaialfgPar9Rgoadfhsavaoadz:jjjjbgzceVhHcbhOdndninaeaO9nmeaPax9RaD6mdamaeaO9RaOamfgoae6EgAcsfglc9WGhCabaOad2fhXaAcethQaxaDfhiaOaeaoaeao6E9RhLalcl4cifcd4hKazcj;cbfaAfhYcbh8AazcjdfhEaHh3incbh5dnawTmbaxa8Acd4fRbbh5kcbh8Eazcj;cbfhqinaih8Fdndndndna5a8Ecet4ciGgoc9:fPdebdkaPa8F9RaA6mrazcj;cbfa8EaA2fa8FaAz:jjjjb8Aa8FaAfhixdkazcj;cbfa8EaA2fcbaAz:kjjjb8Aa8FhixekaPa8F9RaK6mva8FaKfhidnaCTmbaPai9RcK6mbaocdtc:q:G:cjbfcj:G:cjbawEhaczhrcbhlinargoc9Wfghaqfhrdndndndndndnaaa8Fahco4fRbbalcoG4ciGcdtfydbPDbedvivvvlvkar9cb83bwar9cb83bbxlkarcbaiRbdai8Xbb9c:c:qj:bw9:9c:q;c1:I1e:d9c:b:c:e1z9:gg9cjjjjjz:dg8J9qE86bbaqaofgrcGfcbaicdfa8J9c8N1:NfghRbbag9cjjjjjw:dg8J9qE86bbarcVfcbaha8J9c8M1:NfghRbbag9cjjjjjl:dg8J9qE86bbarc7fcbaha8J9c8L1:NfghRbbag9cjjjjjd:dg8J9qE86bbarctfcbaha8J9c8K1:NfghRbbag9cjjjjje:dg8J9qE86bbarc91fcbaha8J9c8J1:NfghRbbag9cjjjj;ab:dg8J9qE86bbarc4fcbaha8J9cg1:NfghRbbag9cjjjja:dg8J9qE86bbarc93fcbaha8J9ch1:NfghRbbag9cjjjjz:dgg9qE86bbarc94fcbahag9ca1:NfghRbbai8Xbe9c:c:qj:bw9:9c:q;c1:I1e:d9c:b:c:e1z9:gg9cjjjjjz:dg8J9qE86bbarc95fcbaha8J9c8N1:NfgiRbbag9cjjjjjw:dg8J9qE86bbarc96fcbaia8J9c8M1:NfgiRbbag9cjjjjjl:dg8J9qE86bbarc97fcbaia8J9c8L1:NfgiRbbag9cjjjjjd:dg8J9qE86bbarc98fcbaia8J9c8K1:NfgiRbbag9cjjjjje:dg8J9qE86bbarc99fcbaia8J9c8J1:NfgiRbbag9cjjjj;ab:dg8J9qE86bbarc9:fcbaia8J9cg1:NfgiRbbag9cjjjja:dg8J9qE86bbarcufcbaia8J9ch1:NfgiRbbag9cjjjjz:dgg9qE86bbaiag9ca1:NfhixikaraiRblaiRbbghco4g8Ka8KciSg8KE86bbaqaofgrcGfaiclfa8Kfg8KRbbahcl4ciGg8La8LciSg8LE86bbarcVfa8Ka8Lfg8KRbbahcd4ciGg8La8LciSg8LE86bbarc7fa8Ka8Lfg8KRbbahciGghahciSghE86bbarctfa8Kahfg8KRbbaiRbeghco4g8La8LciSg8LE86bbarc91fa8Ka8Lfg8KRbbahcl4ciGg8La8LciSg8LE86bbarc4fa8Ka8Lfg8KRbbahcd4ciGg8La8LciSg8LE86bbarc93fa8Ka8Lfg8KRbbahciGghahciSghE86bbarc94fa8Kahfg8KRbbaiRbdghco4g8La8LciSg8LE86bbarc95fa8Ka8Lfg8KRbbahcl4ciGg8La8LciSg8LE86bbarc96fa8Ka8Lfg8KRbbahcd4ciGg8La8LciSg8LE86bbarc97fa8Ka8Lfg8KRbbahciGghahciSghE86bbarc98fa8KahfghRbbaiRbigico4g8Ka8KciSg8KE86bbarc99faha8KfghRbbaicl4ciGg8Ka8KciSg8KE86bbarc9:faha8KfghRbbaicd4ciGg8Ka8KciSg8KE86bbarcufaha8KfgrRbbaiciGgiaiciSgiE86bbaraifhixdkaraiRbwaiRbbghcl4g8Ka8KcsSg8KE86bbaqaofgrcGfaicwfa8Kfg8KRbbahcsGghahcsSghE86bbarcVfa8KahfghRbbaiRbeg8Kcl4g8La8LcsSg8LE86bbarc7faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarctfaha8KfghRbbaiRbdg8Kcl4g8La8LcsSg8LE86bbarc91faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc4faha8KfghRbbaiRbig8Kcl4g8La8LcsSg8LE86bbarc93faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc94faha8KfghRbbaiRblg8Kcl4g8La8LcsSg8LE86bbarc95faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc96faha8KfghRbbaiRbvg8Kcl4g8La8LcsSg8LE86bbarc97faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc98faha8KfghRbbaiRbog8Kcl4g8La8LcsSg8LE86bbarc99faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc9:faha8KfghRbbaiRbrgicl4g8Ka8KcsSg8KE86bbarcufaha8KfgrRbbaicsGgiaicsSgiE86bbaraifhixekarai8Pbw83bwarai8Pbb83bbaiczfhikdnaoaC9pmbalcdfhlaoczfhraPai9RcL0mekkaoaC6moaimexokaCmva8FTmvkaqaAfhqa8Ecefg8Ecl9hmbkdndndndnawTmbasa8Acd4fRbbgociGPlbedrbkaATmdaza8Afh8Fazcj;cbfhhcbh8EaEhaina8FRbbhraahocbhlinaoahalfRbbgqce4cbaqceG9R7arfgr86bbaoadfhoaAalcefgl9hmbkaacefhaa8Fcefh8FahaAfhha8Ecefg8Ecl9hmbxikkaATmeaza8Afhaazcj;cbfhhcbhoceh8EaYh8FinaEaofhlaa8Vbbhrcbhoinala8FaofRbbcwtahaofRbbgqVc;:FiGce4cbaqceG9R7arfgr87bbaladfhlaLaocefgofmbka8FaQfh8FcdhoaacdfhaahaQfhha8EceGhlcbh8EalmbxdkkaATmbaocl4h8Eaza8AfRbbhqcwhoa3hlinalRbbaotaqVhqalcefhlaocwfgoca9hmbkcbhhaEh8FaYhainazcj;cbfahfRbbhrcwhoaahlinalRbbaotarVhralaAfhlaocwfgoca9hmbkara8E94aq7hqcbhoa8Fhlinalaqao486bbalcefhlaocwfgoca9hmbka8Fadfh8FaacefhaahcefghaA9hmbkkaEclfhEa3clfh3a8Aclfg8Aad6mbkaXazcjdfaAad2z:jjjjb8AazazcjdfaAcufad2fadz:jjjjb8AaAaOfhOaihxaimbkc9:hoxdkcbc99aPax9RakSEhoxekc9:hokavcj;kbf8Kjjjjbaok:ysezu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnalaeci9UgrcHf6mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecjez:kjjjb8Aav9cu83iUav9cu83i8Wav9cu83iyav9cu83iaav9cu83iKav9cu83izav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhldnaeTmbcmcsaDceSEhkcbhxcbhmcbhrcbhicbhoindnalaq9nmbc9:hoxikdndnawRbbgDc;Ve0mbavc;abfaoaDcu7gPcl4fcsGcitfgsydlhzasydbhHdndnaDcsGgsak9pmbavaiaPfcsGcdtfydbaxasEhDaxasTgOfhxxekdndnascsSmbcehOasc987asamffcefhDxekalcefhDal8SbbgscFeGhPdndnascu9mmbaDhlxekalcvfhlaPcFbGhPcrhsdninaD8SbbgOcFbGastaPVhPaOcu9kmeaDcefhDascrfgsc8J9hmbxdkkaDcefhlkcehOaPce4cbaPceG9R7amfhDkaDhmkavc;abfaocitfgsaDBdbasazBdlavaicdtfaDBdbavc;abfaocefcsGcitfgsaHBdbasaDBdlaocdfhoaOaifhidnadcd9hmbabarcetfgsaH87ebasclfaD87ebascdfaz87ebxdkabarcdtfgsaHBdbascwfaDBdbasclfazBdbxekdnaDcpe0mbavaiaqaDcsGfRbbgscl4gP9RcsGcdtfydbaxcefgOaPEhDavaias9RcsGcdtfydbaOaPTgzfgOascsGgPEhsaPThPdndnadcd9hmbabarcetfgHax87ebaHclfas87ebaHcdfaD87ebxekabarcdtfgHaxBdbaHcwfasBdbaHclfaDBdbkavaicdtfaxBdbavc;abfaocitfgHaDBdbaHaxBdlavaicefgicsGcdtfaDBdbavc;abfaocefcsGcitfgHasBdbaHaDBdlavaiazfgicsGcdtfasBdbavc;abfaocdfcsGcitfgDaxBdbaDasBdlaocifhoaiaPfhiaOaPfhxxekaxcbalRbbgsEgHaDc;:eSgDfhOascsGhAdndnascl4gCmbaOcefhzxekaOhzavaiaC9RcsGcdtfydbhOkdndnaAmbazcefhxxekazhxavaias9RcsGcdtfydbhzkdndnaDTmbalcefhDxekalcdfhDal8SbegPcFeGhsdnaPcu9kmbalcofhHascFbGhscrhldninaD8SbbgPcFbGaltasVhsaPcu9kmeaDcefhDalcrfglc8J9hmbkaHhDxekaDcefhDkasce4cbasceG9R7amfgmhHkdndnaCcsSmbaDhsxekaDcefhsaD8SbbglcFeGhPdnalcu9kmbaDcvfhOaPcFbGhPcrhldninas8SbbgDcFbGaltaPVhPaDcu9kmeascefhsalcrfglc8J9hmbkaOhsxekascefhskaPce4cbaPceG9R7amfgmhOkdndnaAcsSmbashlxekascefhlas8SbbgDcFeGhPdnaDcu9kmbascvfhzaPcFbGhPcrhDdninal8SbbgscFbGaDtaPVhPascu9kmealcefhlaDcrfgDc8J9hmbkazhlxekalcefhlkaPce4cbaPceG9R7amfgmhzkdndnadcd9hmbabarcetfgDaH87ebaDclfaz87ebaDcdfaO87ebxekabarcdtfgDaHBdbaDcwfazBdbaDclfaOBdbkavc;abfaocitfgDaOBdbaDaHBdlavaicdtfaHBdbavc;abfaocefcsGcitfgDazBdbaDaOBdlavaicefgicsGcdtfaOBdbavc;abfaocdfcsGcitfgDaHBdbaDazBdlavaiaCTaCcsSVfgicsGcdtfazBdbaiaATaAcsSVfhiaocifhokawcefhwaocsGhoaicsGhiarcifgrae6mbkkcbc99alaqSEhokavc;aef8Kjjjjbaok:clevu8Jjjjjbcz9Rhvdnalaecvf9pmbc9:skdnaiRbbc;:eGc;qeSmbcuskav9cb83iwaicefhoaialfc98fhrdnaeTmbdnadcdSmbcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcdtfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgiBdbalaiBdbawcefgwae9hmbxdkkcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcetfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgi87ebalaiBdbawcefgwae9hmbkkcbc99aoarSEk:Lvoeue99dud99eud99dndnadcl9hmbaeTmeindndnabcdfgd8Sbb:Yab8Sbbgi:Ygl:l:tabcefgv8Sbbgo:Ygr:l:tgwJbb;:9cawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai86bbdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad86bbdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad86bbabclfhbaecufgembxdkkaeTmbindndnabclfgd8Ueb:Yab8Uebgi:Ygl:l:tabcdfgv8Uebgo:Ygr:l:tgwJb;:FSawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai87ebdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad87ebdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad87ebabcwfhbaecufgembkkk:4ioiue99dud99dud99dnaeTmbcbhiabhlindndnal8Uebgv:YgoJ:ji:1Salcof8UebgrciVgw:Y:vgDNJbbbZJbbb:;avcu9kEMgq:lJbbb9p9DTmbaq:Ohkxekcjjjj94hkkalclf8Uebhvalcdf8UebhxalarcefciGcetfak87ebdndnax:YgqaDNJbbbZJbbb:;axcu9kEMgm:lJbbb9p9DTmbam:Ohxxekcjjjj94hxkabaiarciGgkfcd7cetfax87ebdndnav:YgmaDNJbbbZJbbb:;avcu9kEMgP:lJbbb9p9DTmbaP:Ohvxekcjjjj94hvkalarcufciGcetfav87ebdndnawaw2:ZgPaPMaoaoN:taqaqN:tamamN:tgoJbbbbaoJbbbb9GE:raDNJbbbZMgD:lJbbb9p9DTmbaD:Ohrxekcjjjj94hrkalakcetfar87ebalcwfhlaiclfhiaecufgembkkk9mbdnadcd4ae2gdTmbinababydbgecwtcw91:Yaece91cjjj98Gcjjj;8if::NUdbabclfhbadcufgdmbkkk:Tvirud99eudndnadcl9hmbaeTmeindndnabRbbgiabcefgl8Sbbgvabcdfgo8Sbbgrf9R:YJbbuJabcifgwRbbgdce4adVgDcd4aDVgDcl4aDVgD:Z:vgqNJbbbZMgk:lJbbb9p9DTmbak:Ohxxekcjjjj94hxkaoax86bbdndnaraif:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohoxekcjjjj94hokalao86bbdndnavaifar9R:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikabai86bbdndnaDadcetGadceGV:ZaqNJbbbZMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkawad86bbabclfhbaecufgembxdkkaeTmbindndnab8Vebgiabcdfgl8Uebgvabclfgo8Uebgrf9R:YJbFu9habcofgw8Vebgdce4adVgDcd4aDVgDcl4aDVgDcw4aDVgD:Z:vgqNJbbbZMgk:lJbbb9p9DTmbak:Ohxxekcjjjj94hxkaoax87ebdndnaraif:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohoxekcjjjj94hokalao87ebdndnavaifar9R:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikabai87ebdndnaDadcetGadceGV:ZaqNJbbbZMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkawad87ebabcwfhbaecufgembkkk9teiucbcbyd:K:G:cjbgeabcifc98GfgbBd:K:G:cjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaik;LeeeudndnaeabVciGTmbabhixekdndnadcz9pmbabhixekabhiinaiaeydbBdbaiclfaeclfydbBdbaicwfaecwfydbBdbaicxfaecxfydbBdbaeczfheaiczfhiadc9Wfgdcs0mbkkadcl6mbinaiaeydbBdbaeclfheaiclfhiadc98fgdci0mbkkdnadTmbinaiaeRbb86bbaicefhiaecefheadcufgdmbkkabk;aeedudndnabciGTmbabhixekaecFeGc:b:c:ew2hldndnadcz9pmbabhixekabhiinaialBdbaicxfalBdbaicwfalBdbaiclfalBdbaiczfhiadc9Wfgdcs0mbkkadcl6mbinaialBdbaiclfhiadc98fgdci0mbkkdnadTmbinaiae86bbaicefhiadcufgdmbkkabkk83dbcj:Gdk8Kbbbbdbbblbbbwbbbbbbbebbbdbbblbbbwbbbbc:K:Gdkl8W:qbb",e="b9H79TebbbeKl9Gbb9Gvuuuuueu9Giuuub9Geueuixkbbebeeddddilve9Weeeviebeoweuecj:Gdkr;Neqo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbdY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVblE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtboK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbrL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949WbwY9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVJ9V29VVbDl79IV9Rbqq:W9Dklbzik94evu8Jjjjjbcz9Rhbcbheincbhdcbhiinabcwfadfaicjuaead4ceGglE86bbaialfhiadcefgdcw9hmbkaeai86b:q:W:cjbaecitab8Piw83i:q:G:cjbaecefgecjd9hmbkk:JBl8Aud97dur978Jjjjjbcj;kb9Rgv8Kjjjjbc9:hodnalTmbcuhoaiRbbgrc;WeGc:Ge9hmbarcsGgwce0mbc9:hoalcufadcd4cbawEgDadfgrcKcaawEgqaraq0Egk6mbaialfgxar9RhodnadTgmmbavaoad;8qbbkaicefhPcj;abad9Uc;WFbGcjdadca0EhsdndndnadTmbaoadfhzcbhHinaeaH9nmdaxaP9RaD6miabaHad2fhOaPaDfhAasaeaH9RaHasfae6EgCcsfgocl4cifcd4hXavcj;cbfaoc9WGgQcetfhLavcj;cbfaQci2fhKavcj;cbfaQfhYcbh8Aaoc;ab6hEincbh3dnawTmbaPa8Acd4fRbbh3kcbh5avcj;cbfh8Eindndndndna3a5cet4ciGgoc9:fPdebdkaxaA9RaQ6mwdnaQTmbavcj;cbfa5aQ2faAaQ;8qbbkaAaCfhAxdkaQTmeavcj;cbfa5aQ2fcbaQ;8kbxekaxaA9RaX6moaoclVcbawEhraAaXfhocbhidnaEmbaxao9Rc;Gb6mbcbhlina8EalfhidndndndndndnaAalco4fRbbgqciGarfPDbedibledibkaipxbbbbbbbbbbbbbbbbpklbxlkaiaopbblaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLg8Fcdp:mea8FpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogapxiiiiiiiiiiiiiiiip8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbahaoclffagRb:q:W:cjbfhoxikaiaopbbwaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogapxssssssssssssssssp8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbahaocwffagRb:q:W:cjbfhoxdkaiaopbbbpklbaoczfhoxekaiaopbbdaoRbbghcitpbi:q:G:cjbahRb:q:W:cjbghpsaoRbeggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPpklbahaocdffagRb:q:W:cjbfhokdndndndndndnaqcd4ciGarfPDbedibledibkaiczfpxbbbbbbbbbbbbbbbbpklbxlkaiczfaopbblaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLg8Fcdp:mea8FpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogapxiiiiiiiiiiiiiiiip8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbahaoclffagRb:q:W:cjbfhoxikaiczfaopbbwaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogapxssssssssssssssssp8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbahaocwffagRb:q:W:cjbfhoxdkaiczfaopbbbpklbaoczfhoxekaiczfaopbbdaoRbbghcitpbi:q:G:cjbahRb:q:W:cjbghpsaoRbeggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPpklbahaocdffagRb:q:W:cjbfhokdndndndndndnaqcl4ciGarfPDbedibledibkaicafpxbbbbbbbbbbbbbbbbpklbxlkaicafaopbblaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLg8Fcdp:mea8FpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogapxiiiiiiiiiiiiiiiip8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbahaoclffagRb:q:W:cjbfhoxikaicafaopbbwaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogapxssssssssssssssssp8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbahaocwffagRb:q:W:cjbfhoxdkaicafaopbbbpklbaoczfhoxekaicafaopbbdaoRbbghcitpbi:q:G:cjbahRb:q:W:cjbghpsaoRbeggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPpklbahaocdffagRb:q:W:cjbfhokdndndndndndnaqco4arfPDbedibledibkaic8Wfpxbbbbbbbbbbbbbbbbpklbxlkaic8Wfaopbblaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLg8Fcdp:mea8FpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogapxiiiiiiiiiiiiiiiip8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Ngicitpbi:q:G:cjbaiRb:q:W:cjbgipsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Ngqcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbaiaoclffaqRb:q:W:cjbfhoxikaic8Wfaopbbwaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogapxssssssssssssssssp8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Ngicitpbi:q:G:cjbaiRb:q:W:cjbgipsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Ngqcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbaiaocwffaqRb:q:W:cjbfhoxdkaic8Wfaopbbbpklbaoczfhoxekaic8WfaopbbdaoRbbgicitpbi:q:G:cjbaiRb:q:W:cjbgipsaoRbegqcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPpklbaiaocdffaqRb:q:W:cjbfhokalc;abfhialcjefaQ0meaihlaxao9Rc;Fb0mbkkdnaiaQ9pmbaici4hlinaxao9RcK6mwa8EaifhqdndndndndndnaAaico4fRbbalcoG4ciGarfPDbedibledibkaqpxbbbbbbbbbbbbbbbbpkbbxlkaqaopbblaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLg8Fcdp:mea8FpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogapxiiiiiiiiiiiiiiiip8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spkbbahaoclffagRb:q:W:cjbfhoxikaqaopbbwaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogapxssssssssssssssssp8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spkbbahaocwffagRb:q:W:cjbfhoxdkaqaopbbbpkbbaoczfhoxekaqaopbbdaoRbbghcitpbi:q:G:cjbahRb:q:W:cjbghpsaoRbeggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPpkbbahaocdffagRb:q:W:cjbfhokalcdfhlaiczfgiaQ6mbkkaohAaoTmoka8EaQfh8Ea5cefg5cl9hmbkdndndndnawTmbaza8Acd4fRbbglciGPlbedwbkaQTmdavcjdfa8Afhlava8Afpbdbh8Jcbhoinalavcj;cbfaofpblbg8KaYaofpblbg8LpmbzeHdOiAlCvXoQrLg8MaLaofpblbg8NaKaofpblbgypmbzeHdOiAlCvXoQrLg8PpmbezHdiOAlvCXorQLg8Fcep9Ta8Fpxeeeeeeeeeeeeeeeegap9op9Hp9rg8Fa8Jp9Ug8Jp9Abbbaladfgla8Ja8Fa8Fpmlvorlvorlvorlvorp9Ug8Jp9Abbbaladfgla8Ja8Fa8FpmwDqkwDqkwDqkwDqkp9Ug8Jp9Abbbaladfgla8Ja8Fa8FpmxmPsxmPsxmPsxmPsp9Ug8Jp9Abbbaladfgla8Ja8Ma8PpmwDKYqk8AExm35Ps8E8Fg8Fcep9Ta8Faap9op9Hp9rg8Fp9Ug8Jp9Abbbaladfgla8Ja8Fa8Fpmlvorlvorlvorlvorp9Ug8Jp9Abbbaladfgla8Ja8Fa8FpmwDqkwDqkwDqkwDqkp9Ug8Jp9Abbbaladfgla8Ja8Fa8FpmxmPsxmPsxmPsxmPsp9Ug8Jp9Abbbaladfgla8Ja8Ka8LpmwKDYq8AkEx3m5P8Es8Fg8Ka8NaypmwKDYq8AkEx3m5P8Es8Fg8LpmbezHdiOAlvCXorQLg8Fcep9Ta8Faap9op9Hp9rg8Fp9Ug8Jp9Abbbaladfgla8Ja8Fa8Fpmlvorlvorlvorlvorp9Ug8Jp9Abbbaladfgla8Ja8Fa8FpmwDqkwDqkwDqkwDqkp9Ug8Jp9Abbbaladfgla8Ja8Fa8FpmxmPsxmPsxmPsxmPsp9Ug8Jp9Abbbaladfgla8Ja8Ka8LpmwDKYqk8AExm35Ps8E8Fg8Fcep9Ta8Faap9op9Hp9rg8Fp9Ugap9Abbbaladfglaaa8Fa8Fpmlvorlvorlvorlvorp9Ugap9Abbbaladfglaaa8Fa8FpmwDqkwDqkwDqkwDqkp9Ugap9Abbbaladfglaaa8Fa8FpmxmPsxmPsxmPsxmPsp9Ug8Jp9AbbbaladfhlaoczfgoaQ6mbxikkaQTmeavcjdfa8Afhlava8Afpbdbh8Jcbhoinalavcj;cbfaofpblbg8KaYaofpblbg8LpmbzeHdOiAlCvXoQrLg8MaLaofpblbg8NaKaofpblbgypmbzeHdOiAlCvXoQrLg8PpmbezHdiOAlvCXorQLg8Fcep:nea8Fpxebebebebebebebebgap9op:bep9rg8Fa8Jp:oeg8Jp9Abbbaladfgla8Ja8Fa8Fpmlvorlvorlvorlvorp:oeg8Jp9Abbbaladfgla8Ja8Fa8FpmwDqkwDqkwDqkwDqkp:oeg8Jp9Abbbaladfgla8Ja8Fa8FpmxmPsxmPsxmPsxmPsp:oeg8Jp9Abbbaladfgla8Ja8Ma8PpmwDKYqk8AExm35Ps8E8Fg8Fcep:nea8Faap9op:bep9rg8Fp:oeg8Jp9Abbbaladfgla8Ja8Fa8Fpmlvorlvorlvorlvorp:oeg8Jp9Abbbaladfgla8Ja8Fa8FpmwDqkwDqkwDqkwDqkp:oeg8Jp9Abbbaladfgla8Ja8Fa8FpmxmPsxmPsxmPsxmPsp:oeg8Jp9Abbbaladfgla8Ja8Ka8LpmwKDYq8AkEx3m5P8Es8Fg8Ka8NaypmwKDYq8AkEx3m5P8Es8Fg8LpmbezHdiOAlvCXorQLg8Fcep:nea8Faap9op:bep9rg8Fp:oeg8Jp9Abbbaladfgla8Ja8Fa8Fpmlvorlvorlvorlvorp:oeg8Jp9Abbbaladfgla8Ja8Fa8FpmwDqkwDqkwDqkwDqkp:oeg8Jp9Abbbaladfgla8Ja8Fa8FpmxmPsxmPsxmPsxmPsp:oeg8Jp9Abbbaladfgla8Ja8Ka8LpmwDKYqk8AExm35Ps8E8Fg8Fcep:nea8Faap9op:bep9rg8Fp:oegap9Abbbaladfglaaa8Fa8Fpmlvorlvorlvorlvorp:oegap9Abbbaladfglaaa8Fa8FpmwDqkwDqkwDqkwDqkp:oegap9Abbbaladfglaaa8Fa8FpmxmPsxmPsxmPsxmPsp:oeg8Jp9AbbbaladfhlaoczfgoaQ6mbxdkkaQTmbcbhocbalcl4gl9Rc8FGhiavcjdfa8Afhrava8Afpbdbhainaravcj;cbfaofpblbg8JaYaofpblbg8KpmbzeHdOiAlCvXoQrLg8LaLaofpblbg8MaKaofpblbg8NpmbzeHdOiAlCvXoQrLgypmbezHdiOAlvCXorQLg8Faip:Rea8Falp:Tep9qg8Faap9rgap9Abbbaradfgraaa8Fa8Fpmlvorlvorlvorlvorp9rgap9Abbbaradfgraaa8Fa8FpmwDqkwDqkwDqkwDqkp9rgap9Abbbaradfgraaa8Fa8FpmxmPsxmPsxmPsxmPsp9rgap9Abbbaradfgraaa8LaypmwDKYqk8AExm35Ps8E8Fg8Faip:Rea8Falp:Tep9qg8Fp9rgap9Abbbaradfgraaa8Fa8Fpmlvorlvorlvorlvorp9rgap9Abbbaradfgraaa8Fa8FpmwDqkwDqkwDqkwDqkp9rgap9Abbbaradfgraaa8Fa8FpmxmPsxmPsxmPsxmPsp9rgap9Abbbaradfgraaa8Ja8KpmwKDYq8AkEx3m5P8Es8Fg8Ja8Ma8NpmwKDYq8AkEx3m5P8Es8Fg8KpmbezHdiOAlvCXorQLg8Faip:Rea8Falp:Tep9qg8Fp9rgap9Abbbaradfgraaa8Fa8Fpmlvorlvorlvorlvorp9rgap9Abbbaradfgraaa8Fa8FpmwDqkwDqkwDqkwDqkp9rgap9Abbbaradfgraaa8Fa8FpmxmPsxmPsxmPsxmPsp9rgap9Abbbaradfgraaa8Ja8KpmwDKYqk8AExm35Ps8E8Fg8Faip:Rea8Falp:Tep9qg8Fp9rgap9Abbbaradfgraaa8Fa8Fpmlvorlvorlvorlvorp9rgap9Abbbaradfgraaa8Fa8FpmwDqkwDqkwDqkwDqkp9rgap9Abbbaradfgraaa8Fa8FpmxmPsxmPsxmPsxmPsp9rgap9AbbbaradfhraoczfgoaQ6mbkka8Aclfg8Aad6mbkdnaCad2goTmbaOavcjdfao;8qbbkdnammbavavcjdfaCcufad2fad;8qbbkaCaHfhHc9:hoaAhPaAmbxlkkaeTmbaDalfhrcbhocuhlinaralaD9RglfaD6mdasaeao9Raoasfae6Eaofgoae6mbkaial9RhPkcbc99axaP9RakSEhoxekc9:hokavcj;kbf8Kjjjjbaokwbz:bjjjbkNsezu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnalaeci9UgrcHf6mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecje;8kbav9cu83iUav9cu83i8Wav9cu83iyav9cu83iaav9cu83iKav9cu83izav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhldnaeTmbcmcsaDceSEhkcbhxcbhmcbhrcbhicbhoindnalaq9nmbc9:hoxikdndnawRbbgDc;Ve0mbavc;abfaoaDcu7gPcl4fcsGcitfgsydlhzasydbhHdndnaDcsGgsak9pmbavaiaPfcsGcdtfydbaxasEhDaxasTgOfhxxekdndnascsSmbcehOasc987asamffcefhDxekalcefhDal8SbbgscFeGhPdndnascu9mmbaDhlxekalcvfhlaPcFbGhPcrhsdninaD8SbbgOcFbGastaPVhPaOcu9kmeaDcefhDascrfgsc8J9hmbxdkkaDcefhlkcehOaPce4cbaPceG9R7amfhDkaDhmkavc;abfaocitfgsaDBdbasazBdlavaicdtfaDBdbavc;abfaocefcsGcitfgsaHBdbasaDBdlaocdfhoaOaifhidnadcd9hmbabarcetfgsaH87ebasclfaD87ebascdfaz87ebxdkabarcdtfgsaHBdbascwfaDBdbasclfazBdbxekdnaDcpe0mbavaiaqaDcsGfRbbgscl4gP9RcsGcdtfydbaxcefgOaPEhDavaias9RcsGcdtfydbaOaPTgzfgOascsGgPEhsaPThPdndnadcd9hmbabarcetfgHax87ebaHclfas87ebaHcdfaD87ebxekabarcdtfgHaxBdbaHcwfasBdbaHclfaDBdbkavaicdtfaxBdbavc;abfaocitfgHaDBdbaHaxBdlavaicefgicsGcdtfaDBdbavc;abfaocefcsGcitfgHasBdbaHaDBdlavaiazfgicsGcdtfasBdbavc;abfaocdfcsGcitfgDaxBdbaDasBdlaocifhoaiaPfhiaOaPfhxxekaxcbalRbbgsEgHaDc;:eSgDfhOascsGhAdndnascl4gCmbaOcefhzxekaOhzavaiaC9RcsGcdtfydbhOkdndnaAmbazcefhxxekazhxavaias9RcsGcdtfydbhzkdndnaDTmbalcefhDxekalcdfhDal8SbegPcFeGhsdnaPcu9kmbalcofhHascFbGhscrhldninaD8SbbgPcFbGaltasVhsaPcu9kmeaDcefhDalcrfglc8J9hmbkaHhDxekaDcefhDkasce4cbasceG9R7amfgmhHkdndnaCcsSmbaDhsxekaDcefhsaD8SbbglcFeGhPdnalcu9kmbaDcvfhOaPcFbGhPcrhldninas8SbbgDcFbGaltaPVhPaDcu9kmeascefhsalcrfglc8J9hmbkaOhsxekascefhskaPce4cbaPceG9R7amfgmhOkdndnaAcsSmbashlxekascefhlas8SbbgDcFeGhPdnaDcu9kmbascvfhzaPcFbGhPcrhDdninal8SbbgscFbGaDtaPVhPascu9kmealcefhlaDcrfgDc8J9hmbkazhlxekalcefhlkaPce4cbaPceG9R7amfgmhzkdndnadcd9hmbabarcetfgDaH87ebaDclfaz87ebaDcdfaO87ebxekabarcdtfgDaHBdbaDcwfazBdbaDclfaOBdbkavc;abfaocitfgDaOBdbaDaHBdlavaicdtfaHBdbavc;abfaocefcsGcitfgDazBdbaDaOBdlavaicefgicsGcdtfaOBdbavc;abfaocdfcsGcitfgDaHBdbaDazBdlavaiaCTaCcsSVfgicsGcdtfazBdbaiaATaAcsSVfhiaocifhokawcefhwaocsGhoaicsGhiarcifgrae6mbkkcbc99alaqSEhokavc;aef8Kjjjjbaok:clevu8Jjjjjbcz9Rhvdnalaecvf9pmbc9:skdnaiRbbc;:eGc;qeSmbcuskav9cb83iwaicefhoaialfc98fhrdnaeTmbdnadcdSmbcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcdtfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgiBdbalaiBdbawcefgwae9hmbxdkkcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcetfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgi87ebalaiBdbawcefgwae9hmbkkcbc99aoarSEk;Toio97eue97aec98Ghedndnadcl9hmbaeTmecbhdinababpbbbgicKp:RecKp:Sep;6eglaicwp:RecKp:Sep;6ealp;Geaiczp:RecKp:Sep;6egvp;Gep;Kep;Legopxbbbbbbbbbbbbbbbbp:2egralpxbbbjbbbjbbbjbbbjgwp9op9rp;Keglpxbb;:9cbb;:9cbb;:9cbb;:9calalp;Meaoaop;Meavaravawp9op9rp;Keglalp;Mep;Kep;Kep;Jep;Negvp;Mepxbbn0bbn0bbn0bbn0grp;KepxFbbbFbbbFbbbFbbbp9oaipxbbbFbbbFbbbFbbbFp9op9qalavp;Mearp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaoavp;Mearp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpkbbabczfhbadclfgdae6mbxdkkaeTmbcbhdinabczfgDaDpbbbgipxbbbbbbFFbbbbbbFFgwp9oabpbbbgoaipmbediwDqkzHOAKY8AEgvczp:Reczp:Sep;6eglaoaipmlvorxmPsCXQL358E8FpxFubbFubbFubbFubbp9op;6eavczp:Sep;6egvp;Gealp;Gep;Kep;Legipxbbbbbbbbbbbbbbbbp:2egralpxbbbjbbbjbbbjbbbjgqp9op9rp;Keglpxb;:FSb;:FSb;:FSb;:FSalalp;Meaiaip;Meavaravaqp9op9rp;Keglalp;Mep;Kep;Kep;Jep;Negvp;Mepxbbn0bbn0bbn0bbn0grp;KepxFFbbFFbbFFbbFFbbp9oaiavp;Mearp;Keczp:Rep9qgialavp;Mearp;KepxFFbbFFbbFFbbFFbbp9oglpmwDKYqk8AExm35Ps8E8Fp9qpkbbabaoawp9oaialpmbezHdiOAlvCXorQLp9qpkbbabcafhbadclfgdae6mbkkk;2ileue97euo97dnaec98GgiTmbcbheinabcKfpx:ji:1S:ji:1S:ji:1S:ji:1SabpbbbglabczfgvpbbbgopmlvorxmPsCXQL358E8Fgrczp:Segwpxibbbibbbibbbibbbp9qp;6egDp;NegqaDaDp;MegDaDp;KealaopmbediwDqkzHOAKY8AEgDczp:Reczp:Sep;6eglalp;MeaDczp:Sep;6egoaop;Mearczp:Reczp:Sep;6egrarp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jep;Mepxbbn0bbn0bbn0bbn0gDp;KepxFFbbFFbbFFbbFFbbgkp9oaqaop;MeaDp;Keczp:Rep9qgoaqalp;MeaDp;Keakp9oaqarp;MeaDp;Keczp:Rep9qgDpmwDKYqk8AExm35Ps8E8Fglp5eawclp:RegqpEi:T:j83ibavalp5baqpEd:T:j83ibabcwfaoaDpmbezHdiOAlvCXorQLgDp5eaqpEe:T:j83ibabaDp5baqpEb:T:j83ibabcafhbaeclfgeai6mbkkkuee97dnadcd4ae2c98GgeTmbcbhdinababpbbbgicwp:Recwp:Sep;6eaicep:SepxbbjFbbjFbbjFbbjFp9opxbbjZbbjZbbjZbbjZp:Uep;Mepkbbabczfhbadclfgdae6mbkkk:Sodw97euaec98Ghedndnadcl9hmbaeTmecbhdinabpxbbuJbbuJbbuJbbuJabpbbbgicKp:TeglaicYp:Tep9qgvcdp:Teavp9qgvclp:Teavp9qgop;6ep;Negvaicwp:RecKp:SegraipxFbbbFbbbFbbbFbbbgwp9ogDp:Uep;6ep;Mepxbbn0bbn0bbn0bbn0gqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9oavaDarp:Xeaiczp:RecKp:Segip:Uep;6ep;Meaqp;Keawp9op9qavaDaraip:Uep:Xep;6ep;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qavaoalcep:Rep9oalpxebbbebbbebbbebbbp9op9qp;6ep;Meaqp;KecKp:Rep9qpkbbabczfhbadclfgdae6mbxdkkaeTmbcbhdinabczfgkpxbFu9hbFu9hbFu9hbFu9habpbbbglakpbbbgrpmlvorxmPsCXQL358E8Fgvczp:TegqavcHp:Tep9qgicdp:Teaip9qgiclp:Teaip9qgicwp:Teaip9qgop;6ep;NegialarpmbediwDqkzHOAKY8AEgDpxFFbbFFbbFFbbFFbbglp9ograDczp:Segwp:Ueavczp:Reczp:SegDp:Xep;6ep;Mepxbbn0bbn0bbn0bbn0gvp;Kealp9oaiarawaDp:Uep:Xep;6ep;Meavp;Keczp:Rep9qgwaiaoaqcep:Rep9oaqpxebbbebbbebbbebbbp9op9qp;6ep;Meavp;Keczp:ReaiaDarp:Uep;6ep;Meavp;Kealp9op9qgipmwDKYqk8AExm35Ps8E8FpkbbabawaipmbezHdiOAlvCXorQLpkbbabcafhbadclfgdae6mbkkk9teiucbcbydj:G:cjbgeabcifc98GfgbBdj:G:cjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaikkxebcj:Gdklz:zbb",t=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]),n=new Uint8Array([32,0,65,2,1,106,34,33,3,128,11,4,13,64,6,253,10,7,15,116,127,5,8,12,40,16,19,54,20,9,27,255,113,17,42,67,24,23,146,148,18,14,22,45,70,69,56,114,101,21,25,63,75,136,108,28,118,29,73,115]);if(typeof WebAssembly!="object")return{supported:!1};var r=WebAssembly.validate(t)?o(e):o(i),s,a=WebAssembly.instantiate(r,{}).then(function(g){s=g.instance,s.exports.__wasm_call_ctors()});function o(g){for(var S=new Uint8Array(g.length),A=0;A<g.length;++A){var T=g.charCodeAt(A);S[A]=T>96?T-97:T>64?T-39:T+4}for(var N=0,A=0;A<g.length;++A)S[N++]=S[A]<60?n[S[A]]:(S[A]-60)*64+S[++A];return S.buffer.slice(0,N)}function l(g,S,A,T,N,P,U){var v=g.exports.sbrk,I=T+3&-4,B=v(I*N),k=v(P.length),V=new Uint8Array(g.exports.memory.buffer);V.set(P,k);var J=S(B,T,N,k,P.length);if(J==0&&U&&U(B,I,N),A.set(V.subarray(B,B+T*N)),v(B-v(0)),J!=0)throw new Error("Malformed buffer data: "+J)}var c={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp",COLOR:"meshopt_decodeFilterColor"},h={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"},d=[],f=0;function p(g){var S={object:new Worker(g),pending:0,requests:{}};return S.object.onmessage=function(A){var T=A.data;S.pending-=T.count,S.requests[T.id][T.action](T.value),delete S.requests[T.id]},S}function x(g){for(var S="self.ready = WebAssembly.instantiate(new Uint8Array(["+new Uint8Array(r)+"]), {}).then(function(result) { result.instance.exports.__wasm_call_ctors(); return result.instance; });self.onmessage = "+b.name+";"+l.toString()+b.toString(),A=new Blob([S],{type:"text/javascript"}),T=URL.createObjectURL(A),N=d.length;N<g;++N)d[N]=p(T);for(var N=g;N<d.length;++N)d[N].object.postMessage({});d.length=g,URL.revokeObjectURL(T)}function y(g,S,A,T,N){for(var P=d[0],U=1;U<d.length;++U)d[U].pending<P.pending&&(P=d[U]);return new Promise(function(v,I){var B=new Uint8Array(A),k=++f;P.pending+=g,P.requests[k]={resolve:v,reject:I},P.object.postMessage({id:k,count:g,size:S,source:B,mode:T,filter:N},[B.buffer])})}function b(g){var S=g.data;self.ready.then(function(A){if(!S.id)return self.close();try{var T=new Uint8Array(S.count*S.size);l(A,A.exports[S.mode],T,S.count,S.size,S.source,A.exports[S.filter]),self.postMessage({id:S.id,count:S.count,action:"resolve",value:T},[T.buffer])}catch(N){self.postMessage({id:S.id,count:S.count,action:"reject",value:N})}})}return{ready:a,supported:!0,useWorkers:function(g){x(g)},decodeVertexBuffer:function(g,S,A,T,N){l(s,s.exports.meshopt_decodeVertexBuffer,g,S,A,T,s.exports[c[N]])},decodeIndexBuffer:function(g,S,A,T){l(s,s.exports.meshopt_decodeIndexBuffer,g,S,A,T)},decodeIndexSequence:function(g,S,A,T){l(s,s.exports.meshopt_decodeIndexSequence,g,S,A,T)},decodeGltfBuffer:function(g,S,A,T,N,P){l(s,s.exports[h[N]],g,S,A,T,s.exports[c[P]])},decodeGltfBufferAsync:function(g,S,A,T,N){return d.length>0?y(g,S,A,h[T],c[N]):a.then(function(){var P=new Uint8Array(g*S);return l(s,s.exports[h[T]],P,g,S,A,s.exports[c[N]]),P})}}})()});function pE(i){typeof i=="string"&&i&&(jb=i.endsWith("/")?i:`${i}/`)}function Xb(){return mp||(mp=Promise.resolve().then(()=>(qb(),Wb)).then(i=>i.MeshoptDecoder).catch(()=>null)),mp}function Gh(){if(La)return La;La=new kh;let i=new Hh;return i.setDecoderPath(jb),La.setDRACOLoader(i),Xb().then(e=>{e&&La.setMeshoptDecoder(e)}),La}async function Kb(){let i=Gh();return await Xb(),i}var $b,La,jb,mp,Vh=un(()=>{Gb();Vb();$b="https://cdn.jsdelivr.net/npm/[email protected]/examples/jsm/libs/draco/gltf/",La=null,jb=$b,mp=null});function Rp(i){let e=i&&i.length?i.length/4:0;if(!e)return{intensity:.4,tint:{r:1,g:1,b:1}};let t=0,n=0,r=0,s=0;for(let h=0;h<i.length;h+=4){let d=i[h],f=i[h+1],p=i[h+2];t+=d,n+=f,r+=p,s+=.2126*d+.7152*f+.0722*p}let a=s/e/255,o=Math.min(1.35,Math.max(.4,.35+a*1.25)),l=(t+n+r)/(e*3);if(l<=6)return{intensity:o,tint:{r:1,g:1,b:1}};let c=h=>1+(h/e/l-1)*.33;return{intensity:o,tint:{r:c(t),g:c(n),b:c(r)}}}function Ko(i,{skinned:e=!1}={}){let t=Number(i?.max?.x)-Number(i?.min?.x),n=Number(i?.max?.y)-Number(i?.min?.y),r=Number(i?.max?.z)-Number(i?.min?.z);if(![t,n,r].every(c=>Number.isFinite(c)&&c>=0))return{scale:1,yOffset:0};let s=Math.max(t,n,r);if(s<=1e-6)return{scale:1,yOffset:0};let a;e&&n>1e-6?a=1.65/n:a=.75/s,a>.5&&a<2&&(a=1);let o=Number(i.min.y),l=Number.isFinite(o)?-o*a:0;return{scale:a,yOffset:l}}function Cp(i,e,t=1.6){let n=Number(e?.x)||0,r=Number(e?.z)||0,s=Math.hypot(n,r),a=s>1e-4?n/s:0,o=s>1e-4?r/s:-1,l=(Number(i?.x)||0)+a*t,c=(Number(i?.z)||0)+o*t;return{x:l,z:c}}function Ip(i,e){if(!Number.isFinite(i)||!Number.isFinite(e))return 0;let t=e-i;for(;t>Math.PI;)t-=2*Math.PI;for(;t<=-Math.PI;)t+=2*Math.PI;return t}function Yh(i){return Math.atan2(i[1].clientY-i[0].clientY,i[1].clientX-i[0].clientX)}function Jr(i){let e=String(i??"").trim();if(!e)return null;if(e.startsWith("/")&&!e.startsWith("//"))return e;try{let t=new URL(e);return t.protocol==="https:"?t.href:null}catch{return null}}function Jh(i){let e=(Array.isArray(i)?i:[]).slice(0,20).map(t=>({src:String(t.src||""),title:String(t.title||"").slice(0,120),x:Number(t.x)||0,z:Number(t.z)||0,yaw:Number(t.yaw)||0,scale:Xh(Number(t.scale)||1,.25,4)})).filter(t=>Jr(t.src));return JSON.stringify({v:1,items:e})}function Zh(i){let e;try{e=JSON.parse(i??"null")}catch{return[]}if(!e||e.v!==1||!Array.isArray(e.items))return[];let t=[];for(let n of e.items){if(t.length>=20)break;let r=Jr(n?.src);if(!r)continue;let s=Number(n.x),a=Number(n.z);!Number.isFinite(s)||!Number.isFinite(a)||t.push({src:r,title:String(n.title||"").slice(0,120),x:Xh(s,-50,50),z:Xh(a,-50,50),yaw:Number.isFinite(Number(n.yaw))?Number(n.yaw):0,scale:Xh(Number(n.scale)||1,.25,4)})}return t}function WE(i){let e=new TextEncoder().encode(i),t="";for(let n of e)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function qE(i){let e=String(i).replace(/-/g,"+").replace(/_/g,"/"),t=atob(e+"=".repeat((4-e.length%4)%4)),n=Uint8Array.from(t,r=>r.charCodeAt(0));return new TextDecoder().decode(n)}function Mx(i){let e=Jh(i);try{return JSON.parse(e).items.length?WE(e):""}catch{return""}}function Pp(i){if(!i)return[];try{return Zh(qE(i))}catch{return[]}}function Lp(i,e,t=1500){let n=Qh(i,e),r=Mx(e);if(!r)return n;let s=`${n}#s=${r}`;return s.length<=t?s:n}function Qh(i,e,t=4){let n=String(i||"").split("#")[0],r=(Array.isArray(e)?e:[]).map(c=>({src:Jr(c.src),title:String(c.title||"").slice(0,60)})).filter(c=>c.src),s=new Set,a=r.filter(c=>s.has(c.src)?!1:(s.add(c.src),!0)).slice(0,t);if(!a.length)return n;let o=new URLSearchParams;for(let c of a)o.append("src",c.src),o.append("title",c.title);let l=n.includes("?")?"&":"?";return`${n}${l}${o.toString()}`}var zE,HE,GE,VE,Kh,Ep,Xh,eu=un(()=>{zE=1.65,HE=.75,GE=.25,VE=4,Kh=20,Ep=1.6;Xh=(i,e,t)=>Math.min(t,Math.max(e,i))});function tR(i,e){return eR(i,e||{},0,0)}function Qo(i,e){if(e){for(var t=new Cn(i.length),n=0;n<i.length;++n)t[n]=i.charCodeAt(n);return t}if(Cx)return Cx.encode(i);for(var r=i.length,s=new Cn(i.length+(i.length>>1)),a=0,o=function(h){s[a++]=h},n=0;n<r;++n){if(a+5>s.length){var l=new Cn(a+8+(r-n<<1));l.set(s),s=l}var c=i.charCodeAt(n);c<128||e?o(c):c<2048?(o(192|c>>6),o(128|c&63)):c>55295&&c<57344?(c=65536+(c&1047552)|i.charCodeAt(++n)&1023,o(240|c>>18),o(128|c>>12&63),o(128|c>>6&63),o(128|c&63)):(o(224|c>>12),o(128|c>>6&63),o(128|c&63))}return Ox(s,0,a)}function zx(i,e){e||(e={});var t={},n=[];Bx(i,"",t,e);var r=0,s=0;for(var a in t){var o=t[a],l=o[0],c=o[1],h=c.level==0?0:8,d=Qo(a),f=d.length,p=c.comment,x=p&&Qo(p),y=x&&x.length,b=Up(c.extra);f>65535&&nu(11);var g=h?tR(l,c):l,S=g.length,A=QE();A.p(l),n.push(kx(c,{size:l.length,crc:A.d(),c:g,f:d,m:x,u:f!=a.length||x&&p.length!=y,o:r,compression:h})),r+=30+f+b+S,s+=76+2*(f+b)+(y||0)+S}for(var T=new Cn(s+22),N=r,P=s-r,U=0;U<n.length;++U){var d=n[U];Ix(T,d.o,d,d.f,d.u,d.c.length);var v=30+d.f.length+Up(d.extra);T.set(d.c,d.o+v),Ix(T,r,d,d.f,d.u,d.c.length,d.o,d.m),r+=16+v+(d.m?d.m.length:0)}return rR(T,r,n.length,P,N),T}var Cn,li,kp,Bp,zp,Ax,Px,Lx,$E,Np,Dx,rL,Tx,Op,xr,Lt,Zo,Os,Lt,Lt,Lt,Lt,tu,Lt,jE,XE,Nx,Ox,KE,nu,_r,Yo,Dp,Fp,Ex,Jo,Fx,Rx,YE,Ux,JE,ZE,QE,eR,kx,Rn,Bx,Cx,nR,iR,Up,Ix,rR,Hx=un(()=>{Cn=Uint8Array,li=Uint16Array,kp=Int32Array,Bp=new Cn([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),zp=new Cn([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Ax=new Cn([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Px=function(i,e){for(var t=new li(31),n=0;n<31;++n)t[n]=e+=1<<i[n-1];for(var r=new kp(t[30]),n=1;n<30;++n)for(var s=t[n];s<t[n+1];++s)r[s]=s-t[n]<<5|n;return{b:t,r}},Lx=Px(Bp,2),$E=Lx.b,Np=Lx.r;$E[28]=258,Np[258]=28;Dx=Px(zp,0),rL=Dx.b,Tx=Dx.r,Op=new li(32768);for(Lt=0;Lt<32768;++Lt)xr=(Lt&43690)>>1|(Lt&21845)<<1,xr=(xr&52428)>>2|(xr&13107)<<2,xr=(xr&61680)>>4|(xr&3855)<<4,Op[Lt]=((xr&65280)>>8|(xr&255)<<8)>>1;Zo=(function(i,e,t){for(var n=i.length,r=0,s=new li(e);r<n;++r)i[r]&&++s[i[r]-1];var a=new li(e);for(r=1;r<e;++r)a[r]=a[r-1]+s[r-1]<<1;var o;if(t){o=new li(1<<e);var l=15-e;for(r=0;r<n;++r)if(i[r])for(var c=r<<4|i[r],h=e-i[r],d=a[i[r]-1]++<<h,f=d|(1<<h)-1;d<=f;++d)o[Op[d]>>l]=c}else for(o=new li(n),r=0;r<n;++r)i[r]&&(o[r]=Op[a[i[r]-1]++]>>15-i[r]);return o}),Os=new Cn(288);for(Lt=0;Lt<144;++Lt)Os[Lt]=8;for(Lt=144;Lt<256;++Lt)Os[Lt]=9;for(Lt=256;Lt<280;++Lt)Os[Lt]=7;for(Lt=280;Lt<288;++Lt)Os[Lt]=8;tu=new Cn(32);for(Lt=0;Lt<32;++Lt)tu[Lt]=5;jE=Zo(Os,9,0),XE=Zo(tu,5,0),Nx=function(i){return(i+7)/8|0},Ox=function(i,e,t){return(e==null||e<0)&&(e=0),(t==null||t>i.length)&&(t=i.length),new Cn(i.subarray(e,t))},KE=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],nu=function(i,e,t){var n=new Error(e||KE[i]);if(n.code=i,Error.captureStackTrace&&Error.captureStackTrace(n,nu),!t)throw n;return n},_r=function(i,e,t){t<<=e&7;var n=e/8|0;i[n]|=t,i[n+1]|=t>>8},Yo=function(i,e,t){t<<=e&7;var n=e/8|0;i[n]|=t,i[n+1]|=t>>8,i[n+2]|=t>>16},Dp=function(i,e){for(var t=[],n=0;n<i.length;++n)i[n]&&t.push({s:n,f:i[n]});var r=t.length,s=t.slice();if(!r)return{t:Ux,l:0};if(r==1){var a=new Cn(t[0].s+1);return a[t[0].s]=1,{t:a,l:1}}t.sort(function(N,P){return N.f-P.f}),t.push({s:-1,f:25001});var o=t[0],l=t[1],c=0,h=1,d=2;for(t[0]={s:-1,f:o.f+l.f,l:o,r:l};h!=r-1;)o=t[t[c].f<t[d].f?c++:d++],l=t[c!=h&&t[c].f<t[d].f?c++:d++],t[h++]={s:-1,f:o.f+l.f,l:o,r:l};for(var f=s[0].s,n=1;n<r;++n)s[n].s>f&&(f=s[n].s);var p=new li(f+1),x=Fp(t[h-1],p,0);if(x>e){var n=0,y=0,b=x-e,g=1<<b;for(s.sort(function(P,U){return p[U.s]-p[P.s]||P.f-U.f});n<r;++n){var S=s[n].s;if(p[S]>e)y+=g-(1<<x-p[S]),p[S]=e;else break}for(y>>=b;y>0;){var A=s[n].s;p[A]<e?y-=1<<e-p[A]++-1:++n}for(;n>=0&&y;--n){var T=s[n].s;p[T]==e&&(--p[T],++y)}x=e}return{t:new Cn(p),l:x}},Fp=function(i,e,t){return i.s==-1?Math.max(Fp(i.l,e,t+1),Fp(i.r,e,t+1)):e[i.s]=t},Ex=function(i){for(var e=i.length;e&&!i[--e];);for(var t=new li(++e),n=0,r=i[0],s=1,a=function(l){t[n++]=l},o=1;o<=e;++o)if(i[o]==r&&o!=e)++s;else{if(!r&&s>2){for(;s>138;s-=138)a(32754);s>2&&(a(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(a(r),--s;s>6;s-=6)a(8304);s>2&&(a(s-3<<5|8208),s=0)}for(;s--;)a(r);s=1,r=i[o]}return{c:t.subarray(0,n),n:e}},Jo=function(i,e){for(var t=0,n=0;n<e.length;++n)t+=i[n]*e[n];return t},Fx=function(i,e,t){var n=t.length,r=Nx(e+2);i[r]=n&255,i[r+1]=n>>8,i[r+2]=i[r]^255,i[r+3]=i[r+1]^255;for(var s=0;s<n;++s)i[r+s+4]=t[s];return(r+4+n)*8},Rx=function(i,e,t,n,r,s,a,o,l,c,h){_r(e,h++,t),++r[256];for(var d=Dp(r,15),f=d.t,p=d.l,x=Dp(s,15),y=x.t,b=x.l,g=Ex(f),S=g.c,A=g.n,T=Ex(y),N=T.c,P=T.n,U=new li(19),v=0;v<S.length;++v)++U[S[v]&31];for(var v=0;v<N.length;++v)++U[N[v]&31];for(var I=Dp(U,7),B=I.t,k=I.l,V=19;V>4&&!B[Ax[V-1]];--V);var J=c+5<<3,L=Jo(r,Os)+Jo(s,tu)+a,E=Jo(r,f)+Jo(s,y)+a+14+3*V+Jo(U,B)+2*U[16]+3*U[17]+7*U[18];if(l>=0&&J<=L&&J<=E)return Fx(e,h,i.subarray(l,l+c));var D,O,H,Y;if(_r(e,h,1+(E<L)),h+=2,E<L){D=Zo(f,p,0),O=f,H=Zo(y,b,0),Y=y;var le=Zo(B,k,0);_r(e,h,A-257),_r(e,h+5,P-1),_r(e,h+10,V-4),h+=14;for(var v=0;v<V;++v)_r(e,h+3*v,B[Ax[v]]);h+=3*V;for(var fe=[S,N],be=0;be<2;++be)for(var Te=fe[be],v=0;v<Te.length;++v){var Je=Te[v]&31;_r(e,h,le[Je]),h+=B[Je],Je>15&&(_r(e,h,Te[v]>>5&127),h+=Te[v]>>12)}}else D=jE,O=Os,H=XE,Y=tu;for(var v=0;v<o;++v){var ke=n[v];if(ke>255){var Je=ke>>18&31;Yo(e,h,D[Je+257]),h+=O[Je+257],Je>7&&(_r(e,h,ke>>23&31),h+=Bp[Je]);var oe=ke&31;Yo(e,h,H[oe]),h+=Y[oe],oe>3&&(Yo(e,h,ke>>5&8191),h+=zp[oe])}else Yo(e,h,D[ke]),h+=O[ke]}return Yo(e,h,D[256]),h+O[256]},YE=new kp([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Ux=new Cn(0),JE=function(i,e,t,n,r,s){var a=s.z||i.length,o=new Cn(n+a+5*(1+Math.ceil(a/7e3))+r),l=o.subarray(n,o.length-r),c=s.l,h=(s.r||0)&7;if(e){h&&(l[0]=s.r>>3);for(var d=YE[e-1],f=d>>13,p=d&8191,x=(1<<t)-1,y=s.p||new li(32768),b=s.h||new li(x+1),g=Math.ceil(t/3),S=2*g,A=function(mt){return(i[mt]^i[mt+1]<<g^i[mt+2]<<S)&x},T=new kp(25e3),N=new li(288),P=new li(32),U=0,v=0,I=s.i||0,B=0,k=s.w||0,V=0;I+2<a;++I){var J=A(I),L=I&32767,E=b[J];if(y[L]=E,b[J]=L,k<=I){var D=a-I;if((U>7e3||B>24576)&&(D>423||!c)){h=Rx(i,l,0,T,N,P,v,B,V,I-V,h),B=U=v=0,V=I;for(var O=0;O<286;++O)N[O]=0;for(var O=0;O<30;++O)P[O]=0}var H=2,Y=0,le=p,fe=L-E&32767;if(D>2&&J==A(I-fe))for(var be=Math.min(f,D)-1,Te=Math.min(32767,I),Je=Math.min(258,D);fe<=Te&&--le&&L!=E;){if(i[I+H]==i[I+H-fe]){for(var ke=0;ke<Je&&i[I+ke]==i[I+ke-fe];++ke);if(ke>H){if(H=ke,Y=fe,ke>be)break;for(var oe=Math.min(fe,ke-2),Ee=0,O=0;O<oe;++O){var _e=I-fe+O&32767,Ze=y[_e],tt=_e-Ze&32767;tt>Ee&&(Ee=tt,E=_e)}}}L=E,E=y[L],fe+=L-E&32767}if(Y){T[B++]=268435456|Np[H]<<18|Tx[Y];var Qe=Np[H]&31,Et=Tx[Y]&31;v+=Bp[Qe]+zp[Et],++N[257+Qe],++P[Et],k=I+H,++U}else T[B++]=i[I],++N[i[I]]}}for(I=Math.max(I,k);I<a;++I)T[B++]=i[I],++N[i[I]];h=Rx(i,l,c,T,N,P,v,B,V,I-V,h),c||(s.r=h&7|l[h/8|0]<<3,h-=7,s.h=b,s.p=y,s.i=I,s.w=k)}else{for(var I=s.w||0;I<a+c;I+=65535){var it=I+65535;it>=a&&(l[h/8|0]=c,it=a),h=Fx(l,h+1,i.subarray(I,it))}s.i=a}return Ox(o,0,n+Nx(h)+r)},ZE=(function(){for(var i=new Int32Array(256),e=0;e<256;++e){for(var t=e,n=9;--n;)t=(t&1&&-306674912)^t>>>1;i[e]=t}return i})(),QE=function(){var i=-1;return{p:function(e){for(var t=i,n=0;n<e.length;++n)t=ZE[t&255^e[n]]^t>>>8;i=t},d:function(){return~i}}},eR=function(i,e,t,n,r){if(!r&&(r={l:1},e.dictionary)){var s=e.dictionary.subarray(-32768),a=new Cn(s.length+i.length);a.set(s),a.set(i,s.length),i=a,r.w=s.length}return JE(i,e.level==null?6:e.level,e.mem==null?r.l?Math.ceil(Math.max(8,Math.min(13,Math.log(i.length)))*1.5):20:12+e.mem,t,n,r)},kx=function(i,e){var t={};for(var n in i)t[n]=i[n];for(var n in e)t[n]=e[n];return t},Rn=function(i,e,t){for(;t;++e)i[e]=t,t>>>=8};Bx=function(i,e,t,n){for(var r in i){var s=i[r],a=e+r,o=n;Array.isArray(s)&&(o=kx(n,s[1]),s=s[0]),s instanceof Cn?t[a]=[s,o]:(t[a+="/"]=[new Cn(0),o],Bx(s,a,t,n))}},Cx=typeof TextEncoder<"u"&&new TextEncoder,nR=typeof TextDecoder<"u"&&new TextDecoder,iR=0;try{nR.decode(Ux,{stream:!0}),iR=1}catch{}Up=function(i){var e=0;if(i)for(var t in i){var n=i[t].length;n>65535&&nu(9),e+=n+4}return e},Ix=function(i,e,t,n,r,s,a,o){var l=n.length,c=t.extra,h=o&&o.length,d=Up(c);Rn(i,e,a!=null?33639248:67324752),e+=4,a!=null&&(i[e++]=20,i[e++]=t.os),i[e]=20,e+=2,i[e++]=t.flag<<1|(s<0&&8),i[e++]=r&&8,i[e++]=t.compression&255,i[e++]=t.compression>>8;var f=new Date(t.mtime==null?Date.now():t.mtime),p=f.getFullYear()-1980;if((p<0||p>119)&&nu(10),Rn(i,e,p<<25|f.getMonth()+1<<21|f.getDate()<<16|f.getHours()<<11|f.getMinutes()<<5|f.getSeconds()>>1),e+=4,s!=-1&&(Rn(i,e,t.crc),Rn(i,e+4,s<0?-s-2:s),Rn(i,e+8,t.size)),Rn(i,e+12,l),Rn(i,e+14,d),e+=16,a!=null&&(Rn(i,e,h),Rn(i,e+6,t.attrs),Rn(i,e+10,a),e+=14),i.set(n,e),e+=l,d)for(var x in c){var y=c[x],b=y.length;Rn(i,e,+x),Rn(i,e+2,b),i.set(y,e+4),e+=4+b}return h&&(i.set(o,e),e+=h),e},rR=function(i,e,t,n,r){Rn(i,e,101010256),Rn(i,e+8,t),Rn(i,e+10,t),Rn(i,e+12,n),Rn(i,e+16,r)}});var Kx={};Ar(Kx,{USDZExporter:()=>Gp});function Wx(i,e){let t=i.name;return t=t.replace(/[^A-Za-z0-9_]/g,""),/^[0-9]/.test(t)&&(t="_"+t),t===""&&(i.isCamera?t="Camera":t="Object"),e.has(t)&&(t=t+"_"+i.id),e.add(t),t}function sR(i,e,t){if(typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&i instanceof OffscreenCanvas||typeof ImageBitmap<"u"&&i instanceof ImageBitmap){let n=t/Math.max(i.width,i.height),r=document.createElement("canvas");r.width=i.width*Math.min(1,n),r.height=i.height*Math.min(1,n);let s=r.getContext("2d");return e===!0&&(s.translate(0,r.height),s.scale(1,-1)),s.drawImage(i,0,0,r.width,r.height),r}else throw new Error("THREE.USDZExporter: No valid image data found. Unable to process texture.")}function qx(){return`#usda 1.0
+}`,Hp=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let n=new sc(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=n}}getMesh(e){if(this.texture!==null&&this.mesh===null){let t=e.cameras[0].viewport,n=new bi({vertexShader:dC,fragmentShader:pC,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new vt(new Ii(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},Vp=class extends Ki{constructor(e,t){super();let n=this,s=null,r=1,a=null,o="local-floor",c=1,l=null,h=null,u=null,d=null,p=null,b=null,v=typeof XRWebGLBinding<"u",_=new Hp,g={},E=t.getContextAttributes(),L=null,S=null,M=[],A=[],I=new dt,y=null,C=null,k=new fn;k.viewport=new Gt;let z=new fn;z.viewport=new Gt;let $=[k,z],K=new Th,P=null,N=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(fe){let ge=M[fe];return ge===void 0&&(ge=new Ka,M[fe]=ge),ge.getTargetRaySpace()},this.getControllerGrip=function(fe){let ge=M[fe];return ge===void 0&&(ge=new Ka,M[fe]=ge),ge.getGripSpace()},this.getHand=function(fe){let ge=M[fe];return ge===void 0&&(ge=new Ka,M[fe]=ge),ge.getHandSpace()};function O(fe){let ge=A.indexOf(fe.inputSource);if(ge===-1)return;let Ve=M[ge];Ve!==void 0&&(Ve.update(fe.inputSource,fe.frame,l||a),Ve.dispatchEvent({type:fe.type,data:fe.inputSource}))}function F(){s.removeEventListener("select",O),s.removeEventListener("selectstart",O),s.removeEventListener("selectend",O),s.removeEventListener("squeeze",O),s.removeEventListener("squeezestart",O),s.removeEventListener("squeezeend",O),s.removeEventListener("end",F),s.removeEventListener("inputsourceschange",H);for(let fe=0;fe<M.length;fe++){let ge=A[fe];ge!==null&&(A[fe]=null,M[fe].disconnect(ge))}P=null,N=null,_.reset();for(let fe in g)delete g[fe];if(e.setRenderTarget(L),p=null,d=null,u=null,s=null,S=null,Qe.stop(),n.isPresenting=!1,e.setPixelRatio(y),e.setSize(I.width,I.height,!1),C!==null){let fe=C.camera;fe.fov=C.fov,fe.zoom=C.zoom,fe.updateProjectionMatrix(),C=null}n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(fe){r=fe,n.isPresenting===!0&&tt("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(fe){o=fe,n.isPresenting===!0&&tt("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||a},this.setReferenceSpace=function(fe){l=fe},this.getBaseLayer=function(){return d!==null?d:p},this.getBinding=function(){return u===null&&v&&(u=new XRWebGLBinding(s,t)),u},this.getFrame=function(){return b},this.getSession=function(){return s},this.setSession=async function(fe){if(s=fe,s!==null){if(L=e.getRenderTarget(),s.addEventListener("select",O),s.addEventListener("selectstart",O),s.addEventListener("selectend",O),s.addEventListener("squeeze",O),s.addEventListener("squeezestart",O),s.addEventListener("squeezeend",O),s.addEventListener("end",F),s.addEventListener("inputsourceschange",H),E.xrCompatible!==!0&&await t.makeXRCompatible(),y=e.getPixelRatio(),e.getSize(I),v&&"createProjectionLayer"in XRWebGLBinding.prototype){let Ve=null,it=null,Ue=null;E.depth&&(Ue=E.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,Ve=E.stencil?Sr:fs,it=E.stencil?ro:Zi);let ct={colorFormat:t.RGBA8,depthFormat:Ue,scaleFactor:r};u=this.getBinding(),d=u.createProjectionLayer(ct),s.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),S=new Gn(d.textureWidth,d.textureHeight,{format:yi,type:oi,depthTexture:new pr(d.textureWidth,d.textureHeight,it,void 0,void 0,void 0,void 0,void 0,void 0,Ve),stencilBuffer:E.stencil,colorSpace:e.outputColorSpace,samples:E.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1,storeMultisampledDepthBuffer:d.ignoreDepthValues===!1,storeMultisampledStencilBuffer:d.ignoreDepthValues===!1})}else{let Ve={antialias:E.antialias,alpha:!0,depth:E.depth,stencil:E.stencil,framebufferScaleFactor:r};p=new XRWebGLLayer(s,t,Ve),s.updateRenderState({baseLayer:p}),e.setPixelRatio(1),e.setSize(p.framebufferWidth,p.framebufferHeight,!1),S=new Gn(p.framebufferWidth,p.framebufferHeight,{format:yi,type:oi,colorSpace:e.outputColorSpace,stencilBuffer:E.stencil,resolveDepthBuffer:p.ignoreDepthValues===!1,resolveStencilBuffer:p.ignoreDepthValues===!1,storeMultisampledDepthBuffer:p.ignoreDepthValues===!1,storeMultisampledStencilBuffer:p.ignoreDepthValues===!1})}S.isXRRenderTarget=!0,this.setFoveation(c),l=null,a=await s.requestReferenceSpace(o),Qe.setContext(s),Qe.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(s!==null)return s.environmentBlendMode},this.getDepthTexture=function(){return _.getDepthTexture()};function H(fe){for(let ge=0;ge<fe.removed.length;ge++){let Ve=fe.removed[ge],it=A.indexOf(Ve);it>=0&&(A[it]=null,M[it].disconnect(Ve))}for(let ge=0;ge<fe.added.length;ge++){let Ve=fe.added[ge],it=A.indexOf(Ve);if(it===-1){for(let ct=0;ct<M.length;ct++)if(ct>=A.length){A.push(Ve),it=ct;break}else if(A[ct]===null){A[ct]=Ve,it=ct;break}if(it===-1)break}let Ue=M[it];Ue&&Ue.connect(Ve)}}let V=new j,Q=new j;function te(fe,ge,Ve){V.setFromMatrixPosition(ge.matrixWorld),Q.setFromMatrixPosition(Ve.matrixWorld);let it=V.distanceTo(Q),Ue=ge.projectionMatrix.elements,ct=Ve.projectionMatrix.elements,zt=Ue[14]/(Ue[10]-1),ot=Ue[14]/(Ue[10]+1),mt=(Ue[9]+1)/Ue[5],Lt=(Ue[9]-1)/Ue[5],ft=(Ue[8]-1)/Ue[0],xt=(ct[8]+1)/ct[0],Wt=zt*ft,_n=zt*xt,Ht=it/(-ft+xt),Kt=Ht*-ft;if(ge.matrixWorld.decompose(fe.position,fe.quaternion,fe.scale),fe.translateX(Kt),fe.translateZ(Ht),fe.matrixWorld.compose(fe.position,fe.quaternion,fe.scale),fe.matrixWorldInverse.copy(fe.matrixWorld).invert(),Ue[10]===-1)fe.projectionMatrix.copy(ge.projectionMatrix),fe.projectionMatrixInverse.copy(ge.projectionMatrixInverse);else{let q=zt+Ht,hn=ot+Ht,Et=Wt-Kt,U=_n+(it-Kt),w=mt*ot/hn*q,ee=Lt*ot/hn*q;fe.projectionMatrix.makePerspective(Et,U,w,ee,q,hn),fe.projectionMatrixInverse.copy(fe.projectionMatrix).invert()}}function Se(fe,ge){ge===null?fe.matrixWorld.copy(fe.matrix):fe.matrixWorld.multiplyMatrices(ge.matrixWorld,fe.matrix),fe.matrixWorldInverse.copy(fe.matrixWorld).invert()}this.updateCamera=function(fe){if(s===null)return;let ge=fe.near,Ve=fe.far;_.texture!==null&&(_.depthNear>0&&(ge=_.depthNear),_.depthFar>0&&(Ve=_.depthFar)),K.near=z.near=k.near=ge,K.far=z.far=k.far=Ve,(P!==K.near||N!==K.far)&&(s.updateRenderState({depthNear:K.near,depthFar:K.far}),P=K.near,N=K.far),K.layers.mask=fe.layers.mask|6,k.layers.mask=K.layers.mask&-5,z.layers.mask=K.layers.mask&-3;let it=fe.parent,Ue=K.cameras;Se(K,it);for(let ct=0;ct<Ue.length;ct++)Se(Ue[ct],it);Ue.length===2?te(K,k,z):K.projectionMatrix.copy(k.projectionMatrix),C===null&&fe.isPerspectiveCamera&&(C={camera:fe,fov:fe.fov,zoom:fe.zoom}),ve(fe,K,it)};function ve(fe,ge,Ve){Ve===null?fe.matrix.copy(ge.matrixWorld):(fe.matrix.copy(Ve.matrixWorld),fe.matrix.invert(),fe.matrix.multiply(ge.matrixWorld)),fe.matrix.decompose(fe.position,fe.quaternion,fe.scale),fe.updateMatrixWorld(!0),fe.projectionMatrix.copy(ge.projectionMatrix),fe.projectionMatrixInverse.copy(ge.projectionMatrixInverse),fe.isPerspectiveCamera&&(fe.fov=Xr*2*Math.atan(1/fe.projectionMatrix.elements[5]),fe.zoom=1)}this.getCamera=function(){return K},this.getFoveation=function(){if(!(d===null&&p===null))return c},this.setFoveation=function(fe){c=fe,d!==null&&(d.fixedFoveation=fe),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=fe)},this.hasDepthSensing=function(){return _.texture!==null},this.getDepthSensingMesh=function(){return _.getMesh(K)},this.getCameraTexture=function(fe){return g[fe]};let nt=null;function je(fe,ge){if(h=ge.getViewerPose(l||a),b=ge,h!==null){let Ve=h.views;p!==null&&(e.setRenderTargetFramebuffer(S,p.framebuffer),e.setRenderTarget(S));let it=!1;Ve.length!==K.cameras.length&&(K.cameras.length=0,it=!0);for(let ot=0;ot<Ve.length;ot++){let mt=Ve[ot],Lt=null;if(p!==null)Lt=p.getViewport(mt);else{let xt=u.getViewSubImage(d,mt);Lt=xt.viewport,ot===0&&(e.setRenderTargetTextures(S,xt.colorTexture,xt.depthStencilTexture),e.setRenderTarget(S))}let ft=$[ot];ft===void 0&&(ft=new fn,ft.layers.enable(ot),ft.viewport=new Gt,$[ot]=ft),ft.matrix.fromArray(mt.transform.matrix),ft.matrix.decompose(ft.position,ft.quaternion,ft.scale),ft.projectionMatrix.fromArray(mt.projectionMatrix),ft.projectionMatrixInverse.copy(ft.projectionMatrix).invert(),ft.viewport.set(Lt.x,Lt.y,Lt.width,Lt.height),ot===0&&(K.matrix.copy(ft.matrix),K.matrix.decompose(K.position,K.quaternion,K.scale)),it===!0&&K.cameras.push(ft)}let Ue=s.enabledFeatures;if(Ue&&Ue.includes("depth-sensing")&&s.depthUsage=="gpu-optimized"&&v){u=n.getBinding();let ot=u.getDepthInformation(Ve[0]);ot&&ot.isValid&&ot.texture&&_.init(ot,s.renderState)}if(Ue&&Ue.includes("camera-access")&&v){e.state.unbindTexture(),u=n.getBinding();for(let ot=0;ot<Ve.length;ot++){let mt=Ve[ot].camera;if(mt){let Lt=g[mt];Lt||(Lt=new sc,g[mt]=Lt);let ft=u.getCameraImage(mt);Lt.sourceTexture=ft}}}}for(let Ve=0;Ve<M.length;Ve++){let it=A[Ve],Ue=M[Ve];it!==null&&Ue!==void 0&&Ue.update(it,ge,l||a)}nt&&nt(fe,ge),ge.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:ge}),b=null}let Qe=new Q_;Qe.setAnimationLoop(je),this.setAnimationLoop=function(fe){nt=fe},this.dispose=function(){}}},mC=new ht,rx=new ut;rx.set(-1,0,0,0,1,0,0,0,1);_C=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]),_s=null;wu=class{constructor(e={}){let{canvas:t=S_(),context:n=null,depth:s=!0,stencil:r=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:l=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:d=!1,outputBufferType:p=oi}=e;this.isWebGLRenderer=!0;let b;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");b=n.getContextAttributes().alpha}else b=a;let v=p,_=new Set([Hh,zh,Bh]),g=new Set([oi,Zi,so,ro,Fh,kh]),E=new Uint32Array(4),L=new Int32Array(4),S=new j,M=null,A=null,I=[],y=[],C=null;this.domElement=t,this.debug={checkShaderErrors:!0,diagnostics:{keywords:!1},onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=Ji,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let k=this,z=!1,$=null,K=null,P=null,N=null;this._outputColorSpace=Jt;let O=0,F=0,H=null,V=-1,Q=null,te=new Gt,Se=new Gt,ve=null,nt=new He(0),je=0,Qe=t.width,fe=t.height,ge=1,Ve=null,it=null,Ue=new Gt(0,0,Qe,fe),ct=new Gt(0,0,Qe,fe),zt=!1,ot=new Ja,mt=!1,Lt=!1,ft=new ht,xt=new j,Wt=new Gt,_n={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},Ht=!1;function Kt(){return H===null?ge:1}let q=n;function hn(D,W){return t.getContext(D,W)}let Et,U,w,ee,re,ce,Ee,Ce,de,xe,Pe,qe,Ae,Le,Fe,Je,at,G,Ie,be,Re,Be,ye;try{let D={alpha:!0,depth:s,stencil:r,antialias:o,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:h,failIfMajorPerformanceCaveat:u};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${"186"}`),t.addEventListener("webglcontextlost",Ut,!1),t.addEventListener("webglcontextrestored",Pt,!1),t.addEventListener("webglcontextcreationerror",zn,!1),q===null){let W="webgl2";if(q=hn(W,D),q===null)throw hn(W)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}et()}catch(D){throw t.removeEventListener("webglcontextlost",Ut,!1),t.removeEventListener("webglcontextrestored",Pt,!1),t.removeEventListener("webglcontextcreationerror",zn,!1),st("WebGLRenderer: "+D.message),D}function et(){Et=new AT(q),Et.init(),Re=new fC(q,Et),U=new gT(q,Et,e,Re),w=new hC(q,Et),U.reversedDepthBuffer&&d&&w.buffers.depth.setReversed(!0),K=q.createFramebuffer(),P=q.createFramebuffer(),N=q.createFramebuffer(),ee=new CT(q),re=new YR,ce=new uC(q,Et,w,re,U,Re,ee),Ee=new ET(k),Ce=new PM(q),Be=new pT(q,Ce),de=new TT(q,Ce,ee,Be),xe=new PT(q,de,Ce,Be,ee),G=new IT(q,U,ce),Fe=new bT(re),Pe=new KR(k,Ee,Et,U,Be,Fe),qe=new gC(k,re),Ae=new ZR,Le=new sC(Et),at=new dT(k,Ee,w,xe,b,c),Je=new lC(k,xe,U),ye=new bC(q,ee,U,w),Ie=new mT(q,Et,ee),be=new RT(q,Et,ee),ee.programs=Pe.programs,k.capabilities=U,k.extensions=Et,k.properties=re,k.renderLists=Ae,k.shadowMap=Je,k.state=w,k.info=ee}v!==oi&&(C=new DT(v,t.width,t.height,o,s,r));let Ye=new Vp(k,q);this.xr=Ye,this.getContext=function(){return q},this.getContextAttributes=function(){return q.getContextAttributes()},this.forceContextLoss=function(){let D=Et.get("WEBGL_lose_context");D&&D.loseContext()},this.forceContextRestore=function(){let D=Et.get("WEBGL_lose_context");D&&D.restoreContext()},this.getPixelRatio=function(){return ge},this.setPixelRatio=function(D){D!==void 0&&(ge=D,this.setSize(Qe,fe,!1))},this.getSize=function(D){return D.set(Qe,fe)},this.setSize=function(D,W,oe=!0){if(Ye.isPresenting){tt("WebGLRenderer: Can't change size while VR device is presenting.");return}Qe=D,fe=W,t.width=Math.floor(D*ge),t.height=Math.floor(W*ge),oe===!0&&(t.style.width=D+"px",t.style.height=W+"px"),C!==null&&C.setSize(t.width,t.height),this.setViewport(0,0,D,W)},this.getDrawingBufferSize=function(D){return D.set(Qe*ge,fe*ge).floor()},this.setDrawingBufferSize=function(D,W,oe){Qe=D,fe=W,ge=oe,t.width=Math.floor(D*oe),t.height=Math.floor(W*oe),this.setViewport(0,0,D,W)},this.setEffects=function(D){if(v===oi){st("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(D){for(let W=0;W<D.length;W++)if(D[W].isOutputPass===!0){tt("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}C.setEffects(D||[])},this.getCurrentViewport=function(D){return D.copy(te)},this.getViewport=function(D){return D.copy(Ue)},this.setViewport=function(D,W,oe,ne){D.isVector4?Ue.set(D.x,D.y,D.z,D.w):Ue.set(D,W,oe,ne),w.viewport(te.copy(Ue).multiplyScalar(ge).round())},this.getScissor=function(D){return D.copy(ct)},this.setScissor=function(D,W,oe,ne){D.isVector4?ct.set(D.x,D.y,D.z,D.w):ct.set(D,W,oe,ne),w.scissor(Se.copy(ct).multiplyScalar(ge).round())},this.getScissorTest=function(){return zt},this.setScissorTest=function(D){w.setScissorTest(zt=D)},this.setOpaqueSort=function(D){Ve=D},this.setTransparentSort=function(D){it=D},this.getClearColor=function(D){return D.copy(at.getClearColor())},this.setClearColor=function(){at.setClearColor(...arguments)},this.getClearAlpha=function(){return at.getClearAlpha()},this.setClearAlpha=function(){at.setClearAlpha(...arguments)},this.clear=function(D=!0,W=!0,oe=!0){let ne=0;if(D){let ie=!1;if(H!==null){let Ne=H.texture.format;ie=_.has(Ne)}if(ie){let Ne=H.texture.type,We=g.has(Ne),we=at.getClearColor(),Ge=at.getClearAlpha(),Ze=we.r,lt=we.g,bt=we.b;We?(E[0]=Ze,E[1]=lt,E[2]=bt,E[3]=Ge,q.clearBufferuiv(q.COLOR,0,E)):(L[0]=Ze,L[1]=lt,L[2]=bt,L[3]=Ge,q.clearBufferiv(q.COLOR,0,L))}else ne|=q.COLOR_BUFFER_BIT}W&&(ne|=q.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),oe&&(ne|=q.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),ne!==0&&q.clear(ne)},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.setNodesHandler=function(D){D.setRenderer(this),$=D},this.dispose=function(){t.removeEventListener("webglcontextlost",Ut,!1),t.removeEventListener("webglcontextrestored",Pt,!1),t.removeEventListener("webglcontextcreationerror",zn,!1),at.dispose(),Ae.dispose(),Le.dispose(),re.dispose(),Ee.dispose(),xe.dispose(),Be.dispose(),ye.dispose(),Pe.dispose(),Ye.dispose(),Ye.removeEventListener("sessionstart",Al),Ye.removeEventListener("sessionend",ni),ls.stop()};function Ut(D){D.preventDefault(),Xo("WebGLRenderer: Context Lost."),z=!0}function Pt(){Xo("WebGLRenderer: Context Restored."),z=!1;let D=ee.autoReset,W=Je.enabled,oe=Je.autoUpdate,ne=Je.needsUpdate,ie=Je.type;et(),ee.autoReset=D,Je.enabled=W,Je.autoUpdate=oe,Je.needsUpdate=ne,Je.type=ie}function zn(D){st("WebGLRenderer: A WebGL context could not be created. Reason: ",D.statusMessage)}function Ai(D){let W=D.target;W.removeEventListener("dispose",Ai),Ml(W)}function Ml(D){ud(D),re.remove(D)}function ud(D){let W=re.get(D).programs;W!==void 0&&(W.forEach(function(oe){Pe.releaseProgram(oe)}),D.isShaderMaterial&&Pe.releaseShaderCache(D))}this.renderBufferDirect=function(D,W,oe,ne,ie,Ne){W===null&&(W=_n);let We=ie.isMesh&&ie.matrixWorld.determinantAffine()<0,we=fd(D,W,oe,ne,ie);w.setMaterial(ne,We);let Ge=oe.index,Ze=1;if(ne.wireframe===!0){if(Ge=de.getWireframeAttribute(oe),Ge===void 0)return;Ze=2}let lt=oe.drawRange,bt=oe.attributes.position,Ke=lt.start*Ze,Dt=(lt.start+lt.count)*Ze;Ne!==null&&(Ke=Math.max(Ke,Ne.start*Ze),Dt=Math.min(Dt,(Ne.start+Ne.count)*Ze)),Ge!==null?(Ke=Math.max(Ke,0),Dt=Math.min(Dt,Ge.count)):bt!=null&&(Ke=Math.max(Ke,0),Dt=Math.min(Dt,bt.count));let Zt=Dt-Ke;if(Zt<0||Zt===1/0)return;Be.setup(ie,ne,we,oe,Ge);let Nt,Ct=Ie;if(Ge!==null&&(Nt=Ce.get(Ge),Ct=be,Ct.setIndex(Nt)),ie.isMesh)ne.wireframe===!0?(w.setLineWidth(ne.wireframeLinewidth*Kt()),Ct.setMode(q.LINES)):Ct.setMode(q.TRIANGLES);else if(ie.isLine){let tn=ne.linewidth;tn===void 0&&(tn=1),w.setLineWidth(tn*Kt()),ie.isLineSegments?Ct.setMode(q.LINES):ie.isLineLoop?Ct.setMode(q.LINE_LOOP):Ct.setMode(q.LINE_STRIP)}else ie.isPoints?Ct.setMode(q.POINTS):ie.isSprite&&Ct.setMode(q.TRIANGLES);if(ie.isBatchedMesh)if(Et.get("WEBGL_multi_draw"))Ct.renderMultiDraw(ie._multiDrawStarts,ie._multiDrawCounts,ie._multiDrawCount);else{let tn=ie._multiDrawStarts,$e=ie._multiDrawCounts,Ln=ie._multiDrawCount,At=Ge?Ce.get(Ge).bytesPerElement:1,nn=re.get(ne).currentProgram.getUniforms();for(let an=0;an<Ln;an++)nn.setValue(q,"_gl_DrawID",an),Ct.render(tn[an]/At,$e[an])}else if(ie.isInstancedMesh)Ct.renderInstances(Ke,Zt,ie.count);else if(oe.isInstancedBufferGeometry){let tn=oe._maxInstanceCount!==void 0?oe._maxInstanceCount:1/0,$e=Math.min(oe.instanceCount,tn);Ct.renderInstances(Ke,Zt,$e)}else Ct.render(Ke,Zt)};function Fr(D,W,oe,ne){$!==null&&D.isNodeMaterial&&$.setObject(ne,D),mt===!0&&Fe.setState(D,oe,!1),D.transparent===!0&&D.side===$n&&D.forceSinglePass===!1?(D.side=Nn,D.needsUpdate=!0,Ur(D,W,ne),D.side=gs,D.needsUpdate=!0,Ur(D,W,ne),D.side=$n):Ur(D,W,ne)}this.compile=function(D,W,oe=null){oe===null&&(oe=D),$!==null&&$.renderStart(D,W,oe),A=Le.get(oe),A.init(W),y.push(A),oe.traverseVisible(function(ie){ie.isLight&&ie.layers.test(W.layers)&&(A.pushLight(ie),ie.castShadow&&A.pushShadow(ie))}),D!==oe&&D.traverseVisible(function(ie){ie.isLight&&ie.layers.test(W.layers)&&(A.pushLight(ie),ie.castShadow&&A.pushShadow(ie))}),A.setupLights(),$!==null&&$.updateLights(A.state.lightsArray),Lt=this.localClippingEnabled,mt=Fe.init(this.clippingPlanes,Lt),mt===!0&&Fe.setGlobalState(this.clippingPlanes,W),$!==null&&Je.render(A.state.shadowsArray,oe,W);let ne=new Set;return D.traverse(function(ie){if(!(ie.isMesh||ie.isPoints||ie.isLine||ie.isSprite))return;let Ne=ie.material;if(Ne)if(Array.isArray(Ne))for(let We=0;We<Ne.length;We++){let we=Ne[We];Fr(we,oe,W,ie),ne.add(we)}else Fr(Ne,oe,W,ie),ne.add(Ne)}),A=y.pop(),$!==null&&$.renderEnd(),ne},this.compileAsync=function(D,W,oe=null){let ne=this.compile(D,W,oe);return new Promise(ie=>{function Ne(){if(ne.forEach(function(We){let Ge=re.get(We).currentProgram;(Ge===void 0||Ge.isReady())&&ne.delete(We)}),ne.size===0){ie(D);return}setTimeout(Ne,10)}Et.get("KHR_parallel_shader_compile")!==null?Ne():setTimeout(Ne,10)})};let Ma=null;function El(D){Ma&&Ma(D)}function Al(){ls.stop()}function ni(){ls.start()}let ls=new Q_;ls.setAnimationLoop(El),typeof self<"u"&&ls.setContext(self),this.setAnimationLoop=function(D){Ma=D,Ye.setAnimationLoop(D),D===null?ls.stop():ls.start()},Ye.addEventListener("sessionstart",Al),Ye.addEventListener("sessionend",ni),this.render=function(D,W){if(W!==void 0&&W.isCamera!==!0){st("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(z===!0)return;$!==null&&$.renderStart(D,W);let oe=Ye.enabled===!0&&Ye.isPresenting===!0,ne=C!==null&&(H===null||oe)&&C.begin(k,H);if(D.matrixWorldAutoUpdate===!0&&D.updateMatrixWorld(),W.parent===null&&W.matrixWorldAutoUpdate===!0&&W.updateMatrixWorld(),Ye.enabled===!0&&Ye.isPresenting===!0&&(C===null||C.isCompositing()===!1)&&(Ye.cameraAutoUpdate===!0&&Ye.updateCamera(W),W=Ye.getCamera()),D.isScene===!0&&D.onBeforeRender(k,D,W,H),A=Le.get(D,y.length),A.init(W),A.state.textureUnits=ce.getTextureUnits(),y.push(A),ft.multiplyMatrices(W.projectionMatrix,W.matrixWorldInverse),ot.setFromProjectionMatrix(ft,ji,W.reversedDepth),Lt=this.localClippingEnabled,mt=Fe.init(this.clippingPlanes,Lt),M=Ae.get(D,I.length),M.init(),I.push(M),Ye.enabled===!0&&Ye.isPresenting===!0){let We=k.xr.getDepthSensingMesh();We!==null&&Ea(We,W,-1/0,k.sortObjects)}Ea(D,W,0,k.sortObjects),M.finish(),$!==null&&$.updateLights(A.state.lightsArray),k.sortObjects===!0&&M.sort(Ve,it),Ht=Ye.enabled===!1||Ye.isPresenting===!1||Ye.hasDepthSensing()===!1,Ht&&at.addToRenderList(M,D),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),mt===!0&&Fe.beginShadows();let ie=A.state.shadowsArray;if(Je.render(ie,D,W),mt===!0&&Fe.endShadows(),(ne&&C.hasRenderPass())===!1){let We=M.opaque,we=M.transmissive;if(A.setupLights(),W.isArrayCamera){let Ge=W.cameras;if(we.length>0)for(let Ze=0,lt=Ge.length;Ze<lt;Ze++){let bt=Ge[Ze];Lo(We,we,D,bt)}Ht&&at.render(D);for(let Ze=0,lt=Ge.length;Ze<lt;Ze++){let bt=Ge[Ze];Ti(M,D,bt,bt.viewport)}}else we.length>0&&Lo(We,we,D,W),Ht&&at.render(D),Ti(M,D,W)}H!==null&&F===0&&(ce.updateMultisampleRenderTarget(H),ce.updateRenderTargetMipmap(H)),ne&&C.end(k),D.isScene===!0&&D.onAfterRender(k,D,W),Be.resetDefaultState(),V=-1,Q=null,y.pop(),y.length>0?(A=y[y.length-1],ce.setTextureUnits(A.state.textureUnits),mt===!0&&Fe.setGlobalState(k.clippingPlanes,A.state.camera)):A=null,I.pop(),I.length>0?M=I[I.length-1]:M=null,$!==null&&$.renderEnd()};function Ea(D,W,oe,ne){if(D.visible===!1)return;if(D.layers.test(W.layers)){if(D.isGroup)oe=D.renderOrder;else if(D.isLOD)D.autoUpdate===!0&&D.update(W);else if(D.isLightProbeGrid)A.pushLightProbeGrid(D);else if(D.isLight)A.pushLight(D),D.castShadow&&A.pushShadow(D);else if(D.isSprite){if(!D.frustumCulled||D.intersectsFrustum(ot)){ne&&Wt.setFromMatrixPosition(D.matrixWorld).applyMatrix4(ft);let We=xe.update(D),we=D.material;we.visible&&M.push(D,We,we,oe,Wt.z,null,W)}}else if((D.isMesh||D.isLine||D.isPoints)&&(!D.frustumCulled||D.intersectsFrustum(ot))){let We=xe.update(D),we=D.material;if(ne&&(D.boundingSphere!==void 0?(D.boundingSphere===null&&D.computeBoundingSphere(),Wt.copy(D.boundingSphere.center)):(We.boundingSphere===null&&We.computeBoundingSphere(),Wt.copy(We.boundingSphere.center)),Wt.applyMatrix4(D.matrixWorld).applyMatrix4(ft)),Array.isArray(we)){let Ge=We.groups;for(let Ze=0,lt=Ge.length;Ze<lt;Ze++){let bt=Ge[Ze],Ke=we[bt.materialIndex];Ke&&Ke.visible&&M.push(D,We,Ke,oe,Wt.z,bt,W)}}else we.visible&&M.push(D,We,we,oe,Wt.z,null,W)}}let Ne=D.children;for(let We=0,we=Ne.length;We<we;We++)Ea(Ne[We],W,oe,ne)}function Ti(D,W,oe,ne){let{opaque:ie,transmissive:Ne,transparent:We}=D;A.setupLightsView(oe),mt===!0&&Fe.setGlobalState(k.clippingPlanes,oe),ne&&w.viewport(te.copy(ne)),ie.length>0&&kr(ie,W,oe),Ne.length>0&&kr(Ne,W,oe),We.length>0&&kr(We,W,oe),w.buffers.depth.setTest(!0),w.buffers.depth.setMask(!0),w.buffers.color.setMask(!0),w.setPolygonOffset(!1)}function Lo(D,W,oe,ne){if((oe.isScene===!0?oe.overrideMaterial:null)!==null)return;if(A.state.transmissionRenderTarget[ne.id]===void 0){let Ke=Et.has("EXT_color_buffer_half_float")||Et.has("EXT_color_buffer_float");A.state.transmissionRenderTarget[ne.id]=new Gn(1,1,{generateMipmaps:!0,type:Ke?Zn:oi,minFilter:Di,samples:Math.max(4,U.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,colorSpace:gt.workingColorSpace})}let Ne=A.state.transmissionRenderTarget[ne.id],We=ne.viewport||te;Ne.setSize(We.z*k.transmissionResolutionScale,We.w*k.transmissionResolutionScale);let we=k.getRenderTarget(),Ge=k.getActiveCubeFace(),Ze=k.getActiveMipmapLevel();k.setRenderTarget(Ne),k.getClearColor(nt),je=k.getClearAlpha(),je<1&&k.setClearColor(16777215,.5),k.clear(),Ht&&at.render(oe);let lt=k.toneMapping;k.toneMapping=Ji;let bt=ne.viewport;if(ne.viewport!==void 0&&(ne.viewport=void 0),A.setupLightsView(ne),mt===!0&&Fe.setGlobalState(k.clippingPlanes,ne),kr(D,oe,ne),ce.updateMultisampleRenderTarget(Ne),ce.updateRenderTargetMipmap(Ne),Et.has("WEBGL_multisampled_render_to_texture")===!1){let Ke=!1;for(let Dt=0,Zt=W.length;Dt<Zt;Dt++){let Nt=W[Dt],{object:Ct,geometry:tn,material:$e,group:Ln}=Nt;if($e.side===$n&&Ct.layers.test(ne.layers)){let At=$e.side;$e.side=Nn,$e.needsUpdate=!0,Cs(Ct,oe,ne,tn,$e,Ln),$e.side=At,$e.needsUpdate=!0,Ke=!0}}Ke===!0&&(ce.updateMultisampleRenderTarget(Ne),ce.updateRenderTargetMipmap(Ne))}k.setRenderTarget(we,Ge,Ze),k.setClearColor(nt,je),bt!==void 0&&(ne.viewport=bt),k.toneMapping=lt}function kr(D,W,oe){let ne=W.isScene===!0?W.overrideMaterial:null;for(let ie=0,Ne=D.length;ie<Ne;ie++){let We=D[ie],{object:we,geometry:Ge,group:Ze}=We,lt=We.material;lt.allowOverride===!0&&ne!==null&&(lt=ne),we.layers.test(oe.layers)&&Cs(we,W,oe,Ge,lt,Ze)}}function Cs(D,W,oe,ne,ie,Ne){$!==null&&ie.isNodeMaterial&&$.setObject(D,ie),D.onBeforeRender(k,W,oe,ne,ie,Ne),D.modelViewMatrix.multiplyMatrices(oe.matrixWorldInverse,D.matrixWorld),D.normalMatrix.getNormalMatrix(D.modelViewMatrix),ie.onBeforeRender(k,W,oe,ne,D,Ne),ie.transparent===!0&&ie.side===$n&&ie.forceSinglePass===!1?(ie.side=Nn,ie.needsUpdate=!0,k.renderBufferDirect(oe,W,ne,ie,D,Ne),ie.side=gs,ie.needsUpdate=!0,k.renderBufferDirect(oe,W,ne,ie,D,Ne),ie.side=$n):k.renderBufferDirect(oe,W,ne,ie,D,Ne),D.onAfterRender(k,W,oe,ne,ie,Ne)}function Ur(D,W,oe){W.isScene!==!0&&(W=_n);let ne=re.get(D),ie=A.state.lights,Ne=A.state.shadowsArray,We=ie.state.version,we=Pe.getParameters(D,ie.state,Ne,W,oe,A.state.lightProbeGridArray),Ge=Pe.getProgramCacheKey(we),Ze=ne.programs;ne.environment=D.isMeshStandardMaterial||D.isMeshLambertMaterial||D.isMeshPhongMaterial?W.environment:null,ne.fog=W.fog;let lt=D.isMeshStandardMaterial||D.isMeshLambertMaterial&&!D.envMap||D.isMeshPhongMaterial&&!D.envMap;ne.envMap=Ee.get(D.envMap||ne.environment,lt),ne.envMapRotation=ne.environment!==null&&D.envMap===null?W.environmentRotation:D.envMapRotation,Ze===void 0&&(D.addEventListener("dispose",Ai),Ze=new Map,ne.programs=Ze);let bt=Ze.get(Ge);if(bt!==void 0){if(ne.currentProgram===bt&&ne.lightsStateVersion===We)return Is(D,we),bt}else we.uniforms=Pe.getUniforms(D),$!==null&&D.isNodeMaterial&&$.build(D,oe,we),D.onBeforeCompile(we,k),bt=Pe.acquireProgram(we,Ge),Ze.set(Ge,bt),ne.uniforms=we.uniforms;let Ke=ne.uniforms;return(!D.isShaderMaterial&&!D.isRawShaderMaterial||D.clipping===!0)&&(Ke.clippingPlanes=Fe.uniform),Is(D,we),ne.needsLights=ui(D),ne.lightsStateVersion=We,ne.needsLights&&(Ke.ambientLightColor.value=ie.state.ambient,Ke.lightProbe.value=ie.state.probe,Ke.sunLights.value=ie.state.sun,Ke.sunLightShadows.value=ie.state.sunShadow,Ke.directionalLights.value=ie.state.directional,Ke.directionalLightShadows.value=ie.state.directionalShadow,Ke.spotLights.value=ie.state.spot,Ke.spotLightShadows.value=ie.state.spotShadow,Ke.rectAreaLights.value=ie.state.rectArea,Ke.ltc_1.value=ie.state.rectAreaLTC1,Ke.ltc_2.value=ie.state.rectAreaLTC2,Ke.pointLights.value=ie.state.point,Ke.pointLightShadows.value=ie.state.pointShadow,Ke.hemisphereLights.value=ie.state.hemi,Ke.sunShadowMatrix.value=ie.state.sunShadowMatrix,Ke.sunShadowCascade.value=ie.state.sunShadowCascade,Ke.directionalShadowMatrix.value=ie.state.directionalShadowMatrix,Ke.spotLightMatrix.value=ie.state.spotLightMatrix,Ke.spotLightMap.value=ie.state.spotLightMap,Ke.pointShadowMatrix.value=ie.state.pointShadowMatrix),ne.lightProbeGrid=A.state.lightProbeGridArray.length>0,ne.currentProgram=bt,ne.uniformsList=null,bt}function Do(D){if(D.uniformsList===null){let W=D.currentProgram.getUniforms();D.uniformsList=ho.seqWithValue(W.seq,D.uniforms)}return D.uniformsList}function Is(D,W){let oe=re.get(D);oe.outputColorSpace=W.outputColorSpace,oe.batching=W.batching,oe.batchingColor=W.batchingColor,oe.instancing=W.instancing,oe.instancingColor=W.instancingColor,oe.instancingMorph=W.instancingMorph,oe.skinning=W.skinning,oe.morphTargets=W.morphTargets,oe.morphNormals=W.morphNormals,oe.morphColors=W.morphColors,oe.morphTargetsCount=W.morphTargetsCount,oe.numClippingPlanes=W.numClippingPlanes,oe.numIntersection=W.numClipIntersection,oe.vertexAlphas=W.vertexAlphas,oe.vertexTangents=W.vertexTangents,oe.toneMapping=W.toneMapping}function zi(D,W){if(D.length===0)return null;if(D.length===1)return D[0].texture!==null?D[0]:null;S.setFromMatrixPosition(W.matrixWorld);for(let oe=0,ne=D.length;oe<ne;oe++){let ie=D[oe];if(ie.texture!==null&&ie.boundingBox.containsPoint(S))return ie}return null}function fd(D,W,oe,ne,ie){W.isScene!==!0&&(W=_n),ce.resetTextureUnits();let Ne=W.fog,We=ne.isMeshStandardMaterial||ne.isMeshLambertMaterial||ne.isMeshPhongMaterial?W.environment:null,we=H===null?k.outputColorSpace:H.isXRRenderTarget===!0?H.texture.colorSpace:gt.workingColorSpace,Ge=ne.isMeshStandardMaterial||ne.isMeshLambertMaterial&&!ne.envMap||ne.isMeshPhongMaterial&&!ne.envMap,Ze=Ee.get(ne.envMap||We,Ge),lt=ne.vertexColors===!0&&!!oe.attributes.color&&oe.attributes.color.itemSize===4,bt=!!oe.attributes.tangent&&(!!ne.normalMap||ne.anisotropy>0),Ke=!!oe.morphAttributes.position,Dt=!!oe.morphAttributes.normal,Zt=!!oe.morphAttributes.color,Nt=Ji;ne.toneMapped&&(H===null||H.isXRRenderTarget===!0)&&(Nt=k.toneMapping);let Ct=oe.morphAttributes.position||oe.morphAttributes.normal||oe.morphAttributes.color,tn=Ct!==void 0?Ct.length:0,$e=re.get(ne),Ln=A.state.lights;if(mt===!0&&(Lt===!0||D!==Q)){let R=D===Q&&ne.id===V;Fe.setState(ne,D,R)}let At=!1;ne.version===$e.__version?($e.needsLights&&$e.lightsStateVersion!==Ln.state.version||$e.outputColorSpace!==we||ie.isBatchedMesh&&$e.batching===!1||!ie.isBatchedMesh&&$e.batching===!0||ie.isBatchedMesh&&$e.batchingColor===!0&&ie._colorsTexture===null||ie.isBatchedMesh&&$e.batchingColor===!1&&ie._colorsTexture!==null||ie.isInstancedMesh&&$e.instancing===!1||!ie.isInstancedMesh&&$e.instancing===!0||ie.isSkinnedMesh&&$e.skinning===!1||!ie.isSkinnedMesh&&$e.skinning===!0||ie.isInstancedMesh&&$e.instancingColor===!0&&ie.instanceColor===null||ie.isInstancedMesh&&$e.instancingColor===!1&&ie.instanceColor!==null||ie.isInstancedMesh&&$e.instancingMorph===!0&&ie.morphTexture===null||ie.isInstancedMesh&&$e.instancingMorph===!1&&ie.morphTexture!==null||$e.envMap!==Ze||ne.fog===!0&&$e.fog!==Ne||$e.numClippingPlanes!==void 0&&($e.numClippingPlanes!==Fe.numPlanes||$e.numIntersection!==Fe.numIntersection)||$e.vertexAlphas!==lt||$e.vertexTangents!==bt||$e.morphTargets!==Ke||$e.morphNormals!==Dt||$e.morphColors!==Zt||$e.toneMapping!==Nt||$e.morphTargetsCount!==tn||!!$e.lightProbeGrid!=A.state.lightProbeGridArray.length>0)&&(At=!0):(At=!0,$e.__version=ne.version);let nn=$e.currentProgram;At===!0&&(nn=Ur(ne,W,ie),$&&ne.isNodeMaterial&&$.onUpdateProgram(ne,nn,$e));let an=!1,Dn=!1,fi=!1,Tt=nn.getUniforms(),$t=$e.uniforms;if(w.useProgram(nn.program)&&(an=!0,Dn=!0,fi=!0),ne.id!==V&&(V=ne.id,Dn=!0),$e.needsLights){let R=zi(A.state.lightProbeGridArray,ie);$e.lightProbeGrid!==R&&($e.lightProbeGrid=R,Dn=!0)}if(an||Q!==D){w.buffers.depth.getReversed()&&D.reversedDepth!==!0&&(D._reversedDepth=!0,D.updateProjectionMatrix()),Tt.setValue(q,"projectionMatrix",D.projectionMatrix),Tt.setValue(q,"viewMatrix",D.matrixWorldInverse);let f=Tt.map.cameraPosition;f!==void 0&&f.setValue(q,xt.setFromMatrixPosition(D.matrixWorld)),U.logarithmicDepthBuffer&&Tt.setValue(q,"logDepthBufFC",2/(Math.log(D.far+1)/Math.LN2)),(ne.isMeshPhongMaterial||ne.isMeshToonMaterial||ne.isMeshLambertMaterial||ne.isMeshBasicMaterial||ne.isMeshStandardMaterial||ne.isShaderMaterial)&&Tt.setValue(q,"isOrthographic",D.isOrthographicCamera===!0),Q!==D&&(Q=D,Dn=!0,fi=!0)}if($e.needsLights&&(Ln.state.sunShadowMap.length>0&&Tt.setValue(q,"sunShadowMap",Ln.state.sunShadowMap,ce),Ln.state.directionalShadowMap.length>0&&Tt.setValue(q,"directionalShadowMap",Ln.state.directionalShadowMap,ce),Ln.state.spotShadowMap.length>0&&Tt.setValue(q,"spotShadowMap",Ln.state.spotShadowMap,ce),Ln.state.pointShadowMap.length>0&&Tt.setValue(q,"pointShadowMap",Ln.state.pointShadowMap,ce)),ie.isSkinnedMesh){Tt.setOptional(q,ie,"bindMatrix"),Tt.setOptional(q,ie,"bindMatrixInverse");let R=ie.skeleton;R&&(R.boneTexture===null&&R.computeBoneTexture(),Tt.setValue(q,"boneTexture",R.boneTexture,ce))}ie.isBatchedMesh&&(Tt.setOptional(q,ie,"batchingTexture"),Tt.setValue(q,"batchingTexture",ie._matricesTexture,ce),Tt.setOptional(q,ie,"batchingIdTexture"),Tt.setValue(q,"batchingIdTexture",ie._indirectTexture,ce),Tt.setOptional(q,ie,"batchingColorTexture"),ie._colorsTexture!==null&&Tt.setValue(q,"batchingColorTexture",ie._colorsTexture,ce));let di=oe.morphAttributes;if((di.position!==void 0||di.normal!==void 0||di.color!==void 0)&&G.update(ie,oe,nn),(Dn||$e.receiveShadow!==ie.receiveShadow)&&($e.receiveShadow=ie.receiveShadow,Tt.setValue(q,"receiveShadow",ie.receiveShadow)),(ne.isMeshStandardMaterial||ne.isMeshLambertMaterial||ne.isMeshPhongMaterial)&&ne.envMap===null&&W.environment!==null&&($t.envMapIntensity.value=W.environmentIntensity),$t.dfgLUT!==void 0&&($t.dfgLUT.value=xC()),Dn){if(Tt.setValue(q,"toneMappingExposure",k.toneMappingExposure),$e.needsLights&&Tl($t,fi),Ne&&ne.fog===!0&&qe.refreshFogUniforms($t,Ne),qe.refreshMaterialUniforms($t,ne,ge,fe,A.state.transmissionRenderTarget[D.id]),$e.needsLights&&$e.lightProbeGrid){let R=$e.lightProbeGrid;$t.probesSH.value=R.texture,$t.probesMin.value.copy(R.boundingBox.min),$t.probesMax.value.copy(R.boundingBox.max),$t.probesResolution.value.copy(R.resolution)}ho.upload(q,Do($e),$t,ce)}if(ne.isShaderMaterial&&ne.uniformsNeedUpdate===!0&&(ho.upload(q,Do($e),$t,ce),ne.uniformsNeedUpdate=!1),ne.isSpriteMaterial&&Tt.setValue(q,"center",ie.center),Tt.setValue(q,"modelViewMatrix",ie.modelViewMatrix),Tt.setValue(q,"normalMatrix",ie.normalMatrix),Tt.setValue(q,"modelMatrix",ie.matrixWorld),ne.uniformsGroups!==void 0){let R=ne.uniformsGroups;for(let f=0,m=R.length;f<m;f++){let x=R[f];ye.update(x,nn),ye.bind(x,nn)}}return nn}function Tl(D,W){D.ambientLightColor.needsUpdate=W,D.lightProbe.needsUpdate=W,D.sunLights.needsUpdate=W,D.sunLightShadows.needsUpdate=W,D.directionalLights.needsUpdate=W,D.directionalLightShadows.needsUpdate=W,D.pointLights.needsUpdate=W,D.pointLightShadows.needsUpdate=W,D.spotLights.needsUpdate=W,D.spotLightShadows.needsUpdate=W,D.rectAreaLights.needsUpdate=W,D.hemisphereLights.needsUpdate=W}function ui(D){return D.isMeshLambertMaterial||D.isMeshToonMaterial||D.isMeshPhongMaterial||D.isMeshStandardMaterial||D.isShadowMaterial||D.isShaderMaterial&&D.lights===!0}this.getActiveCubeFace=function(){return O},this.getActiveMipmapLevel=function(){return F},this.getRenderTarget=function(){return H},this.setRenderTargetTextures=function(D,W,oe){let ne=re.get(D);ne.__autoAllocateDepthBuffer=D.resolveDepthBuffer===!1,ne.__autoAllocateDepthBuffer===!1&&(ne.__useRenderToTexture=!1),re.get(D.texture).__webglTexture=W,re.get(D.depthTexture).__webglTexture=ne.__autoAllocateDepthBuffer?void 0:oe,ne.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(D,W){let oe=re.get(D);oe.__webglFramebuffer=W,oe.__useDefaultFramebuffer=W===void 0},this.setRenderTarget=function(D,W=0,oe=0){H=D,O=W,F=oe;let ne=null,ie=!1,Ne=!1;if(D){let we=re.get(D);if(we.__useDefaultFramebuffer!==void 0){w.bindFramebuffer(q.FRAMEBUFFER,we.__webglFramebuffer),te.copy(D.viewport),Se.copy(D.scissor),ve=D.scissorTest,w.viewport(te),w.scissor(Se),w.setScissorTest(ve),V=-1;return}else if(we.__webglFramebuffer===void 0)ce.setupRenderTarget(D);else if(we.__hasExternalTextures)ce.rebindTextures(D,re.get(D.texture).__webglTexture,re.get(D.depthTexture).__webglTexture);else if(D.depthBuffer){let lt=D.depthTexture;if(we.__boundDepthTexture!==lt){if(lt!==null&&re.has(lt)&&(D.width!==lt.image.width||D.height!==lt.image.height))throw new Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");ce.setupDepthRenderbuffer(D)}}let Ge=D.texture;(Ge.isData3DTexture||Ge.isDataArrayTexture||Ge.isCompressedArrayTexture)&&(Ne=!0);let Ze=re.get(D).__webglFramebuffer;D.isWebGLCubeRenderTarget?(Array.isArray(Ze[W])?ne=Ze[W][oe]:ne=Ze[W],ie=!0):D.samples>0&&ce.useMultisampledRTT(D)===!1?ne=re.get(D).__webglMultisampledFramebuffer:Array.isArray(Ze)?ne=Ze[oe]:ne=Ze,te.copy(D.viewport),Se.copy(D.scissor),ve=D.scissorTest}else te.copy(Ue).multiplyScalar(ge).floor(),Se.copy(ct).multiplyScalar(ge).floor(),ve=zt;if(oe!==0&&(ne=K),w.bindFramebuffer(q.FRAMEBUFFER,ne)&&w.drawBuffers(D,ne),w.viewport(te),w.scissor(Se),w.setScissorTest(ve),ie){let we=re.get(D.texture);q.framebufferTexture2D(q.FRAMEBUFFER,q.COLOR_ATTACHMENT0,q.TEXTURE_CUBE_MAP_POSITIVE_X+W,we.__webglTexture,oe)}else if(Ne){let we=W;for(let Ge=0;Ge<D.textures.length;Ge++){let Ze=re.get(D.textures[Ge]);q.framebufferTextureLayer(q.FRAMEBUFFER,q.COLOR_ATTACHMENT0+Ge,Ze.__webglTexture,oe,we)}}else if(D!==null&&oe!==0){let we=re.get(D.texture);q.framebufferTexture2D(q.FRAMEBUFFER,q.COLOR_ATTACHMENT0,q.TEXTURE_2D,we.__webglTexture,oe)}V=-1};function No(D){let W=re.get(D);return(W.__readFormat!==D.format||W.__readType!==D.type)&&(W.__readFormat=D.format,W.__readType=D.type,W.__formatReadable=U.textureFormatReadable(D.format),W.__typeReadable=U.textureTypeReadable(D.type)),W}this.readRenderTargetPixels=function(D,W,oe,ne,ie,Ne,We,we=0){if(!(D&&D.isWebGLRenderTarget)){st("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Ge=re.get(D).__webglFramebuffer;if(D.isWebGLCubeRenderTarget&&We!==void 0&&(Ge=Ge[We]),Ge){w.bindFramebuffer(q.FRAMEBUFFER,Ge);try{let Ze=D.textures[we],lt=Ze.format,bt=Ze.type;D.textures.length>1&&q.readBuffer(q.COLOR_ATTACHMENT0+we);let Ke=No(Ze);if(Ke.__formatReadable===!1){st("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(Ke.__typeReadable===!1){st("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}W>=0&&W<=D.width-ne&&oe>=0&&oe<=D.height-ie&&q.readPixels(W,oe,ne,ie,Re.convert(lt),Re.convert(bt),Ne)}finally{let Ze=H!==null?re.get(H).__webglFramebuffer:null;w.bindFramebuffer(q.FRAMEBUFFER,Ze)}}},this.readRenderTargetPixelsAsync=async function(D,W,oe,ne,ie,Ne,We,we=0){if(!(D&&D.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Ge=re.get(D).__webglFramebuffer;if(D.isWebGLCubeRenderTarget&&We!==void 0&&(Ge=Ge[We]),Ge)if(W>=0&&W<=D.width-ne&&oe>=0&&oe<=D.height-ie){w.bindFramebuffer(q.FRAMEBUFFER,Ge);let Ze=D.textures[we],lt=Ze.format,bt=Ze.type;D.textures.length>1&&q.readBuffer(q.COLOR_ATTACHMENT0+we);let Ke=No(Ze);if(Ke.__formatReadable===!1)throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(Ke.__typeReadable===!1)throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let Dt=q.createBuffer();q.bindBuffer(q.PIXEL_PACK_BUFFER,Dt),q.bufferData(q.PIXEL_PACK_BUFFER,Ne.byteLength,q.STREAM_READ),q.readPixels(W,oe,ne,ie,Re.convert(lt),Re.convert(bt),0),q.bindBuffer(q.PIXEL_PACK_BUFFER,null);let Zt=H!==null?re.get(H).__webglFramebuffer:null;w.bindFramebuffer(q.FRAMEBUFFER,Zt);let Nt=q.fenceSync(q.SYNC_GPU_COMMANDS_COMPLETE,0);return q.flush(),await M_(q,Nt,4),q.bindBuffer(q.PIXEL_PACK_BUFFER,Dt),q.getBufferSubData(q.PIXEL_PACK_BUFFER,0,Ne),q.bindBuffer(q.PIXEL_PACK_BUFFER,null),q.deleteBuffer(Dt),q.deleteSync(Nt),Ne}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(D,W=null,oe=0){let ne=Math.pow(2,-oe),ie=Math.floor(D.image.width*ne),Ne=Math.floor(D.image.height*ne),We=W!==null?W.x:0,we=W!==null?W.y:0;ce.setTexture2D(D,0),q.copyTexSubImage2D(q.TEXTURE_2D,oe,0,0,We,we,ie,Ne),w.unbindTexture()},this.copyTextureToTexture=function(D,W,oe=null,ne=null,ie=0,Ne=0){let We,we,Ge,Ze,lt,bt,Ke,Dt,Zt,Nt=D.isCompressedTexture?D.mipmaps[Ne]:D.image;if(oe!==null)We=oe.max.x-oe.min.x,we=oe.max.y-oe.min.y,Ge=oe.isBox3?oe.max.z-oe.min.z:1,Ze=oe.min.x,lt=oe.min.y,bt=oe.isBox3?oe.min.z:0;else{let $t=Math.pow(2,-ie);We=Math.floor(Nt.width*$t),we=Math.floor(Nt.height*$t),D.isDataArrayTexture?Ge=Nt.depth:D.isData3DTexture?Ge=Math.floor(Nt.depth*$t):Ge=1,Ze=0,lt=0,bt=0}ne!==null?(Ke=ne.x,Dt=ne.y,Zt=ne.z):(Ke=0,Dt=0,Zt=0);let Ct=Re.convert(W.format),tn=Re.convert(W.type),$e;W.isData3DTexture?(ce.setTexture3D(W,0),$e=q.TEXTURE_3D):W.isDataArrayTexture||W.isCompressedArrayTexture?(ce.setTexture2DArray(W,0),$e=q.TEXTURE_2D_ARRAY):(ce.setTexture2D(W,0),$e=q.TEXTURE_2D),w.activeTexture(q.TEXTURE0),w.pixelStorei(q.UNPACK_FLIP_Y_WEBGL,W.flipY),w.pixelStorei(q.UNPACK_PREMULTIPLY_ALPHA_WEBGL,W.premultiplyAlpha),w.pixelStorei(q.UNPACK_ALIGNMENT,W.unpackAlignment);let Ln=w.getParameter(q.UNPACK_ROW_LENGTH),At=w.getParameter(q.UNPACK_IMAGE_HEIGHT),nn=w.getParameter(q.UNPACK_SKIP_PIXELS),an=w.getParameter(q.UNPACK_SKIP_ROWS),Dn=w.getParameter(q.UNPACK_SKIP_IMAGES);w.pixelStorei(q.UNPACK_ROW_LENGTH,Nt.width),w.pixelStorei(q.UNPACK_IMAGE_HEIGHT,Nt.height),w.pixelStorei(q.UNPACK_SKIP_PIXELS,Ze),w.pixelStorei(q.UNPACK_SKIP_ROWS,lt),w.pixelStorei(q.UNPACK_SKIP_IMAGES,bt);let fi=D.isDataArrayTexture||D.isData3DTexture,Tt=W.isDataArrayTexture||W.isData3DTexture;if(D.isDepthTexture){let $t=re.get(D),di=re.get(W),R=re.get($t.__renderTarget),f=re.get(di.__renderTarget);w.bindFramebuffer(q.READ_FRAMEBUFFER,R.__webglFramebuffer),w.bindFramebuffer(q.DRAW_FRAMEBUFFER,f.__webglFramebuffer);for(let m=0;m<Ge;m++)fi&&(q.framebufferTextureLayer(q.READ_FRAMEBUFFER,q.COLOR_ATTACHMENT0,re.get(D).__webglTexture,ie,bt+m),q.framebufferTextureLayer(q.DRAW_FRAMEBUFFER,q.COLOR_ATTACHMENT0,re.get(W).__webglTexture,Ne,Zt+m)),q.blitFramebuffer(Ze,lt,We,we,Ke,Dt,We,we,q.DEPTH_BUFFER_BIT,q.NEAREST);w.bindFramebuffer(q.READ_FRAMEBUFFER,null),w.bindFramebuffer(q.DRAW_FRAMEBUFFER,null)}else if(ie!==0||D.isRenderTargetTexture||re.has(D)){let $t=re.get(D),di=re.get(W);w.bindFramebuffer(q.READ_FRAMEBUFFER,P),w.bindFramebuffer(q.DRAW_FRAMEBUFFER,N);for(let R=0;R<Ge;R++)fi?q.framebufferTextureLayer(q.READ_FRAMEBUFFER,q.COLOR_ATTACHMENT0,$t.__webglTexture,ie,bt+R):q.framebufferTexture2D(q.READ_FRAMEBUFFER,q.COLOR_ATTACHMENT0,q.TEXTURE_2D,$t.__webglTexture,ie),Tt?q.framebufferTextureLayer(q.DRAW_FRAMEBUFFER,q.COLOR_ATTACHMENT0,di.__webglTexture,Ne,Zt+R):q.framebufferTexture2D(q.DRAW_FRAMEBUFFER,q.COLOR_ATTACHMENT0,q.TEXTURE_2D,di.__webglTexture,Ne),ie!==0?q.blitFramebuffer(Ze,lt,We,we,Ke,Dt,We,we,q.COLOR_BUFFER_BIT,q.NEAREST):Tt?q.copyTexSubImage3D($e,Ne,Ke,Dt,Zt+R,Ze,lt,We,we):q.copyTexSubImage2D($e,Ne,Ke,Dt,Ze,lt,We,we);w.bindFramebuffer(q.READ_FRAMEBUFFER,null),w.bindFramebuffer(q.DRAW_FRAMEBUFFER,null)}else Tt?D.isDataTexture||D.isData3DTexture?q.texSubImage3D($e,Ne,Ke,Dt,Zt,We,we,Ge,Ct,tn,Nt.data):W.isCompressedArrayTexture?q.compressedTexSubImage3D($e,Ne,Ke,Dt,Zt,We,we,Ge,Ct,Nt.data):q.texSubImage3D($e,Ne,Ke,Dt,Zt,We,we,Ge,Ct,tn,Nt):D.isDataTexture?q.texSubImage2D(q.TEXTURE_2D,Ne,Ke,Dt,We,we,Ct,tn,Nt.data):D.isCompressedTexture?q.compressedTexSubImage2D(q.TEXTURE_2D,Ne,Ke,Dt,Nt.width,Nt.height,Ct,Nt.data):q.texSubImage2D(q.TEXTURE_2D,Ne,Ke,Dt,We,we,Ct,tn,Nt);w.pixelStorei(q.UNPACK_ROW_LENGTH,Ln),w.pixelStorei(q.UNPACK_IMAGE_HEIGHT,At),w.pixelStorei(q.UNPACK_SKIP_PIXELS,nn),w.pixelStorei(q.UNPACK_SKIP_ROWS,an),w.pixelStorei(q.UNPACK_SKIP_IMAGES,Dn),Ne===0&&W.generateMipmaps&&q.generateMipmap($e),w.unbindTexture()},this.initRenderTarget=function(D){re.get(D).__webglFramebuffer===void 0&&ce.setupRenderTarget(D)},this.initTexture=function(D){D.isCubeTexture?ce.setTextureCube(D,0):D.isData3DTexture?ce.setTexture3D(D,0):D.isDataArrayTexture||D.isCompressedArrayTexture?ce.setTexture2DArray(D,0):ce.setTexture2D(D,0),w.unbindTexture()},this.resetState=function(){O=0,F=0,H=null,w.reset(),Be.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return ji}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=gt._getDrawingBufferColorSpace(e),t.unpackColorSpace=gt._getUnpackColorSpace()}}});function aa(i){let e=new Map,t=new Map,n=i.clone();return ax(i,n,function(s,r){e.set(r,s),t.set(s,r)}),n.traverse(function(s){if(!s.isSkinnedMesh)return;let r=s,a=e.get(s),o=a.skeleton.bones;r.skeleton=a.skeleton.clone(),r.bindMatrix.copy(a.bindMatrix),r.skeleton.bones=o.map(function(c){return t.get(c)}),r.bind(r.skeleton,r.bindMatrix)}),n}function ax(i,e,t){t(i,e);for(let n=0;n<i.children.length;n++)ax(i.children[n],e.children[n],t)}var Au=un(()=>{});var Sx={};er(Sx,{HDRLoader:()=>om});var om,wx=un(()=>{Qn();om=class extends fc{constructor(e){super(e),this.type=Zn}parse(e){let a=function(y,C){switch(y){case 1:throw new Error("THREE.HDRLoader: Read Error: "+(C||""));case 2:throw new Error("THREE.HDRLoader: Write Error: "+(C||""));case 3:throw new Error("THREE.HDRLoader: Bad File Format: "+(C||""));default:case 4:throw new Error("THREE.HDRLoader: Memory Error: "+(C||""))}},u=function(y,C,k){C=C||1024;let $=y.pos,K=-1,P=0,N="",O=String.fromCharCode.apply(null,new Uint16Array(y.subarray($,$+128)));for(;0>(K=O.indexOf(`
+`))&&P<C&&$<y.byteLength;)N+=O,P+=O.length,$+=128,O=String.fromCharCode.apply(null,new Uint16Array(y.subarray($,$+128)));return-1<K?(k!==!1&&(y.pos+=P+K+1),N+O.slice(0,K)):!1},d=function(y){let C=/^#\?(\S+)/,k=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,z=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,$=/^\s*FORMAT=(\S+)\s*$/,K=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,P={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0},N,O;for((y.pos>=y.byteLength||!(N=u(y)))&&a(1,"no header found"),(O=N.match(C))||a(3,"bad initial token"),P.valid|=1,P.programtype=O[1],P.string+=N+`
+`;N=u(y),N!==!1;){if(P.string+=N+`
+`,N.charAt(0)==="#"){P.comments+=N+`
+`;continue}if((O=N.match(k))&&(P.gamma=parseFloat(O[1])),(O=N.match(z))&&(P.exposure=parseFloat(O[1])),(O=N.match($))&&(P.valid|=2,P.format=O[1]),(O=N.match(K))&&(P.valid|=4,P.height=parseInt(O[1],10),P.width=parseInt(O[2],10)),P.valid&2&&P.valid&4)break}return P.valid&2||a(3,"missing format specifier"),P.valid&4||a(3,"missing image size specifier"),P},p=function(y,C,k){let z=C;if(z<8||z>32767||y[0]!==2||y[1]!==2||y[2]&128)return new Uint8Array(y);z!==(y[2]<<8|y[3])&&a(3,"wrong scanline width");let $=new Uint8Array(4*C*k);$.length||a(4,"unable to allocate buffer space");let K=0,P=0,N=4*z,O=new Uint8Array(4),F=new Uint8Array(N),H=k;for(;H>0&&P<y.byteLength;){P+4>y.byteLength&&a(1),O[0]=y[P++],O[1]=y[P++],O[2]=y[P++],O[3]=y[P++],(O[0]!=2||O[1]!=2||(O[2]<<8|O[3])!=z)&&a(3,"bad rgbe scanline format");let V=0,Q;for(;V<N&&P<y.byteLength;){Q=y[P++];let Se=Q>128;if(Se&&(Q-=128),(Q===0||V+Q>N)&&a(3,"bad scanline data"),Se){let ve=y[P++];for(let nt=0;nt<Q;nt++)F[V++]=ve}else F.set(y.subarray(P,P+Q),V),V+=Q,P+=Q}let te=z;for(let Se=0;Se<te;Se++){let ve=0;$[K]=F[Se+ve],ve+=z,$[K+1]=F[Se+ve],ve+=z,$[K+2]=F[Se+ve],ve+=z,$[K+3]=F[Se+ve],K+=4}H--}return $},b=function(y,C,k,z){let $=y[C+3],K=Math.pow(2,$-128)/255;k[z+0]=y[C+0]*K,k[z+1]=y[C+1]*K,k[z+2]=y[C+2]*K,k[z+3]=1},v=function(y,C,k,z){let $=y[C+3],K=Math.pow(2,$-128)/255;k[z+0]=lr.toHalfFloat(Math.min(y[C+0]*K,65504)),k[z+1]=lr.toHalfFloat(Math.min(y[C+1]*K,65504)),k[z+2]=lr.toHalfFloat(Math.min(y[C+2]*K,65504)),k[z+3]=lr.toHalfFloat(1)},_=new Uint8Array(e);_.pos=0;let g=d(_),E=g.width,L=g.height,S=p(_.subarray(_.pos),E,L),M,A,I;switch(this.type){case qn:I=S.length/4;let y=new Float32Array(I*4);for(let k=0;k<I;k++)b(S,k*4,y,k*4);M=y,A=qn;break;case Zn:I=S.length/4;let C=new Uint16Array(I*4);for(let k=0;k<I;k++)v(S,k*4,C,k*4);M=C,A=Zn;break;default:throw new Error("THREE.HDRLoader: Unsupported type: "+this.type)}return{width:E,height:L,data:M,header:g.string,gamma:g.gamma,exposure:g.exposure,type:A,colorSpace:Mn,minFilter:qt,magFilter:qt,generateMipmaps:!1,flipY:!0}}setDataType(e){return this.type=e,this}}});function dm(i,e){if(e===dp)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),i;if(e===oo||e===Pc){let t=i.getIndex();if(t===null){let r=[],a=i.getAttribute("position");if(a!==void 0){for(let o=0;o<a.count;o++)r.push(o);i.setIndex(r),t=i.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),i}let n=t.count-2,s=[];if(e===oo)for(let r=1;r<=n;r++)s.push(t.getX(0)),s.push(t.getX(r)),s.push(t.getX(r+1));else for(let r=0;r<n;r++)r%2===0?(s.push(t.getX(r)),s.push(t.getX(r+1)),s.push(t.getX(r+2))):(s.push(t.getX(r+2)),s.push(t.getX(r+1)),s.push(t.getX(r)));return s.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles."),i.setIndex(s),i.clearGroups(),i}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),i}var Nx=un(()=>{Qn()});function o2(){let i={};return{get:function(e){return i[e]},add:function(e,t){i[e]=t},remove:function(e){delete i[e]},removeAll:function(){i={}}}}function mn(i,e,t){let n=i.json.materials[e];return n.extensions&&n.extensions[t]?n.extensions[t]:null}function h2(i){return i.DefaultMaterial===void 0&&(i.DefaultMaterial=new Pi({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:gs})),i.DefaultMaterial}function ha(i,e,t){for(let n in t.extensions)i[n]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=t.extensions[n])}function Ss(i,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(i.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function u2(i,e,t){let n=!1,s=!1,r=!1;for(let l=0,h=e.length;l<h;l++){let u=e[l];if(u.POSITION!==void 0&&(n=!0),u.NORMAL!==void 0&&(s=!0),u.COLOR_0!==void 0&&(r=!0),n&&s&&r)break}if(!n&&!s&&!r)return Promise.resolve(i);let a=[],o=[],c=[];for(let l=0,h=e.length;l<h;l++){let u=e[l];if(n){let d=u.POSITION!==void 0?t.getDependency("accessor",u.POSITION):i.attributes.position;a.push(d)}if(s){let d=u.NORMAL!==void 0?t.getDependency("accessor",u.NORMAL):i.attributes.normal;o.push(d)}if(r){let d=u.COLOR_0!==void 0?t.getDependency("accessor",u.COLOR_0):i.attributes.color;c.push(d)}}return Promise.all([Promise.all(a),Promise.all(o),Promise.all(c)]).then(function(l){let h=l[0],u=l[1],d=l[2];return n&&(i.morphAttributes.position=h),s&&(i.morphAttributes.normal=u),r&&(i.morphAttributes.color=d),i.morphTargetsRelative=!0,i})}function f2(i,e){if(i.updateMorphTargets(),e.weights!==void 0)for(let t=0,n=e.weights.length;t<n;t++)i.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){let t=e.extras.targetNames;if(i.morphTargetInfluences.length===t.length){i.morphTargetDictionary={};for(let n=0,s=t.length;n<s;n++)i.morphTargetDictionary[t[n]]=n}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function d2(i){let e,t=i.extensions&&i.extensions[St.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+gm(t.attributes):e=i.indices+":"+gm(i.attributes)+":"+i.mode,i.targets!==void 0)for(let n=0,s=i.targets.length;n<s;n++)e+=":"+gm(i.targets[n]);return e}function gm(i){let e="",t=Object.keys(i).sort();for(let n=0,s=t.length;n<s;n++)e+=t[n]+":"+i[t[n]]+";";return e}function zm(i){switch(i){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function p2(i){return i.search(/\.jpe?g($|\?)/i)>0||i.search(/^data\:image\/jpeg/)===0?"image/jpeg":i.search(/\.webp($|\?)/i)>0||i.search(/^data\:image\/webp/)===0?"image/webp":i.search(/\.ktx2($|\?)/i)>0||i.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}function g2(i,e,t){let n=e.attributes,s=new ln;if(n.POSITION!==void 0){let o=t.json.accessors[n.POSITION],c=o.min,l=o.max;if(c!==void 0&&l!==void 0){if(s.set(new j(c[0],c[1],c[2]),new j(l[0],l[1],l[2])),o.normalized){let h=zm(yo[o.componentType]);s.min.multiplyScalar(h),s.max.multiplyScalar(h)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;let r=e.targets;if(r!==void 0){let o=new j,c=new j;for(let l=0,h=r.length;l<h;l++){let u=r[l];if(u.POSITION!==void 0){let d=t.json.accessors[u.POSITION],p=d.min,b=d.max;if(p!==void 0&&b!==void 0){if(c.setX(Math.max(Math.abs(p[0]),Math.abs(b[0]))),c.setY(Math.max(Math.abs(p[1]),Math.abs(b[1]))),c.setZ(Math.max(Math.abs(p[2]),Math.abs(b[2]))),d.normalized){let v=zm(yo[d.componentType]);c.multiplyScalar(v)}o.max(c)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}s.expandByVector(o)}i.boundingBox=s;let a=new si;s.getCenter(a.center),a.radius=s.min.distanceTo(s.max)/2,i.boundingSphere=a}function Ux(i,e,t){let n=e.attributes,s=[];function r(a,o){return t.getDependency("accessor",a).then(function(c){i.setAttribute(o,c)})}for(let a in n){let o=Bm[a]||a.toLowerCase();o in i.attributes||s.push(r(n[a],o))}if(e.indices!==void 0&&!i.index){let a=t.getDependency("accessor",e.indices).then(function(o){i.setIndex(o)});s.push(a)}return gt.workingColorSpace!==Mn&&"COLOR_0"in n&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${gt.workingColorSpace}" not supported.`),Ss(i,e),g2(i,e,t),Promise.all(s).then(function(){return e.targets!==void 0?u2(i,e.targets,t):i})}var Hu,St,bm,_m,xm,ym,vm,Sm,wm,Mm,Em,Am,Tm,Rm,Cm,Im,Pm,Lm,Vu,Dm,Bx,zc,Ox,Nm,Om,Fm,km,Gu,c2,Um,Ni,yo,Fx,kx,pm,Bm,Mr,l2,mm,m2,Hm,zx=un(()=>{Qn();Nx();Au();Hu=class extends _i{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new ym(t)}),this.register(function(t){return new vm(t)}),this.register(function(t){return new Im(t)}),this.register(function(t){return new Pm(t)}),this.register(function(t){return new Lm(t)}),this.register(function(t){return new wm(t)}),this.register(function(t){return new Mm(t)}),this.register(function(t){return new Em(t)}),this.register(function(t){return new Am(t)}),this.register(function(t){return new xm(t)}),this.register(function(t){return new Tm(t)}),this.register(function(t){return new Sm(t)}),this.register(function(t){return new Cm(t)}),this.register(function(t){return new Rm(t)}),this.register(function(t){return new bm(t)}),this.register(function(t){return new Vu(t,St.EXT_MESHOPT_COMPRESSION)}),this.register(function(t){return new Vu(t,St.KHR_MESHOPT_COMPRESSION)}),this.register(function(t){return new Dm(t)})}load(e,t,n,s){let r=this,a;if(this.resourcePath!=="")a=this.resourcePath;else if(this.path!==""){let l=xi.extractUrlBase(e);a=xi.resolveURL(l,this.path)}else a=xi.extractUrlBase(e);this.manager.itemStart(e);let o=function(l){s?s(l):console.error(l),r.manager.itemError(e),r.manager.itemEnd(e)},c=new ms(this.manager);c.setPath(this.path),c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setWithCredentials(this.withCredentials),c.load(e,function(l){try{r.parse(l,a,function(h){t(h),r.manager.itemEnd(e)},o)}catch(h){o(h)}},n,o)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,s){let r,a={},o={},c=new TextDecoder;if(typeof e=="string")r=JSON.parse(e);else if(e instanceof ArrayBuffer)if(c.decode(new Uint8Array(e,0,4))===Bx){try{a[St.KHR_BINARY_GLTF]=new Nm(e)}catch(u){s&&s(u);return}r=JSON.parse(a[St.KHR_BINARY_GLTF].content)}else r=JSON.parse(c.decode(e));else r=e;if(r.asset===void 0||r.asset.version[0]<2){s&&s(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}let l=new Hm(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let h=0;h<this.pluginCallbacks.length;h++){let u=this.pluginCallbacks[h](l);u.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),o[u.name]=u,a[u.name]=!0}if(r.extensionsUsed)for(let h=0;h<r.extensionsUsed.length;++h){let u=r.extensionsUsed[h],d=r.extensionsRequired||[];switch(u){case St.KHR_MATERIALS_UNLIT:a[u]=new _m;break;case St.KHR_DRACO_MESH_COMPRESSION:a[u]=new Om(r,this.dracoLoader);break;case St.KHR_TEXTURE_TRANSFORM:a[u]=new Fm;break;case St.KHR_MESH_QUANTIZATION:a[u]=new km;break;default:d.indexOf(u)>=0&&o[u]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}l.setExtensions(a),l.setPlugins(o),l.parse(n,s)}parseAsync(e,t){let n=this;return new Promise(function(s,r){n.parse(e,t,s,r)})}};St={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",KHR_MESHOPT_COMPRESSION:"KHR_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"},bm=class{constructor(e){this.parser=e,this.name=St.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let n=0,s=t.length;n<s;n++){let r=t[n];r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){let t=this.parser,n="light:"+e,s=t.cache.get(n);if(s)return s;let r=t.json,c=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e],l,h=new He(16777215);c.color!==void 0&&h.setRGB(c.color[0],c.color[1],c.color[2],Mn);let u=c.range!==void 0?c.range:0;switch(c.type){case"directional":l=new Yi(h),l.target.position.set(0,0,-1),l.add(l.target);break;case"point":l=new Qr(h),l.distance=u;break;case"spot":l=new mc(h),l.distance=u,c.spot=c.spot||{},c.spot.innerConeAngle=c.spot.innerConeAngle!==void 0?c.spot.innerConeAngle:0,c.spot.outerConeAngle=c.spot.outerConeAngle!==void 0?c.spot.outerConeAngle:Math.PI/4,l.angle=c.spot.outerConeAngle,l.penumbra=1-c.spot.innerConeAngle/c.spot.outerConeAngle,l.target.position.set(0,0,-1),l.add(l.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+c.type)}return l.position.set(0,0,0),Ss(l,c),c.intensity!==void 0&&(l.intensity=c.intensity),l.name=t.createUniqueName(c.name||"light_"+e),s=Promise.resolve(l),t.cache.add(n,s),s}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){let t=this,n=this.parser,r=n.json.nodes[e],o=(r.extensions&&r.extensions[this.name]||{}).light;return o===void 0?null:this._loadLight(o).then(function(c){return n._getNodeRef(t.cache,o,c)})}},_m=class{constructor(){this.name=St.KHR_MATERIALS_UNLIT}getMaterialType(){return Sn}extendParams(e,t,n){let s=[];e.color=new He(1,1,1),e.opacity=1;let r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){let a=r.baseColorFactor;e.color.setRGB(a[0],a[1],a[2],Mn),e.opacity=a[3]}r.baseColorTexture!==void 0&&s.push(n.assignTexture(e,"map",r.baseColorTexture,Jt))}return Promise.all(s)}},xm=class{constructor(e){this.parser=e,this.name=St.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){let n=mn(this.parser,e,this.name);return n===null||n.emissiveStrength!==void 0&&(t.emissiveIntensity=n.emissiveStrength),Promise.resolve()}},ym=class{constructor(e){this.parser=e,this.name=St.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){return mn(this.parser,e,this.name)!==null?ri:null}extendMaterialParams(e,t){let n=mn(this.parser,e,this.name);if(n===null)return Promise.resolve();let s=[];if(n.clearcoatFactor!==void 0&&(t.clearcoat=n.clearcoatFactor),n.clearcoatTexture!==void 0&&s.push(this.parser.assignTexture(t,"clearcoatMap",n.clearcoatTexture)),n.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=n.clearcoatRoughnessFactor),n.clearcoatRoughnessTexture!==void 0&&s.push(this.parser.assignTexture(t,"clearcoatRoughnessMap",n.clearcoatRoughnessTexture)),n.clearcoatNormalTexture!==void 0&&(s.push(this.parser.assignTexture(t,"clearcoatNormalMap",n.clearcoatNormalTexture)),n.clearcoatNormalTexture.scale!==void 0)){let r=n.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new dt(r,r)}return Promise.all(s)}},vm=class{constructor(e){this.parser=e,this.name=St.KHR_MATERIALS_DISPERSION}getMaterialType(e){return mn(this.parser,e,this.name)!==null?ri:null}extendMaterialParams(e,t){let n=mn(this.parser,e,this.name);return n===null||(t.dispersion=n.dispersion!==void 0?n.dispersion:0),Promise.resolve()}},Sm=class{constructor(e){this.parser=e,this.name=St.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){return mn(this.parser,e,this.name)!==null?ri:null}extendMaterialParams(e,t){let n=mn(this.parser,e,this.name);if(n===null)return Promise.resolve();let s=[];return n.iridescenceFactor!==void 0&&(t.iridescence=n.iridescenceFactor),n.iridescenceTexture!==void 0&&s.push(this.parser.assignTexture(t,"iridescenceMap",n.iridescenceTexture)),n.iridescenceIor!==void 0&&(t.iridescenceIOR=n.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),n.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=n.iridescenceThicknessMinimum),n.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=n.iridescenceThicknessMaximum),n.iridescenceThicknessTexture!==void 0&&s.push(this.parser.assignTexture(t,"iridescenceThicknessMap",n.iridescenceThicknessTexture)),Promise.all(s)}},wm=class{constructor(e){this.parser=e,this.name=St.KHR_MATERIALS_SHEEN}getMaterialType(e){return mn(this.parser,e,this.name)!==null?ri:null}extendMaterialParams(e,t){let n=mn(this.parser,e,this.name);if(n===null)return Promise.resolve();let s=[];if(t.sheenColor=new He(0,0,0),t.sheenRoughness=0,t.sheen=1,n.sheenColorFactor!==void 0){let r=n.sheenColorFactor;t.sheenColor.setRGB(r[0],r[1],r[2],Mn)}return n.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=n.sheenRoughnessFactor),n.sheenColorTexture!==void 0&&s.push(this.parser.assignTexture(t,"sheenColorMap",n.sheenColorTexture,Jt)),n.sheenRoughnessTexture!==void 0&&s.push(this.parser.assignTexture(t,"sheenRoughnessMap",n.sheenRoughnessTexture)),Promise.all(s)}},Mm=class{constructor(e){this.parser=e,this.name=St.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){return mn(this.parser,e,this.name)!==null?ri:null}extendMaterialParams(e,t){let n=mn(this.parser,e,this.name);if(n===null)return Promise.resolve();let s=[];return n.transmissionFactor!==void 0&&(t.transmission=n.transmissionFactor),n.transmissionTexture!==void 0&&s.push(this.parser.assignTexture(t,"transmissionMap",n.transmissionTexture)),Promise.all(s)}},Em=class{constructor(e){this.parser=e,this.name=St.KHR_MATERIALS_VOLUME}getMaterialType(e){return mn(this.parser,e,this.name)!==null?ri:null}extendMaterialParams(e,t){let n=mn(this.parser,e,this.name);if(n===null)return Promise.resolve();let s=[];t.thickness=n.thicknessFactor!==void 0?n.thicknessFactor:0,n.thicknessTexture!==void 0&&s.push(this.parser.assignTexture(t,"thicknessMap",n.thicknessTexture)),t.attenuationDistance=n.attenuationDistance||1/0;let r=n.attenuationColor||[1,1,1];return t.attenuationColor=new He().setRGB(r[0],r[1],r[2],Mn),Promise.all(s)}},Am=class{constructor(e){this.parser=e,this.name=St.KHR_MATERIALS_IOR}getMaterialType(e){return mn(this.parser,e,this.name)!==null?ri:null}extendMaterialParams(e,t){let n=mn(this.parser,e,this.name);return n===null||(t.ior=n.ior!==void 0?n.ior:1.5,t.ior===0&&(t.ior=1e3)),Promise.resolve()}},Tm=class{constructor(e){this.parser=e,this.name=St.KHR_MATERIALS_SPECULAR}getMaterialType(e){return mn(this.parser,e,this.name)!==null?ri:null}extendMaterialParams(e,t){let n=mn(this.parser,e,this.name);if(n===null)return Promise.resolve();let s=[];t.specularIntensity=n.specularFactor!==void 0?n.specularFactor:1,n.specularTexture!==void 0&&s.push(this.parser.assignTexture(t,"specularIntensityMap",n.specularTexture));let r=n.specularColorFactor||[1,1,1];return t.specularColor=new He().setRGB(r[0],r[1],r[2],Mn),n.specularColorTexture!==void 0&&s.push(this.parser.assignTexture(t,"specularColorMap",n.specularColorTexture,Jt)),Promise.all(s)}},Rm=class{constructor(e){this.parser=e,this.name=St.EXT_MATERIALS_BUMP}getMaterialType(e){return mn(this.parser,e,this.name)!==null?ri:null}extendMaterialParams(e,t){let n=mn(this.parser,e,this.name);if(n===null)return Promise.resolve();let s=[];return t.bumpScale=n.bumpFactor!==void 0?n.bumpFactor:1,n.bumpTexture!==void 0&&s.push(this.parser.assignTexture(t,"bumpMap",n.bumpTexture)),Promise.all(s)}},Cm=class{constructor(e){this.parser=e,this.name=St.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){return mn(this.parser,e,this.name)!==null?ri:null}extendMaterialParams(e,t){let n=mn(this.parser,e,this.name);if(n===null)return Promise.resolve();let s=[];return n.anisotropyStrength!==void 0&&(t.anisotropy=n.anisotropyStrength),n.anisotropyRotation!==void 0&&(t.anisotropyRotation=n.anisotropyRotation),n.anisotropyTexture!==void 0&&s.push(this.parser.assignTexture(t,"anisotropyMap",n.anisotropyTexture)),Promise.all(s)}},Im=class{constructor(e){this.parser=e,this.name=St.KHR_TEXTURE_BASISU}loadTexture(e){let t=this.parser,n=t.json,s=n.textures[e];if(!s.extensions||!s.extensions[this.name])return null;let r=s.extensions[this.name],a=t.options.ktx2Loader;if(!a){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,r.source,a)}},Pm=class{constructor(e){this.parser=e,this.name=St.EXT_TEXTURE_WEBP}loadTexture(e){let t=this.name,n=this.parser,s=n.json,r=s.textures[e];if(!r.extensions||!r.extensions[t])return null;let a=r.extensions[t],o=s.images[a.source],c=n.textureLoader;if(o.uri){let l=n.options.manager.getHandler(o.uri);l!==null&&(c=l)}return n.loadTextureImage(e,a.source,c)}},Lm=class{constructor(e){this.parser=e,this.name=St.EXT_TEXTURE_AVIF}loadTexture(e){let t=this.name,n=this.parser,s=n.json,r=s.textures[e];if(!r.extensions||!r.extensions[t])return null;let a=r.extensions[t],o=s.images[a.source],c=n.textureLoader;if(o.uri){let l=n.options.manager.getHandler(o.uri);l!==null&&(c=l)}return n.loadTextureImage(e,a.source,c)}},Vu=class{constructor(e,t){this.name=t,this.parser=e}loadBufferView(e){let t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){let s=n.extensions[this.name],r=this.parser.getDependency("buffer",s.buffer),a=this.parser.options.meshoptDecoder;if(!a||!a.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return r.then(function(o){let c=s.byteOffset||0,l=s.byteLength||0,h=s.count,u=s.byteStride,d=new Uint8Array(o,c,l);return a.decodeGltfBufferAsync?a.decodeGltfBufferAsync(h,u,d,s.mode,s.filter).then(function(p){return p.buffer}):a.ready.then(function(){let p=new ArrayBuffer(h*u);return a.decodeGltfBuffer(new Uint8Array(p),h,u,d,s.mode,s.filter),p})})}else return null}},Dm=class{constructor(e){this.name=St.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){let t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;let s=t.meshes[n.mesh];for(let l of s.primitives)if(l.mode!==Ni.TRIANGLES&&l.mode!==Ni.TRIANGLE_STRIP&&l.mode!==Ni.TRIANGLE_FAN&&l.mode!==void 0)return null;let a=n.extensions[this.name].attributes,o=[],c={};for(let l in a)o.push(this.parser.getDependency("accessor",a[l]).then(h=>(c[l]=h,c[l])));return o.length<1?null:(o.push(this.parser.createNodeMesh(e)),Promise.all(o).then(l=>{let h=l.pop(),u=h.isGroup?h.children:[h],d=l[0].count,p=[];for(let b of u){let v=new ht,_=new j,g=new Ft,E=new j(1,1,1),L=new Kr(b.geometry,b.material,d);for(let M=0;M<d;M++)c.TRANSLATION&&_.fromBufferAttribute(c.TRANSLATION,M),c.ROTATION&&g.fromBufferAttribute(c.ROTATION,M),c.SCALE&&E.fromBufferAttribute(c.SCALE,M),L.setMatrixAt(M,v.compose(_,g,E));let S=null;for(let M in c)if(M==="_COLOR_0"){let A=c[M];L.instanceColor=new Bs(A.array,A.itemSize,A.normalized)}else if(M!=="TRANSLATION"&&M!=="ROTATION"&&M!=="SCALE"){if(S===null){let I=L.geometry;S=new pn,S.name=I.name;for(let y in I.attributes)S.setAttribute(y,I.attributes[y]);for(let y in I.morphAttributes)S.morphAttributes[y]=I.morphAttributes[y];I.index!==null&&S.setIndex(I.index),S.morphTargetsRelative=I.morphTargetsRelative;for(let y of I.groups)S.addGroup(y.start,y.count,y.materialIndex);I.boundingBox!==null&&(S.boundingBox=I.boundingBox.clone()),I.boundingSphere!==null&&(S.boundingSphere=I.boundingSphere.clone()),S.drawRange.start=I.drawRange.start,S.drawRange.count=I.drawRange.count,S.userData=Object.assign({},I.userData),L.geometry=S}let A=c[M];S.setAttribute(M,new Bs(A.array,A.itemSize,A.normalized))}Yt.prototype.copy.call(L,b),this.parser.assignFinalMaterial(L),p.push(L)}return h.isGroup?(h.clear(),h.add(...p),h):p[0]}))}},Bx="glTF",zc=12,Ox={JSON:1313821514,BIN:5130562},Nm=class{constructor(e){this.name=St.KHR_BINARY_GLTF,this.content=null,this.body=null;let t=new DataView(e,0,zc),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Bx)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");let s=this.header.length-zc,r=new DataView(e,zc),a=0;for(;a<s;){let o=r.getUint32(a,!0);a+=4;let c=r.getUint32(a,!0);if(a+=4,c===Ox.JSON){let l=new Uint8Array(e,zc+a,o);this.content=n.decode(l)}else if(c===Ox.BIN){let l=zc+a;this.body=e.slice(l,l+o)}a+=o}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}},Om=class{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=St.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){let n=this.json,s=this.dracoLoader,r=e.extensions[this.name].bufferView,a=e.extensions[this.name].attributes,o={},c={},l={};for(let h in a){let u=Bm[h]||h.toLowerCase();o[u]=a[h]}for(let h in e.attributes){let u=Bm[h]||h.toLowerCase();if(a[h]!==void 0){let d=n.accessors[e.attributes[h]],p=yo[d.componentType];l[u]=p.name,c[u]=d.normalized===!0}}return t.getDependency("bufferView",r).then(function(h){return new Promise(function(u,d){s.decodeDracoFile(h,function(p){for(let b in p.attributes){let v=p.attributes[b],_=c[b];_!==void 0&&(v.normalized=_)}u(p)},o,l,Mn,d)})})}},Fm=class{constructor(){this.name=St.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){if((t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0)return e;if(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),t.rotation!==void 0){let n=Math.cos(e.rotation),s=Math.sin(e.rotation);e.matrix.set(e.repeat.x*n,e.repeat.y*s,e.offset.x,-e.repeat.x*s,e.repeat.y*n,e.offset.y,0,0,1),e.matrixAutoUpdate=!1}return e.needsUpdate=!0,e}},km=class{constructor(){this.name=St.KHR_MESH_QUANTIZATION}},Gu=class extends ps{constructor(e,t,n,s){super(e,t,n,s)}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,s=this.valueSize,r=e*s*3+s;for(let a=0;a!==s;a++)t[a]=n[r+a];return t}interpolate_(e,t,n,s){let r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=o*2,l=o*3,h=s-t,u=(n-t)/h,d=u*u,p=d*u,b=e*l,v=b-l,_=-2*p+3*d,g=p-d,E=1-_,L=g-d+u;for(let S=0;S!==o;S++){let M=a[v+S+o],A=a[v+S+c]*h,I=a[b+S+o],y=a[b+S]*h;r[S]=E*M+L*A+_*I+g*y}return r}},c2=new Ft,Um=class extends Gu{interpolate_(e,t,n,s){let r=super.interpolate_(e,t,n,s);return c2.fromArray(r).normalize().toArray(r),r}},Ni={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},yo={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Fx={9728:dn,9729:qt,9984:Nh,9985:io,9986:ia,9987:Di},kx={33071:ii,33648:Ga,10497:or},pm={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Bm={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},Mr={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},l2={CUBICSPLINE:void 0,LINEAR:jr,STEP:qr},mm={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};m2=new ht,Hm=class{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new o2,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,s=-1,r=!1,a=-1;if(typeof navigator<"u"&&typeof navigator.userAgent<"u"){let o=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(o)===!0;let c=o.match(/Version\/(\d+)/);s=n&&c?parseInt(c[1],10):-1,r=o.indexOf("Firefox")>-1,a=r?o.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||n&&s<17||r&&a<98?this.textureLoader=new dc(this.options.manager):this.textureLoader=new bc(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new ms(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){let n=this,s=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(a){return a._markDefs&&a._markDefs()}),Promise.all(this._invokeAll(function(a){return a.beforeRoot&&a.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(a){let o={scene:a[0][s.scene||0],scenes:a[0],animations:a[1],cameras:a[2],asset:s.asset,parser:n,userData:{}};return ha(r,o,s),Ss(o,s),Promise.all(n._invokeAll(function(c){return c.afterRoot&&c.afterRoot(o)})).then(function(){for(let c of o.scenes)c.updateMatrixWorld();e(o)})}).catch(t)}_markDefs(){let e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let s=0,r=t.length;s<r;s++){let a=t[s].joints;for(let o=0,c=a.length;o<c;o++)e[a[o]].isBone=!0}for(let s=0,r=e.length;s<r;s++){let a=e[s];a.mesh!==void 0&&(this._addNodeRef(this.meshCache,a.mesh),a.skin!==void 0&&(n[a.mesh].isSkinnedMesh=!0)),a.camera!==void 0&&this._addNodeRef(this.cameraCache,a.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;let s=n.clone(),r=(a,o)=>{let c=this.associations.get(a);c!=null&&this.associations.set(o,c);for(let[l,h]of a.children.entries())r(h,o.children[l])};return r(n,s),s.name+="_instance_"+e.uses[t]++,s}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){let s=e(t[n]);if(s)return s}return null}_invokeAll(e){let t=Object.values(this.plugins);t.unshift(this);let n=[];for(let s=0;s<t.length;s++){let r=e(t[s]);r&&n.push(r)}return n}getDependency(e,t){let n=e+":"+t,s=this.cache.get(n);if(!s){switch(e){case"scene":s=this.loadScene(t);break;case"node":s=this._invokeOne(function(r){return r.loadNode&&r.loadNode(t)});break;case"mesh":s=this._invokeOne(function(r){return r.loadMesh&&r.loadMesh(t)});break;case"accessor":s=this.loadAccessor(t);break;case"bufferView":s=this._invokeOne(function(r){return r.loadBufferView&&r.loadBufferView(t)});break;case"buffer":s=this.loadBuffer(t);break;case"material":s=this._invokeOne(function(r){return r.loadMaterial&&r.loadMaterial(t)});break;case"texture":s=this._invokeOne(function(r){return r.loadTexture&&r.loadTexture(t)});break;case"skin":s=this.loadSkin(t);break;case"animation":s=this._invokeOne(function(r){return r.loadAnimation&&r.loadAnimation(t)});break;case"camera":s=this.loadCamera(t);break;default:if(s=this._invokeOne(function(r){return r!=this&&r.getDependency&&r.getDependency(e,t)}),!s)throw new Error("Unknown type: "+e);break}this.cache.add(n,s)}return s}getDependencies(e){let t=this.cache.get(e);if(!t){let n=this,s=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(s.map(function(r,a){return n.getDependency(e,a)})),this.cache.add(e,t)}return t}loadBuffer(e){let t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[St.KHR_BINARY_GLTF].body);let s=this.options;return new Promise(function(r,a){n.load(xi.resolveURL(t.uri,s.path),r,void 0,function(){a(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){let t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(n){let s=t.byteLength||0,r=t.byteOffset||0;return n.slice(r,r+s)})}loadAccessor(e){let t=this,n=this.json,s=this.json.accessors[e];if(s.bufferView===void 0&&s.sparse===void 0){let a=pm[s.type],o=yo[s.componentType],c=s.normalized===!0,l=new o(s.count*a);return Promise.resolve(new Qt(l,a,c))}let r=[];return s.bufferView!==void 0?r.push(this.getDependency("bufferView",s.bufferView)):r.push(null),s.sparse!==void 0&&(r.push(this.getDependency("bufferView",s.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",s.sparse.values.bufferView))),Promise.all(r).then(function(a){let o=a[0],c=pm[s.type],l=yo[s.componentType],h=l.BYTES_PER_ELEMENT,u=h*c,d=s.byteOffset||0,p=s.bufferView!==void 0?n.bufferViews[s.bufferView].byteStride:void 0,b=s.normalized===!0,v,_;if(p&&p!==u){let g=Math.floor(d/p),E="InterleavedBuffer:"+s.bufferView+":"+s.componentType+":"+g+":"+s.count,L=t.cache.get(E);L||(v=new l(o,g*p,s.count*p/h),L=new hr(v,p/h),t.cache.add(E,L)),_=new ur(L,c,d%p/h,b)}else o===null?v=new l(s.count*c):v=new l(o,d,s.count*c),_=new Qt(v,c,b);if(s.sparse!==void 0){let g=pm.SCALAR,E=yo[s.sparse.indices.componentType],L=s.sparse.indices.byteOffset||0,S=s.sparse.values.byteOffset||0,M=new E(a[1],L,s.sparse.count*g),A=new l(a[2],S,s.sparse.count*c);o!==null&&(_=new Qt(_.array.slice(),_.itemSize,_.normalized)),_.normalized=!1;for(let I=0,y=M.length;I<y;I++){let C=M[I];if(_.setX(C,A[I*c]),c>=2&&_.setY(C,A[I*c+1]),c>=3&&_.setZ(C,A[I*c+2]),c>=4&&_.setW(C,A[I*c+3]),c>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}_.normalized=b}return _})}loadTexture(e){let t=this.json,n=this.options,r=t.textures[e].source,a=t.images[r],o=this.textureLoader;if(a.uri){let c=n.manager.getHandler(a.uri);c!==null&&(o=c)}return this.loadTextureImage(e,r,o)}loadTextureImage(e,t,n){let s=this,r=this.json,a=r.textures[e],o=r.images[t],c=(o.uri||o.bufferView)+":"+a.sampler;if(this.textureCache[c])return this.textureCache[c];let l=this.loadImageSource(t,n).then(function(h){h.flipY=!1,h.name=a.name||o.name||"",h.name===""&&typeof o.uri=="string"&&o.uri.startsWith("data:image/")===!1&&(h.name=o.uri);let d=(r.samplers||{})[a.sampler]||{};return h.magFilter=Fx[d.magFilter]||qt,h.minFilter=Fx[d.minFilter]||Di,h.wrapS=kx[d.wrapS]||or,h.wrapT=kx[d.wrapT]||or,h.generateMipmaps=!h.isCompressedTexture&&h.minFilter!==dn&&h.minFilter!==qt,s.associations.set(h,{textures:e}),h}).catch(function(){return null});return this.textureCache[c]=l,l}loadImageSource(e,t){let n=this,s=this.json,r=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(u=>u.clone());let a=s.images[e],o=self.URL||self.webkitURL,c=a.uri||"",l=!1;if(a.bufferView!==void 0)c=n.getDependency("bufferView",a.bufferView).then(function(u){l=!0;let d=new Blob([u],{type:a.mimeType});return c=o.createObjectURL(d),c});else if(a.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");let h=Promise.resolve(c).then(function(u){return new Promise(function(d,p){let b=d;t.isImageBitmapLoader===!0&&(b=function(v){let _=new En(v);_.needsUpdate=!0,d(_)}),t.load(xi.resolveURL(u,r.path),b,void 0,p)})}).then(function(u){return l===!0&&o.revokeObjectURL(c),Ss(u,a),u.userData.mimeType=a.mimeType||p2(a.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",c),u});return this.sourceCache[e]=h,h}assignTexture(e,t,n,s){let r=this;return this.getDependency("texture",n.index).then(function(a){if(!a)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(a=a.clone(),a.channel=n.texCoord),r.extensions[St.KHR_TEXTURE_TRANSFORM]){let o=n.extensions!==void 0?n.extensions[St.KHR_TEXTURE_TRANSFORM]:void 0;if(o){let c=r.associations.get(a);a=r.extensions[St.KHR_TEXTURE_TRANSFORM].extendTexture(a,o),r.associations.set(a,c)}}return s!==void 0&&(a.colorSpace=s),e[t]=a,a})}assignFinalMaterial(e){let t=e.geometry,n=e.material,s=t.attributes.tangent===void 0,r=t.attributes.color!==void 0,a=t.attributes.normal===void 0;if(e.isPoints){let o="PointsMaterial:"+n.uuid,c=this.cache.get(o);c||(c=new Qa,Wn.prototype.copy.call(c,n),c.color.copy(n.color),c.map=n.map,c.sizeAttenuation=!1,this.cache.add(o,c)),n=c}else if(e.isLine){let o="LineBasicMaterial:"+n.uuid,c=this.cache.get(o);c||(c=new Yr,Wn.prototype.copy.call(c,n),c.color.copy(n.color),c.map=n.map,this.cache.add(o,c)),n=c}if(s||r||a){let o="ClonedMaterial:"+n.uuid+":";s&&(o+="derivative-tangents:"),r&&(o+="vertex-colors:"),a&&(o+="flat-shading:");let c=this.cache.get(o);c||(c=n.clone(),r&&(c.vertexColors=!0),a&&(c.flatShading=!0),s&&(c.normalScale&&(c.normalScale.y*=-1),c.clearcoatNormalScale&&(c.clearcoatNormalScale.y*=-1)),this.cache.add(o,c),this.associations.set(c,this.associations.get(n))),n=c}e.material=n}getMaterialType(){return Pi}loadMaterial(e){let t=this,n=this.json,s=this.extensions,r=n.materials[e],a,o={},c=r.extensions||{},l=[];if(c[St.KHR_MATERIALS_UNLIT]){let u=s[St.KHR_MATERIALS_UNLIT];a=u.getMaterialType(),l.push(u.extendParams(o,r,t))}else{let u=r.pbrMetallicRoughness||{};if(o.color=new He(1,1,1),o.opacity=1,Array.isArray(u.baseColorFactor)){let d=u.baseColorFactor;o.color.setRGB(d[0],d[1],d[2],Mn),o.opacity=d[3]}u.baseColorTexture!==void 0&&l.push(t.assignTexture(o,"map",u.baseColorTexture,Jt)),o.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,o.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0&&(l.push(t.assignTexture(o,"metalnessMap",u.metallicRoughnessTexture)),l.push(t.assignTexture(o,"roughnessMap",u.metallicRoughnessTexture))),a=this._invokeOne(function(d){return d.getMaterialType&&d.getMaterialType(e)}),l.push(Promise.all(this._invokeAll(function(d){return d.extendMaterialParams&&d.extendMaterialParams(e,o)})))}r.doubleSided===!0&&(o.side=$n);let h=r.alphaMode||mm.OPAQUE;if(h===mm.BLEND?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,h===mm.MASK&&(o.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:.5)),r.normalTexture!==void 0&&a!==Sn&&(l.push(t.assignTexture(o,"normalMap",r.normalTexture)),o.normalScale=new dt(1,1),r.normalTexture.scale!==void 0)){let u=r.normalTexture.scale;o.normalScale.set(u,u)}if(r.occlusionTexture!==void 0&&a!==Sn&&(l.push(t.assignTexture(o,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0&&(o.aoMapIntensity=r.occlusionTexture.strength)),r.emissiveFactor!==void 0&&a!==Sn){let u=r.emissiveFactor;o.emissive=new He().setRGB(u[0],u[1],u[2],Mn)}return r.emissiveTexture!==void 0&&a!==Sn&&l.push(t.assignTexture(o,"emissiveMap",r.emissiveTexture,Jt)),Promise.all(l).then(function(){let u=new a(o);return r.name&&(u.name=r.name),Ss(u,r),t.associations.set(u,{materials:e}),r.extensions&&ha(s,u,r),u})}createUniqueName(e){let t=Ot.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){let t=this,n=this.extensions,s=this.primitiveCache;function r(o){return n[St.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(o,t).then(function(c){return Ux(c,o,t)})}let a=[];for(let o=0,c=e.length;o<c;o++){let l=e[o],h=d2(l),u=s[h];if(u)a.push(u.promise);else{let d;l.extensions&&l.extensions[St.KHR_DRACO_MESH_COMPRESSION]?d=r(l):d=Ux(new pn,l,t),l.mode===Ni.TRIANGLE_STRIP?d=d.then(p=>dm(p,Pc)):l.mode===Ni.TRIANGLE_FAN&&(d=d.then(p=>dm(p,oo))),s[h]={primitive:l,promise:d},a.push(d)}}return Promise.all(a)}loadMesh(e){let t=this,n=this.json,s=this.extensions,r=n.meshes[e],a=r.primitives,o=[];for(let c=0,l=a.length;c<l;c++){let h=a[c].material===void 0?h2(this.cache):this.getDependency("material",a[c].material);o.push(h)}return o.push(t.loadGeometries(a)),Promise.all(o).then(async function(c){let l=c.slice(0,c.length-1),h=c[c.length-1],u=[];for(let p=0,b=h.length;p<b;p++){let v=h[p],_=a[p],g,E=l[p];if(_.mode===Ni.TRIANGLES||_.mode===Ni.TRIANGLE_STRIP||_.mode===Ni.TRIANGLE_FAN||_.mode===void 0){let L=r.isSkinnedMesh===!0,S=v.hasAttribute("skinIndex")&&v.hasAttribute("skinWeight");L&&S===!1&&console.warn("THREE.GLTFLoader: Missing skinIndex or skinWeight attributes. Skinning disabled."),g=L&&S?new Qo(v,E):new vt(v,E),g.isSkinnedMesh===!0&&g.normalizeSkinWeights()}else if(_.mode===Ni.LINES)g=new Za(v,E);else if(_.mode===Ni.LINE_STRIP)g=new Jr(v,E);else if(_.mode===Ni.LINE_LOOP)g=new tc(v,E);else if(_.mode===Ni.POINTS)g=new nc(v,E);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+_.mode);Object.keys(g.geometry.morphAttributes).length>0&&f2(g,r),g.name=t.createUniqueName(r.name||"mesh_"+e),Ss(g,r),_.extensions&&ha(s,g,_),t.assignFinalMaterial(g),u.push(g)}for(let p=0,b=u.length;p<b;p++)t.associations.set(u[p],{meshes:e,primitives:p});if(u.length===1)return r.extensions&&ha(s,u[0],r),u[0];let d=new vn;r.extensions&&ha(s,d,r),t.associations.set(d,{meshes:e});for(let p=0,b=u.length;p<b;p++)d.add(u[p]);return d})}loadCamera(e){let t,n=this.json.cameras[e],s=n[n.type];if(!s){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return n.type==="perspective"?t=new fn(bp.radToDeg(s.yfov),s.aspectRatio||1,s.znear||1,s.zfar||2e6):n.type==="orthographic"&&(t=new xr(-s.xmag,s.xmag,s.ymag,-s.ymag,s.znear,s.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),Ss(t,n),Promise.resolve(t)}loadSkin(e){let t=this.json.skins[e],n=[];for(let s=0,r=t.joints.length;s<r;s++)n.push(this._loadNodeShallow(t.joints[s]));return t.inverseBindMatrices!==void 0?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then(function(s){let r=s.pop(),a=s,o=[],c=[];for(let l=0,h=a.length;l<h;l++){let u=a[l];if(u){o.push(u);let d=new ht;r!==null&&d.fromArray(r.array,l*16),c.push(d)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[l])}return new ec(o,c)})}loadAnimation(e){let t=this.json,n=this,s=t.animations[e],r=s.name?s.name:"animation_"+e,a=[],o=[],c=[],l=[],h=[];for(let u=0,d=s.channels.length;u<d;u++){let p=s.channels[u],b=s.samplers[p.sampler],v=p.target,_=v.node,g=s.parameters!==void 0?s.parameters[b.input]:b.input,E=s.parameters!==void 0?s.parameters[b.output]:b.output;v.node!==void 0&&(a.push(this.getDependency("node",_)),o.push(this.getDependency("accessor",g)),c.push(this.getDependency("accessor",E)),l.push(b),h.push(v))}return Promise.all([Promise.all(a),Promise.all(o),Promise.all(c),Promise.all(l),Promise.all(h)]).then(function(u){let d=u[0],p=u[1],b=u[2],v=u[3],_=u[4],g=[];for(let L=0,S=d.length;L<S;L++){let M=d[L],A=p[L],I=b[L],y=v[L],C=_[L];if(M===void 0)continue;M.updateMatrix&&M.updateMatrix();let k=n._createAnimationTracks(M,A,I,y,C);if(k)for(let z=0;z<k.length;z++)g.push(k[z])}let E=new Li(r,void 0,g);return Ss(E,s),E})}createNodeMesh(e){let t=this.json,n=this,s=t.nodes[e];return s.mesh===void 0?null:n.getDependency("mesh",s.mesh).then(function(r){let a=n._getNodeRef(n.meshCache,s.mesh,r);return s.weights!==void 0&&a.traverse(function(o){if(o.isMesh)for(let c=0,l=s.weights.length;c<l;c++)o.morphTargetInfluences[c]=s.weights[c]}),a})}loadNode(e){let t=this.json,n=this,s=t.nodes[e],r=n._loadNodeShallow(e),a=[],o=s.children||[];for(let l=0,h=o.length;l<h;l++)a.push(n.getDependency("node",o[l]));let c=s.skin===void 0?Promise.resolve(null):n.getDependency("skin",s.skin);return Promise.all([r,Promise.all(a),c]).then(function(l){let h=l[0],u=l[1],d=l[2];d!==null&&h.traverse(function(p){p.isSkinnedMesh&&p.bind(d,m2)});for(let p=0,b=u.length;p<b;p++)h.add(u[p]);if(h.userData.pivot!==void 0&&u.length>0){let p=h.userData.pivot,b=u[0];h.pivot=new j().fromArray(p),h.position.x-=p[0],h.position.y-=p[1],h.position.z-=p[2],b.position.set(0,0,0),delete h.userData.pivot}return h})}_loadNodeShallow(e){let t=this.json,n=this.extensions,s=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];let r=t.nodes[e],a=r.name?s.createUniqueName(r.name):"",o=[],c=s._invokeOne(function(l){return l.createNodeMesh&&l.createNodeMesh(e)});return c&&o.push(c),r.camera!==void 0&&o.push(s.getDependency("camera",r.camera).then(function(l){return s._getNodeRef(s.cameraCache,r.camera,l)})),s._invokeAll(function(l){return l.createNodeAttachment&&l.createNodeAttachment(e)}).forEach(function(l){o.push(l)}),this.nodeCache[e]=Promise.all(o).then(function(l){let h;if(r.isBone===!0?h=new Ya:l.length>1?h=new vn:l.length===1?h=l[0]:h=new Yt,h!==l[0])for(let u=0,d=l.length;u<d;u++)h.add(l[u]);if(r.name&&(h.userData.name=r.name,h.name=a),Ss(h,r),r.extensions&&ha(n,h,r),r.matrix!==void 0){let u=new ht;u.fromArray(r.matrix),h.applyMatrix4(u)}else r.translation!==void 0&&h.position.fromArray(r.translation),r.rotation!==void 0&&h.quaternion.fromArray(r.rotation),r.scale!==void 0&&h.scale.fromArray(r.scale);if(!s.associations.has(h))s.associations.set(h,{});else if(r.mesh!==void 0&&s.meshCache.refs[r.mesh]>1){let u=s.associations.get(h);s.associations.set(h,{...u})}return s.associations.get(h).nodes=e,h}),this.nodeCache[e]}loadScene(e){let t=this.extensions,n=this.json.scenes[e],s=this,r=new vn;n.name&&(r.name=s.createUniqueName(n.name)),Ss(r,n),n.extensions&&ha(t,r,n);let a=n.nodes||[],o=[];for(let c=0,l=a.length;c<l;c++)o.push(s.getDependency("node",a[c]));return Promise.all(o).then(function(c){for(let h=0,u=c.length;h<u;h++){let d=c[h];d.parent!==null?r.add(aa(d)):r.add(d)}let l=h=>{let u=new Map;for(let[d,p]of s.associations)(d instanceof Wn||d instanceof En)&&u.set(d,p);return h.traverse(d=>{let p=s.associations.get(d);p!=null&&u.set(d,p)}),u};return s.associations=l(r),r})}_createAnimationTracks(e,t,n,s,r){let a=[],o=e.name?e.name:e.uuid,c=[];function l(p){p.morphTargetInfluences&&c.push(p.name?p.name:p.uuid)}Mr[r.path]===Mr.weights?(l(e),e.isGroup&&e.children.forEach(l)):c.push(o);let h;switch(Mr[r.path]){case Mr.weights:h=Hs;break;case Mr.rotation:h=Vs;break;case Mr.translation:case Mr.scale:h=br;break;default:n.itemSize===1?h=Hs:h=br;break}let u=s.interpolation!==void 0?l2[s.interpolation]:jr,d=this._getArrayFromAccessor(n);for(let p=0,b=c.length;p<b;p++){let v=new h(c[p]+"."+Mr[r.path],t.array,d,u);s.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(v),a.push(v)}return a}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){let n=zm(t.constructor),s=new Float32Array(t.length);for(let r=0,a=t.length;r<a;r++)s[r]=t[r]*n;t=s}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){let s=this instanceof Vs?Um:Gu;return new s(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}});function y2(){let i,e;onmessage=function(a){let o=a.data;switch(o.type){case"init":i=o.decoderConfig,e=new Promise(function(h){i.onModuleLoaded=function(u){h({draco:u})},DracoDecoderModule(i)});break;case"decode":let c=o.buffer,l=o.taskConfig;e.then(h=>{let u=h.draco,d=new u.Decoder;try{let p=t(u,d,new Int8Array(c),l),b=p.attributes.map(v=>v.array.buffer);p.index&&b.push(p.index.array.buffer),self.postMessage({type:"decode",id:o.id,geometry:p},b)}catch(p){console.error(p),self.postMessage({type:"error",id:o.id,error:p.message})}finally{u.destroy(d)}});break}};function t(a,o,c,l){let h=l.attributeIDs,u=l.attributeTypes,d,p,b=o.GetEncodedGeometryType(c);if(b===a.TRIANGULAR_MESH)d=new a.Mesh,p=o.DecodeArrayToMesh(c,c.byteLength,d);else if(b===a.POINT_CLOUD)d=new a.PointCloud,p=o.DecodeArrayToPointCloud(c,c.byteLength,d);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!p.ok()||d.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+p.error_msg());let v={index:null,attributes:[]};for(let _ in h){let g=self[u[_]],E,L;if(l.useUniqueIDs)L=h[_],E=o.GetAttributeByUniqueId(d,L);else{if(L=o.GetAttributeId(d,a[h[_]]),L===-1)continue;E=o.GetAttribute(d,L)}let S=s(a,o,d,_,g,E);_==="color"&&(S.vertexColorSpace=l.vertexColorSpace),v.attributes.push(S)}return b===a.TRIANGULAR_MESH&&(v.index=n(a,o,d)),a.destroy(d),v}function n(a,o,c){let h=c.num_faces()*3,u=h*4,d=a._malloc(u);o.GetTrianglesUInt32Array(c,u,d);let p=new Uint32Array(a.HEAPF32.buffer,d,h).slice();return a._free(d),{array:p,itemSize:1}}function s(a,o,c,l,h,u){let d=c.num_points(),p=u.num_components(),b=r(a,h),v=p*h.BYTES_PER_ELEMENT,_=Math.ceil(v/4)*4,g=_/h.BYTES_PER_ELEMENT,E=d*v,L=d*_,S=a._malloc(E);o.GetAttributeDataArrayForAllPoints(c,u,b,E,S);let M=new h(a.HEAPF32.buffer,S,E/h.BYTES_PER_ELEMENT),A;if(v===_)A=M.slice();else{A=new h(L/h.BYTES_PER_ELEMENT);let I=0;for(let y=0,C=M.length;y<C;y++){for(let k=0;k<p;k++)A[I+k]=M[y*p+k];I+=g}}return a._free(S),{name:l,count:d,itemSize:p,array:A,stride:g}}function r(a,o){switch(o){case Float32Array:return a.DT_FLOAT32;case Int8Array:return a.DT_INT8;case Int16Array:return a.DT_INT16;case Int32Array:return a.DT_INT32;case Uint8Array:return a.DT_UINT8;case Uint16Array:return a.DT_UINT16;case Uint32Array:return a.DT_UINT32}}}var Vm,b2,_2,x2,vF,Wu,Hx=un(()=>{Qn();Vm=new WeakMap,b2=new URL("../libs/draco/draco_decoder.wasm",import.meta.url).toString(),_2=new URL("../libs/draco/draco_wasm_wrapper.js",import.meta.url).toString(),x2=new URL("../libs/draco/draco_decoder.js",import.meta.url).toString(),vF={js:new URL("../libs/draco/gltf/draco_wasm_wrapper.js",import.meta.url).toString(),wasm:new URL("../libs/draco/gltf/draco_decoder.wasm",import.meta.url).toString()},Wu=class extends _i{constructor(e){super(e),this.decoderPaths={js:_2,wasm:b2,dep_js:x2},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){let{decoderPaths:t}=this;return typeof e=="object"?(t.js=e.js,t.wasm=e.wasm,t.dep_js=null):(t.js=xi.resolveURL("draco_wasm_wrapper.js",e),t.wasm=xi.resolveURL("draco_decoder.wasm",e),t.dep_js=xi.resolveURL("draco_decoder.js",e)),this}setDecoderConfig(e){return console.warn("THREE.DRACOLoader: setDecoderConfig to has been deprecated and will be removed in r194."),this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,n,s){let r=new ms(this.manager);r.setPath(this.path),r.setResponseType("arraybuffer"),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(e,a=>{this.parse(a,t,s)},n,s)}parse(e,t,n=()=>{}){this.decodeDracoFile(e,t,null,null,Jt,n).catch(n)}decodeDracoFile(e,t,n,s,r=Mn,a=()=>{}){let o={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:s||this.defaultAttributeTypes,useUniqueIDs:!!n,vertexColorSpace:r};return this.decodeGeometry(e,o).then(t).catch(a)}decodeGeometry(e,t){let n=JSON.stringify(t);if(Vm.has(e)){let c=Vm.get(e);if(c.key===n)return c.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let s,r=this.workerNextTaskID++,a=e.byteLength,o=this._getWorker(r,a).then(c=>(s=c,new Promise((l,h)=>{s._callbacks[r]={resolve:l,reject:h},s.postMessage({type:"decode",id:r,taskConfig:t,buffer:e},[e])}))).then(c=>this._createGeometry(c.geometry));return o.catch(()=>!0).then(()=>{s&&r&&this._releaseTask(s,r)}),Vm.set(e,{key:n,promise:o}),o}_createGeometry(e){let t=new pn;e.index&&t.setIndex(new Qt(e.index.array,1));for(let n=0;n<e.attributes.length;n++){let{name:s,array:r,itemSize:a,stride:o,vertexColorSpace:c}=e.attributes[n],l;if(a===o)l=new Qt(r,a);else{let h=new hr(r,o);l=new ur(h,a,0)}s==="color"&&(this._assignVertexColorSpace(l,c),l.normalized=!(r instanceof Float32Array)),t.setAttribute(s,l)}return t}_assignVertexColorSpace(e,t){if(t!==Jt)return;let n=new He;for(let s=0,r=e.count;s<r;s++)n.fromBufferAttribute(e,s),gt.colorSpaceToWorking(n,Jt),e.setXYZ(s,n.r,n.g,n.b)}_loadLibrary(e,t){let n=new ms(this.manager);return n.setResponseType(t),n.setWithCredentials(this.withCredentials),new Promise((s,r)=>{n.load(e,s,void 0,r)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;let e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[],{decoderPaths:n}=this;if(e){if(n.dep_js===null)throw new Error("THREE.DRACOLoader: WebAssembly is required when using a custom decoder paths.");t.push(this._loadLibrary(n.dep_js,"text"))}else t.push(this._loadLibrary(n.js,"text")),t.push(this._loadLibrary(n.wasm,"arraybuffer"));return this.decoderPending=Promise.all(t).then(s=>{let r=s[0];e||(this.decoderConfig.wasmBinary=s[1]);let a=y2.toString(),o=["/* draco decoder */",r,"","/* worker */",a.substring(a.indexOf("{")+1,a.lastIndexOf("}"))].join(`
+`);this.workerSourceURL=URL.createObjectURL(new Blob([o]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){let s=new Worker(this.workerSourceURL);s._callbacks={},s._taskCosts={},s._taskLoad=0,s.postMessage({type:"init",decoderConfig:this.decoderConfig}),s.onmessage=function(r){let a=r.data;switch(a.type){case"decode":s._callbacks[a.id].resolve(a);break;case"error":s._callbacks[a.id].reject(a);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+a.type+'"')}},this.workerPool.push(s)}else this.workerPool.sort(function(s,r){return s._taskLoad>r._taskLoad?-1:1});let n=this.workerPool[this.workerPool.length-1];return n._taskCosts[e]=t,n._taskLoad+=t,n})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}}});var Vx={};er(Vx,{MeshoptDecoder:()=>v2});var v2,Gx=un(()=>{v2=(function(){var i="b9H79Tebbbe8Fv9Gbb9Gvuuuuueu9Giuuub9Geueu9Giuuueuixkbeeeddddillviebeoweuecj:Gdkr;Neqo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbeY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVbdE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbiL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtblK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949WboY9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVJ9V29VVbrl79IV9Rbwq:VZkdbk:XYi5ud9:du8Jjjjjbcj;kb9Rgv8Kjjjjbc9:hodnalTmbcuhoaiRbbgrc;WeGc:Ge9hmbarcsGgwce0mbc9:hoalcufadcd4cbawEgDadfgrcKcaawEgqaraq0Egk6mbaicefhxcj;abad9Uc;WFbGcjdadca0EhmaialfgPar9Rgoadfhsavaoadz:jjjjbgzceVhHcbhOdndninaeaO9nmeaPax9RaD6mdamaeaO9RaOamfgoae6EgAcsfglc9WGhCabaOad2fhXaAcethQaxaDfhiaOaeaoaeao6E9RhLalcl4cifcd4hKazcj;cbfaAfhYcbh8AazcjdfhEaHh3incbh5dnawTmbaxa8Acd4fRbbh5kcbh8Eazcj;cbfhqinaih8Fdndndndna5a8Ecet4ciGgoc9:fPdebdkaPa8F9RaA6mrazcj;cbfa8EaA2fa8FaAz:jjjjb8Aa8FaAfhixdkazcj;cbfa8EaA2fcbaAz:kjjjb8Aa8FhixekaPa8F9RaK6mva8FaKfhidnaCTmbaPai9RcK6mbaocdtc:q:G:cjbfcj:G:cjbawEhaczhrcbhlinargoc9Wfghaqfhrdndndndndndnaaa8Fahco4fRbbalcoG4ciGcdtfydbPDbedvivvvlvkar9cb83bwar9cb83bbxlkarcbaiRbdai8Xbb9c:c:qj:bw9:9c:q;c1:I1e:d9c:b:c:e1z9:gg9cjjjjjz:dg8J9qE86bbaqaofgrcGfcbaicdfa8J9c8N1:NfghRbbag9cjjjjjw:dg8J9qE86bbarcVfcbaha8J9c8M1:NfghRbbag9cjjjjjl:dg8J9qE86bbarc7fcbaha8J9c8L1:NfghRbbag9cjjjjjd:dg8J9qE86bbarctfcbaha8J9c8K1:NfghRbbag9cjjjjje:dg8J9qE86bbarc91fcbaha8J9c8J1:NfghRbbag9cjjjj;ab:dg8J9qE86bbarc4fcbaha8J9cg1:NfghRbbag9cjjjja:dg8J9qE86bbarc93fcbaha8J9ch1:NfghRbbag9cjjjjz:dgg9qE86bbarc94fcbahag9ca1:NfghRbbai8Xbe9c:c:qj:bw9:9c:q;c1:I1e:d9c:b:c:e1z9:gg9cjjjjjz:dg8J9qE86bbarc95fcbaha8J9c8N1:NfgiRbbag9cjjjjjw:dg8J9qE86bbarc96fcbaia8J9c8M1:NfgiRbbag9cjjjjjl:dg8J9qE86bbarc97fcbaia8J9c8L1:NfgiRbbag9cjjjjjd:dg8J9qE86bbarc98fcbaia8J9c8K1:NfgiRbbag9cjjjjje:dg8J9qE86bbarc99fcbaia8J9c8J1:NfgiRbbag9cjjjj;ab:dg8J9qE86bbarc9:fcbaia8J9cg1:NfgiRbbag9cjjjja:dg8J9qE86bbarcufcbaia8J9ch1:NfgiRbbag9cjjjjz:dgg9qE86bbaiag9ca1:NfhixikaraiRblaiRbbghco4g8Ka8KciSg8KE86bbaqaofgrcGfaiclfa8Kfg8KRbbahcl4ciGg8La8LciSg8LE86bbarcVfa8Ka8Lfg8KRbbahcd4ciGg8La8LciSg8LE86bbarc7fa8Ka8Lfg8KRbbahciGghahciSghE86bbarctfa8Kahfg8KRbbaiRbeghco4g8La8LciSg8LE86bbarc91fa8Ka8Lfg8KRbbahcl4ciGg8La8LciSg8LE86bbarc4fa8Ka8Lfg8KRbbahcd4ciGg8La8LciSg8LE86bbarc93fa8Ka8Lfg8KRbbahciGghahciSghE86bbarc94fa8Kahfg8KRbbaiRbdghco4g8La8LciSg8LE86bbarc95fa8Ka8Lfg8KRbbahcl4ciGg8La8LciSg8LE86bbarc96fa8Ka8Lfg8KRbbahcd4ciGg8La8LciSg8LE86bbarc97fa8Ka8Lfg8KRbbahciGghahciSghE86bbarc98fa8KahfghRbbaiRbigico4g8Ka8KciSg8KE86bbarc99faha8KfghRbbaicl4ciGg8Ka8KciSg8KE86bbarc9:faha8KfghRbbaicd4ciGg8Ka8KciSg8KE86bbarcufaha8KfgrRbbaiciGgiaiciSgiE86bbaraifhixdkaraiRbwaiRbbghcl4g8Ka8KcsSg8KE86bbaqaofgrcGfaicwfa8Kfg8KRbbahcsGghahcsSghE86bbarcVfa8KahfghRbbaiRbeg8Kcl4g8La8LcsSg8LE86bbarc7faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarctfaha8KfghRbbaiRbdg8Kcl4g8La8LcsSg8LE86bbarc91faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc4faha8KfghRbbaiRbig8Kcl4g8La8LcsSg8LE86bbarc93faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc94faha8KfghRbbaiRblg8Kcl4g8La8LcsSg8LE86bbarc95faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc96faha8KfghRbbaiRbvg8Kcl4g8La8LcsSg8LE86bbarc97faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc98faha8KfghRbbaiRbog8Kcl4g8La8LcsSg8LE86bbarc99faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc9:faha8KfghRbbaiRbrgicl4g8Ka8KcsSg8KE86bbarcufaha8KfgrRbbaicsGgiaicsSgiE86bbaraifhixekarai8Pbw83bwarai8Pbb83bbaiczfhikdnaoaC9pmbalcdfhlaoczfhraPai9RcL0mekkaoaC6moaimexokaCmva8FTmvkaqaAfhqa8Ecefg8Ecl9hmbkdndndndnawTmbasa8Acd4fRbbgociGPlbedrbkaATmdaza8Afh8Fazcj;cbfhhcbh8EaEhaina8FRbbhraahocbhlinaoahalfRbbgqce4cbaqceG9R7arfgr86bbaoadfhoaAalcefgl9hmbkaacefhaa8Fcefh8FahaAfhha8Ecefg8Ecl9hmbxikkaATmeaza8Afhaazcj;cbfhhcbhoceh8EaYh8FinaEaofhlaa8Vbbhrcbhoinala8FaofRbbcwtahaofRbbgqVc;:FiGce4cbaqceG9R7arfgr87bbaladfhlaLaocefgofmbka8FaQfh8FcdhoaacdfhaahaQfhha8EceGhlcbh8EalmbxdkkaATmbaocl4h8Eaza8AfRbbhqcwhoa3hlinalRbbaotaqVhqalcefhlaocwfgoca9hmbkcbhhaEh8FaYhainazcj;cbfahfRbbhrcwhoaahlinalRbbaotarVhralaAfhlaocwfgoca9hmbkara8E94aq7hqcbhoa8Fhlinalaqao486bbalcefhlaocwfgoca9hmbka8Fadfh8FaacefhaahcefghaA9hmbkkaEclfhEa3clfh3a8Aclfg8Aad6mbkaXazcjdfaAad2z:jjjjb8AazazcjdfaAcufad2fadz:jjjjb8AaAaOfhOaihxaimbkc9:hoxdkcbc99aPax9RakSEhoxekc9:hokavcj;kbf8Kjjjjbaok:ysezu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnalaeci9UgrcHf6mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecjez:kjjjb8Aav9cu83iUav9cu83i8Wav9cu83iyav9cu83iaav9cu83iKav9cu83izav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhldnaeTmbcmcsaDceSEhkcbhxcbhmcbhrcbhicbhoindnalaq9nmbc9:hoxikdndnawRbbgDc;Ve0mbavc;abfaoaDcu7gPcl4fcsGcitfgsydlhzasydbhHdndnaDcsGgsak9pmbavaiaPfcsGcdtfydbaxasEhDaxasTgOfhxxekdndnascsSmbcehOasc987asamffcefhDxekalcefhDal8SbbgscFeGhPdndnascu9mmbaDhlxekalcvfhlaPcFbGhPcrhsdninaD8SbbgOcFbGastaPVhPaOcu9kmeaDcefhDascrfgsc8J9hmbxdkkaDcefhlkcehOaPce4cbaPceG9R7amfhDkaDhmkavc;abfaocitfgsaDBdbasazBdlavaicdtfaDBdbavc;abfaocefcsGcitfgsaHBdbasaDBdlaocdfhoaOaifhidnadcd9hmbabarcetfgsaH87ebasclfaD87ebascdfaz87ebxdkabarcdtfgsaHBdbascwfaDBdbasclfazBdbxekdnaDcpe0mbavaiaqaDcsGfRbbgscl4gP9RcsGcdtfydbaxcefgOaPEhDavaias9RcsGcdtfydbaOaPTgzfgOascsGgPEhsaPThPdndnadcd9hmbabarcetfgHax87ebaHclfas87ebaHcdfaD87ebxekabarcdtfgHaxBdbaHcwfasBdbaHclfaDBdbkavaicdtfaxBdbavc;abfaocitfgHaDBdbaHaxBdlavaicefgicsGcdtfaDBdbavc;abfaocefcsGcitfgHasBdbaHaDBdlavaiazfgicsGcdtfasBdbavc;abfaocdfcsGcitfgDaxBdbaDasBdlaocifhoaiaPfhiaOaPfhxxekaxcbalRbbgsEgHaDc;:eSgDfhOascsGhAdndnascl4gCmbaOcefhzxekaOhzavaiaC9RcsGcdtfydbhOkdndnaAmbazcefhxxekazhxavaias9RcsGcdtfydbhzkdndnaDTmbalcefhDxekalcdfhDal8SbegPcFeGhsdnaPcu9kmbalcofhHascFbGhscrhldninaD8SbbgPcFbGaltasVhsaPcu9kmeaDcefhDalcrfglc8J9hmbkaHhDxekaDcefhDkasce4cbasceG9R7amfgmhHkdndnaCcsSmbaDhsxekaDcefhsaD8SbbglcFeGhPdnalcu9kmbaDcvfhOaPcFbGhPcrhldninas8SbbgDcFbGaltaPVhPaDcu9kmeascefhsalcrfglc8J9hmbkaOhsxekascefhskaPce4cbaPceG9R7amfgmhOkdndnaAcsSmbashlxekascefhlas8SbbgDcFeGhPdnaDcu9kmbascvfhzaPcFbGhPcrhDdninal8SbbgscFbGaDtaPVhPascu9kmealcefhlaDcrfgDc8J9hmbkazhlxekalcefhlkaPce4cbaPceG9R7amfgmhzkdndnadcd9hmbabarcetfgDaH87ebaDclfaz87ebaDcdfaO87ebxekabarcdtfgDaHBdbaDcwfazBdbaDclfaOBdbkavc;abfaocitfgDaOBdbaDaHBdlavaicdtfaHBdbavc;abfaocefcsGcitfgDazBdbaDaOBdlavaicefgicsGcdtfaOBdbavc;abfaocdfcsGcitfgDaHBdbaDazBdlavaiaCTaCcsSVfgicsGcdtfazBdbaiaATaAcsSVfhiaocifhokawcefhwaocsGhoaicsGhiarcifgrae6mbkkcbc99alaqSEhokavc;aef8Kjjjjbaok:clevu8Jjjjjbcz9Rhvdnalaecvf9pmbc9:skdnaiRbbc;:eGc;qeSmbcuskav9cb83iwaicefhoaialfc98fhrdnaeTmbdnadcdSmbcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcdtfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgiBdbalaiBdbawcefgwae9hmbxdkkcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcetfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgi87ebalaiBdbawcefgwae9hmbkkcbc99aoarSEk:Lvoeue99dud99eud99dndnadcl9hmbaeTmeindndnabcdfgd8Sbb:Yab8Sbbgi:Ygl:l:tabcefgv8Sbbgo:Ygr:l:tgwJbb;:9cawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai86bbdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad86bbdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad86bbabclfhbaecufgembxdkkaeTmbindndnabclfgd8Ueb:Yab8Uebgi:Ygl:l:tabcdfgv8Uebgo:Ygr:l:tgwJb;:FSawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai87ebdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad87ebdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad87ebabcwfhbaecufgembkkk:4ioiue99dud99dud99dnaeTmbcbhiabhlindndnal8Uebgv:YgoJ:ji:1Salcof8UebgrciVgw:Y:vgDNJbbbZJbbb:;avcu9kEMgq:lJbbb9p9DTmbaq:Ohkxekcjjjj94hkkalclf8Uebhvalcdf8UebhxalarcefciGcetfak87ebdndnax:YgqaDNJbbbZJbbb:;axcu9kEMgm:lJbbb9p9DTmbam:Ohxxekcjjjj94hxkabaiarciGgkfcd7cetfax87ebdndnav:YgmaDNJbbbZJbbb:;avcu9kEMgP:lJbbb9p9DTmbaP:Ohvxekcjjjj94hvkalarcufciGcetfav87ebdndnawaw2:ZgPaPMaoaoN:taqaqN:tamamN:tgoJbbbbaoJbbbb9GE:raDNJbbbZMgD:lJbbb9p9DTmbaD:Ohrxekcjjjj94hrkalakcetfar87ebalcwfhlaiclfhiaecufgembkkk9mbdnadcd4ae2gdTmbinababydbgecwtcw91:Yaece91cjjj98Gcjjj;8if::NUdbabclfhbadcufgdmbkkk:Tvirud99eudndnadcl9hmbaeTmeindndnabRbbgiabcefgl8Sbbgvabcdfgo8Sbbgrf9R:YJbbuJabcifgwRbbgdce4adVgDcd4aDVgDcl4aDVgD:Z:vgqNJbbbZMgk:lJbbb9p9DTmbak:Ohxxekcjjjj94hxkaoax86bbdndnaraif:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohoxekcjjjj94hokalao86bbdndnavaifar9R:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikabai86bbdndnaDadcetGadceGV:ZaqNJbbbZMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkawad86bbabclfhbaecufgembxdkkaeTmbindndnab8Vebgiabcdfgl8Uebgvabclfgo8Uebgrf9R:YJbFu9habcofgw8Vebgdce4adVgDcd4aDVgDcl4aDVgDcw4aDVgD:Z:vgqNJbbbZMgk:lJbbb9p9DTmbak:Ohxxekcjjjj94hxkaoax87ebdndnaraif:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohoxekcjjjj94hokalao87ebdndnavaifar9R:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikabai87ebdndnaDadcetGadceGV:ZaqNJbbbZMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkawad87ebabcwfhbaecufgembkkk9teiucbcbyd:K:G:cjbgeabcifc98GfgbBd:K:G:cjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaik;LeeeudndnaeabVciGTmbabhixekdndnadcz9pmbabhixekabhiinaiaeydbBdbaiclfaeclfydbBdbaicwfaecwfydbBdbaicxfaecxfydbBdbaeczfheaiczfhiadc9Wfgdcs0mbkkadcl6mbinaiaeydbBdbaeclfheaiclfhiadc98fgdci0mbkkdnadTmbinaiaeRbb86bbaicefhiaecefheadcufgdmbkkabk;aeedudndnabciGTmbabhixekaecFeGc:b:c:ew2hldndnadcz9pmbabhixekabhiinaialBdbaicxfalBdbaicwfalBdbaiclfalBdbaiczfhiadc9Wfgdcs0mbkkadcl6mbinaialBdbaiclfhiadc98fgdci0mbkkdnadTmbinaiae86bbaicefhiadcufgdmbkkabkk83dbcj:Gdk8Kbbbbdbbblbbbwbbbbbbbebbbdbbblbbbwbbbbc:K:Gdkl8W:qbb",e="b9H79TebbbeKl9Gbb9Gvuuuuueu9Giuuub9Geueuixkbbebeeddddilve9Weeeviebeoweuecj:Gdkr;Neqo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbdY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVblE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtboK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbrL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949WbwY9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVJ9V29VVbDl79IV9Rbqq:W9Dklbzik94evu8Jjjjjbcz9Rhbcbheincbhdcbhiinabcwfadfaicjuaead4ceGglE86bbaialfhiadcefgdcw9hmbkaeai86b:q:W:cjbaecitab8Piw83i:q:G:cjbaecefgecjd9hmbkk:JBl8Aud97dur978Jjjjjbcj;kb9Rgv8Kjjjjbc9:hodnalTmbcuhoaiRbbgrc;WeGc:Ge9hmbarcsGgwce0mbc9:hoalcufadcd4cbawEgDadfgrcKcaawEgqaraq0Egk6mbaialfgxar9RhodnadTgmmbavaoad;8qbbkaicefhPcj;abad9Uc;WFbGcjdadca0EhsdndndnadTmbaoadfhzcbhHinaeaH9nmdaxaP9RaD6miabaHad2fhOaPaDfhAasaeaH9RaHasfae6EgCcsfgocl4cifcd4hXavcj;cbfaoc9WGgQcetfhLavcj;cbfaQci2fhKavcj;cbfaQfhYcbh8Aaoc;ab6hEincbh3dnawTmbaPa8Acd4fRbbh3kcbh5avcj;cbfh8Eindndndndna3a5cet4ciGgoc9:fPdebdkaxaA9RaQ6mwdnaQTmbavcj;cbfa5aQ2faAaQ;8qbbkaAaCfhAxdkaQTmeavcj;cbfa5aQ2fcbaQ;8kbxekaxaA9RaX6moaoclVcbawEhraAaXfhocbhidnaEmbaxao9Rc;Gb6mbcbhlina8EalfhidndndndndndnaAalco4fRbbgqciGarfPDbedibledibkaipxbbbbbbbbbbbbbbbbpklbxlkaiaopbblaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLg8Fcdp:mea8FpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogapxiiiiiiiiiiiiiiiip8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbahaoclffagRb:q:W:cjbfhoxikaiaopbbwaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogapxssssssssssssssssp8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbahaocwffagRb:q:W:cjbfhoxdkaiaopbbbpklbaoczfhoxekaiaopbbdaoRbbghcitpbi:q:G:cjbahRb:q:W:cjbghpsaoRbeggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPpklbahaocdffagRb:q:W:cjbfhokdndndndndndnaqcd4ciGarfPDbedibledibkaiczfpxbbbbbbbbbbbbbbbbpklbxlkaiczfaopbblaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLg8Fcdp:mea8FpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogapxiiiiiiiiiiiiiiiip8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbahaoclffagRb:q:W:cjbfhoxikaiczfaopbbwaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogapxssssssssssssssssp8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbahaocwffagRb:q:W:cjbfhoxdkaiczfaopbbbpklbaoczfhoxekaiczfaopbbdaoRbbghcitpbi:q:G:cjbahRb:q:W:cjbghpsaoRbeggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPpklbahaocdffagRb:q:W:cjbfhokdndndndndndnaqcl4ciGarfPDbedibledibkaicafpxbbbbbbbbbbbbbbbbpklbxlkaicafaopbblaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLg8Fcdp:mea8FpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogapxiiiiiiiiiiiiiiiip8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbahaoclffagRb:q:W:cjbfhoxikaicafaopbbwaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogapxssssssssssssssssp8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbahaocwffagRb:q:W:cjbfhoxdkaicafaopbbbpklbaoczfhoxekaicafaopbbdaoRbbghcitpbi:q:G:cjbahRb:q:W:cjbghpsaoRbeggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPpklbahaocdffagRb:q:W:cjbfhokdndndndndndnaqco4arfPDbedibledibkaic8Wfpxbbbbbbbbbbbbbbbbpklbxlkaic8Wfaopbblaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLg8Fcdp:mea8FpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogapxiiiiiiiiiiiiiiiip8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Ngicitpbi:q:G:cjbaiRb:q:W:cjbgipsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Ngqcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbaiaoclffaqRb:q:W:cjbfhoxikaic8Wfaopbbwaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogapxssssssssssssssssp8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Ngicitpbi:q:G:cjbaiRb:q:W:cjbgipsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Ngqcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbaiaocwffaqRb:q:W:cjbfhoxdkaic8Wfaopbbbpklbaoczfhoxekaic8WfaopbbdaoRbbgicitpbi:q:G:cjbaiRb:q:W:cjbgipsaoRbegqcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPpklbaiaocdffaqRb:q:W:cjbfhokalc;abfhialcjefaQ0meaihlaxao9Rc;Fb0mbkkdnaiaQ9pmbaici4hlinaxao9RcK6mwa8EaifhqdndndndndndnaAaico4fRbbalcoG4ciGarfPDbedibledibkaqpxbbbbbbbbbbbbbbbbpkbbxlkaqaopbblaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLg8Fcdp:mea8FpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogapxiiiiiiiiiiiiiiiip8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spkbbahaoclffagRb:q:W:cjbfhoxikaqaopbbwaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogapxssssssssssssssssp8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spkbbahaocwffagRb:q:W:cjbfhoxdkaqaopbbbpkbbaoczfhoxekaqaopbbdaoRbbghcitpbi:q:G:cjbahRb:q:W:cjbghpsaoRbeggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPpkbbahaocdffagRb:q:W:cjbfhokalcdfhlaiczfgiaQ6mbkkaohAaoTmoka8EaQfh8Ea5cefg5cl9hmbkdndndndnawTmbaza8Acd4fRbbglciGPlbedwbkaQTmdavcjdfa8Afhlava8Afpbdbh8Jcbhoinalavcj;cbfaofpblbg8KaYaofpblbg8LpmbzeHdOiAlCvXoQrLg8MaLaofpblbg8NaKaofpblbgypmbzeHdOiAlCvXoQrLg8PpmbezHdiOAlvCXorQLg8Fcep9Ta8Fpxeeeeeeeeeeeeeeeegap9op9Hp9rg8Fa8Jp9Ug8Jp9Abbbaladfgla8Ja8Fa8Fpmlvorlvorlvorlvorp9Ug8Jp9Abbbaladfgla8Ja8Fa8FpmwDqkwDqkwDqkwDqkp9Ug8Jp9Abbbaladfgla8Ja8Fa8FpmxmPsxmPsxmPsxmPsp9Ug8Jp9Abbbaladfgla8Ja8Ma8PpmwDKYqk8AExm35Ps8E8Fg8Fcep9Ta8Faap9op9Hp9rg8Fp9Ug8Jp9Abbbaladfgla8Ja8Fa8Fpmlvorlvorlvorlvorp9Ug8Jp9Abbbaladfgla8Ja8Fa8FpmwDqkwDqkwDqkwDqkp9Ug8Jp9Abbbaladfgla8Ja8Fa8FpmxmPsxmPsxmPsxmPsp9Ug8Jp9Abbbaladfgla8Ja8Ka8LpmwKDYq8AkEx3m5P8Es8Fg8Ka8NaypmwKDYq8AkEx3m5P8Es8Fg8LpmbezHdiOAlvCXorQLg8Fcep9Ta8Faap9op9Hp9rg8Fp9Ug8Jp9Abbbaladfgla8Ja8Fa8Fpmlvorlvorlvorlvorp9Ug8Jp9Abbbaladfgla8Ja8Fa8FpmwDqkwDqkwDqkwDqkp9Ug8Jp9Abbbaladfgla8Ja8Fa8FpmxmPsxmPsxmPsxmPsp9Ug8Jp9Abbbaladfgla8Ja8Ka8LpmwDKYqk8AExm35Ps8E8Fg8Fcep9Ta8Faap9op9Hp9rg8Fp9Ugap9Abbbaladfglaaa8Fa8Fpmlvorlvorlvorlvorp9Ugap9Abbbaladfglaaa8Fa8FpmwDqkwDqkwDqkwDqkp9Ugap9Abbbaladfglaaa8Fa8FpmxmPsxmPsxmPsxmPsp9Ug8Jp9AbbbaladfhlaoczfgoaQ6mbxikkaQTmeavcjdfa8Afhlava8Afpbdbh8Jcbhoinalavcj;cbfaofpblbg8KaYaofpblbg8LpmbzeHdOiAlCvXoQrLg8MaLaofpblbg8NaKaofpblbgypmbzeHdOiAlCvXoQrLg8PpmbezHdiOAlvCXorQLg8Fcep:nea8Fpxebebebebebebebebgap9op:bep9rg8Fa8Jp:oeg8Jp9Abbbaladfgla8Ja8Fa8Fpmlvorlvorlvorlvorp:oeg8Jp9Abbbaladfgla8Ja8Fa8FpmwDqkwDqkwDqkwDqkp:oeg8Jp9Abbbaladfgla8Ja8Fa8FpmxmPsxmPsxmPsxmPsp:oeg8Jp9Abbbaladfgla8Ja8Ma8PpmwDKYqk8AExm35Ps8E8Fg8Fcep:nea8Faap9op:bep9rg8Fp:oeg8Jp9Abbbaladfgla8Ja8Fa8Fpmlvorlvorlvorlvorp:oeg8Jp9Abbbaladfgla8Ja8Fa8FpmwDqkwDqkwDqkwDqkp:oeg8Jp9Abbbaladfgla8Ja8Fa8FpmxmPsxmPsxmPsxmPsp:oeg8Jp9Abbbaladfgla8Ja8Ka8LpmwKDYq8AkEx3m5P8Es8Fg8Ka8NaypmwKDYq8AkEx3m5P8Es8Fg8LpmbezHdiOAlvCXorQLg8Fcep:nea8Faap9op:bep9rg8Fp:oeg8Jp9Abbbaladfgla8Ja8Fa8Fpmlvorlvorlvorlvorp:oeg8Jp9Abbbaladfgla8Ja8Fa8FpmwDqkwDqkwDqkwDqkp:oeg8Jp9Abbbaladfgla8Ja8Fa8FpmxmPsxmPsxmPsxmPsp:oeg8Jp9Abbbaladfgla8Ja8Ka8LpmwDKYqk8AExm35Ps8E8Fg8Fcep:nea8Faap9op:bep9rg8Fp:oegap9Abbbaladfglaaa8Fa8Fpmlvorlvorlvorlvorp:oegap9Abbbaladfglaaa8Fa8FpmwDqkwDqkwDqkwDqkp:oegap9Abbbaladfglaaa8Fa8FpmxmPsxmPsxmPsxmPsp:oeg8Jp9AbbbaladfhlaoczfgoaQ6mbxdkkaQTmbcbhocbalcl4gl9Rc8FGhiavcjdfa8Afhrava8Afpbdbhainaravcj;cbfaofpblbg8JaYaofpblbg8KpmbzeHdOiAlCvXoQrLg8LaLaofpblbg8MaKaofpblbg8NpmbzeHdOiAlCvXoQrLgypmbezHdiOAlvCXorQLg8Faip:Rea8Falp:Tep9qg8Faap9rgap9Abbbaradfgraaa8Fa8Fpmlvorlvorlvorlvorp9rgap9Abbbaradfgraaa8Fa8FpmwDqkwDqkwDqkwDqkp9rgap9Abbbaradfgraaa8Fa8FpmxmPsxmPsxmPsxmPsp9rgap9Abbbaradfgraaa8LaypmwDKYqk8AExm35Ps8E8Fg8Faip:Rea8Falp:Tep9qg8Fp9rgap9Abbbaradfgraaa8Fa8Fpmlvorlvorlvorlvorp9rgap9Abbbaradfgraaa8Fa8FpmwDqkwDqkwDqkwDqkp9rgap9Abbbaradfgraaa8Fa8FpmxmPsxmPsxmPsxmPsp9rgap9Abbbaradfgraaa8Ja8KpmwKDYq8AkEx3m5P8Es8Fg8Ja8Ma8NpmwKDYq8AkEx3m5P8Es8Fg8KpmbezHdiOAlvCXorQLg8Faip:Rea8Falp:Tep9qg8Fp9rgap9Abbbaradfgraaa8Fa8Fpmlvorlvorlvorlvorp9rgap9Abbbaradfgraaa8Fa8FpmwDqkwDqkwDqkwDqkp9rgap9Abbbaradfgraaa8Fa8FpmxmPsxmPsxmPsxmPsp9rgap9Abbbaradfgraaa8Ja8KpmwDKYqk8AExm35Ps8E8Fg8Faip:Rea8Falp:Tep9qg8Fp9rgap9Abbbaradfgraaa8Fa8Fpmlvorlvorlvorlvorp9rgap9Abbbaradfgraaa8Fa8FpmwDqkwDqkwDqkwDqkp9rgap9Abbbaradfgraaa8Fa8FpmxmPsxmPsxmPsxmPsp9rgap9AbbbaradfhraoczfgoaQ6mbkka8Aclfg8Aad6mbkdnaCad2goTmbaOavcjdfao;8qbbkdnammbavavcjdfaCcufad2fad;8qbbkaCaHfhHc9:hoaAhPaAmbxlkkaeTmbaDalfhrcbhocuhlinaralaD9RglfaD6mdasaeao9Raoasfae6Eaofgoae6mbkaial9RhPkcbc99axaP9RakSEhoxekc9:hokavcj;kbf8Kjjjjbaokwbz:bjjjbkNsezu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnalaeci9UgrcHf6mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecje;8kbav9cu83iUav9cu83i8Wav9cu83iyav9cu83iaav9cu83iKav9cu83izav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhldnaeTmbcmcsaDceSEhkcbhxcbhmcbhrcbhicbhoindnalaq9nmbc9:hoxikdndnawRbbgDc;Ve0mbavc;abfaoaDcu7gPcl4fcsGcitfgsydlhzasydbhHdndnaDcsGgsak9pmbavaiaPfcsGcdtfydbaxasEhDaxasTgOfhxxekdndnascsSmbcehOasc987asamffcefhDxekalcefhDal8SbbgscFeGhPdndnascu9mmbaDhlxekalcvfhlaPcFbGhPcrhsdninaD8SbbgOcFbGastaPVhPaOcu9kmeaDcefhDascrfgsc8J9hmbxdkkaDcefhlkcehOaPce4cbaPceG9R7amfhDkaDhmkavc;abfaocitfgsaDBdbasazBdlavaicdtfaDBdbavc;abfaocefcsGcitfgsaHBdbasaDBdlaocdfhoaOaifhidnadcd9hmbabarcetfgsaH87ebasclfaD87ebascdfaz87ebxdkabarcdtfgsaHBdbascwfaDBdbasclfazBdbxekdnaDcpe0mbavaiaqaDcsGfRbbgscl4gP9RcsGcdtfydbaxcefgOaPEhDavaias9RcsGcdtfydbaOaPTgzfgOascsGgPEhsaPThPdndnadcd9hmbabarcetfgHax87ebaHclfas87ebaHcdfaD87ebxekabarcdtfgHaxBdbaHcwfasBdbaHclfaDBdbkavaicdtfaxBdbavc;abfaocitfgHaDBdbaHaxBdlavaicefgicsGcdtfaDBdbavc;abfaocefcsGcitfgHasBdbaHaDBdlavaiazfgicsGcdtfasBdbavc;abfaocdfcsGcitfgDaxBdbaDasBdlaocifhoaiaPfhiaOaPfhxxekaxcbalRbbgsEgHaDc;:eSgDfhOascsGhAdndnascl4gCmbaOcefhzxekaOhzavaiaC9RcsGcdtfydbhOkdndnaAmbazcefhxxekazhxavaias9RcsGcdtfydbhzkdndnaDTmbalcefhDxekalcdfhDal8SbegPcFeGhsdnaPcu9kmbalcofhHascFbGhscrhldninaD8SbbgPcFbGaltasVhsaPcu9kmeaDcefhDalcrfglc8J9hmbkaHhDxekaDcefhDkasce4cbasceG9R7amfgmhHkdndnaCcsSmbaDhsxekaDcefhsaD8SbbglcFeGhPdnalcu9kmbaDcvfhOaPcFbGhPcrhldninas8SbbgDcFbGaltaPVhPaDcu9kmeascefhsalcrfglc8J9hmbkaOhsxekascefhskaPce4cbaPceG9R7amfgmhOkdndnaAcsSmbashlxekascefhlas8SbbgDcFeGhPdnaDcu9kmbascvfhzaPcFbGhPcrhDdninal8SbbgscFbGaDtaPVhPascu9kmealcefhlaDcrfgDc8J9hmbkazhlxekalcefhlkaPce4cbaPceG9R7amfgmhzkdndnadcd9hmbabarcetfgDaH87ebaDclfaz87ebaDcdfaO87ebxekabarcdtfgDaHBdbaDcwfazBdbaDclfaOBdbkavc;abfaocitfgDaOBdbaDaHBdlavaicdtfaHBdbavc;abfaocefcsGcitfgDazBdbaDaOBdlavaicefgicsGcdtfaOBdbavc;abfaocdfcsGcitfgDaHBdbaDazBdlavaiaCTaCcsSVfgicsGcdtfazBdbaiaATaAcsSVfhiaocifhokawcefhwaocsGhoaicsGhiarcifgrae6mbkkcbc99alaqSEhokavc;aef8Kjjjjbaok:clevu8Jjjjjbcz9Rhvdnalaecvf9pmbc9:skdnaiRbbc;:eGc;qeSmbcuskav9cb83iwaicefhoaialfc98fhrdnaeTmbdnadcdSmbcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcdtfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgiBdbalaiBdbawcefgwae9hmbxdkkcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcetfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgi87ebalaiBdbawcefgwae9hmbkkcbc99aoarSEk;Toio97eue97aec98Ghedndnadcl9hmbaeTmecbhdinababpbbbgicKp:RecKp:Sep;6eglaicwp:RecKp:Sep;6ealp;Geaiczp:RecKp:Sep;6egvp;Gep;Kep;Legopxbbbbbbbbbbbbbbbbp:2egralpxbbbjbbbjbbbjbbbjgwp9op9rp;Keglpxbb;:9cbb;:9cbb;:9cbb;:9calalp;Meaoaop;Meavaravawp9op9rp;Keglalp;Mep;Kep;Kep;Jep;Negvp;Mepxbbn0bbn0bbn0bbn0grp;KepxFbbbFbbbFbbbFbbbp9oaipxbbbFbbbFbbbFbbbFp9op9qalavp;Mearp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaoavp;Mearp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpkbbabczfhbadclfgdae6mbxdkkaeTmbcbhdinabczfgDaDpbbbgipxbbbbbbFFbbbbbbFFgwp9oabpbbbgoaipmbediwDqkzHOAKY8AEgvczp:Reczp:Sep;6eglaoaipmlvorxmPsCXQL358E8FpxFubbFubbFubbFubbp9op;6eavczp:Sep;6egvp;Gealp;Gep;Kep;Legipxbbbbbbbbbbbbbbbbp:2egralpxbbbjbbbjbbbjbbbjgqp9op9rp;Keglpxb;:FSb;:FSb;:FSb;:FSalalp;Meaiaip;Meavaravaqp9op9rp;Keglalp;Mep;Kep;Kep;Jep;Negvp;Mepxbbn0bbn0bbn0bbn0grp;KepxFFbbFFbbFFbbFFbbp9oaiavp;Mearp;Keczp:Rep9qgialavp;Mearp;KepxFFbbFFbbFFbbFFbbp9oglpmwDKYqk8AExm35Ps8E8Fp9qpkbbabaoawp9oaialpmbezHdiOAlvCXorQLp9qpkbbabcafhbadclfgdae6mbkkk;2ileue97euo97dnaec98GgiTmbcbheinabcKfpx:ji:1S:ji:1S:ji:1S:ji:1SabpbbbglabczfgvpbbbgopmlvorxmPsCXQL358E8Fgrczp:Segwpxibbbibbbibbbibbbp9qp;6egDp;NegqaDaDp;MegDaDp;KealaopmbediwDqkzHOAKY8AEgDczp:Reczp:Sep;6eglalp;MeaDczp:Sep;6egoaop;Mearczp:Reczp:Sep;6egrarp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jep;Mepxbbn0bbn0bbn0bbn0gDp;KepxFFbbFFbbFFbbFFbbgkp9oaqaop;MeaDp;Keczp:Rep9qgoaqalp;MeaDp;Keakp9oaqarp;MeaDp;Keczp:Rep9qgDpmwDKYqk8AExm35Ps8E8Fglp5eawclp:RegqpEi:T:j83ibavalp5baqpEd:T:j83ibabcwfaoaDpmbezHdiOAlvCXorQLgDp5eaqpEe:T:j83ibabaDp5baqpEb:T:j83ibabcafhbaeclfgeai6mbkkkuee97dnadcd4ae2c98GgeTmbcbhdinababpbbbgicwp:Recwp:Sep;6eaicep:SepxbbjFbbjFbbjFbbjFp9opxbbjZbbjZbbjZbbjZp:Uep;Mepkbbabczfhbadclfgdae6mbkkk:Sodw97euaec98Ghedndnadcl9hmbaeTmecbhdinabpxbbuJbbuJbbuJbbuJabpbbbgicKp:TeglaicYp:Tep9qgvcdp:Teavp9qgvclp:Teavp9qgop;6ep;Negvaicwp:RecKp:SegraipxFbbbFbbbFbbbFbbbgwp9ogDp:Uep;6ep;Mepxbbn0bbn0bbn0bbn0gqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9oavaDarp:Xeaiczp:RecKp:Segip:Uep;6ep;Meaqp;Keawp9op9qavaDaraip:Uep:Xep;6ep;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qavaoalcep:Rep9oalpxebbbebbbebbbebbbp9op9qp;6ep;Meaqp;KecKp:Rep9qpkbbabczfhbadclfgdae6mbxdkkaeTmbcbhdinabczfgkpxbFu9hbFu9hbFu9hbFu9habpbbbglakpbbbgrpmlvorxmPsCXQL358E8Fgvczp:TegqavcHp:Tep9qgicdp:Teaip9qgiclp:Teaip9qgicwp:Teaip9qgop;6ep;NegialarpmbediwDqkzHOAKY8AEgDpxFFbbFFbbFFbbFFbbglp9ograDczp:Segwp:Ueavczp:Reczp:SegDp:Xep;6ep;Mepxbbn0bbn0bbn0bbn0gvp;Kealp9oaiarawaDp:Uep:Xep;6ep;Meavp;Keczp:Rep9qgwaiaoaqcep:Rep9oaqpxebbbebbbebbbebbbp9op9qp;6ep;Meavp;Keczp:ReaiaDarp:Uep;6ep;Meavp;Kealp9op9qgipmwDKYqk8AExm35Ps8E8FpkbbabawaipmbezHdiOAlvCXorQLpkbbabcafhbadclfgdae6mbkkk9teiucbcbydj:G:cjbgeabcifc98GfgbBdj:G:cjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaikkxebcj:Gdklz:zbb",t=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]),n=new Uint8Array([32,0,65,2,1,106,34,33,3,128,11,4,13,64,6,253,10,7,15,116,127,5,8,12,40,16,19,54,20,9,27,255,113,17,42,67,24,23,146,148,18,14,22,45,70,69,56,114,101,21,25,63,75,136,108,28,118,29,73,115]);if(typeof WebAssembly!="object")return{supported:!1};var s=WebAssembly.validate(t)?o(e):o(i),r,a=WebAssembly.instantiate(s,{}).then(function(g){r=g.instance,r.exports.__wasm_call_ctors()});function o(g){for(var E=new Uint8Array(g.length),L=0;L<g.length;++L){var S=g.charCodeAt(L);E[L]=S>96?S-97:S>64?S-39:S+4}for(var M=0,L=0;L<g.length;++L)E[M++]=E[L]<60?n[E[L]]:(E[L]-60)*64+E[++L];return E.buffer.slice(0,M)}function c(g,E,L,S,M,A,I){var y=g.exports.sbrk,C=S+3&-4,k=y(C*M),z=y(A.length),$=new Uint8Array(g.exports.memory.buffer);$.set(A,z);var K=E(k,S,M,z,A.length);if(K==0&&I&&I(k,C,M),L.set($.subarray(k,k+S*M)),y(k-y(0)),K!=0)throw new Error("Malformed buffer data: "+K)}var l={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp",COLOR:"meshopt_decodeFilterColor"},h={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"},u=[],d=0;function p(g){var E={object:new Worker(g),pending:0,requests:{}};return E.object.onmessage=function(L){var S=L.data;E.pending-=S.count,E.requests[S.id][S.action](S.value),delete E.requests[S.id]},E}function b(g){for(var E="self.ready = WebAssembly.instantiate(new Uint8Array(["+new Uint8Array(s)+"]), {}).then(function(result) { result.instance.exports.__wasm_call_ctors(); return result.instance; });self.onmessage = "+_.name+";"+c.toString()+_.toString(),L=new Blob([E],{type:"text/javascript"}),S=URL.createObjectURL(L),M=u.length;M<g;++M)u[M]=p(S);for(var M=g;M<u.length;++M)u[M].object.postMessage({});u.length=g,URL.revokeObjectURL(S)}function v(g,E,L,S,M){for(var A=u[0],I=1;I<u.length;++I)u[I].pending<A.pending&&(A=u[I]);return new Promise(function(y,C){var k=new Uint8Array(L),z=++d;A.pending+=g,A.requests[z]={resolve:y,reject:C},A.object.postMessage({id:z,count:g,size:E,source:k,mode:S,filter:M},[k.buffer])})}function _(g){var E=g.data;self.ready.then(function(L){if(!E.id)return self.close();try{var S=new Uint8Array(E.count*E.size);c(L,L.exports[E.mode],S,E.count,E.size,E.source,L.exports[E.filter]),self.postMessage({id:E.id,count:E.count,action:"resolve",value:S},[S.buffer])}catch(M){self.postMessage({id:E.id,count:E.count,action:"reject",value:M})}})}return{ready:a,supported:!0,useWorkers:function(g){b(g)},decodeVertexBuffer:function(g,E,L,S,M){c(r,r.exports.meshopt_decodeVertexBuffer,g,E,L,S,r.exports[l[M]])},decodeIndexBuffer:function(g,E,L,S){c(r,r.exports.meshopt_decodeIndexBuffer,g,E,L,S)},decodeIndexSequence:function(g,E,L,S){c(r,r.exports.meshopt_decodeIndexSequence,g,E,L,S)},decodeGltfBuffer:function(g,E,L,S,M,A){c(r,r.exports[h[M]],g,E,L,S,r.exports[l[A]])},decodeGltfBufferAsync:function(g,E,L,S,M){return u.length>0?v(g,E,L,h[S],l[M]):a.then(function(){var A=new Uint8Array(g*E);return c(r,r.exports[h[S]],A,g,E,L,r.exports[l[M]]),A})}}})()});function S2(i){typeof i=="string"&&i&&($x=i.endsWith("/")?i:`${i}/`)}function qx(){return Gm||(Gm=Promise.resolve().then(()=>(Gx(),Vx)).then(i=>i.MeshoptDecoder).catch(()=>null)),Gm}function $u(){if(vo)return vo;vo=new Hu;let i=new Wu;return i.setDecoderPath($x),vo.setDRACOLoader(i),qx().then(e=>{e&&vo.setMeshoptDecoder(e)}),vo}async function jx(){let i=$u();return await qx(),i}var Wx,vo,$x,Gm,qu=un(()=>{"use strict";zx();Hx();Wx="https://cdn.jsdelivr.net/npm/[email protected]/examples/jsm/libs/draco/gltf/",vo=null,$x=Wx,Gm=null});function ng(i){let e=i&&i.length?i.length/4:0;if(!e)return{intensity:.4,tint:{r:1,g:1,b:1}};let t=0,n=0,s=0,r=0;for(let h=0;h<i.length;h+=4){let u=i[h],d=i[h+1],p=i[h+2];t+=u,n+=d,s+=p,r+=.2126*u+.7152*d+.0722*p}let a=r/e/255,o=Math.min(1.35,Math.max(.4,.35+a*1.25)),c=(t+n+s)/(e*3);if(c<=6)return{intensity:o,tint:{r:1,g:1,b:1}};let l=h=>1+(h/e/c-1)*.33;return{intensity:o,tint:{r:l(t),g:l(n),b:l(s)}}}function Vc(i,{skinned:e=!1}={}){let t=Number(i?.max?.x)-Number(i?.min?.x),n=Number(i?.max?.y)-Number(i?.min?.y),s=Number(i?.max?.z)-Number(i?.min?.z);if(![t,n,s].every(l=>Number.isFinite(l)&&l>=0))return{scale:1,yOffset:0};let r=Math.max(t,n,s);if(r<=1e-6)return{scale:1,yOffset:0};let a;e&&n>1e-6?a=1.65/n:a=.75/r,a>.5&&a<2&&(a=1);let o=Number(i.min.y),c=Number.isFinite(o)?-o*a:0;return{scale:a,yOffset:c}}function ig(i,e,t=1.6){let n=Number(e?.x)||0,s=Number(e?.z)||0,r=Math.hypot(n,s),a=r>1e-4?n/r:0,o=r>1e-4?s/r:-1,c=(Number(i?.x)||0)+a*t,l=(Number(i?.z)||0)+o*t;return{x:c,z:l}}function sg(i,e){if(!Number.isFinite(i)||!Number.isFinite(e))return 0;let t=e-i;for(;t>Math.PI;)t-=2*Math.PI;for(;t<=-Math.PI;)t+=2*Math.PI;return t}function Qu(i){return Math.atan2(i[1].clientY-i[0].clientY,i[1].clientX-i[0].clientX)}function Er(i){let e=String(i??"").trim();if(!e)return null;if(e.startsWith("/")&&!e.startsWith("//"))return e;try{let t=new URL(e);return t.protocol==="https:"?t.href:null}catch{return null}}function ef(i){let e=(Array.isArray(i)?i:[]).slice(0,20).map(t=>({src:String(t.src||""),title:String(t.title||"").slice(0,120),x:Number(t.x)||0,z:Number(t.z)||0,yaw:Number(t.yaw)||0,scale:Ju(Number(t.scale)||1,.25,4)})).filter(t=>Er(t.src));return JSON.stringify({v:1,items:e})}function tf(i){let e;try{e=JSON.parse(i??"null")}catch{return[]}if(!e||e.v!==1||!Array.isArray(e.items))return[];let t=[];for(let n of e.items){if(t.length>=20)break;let s=Er(n?.src);if(!s)continue;let r=Number(n.x),a=Number(n.z);!Number.isFinite(r)||!Number.isFinite(a)||t.push({src:s,title:String(n.title||"").slice(0,120),x:Ju(r,-50,50),z:Ju(a,-50,50),yaw:Number.isFinite(Number(n.yaw))?Number(n.yaw):0,scale:Ju(Number(n.scale)||1,.25,4)})}return t}function Z2(i){let e=new TextEncoder().encode(i),t="";for(let n of e)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function Q2(i){let e=String(i).replace(/-/g,"+").replace(/_/g,"/"),t=atob(e+"=".repeat((4-e.length%4)%4)),n=Uint8Array.from(t,s=>s.charCodeAt(0));return new TextDecoder().decode(n)}function Sy(i){let e=ef(i);try{return JSON.parse(e).items.length?Z2(e):""}catch{return""}}function rg(i){if(!i)return[];try{return tf(Q2(i))}catch{return[]}}function ag(i,e,t=1500){let n=nf(i,e),s=Sy(e);if(!s)return n;let r=`${n}#s=${s}`;return r.length<=t?r:n}function nf(i,e,t=4){let n=String(i||"").split("#")[0],s=(Array.isArray(e)?e:[]).map(l=>({src:Er(l.src),title:String(l.title||"").slice(0,60)})).filter(l=>l.src),r=new Set,a=s.filter(l=>r.has(l.src)?!1:(r.add(l.src),!0)).slice(0,t);if(!a.length)return n;let o=new URLSearchParams;for(let l of a)o.append("src",l.src),o.append("title",l.title);let c=n.includes("?")?"&":"?";return`${n}${c}${o.toString()}`}var X2,K2,Y2,J2,Zu,tg,Ju,sf=un(()=>{"use strict";X2=1.65,K2=.75,Y2=.25,J2=4,Zu=20,tg=1.6;Ju=(i,e,t)=>Math.min(t,Math.max(e,i))});function lI(i,e){return cI(i,e||{},0,0)}function qc(i,e){if(e){for(var t=new kn(i.length),n=0;n<i.length;++n)t[n]=i.charCodeAt(n);return t}if(Ty)return Ty.encode(i);for(var s=i.length,r=new kn(i.length+(i.length>>1)),a=0,o=function(h){r[a++]=h},n=0;n<s;++n){if(a+5>r.length){var c=new kn(a+8+(s-n<<1));c.set(r),r=c}var l=i.charCodeAt(n);l<128||e?o(l):l<2048?(o(192|l>>6),o(128|l&63)):l>55295&&l<57344?(l=65536+(l&1047552)|i.charCodeAt(++n)&1023,o(240|l>>18),o(128|l>>12&63),o(128|l>>6&63),o(128|l&63)):(o(224|l>>12),o(128|l>>6&63),o(128|l&63))}return Dy(r,0,a)}function Uy(i,e){e||(e={});var t={},n=[];ky(i,"",t,e);var s=0,r=0;for(var a in t){var o=t[a],c=o[0],l=o[1],h=l.level==0?0:8,u=qc(a),d=u.length,p=l.comment,b=p&&qc(p),v=b&&b.length,_=ug(l.extra);d>65535&&af(11);var g=h?lI(c,l):c,E=g.length,L=oI();L.p(c),n.push(Fy(l,{size:c.length,crc:L.d(),c:g,f:u,m:b,u:d!=a.length||b&&p.length!=v,o:s,compression:h})),s+=30+d+_+E,r+=76+2*(d+_)+(v||0)+E}for(var S=new kn(r+22),M=s,A=r-s,I=0;I<n.length;++I){var u=n[I];Ry(S,u.o,u,u.f,u.u,u.c.length);var y=30+u.f.length+ug(u.extra);S.set(u.c,u.o+y),Ry(S,s,u,u.f,u.u,u.c.length,u.o,u.m),s+=16+y+(u.m?u.m.length:0)}return fI(S,s,n.length,A,M),S}var kn,vi,fg,dg,pg,wy,Cy,Iy,eI,cg,Py,XF,My,lg,Ws,kt,$c,fa,kt,kt,kt,kt,rf,kt,tI,nI,Ly,Dy,iI,af,$s,Gc,og,hg,Ey,Wc,Ny,Ay,sI,Oy,rI,aI,oI,cI,Fy,Fn,ky,Ty,hI,uI,ug,Ry,fI,By=un(()=>{kn=Uint8Array,vi=Uint16Array,fg=Int32Array,dg=new kn([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),pg=new kn([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),wy=new kn([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Cy=function(i,e){for(var t=new vi(31),n=0;n<31;++n)t[n]=e+=1<<i[n-1];for(var s=new fg(t[30]),n=1;n<30;++n)for(var r=t[n];r<t[n+1];++r)s[r]=r-t[n]<<5|n;return{b:t,r:s}},Iy=Cy(dg,2),eI=Iy.b,cg=Iy.r;eI[28]=258,cg[258]=28;Py=Cy(pg,0),XF=Py.b,My=Py.r,lg=new vi(32768);for(kt=0;kt<32768;++kt)Ws=(kt&43690)>>1|(kt&21845)<<1,Ws=(Ws&52428)>>2|(Ws&13107)<<2,Ws=(Ws&61680)>>4|(Ws&3855)<<4,lg[kt]=((Ws&65280)>>8|(Ws&255)<<8)>>1;$c=(function(i,e,t){for(var n=i.length,s=0,r=new vi(e);s<n;++s)i[s]&&++r[i[s]-1];var a=new vi(e);for(s=1;s<e;++s)a[s]=a[s-1]+r[s-1]<<1;var o;if(t){o=new vi(1<<e);var c=15-e;for(s=0;s<n;++s)if(i[s])for(var l=s<<4|i[s],h=e-i[s],u=a[i[s]-1]++<<h,d=u|(1<<h)-1;u<=d;++u)o[lg[u]>>c]=l}else for(o=new vi(n),s=0;s<n;++s)i[s]&&(o[s]=lg[a[i[s]-1]++]>>15-i[s]);return o}),fa=new kn(288);for(kt=0;kt<144;++kt)fa[kt]=8;for(kt=144;kt<256;++kt)fa[kt]=9;for(kt=256;kt<280;++kt)fa[kt]=7;for(kt=280;kt<288;++kt)fa[kt]=8;rf=new kn(32);for(kt=0;kt<32;++kt)rf[kt]=5;tI=$c(fa,9,0),nI=$c(rf,5,0),Ly=function(i){return(i+7)/8|0},Dy=function(i,e,t){return(e==null||e<0)&&(e=0),(t==null||t>i.length)&&(t=i.length),new kn(i.subarray(e,t))},iI=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],af=function(i,e,t){var n=new Error(e||iI[i]);if(n.code=i,Error.captureStackTrace&&Error.captureStackTrace(n,af),!t)throw n;return n},$s=function(i,e,t){t<<=e&7;var n=e/8|0;i[n]|=t,i[n+1]|=t>>8},Gc=function(i,e,t){t<<=e&7;var n=e/8|0;i[n]|=t,i[n+1]|=t>>8,i[n+2]|=t>>16},og=function(i,e){for(var t=[],n=0;n<i.length;++n)i[n]&&t.push({s:n,f:i[n]});var s=t.length,r=t.slice();if(!s)return{t:Oy,l:0};if(s==1){var a=new kn(t[0].s+1);return a[t[0].s]=1,{t:a,l:1}}t.sort(function(M,A){return M.f-A.f}),t.push({s:-1,f:25001});var o=t[0],c=t[1],l=0,h=1,u=2;for(t[0]={s:-1,f:o.f+c.f,l:o,r:c};h!=s-1;)o=t[t[l].f<t[u].f?l++:u++],c=t[l!=h&&t[l].f<t[u].f?l++:u++],t[h++]={s:-1,f:o.f+c.f,l:o,r:c};for(var d=r[0].s,n=1;n<s;++n)r[n].s>d&&(d=r[n].s);var p=new vi(d+1),b=hg(t[h-1],p,0);if(b>e){var n=0,v=0,_=b-e,g=1<<_;for(r.sort(function(A,I){return p[I.s]-p[A.s]||A.f-I.f});n<s;++n){var E=r[n].s;if(p[E]>e)v+=g-(1<<b-p[E]),p[E]=e;else break}for(v>>=_;v>0;){var L=r[n].s;p[L]<e?v-=1<<e-p[L]++-1:++n}for(;n>=0&&v;--n){var S=r[n].s;p[S]==e&&(--p[S],++v)}b=e}return{t:new kn(p),l:b}},hg=function(i,e,t){return i.s==-1?Math.max(hg(i.l,e,t+1),hg(i.r,e,t+1)):e[i.s]=t},Ey=function(i){for(var e=i.length;e&&!i[--e];);for(var t=new vi(++e),n=0,s=i[0],r=1,a=function(c){t[n++]=c},o=1;o<=e;++o)if(i[o]==s&&o!=e)++r;else{if(!s&&r>2){for(;r>138;r-=138)a(32754);r>2&&(a(r>10?r-11<<5|28690:r-3<<5|12305),r=0)}else if(r>3){for(a(s),--r;r>6;r-=6)a(8304);r>2&&(a(r-3<<5|8208),r=0)}for(;r--;)a(s);r=1,s=i[o]}return{c:t.subarray(0,n),n:e}},Wc=function(i,e){for(var t=0,n=0;n<e.length;++n)t+=i[n]*e[n];return t},Ny=function(i,e,t){var n=t.length,s=Ly(e+2);i[s]=n&255,i[s+1]=n>>8,i[s+2]=i[s]^255,i[s+3]=i[s+1]^255;for(var r=0;r<n;++r)i[s+r+4]=t[r];return(s+4+n)*8},Ay=function(i,e,t,n,s,r,a,o,c,l,h){$s(e,h++,t),++s[256];for(var u=og(s,15),d=u.t,p=u.l,b=og(r,15),v=b.t,_=b.l,g=Ey(d),E=g.c,L=g.n,S=Ey(v),M=S.c,A=S.n,I=new vi(19),y=0;y<E.length;++y)++I[E[y]&31];for(var y=0;y<M.length;++y)++I[M[y]&31];for(var C=og(I,7),k=C.t,z=C.l,$=19;$>4&&!k[wy[$-1]];--$);var K=l+5<<3,P=Wc(s,fa)+Wc(r,rf)+a,N=Wc(s,d)+Wc(r,v)+a+14+3*$+Wc(I,k)+2*I[16]+3*I[17]+7*I[18];if(c>=0&&K<=P&&K<=N)return Ny(e,h,i.subarray(c,c+l));var O,F,H,V;if($s(e,h,1+(N<P)),h+=2,N<P){O=$c(d,p,0),F=d,H=$c(v,_,0),V=v;var Q=$c(k,z,0);$s(e,h,L-257),$s(e,h+5,A-1),$s(e,h+10,$-4),h+=14;for(var y=0;y<$;++y)$s(e,h+3*y,k[wy[y]]);h+=3*$;for(var te=[E,M],Se=0;Se<2;++Se)for(var ve=te[Se],y=0;y<ve.length;++y){var nt=ve[y]&31;$s(e,h,Q[nt]),h+=k[nt],nt>15&&($s(e,h,ve[y]>>5&127),h+=ve[y]>>12)}}else O=tI,F=fa,H=nI,V=rf;for(var y=0;y<o;++y){var je=n[y];if(je>255){var nt=je>>18&31;Gc(e,h,O[nt+257]),h+=F[nt+257],nt>7&&($s(e,h,je>>23&31),h+=dg[nt]);var Qe=je&31;Gc(e,h,H[Qe]),h+=V[Qe],Qe>3&&(Gc(e,h,je>>5&8191),h+=pg[Qe])}else Gc(e,h,O[je]),h+=F[je]}return Gc(e,h,O[256]),h+F[256]},sI=new fg([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Oy=new kn(0),rI=function(i,e,t,n,s,r){var a=r.z||i.length,o=new kn(n+a+5*(1+Math.ceil(a/7e3))+s),c=o.subarray(n,o.length-s),l=r.l,h=(r.r||0)&7;if(e){h&&(c[0]=r.r>>3);for(var u=sI[e-1],d=u>>13,p=u&8191,b=(1<<t)-1,v=r.p||new vi(32768),_=r.h||new vi(b+1),g=Math.ceil(t/3),E=2*g,L=function(ot){return(i[ot]^i[ot+1]<<g^i[ot+2]<<E)&b},S=new fg(25e3),M=new vi(288),A=new vi(32),I=0,y=0,C=r.i||0,k=0,z=r.w||0,$=0;C+2<a;++C){var K=L(C),P=C&32767,N=_[K];if(v[P]=N,_[K]=P,z<=C){var O=a-C;if((I>7e3||k>24576)&&(O>423||!l)){h=Ay(i,c,0,S,M,A,y,k,$,C-$,h),k=I=y=0,$=C;for(var F=0;F<286;++F)M[F]=0;for(var F=0;F<30;++F)A[F]=0}var H=2,V=0,Q=p,te=P-N&32767;if(O>2&&K==L(C-te))for(var Se=Math.min(d,O)-1,ve=Math.min(32767,C),nt=Math.min(258,O);te<=ve&&--Q&&P!=N;){if(i[C+H]==i[C+H-te]){for(var je=0;je<nt&&i[C+je]==i[C+je-te];++je);if(je>H){if(H=je,V=te,je>Se)break;for(var Qe=Math.min(te,je-2),fe=0,F=0;F<Qe;++F){var ge=C-te+F&32767,Ve=v[ge],it=ge-Ve&32767;it>fe&&(fe=it,N=ge)}}}P=N,N=v[P],te+=P-N&32767}if(V){S[k++]=268435456|cg[H]<<18|My[V];var Ue=cg[H]&31,ct=My[V]&31;y+=dg[Ue]+pg[ct],++M[257+Ue],++A[ct],z=C+H,++I}else S[k++]=i[C],++M[i[C]]}}for(C=Math.max(C,z);C<a;++C)S[k++]=i[C],++M[i[C]];h=Ay(i,c,l,S,M,A,y,k,$,C-$,h),l||(r.r=h&7|c[h/8|0]<<3,h-=7,r.h=_,r.p=v,r.i=C,r.w=z)}else{for(var C=r.w||0;C<a+l;C+=65535){var zt=C+65535;zt>=a&&(c[h/8|0]=l,zt=a),h=Ny(c,h+1,i.subarray(C,zt))}r.i=a}return Dy(o,0,n+Ly(h)+s)},aI=(function(){for(var i=new Int32Array(256),e=0;e<256;++e){for(var t=e,n=9;--n;)t=(t&1&&-306674912)^t>>>1;i[e]=t}return i})(),oI=function(){var i=-1;return{p:function(e){for(var t=i,n=0;n<e.length;++n)t=aI[t&255^e[n]]^t>>>8;i=t},d:function(){return~i}}},cI=function(i,e,t,n,s){if(!s&&(s={l:1},e.dictionary)){var r=e.dictionary.subarray(-32768),a=new kn(r.length+i.length);a.set(r),a.set(i,r.length),i=a,s.w=r.length}return rI(i,e.level==null?6:e.level,e.mem==null?s.l?Math.ceil(Math.max(8,Math.min(13,Math.log(i.length)))*1.5):20:12+e.mem,t,n,s)},Fy=function(i,e){var t={};for(var n in i)t[n]=i[n];for(var n in e)t[n]=e[n];return t},Fn=function(i,e,t){for(;t;++e)i[e]=t,t>>>=8};ky=function(i,e,t,n){for(var s in i){var r=i[s],a=e+s,o=n;Array.isArray(r)&&(o=Fy(n,r[1]),r=r[0]),r instanceof kn?t[a]=[r,o]:(t[a+="/"]=[new kn(0),o],ky(r,a,t,n))}},Ty=typeof TextEncoder<"u"&&new TextEncoder,hI=typeof TextDecoder<"u"&&new TextDecoder,uI=0;try{hI.decode(Oy,{stream:!0}),uI=1}catch{}ug=function(i){var e=0;if(i)for(var t in i){var n=i[t].length;n>65535&&af(9),e+=n+4}return e},Ry=function(i,e,t,n,s,r,a,o){var c=n.length,l=t.extra,h=o&&o.length,u=ug(l);Fn(i,e,a!=null?33639248:67324752),e+=4,a!=null&&(i[e++]=20,i[e++]=t.os),i[e]=20,e+=2,i[e++]=t.flag<<1|(r<0&&8),i[e++]=s&&8,i[e++]=t.compression&255,i[e++]=t.compression>>8;var d=new Date(t.mtime==null?Date.now():t.mtime),p=d.getFullYear()-1980;if((p<0||p>119)&&af(10),Fn(i,e,p<<25|d.getMonth()+1<<21|d.getDate()<<16|d.getHours()<<11|d.getMinutes()<<5|d.getSeconds()>>1),e+=4,r!=-1&&(Fn(i,e,t.crc),Fn(i,e+4,r<0?-r-2:r),Fn(i,e+8,t.size)),Fn(i,e+12,c),Fn(i,e+14,u),e+=16,a!=null&&(Fn(i,e,h),Fn(i,e+6,t.attrs),Fn(i,e+10,a),e+=14),i.set(n,e),e+=c,u)for(var b in l){var v=l[b],_=v.length;Fn(i,e,+b),Fn(i,e+2,_),i.set(v,e+4),e+=4+_}return h&&(i.set(o,e),e+=h),e},fI=function(i,e,t,n,s){Fn(i,e,101010256),Fn(i,e+8,t),Fn(i,e+10,t),Fn(i,e+12,n),Fn(i,e+16,s)}});var Jy={};er(Jy,{USDZExporter:()=>gg});function Gy(i,e){let t=i.name;return t=t.replace(/[^A-Za-z0-9_]/g,""),/^[0-9]/.test(t)&&(t="_"+t),t===""&&(i.isCamera?t="Camera":t="Object"),e.has(t)&&(t=t+"_"+i.id),e.add(t),t}function Wy(i){return i.userData.mimeType==="image/jpeg"?"jpg":"png"}function dI(i,e,t){if(typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&i instanceof OffscreenCanvas||typeof ImageBitmap<"u"&&i instanceof ImageBitmap){let n=t/Math.max(i.width,i.height),s=document.createElement("canvas");s.width=i.width*Math.min(1,n),s.height=i.height*Math.min(1,n);let r=s.getContext("2d");return e===!0&&(r.translate(0,s.height),r.scale(1,-1)),r.drawImage(i,0,0,s.width,s.height),s}else throw new Error("THREE.USDZExporter: No valid image data found. Unable to process texture.")}function $y(i=null){return`#usda 1.0
(
customLayerData = {
string creator = "Three.js USDZExporter"
}
defaultPrim = "Root"
metersPerUnit = 1
- upAxis = "Y"
+ upAxis = "Y"${i?`
+ startTimeCode = 0
+ endTimeCode = ${i.endTimeCode}
+ timeCodesPerSecond = ${i.fps}
+ framesPerSecond = ${i.fps}`:""}
)
-`}function $x(i,e,t,n,r,s){for(let a=0,o=i.children.length;a<o;a++){let l=i.children[a];if(l.visible===!1&&s.onlyVisible===!0)continue;let c;if(l.isMesh){let h=l.geometry,d=l.material;if(d.isMeshStandardMaterial){let f="geometries/Geometry_"+h.id+".usda";if(!(f in r)){let p=oR(h);r[f]=Qo(qx()+`
-`+p.toString())}d.uuid in t||(t[d.uuid]=d),c=aR(l,h,t[d.uuid],n)}else console.warn("THREE.USDZExporter: Unsupported material type (USDZ only supports MeshStandardMaterial)",l)}else l.isCamera?c=mR(l,n):c=jx(l,n);c&&(e.addChild(c),$x(l,c,t,n,r,s))}}function jx(i,e){let t=Wx(i,e);i.matrix.determinant()<0&&console.warn("THREE.USDZExporter: USDZ does not support negative scales",i);let n=new Wn(t,"Xform");if(i.pivot!==null){let r=i.position,s=i.quaternion,a=i.scale,o=i.pivot;n.addProperty(`float3 xformOp:translate = (${r.x.toPrecision(Ht)}, ${r.y.toPrecision(Ht)}, ${r.z.toPrecision(Ht)})`),n.addProperty(`float3 xformOp:translate:pivot = (${o.x.toPrecision(Ht)}, ${o.y.toPrecision(Ht)}, ${o.z.toPrecision(Ht)})`),n.addProperty(`quatf xformOp:orient = (${s.w.toPrecision(Ht)}, ${s.x.toPrecision(Ht)}, ${s.y.toPrecision(Ht)}, ${s.z.toPrecision(Ht)})`),n.addProperty(`float3 xformOp:scale = (${a.x.toPrecision(Ht)}, ${a.y.toPrecision(Ht)}, ${a.z.toPrecision(Ht)})`),n.addProperty('uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:translate:pivot", "xformOp:orient", "xformOp:scale", "!invert!xformOp:translate:pivot"]')}else{let r=Xx(i.matrix);n.addProperty(`matrix4d xformOp:transform = ${r}`),n.addProperty('uniform token[] xformOpOrder = ["xformOp:transform"]')}return n}function aR(i,e,t,n){let r=jx(i,n);return r.addMetadata("prepend references",`@./geometries/Geometry_${e.id}.usda@</Geometry>`),r.addMetadata("prepend apiSchemas",'["MaterialBindingAPI"]'),r.addProperty(`rel material:binding = </Materials/Material_${t.id}>`),r}function Xx(i){let e=i.elements;return`( ${iu(e,0)}, ${iu(e,4)}, ${iu(e,8)}, ${iu(e,12)} )`}function iu(i,e){return`(${i[e+0]}, ${i[e+1]}, ${i[e+2]}, ${i[e+3]})`}function oR(i){let e=new Wn("Geometry"),t=cR(i);return e.addChild(t),e}function cR(i){let e="Geometry",t=i.attributes,n=t.position.count,r=new Wn(e,"Mesh");r.addProperty(`int[] faceVertexCounts = [${lR(i)}]`),r.addProperty(`int[] faceVertexIndices = [${hR(i)}]`),r.addProperty(`normal3f[] normals = [${Hp(t.normal,n)}]`,['interpolation = "vertex"']),r.addProperty(`point3f[] points = [${Hp(t.position,n)}]`);for(let a=0;a<4;a++){let o=a>0?a:"",l=t["uv"+o];l!==void 0&&r.addProperty(`texCoord2f[] primvars:st${o} = [${uR(l)}]`,['interpolation = "vertex"'])}let s=t.color;return s!==void 0&&r.addProperty(`color3f[] primvars:displayColor = [${Hp(s,n)}]`,['interpolation = "vertex"']),r.addProperty('uniform token subdivisionScheme = "none"'),r}function lR(i){let e=i.index!==null?i.index.count:i.attributes.position.count;return Array(e/3).fill(3).join(", ")}function hR(i){let e=i.index,t=[];if(e!==null)for(let n=0;n<e.count;n++)t.push(e.getX(n));else{let n=i.attributes.position.count;for(let r=0;r<n;r++)t.push(r)}return t.join(", ")}function Hp(i,e){if(i===void 0)return console.warn("USDZExporter: Normals missing."),Array(e).fill("(0, 0, 0)").join(", ");let t=[];for(let n=0;n<i.count;n++){let r=i.getX(n),s=i.getY(n),a=i.getZ(n);t.push(`(${r.toPrecision(Ht)}, ${s.toPrecision(Ht)}, ${a.toPrecision(Ht)})`)}return t.join(", ")}function uR(i){let e=[];for(let t=0;t<i.count;t++){let n=i.getX(t),r=i.getY(t);e.push(`(${n.toPrecision(Ht)}, ${1-r.toPrecision(Ht)})`)}return e.join(", ")}function dR(i,e,t=!1){let n=new Wn("Materials");for(let r in i){let s=i[r];n.addChild(fR(s,e,t))}return n}function fR(i,e,t=!1){let n=new Wn(`Material_${i.id}`,"Material");function r(a,o,l){let c=a.source.id+"_"+a.flipY;e[c]=a;let h=a.channel>0?"st"+a.channel:"st",d={1e3:"repeat",1001:"clamp",1002:"mirror"},f=a.repeat.clone(),p=a.offset.clone(),x=a.rotation,y=Math.sin(x),b=Math.cos(x);p.y=1-p.y-f.y,t?(p.x=p.x/f.x,p.y=p.y/f.y,p.x+=y/f.x,p.y+=b-1):(p.x+=y*f.x,p.y+=(1-b)*f.y);let g=new Wn(`PrimvarReader_${o}`,"Shader");g.addProperty('uniform token info:id = "UsdPrimvarReader_float2"'),g.addProperty("float2 inputs:fallback = (0.0, 0.0)"),g.addProperty(`string inputs:varname = "${h}"`),g.addProperty("float2 outputs:result");let S=new Wn(`Transform2d_${o}`,"Shader");S.addProperty('uniform token info:id = "UsdTransform2d"'),S.addProperty(`float2 inputs:in.connect = </Materials/Material_${i.id}/PrimvarReader_${o}.outputs:result>`),S.addProperty(`float inputs:rotation = ${(x*(180/Math.PI)).toFixed(Ht)}`),S.addProperty(`float2 inputs:scale = ${Vx(f)}`),S.addProperty(`float2 inputs:translation = ${Vx(p)}`),S.addProperty("float2 outputs:result");let A=new Wn(`Texture_${a.id}_${o}`,"Shader");return A.addProperty('uniform token info:id = "UsdUVTexture"'),A.addProperty(`asset inputs:file = @textures/Texture_${c}.png@`),A.addProperty(`float2 inputs:st.connect = </Materials/Material_${i.id}/Transform2d_${o}.outputs:result>`),l!==void 0&&A.addProperty(`float4 inputs:scale = ${pR(l)}`),o==="normal"&&(A.addProperty("float4 inputs:scale = (2, 2, 2, 1)"),A.addProperty("float4 inputs:bias = (-1, -1, -1, 0)")),A.addProperty(`token inputs:sourceColorSpace = "${a.colorSpace===Fi?"raw":"sRGB"}"`),A.addProperty(`token inputs:wrapS = "${d[a.wrapS]}"`),A.addProperty(`token inputs:wrapT = "${d[a.wrapT]}"`),A.addProperty("float outputs:r"),A.addProperty("float outputs:g"),A.addProperty("float outputs:b"),A.addProperty("float3 outputs:rgb"),(i.transparent||i.alphaTest>0)&&A.addProperty("float outputs:a"),[g,S,A]}i.side===Dn&&console.warn("THREE.USDZExporter: USDZ does not support double sided materials",i);let s=new Wn("PreviewSurface","Shader");if(s.addProperty('uniform token info:id = "UsdPreviewSurface"'),i.map!==null?(s.addProperty(`color3f inputs:diffuseColor.connect = </Materials/Material_${i.id}/Texture_${i.map.id}_diffuse.outputs:rgb>`),i.transparent?s.addProperty(`float inputs:opacity.connect = </Materials/Material_${i.id}/Texture_${i.map.id}_diffuse.outputs:a>`):i.alphaTest>0&&(s.addProperty(`float inputs:opacity.connect = </Materials/Material_${i.id}/Texture_${i.map.id}_diffuse.outputs:a>`),s.addProperty(`float inputs:opacityThreshold = ${i.alphaTest}`)),r(i.map,"diffuse",i.color).forEach(o=>n.addChild(o))):s.addProperty(`color3f inputs:diffuseColor = ${Gx(i.color)}`),i.emissiveMap!==null){s.addProperty(`color3f inputs:emissiveColor.connect = </Materials/Material_${i.id}/Texture_${i.emissiveMap.id}_emissive.outputs:rgb>`);let a=new Ve(i.emissive.r*i.emissiveIntensity,i.emissive.g*i.emissiveIntensity,i.emissive.b*i.emissiveIntensity);r(i.emissiveMap,"emissive",a).forEach(l=>n.addChild(l))}else i.emissive.getHex()>0&&s.addProperty(`color3f inputs:emissiveColor = ${Gx(i.emissive)}`);if(i.normalMap!==null&&(s.addProperty(`normal3f inputs:normal.connect = </Materials/Material_${i.id}/Texture_${i.normalMap.id}_normal.outputs:rgb>`),r(i.normalMap,"normal").forEach(o=>n.addChild(o))),i.aoMap!==null){s.addProperty(`float inputs:occlusion.connect = </Materials/Material_${i.id}/Texture_${i.aoMap.id}_occlusion.outputs:r>`);let a=new Ve(i.aoMapIntensity,i.aoMapIntensity,i.aoMapIntensity);r(i.aoMap,"occlusion",a).forEach(l=>n.addChild(l))}if(i.roughnessMap!==null){s.addProperty(`float inputs:roughness.connect = </Materials/Material_${i.id}/Texture_${i.roughnessMap.id}_roughness.outputs:g>`);let a=new Ve(i.roughness,i.roughness,i.roughness);r(i.roughnessMap,"roughness",a).forEach(l=>n.addChild(l))}else s.addProperty(`float inputs:roughness = ${i.roughness}`);if(i.metalnessMap!==null){s.addProperty(`float inputs:metallic.connect = </Materials/Material_${i.id}/Texture_${i.metalnessMap.id}_metallic.outputs:b>`);let a=new Ve(i.metalness,i.metalness,i.metalness);r(i.metalnessMap,"metallic",a).forEach(l=>n.addChild(l))}else s.addProperty(`float inputs:metallic = ${i.metalness}`);if(i.alphaMap!==null?(s.addProperty(`float inputs:opacity.connect = </Materials/Material_${i.id}/Texture_${i.alphaMap.id}_opacity.outputs:r>`),s.addProperty("float inputs:opacityThreshold = 0.0001"),r(i.alphaMap,"opacity").forEach(o=>n.addChild(o))):s.addProperty(`float inputs:opacity = ${i.opacity}`),i.isMeshPhysicalMaterial){if(i.clearcoatMap!==null){s.addProperty(`float inputs:clearcoat.connect = </Materials/Material_${i.id}/Texture_${i.clearcoatMap.id}_clearcoat.outputs:r>`);let a=new Ve(i.clearcoat,i.clearcoat,i.clearcoat);r(i.clearcoatMap,"clearcoat",a).forEach(l=>n.addChild(l))}else s.addProperty(`float inputs:clearcoat = ${i.clearcoat}`);if(i.clearcoatRoughnessMap!==null){s.addProperty(`float inputs:clearcoatRoughness.connect = </Materials/Material_${i.id}/Texture_${i.clearcoatRoughnessMap.id}_clearcoatRoughness.outputs:g>`);let a=new Ve(i.clearcoatRoughness,i.clearcoatRoughness,i.clearcoatRoughness);r(i.clearcoatRoughnessMap,"clearcoatRoughness",a).forEach(l=>n.addChild(l))}else s.addProperty(`float inputs:clearcoatRoughness = ${i.clearcoatRoughness}`);s.addProperty(`float inputs:ior = ${i.ior}`)}return s.addProperty("int inputs:useSpecularWorkflow = 0"),s.addProperty("token outputs:surface"),n.addChild(s),n.addProperty(`token outputs:surface.connect = </Materials/Material_${i.id}/PreviewSurface.outputs:surface>`),n}function Gx(i){return`(${i.r}, ${i.g}, ${i.b})`}function pR(i){return`(${i.r}, ${i.g}, ${i.b}, 1.0)`}function Vx(i){return`(${i.x}, ${i.y})`}function mR(i,e){let t=Wx(i,e),n=Xx(i.matrix);i.matrix.determinant()<0&&console.warn("THREE.USDZExporter: USDZ does not support negative scales",i);let r=new Wn(t,"Camera");r.addProperty(`matrix4d xformOp:transform = ${n}`),r.addProperty('uniform token[] xformOpOrder = ["xformOp:transform"]');let s=i.isOrthographicCamera?"orthographic":"perspective";r.addProperty(`token projection = "${s}"`);let a=`(${i.near.toPrecision(Ht)}, ${i.far.toPrecision(Ht)})`;r.addProperty(`float2 clippingRange = ${a}`);let o;i.isOrthographicCamera?o=((Math.abs(i.left)+Math.abs(i.right))*10).toPrecision(Ht):o=i.getFilmWidth().toPrecision(Ht),r.addProperty(`float horizontalAperture = ${o}`);let l;if(i.isOrthographicCamera?l=((Math.abs(i.top)+Math.abs(i.bottom))*10).toPrecision(Ht):l=i.getFilmHeight().toPrecision(Ht),r.addProperty(`float verticalAperture = ${l}`),i.isPerspectiveCamera){let c=i.getFocalLength().toPrecision(Ht);r.addProperty(`float focalLength = ${c}`);let h=i.focus.toPrecision(Ht);r.addProperty(`float focusDistance = ${h}`)}return r}var Wn,Gp,Ht,Yx=un(()=>{Vn();Hx();Wn=class{constructor(e,t="",n=[],r=[]){this.name=e,this.type=t,this.metadata=n,this.properties=r,this.children=[]}addMetadata(e,t){this.metadata.push({key:e,value:t})}addProperty(e,t=[]){this.properties.push({property:e,metadata:t})}addChild(e){this.children.push(e)}toString(e=0){let t=" ".repeat(e),n=this.metadata.map(h=>{let d=h.key,f=h.value;if(Array.isArray(f)){let p=[];return p.push(`${d} = {`),f.forEach(x=>{p.push(`${t} ${x}`)}),p.push(`${t} }`),p.join(`
-`)}else return`${d} = ${f}`}),r=n.length?` (
+`}function pI(i,e){let t=new Map;for(let n=0;n<e.length;n++){let s=e[n];for(let r=0;r<s.tracks.length;r++){let a=s.tracks[r],o=Ot.parseTrackName(a.name),c=Ot.findNode(i,o.nodeName);if(c==null)continue;let l=o.propertyName;if(l!=="position"&&l!=="quaternion"&&l!=="scale")continue;let h=t.get(c);h===void 0&&(h={},t.set(c,h)),h[l]=a}}return t}function mI(i){let e=0;for(let t=0;t<i.length;t++)i[t].duration>e&&(e=i[t].duration);return e}function zy(i,e,t,n){let s=t.times,r=t.values,a=[];for(let o=0;o<s.length;o++){let c=o*3;a.push(`${(s[o]*n).toPrecision(wt)}: (${r[c].toPrecision(wt)}, ${r[c+1].toPrecision(wt)}, ${r[c+2].toPrecision(wt)})`)}return`${e} ${i}.timeSamples = {
+ ${a.join(`,
+ `)},
+}`}function gI(i,e){let t=i.times,n=i.values,s=[];for(let r=0;r<t.length;r++){let a=r*4;s.push(`${(t[r]*e).toPrecision(wt)}: (${n[a+3].toPrecision(wt)}, ${n[a].toPrecision(wt)}, ${n[a+1].toPrecision(wt)}, ${n[a+2].toPrecision(wt)})`)}return`quatf xformOp:orient.timeSamples = {
+ ${s.join(`,
+ `)},
+}`}function qy(i,e,t,n,s,r){for(let a=0,o=i.children.length;a<o;a++)jy(i.children[a],e,t,n,s,r)}function jy(i,e,t,n,s,r){if(i.visible===!1&&r.onlyVisible===!0)return;let a;if(i.isMesh){let o=i.geometry,c=Array.isArray(i.material),l=c?i.material:[i.material];for(let u=0;u<l.length;u++){let d=l[u];d.isMeshStandardMaterial||console.warn("THREE.USDZExporter: Use MeshStandardMaterial for best results."),d.uuid in t||(t[d.uuid]=d)}let h=l.map(u=>t[u.uuid]);if(c===!1){let u=`geometries/Geometry_${o.id}.usda`;if(!(u in s)){let d=xI(o);s[u]=qc($y()+`
+`+d.toString())}}a=bI(i,o,h,n,r)}else i.isCamera?a=AI(i,n,r):a=Ky(i,n,r);e.addChild(a),qy(i,a,t,n,s,r)}function Xy(i,e,t){let n=t.animationTracks.get(e),s=e.pivot!==null;if(!s&&n===void 0){let l=_I(e.matrix);i.addProperty(`matrix4d xformOp:transform = ${l}`),i.addProperty('uniform token[] xformOpOrder = ["xformOp:transform"]');return}let r=t.animationFrameRate,a=e.position,o=e.quaternion,c=e.scale;if(n!==void 0&&n.position!==void 0?i.addProperty(zy("xformOp:translate","float3",n.position,r)):i.addProperty(`float3 xformOp:translate = (${a.x.toPrecision(wt)}, ${a.y.toPrecision(wt)}, ${a.z.toPrecision(wt)})`),s){let l=e.pivot;i.addProperty(`float3 xformOp:translate:pivot = (${l.x.toPrecision(wt)}, ${l.y.toPrecision(wt)}, ${l.z.toPrecision(wt)})`)}n!==void 0&&n.quaternion!==void 0?i.addProperty(gI(n.quaternion,r)):i.addProperty(`quatf xformOp:orient = (${o.w.toPrecision(wt)}, ${o.x.toPrecision(wt)}, ${o.y.toPrecision(wt)}, ${o.z.toPrecision(wt)})`),n!==void 0&&n.scale!==void 0?i.addProperty(zy("xformOp:scale","float3",n.scale,r)):i.addProperty(`float3 xformOp:scale = (${c.x.toPrecision(wt)}, ${c.y.toPrecision(wt)}, ${c.z.toPrecision(wt)})`),s?i.addProperty('uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:translate:pivot", "xformOp:orient", "xformOp:scale", "!invert!xformOp:translate:pivot"]'):i.addProperty('uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:orient", "xformOp:scale"]')}function Ky(i,e,t){let n=Gy(i,e);i.matrix.determinant()<0&&console.warn("THREE.USDZExporter: USDZ does not support negative scales",i);let s=new Xn(n,"Xform");return Xy(s,i,t),s}function bI(i,e,t,n,s){let r=Ky(i,n,s);return t.length===1?(r.addMetadata("prepend references",`@./geometries/Geometry_${e.id}.usda@</Geometry>`),r.addMetadata("prepend apiSchemas",'["MaterialBindingAPI"]'),r.addProperty(`rel material:binding = </Materials/Material_${t[0].id}>`)):r.addChild(Yy(e,t)),r}function _I(i){let e=i.elements;return`( ${of(e,0)}, ${of(e,4)}, ${of(e,8)}, ${of(e,12)} )`}function of(i,e){return`(${i[e+0]}, ${i[e+1]}, ${i[e+2]}, ${i[e+3]})`}function xI(i){let e=new Xn("Geometry"),t=Yy(i);return e.addChild(t),e}function Yy(i,e=null){let t="Geometry",n=i.attributes,s=n.position.count,r=new Xn(t,"Mesh");r.addProperty(`int[] faceVertexCounts = [${yI(i)}]`),r.addProperty(`int[] faceVertexIndices = [${vI(i)}]`),r.addProperty(`normal3f[] normals = [${mg(n.normal,s)}]`,['interpolation = "vertex"']),r.addProperty(`point3f[] points = [${mg(n.position,s)}]`);for(let o=0;o<4;o++){let c=o>0?o:"",l=n["uv"+c];l!==void 0&&r.addProperty(`texCoord2f[] primvars:st${c} = [${SI(l)}]`,['interpolation = "vertex"'])}let a=n.color;if(a!==void 0&&r.addProperty(`color3f[] primvars:displayColor = [${mg(a,s)}]`,['interpolation = "vertex"']),r.addProperty('uniform token subdivisionScheme = "none"'),e!==null){let o=i.groups,c=(i.index!==null?i.index.count:n.position.count)/3;for(let l=0;l<o.length;l++){let h=o[l],u=e[h.materialIndex];if(u===void 0)continue;let d=Math.floor(h.start/3),p=Math.min(d+Math.floor(h.count/3),c),b=[];for(let _=d;_<p;_++)b.push(_);let v=new Xn(`subset_${l}`,"GeomSubset");v.addMetadata("prepend apiSchemas",'["MaterialBindingAPI"]'),v.addProperty('uniform token elementType = "face"'),v.addProperty('uniform token familyName = "materialBind"'),v.addProperty(`int[] indices = [${b.join(", ")}]`),v.addProperty(`rel material:binding = </Materials/Material_${u.id}>`),r.addChild(v)}}return r}function yI(i){let e=i.index!==null?i.index.count:i.attributes.position.count;return Array(e/3).fill(3).join(", ")}function vI(i){let e=i.index,t=[];if(e!==null)for(let n=0;n<e.count;n++)t.push(e.getX(n));else{let n=i.attributes.position.count;for(let s=0;s<n;s++)t.push(s)}return t.join(", ")}function mg(i,e){if(i===void 0)return console.warn("USDZExporter: Normals missing."),Array(e).fill("(0, 0, 0)").join(", ");let t=[];for(let n=0;n<i.count;n++){let s=i.getX(n),r=i.getY(n),a=i.getZ(n);t.push(`(${s.toPrecision(wt)}, ${r.toPrecision(wt)}, ${a.toPrecision(wt)})`)}return t.join(", ")}function SI(i){let e=[];for(let t=0;t<i.count;t++){let n=i.getX(t),s=i.getY(t);e.push(`(${n.toPrecision(wt)}, ${1-s.toPrecision(wt)})`)}return e.join(", ")}function wI(i,e,t=!1){let n=new Xn("Materials");for(let s in i){let r=i[s];n.addChild(MI(r,e,t))}return n}function MI(i,e,t=!1){let n=new Xn(`Material_${i.id}`,"Material");function s(a,o,c){let l=a.source.id+"_"+a.flipY;e[l]=a;let h=a.channel>0?"st"+a.channel:"st",u={1e3:"repeat",1001:"clamp",1002:"mirror"},d=a.repeat.clone(),p=a.offset.clone(),b=a.rotation,v=Math.sin(b),_=Math.cos(b);p.y=1-p.y-d.y,t?(p.x=p.x/d.x,p.y=p.y/d.y,p.x+=v/d.x,p.y+=_-1):(p.x+=v*d.x,p.y+=(1-_)*d.y);let g=new Xn(`PrimvarReader_${o}`,"Shader");g.addProperty('uniform token info:id = "UsdPrimvarReader_float2"'),g.addProperty("float2 inputs:fallback = (0.0, 0.0)"),g.addProperty(`string inputs:varname = "${h}"`),g.addProperty("float2 outputs:result");let E=new Xn(`Transform2d_${o}`,"Shader");E.addProperty('uniform token info:id = "UsdTransform2d"'),E.addProperty(`float2 inputs:in.connect = </Materials/Material_${i.id}/PrimvarReader_${o}.outputs:result>`),E.addProperty(`float inputs:rotation = ${(b*(180/Math.PI)).toFixed(wt)}`),E.addProperty(`float2 inputs:scale = ${Vy(d)}`),E.addProperty(`float2 inputs:translation = ${Vy(p)}`),E.addProperty("float2 outputs:result");let L=new Xn(`Texture_${a.id}_${o}`,"Shader");if(L.addProperty('uniform token info:id = "UsdUVTexture"'),L.addProperty(`asset inputs:file = @textures/Texture_${l}.${Wy(a)}@`),L.addProperty(`float2 inputs:st.connect = </Materials/Material_${i.id}/Transform2d_${o}.outputs:result>`),c!==void 0){let S=o==="diffuse"?i.opacity:1;L.addProperty(`float4 inputs:scale = ${EI(c,S)}`)}if(o==="normal"){let S=i.normalScale.x;L.addProperty(`float4 inputs:scale = (${2*S}, ${2*S}, 2, 1)`),L.addProperty(`float4 inputs:bias = (${-S}, ${-S}, -1, 0)`)}return L.addProperty(`token inputs:sourceColorSpace = "${a.colorSpace===Qi?"raw":"sRGB"}"`),L.addProperty(`token inputs:wrapS = "${u[a.wrapS]}"`),L.addProperty(`token inputs:wrapT = "${u[a.wrapT]}"`),L.addProperty("float outputs:r"),L.addProperty("float outputs:g"),L.addProperty("float outputs:b"),L.addProperty("float3 outputs:rgb"),(i.transparent||i.alphaTest>0)&&L.addProperty("float outputs:a"),[g,E,L]}i.side===$n&&console.warn("THREE.USDZExporter: USDZ does not support double sided materials",i);let r=new Xn("PreviewSurface","Shader");if(r.addProperty('uniform token info:id = "UsdPreviewSurface"'),i.map!==null?(r.addProperty(`color3f inputs:diffuseColor.connect = </Materials/Material_${i.id}/Texture_${i.map.id}_diffuse.outputs:rgb>`),i.transparent?r.addProperty(`float inputs:opacity.connect = </Materials/Material_${i.id}/Texture_${i.map.id}_diffuse.outputs:a>`):i.alphaTest>0&&(r.addProperty(`float inputs:opacity.connect = </Materials/Material_${i.id}/Texture_${i.map.id}_diffuse.outputs:a>`),r.addProperty(`float inputs:opacityThreshold = ${i.alphaTest}`)),s(i.map,"diffuse",i.color).forEach(o=>n.addChild(o))):r.addProperty(`color3f inputs:diffuseColor = ${Hy(i.color)}`),i.emissive){let a=i.emissiveIntensity??1;if(i.emissiveMap){r.addProperty(`color3f inputs:emissiveColor.connect = </Materials/Material_${i.id}/Texture_${i.emissiveMap.id}_emissive.outputs:rgb>`);let o=new He(i.emissive.r*a,i.emissive.g*a,i.emissive.b*a);s(i.emissiveMap,"emissive",o).forEach(l=>n.addChild(l))}else i.emissive.getHex()>0&&r.addProperty(`color3f inputs:emissiveColor = ${Hy(i.emissive)}`)}if(i.normalMap&&(r.addProperty(`normal3f inputs:normal.connect = </Materials/Material_${i.id}/Texture_${i.normalMap.id}_normal.outputs:rgb>`),s(i.normalMap,"normal").forEach(o=>n.addChild(o))),i.aoMap){r.addProperty(`float inputs:occlusion.connect = </Materials/Material_${i.id}/Texture_${i.aoMap.id}_occlusion.outputs:r>`);let a=i.aoMapIntensity??1,o=new He(a,a,a);s(i.aoMap,"occlusion",o).forEach(l=>n.addChild(l))}if(i.roughnessMap){r.addProperty(`float inputs:roughness.connect = </Materials/Material_${i.id}/Texture_${i.roughnessMap.id}_roughness.outputs:g>`);let a=new He(i.roughness,i.roughness,i.roughness);s(i.roughnessMap,"roughness",a).forEach(c=>n.addChild(c))}else r.addProperty(`float inputs:roughness = ${i.roughness??1}`);if(i.metalnessMap){r.addProperty(`float inputs:metallic.connect = </Materials/Material_${i.id}/Texture_${i.metalnessMap.id}_metallic.outputs:b>`);let a=new He(i.metalness,i.metalness,i.metalness);s(i.metalnessMap,"metallic",a).forEach(c=>n.addChild(c))}else r.addProperty(`float inputs:metallic = ${i.metalness??0}`);if(i.alphaMap?(r.addProperty(`float inputs:opacity.connect = </Materials/Material_${i.id}/Texture_${i.alphaMap.id}_opacity.outputs:r>`),r.addProperty("float inputs:opacityThreshold = 0.0001"),s(i.alphaMap,"opacity").forEach(o=>n.addChild(o))):r.addProperty(`float inputs:opacity = ${i.opacity}`),i.isMeshPhysicalMaterial){if(i.clearcoatMap!==null){r.addProperty(`float inputs:clearcoat.connect = </Materials/Material_${i.id}/Texture_${i.clearcoatMap.id}_clearcoat.outputs:r>`);let a=new He(i.clearcoat,i.clearcoat,i.clearcoat);s(i.clearcoatMap,"clearcoat",a).forEach(c=>n.addChild(c))}else r.addProperty(`float inputs:clearcoat = ${i.clearcoat}`);if(i.clearcoatRoughnessMap!==null){r.addProperty(`float inputs:clearcoatRoughness.connect = </Materials/Material_${i.id}/Texture_${i.clearcoatRoughnessMap.id}_clearcoatRoughness.outputs:g>`);let a=new He(i.clearcoatRoughness,i.clearcoatRoughness,i.clearcoatRoughness);s(i.clearcoatRoughnessMap,"clearcoatRoughness",a).forEach(c=>n.addChild(c))}else r.addProperty(`float inputs:clearcoatRoughness = ${i.clearcoatRoughness}`);r.addProperty(`float inputs:ior = ${i.ior}`)}return r.addProperty("int inputs:useSpecularWorkflow = 0"),r.addProperty("token outputs:surface"),n.addChild(r),n.addProperty(`token outputs:surface.connect = </Materials/Material_${i.id}/PreviewSurface.outputs:surface>`),n}function Hy(i){return`(${i.r}, ${i.g}, ${i.b})`}function EI(i,e=1){return`(${i.r}, ${i.g}, ${i.b}, ${e})`}function Vy(i){return`(${i.x}, ${i.y})`}function AI(i,e,t){let n=Gy(i,e);i.matrix.determinant()<0&&console.warn("THREE.USDZExporter: USDZ does not support negative scales",i);let s=new Xn(n,"Camera");Xy(s,i,t);let r=i.isOrthographicCamera?"orthographic":"perspective";s.addProperty(`token projection = "${r}"`);let a=`(${i.near.toPrecision(wt)}, ${i.far.toPrecision(wt)})`;s.addProperty(`float2 clippingRange = ${a}`);let o;i.isOrthographicCamera?o=((Math.abs(i.left)+Math.abs(i.right))*10).toPrecision(wt):o=i.getFilmWidth().toPrecision(wt),s.addProperty(`float horizontalAperture = ${o}`);let c;if(i.isOrthographicCamera?c=((Math.abs(i.top)+Math.abs(i.bottom))*10).toPrecision(wt):c=i.getFilmHeight().toPrecision(wt),s.addProperty(`float verticalAperture = ${c}`),i.isPerspectiveCamera){let l=i.getFocalLength().toPrecision(wt);s.addProperty(`float focalLength = ${l}`);let h=i.focus.toPrecision(wt);s.addProperty(`float focusDistance = ${h}`)}return s}var Xn,gg,wt,Zy=un(()=>{Qn();By();Xn=class{constructor(e,t="",n=[],s=[]){this.name=e,this.type=t,this.metadata=n,this.properties=s,this.children=[]}addMetadata(e,t){this.metadata.push({key:e,value:t})}addProperty(e,t=[]){this.properties.push({property:e,metadata:t})}addChild(e){this.children.push(e)}toString(e=0){let t=" ".repeat(e),n=this.metadata.map(h=>{let u=h.key,d=h.value;if(Array.isArray(d)){let p=[];return p.push(`${u} = {`),d.forEach(b=>{p.push(`${t} ${b}`)}),p.push(`${t} }`),p.join(`
+`)}else return`${u} = ${d}`}),s=n.length?` (
${n.map(h=>`${t} ${h}`).join(`
`)}
-${t})`:"",s=this.properties.map(h=>{let d=h.property,f=h.metadata.length?` (
+${t})`:"",r=this.properties.map(h=>{let u=h.property.replace(/\n/g,`
+`+t+" "),d=h.metadata.length?` (
${h.metadata.map(p=>`${t} ${p}`).join(`
`)}
-${t} )`:"";return`${t} ${d}${f}`}),a=this.children.map(h=>h.toString(e+1)),o=[];if(s.length>0&&o.push(...s),a.length>0){s.length>0&&o.push("");for(let h=0;h<a.length;h++)o.push(a[h]),h<a.length-1&&o.push("")}let l=o.join(`
-`),c=this.type?this.type+" ":"";return`${t}def ${c}"${this.name}"${r}
+${t} )`:"";return`${t} ${u}${d}`}),a=this.children.map(h=>h.toString(e+1)),o=[];if(r.length>0&&o.push(...r),a.length>0){r.length>0&&o.push("");for(let h=0;h<a.length;h++)o.push(a[h]),h<a.length-1&&o.push("")}let c=o.join(`
+`),l=this.type?this.type+" ":"";return`${t}def ${l}"${this.name}"${s}
${t}{
-${l}
-${t}}`}},Gp=class{constructor(){this.textureUtils=null}setTextureUtils(e){this.textureUtils=e}parse(e,t,n,r){this.parseAsync(e,r).then(t).catch(n)}async parseAsync(e,t={}){t=Object.assign({ar:{anchoring:{type:"plane"},planeAnchoring:{alignment:"horizontal"}},includeAnchoringProperties:!0,onlyVisible:!0,quickLookCompatible:!1,maxTextureSize:1024},t);let n=new Set,r={},s="model.usda";r[s]=null;let a=new Wn("Root","Xform"),o=new Wn("Scenes","Scope");o.addMetadata("kind",'"sceneLibrary"'),a.addChild(o);let l="Scene",c=new Wn(l,"Xform");c.addMetadata("customData",["bool preliminary_collidesWithEnvironment = 0",`string sceneName = "${l}"`]),c.addMetadata("sceneName",`"${l}"`),t.includeAnchoringProperties&&(c.addProperty(`token preliminary:anchoring:type = "${t.ar.anchoring.type}"`),c.addProperty(`token preliminary:planeAnchoring:alignment = "${t.ar.planeAnchoring.alignment}"`)),o.addChild(c);let h,d={},f={};$x(e,c,d,n,r,t);let p=dR(d,f,t.quickLookCompatible);h=qx()+`
-`+a.toString()+`
+${c}
+${t}}`}},gg=class{constructor(){this.textureUtils=null}setTextureUtils(e){this.textureUtils=e}parse(e,t,n,s){this.parseAsync(e,s).then(t).catch(n)}async parseAsync(e,t={}){t=Object.assign({ar:{anchoring:{type:"plane"},planeAnchoring:{alignment:"horizontal"}},includeAnchoringProperties:!0,onlyVisible:!0,quickLookCompatible:!1,maxTextureSize:1024,animations:[],animationFrameRate:60},t);let n=new Set,s={},r="model.usda";s[r]=null;let a=pI(e,t.animations);t.animationTracks=a;let o=new Xn("Root","Xform"),c=new Xn("Scenes","Scope");c.addMetadata("kind",'"sceneLibrary"'),o.addChild(c);let l="Scene",h=new Xn(l,"Xform");h.addMetadata("customData",["bool preliminary_collidesWithEnvironment = 0",`string sceneName = "${l}"`]),h.addMetadata("sceneName",`"${l}"`),t.includeAnchoringProperties&&(h.addProperty(`token preliminary:anchoring:type = "${t.ar.anchoring.type}"`),h.addProperty(`token preliminary:planeAnchoring:alignment = "${t.ar.planeAnchoring.alignment}"`)),c.addChild(h);let u,d={},p={};e.isScene?qy(e,h,d,n,s,t):jy(e,h,d,n,s,t);let b=wI(d,p,t.quickLookCompatible),v=a.size>0?{fps:t.animationFrameRate,endTimeCode:mI(t.animations)*t.animationFrameRate}:null;u=$y(v)+`
+`+o.toString()+`
-`+p.toString(),r[s]=Qo(h),h=null;for(let y in f){let b=f[y];if(b.isCompressedTexture===!0){if(this.textureUtils===null)throw new Error("THREE.USDZExporter: setTextureUtils() must be called to process compressed textures.");b=await this.textureUtils.decompress(b)}let g=sR(b.image,b.flipY,t.maxTextureSize),S=await new Promise(A=>g.toBlob(A,"image/png",1));r[`textures/Texture_${y}.png`]=new Uint8Array(await S.arrayBuffer())}let x=0;for(let y in r){let b=r[y],g=34+y.length;x+=g;let S=x&63;if(S!==4){let A=64-S,T=new Uint8Array(A);r[y]=[b,{extra:{12345:T}}]}x=b.length}return zx(r,{level:0})}};Ht=7});var Qp={};Ar(Qp,{MAX_AR_FOOTPRINT_M:()=>Yp,MAX_AR_HEIGHT_M:()=>Jp,bakeSkinnedMeshes:()=>Vp,bakedLocalPositions:()=>Jx,clampToPlaceableSize:()=>Zp,coerceMaterialsToStandard:()=>Wp,ensureNormals:()=>qp,fitToRoomScale:()=>Kp,glbUrlToUsdzBlob:()=>Qx,groundOnFloor:()=>Xp,objectToUsdzBlob:()=>Zx,sceneToUsdzBlob:()=>ru,usdzExportRoot:()=>$p});function Jx(i){let e=i.geometry.getAttribute("position"),t=new Float32Array(e.count*3),n=new W;for(let r=0;r<e.count;r++)n.fromBufferAttribute(e,r),i.applyBoneTransform(r,n),t[r*3]=n.x,t[r*3+1]=n.y,t[r*3+2]=n.z;return t}function Vp(i){i.updateMatrixWorld(!0);let e=[];i.traverse(t=>{t.isSkinnedMesh&&t.skeleton?.bones?.length&&e.push(t)});for(let t of e){if(!t.geometry.getAttribute("position"))continue;let n=t.geometry.clone();n.setAttribute("position",new Kt(Jx(t),3)),n.deleteAttribute("skinIndex"),n.deleteAttribute("skinWeight"),n.computeVertexNormals();let r=new xt(n,t.material);r.name=t.name,r.visible=t.visible,r.position.copy(t.position),r.quaternion.copy(t.quaternion),r.scale.copy(t.scale);let s=t.parent||i;s.add(r),s.remove(t)}}function Wp(i){i.traverse(e=>{if(!e.isMesh)return;(Array.isArray(e.material)?e.material:[e.material]).forEach((n,r)=>{if(!n||n.isMeshStandardMaterial)return;let s=new gi({color:n.color?n.color.clone():new Ve(16777215),map:n.map||null,normalMap:n.normalMap||null,roughness:typeof n.roughness=="number"?n.roughness:.85,metalness:typeof n.metalness=="number"?n.metalness:0,transparent:!!n.transparent,opacity:typeof n.opacity=="number"?n.opacity:1,side:n.side??Dn});Array.isArray(e.material)?e.material[r]=s:e.material=s})})}function qp(i){i.traverse(e=>{!e.isMesh||!e.geometry||e.geometry.getAttribute("normal")||e.geometry.getAttribute("position")&&e.geometry.computeVertexNormals()})}function $p(i){let e=new pn;e.name="Root";let t=new pn;return t.name="Model",t.add(i),e.add(t),e.updateMatrixWorld(!0),{root:e,stage:t}}function jp(i){i.updateMatrixWorld(!0);let e=new rn().setFromObject(i);if(e.isEmpty())return null;let t=e.min,n=e.max;return[t.x,t.y,t.z,n.x,n.y,n.z].every(Number.isFinite)?e:null}function Xp(i,e){let t=jp(e);if(!t)return!1;let n=t.getCenter(new W);return i.position.x-=n.x,i.position.y-=t.min.y,i.position.z-=n.z,e.updateMatrixWorld(!0),!0}function Kp(i,e){let t=jp(e);if(!t)return 1;let n=!1;e.traverse(s=>{s.isSkinnedMesh&&(n=!0)});let{scale:r}=Ko({min:{x:t.min.x,y:t.min.y,z:t.min.z},max:{x:t.max.x,y:t.max.y,z:t.max.z}},{skinned:n});return!(r>0)||r===1?1:(i.scale.multiplyScalar(r),e.updateMatrixWorld(!0),r)}function Zp(i,e,{maxFootprint:t=Yp,maxHeight:n=Jp}={}){let r=jp(e);if(!r)return 1;let s=r.getSize(new W),a=Math.max(s.x,s.z),o=Math.min(a>0?t/a:1,s.y>0?n/s.y:1);return!(o<1)||!Number.isFinite(o)?1:(i.scale.multiplyScalar(o),e.updateMatrixWorld(!0),o)}async function ru(i,{fit:e=!1,...t}={}){let{root:n,stage:r}=$p(i);Vp(n),Wp(n),qp(n),e&&Kp(r,n),Zp(r,n),Xp(r,n);let{USDZExporter:s}=await Promise.resolve().then(()=>(Yx(),Kx)),a=await new s().parseAsync(n,{quickLookCompatible:!0,includeAnchoringProperties:!0,ar:{anchoring:{type:"plane"},planeAnchoring:{alignment:"horizontal"}},...t});return new Blob([a],{type:"model/vnd.usdz+zip"})}async function Zx(i){i.updateMatrixWorld(!0);let e=Cs(i);return e.position.set(0,0,0),e.rotation.set(0,0,0),e.scale.copy(i.getWorldScale(new W)),e.updateMatrixWorld(!0),ru(e)}async function Qx(i,{signal:e,onProgress:t}={}){t?.("download");let n=await fetch(i,{signal:e});if(!n.ok)throw new Error(`model fetch ${n.status}`);let r=await n.arrayBuffer();t?.("parse");let s=await Kb(),a=await new Promise((l,c)=>{s.parse(r,"",l,c)}),o=a.scene||a.scenes?.[0];if(!o)throw new Error("that model contains no scene");return t?.("convert"),ru(o,{fit:!0})}var Yp,Jp,su=un(()=>{Vn();wh();Vh();eu();Yp=2.5,Jp=2.5});var f_=dn(()=>{"use strict";ArrayBuffer.isView||(ArrayBuffer.isView=i=>i!==null&&typeof i=="object"&&i.buffer instanceof ArrayBuffer);typeof globalThis>"u"&&typeof window<"u"&&(window.globalThis=window);typeof FormData>"u"&&(globalThis.FormData=class{})});var ic={};Ar(ic,{__addDisposableResource:()=>k_,__assign:()=>du,__asyncDelegator:()=>I_,__asyncGenerator:()=>C_,__asyncValues:()=>P_,__await:()=>Na,__awaiter:()=>w_,__classPrivateFieldGet:()=>O_,__classPrivateFieldIn:()=>U_,__classPrivateFieldSet:()=>F_,__createBinding:()=>pu,__decorate:()=>g_,__disposeResources:()=>B_,__esDecorate:()=>x_,__exportStar:()=>A_,__extends:()=>p_,__generator:()=>M_,__importDefault:()=>N_,__importStar:()=>D_,__makeTemplateObject:()=>L_,__metadata:()=>S_,__param:()=>b_,__propKey:()=>y_,__read:()=>dm,__rest:()=>m_,__rewriteRelativeImportExtension:()=>z_,__runInitializers:()=>__,__setFunctionName:()=>v_,__spread:()=>T_,__spreadArray:()=>R_,__spreadArrays:()=>E_,__values:()=>fu,default:()=>TR});function p_(i,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");hm(i,e);function t(){this.constructor=i}i.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function m_(i,e){var t={};for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&e.indexOf(n)<0&&(t[n]=i[n]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,n=Object.getOwnPropertySymbols(i);r<n.length;r++)e.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(i,n[r])&&(t[n[r]]=i[n[r]]);return t}function g_(i,e,t,n){var r=arguments.length,s=r<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(i,e,t,n);else for(var o=i.length-1;o>=0;o--)(a=i[o])&&(s=(r<3?a(s):r>3?a(e,t,s):a(e,t))||s);return r>3&&s&&Object.defineProperty(e,t,s),s}function b_(i,e){return function(t,n){e(t,n,i)}}function x_(i,e,t,n,r,s){function a(g){if(g!==void 0&&typeof g!="function")throw new TypeError("Function expected");return g}for(var o=n.kind,l=o==="getter"?"get":o==="setter"?"set":"value",c=!e&&i?n.static?i:i.prototype:null,h=e||(c?Object.getOwnPropertyDescriptor(c,n.name):{}),d,f=!1,p=t.length-1;p>=0;p--){var x={};for(var y in n)x[y]=y==="access"?{}:n[y];for(var y in n.access)x.access[y]=n.access[y];x.addInitializer=function(g){if(f)throw new TypeError("Cannot add initializers after decoration has completed");s.push(a(g||null))};var b=(0,t[p])(o==="accessor"?{get:h.get,set:h.set}:h[l],x);if(o==="accessor"){if(b===void 0)continue;if(b===null||typeof b!="object")throw new TypeError("Object expected");(d=a(b.get))&&(h.get=d),(d=a(b.set))&&(h.set=d),(d=a(b.init))&&r.unshift(d)}else(d=a(b))&&(o==="field"?r.unshift(d):h[l]=d)}c&&Object.defineProperty(c,n.name,h),f=!0}function __(i,e,t){for(var n=arguments.length>2,r=0;r<e.length;r++)t=n?e[r].call(i,t):e[r].call(i);return n?t:void 0}function y_(i){return typeof i=="symbol"?i:"".concat(i)}function v_(i,e,t){return typeof e=="symbol"&&(e=e.description?"[".concat(e.description,"]"):""),Object.defineProperty(i,"name",{configurable:!0,value:t?"".concat(t," ",e):e})}function S_(i,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(i,e)}function w_(i,e,t,n){function r(s){return s instanceof t?s:new t(function(a){a(s)})}return new(t||(t=Promise))(function(s,a){function o(h){try{c(n.next(h))}catch(d){a(d)}}function l(h){try{c(n.throw(h))}catch(d){a(d)}}function c(h){h.done?s(h.value):r(h.value).then(o,l)}c((n=n.apply(i,e||[])).next())})}function M_(i,e){var t={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},n,r,s,a=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return a.next=o(0),a.throw=o(1),a.return=o(2),typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function o(c){return function(h){return l([c,h])}}function l(c){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(t=0)),t;)try{if(n=1,r&&(s=c[0]&2?r.return:c[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,c[1])).done)return s;switch(r=0,s&&(c=[c[0]&2,s.value]),c[0]){case 0:case 1:s=c;break;case 4:return t.label++,{value:c[1],done:!1};case 5:t.label++,r=c[1],c=[0];continue;case 7:c=t.ops.pop(),t.trys.pop();continue;default:if(s=t.trys,!(s=s.length>0&&s[s.length-1])&&(c[0]===6||c[0]===2)){t=0;continue}if(c[0]===3&&(!s||c[1]>s[0]&&c[1]<s[3])){t.label=c[1];break}if(c[0]===6&&t.label<s[1]){t.label=s[1],s=c;break}if(s&&t.label<s[2]){t.label=s[2],t.ops.push(c);break}s[2]&&t.ops.pop(),t.trys.pop();continue}c=e.call(i,t)}catch(h){c=[6,h],r=0}finally{n=s=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}function A_(i,e){for(var t in i)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&pu(e,i,t)}function fu(i){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&i[e],n=0;if(t)return t.call(i);if(i&&typeof i.length=="number")return{next:function(){return i&&n>=i.length&&(i=void 0),{value:i&&i[n++],done:!i}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function dm(i,e){var t=typeof Symbol=="function"&&i[Symbol.iterator];if(!t)return i;var n=t.call(i),r,s=[],a;try{for(;(e===void 0||e-- >0)&&!(r=n.next()).done;)s.push(r.value)}catch(o){a={error:o}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(a)throw a.error}}return s}function T_(){for(var i=[],e=0;e<arguments.length;e++)i=i.concat(dm(arguments[e]));return i}function E_(){for(var i=0,e=0,t=arguments.length;e<t;e++)i+=arguments[e].length;for(var n=Array(i),r=0,e=0;e<t;e++)for(var s=arguments[e],a=0,o=s.length;a<o;a++,r++)n[r]=s[a];return n}function R_(i,e,t){if(t||arguments.length===2)for(var n=0,r=e.length,s;n<r;n++)(s||!(n in e))&&(s||(s=Array.prototype.slice.call(e,0,n)),s[n]=e[n]);return i.concat(s||Array.prototype.slice.call(e))}function Na(i){return this instanceof Na?(this.v=i,this):new Na(i)}function C_(i,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=t.apply(i,e||[]),r,s=[];return r=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),o("next"),o("throw"),o("return",a),r[Symbol.asyncIterator]=function(){return this},r;function a(p){return function(x){return Promise.resolve(x).then(p,d)}}function o(p,x){n[p]&&(r[p]=function(y){return new Promise(function(b,g){s.push([p,y,b,g])>1||l(p,y)})},x&&(r[p]=x(r[p])))}function l(p,x){try{c(n[p](x))}catch(y){f(s[0][3],y)}}function c(p){p.value instanceof Na?Promise.resolve(p.value.v).then(h,d):f(s[0][2],p)}function h(p){l("next",p)}function d(p){l("throw",p)}function f(p,x){p(x),s.shift(),s.length&&l(s[0][0],s[0][1])}}function I_(i){var e,t;return e={},n("next"),n("throw",function(r){throw r}),n("return"),e[Symbol.iterator]=function(){return this},e;function n(r,s){e[r]=i[r]?function(a){return(t=!t)?{value:Na(i[r](a)),done:!1}:s?s(a):a}:s}}function P_(i){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=i[Symbol.asyncIterator],t;return e?e.call(i):(i=typeof fu=="function"?fu(i):i[Symbol.iterator](),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(s){t[s]=i[s]&&function(a){return new Promise(function(o,l){a=i[s](a),r(o,l,a.done,a.value)})}}function r(s,a,o,l){Promise.resolve(l).then(function(c){s({value:c,done:o})},a)}}function L_(i,e){return Object.defineProperty?Object.defineProperty(i,"raw",{value:e}):i.raw=e,i}function D_(i){if(i&&i.__esModule)return i;var e={};if(i!=null)for(var t=um(i),n=0;n<t.length;n++)t[n]!=="default"&&pu(e,i,t[n]);return MR(e,i),e}function N_(i){return i&&i.__esModule?i:{default:i}}function O_(i,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?i!==e||!n:!e.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(i):n?n.value:e.get(i)}function F_(i,e,t,n,r){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!r)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?i!==e||!r:!e.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?r.call(i,t):r?r.value=t:e.set(i,t),t}function U_(i,e){if(e===null||typeof e!="object"&&typeof e!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof i=="function"?e===i:i.has(e)}function k_(i,e,t){if(e!=null){if(typeof e!="object"&&typeof e!="function")throw new TypeError("Object expected.");var n,r;if(t){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");n=e[Symbol.asyncDispose]}if(n===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");n=e[Symbol.dispose],t&&(r=n)}if(typeof n!="function")throw new TypeError("Object not disposable.");r&&(n=function(){try{r.call(this)}catch(s){return Promise.reject(s)}}),i.stack.push({value:e,dispose:n,async:t})}else t&&i.stack.push({async:!0});return e}function B_(i){function e(s){i.error=i.hasError?new AR(s,i.error,"An error was suppressed during disposal."):s,i.hasError=!0}var t,n=0;function r(){for(;t=i.stack.pop();)try{if(!t.async&&n===1)return n=0,i.stack.push(t),Promise.resolve().then(r);if(t.dispose){var s=t.dispose.call(t.value);if(t.async)return n|=2,Promise.resolve(s).then(r,function(a){return e(a),r()})}else n|=1}catch(a){e(a)}if(n===1)return i.hasError?Promise.reject(i.error):Promise.resolve();if(i.hasError)throw i.error}return r()}function z_(i,e){return typeof i=="string"&&/^\.\.?\//.test(i)?i.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(t,n,r,s,a){return n?e?".jsx":".js":r&&(!s||!a)?t:r+s+"."+a.toLowerCase()+"js"}):i}var hm,du,pu,MR,um,AR,TR,rc=un(()=>{hm=function(i,e){return hm=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])},hm(i,e)};du=function(){return du=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++){t=arguments[n];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s])}return e},du.apply(this,arguments)};pu=Object.create?(function(i,e,t,n){n===void 0&&(n=t);var r=Object.getOwnPropertyDescriptor(e,t);(!r||("get"in r?!e.__esModule:r.writable||r.configurable))&&(r={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(i,n,r)}):(function(i,e,t,n){n===void 0&&(n=t),i[n]=e[t]});MR=Object.create?(function(i,e){Object.defineProperty(i,"default",{enumerable:!0,value:e})}):function(i,e){i.default=e},um=function(i){return um=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},um(i)};AR=typeof SuppressedError=="function"?SuppressedError:function(i,e,t){var n=new Error(t);return n.name="SuppressedError",n.error=i,n.suppressed=e,n};TR={__extends:p_,__assign:du,__rest:m_,__decorate:g_,__param:b_,__esDecorate:x_,__runInitializers:__,__propKey:y_,__setFunctionName:v_,__metadata:S_,__awaiter:w_,__generator:M_,__createBinding:pu,__exportStar:A_,__values:fu,__read:dm,__spread:T_,__spreadArrays:E_,__spreadArray:R_,__await:Na,__asyncGenerator:C_,__asyncDelegator:I_,__asyncValues:P_,__makeTemplateObject:L_,__importStar:D_,__importDefault:N_,__classPrivateFieldGet:O_,__classPrivateFieldSet:F_,__classPrivateFieldIn:U_,__addDisposableResource:k_,__disposeResources:B_,__rewriteRelativeImportExtension:z_}});var sc=dn(Oa=>{"use strict";Oa.CloseCode=void 0;(function(i){i[i.CONSENTED=4e3]="CONSENTED",i[i.DEVMODE_RESTART=4010]="DEVMODE_RESTART"})(Oa.CloseCode||(Oa.CloseCode={}));var fm=class extends Error{constructor(e,t){super(t),this.name="ServerError",this.code=e}},pm=class extends Error{constructor(e){super(e),this.name="AbortError"}};Oa.AbortError=pm;Oa.ServerError=fm});var ac=dn((mu,H_)=>{(function(i,e){typeof mu=="object"&&typeof H_<"u"?e(mu):typeof define=="function"&&define.amd?define(["exports"],e):(i=typeof globalThis<"u"?globalThis:i||self,e(i.schema={}))})(mu,(function(i){"use strict";i.OPERATION=void 0,(function(R){R[R.ADD=128]="ADD",R[R.REPLACE=0]="REPLACE",R[R.DELETE=64]="DELETE",R[R.DELETE_AND_MOVE=96]="DELETE_AND_MOVE",R[R.MOVE_AND_ADD=160]="MOVE_AND_ADD",R[R.DELETE_AND_ADD=192]="DELETE_AND_ADD",R[R.CLEAR=10]="CLEAR",R[R.REVERSE=15]="REVERSE",R[R.MOVE=32]="MOVE",R[R.DELETE_BY_REFID=33]="DELETE_BY_REFID",R[R.ADD_BY_REFID=129]="ADD_BY_REFID"})(i.OPERATION||(i.OPERATION={})),Symbol.metadata??=Symbol.for("Symbol.metadata");let n="~track",r="~encoder",s="~decoder",a="~filter",o="~getByIndex",l="~deleteByIndex",c="~changes",h="~childType",d="~onEncodeEnd",f="~onDecodeEnd",p="~descriptors",x="~__numFields",y="~__refTypeFieldIndexes",b="~__viewFieldIndexes",g="$__fieldIndexesByViewTag",S;try{S=new TextEncoder}catch{}let A=new ArrayBuffer(8),T=new Int32Array(A),N=new Float32Array(A),P=new Float64Array(A),U=new BigInt64Array(A),I=typeof Buffer<"u"&&Buffer.byteLength?Buffer.byteLength:function(R,u){for(var m=0,_=0,w=0,z=R.length;w<z;w++)m=R.charCodeAt(w),m<128?_+=1:m<2048?_+=2:m<55296||m>=57344?_+=3:(w++,_+=4);return _};function B(R,u,m){for(var _=0,w=0,z=u.length;w<z;w++)_=u.charCodeAt(w),_<128?R[m.offset++]=_:_<2048?(R[m.offset]=192|_>>6,R[m.offset+1]=128|_&63,m.offset+=2):_<55296||_>=57344?(R[m.offset]=224|_>>12,R[m.offset+1]=128|_>>6&63,R[m.offset+2]=128|_&63,m.offset+=3):(w++,_=65536+((_&1023)<<10|u.charCodeAt(w)&1023),R[m.offset]=240|_>>18,R[m.offset+1]=128|_>>12&63,R[m.offset+2]=128|_>>6&63,R[m.offset+3]=128|_&63,m.offset+=4)}function k(R,u,m){R[m.offset++]=u&255}function V(R,u,m){R[m.offset++]=u&255}function J(R,u,m){R[m.offset++]=u&255,R[m.offset++]=u>>8&255}function L(R,u,m){R[m.offset++]=u&255,R[m.offset++]=u>>8&255}function E(R,u,m){R[m.offset++]=u&255,R[m.offset++]=u>>8&255,R[m.offset++]=u>>16&255,R[m.offset++]=u>>24&255}function D(R,u,m){let _=u>>24,w=u>>16,z=u>>8,X=u;R[m.offset++]=X&255,R[m.offset++]=z&255,R[m.offset++]=w&255,R[m.offset++]=_&255}function O(R,u,m){let _=Math.floor(u/Math.pow(2,32)),w=u>>>0;D(R,w,m),D(R,_,m)}function H(R,u,m){let _=u/Math.pow(2,32)>>0,w=u>>>0;D(R,w,m),D(R,_,m)}function Y(R,u,m){U[0]=BigInt.asIntN(64,u),E(R,T[0],m),E(R,T[1],m)}function le(R,u,m){U[0]=BigInt.asIntN(64,u),E(R,T[0],m),E(R,T[1],m)}function fe(R,u,m){N[0]=u,E(R,T[0],m)}function be(R,u,m){P[0]=u,E(R,T[0],m),E(R,T[1],m)}function Te(R,u,m){R[m.offset++]=u?1:0}function Je(R,u,m){u||(u="");let _=I(u,"utf8"),w=0;if(_<32)R[m.offset++]=_|160,w=1;else if(_<256)R[m.offset++]=217,R[m.offset++]=_%255,w=2;else if(_<65536)R[m.offset++]=218,L(R,_,m),w=3;else if(_<4294967296)R[m.offset++]=219,D(R,_,m),w=5;else throw new Error("String too long");return B(R,u,m),w+_}function ke(R,u,m){if(isNaN(u))return ke(R,0,m);if(isFinite(u)){if(u!==(u|0))return Math.abs(u)<=34028235e31&&(N[0]=u,Math.abs(Math.abs(N[0])-Math.abs(u))<1e-4)?(R[m.offset++]=202,fe(R,u,m),5):(R[m.offset++]=203,be(R,u,m),9)}else return ke(R,u>0?Number.MAX_SAFE_INTEGER:-Number.MAX_SAFE_INTEGER,m);return u>=0?u<128?(R[m.offset++]=u&255,1):u<256?(R[m.offset++]=204,R[m.offset++]=u&255,2):u<65536?(R[m.offset++]=205,L(R,u,m),3):u<4294967296?(R[m.offset++]=206,D(R,u,m),5):(R[m.offset++]=207,H(R,u,m),9):u>=-32?(R[m.offset++]=224|u+32,1):u>=-128?(R[m.offset++]=208,k(R,u,m),2):u>=-32768?(R[m.offset++]=209,J(R,u,m),3):u>=-2147483648?(R[m.offset++]=210,E(R,u,m),5):(R[m.offset++]=211,O(R,u,m),9)}let oe={int8:k,uint8:V,int16:J,uint16:L,int32:E,uint32:D,int64:O,uint64:H,bigint64:Y,biguint64:le,float32:fe,float64:be,boolean:Te,string:Je,number:ke,utf8Write:B,utf8Length:I},Ee=new ArrayBuffer(8),_e=new Int32Array(Ee),Ze=new Float32Array(Ee),tt=new Float64Array(Ee),Qe=new BigUint64Array(Ee),Et=new BigInt64Array(Ee);function it(R,u,m){m>R.length-u.offset&&(m=R.length-u.offset);for(var _="",w=0,z=u.offset,X=u.offset+m;z<X;z++){var ue=R[z];if((ue&128)===0){_+=String.fromCharCode(ue);continue}if((ue&224)===192){_+=String.fromCharCode((ue&31)<<6|R[++z]&63);continue}if((ue&240)===224){_+=String.fromCharCode((ue&15)<<12|(R[++z]&63)<<6|(R[++z]&63)<<0);continue}if((ue&248)===240){w=(ue&7)<<18|(R[++z]&63)<<12|(R[++z]&63)<<6|(R[++z]&63)<<0,w>=65536?(w-=65536,_+=String.fromCharCode((w>>>10)+55296,(w&1023)+56320)):_+=String.fromCharCode(w);continue}console.error("decode.utf8Read(): Invalid byte "+ue+" at offset "+z+". Skip to end of string: "+(u.offset+m));break}return u.offset+=m,_}function mt(R,u){return wt(R,u)<<24>>24}function wt(R,u){return R[u.offset++]}function lt(R,u){return Bt(R,u)<<16>>16}function Bt(R,u){return R[u.offset++]|R[u.offset++]<<8}function gt(R,u){return R[u.offset++]|R[u.offset++]<<8|R[u.offset++]<<16|R[u.offset++]<<24}function Yt(R,u){return gt(R,u)>>>0}function q(R,u){return _e[0]=gt(R,u),Ze[0]}function $t(R,u){return _e[0]=gt(R,u),_e[1]=gt(R,u),tt[0]}function ht(R,u){let m=Yt(R,u);return gt(R,u)*Math.pow(2,32)+m}function Tt(R,u){let m=Yt(R,u);return Yt(R,u)*Math.pow(2,32)+m}function Pe(R,u){return _e[0]=gt(R,u),_e[1]=gt(R,u),Et[0]}function Ot(R,u){return _e[0]=gt(R,u),_e[1]=gt(R,u),Qe[0]}function F(R,u){return wt(R,u)>0}function M(R,u){let m=R[u.offset++],_;return m<192?_=m&31:m===217?_=wt(R,u):m===218?_=Bt(R,u):m===219&&(_=Yt(R,u)),it(R,u,_)}function Z(R,u){let m=R[u.offset++];if(m<128)return m;if(m===202)return q(R,u);if(m===203)return $t(R,u);if(m===204)return wt(R,u);if(m===205)return Bt(R,u);if(m===206)return Yt(R,u);if(m===207)return Tt(R,u);if(m===208)return mt(R,u);if(m===209)return lt(R,u);if(m===210)return gt(R,u);if(m===211)return ht(R,u);if(m>223)return(255-m+1)*-1}function pe(R,u){let m=R[u.offset];return m<192&&m>160||m===217||m===218||m===219}let ge={utf8Read:it,int8:mt,uint8:wt,int16:lt,uint16:Bt,int32:gt,uint32:Yt,float32:q,float64:$t,int64:ht,uint64:Tt,bigint64:Pe,biguint64:Ot,boolean:F,string:M,number:Z,stringCheck:pe},Se={},Ce=new Map;function ce(R,u){u.constructor&&(Ce.set(u.constructor,R),Se[R]=u),u.encode&&(oe[R]=u.encode),u.decode&&(ge[R]=u.decode)}function me(R){return Se[R]}function Be(R){for(let u in R)ce(u,R[u]);return u=>ni(u)}let sn=class sn{static register(u){let m=Object.getPrototypeOf(u);if(m!==Ie){let _=sn.inheritedTypes.get(m);_||(_=new Set,sn.inheritedTypes.set(m,_)),_.add(u)}}static cache(u){let m=sn.cachedContexts.get(u);return m||(m=new sn(u),sn.cachedContexts.set(u,m)),m}constructor(u){this.types={},this.schemas=new Map,this.hasFilters=!1,this.parentFiltered={},u&&this.discoverTypes(u)}has(u){return this.schemas.has(u)}get(u){return this.types[u]}add(u,m=this.schemas.size){return this.schemas.has(u)?!1:(this.types[m]=u,u[Symbol.metadata]===void 0&&je.initialize(u),this.schemas.set(u,m),!0)}getTypeId(u){return this.schemas.get(u)}discoverTypes(u,m,_,w){if(w&&this.registerFilteredByParent(u,m,_),!this.add(u))return;sn.inheritedTypes.get(u)?.forEach(ue=>{this.discoverTypes(ue,m,_,w)});let z=u;for(;(z=Object.getPrototypeOf(z))&&z!==Ie&&z!==Function.prototype;)this.discoverTypes(z);let X=u[Symbol.metadata]??={};X[b]&&(this.hasFilters=!0);for(let ue in X){let ne=ue,ae=X[ne].type,he=X[ne].tag!==void 0;if(typeof ae!="string")if(typeof ae=="function")this.discoverTypes(ae,u,ne,w||he);else{let se=Object.values(ae)[0];if(typeof se=="string")continue;this.discoverTypes(se,u,ne,w||he)}}}registerFilteredByParent(u,m,_){let z=`${this.schemas.get(u)??this.schemas.size}`;m&&(z+=`-${this.schemas.get(m)}`),z+=`-${_}`,this.parentFiltered[z]=!0}debug(){let u="";for(let m in this.parentFiltered){let _=m.split("-").map(Number),w=_.pop();u+=`
- `,u+=`${m}: ${_.reverse().map((z,X)=>{let ue=this.types[z],ne=ue[Symbol.metadata],ae=ue.name;return X===0&&(ae+=`[${ne[w].name}]`),`${ae}`}).join(" -> ")}`}return`TypeContext ->
+`+b.toString(),s[r]=qc(u),u=null;for(let g in p){let E=p[g];if(E.isCompressedTexture===!0){if(this.textureUtils===null)throw new Error("THREE.USDZExporter: setTextureUtils() must be called to process compressed textures.");E=await this.textureUtils.decompress(E)}let L=dI(E.image,E.flipY,t.maxTextureSize),S=E.userData.mimeType==="image/jpeg"?"image/jpeg":"image/png",M=await new Promise(A=>L.toBlob(A,S));s[`textures/Texture_${g}.${Wy(E)}`]=new Uint8Array(await M.arrayBuffer())}let _=0;for(let g in s){let E=s[g],L=34+g.length;_+=L;let S=_&63;if(S!==4){let M=64-S,A=new Uint8Array(M);s[g]=[E,{extra:{12345:A}}]}_=E.length}return Uy(s,{level:0,mtime:new Date})}};wt=7});var Tg={};er(Tg,{MAX_AR_FOOTPRINT_M:()=>Mg,MAX_AR_HEIGHT_M:()=>Eg,bakeSkinnedMeshes:()=>bg,bakedLocalPositions:()=>Qy,clampToPlaceableSize:()=>Ag,coerceMaterialsToStandard:()=>_g,ensureNormals:()=>xg,fitToRoomScale:()=>wg,glbUrlToUsdzBlob:()=>tv,groundOnFloor:()=>Sg,objectToUsdzBlob:()=>ev,sceneToUsdzBlob:()=>cf,usdzExportRoot:()=>yg});function Qy(i){let e=i.geometry.getAttribute("position"),t=new Float32Array(e.count*3),n=new j;for(let s=0;s<e.count;s++)n.fromBufferAttribute(e,s),i.applyBoneTransform(s,n),t[s*3]=n.x,t[s*3+1]=n.y,t[s*3+2]=n.z;return t}function bg(i){i.updateMatrixWorld(!0);let e=[];i.traverse(t=>{t.isSkinnedMesh&&t.skeleton?.bones?.length&&e.push(t)});for(let t of e){if(!t.geometry.getAttribute("position"))continue;let n=t.geometry.clone();n.setAttribute("position",new Qt(Qy(t),3)),n.deleteAttribute("skinIndex"),n.deleteAttribute("skinWeight"),n.computeVertexNormals();let s=new vt(n,t.material);s.name=t.name,s.visible=t.visible,s.position.copy(t.position),s.quaternion.copy(t.quaternion),s.scale.copy(t.scale);let r=t.parent||i;r.add(s),r.remove(t)}}function _g(i){i.traverse(e=>{if(!e.isMesh)return;(Array.isArray(e.material)?e.material:[e.material]).forEach((n,s)=>{if(!n||n.isMeshStandardMaterial)return;let r=new Pi({color:n.color?n.color.clone():new He(16777215),map:n.map||null,normalMap:n.normalMap||null,roughness:typeof n.roughness=="number"?n.roughness:.85,metalness:typeof n.metalness=="number"?n.metalness:0,transparent:!!n.transparent,opacity:typeof n.opacity=="number"?n.opacity:1,side:n.side??$n});Array.isArray(e.material)?e.material[s]=r:e.material=r})})}function xg(i){i.traverse(e=>{!e.isMesh||!e.geometry||e.geometry.getAttribute("normal")||e.geometry.getAttribute("position")&&e.geometry.computeVertexNormals()})}function yg(i){let e=new vn;e.name="Root";let t=new vn;return t.name="Model",t.add(i),e.add(t),e.updateMatrixWorld(!0),{root:e,stage:t}}function vg(i){i.updateMatrixWorld(!0);let e=new ln().setFromObject(i);if(e.isEmpty())return null;let t=e.min,n=e.max;return[t.x,t.y,t.z,n.x,n.y,n.z].every(Number.isFinite)?e:null}function Sg(i,e){let t=vg(e);if(!t)return!1;let n=t.getCenter(new j);return i.position.x-=n.x,i.position.y-=t.min.y,i.position.z-=n.z,e.updateMatrixWorld(!0),!0}function wg(i,e){let t=vg(e);if(!t)return 1;let n=!1;e.traverse(r=>{r.isSkinnedMesh&&(n=!0)});let{scale:s}=Vc({min:{x:t.min.x,y:t.min.y,z:t.min.z},max:{x:t.max.x,y:t.max.y,z:t.max.z}},{skinned:n});return!(s>0)||s===1?1:(i.scale.multiplyScalar(s),e.updateMatrixWorld(!0),s)}function Ag(i,e,{maxFootprint:t=Mg,maxHeight:n=Eg}={}){let s=vg(e);if(!s)return 1;let r=s.getSize(new j),a=Math.max(r.x,r.z),o=Math.min(a>0?t/a:1,r.y>0?n/r.y:1);return!(o<1)||!Number.isFinite(o)?1:(i.scale.multiplyScalar(o),e.updateMatrixWorld(!0),o)}async function cf(i,{fit:e=!1,...t}={}){let{root:n,stage:s}=yg(i);bg(n),_g(n),xg(n),e&&wg(s,n),Ag(s,n),Sg(s,n);let{USDZExporter:r}=await Promise.resolve().then(()=>(Zy(),Jy)),a=await new r().parseAsync(n,{quickLookCompatible:!0,includeAnchoringProperties:!0,ar:{anchoring:{type:"plane"},planeAnchoring:{alignment:"horizontal"}},...t});return new Blob([a],{type:"model/vnd.usdz+zip"})}async function ev(i){i.updateMatrixWorld(!0);let e=aa(i);return e.position.set(0,0,0),e.rotation.set(0,0,0),e.scale.copy(i.getWorldScale(new j)),e.updateMatrixWorld(!0),cf(e)}async function tv(i,{signal:e,onProgress:t}={}){t?.("download");let n=await fetch(i,{signal:e});if(!n.ok)throw new Error(`model fetch ${n.status}`);let s=await n.arrayBuffer();t?.("parse");let r=await jx(),a=await new Promise((c,l)=>{r.parse(s,"",c,l)}),o=a.scene||a.scenes?.[0];if(!o)throw new Error("that model contains no scene");return t?.("convert"),cf(o,{fit:!0})}var Mg,Eg,lf=un(()=>{"use strict";Qn();Au();qu();sf();Mg=2.5,Eg=2.5});var mv=xn(()=>{"use strict";ArrayBuffer.isView||(ArrayBuffer.isView=i=>i!==null&&typeof i=="object"&&i.buffer instanceof ArrayBuffer);typeof globalThis>"u"&&typeof window<"u"&&(window.globalThis=window);typeof FormData>"u"&&(globalThis.FormData=class{})});var Yc={};er(Yc,{__addDisposableResource:()=>zv,__assign:()=>gf,__asyncDelegator:()=>Lv,__asyncGenerator:()=>Pv,__asyncValues:()=>Dv,__await:()=>wo,__awaiter:()=>Ev,__classPrivateFieldGet:()=>kv,__classPrivateFieldIn:()=>Bv,__classPrivateFieldSet:()=>Uv,__createBinding:()=>_f,__decorate:()=>_v,__disposeResources:()=>Hv,__esDecorate:()=>yv,__exportStar:()=>Tv,__extends:()=>gv,__generator:()=>Av,__importDefault:()=>Fv,__importStar:()=>Ov,__makeTemplateObject:()=>Nv,__metadata:()=>Mv,__param:()=>xv,__propKey:()=>Sv,__read:()=>zg,__rest:()=>bv,__rewriteRelativeImportExtension:()=>Vv,__runInitializers:()=>vv,__setFunctionName:()=>wv,__spread:()=>Rv,__spreadArray:()=>Iv,__spreadArrays:()=>Cv,__values:()=>bf,default:()=>kI});function gv(i,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");Ug(i,e);function t(){this.constructor=i}i.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function bv(i,e){var t={};for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&e.indexOf(n)<0&&(t[n]=i[n]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(i);s<n.length;s++)e.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(i,n[s])&&(t[n[s]]=i[n[s]]);return t}function _v(i,e,t,n){var s=arguments.length,r=s<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(i,e,t,n);else for(var o=i.length-1;o>=0;o--)(a=i[o])&&(r=(s<3?a(r):s>3?a(e,t,r):a(e,t))||r);return s>3&&r&&Object.defineProperty(e,t,r),r}function xv(i,e){return function(t,n){e(t,n,i)}}function yv(i,e,t,n,s,r){function a(g){if(g!==void 0&&typeof g!="function")throw new TypeError("Function expected");return g}for(var o=n.kind,c=o==="getter"?"get":o==="setter"?"set":"value",l=!e&&i?n.static?i:i.prototype:null,h=e||(l?Object.getOwnPropertyDescriptor(l,n.name):{}),u,d=!1,p=t.length-1;p>=0;p--){var b={};for(var v in n)b[v]=v==="access"?{}:n[v];for(var v in n.access)b.access[v]=n.access[v];b.addInitializer=function(g){if(d)throw new TypeError("Cannot add initializers after decoration has completed");r.push(a(g||null))};var _=(0,t[p])(o==="accessor"?{get:h.get,set:h.set}:h[c],b);if(o==="accessor"){if(_===void 0)continue;if(_===null||typeof _!="object")throw new TypeError("Object expected");(u=a(_.get))&&(h.get=u),(u=a(_.set))&&(h.set=u),(u=a(_.init))&&s.unshift(u)}else(u=a(_))&&(o==="field"?s.unshift(u):h[c]=u)}l&&Object.defineProperty(l,n.name,h),d=!0}function vv(i,e,t){for(var n=arguments.length>2,s=0;s<e.length;s++)t=n?e[s].call(i,t):e[s].call(i);return n?t:void 0}function Sv(i){return typeof i=="symbol"?i:"".concat(i)}function wv(i,e,t){return typeof e=="symbol"&&(e=e.description?"[".concat(e.description,"]"):""),Object.defineProperty(i,"name",{configurable:!0,value:t?"".concat(t," ",e):e})}function Mv(i,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(i,e)}function Ev(i,e,t,n){function s(r){return r instanceof t?r:new t(function(a){a(r)})}return new(t||(t=Promise))(function(r,a){function o(h){try{l(n.next(h))}catch(u){a(u)}}function c(h){try{l(n.throw(h))}catch(u){a(u)}}function l(h){h.done?r(h.value):s(h.value).then(o,c)}l((n=n.apply(i,e||[])).next())})}function Av(i,e){var t={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},n,s,r,a=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return a.next=o(0),a.throw=o(1),a.return=o(2),typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function o(l){return function(h){return c([l,h])}}function c(l){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(t=0)),t;)try{if(n=1,s&&(r=l[0]&2?s.return:l[0]?s.throw||((r=s.return)&&r.call(s),0):s.next)&&!(r=r.call(s,l[1])).done)return r;switch(s=0,r&&(l=[l[0]&2,r.value]),l[0]){case 0:case 1:r=l;break;case 4:return t.label++,{value:l[1],done:!1};case 5:t.label++,s=l[1],l=[0];continue;case 7:l=t.ops.pop(),t.trys.pop();continue;default:if(r=t.trys,!(r=r.length>0&&r[r.length-1])&&(l[0]===6||l[0]===2)){t=0;continue}if(l[0]===3&&(!r||l[1]>r[0]&&l[1]<r[3])){t.label=l[1];break}if(l[0]===6&&t.label<r[1]){t.label=r[1],r=l;break}if(r&&t.label<r[2]){t.label=r[2],t.ops.push(l);break}r[2]&&t.ops.pop(),t.trys.pop();continue}l=e.call(i,t)}catch(h){l=[6,h],s=0}finally{n=r=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}function Tv(i,e){for(var t in i)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&_f(e,i,t)}function bf(i){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&i[e],n=0;if(t)return t.call(i);if(i&&typeof i.length=="number")return{next:function(){return i&&n>=i.length&&(i=void 0),{value:i&&i[n++],done:!i}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function zg(i,e){var t=typeof Symbol=="function"&&i[Symbol.iterator];if(!t)return i;var n=t.call(i),s,r=[],a;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)r.push(s.value)}catch(o){a={error:o}}finally{try{s&&!s.done&&(t=n.return)&&t.call(n)}finally{if(a)throw a.error}}return r}function Rv(){for(var i=[],e=0;e<arguments.length;e++)i=i.concat(zg(arguments[e]));return i}function Cv(){for(var i=0,e=0,t=arguments.length;e<t;e++)i+=arguments[e].length;for(var n=Array(i),s=0,e=0;e<t;e++)for(var r=arguments[e],a=0,o=r.length;a<o;a++,s++)n[s]=r[a];return n}function Iv(i,e,t){if(t||arguments.length===2)for(var n=0,s=e.length,r;n<s;n++)(r||!(n in e))&&(r||(r=Array.prototype.slice.call(e,0,n)),r[n]=e[n]);return i.concat(r||Array.prototype.slice.call(e))}function wo(i){return this instanceof wo?(this.v=i,this):new wo(i)}function Pv(i,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=t.apply(i,e||[]),s,r=[];return s=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),o("next"),o("throw"),o("return",a),s[Symbol.asyncIterator]=function(){return this},s;function a(p){return function(b){return Promise.resolve(b).then(p,u)}}function o(p,b){n[p]&&(s[p]=function(v){return new Promise(function(_,g){r.push([p,v,_,g])>1||c(p,v)})},b&&(s[p]=b(s[p])))}function c(p,b){try{l(n[p](b))}catch(v){d(r[0][3],v)}}function l(p){p.value instanceof wo?Promise.resolve(p.value.v).then(h,u):d(r[0][2],p)}function h(p){c("next",p)}function u(p){c("throw",p)}function d(p,b){p(b),r.shift(),r.length&&c(r[0][0],r[0][1])}}function Lv(i){var e,t;return e={},n("next"),n("throw",function(s){throw s}),n("return"),e[Symbol.iterator]=function(){return this},e;function n(s,r){e[s]=i[s]?function(a){return(t=!t)?{value:wo(i[s](a)),done:!1}:r?r(a):a}:r}}function Dv(i){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=i[Symbol.asyncIterator],t;return e?e.call(i):(i=typeof bf=="function"?bf(i):i[Symbol.iterator](),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(r){t[r]=i[r]&&function(a){return new Promise(function(o,c){a=i[r](a),s(o,c,a.done,a.value)})}}function s(r,a,o,c){Promise.resolve(c).then(function(l){r({value:l,done:o})},a)}}function Nv(i,e){return Object.defineProperty?Object.defineProperty(i,"raw",{value:e}):i.raw=e,i}function Ov(i){if(i&&i.__esModule)return i;var e={};if(i!=null)for(var t=Bg(i),n=0;n<t.length;n++)t[n]!=="default"&&_f(e,i,t[n]);return OI(e,i),e}function Fv(i){return i&&i.__esModule?i:{default:i}}function kv(i,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?i!==e||!n:!e.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(i):n?n.value:e.get(i)}function Uv(i,e,t,n,s){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?i!==e||!s:!e.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?s.call(i,t):s?s.value=t:e.set(i,t),t}function Bv(i,e){if(e===null||typeof e!="object"&&typeof e!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof i=="function"?e===i:i.has(e)}function zv(i,e,t){if(e!=null){if(typeof e!="object"&&typeof e!="function")throw new TypeError("Object expected.");var n,s;if(t){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");n=e[Symbol.asyncDispose]}if(n===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");n=e[Symbol.dispose],t&&(s=n)}if(typeof n!="function")throw new TypeError("Object not disposable.");s&&(n=function(){try{s.call(this)}catch(r){return Promise.reject(r)}}),i.stack.push({value:e,dispose:n,async:t})}else t&&i.stack.push({async:!0});return e}function Hv(i){function e(r){i.error=i.hasError?new FI(r,i.error,"An error was suppressed during disposal."):r,i.hasError=!0}var t,n=0;function s(){for(;t=i.stack.pop();)try{if(!t.async&&n===1)return n=0,i.stack.push(t),Promise.resolve().then(s);if(t.dispose){var r=t.dispose.call(t.value);if(t.async)return n|=2,Promise.resolve(r).then(s,function(a){return e(a),s()})}else n|=1}catch(a){e(a)}if(n===1)return i.hasError?Promise.reject(i.error):Promise.resolve();if(i.hasError)throw i.error}return s()}function Vv(i,e){return typeof i=="string"&&/^\.\.?\//.test(i)?i.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(t,n,s,r,a){return n?e?".jsx":".js":s&&(!r||!a)?t:s+r+"."+a.toLowerCase()+"js"}):i}var Ug,gf,_f,OI,Bg,FI,kI,Jc=un(()=>{Ug=function(i,e){return Ug=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])},Ug(i,e)};gf=function(){return gf=Object.assign||function(e){for(var t,n=1,s=arguments.length;n<s;n++){t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},gf.apply(this,arguments)};_f=Object.create?(function(i,e,t,n){n===void 0&&(n=t);var s=Object.getOwnPropertyDescriptor(e,t);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(i,n,s)}):(function(i,e,t,n){n===void 0&&(n=t),i[n]=e[t]});OI=Object.create?(function(i,e){Object.defineProperty(i,"default",{enumerable:!0,value:e})}):function(i,e){i.default=e},Bg=function(i){return Bg=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},Bg(i)};FI=typeof SuppressedError=="function"?SuppressedError:function(i,e,t){var n=new Error(t);return n.name="SuppressedError",n.error=i,n.suppressed=e,n};kI={__extends:gv,__assign:gf,__rest:bv,__decorate:_v,__param:xv,__esDecorate:yv,__runInitializers:vv,__propKey:Sv,__setFunctionName:wv,__metadata:Mv,__awaiter:Ev,__generator:Av,__createBinding:_f,__exportStar:Tv,__values:bf,__read:zg,__spread:Rv,__spreadArrays:Cv,__spreadArray:Iv,__await:wo,__asyncGenerator:Pv,__asyncDelegator:Lv,__asyncValues:Dv,__makeTemplateObject:Nv,__importStar:Ov,__importDefault:Fv,__classPrivateFieldGet:kv,__classPrivateFieldSet:Uv,__classPrivateFieldIn:Bv,__addDisposableResource:zv,__disposeResources:Hv,__rewriteRelativeImportExtension:Vv}});var Zc=xn(Mo=>{"use strict";Mo.CloseCode=void 0;(function(i){i[i.CONSENTED=4e3]="CONSENTED",i[i.DEVMODE_RESTART=4010]="DEVMODE_RESTART"})(Mo.CloseCode||(Mo.CloseCode={}));var Hg=class extends Error{constructor(e,t){super(t),this.name="ServerError",this.code=e}},Vg=class extends Error{constructor(e){super(e),this.name="AbortError"}};Mo.AbortError=Vg;Mo.ServerError=Hg});var yf=xn((xf,Gv)=>{(function(i,e){typeof xf=="object"&&typeof Gv<"u"?e(xf):typeof define=="function"&&define.amd?define(["exports"],e):(i=typeof globalThis<"u"?globalThis:i||self,e(i.schema={}))})(xf,(function(i){"use strict";i.OPERATION=void 0,(function(R){R[R.ADD=128]="ADD",R[R.REPLACE=0]="REPLACE",R[R.DELETE=64]="DELETE",R[R.DELETE_AND_MOVE=96]="DELETE_AND_MOVE",R[R.MOVE_AND_ADD=160]="MOVE_AND_ADD",R[R.DELETE_AND_ADD=192]="DELETE_AND_ADD",R[R.CLEAR=10]="CLEAR",R[R.REVERSE=15]="REVERSE",R[R.MOVE=32]="MOVE",R[R.DELETE_BY_REFID=33]="DELETE_BY_REFID",R[R.ADD_BY_REFID=129]="ADD_BY_REFID"})(i.OPERATION||(i.OPERATION={})),Symbol.metadata??=Symbol.for("Symbol.metadata");let n="~track",s="~encoder",r="~decoder",a="~filter",o="~getByIndex",c="~deleteByIndex",l="~changes",h="~childType",u="~onEncodeEnd",d="~onDecodeEnd",p="~descriptors",b="~__numFields",v="~__refTypeFieldIndexes",_="~__viewFieldIndexes",g="$__fieldIndexesByViewTag",E;try{E=new TextEncoder}catch{}let L=new ArrayBuffer(8),S=new Int32Array(L),M=new Float32Array(L),A=new Float64Array(L),I=new BigInt64Array(L),C=typeof Buffer<"u"&&Buffer.byteLength?Buffer.byteLength:function(R,f){for(var m=0,x=0,T=0,B=R.length;T<B;T++)m=R.charCodeAt(T),m<128?x+=1:m<2048?x+=2:m<55296||m>=57344?x+=3:(T++,x+=4);return x};function k(R,f,m){for(var x=0,T=0,B=f.length;T<B;T++)x=f.charCodeAt(T),x<128?R[m.offset++]=x:x<2048?(R[m.offset]=192|x>>6,R[m.offset+1]=128|x&63,m.offset+=2):x<55296||x>=57344?(R[m.offset]=224|x>>12,R[m.offset+1]=128|x>>6&63,R[m.offset+2]=128|x&63,m.offset+=3):(T++,x=65536+((x&1023)<<10|f.charCodeAt(T)&1023),R[m.offset]=240|x>>18,R[m.offset+1]=128|x>>12&63,R[m.offset+2]=128|x>>6&63,R[m.offset+3]=128|x&63,m.offset+=4)}function z(R,f,m){R[m.offset++]=f&255}function $(R,f,m){R[m.offset++]=f&255}function K(R,f,m){R[m.offset++]=f&255,R[m.offset++]=f>>8&255}function P(R,f,m){R[m.offset++]=f&255,R[m.offset++]=f>>8&255}function N(R,f,m){R[m.offset++]=f&255,R[m.offset++]=f>>8&255,R[m.offset++]=f>>16&255,R[m.offset++]=f>>24&255}function O(R,f,m){let x=f>>24,T=f>>16,B=f>>8,Y=f;R[m.offset++]=Y&255,R[m.offset++]=B&255,R[m.offset++]=T&255,R[m.offset++]=x&255}function F(R,f,m){let x=Math.floor(f/Math.pow(2,32)),T=f>>>0;O(R,T,m),O(R,x,m)}function H(R,f,m){let x=f/Math.pow(2,32)>>0,T=f>>>0;O(R,T,m),O(R,x,m)}function V(R,f,m){I[0]=BigInt.asIntN(64,f),N(R,S[0],m),N(R,S[1],m)}function Q(R,f,m){I[0]=BigInt.asIntN(64,f),N(R,S[0],m),N(R,S[1],m)}function te(R,f,m){M[0]=f,N(R,S[0],m)}function Se(R,f,m){A[0]=f,N(R,S[0],m),N(R,S[1],m)}function ve(R,f,m){R[m.offset++]=f?1:0}function nt(R,f,m){f||(f="");let x=C(f,"utf8"),T=0;if(x<32)R[m.offset++]=x|160,T=1;else if(x<256)R[m.offset++]=217,R[m.offset++]=x%255,T=2;else if(x<65536)R[m.offset++]=218,P(R,x,m),T=3;else if(x<4294967296)R[m.offset++]=219,O(R,x,m),T=5;else throw new Error("String too long");return k(R,f,m),T+x}function je(R,f,m){if(isNaN(f))return je(R,0,m);if(isFinite(f)){if(f!==(f|0))return Math.abs(f)<=34028235e31&&(M[0]=f,Math.abs(Math.abs(M[0])-Math.abs(f))<1e-4)?(R[m.offset++]=202,te(R,f,m),5):(R[m.offset++]=203,Se(R,f,m),9)}else return je(R,f>0?Number.MAX_SAFE_INTEGER:-Number.MAX_SAFE_INTEGER,m);return f>=0?f<128?(R[m.offset++]=f&255,1):f<256?(R[m.offset++]=204,R[m.offset++]=f&255,2):f<65536?(R[m.offset++]=205,P(R,f,m),3):f<4294967296?(R[m.offset++]=206,O(R,f,m),5):(R[m.offset++]=207,H(R,f,m),9):f>=-32?(R[m.offset++]=224|f+32,1):f>=-128?(R[m.offset++]=208,z(R,f,m),2):f>=-32768?(R[m.offset++]=209,K(R,f,m),3):f>=-2147483648?(R[m.offset++]=210,N(R,f,m),5):(R[m.offset++]=211,F(R,f,m),9)}let Qe={int8:z,uint8:$,int16:K,uint16:P,int32:N,uint32:O,int64:F,uint64:H,bigint64:V,biguint64:Q,float32:te,float64:Se,boolean:ve,string:nt,number:je,utf8Write:k,utf8Length:C},fe=new ArrayBuffer(8),ge=new Int32Array(fe),Ve=new Float32Array(fe),it=new Float64Array(fe),Ue=new BigUint64Array(fe),ct=new BigInt64Array(fe);function zt(R,f,m){m>R.length-f.offset&&(m=R.length-f.offset);for(var x="",T=0,B=f.offset,Y=f.offset+m;B<Y;B++){var me=R[B];if((me&128)===0){x+=String.fromCharCode(me);continue}if((me&224)===192){x+=String.fromCharCode((me&31)<<6|R[++B]&63);continue}if((me&240)===224){x+=String.fromCharCode((me&15)<<12|(R[++B]&63)<<6|(R[++B]&63)<<0);continue}if((me&248)===240){T=(me&7)<<18|(R[++B]&63)<<12|(R[++B]&63)<<6|(R[++B]&63)<<0,T>=65536?(T-=65536,x+=String.fromCharCode((T>>>10)+55296,(T&1023)+56320)):x+=String.fromCharCode(T);continue}console.error("decode.utf8Read(): Invalid byte "+me+" at offset "+B+". Skip to end of string: "+(f.offset+m));break}return f.offset+=m,x}function ot(R,f){return mt(R,f)<<24>>24}function mt(R,f){return R[f.offset++]}function Lt(R,f){return ft(R,f)<<16>>16}function ft(R,f){return R[f.offset++]|R[f.offset++]<<8}function xt(R,f){return R[f.offset++]|R[f.offset++]<<8|R[f.offset++]<<16|R[f.offset++]<<24}function Wt(R,f){return xt(R,f)>>>0}function _n(R,f){return ge[0]=xt(R,f),Ve[0]}function Ht(R,f){return ge[0]=xt(R,f),ge[1]=xt(R,f),it[0]}function Kt(R,f){let m=Wt(R,f);return xt(R,f)*Math.pow(2,32)+m}function q(R,f){let m=Wt(R,f);return Wt(R,f)*Math.pow(2,32)+m}function hn(R,f){return ge[0]=xt(R,f),ge[1]=xt(R,f),ct[0]}function Et(R,f){return ge[0]=xt(R,f),ge[1]=xt(R,f),Ue[0]}function U(R,f){return mt(R,f)>0}function w(R,f){let m=R[f.offset++],x;return m<192?x=m&31:m===217?x=mt(R,f):m===218?x=ft(R,f):m===219&&(x=Wt(R,f)),zt(R,f,x)}function ee(R,f){let m=R[f.offset++];if(m<128)return m;if(m===202)return _n(R,f);if(m===203)return Ht(R,f);if(m===204)return mt(R,f);if(m===205)return ft(R,f);if(m===206)return Wt(R,f);if(m===207)return q(R,f);if(m===208)return ot(R,f);if(m===209)return Lt(R,f);if(m===210)return xt(R,f);if(m===211)return Kt(R,f);if(m>223)return(255-m+1)*-1}function re(R,f){let m=R[f.offset];return m<192&&m>160||m===217||m===218||m===219}let ce={utf8Read:zt,int8:ot,uint8:mt,int16:Lt,uint16:ft,int32:xt,uint32:Wt,float32:_n,float64:Ht,int64:Kt,uint64:q,bigint64:hn,biguint64:Et,boolean:U,string:w,number:ee,stringCheck:re},Ee={},Ce=new Map;function de(R,f){f.constructor&&(Ce.set(f.constructor,R),Ee[R]=f),f.encode&&(Qe[R]=f.encode),f.decode&&(ce[R]=f.decode)}function xe(R){return Ee[R]}function Pe(R){for(let f in R)de(f,R[f]);return f=>ui(f)}let nn=class nn{static register(f){let m=Object.getPrototypeOf(f);if(m!==we){let x=nn.inheritedTypes.get(m);x||(x=new Set,nn.inheritedTypes.set(m,x)),x.add(f)}}static cache(f){let m=nn.cachedContexts.get(f);return m||(m=new nn(f),nn.cachedContexts.set(f,m)),m}constructor(f){this.types={},this.schemas=new Map,this.hasFilters=!1,this.parentFiltered={},f&&this.discoverTypes(f)}has(f){return this.schemas.has(f)}get(f){return this.types[f]}add(f,m=this.schemas.size){return this.schemas.has(f)?!1:(this.types[m]=f,f[Symbol.metadata]===void 0&&Fe.initialize(f),this.schemas.set(f,m),!0)}getTypeId(f){return this.schemas.get(f)}discoverTypes(f,m,x,T){if(T&&this.registerFilteredByParent(f,m,x),!this.add(f))return;nn.inheritedTypes.get(f)?.forEach(me=>{this.discoverTypes(me,m,x,T)});let B=f;for(;(B=Object.getPrototypeOf(B))&&B!==we&&B!==Function.prototype;)this.discoverTypes(B);let Y=f[Symbol.metadata]??={};Y[_]&&(this.hasFilters=!0);for(let me in Y){let ae=me,ue=Y[ae].type,pe=Y[ae].tag!==void 0;if(typeof ue!="string")if(typeof ue=="function")this.discoverTypes(ue,f,ae,T||pe);else{let he=Object.values(ue)[0];if(typeof he=="string")continue;this.discoverTypes(he,f,ae,T||pe)}}}registerFilteredByParent(f,m,x){let B=`${this.schemas.get(f)??this.schemas.size}`;m&&(B+=`-${this.schemas.get(m)}`),B+=`-${x}`,this.parentFiltered[B]=!0}debug(){let f="";for(let m in this.parentFiltered){let x=m.split("-").map(Number),T=x.pop();f+=`
+ `,f+=`${m}: ${x.reverse().map((B,Y)=>{let me=this.types[B],ae=me[Symbol.metadata],ue=me.name;return Y===0&&(ue+=`[${ae[T].name}]`),`${ue}`}).join(" -> ")}`}return`TypeContext ->
Schema types: ${this.schemas.size}
hasFilters: ${this.hasFilters}
- parentFiltered:${u}`}};sn.inheritedTypes=new Map,sn.cachedContexts=new Map;let Le=sn;function ve(R){if(Array.isArray(R))return{array:ve(R[0])};if(typeof R.type<"u")return R.type;if(Me(R))return Object.keys(R).every(u=>typeof R[u]=="string")?"string":"number";if(typeof R=="object"&&R!==null){let u=Object.keys(R).find(m=>Se[m]!==void 0);if(u)return R[u]=ve(R[u]),R}return R}function Me(R){if(typeof R=="function"&&R[Symbol.metadata])return!1;let u=Object.keys(R),m=u.filter(_=>/\d+/.test(_));return!!(m.length>0&&m.length===u.length/2&&R[R[m[0]]]==m[0]||u.length>0&&u.every(_=>typeof R[_]=="string"&&R[_]===_))}let je={addField(R,u,m,_,w){if(u>64)throw new Error(`Can't define field '${m}'.
-Schema instances may only have up to 64 fields.`);R[u]=Object.assign(R[u]||{},{type:ve(_),index:u,name:m}),Object.defineProperty(R,p,{value:R[p]||{},enumerable:!1,configurable:!0}),w?(R[p][m]=w,R[p][`_${m}`]={value:void 0,writable:!0,enumerable:!1,configurable:!0}):R[p][m]={value:void 0,writable:!0,enumerable:!0,configurable:!0},Object.defineProperty(R,x,{value:u,enumerable:!1,configurable:!0}),Object.defineProperty(R,m,{value:u,enumerable:!1,configurable:!0}),typeof R[u].type!="string"&&(R[y]===void 0&&Object.defineProperty(R,y,{value:[],enumerable:!1,configurable:!0}),R[y].push(u))},setTag(R,u,m){let _=R[u],w=R[_];w.tag=m,R[b]||(Object.defineProperty(R,b,{value:[],enumerable:!1,configurable:!0}),Object.defineProperty(R,g,{value:{},enumerable:!1,configurable:!0})),R[b].push(_),R[g][m]||(R[g][m]=[]),R[g][m].push(_)},setFields(R,u){let m=R.prototype.constructor;Le.register(m);let _=Object.getPrototypeOf(m),w=_&&_[Symbol.metadata],z=je.initialize(m);m[n]||(m[n]=Ie[n]),m[r]||(m[r]=Ie[r]),m[s]||(m[s]=Ie[s]),m.prototype.toJSON||(m.prototype.toJSON=Ie.prototype.toJSON);let X=z[x]??(w&&w[x])??-1;X++;for(let ue in u){let ne=ve(u[ue]),ae=typeof Object.keys(ne)[0]=="string"&&me(Object.keys(ne)[0]),he=ae?Object.values(ne)[0]:ne;je.addField(z,X,ue,ne,C(`_${ue}`,X,he,ae)),X++}return R},isDeprecated(R,u){return R[u].deprecated===!0},init(R){let u={};R[Symbol.metadata]=u,Object.defineProperty(u,x,{value:0,enumerable:!1,configurable:!0})},initialize(R){let u=Object.getPrototypeOf(R),m=u[Symbol.metadata],_=R[Symbol.metadata]??Object.create(null);return u!==Ie&&_===m&&(_=Object.create(null),m&&(Object.setPrototypeOf(_,m),Object.defineProperty(_,x,{value:m[x],enumerable:!1,configurable:!0,writable:!0}),m[b]!==void 0&&(Object.defineProperty(_,b,{value:[...m[b]],enumerable:!1,configurable:!0,writable:!0}),Object.defineProperty(_,g,{value:{...m[g]},enumerable:!1,configurable:!0,writable:!0})),m[y]!==void 0&&Object.defineProperty(_,y,{value:[...m[y]],enumerable:!1,configurable:!0,writable:!0}),Object.defineProperty(_,p,{value:{...m[p]},enumerable:!1,configurable:!0,writable:!0}))),Object.defineProperty(R,Symbol.metadata,{value:_,writable:!1,configurable:!0}),_},isValidInstance(R){return R.constructor[Symbol.metadata]&&Object.prototype.hasOwnProperty.call(R.constructor[Symbol.metadata],x)},getFields(R){let u=R[Symbol.metadata],m={};for(let _=0;_<=u[x];_++)m[u[_].name]=u[_].type;return m},hasViewTagAtIndex(R,u){return R?.[b]?.includes(u)}};function nt(R){return{indexes:{},operations:[],queueRootNode:R}}function pt(){return{next:void 0,tail:void 0}}function G(R,u){let m=R.indexes[u];m===void 0?R.indexes[u]=R.operations.push(u)-1:R.operations[m]=u}function we(R,u){let m=R.indexes[u];m===void 0&&(m=Object.values(R.indexes).at(-1),u=Object.entries(R.indexes).find(([_,w])=>w===m)?.[0]),R.operations[m]=void 0,delete R.indexes[u]}class de{constructor(u){this.isFiltered=!1,this.indexedOperations={},this.changes={indexes:{},operations:[]},this.allChanges={indexes:{},operations:[]},this.isNew=!0,this.ref=u,this.metadata=u.constructor[Symbol.metadata],this.metadata?.[b]&&(this.allFilteredChanges={indexes:{},operations:[]},this.filteredChanges={indexes:{},operations:[]})}setRoot(u){this.root=u;let m=this.root.add(this);this.checkIsFiltered(this.parent,this.parentIndex,m),m&&this.forEachChild((_,w)=>{_.root!==u?_.setRoot(u):u.add(_)})}setParent(u,m,_){if(this.addParent(u,_),!m)return;let w=m.add(this);m!==this.root&&(this.root=m,this.checkIsFiltered(u,_,w)),w&&this.forEachChild((z,X)=>{if(z.root===m){m.add(z),m.moveNextToParent(z);return}z.setParent(this.ref,m,X)})}forEachChild(u){if(this.ref[h]){if(typeof this.ref[h]!="string")for(let[m,_]of this.ref.entries())_&&u(_[c],this.indexes?.[m]??m)}else for(let m of this.metadata?.[y]??[]){let _=this.metadata[m],w=this.ref[_.name];w&&u(w[c],m)}}operation(u){this.filteredChanges!==void 0?(this.filteredChanges.operations.push(-u),this.root?.enqueueChangeTree(this,"filteredChanges")):(this.changes.operations.push(-u),this.root?.enqueueChangeTree(this,"changes"))}change(u,m=i.OPERATION.ADD){let _=this.isFiltered||this.metadata?.[u]?.tag!==void 0,w=_?this.filteredChanges:this.changes,z=this.indexedOperations[u];if(!z||z===i.OPERATION.DELETE){let X=z&&z===i.OPERATION.DELETE?i.OPERATION.DELETE_AND_ADD:m;this.indexedOperations[u]=X}G(w,u),_?(G(this.allFilteredChanges,u),this.root&&(this.root.enqueueChangeTree(this,"filteredChanges"),this.root.enqueueChangeTree(this,"allFilteredChanges"))):(G(this.allChanges,u),this.root?.enqueueChangeTree(this,"changes"))}shiftChangeIndexes(u){let m=this.isFiltered?this.filteredChanges:this.changes,_={},w={};for(let z in this.indexedOperations)_[Number(z)+u]=this.indexedOperations[z],w[Number(z)+u]=m.indexes[z];this.indexedOperations=_,m.indexes=w,m.operations=m.operations.map(z=>z+u)}shiftAllChangeIndexes(u,m=0){this.filteredChanges!==void 0?(this._shiftAllChangeIndexes(u,m,this.allFilteredChanges),this._shiftAllChangeIndexes(u,m,this.allChanges)):this._shiftAllChangeIndexes(u,m,this.allChanges)}_shiftAllChangeIndexes(u,m=0,_){let w={},z=0;for(let X in _.indexes)w[z++]=_.indexes[X];_.indexes=w;for(let X=0;X<_.operations.length;X++){let ue=_.operations[X];ue>m&&(_.operations[X]=ue+u)}}indexedOperation(u,m,_=u){this.indexedOperations[u]=m,this.filteredChanges!==void 0?(G(this.allFilteredChanges,_),G(this.filteredChanges,u),this.root?.enqueueChangeTree(this,"filteredChanges")):(G(this.allChanges,_),G(this.changes,u),this.root?.enqueueChangeTree(this,"changes"))}getType(u){return this.ref[h]||this.metadata[u].type}getChange(u){return this.indexedOperations[u]}getValue(u,m=!1){return this.ref[o](u,m)}delete(u,m,_=u){if(u===void 0){try{throw new Error(`@colyseus/schema ${this.ref.constructor.name}: trying to delete non-existing index '${u}'`)}catch(X){console.warn(X)}return}let w=this.filteredChanges!==void 0?this.filteredChanges:this.changes;this.indexedOperations[u]=m??i.OPERATION.DELETE,G(w,u),we(this.allChanges,_);let z=this.getValue(u);return z&&z[c]&&this.root?.remove(z[c]),this.filteredChanges!==void 0?(we(this.allFilteredChanges,_),this.root?.enqueueChangeTree(this,"filteredChanges")):this.root?.enqueueChangeTree(this,"changes"),z}endEncode(u){this.indexedOperations={},this[u]=nt(),this.ref[d]?.(),this.isNew=!1}discard(u=!1){this.ref[d]?.(),this.indexedOperations={},this.changes=nt(this.changes.queueRootNode),this.filteredChanges!==void 0&&(this.filteredChanges=nt(this.filteredChanges.queueRootNode)),u&&(this.allChanges=nt(this.allChanges.queueRootNode),this.allFilteredChanges!==void 0&&(this.allFilteredChanges=nt(this.allFilteredChanges.queueRootNode)))}discardAll(){let u=Object.keys(this.indexedOperations);for(let m=0,_=u.length;m<_;m++){let w=this.getValue(Number(u[m]));w&&w[c]&&w[c].discardAll()}this.discard()}get changed(){return Object.entries(this.indexedOperations).length>0}checkIsFiltered(u,m,_){this.root.types.hasFilters&&(this._checkFilteredByParent(u,m),this.filteredChanges!==void 0&&(this.root?.enqueueChangeTree(this,"filteredChanges"),_&&this.root?.enqueueChangeTree(this,"allFilteredChanges"))),this.isFiltered||(this.root?.enqueueChangeTree(this,"changes"),_&&this.root?.enqueueChangeTree(this,"allChanges"))}_checkFilteredByParent(u,m){if(!u)return;let _=je.isValidInstance(this.ref)?this.ref.constructor:this.ref[h],w,z=!je.isValidInstance(u);z?(w=u[c],u=w.parent,m=w.parentIndex):w=u[c];let X=u.constructor,ue=`${this.root.types.getTypeId(_)}`;X&&(ue+=`-${this.root.types.schemas.get(X)}`),ue+=`-${m}`;let ne=je.hasViewTagAtIndex(X?.[Symbol.metadata],m);this.isFiltered=u[c].isFiltered||this.root.types.parentFiltered[ue]||ne,this.isFiltered&&(this.isVisibilitySharedWithParent=w.isFiltered&&typeof _!="string"&&!ne&&z,this.filteredChanges||(this.filteredChanges=nt(),this.allFilteredChanges=nt()),this.changes.operations.length>0&&(this.changes.operations.forEach(ae=>G(this.filteredChanges,ae)),this.allChanges.operations.forEach(ae=>G(this.allFilteredChanges,ae)),this.changes=nt(),this.allChanges=nt()))}get parent(){return this.parentChain?.ref}get parentIndex(){return this.parentChain?.index}addParent(u,m){if(this.hasParent((_,w)=>_[c]===u[c])){this.parentChain.index=m;return}this.parentChain={ref:u,index:m,next:this.parentChain}}removeParent(u=this.parent){let m=this.parentChain,_=null;for(;m;){if(m.ref[c]===u[c])return _?_.next=m.next:this.parentChain=m.next,!0;_=m,m=m.next}return this.parentChain===void 0}findParent(u){let m=this.parentChain;for(;m;){if(u(m.ref,m.index))return m;m=m.next}}hasParent(u){return this.findParent(u)!==void 0}getAllParents(){let u=[],m=this.parentChain;for(;m;)u.push({ref:m.ref,index:m.index}),m=m.next;return u}}function He(R,u,m,_,w,z){typeof m=="string"?oe[m]?.(u,_,z):m[Symbol.metadata]!==void 0?(oe.number(u,_[c].refId,z),(w&i.OPERATION.ADD)===i.OPERATION.ADD&&R.tryEncodeTypeId(u,m,_.constructor,z)):oe.number(u,_[c].refId,z)}let Ae=function(R,u,m,_,w,z,X,ue,ne){if(u[z.offset++]=(_|w)&255,w===i.OPERATION.DELETE)return;let ae=m.ref,he=ne[_];He(R,u,ne[_].type,ae[he.name],w,z)},xe=function(R,u,m,_,w,z){if(u[z.offset++]=w&255,oe.number(u,_,z),w===i.OPERATION.DELETE)return;let X=m.ref;if((w&i.OPERATION.ADD)===i.OPERATION.ADD&&typeof X.set=="function"){let ae=m.ref.$indexes.get(_);oe.string(u,ae,z)}let ue=X[h],ne=X[o](_);He(R,u,ue,ne,w,z)},Xe=function(R,u,m,_,w,z,X,ue){let ne=m.ref,ae=ue&&m.isFiltered&&typeof m.getType(_)!="string",he;if(ae){let Oe=ne.tmpItems[_];if(!Oe)return;he=Oe[c].refId,w===i.OPERATION.DELETE?w=i.OPERATION.DELETE_BY_REFID:w===i.OPERATION.ADD&&(w=i.OPERATION.ADD_BY_REFID)}else he=_;if(u[z.offset++]=w&255,oe.number(u,he,z),w===i.OPERATION.DELETE||w===i.OPERATION.DELETE_BY_REFID)return;let se=m.getType(_),Ge=m.getValue(_,X);He(R,u,se,Ge,w,z)},rt=-1;function jt(R,u,m,_,w,z,X,ue){let ne=R.root,ae=m[o](_),he;if((u&i.OPERATION.DELETE)===i.OPERATION.DELETE){let se=ne.refIds.get(ae);se!==void 0&&ne.removeRef(se),u!==i.OPERATION.DELETE_AND_ADD&&m[l](_),he=void 0}if(u!==i.OPERATION.DELETE)if(Ie.is(w)){let se=ge.number(z,X);if(he=ne.refs.get(se),(u&i.OPERATION.ADD)===i.OPERATION.ADD){let Ge=R.getInstanceType(z,X,w);he||(he=R.createInstanceOfType(Ge)),ne.addRef(se,he,he!==ae||u===i.OPERATION.DELETE_AND_ADD&&he===ae)}}else if(typeof w=="string")he=ge[w](z,X);else{let se=me(Object.keys(w)[0]),Ge=ge.number(z,X),Oe=ne.refs.has(Ge)?ae||ne.refs.get(Ge):new se.constructor;if(he=Oe.clone(!0),he[h]=Object.values(w)[0],ae){let Re=ne.refIds.get(ae);if(Re!==void 0&&Ge!==Re){let ye=ae.entries(),$e;for(;($e=ye.next())&&!$e.done;){let[tn,nn]=$e.value;typeof nn=="object"&&(Re=ne.refIds.get(nn),ne.removeRef(Re)),ue.push({ref:ae,refId:Re,op:i.OPERATION.DELETE,field:tn,value:void 0,previousValue:nn})}}}ne.addRef(Ge,he,Oe!==ae||u===i.OPERATION.DELETE_AND_ADD&&Oe===ae)}return{value:he,previousValue:ae}}let Rt=function(R,u,m,_,w){let z=u[m.offset++],X=_.constructor[Symbol.metadata],ue=z>>6<<6,ne=z%(ue||255),ae=X[ne];if(ae===void 0)return console.warn("@colyseus/schema: field not defined at",{index:ne,ref:_.constructor.name,metadata:X}),rt;let{value:he,previousValue:se}=jt(R,ue,_,ne,ae.type,u,m,w);he!=null&&(_[ae.name]=he),se!==he&&w.push({ref:_,refId:R.currentRefId,op:ue,field:ae.name,value:he,previousValue:se})},$n=function(R,u,m,_,w){let z=u[m.offset++];if(z===i.OPERATION.CLEAR){R.removeChildRefs(_,w),_.clear();return}let X=ge.number(u,m),ue=_[h],ne;(z&i.OPERATION.ADD)===i.OPERATION.ADD?typeof _.set=="function"?(ne=ge.string(u,m),_.setIndex(X,ne)):ne=X:ne=_.getIndex(X);let{value:ae,previousValue:he}=jt(R,z,_,X,ue,u,m,w);if(ae!=null){if(typeof _.set=="function")_.$items.set(ne,ae);else if(typeof _.$setAt=="function")_.$setAt(X,ae,z);else if(typeof _.add=="function"){let se=_.add(ae);typeof se=="number"&&_.setIndex(se,se)}}he!==ae&&w.push({ref:_,refId:R.currentRefId,op:z,field:"",dynamicIndex:ne,value:ae,previousValue:he})},ui=function(R,u,m,_,w){let z=u[m.offset++],X;if(z===i.OPERATION.CLEAR){R.removeChildRefs(_,w),_.clear();return}else if(z===i.OPERATION.REVERSE){_.reverse();return}else if(z===i.OPERATION.DELETE_BY_REFID){let se=ge.number(u,m),Ge=R.root.refs.get(se);X=_.findIndex(Oe=>Oe===Ge),_[l](X),w.push({ref:_,refId:R.currentRefId,op:i.OPERATION.DELETE,field:"",dynamicIndex:X,value:void 0,previousValue:Ge});return}else if(z===i.OPERATION.ADD_BY_REFID){let se=ge.number(u,m),Ge=R.root.refs.get(se);Ge&&(X=_.findIndex(Oe=>Oe===Ge)),(X===-1||X===void 0)&&(X=_.length)}else X=ge.number(u,m);let ue=_[h],ne=X,{value:ae,previousValue:he}=jt(R,z,_,X,ue,u,m,w);ae!=null&&ae!==he&&_.$setAt(X,ae,z),he!==ae&&w.push({ref:_,refId:R.currentRefId,op:z,field:"",dynamicIndex:ne,value:ae,previousValue:he})};class Hs extends Error{}function Ou(R,u,m,_){let w,z=!1;switch(u){case"number":case"int8":case"uint8":case"int16":case"uint16":case"int32":case"uint32":case"int64":case"uint64":case"float32":case"float64":w="number",isNaN(R)&&console.log(`trying to encode "NaN" in ${m.constructor.name}#${_}`);break;case"bigint64":case"biguint64":w="bigint";break;case"string":w="string",z=!0;break;case"boolean":return;default:return}if(typeof R!==w&&(!z||z&&R!==null)){let X=`'${JSON.stringify(R)}'${R&&R.constructor&&` (${R.constructor.name})`||""}`;throw new Hs(`a '${w}' was expected, but ${X} was provided in ${m.constructor.name}#${_}`)}}function ns(R,u,m,_){if(!(R instanceof u))throw new Hs(`a '${u.name}' was expected, but '${R&&R.constructor.name}' was provided in ${m.constructor.name}#${_}`)}var ka,zi;let Ba=(R,u)=>{let m=R.toString(),_=u.toString();return m<_?-1:m>_?1:0},hn=class hn{static[(ka=r,zi=s,a)](u,m,_){return!_||typeof u[h]=="string"||_.isChangeTreeVisible(u.tmpItems[m]?.[c])}static is(u){return Array.isArray(u)||u.array!==void 0}static from(u){return new hn(...Array.from(u))}constructor(...u){this.items=[],this.tmpItems=[],this.deletedIndexes={},this.isMovingItems=!1,Object.defineProperty(this,h,{value:void 0,enumerable:!1,writable:!0,configurable:!0});let m=new Proxy(this,{get:(_,w)=>typeof w!="symbol"&&!isNaN(w)?this.items[w]:Reflect.get(_,w),set:(_,w,z)=>{if(typeof w!="symbol"&&!isNaN(w)){if(z==null)_.$deleteAt(w);else{if(z[c]){ns(z,_[h],_,w);let X=_.items[w];_.isMovingItems?(X!==void 0?z[c].isNew?_[c].indexedOperation(Number(w),i.OPERATION.MOVE_AND_ADD):(_[c].getChange(Number(w))&i.OPERATION.DELETE)===i.OPERATION.DELETE?_[c].indexedOperation(Number(w),i.OPERATION.DELETE_AND_MOVE):_[c].indexedOperation(Number(w),i.OPERATION.MOVE):z[c].isNew&&_[c].indexedOperation(Number(w),i.OPERATION.ADD),z[c].setParent(this,_[c].root,w)):_.$changeAt(Number(w),z),X!==void 0&&X[c].root?.remove(X[c])}else _.$changeAt(Number(w),z);_.items[w]=z,_.tmpItems[w]=z}return!0}else return Reflect.set(_,w,z)},deleteProperty:(_,w)=>(typeof w=="number"?_.$deleteAt(w):delete _[w],!0),has:(_,w)=>typeof w!="symbol"&&!isNaN(Number(w))?Reflect.has(this.items,w):Reflect.has(_,w)});return Object.defineProperty(this,c,{value:new de(m),enumerable:!1,writable:!0}),u.length>0&&this.push(...u),m}set length(u){u===0?this.clear():u<this.items.length?this.splice(u,this.length-u):console.warn("ArraySchema: can't set .length to a higher value than its length.")}get length(){return this.items.length}push(...u){let m=this.tmpItems.length,_=this[c];for(let w=0,z=u.length;w<z;w++,m++){let X=u[w];if(X==null)return;typeof X=="object"&&this[h]&&ns(X,this[h],this,w),_.indexedOperation(m,i.OPERATION.ADD,this.items.length),this.items.push(X),this.tmpItems.push(X),X[c]?.setParent(this,_.root,m)}return m}pop(){let u=-1;for(let m=this.tmpItems.length-1;m>=0;m--)if(this.deletedIndexes[m]!==!0){u=m;break}if(!(u<0))return this[c].delete(u,void 0,this.items.length-1),this.deletedIndexes[u]=!0,this.items.pop()}at(u){return u<0&&(u+=this.length),this.items[u]}$changeAt(u,m){if(m==null){console.error("ArraySchema items cannot be null nor undefined; Use `deleteAt(index)` instead.");return}if(this.items[u]===m)return;let _=this.items[u]!==void 0?typeof m=="object"?i.OPERATION.DELETE_AND_ADD:i.OPERATION.REPLACE:i.OPERATION.ADD,w=this[c];w.change(u,_),m[c]?.setParent(this,w.root,u)}$deleteAt(u,m){this[c].delete(u,m)}$setAt(u,m,_){u===0&&_===i.OPERATION.ADD&&this.items[u]!==void 0?this.items.unshift(m):_===i.OPERATION.DELETE_AND_MOVE?(this.items.splice(u,1),this.items[u]=m):this.items[u]=m}clear(){if(this.items.length===0)return;let u=this[c];u.forEachChild((m,_)=>{u.root?.remove(m)}),u.discard(!0),u.operation(i.OPERATION.CLEAR),this.items.length=0,this.tmpItems.length=0}concat(...u){return new hn(...this.items.concat(...u))}join(u){return this.items.join(u)}reverse(){return this[c].operation(i.OPERATION.REVERSE),this.items.reverse(),this.tmpItems.reverse(),this}shift(){if(this.items.length===0)return;let u=this[c],m=this.tmpItems.findIndex(w=>w===this.items[0]),_=this.items.findIndex(w=>w===this.items[0]);return u.delete(m,i.OPERATION.DELETE,_),u.shiftAllChangeIndexes(-1,_),this.deletedIndexes[m]=!0,this.items.shift()}slice(u,m){let _=new hn;return _.push(...this.items.slice(u,m)),_}sort(u=Ba){this.isMovingItems=!0;let m=this[c];return this.items.sort(u).forEach((w,z)=>m.change(z,i.OPERATION.REPLACE)),this.tmpItems.sort(u),this.isMovingItems=!1,this}splice(u,m,..._){let w=this[c],z=this.items.length,X=this.tmpItems.length,ue=_.length,ne=[];for(let ae=0;ae<X;ae++)this.deletedIndexes[ae]!==!0&&ne.push(ae);if(z>u){m===void 0&&(m=z-u);for(let ae=u;ae<u+m;ae++){let he=ne[ae];w.delete(he,i.OPERATION.DELETE),this.deletedIndexes[he]=!0}}else m=0;if(ue>0){if(ue>m)throw console.error("Inserting more elements than deleting during ArraySchema#splice()"),new Error("ArraySchema#splice(): insertCount must be equal or lower than deleteCount.");for(let ae=0;ae<ue;ae++){let he=(ne[u]??z)+ae;w.indexedOperation(he,this.deletedIndexes[he]?i.OPERATION.DELETE_AND_ADD:i.OPERATION.ADD),_[ae][c]?.setParent(this,w.root,he)}}return m>ue&&w.shiftAllChangeIndexes(-(m-ue),ne[u+ue]),w.filteredChanges!==void 0?w.root?.enqueueChangeTree(w,"filteredChanges"):w.root?.enqueueChangeTree(w,"changes"),this.items.splice(u,m,..._)}unshift(...u){let m=this[c];return m.shiftChangeIndexes(u.length),m.isFiltered?G(m.filteredChanges,this.items.length):G(m.allChanges,this.items.length),u.forEach((_,w)=>{m.change(w,i.OPERATION.ADD)}),this.tmpItems.unshift(...u),this.items.unshift(...u)}indexOf(u,m){return this.items.indexOf(u,m)}lastIndexOf(u,m=this.length-1){return this.items.lastIndexOf(u,m)}every(u,m){return this.items.every(u,m)}some(u,m){return this.items.some(u,m)}forEach(u,m){return this.items.forEach(u,m)}map(u,m){return this.items.map(u,m)}filter(u,m){return this.items.filter(u,m)}reduce(u,m){return this.items.reduce(u,m)}reduceRight(u,m){return this.items.reduceRight(u,m)}find(u,m){return this.items.find(u,m)}findIndex(u,m){return this.items.findIndex(u,m)}fill(u,m,_){throw new Error("ArraySchema#fill() not implemented")}copyWithin(u,m,_){throw new Error("ArraySchema#copyWithin() not implemented")}toString(){return this.items.toString()}toLocaleString(){return this.items.toLocaleString()}[Symbol.iterator](){return this.items[Symbol.iterator]()}static get[Symbol.species](){return hn}entries(){return this.items.entries()}keys(){return this.items.keys()}values(){return this.items.values()}includes(u,m){return this.items.includes(u,m)}flatMap(u,m){throw new Error("ArraySchema#flatMap() is not supported.")}flat(u){throw new Error("ArraySchema#flat() is not supported.")}findLast(){return this.items.findLast.apply(this.items,arguments)}findLastIndex(...u){return this.items.findLastIndex.apply(this.items,arguments)}with(u,m){let _=this.items.slice();return u<0&&(u+=this.length),_[u]=m,new hn(..._)}toReversed(){return this.items.slice().reverse()}toSorted(u){return this.items.slice().sort(u)}toSpliced(u,m,..._){return this.items.toSpliced.apply(copy,arguments)}shuffle(){return this.move(u=>{let m=this.items.length;for(;m!=0;){let _=Math.floor(Math.random()*m);m--,[this[m],this[_]]=[this[_],this[m]]}})}move(u){return this.isMovingItems=!0,u(this),this.isMovingItems=!1,this}[o](u,m=!1){return m?this.items[u]:this.deletedIndexes[u]?this.items[u]:this.tmpItems[u]||this.items[u]}[l](u){this.items[u]=void 0,this.tmpItems[u]=void 0}[d](){this.tmpItems=this.items.slice(),this.deletedIndexes={}}[f](){this.items=this.items.filter(u=>u!==void 0),this.tmpItems=this.items.slice()}toArray(){return this.items.slice(0)}toJSON(){return this.toArray().map(u=>typeof u.toJSON=="function"?u.toJSON():u)}clone(u){let m;return u?(m=new hn,m.push(...this.items)):m=new hn(...this.map(_=>_[c]?_.clone():_)),m}};hn[ka]=Xe,hn[zi]=ui;let jn=hn;ce("array",{constructor:jn});var za,is;let kn=class kn{static[(za=r,is=s,a)](u,m,_){return!_||typeof u[h]=="string"||_.isChangeTreeVisible((u[o](m)??u.deletedItems[m])[c])}static is(u){return u.map!==void 0}constructor(u){this.$items=new Map,this.$indexes=new Map,this.deletedItems={};let m=new de(this);if(m.indexes={},Object.defineProperty(this,c,{value:m,enumerable:!1,writable:!0}),u)if(u instanceof Map||u instanceof kn)u.forEach((_,w)=>this.set(w,_));else for(let _ in u)this.set(_,u[_]);Object.defineProperty(this,h,{value:void 0,enumerable:!1,writable:!0,configurable:!0})}[Symbol.iterator](){return this.$items[Symbol.iterator]()}get[Symbol.toStringTag](){return this.$items[Symbol.toStringTag]}static get[Symbol.species](){return kn}set(u,m){if(m==null)throw new Error(`MapSchema#set('${u}', ${m}): trying to set ${m} value on '${u}'.`);typeof m=="object"&&this[h]&&ns(m,this[h],this,u),u=u.toString();let _=this[c],w=m[c]!==void 0,z,X;if(typeof _.indexes[u]<"u"){z=_.indexes[u],X=i.OPERATION.REPLACE;let ue=this.$items.get(u);if(ue===m)return;w&&(X=i.OPERATION.DELETE_AND_ADD,ue!==void 0&&ue[c].root?.remove(ue[c])),this.deletedItems[z]&&delete this.deletedItems[z]}else z=_.indexes[x]??0,X=i.OPERATION.ADD,this.$indexes.set(z,u),_.indexes[u]=z,_.indexes[x]=z+1;return this.$items.set(u,m),_.change(z,X),w&&m[c].setParent(this,_.root,z),this}get(u){return this.$items.get(u)}delete(u){if(!this.$items.has(u))return!1;let m=this[c].indexes[u];return this.deletedItems[m]=this[c].delete(m),this.$items.delete(u)}clear(){let u=this[c];u.discard(!0),u.indexes={},u.forEachChild((m,_)=>{u.root?.remove(m)}),this.$indexes.clear(),this.$items.clear(),u.operation(i.OPERATION.CLEAR)}has(u){return this.$items.has(u)}forEach(u){this.$items.forEach(u)}entries(){return this.$items.entries()}keys(){return this.$items.keys()}values(){return this.$items.values()}get size(){return this.$items.size}setIndex(u,m){this.$indexes.set(u,m)}getIndex(u){return this.$indexes.get(u)}[o](u){return this.$items.get(this.$indexes.get(u))}[l](u){let m=this.$indexes.get(u);this.$items.delete(m),this.$indexes.delete(u)}[d](){let u=this[c];for(let m in this.deletedItems){let _=parseInt(m),w=this.$indexes.get(_);delete u.indexes[w],this.$indexes.delete(_)}this.deletedItems={}}toJSON(){let u={};return this.forEach((m,_)=>{u[_]=typeof m.toJSON=="function"?m.toJSON():m}),u}clone(u){let m;return u?m=Object.assign(new kn,this):(m=new kn,this.forEach((_,w)=>{_[c]?m.set(w,_.clone()):m.set(w,_)})),m}};kn[za]=xe,kn[is]=$n;let di=kn;ce("map",{constructor:di});var rs,Ha;let At=class At{static[(rs=r,Ha=s,a)](u,m,_){return!_||typeof u[h]=="string"||_.isChangeTreeVisible((u[o](m)??u.deletedItems[m])[c])}static is(u){return u.collection!==void 0}constructor(u){this.$items=new Map,this.$indexes=new Map,this.deletedItems={},this.$refId=0,this[c]=new de(this),this[c].indexes={},u&&u.forEach(m=>this.add(m)),Object.defineProperty(this,h,{value:void 0,enumerable:!1,writable:!0,configurable:!0})}add(u){let m=this.$refId++;return u[c]!==void 0&&u[c].setParent(this,this[c].root,m),this[c].indexes[m]=m,this.$indexes.set(m,m),this.$items.set(m,u),this[c].change(m),m}at(u){let m=Array.from(this.$items.keys())[u];return this.$items.get(m)}entries(){return this.$items.entries()}delete(u){let m=this.$items.entries(),_,w;for(;(w=m.next())&&!w.done;)if(u===w.value[1]){_=w.value[0];break}return _===void 0?!1:(this.deletedItems[_]=this[c].delete(_),this.$indexes.delete(_),this.$items.delete(_))}clear(){let u=this[c];u.discard(!0),u.indexes={},u.forEachChild((m,_)=>{u.root?.remove(m)}),this.$indexes.clear(),this.$items.clear(),u.operation(i.OPERATION.CLEAR)}has(u){return Array.from(this.$items.values()).some(m=>m===u)}forEach(u){this.$items.forEach((m,_,w)=>u(m,_,this))}values(){return this.$items.values()}get size(){return this.$items.size}[Symbol.iterator](){return this.$items.values()}setIndex(u,m){this.$indexes.set(u,m)}getIndex(u){return this.$indexes.get(u)}[o](u){return this.$items.get(this.$indexes.get(u))}[l](u){let m=this.$indexes.get(u);this.$items.delete(m),this.$indexes.delete(u)}[d](){this.deletedItems={}}toArray(){return Array.from(this.$items.values())}toJSON(){let u=[];return this.forEach((m,_)=>{u.push(typeof m.toJSON=="function"?m.toJSON():m)}),u}clone(u){let m;return u?m=Object.assign(new At,this):(m=new At,this.forEach(_=>{_[c]?m.add(_.clone()):m.add(_)})),m}};At[rs]=xe,At[Ha]=$n;let sr=At;ce("collection",{constructor:sr});var _c,yc;let Ft=class Ft{static[(_c=r,yc=s,a)](u,m,_){return!_||typeof u[h]=="string"||_.visible.has((u[o](m)??u.deletedItems[m])[c])}static is(u){return u.set!==void 0}constructor(u){this.$items=new Map,this.$indexes=new Map,this.deletedItems={},this.$refId=0,this[c]=new de(this),this[c].indexes={},u&&u.forEach(m=>this.add(m)),Object.defineProperty(this,h,{value:void 0,enumerable:!1,writable:!0,configurable:!0})}add(u){if(this.has(u))return!1;let m=this.$refId++;u[c]!==void 0&&u[c].setParent(this,this[c].root,m);let _=this[c].indexes[m]?.op??i.OPERATION.ADD;return this[c].indexes[m]=m,this.$indexes.set(m,m),this.$items.set(m,u),this[c].change(m,_),m}entries(){return this.$items.entries()}delete(u){let m=this.$items.entries(),_,w;for(;(w=m.next())&&!w.done;)if(u===w.value[1]){_=w.value[0];break}return _===void 0?!1:(this.deletedItems[_]=this[c].delete(_),this.$indexes.delete(_),this.$items.delete(_))}clear(){let u=this[c];u.discard(!0),u.indexes={},this.$indexes.clear(),this.$items.clear(),u.operation(i.OPERATION.CLEAR)}has(u){let m=this.$items.values(),_=!1,w;for(;(w=m.next())&&!w.done;)if(u===w.value){_=!0;break}return _}forEach(u){this.$items.forEach((m,_,w)=>u(m,_,this))}values(){return this.$items.values()}get size(){return this.$items.size}[Symbol.iterator](){return this.$items.values()}setIndex(u,m){this.$indexes.set(u,m)}getIndex(u){return this.$indexes.get(u)}[o](u){return this.$items.get(this.$indexes.get(u))}[l](u){let m=this.$indexes.get(u);this.$items.delete(m),this.$indexes.delete(u)}[d](){this.deletedItems={}}toArray(){return Array.from(this.$items.values())}toJSON(){let u=[];return this.forEach((m,_)=>{u.push(typeof m.toJSON=="function"?m.toJSON():m)}),u}clone(u){let m;return u?m=Object.assign(new Ft,this):(m=new Ft,this.forEach(_=>{_[c]?m.add(_.clone()):m.add(_)})),m}};Ft[_c]=xe,Ft[yc]=$n;let wr=Ft;ce("set",{constructor:wr});let Mi=-1;function Fu(R){return Le.register(R),R}function vc(R=Mi){return function(u,m){let _=u.constructor,z=Object.getPrototypeOf(_)[Symbol.metadata],X=_[Symbol.metadata]??=Object.assign({},_[Symbol.metadata],z??Object.create(null));je.setTag(X,m,R)}}function ni(R,u){return function(m,_){let w=m.constructor;if(!R)throw new Error(`${w.name}: @type() reference provided for "${_}" is undefined. Make sure you don't have any circular dependencies.`);R=ve(R),Le.register(w);let X=Object.getPrototypeOf(w)[Symbol.metadata],ue=je.initialize(w),ne=ue[_];if(ue[ne]!==void 0){if(ue[ne].deprecated)return;if(ue[ne].type!==void 0)try{throw new Error(`@colyseus/schema: Duplicate '${_}' definition on '${w.name}'.
-Check @type() annotation`)}catch(ae){let he=ae.stack.split(`
-`)[4].trim();throw new Error(`${ae.message} ${he}`)}}else ne=ue[x]??(X&&X[x])??-1,ne++;if(u&&u.manual)je.addField(ue,ne,_,R,{enumerable:!0,configurable:!0,writable:!0});else{let ae=typeof Object.keys(R)[0]=="string"&&me(Object.keys(R)[0]),he=ae?Object.values(R)[0]:R;je.addField(ue,ne,_,R,C(`_${_}`,ne,he,ae))}}}function C(R,u,m,_){return{get:function(){return this[R]},set:function(w){let z=this[R]??void 0;if(w!==z){if(w!=null){_?(_.constructor===jn&&!(w instanceof jn)&&(w=new jn(...w)),_.constructor===di&&!(w instanceof di)&&(w=new di(w)),w[h]=m):typeof m!="string"?ns(w,m,this,R.substring(1)):Ou(w,m,this,R.substring(1));let X=this[c];z!==void 0&&z[c]?(X.root?.remove(z[c]),this.constructor[n](X,u,i.OPERATION.DELETE_AND_ADD)):this.constructor[n](X,u,i.OPERATION.ADD),w[c]?.setParent(this,X.root,u)}else z!==void 0&&this[c].delete(u);this[R]=w}},enumerable:!0,configurable:!0}}function j(R=!0){return function(u,m){let _=u.constructor,z=Object.getPrototypeOf(_)[Symbol.metadata],X=_[Symbol.metadata]??=Object.assign({},_[Symbol.metadata],z??Object.create(null)),ue=X[m];X[ue].deprecated=!0,R&&(X[p]??={},X[p][m]={get:function(){throw new Error(`${m} is deprecated.`)},set:function(ne){},enumerable:!1,configurable:!0}),Object.defineProperty(X,ue,{value:X[ue],enumerable:!1,configurable:!0})}}function ie(R,u,m){for(let _ in u)ni(u[_],m)(R.prototype,_);return R}function ee(R,u,m=Ie){let _={},w={},z={},X={};for(let he in R){let se=R[he];typeof se=="object"?(se.view!==void 0&&(X[he]=typeof se.view=="boolean"?Mi:se.view),_[he]=ve(se),Object.prototype.hasOwnProperty.call(se,"default")?z[he]=se.default:Array.isArray(se)||se.array!==void 0?z[he]=new jn:se.map!==void 0?z[he]=new di:se.collection!==void 0?z[he]=new sr:se.set!==void 0?z[he]=new wr:se.type!==void 0&&Ie.is(se.type)&&(!se.type.prototype.initialize||se.type.prototype.initialize.length===0)&&(z[he]=new se.type)):typeof se=="function"?Ie.is(se)?((!se.prototype.initialize||se.prototype.initialize.length===0)&&(z[he]=new se),_[he]=ve(se)):w[he]=se:_[he]=ve(se)}let ue=()=>{let he={};for(let se in z){let Ge=z[se];Ge&&typeof Ge.clone=="function"?he[se]=Ge.clone():he[se]=Ge}return he},ne=he=>{let se=Object.keys(_),Ge={};for(let Oe in he)se.includes(Oe)||(Ge[Oe]=he[Oe]);return Ge},ae=je.setFields(class extends m{constructor(...he){w.initialize&&typeof w.initialize=="function"?(super(Object.assign({},ue(),ne(he[0]||{}))),new.target===ae&&w.initialize.apply(this,he)):super(Object.assign({},ue(),he[0]||{}))}},_);ae._getDefaultValues=ue,Object.assign(ae.prototype,w);for(let he in X)vc(X[he])(ae.prototype,he);return u&&Object.defineProperty(ae,"name",{value:u}),ae.extends=(he,se)=>ee(he,se,ae),ae}function Q(R){return new Array(R).fill(0).map((u,m)=>m===R-1?"\u2514\u2500 ":" ").join("")}function Fe(R){let u=R[c].root,m={ops:{},refs:[]},_=u.changes.next;for(;_;){let w=_.changeTree;if(w===void 0){_=_.next;continue}let z=w.indexedOperations;m.refs.push(`refId#${w.refId}`);for(let X in z){let ue=z[X],ne=i.OPERATION[ue];m.ops[ne]||(m.ops[ne]=0),m.ops[i.OPERATION[ue]]++}_=_.next}return m}var We,De;let Bn=class Bn{static initialize(u){Object.defineProperty(u,c,{value:new de(u),enumerable:!1,writable:!0}),Object.defineProperties(u,u.constructor[Symbol.metadata]?.[p]||{})}static is(u){return typeof u[Symbol.metadata]=="object"}static[(We=r,De=s,n)](u,m,_=i.OPERATION.ADD){u.change(m,_)}static[a](u,m,_){let z=u.constructor[Symbol.metadata][m]?.tag;if(_===void 0)return z===void 0;if(z===void 0)return!0;if(z===Mi)return _.isChangeTreeVisible(u[c]);{let X=_.tags?.get(u[c]);return X&&X.has(z)}}constructor(u){Bn.initialize(this),u&&Object.assign(this,u)}assign(u){return Object.assign(this,u),this}setDirty(u,m){let _=this.constructor[Symbol.metadata];this[c].change(_[_[u]].index,m)}clone(){let u=Object.create(this.constructor.prototype);Bn.initialize(u);let m=this.constructor[Symbol.metadata];for(let _ in m){let w=m[_].name;typeof this[w]=="object"&&typeof this[w]?.clone=="function"?u[w]=this[w].clone():u[w]=this[w]}return u}toJSON(){let u={},m=this.constructor[Symbol.metadata];for(let _ in m){let w=m[_],z=w.name;!w.deprecated&&this[z]!==null&&typeof this[z]<"u"&&(u[z]=typeof this[z].toJSON=="function"?this[z].toJSON():this[z])}return u}discardAllChanges(){this[c].discardAll()}[o](u){let m=this.constructor[Symbol.metadata];return this[m[u].name]}[l](u){let m=this.constructor[Symbol.metadata];this[m[u].name]=void 0}static debugRefIds(u,m=!1,_=0,w,z=""){let X=m?` - ${JSON.stringify(u.toJSON())}`:"",ue=u[c],ne=w?w.root.refIds.get(u):ue.refId,ae=w?w.root:ue.root,he=ae?.refCount?.[ne]>1?` [\xD7${ae.refCount[ne]}]`:"",se=`${Q(_)}${z}${u.constructor.name} (refId: ${ne})${he}${X}
-`;return ue.forEachChild((Ge,Oe)=>{let Re=Oe;typeof Oe=="number"&&u.$indexes&&(Re=u.$indexes.get(Oe)??Oe);let ye=u.forEach!==void 0&&Re!==void 0?`["${Re}"]: `:"";se+=this.debugRefIds(Ge.ref,m,_+1,w,ye)}),se}static debugRefIdEncodingOrder(u,m="allChanges"){let _=[],w=u[c].root[m].next;for(;w;)w.changeTree&&_.push(w.changeTree.refId),w=w.next;return _}static debugRefIdsFromDecoder(u){return this.debugRefIds(u.state,!1,0,u)}static debugChanges(u,m=!1){let _=u[c],w=m?_.allChanges:_.changes,z=m?"allChanges":"changes",X=`${u.constructor.name} (${_.refId}) -> .${z}:
-`;function ue(ne){ne.operations.filter(ae=>ae).forEach(ae=>{let he=_.indexedOperations[ae];X+=`- [${ae}]: ${i.OPERATION[he]} (${JSON.stringify(_.getValue(Number(ae),m))})
-`})}return ue(w),!m&&_.filteredChanges&&_.filteredChanges.operations.filter(ne=>ne).length>0&&(X+=`${u.constructor.name} (${_.refId}) -> .filteredChanges:
-`,ue(_.filteredChanges)),m&&_.allFilteredChanges&&_.allFilteredChanges.operations.filter(ne=>ne).length>0&&(X+=`${u.constructor.name} (${_.refId}) -> .allFilteredChanges:
-`,ue(_.allFilteredChanges)),X}static debugChangesDeep(u,m="changes"){let _="",w=u[c],z=w.root,X=new Map,ue=[],ne=0;for(let[he,se]of Object.entries(z[m])){let Ge=z.changeTrees[he];if(!Ge)continue;let Oe=!1,Re=[],ye=Ge.parent?.[c];if(Ge===w)Oe=!0;else for(;ye!==void 0;){if(Re.push(ye),ye.ref===u){Oe=!0;break}ye=ye.parent?.[c]}Oe&&(ue.push(Ge.refId),ne+=Object.keys(se).length,X.set(Ge,Re.reverse()))}_+=`---
-`,_+=`root refId: ${w.refId}
-`,_+=`Total instances: ${ue.length} (refIds: ${ue.join(", ")})
-`,_+=`Total changes: ${ne}
-`,_+=`---
-`;let ae=new WeakSet;for(let[he,se]of X.entries()){se.forEach(($e,tn)=>{ae.has($e)||(_+=`${Q(tn)}${$e.ref.constructor.name} (refId: ${$e.refId})
-`,ae.add($e))});let Ge=he.indexedOperations,Oe=se.length,Re=Q(Oe),ye=Oe>0?`(${he.parentIndex}) `:"";_+=`${Re}${ye}${he.ref.constructor.name} (refId: ${he.refId}) - changes: ${Object.keys(Ge).length}
-`;for(let $e in Ge){let tn=Ge[$e];_+=`${Q(Oe+1)}${i.OPERATION[tn]}: ${$e}
-`}}return`${_}`}};Bn[We]=Ae,Bn[De]=Rt;let Ie=Bn;function qe(R,u,m,_){var w=arguments.length,z=w<3?u:_===null?_=Object.getOwnPropertyDescriptor(u,m):_,X;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")z=Reflect.decorate(R,u,m,_);else for(var ue=R.length-1;ue>=0;ue--)(X=R[ue])&&(z=(w<3?X(z):w>3?X(u,m,z):X(u,m))||z);return w>3&&z&&Object.defineProperty(u,m,z),z}typeof SuppressedError=="function"&&SuppressedError;class st{constructor(u){this.types=u,this.nextUniqueId=0,this.refCount={},this.changeTrees={},this.allChanges=pt(),this.allFilteredChanges=pt(),this.changes=pt(),this.filteredChanges=pt()}getNextUniqueId(){return this.nextUniqueId++}add(u){u.refId===void 0&&(u.refId=this.getNextUniqueId());let m=this.changeTrees[u.refId]===void 0;m&&(this.changeTrees[u.refId]=u);let _=this.refCount[u.refId];if(_===0){let w=u.allChanges.operations,z=w.length;for(;z--;)u.indexedOperations[w[z]]=i.OPERATION.ADD,G(u.changes,z)}return this.refCount[u.refId]=(_||0)+1,m}remove(u){let m=this.refCount[u.refId]-1;return m<=0?(u.root=void 0,delete this.changeTrees[u.refId],this.removeChangeFromChangeSet("allChanges",u),this.removeChangeFromChangeSet("changes",u),u.filteredChanges&&(this.removeChangeFromChangeSet("allFilteredChanges",u),this.removeChangeFromChangeSet("filteredChanges",u)),this.refCount[u.refId]=0,u.forEachChild((_,w)=>{_.removeParent(u.ref)&&(_.parentChain===void 0||_.parentChain&&this.refCount[_.refId]>0?this.remove(_):_.parentChain&&this.moveNextToParent(_))})):(this.refCount[u.refId]=m,this.recursivelyMoveNextToParent(u)),m}recursivelyMoveNextToParent(u){this.moveNextToParent(u),u.forEachChild((m,_)=>this.recursivelyMoveNextToParent(m))}moveNextToParent(u){u.filteredChanges?(this.moveNextToParentInChangeTreeList("filteredChanges",u),this.moveNextToParentInChangeTreeList("allFilteredChanges",u)):(this.moveNextToParentInChangeTreeList("changes",u),this.moveNextToParentInChangeTreeList("allChanges",u))}moveNextToParentInChangeTreeList(u,m){let _=this[u],w=m[u].queueRootNode;if(!w)return;let z=m.parent;if(!z||!z[c])return;let X=z[c][u]?.queueRootNode;if(!X||X===w)return;let ue=X.position;w.position>ue||(w.prev?w.prev.next=w.next:_.next=w.next,w.next?w.next.prev=w.prev:_.tail=w.prev,w.prev=X,w.next=X.next,X.next?X.next.prev=w:_.tail=w,X.next=w,this.updatePositionsAfterMove(_,w,ue+1))}enqueueChangeTree(u,m,_=u[m].queueRootNode){_||(u[m].queueRootNode=this.addToChangeTreeList(this[m],u))}addToChangeTreeList(u,m){let _={changeTree:m,next:void 0,prev:void 0,position:u.tail?u.tail.position+1:0};return u.next?(_.prev=u.tail,u.tail.next=_,u.tail=_):(u.next=_,u.tail=_),_}updatePositionsAfterRemoval(u,m){let _=u.next,w=0;for(;_;)w>=m&&(_.position=w),_=_.next,w++}updatePositionsAfterMove(u,m,_){let w=u.next,z=0;for(;w;)w.position=z,w=w.next,z++}removeChangeFromChangeSet(u,m){let _=this[u],w=m[u].queueRootNode;if(w&&w.changeTree===m){let z=w.position;return w.prev?w.prev.next=w.next:_.next=w.next,w.next?w.next.prev=w.prev:_.tail=w.prev,this.updatePositionsAfterRemoval(_,z),m[u].queueRootNode=void 0,!0}return!1}}let It=class It{constructor(u){this.sharedBuffer=Buffer.allocUnsafe(It.BUFFER_SIZE),this.context=Le.cache(u.constructor),this.root=new st(this.context),this.setState(u)}setState(u){this.state=u,this.state[c].setRoot(this.root)}encode(u={offset:0},m,_=this.sharedBuffer,w="changes",z=w==="allChanges",X=u.offset){let ue=m!==void 0,ne=this.state[c],ae=this.root[w];for(;ae=ae.next;){let he=ae.changeTree;if(ue){if(!m.isChangeTreeVisible(he)){m.invisible.add(he);continue}m.invisible.delete(he)}let se=he[w],Ge=he.ref,Oe=se.operations.length;if(Oe===0)continue;let Re=Ge.constructor,ye=Re[r],$e=Re[a],tn=Re[Symbol.metadata];(ue||u.offset>X||he!==ne)&&(_[u.offset++]=255,oe.number(_,he.refId,u));for(let nn=0;nn<Oe;nn++){let ii=se.operations[nn];if(ii<0){_[u.offset++]=Math.abs(ii)&255;continue}let fi=z?i.OPERATION.ADD:he.indexedOperations[ii];ii===void 0||fi===void 0||$e&&!$e(Ge,ii,m)||ye(this,_,he,ii,fi,u,z,ue,tn)}}if(u.offset>_.byteLength){let he=Math.ceil(u.offset/(Buffer.poolSize??8192))*(Buffer.poolSize??8192);return console.warn(`@colyseus/schema buffer overflow. Encoded state is higher than default BUFFER_SIZE. Use the following to increase default BUFFER_SIZE:
+ parentFiltered:${f}`}};nn.inheritedTypes=new Map,nn.cachedContexts=new Map;let qe=nn;function Ae(R){if(Array.isArray(R))return{array:Ae(R[0])};if(typeof R.type<"u")return R.type;if(Le(R))return Object.keys(R).every(f=>typeof R[f]=="string")?"string":"number";if(typeof R=="object"&&R!==null){let f=Object.keys(R).find(m=>Ee[m]!==void 0);if(f)return R[f]=Ae(R[f]),R}return R}function Le(R){if(typeof R=="function"&&R[Symbol.metadata])return!1;let f=Object.keys(R),m=f.filter(x=>/\d+/.test(x));return!!(m.length>0&&m.length===f.length/2&&R[R[m[0]]]==m[0]||f.length>0&&f.every(x=>typeof R[x]=="string"&&R[x]===x))}let Fe={addField(R,f,m,x,T){if(f>64)throw new Error(`Can't define field '${m}'.
+Schema instances may only have up to 64 fields.`);R[f]=Object.assign(R[f]||{},{type:Ae(x),index:f,name:m}),Object.defineProperty(R,p,{value:R[p]||{},enumerable:!1,configurable:!0}),T?(R[p][m]=T,R[p][`_${m}`]={value:void 0,writable:!0,enumerable:!1,configurable:!0}):R[p][m]={value:void 0,writable:!0,enumerable:!0,configurable:!0},Object.defineProperty(R,b,{value:f,enumerable:!1,configurable:!0}),Object.defineProperty(R,m,{value:f,enumerable:!1,configurable:!0}),typeof R[f].type!="string"&&(R[v]===void 0&&Object.defineProperty(R,v,{value:[],enumerable:!1,configurable:!0}),R[v].push(f))},setTag(R,f,m){let x=R[f],T=R[x];T.tag=m,R[_]||(Object.defineProperty(R,_,{value:[],enumerable:!1,configurable:!0}),Object.defineProperty(R,g,{value:{},enumerable:!1,configurable:!0})),R[_].push(x),R[g][m]||(R[g][m]=[]),R[g][m].push(x)},setFields(R,f){let m=R.prototype.constructor;qe.register(m);let x=Object.getPrototypeOf(m),T=x&&x[Symbol.metadata],B=Fe.initialize(m);m[n]||(m[n]=we[n]),m[s]||(m[s]=we[s]),m[r]||(m[r]=we[r]),m.prototype.toJSON||(m.prototype.toJSON=we.prototype.toJSON);let Y=B[b]??(T&&T[b])??-1;Y++;for(let me in f){let ae=Ae(f[me]),ue=typeof Object.keys(ae)[0]=="string"&&xe(Object.keys(ae)[0]),pe=ue?Object.values(ae)[0]:ae;Fe.addField(B,Y,me,ae,No(`_${me}`,Y,pe,ue)),Y++}return R},isDeprecated(R,f){return R[f].deprecated===!0},init(R){let f={};R[Symbol.metadata]=f,Object.defineProperty(f,b,{value:0,enumerable:!1,configurable:!0})},initialize(R){let f=Object.getPrototypeOf(R),m=f[Symbol.metadata],x=R[Symbol.metadata]??Object.create(null);return f!==we&&x===m&&(x=Object.create(null),m&&(Object.setPrototypeOf(x,m),Object.defineProperty(x,b,{value:m[b],enumerable:!1,configurable:!0,writable:!0}),m[_]!==void 0&&(Object.defineProperty(x,_,{value:[...m[_]],enumerable:!1,configurable:!0,writable:!0}),Object.defineProperty(x,g,{value:{...m[g]},enumerable:!1,configurable:!0,writable:!0})),m[v]!==void 0&&Object.defineProperty(x,v,{value:[...m[v]],enumerable:!1,configurable:!0,writable:!0}),Object.defineProperty(x,p,{value:{...m[p]},enumerable:!1,configurable:!0,writable:!0}))),Object.defineProperty(R,Symbol.metadata,{value:x,writable:!1,configurable:!0}),x},isValidInstance(R){return R.constructor[Symbol.metadata]&&Object.prototype.hasOwnProperty.call(R.constructor[Symbol.metadata],b)},getFields(R){let f=R[Symbol.metadata],m={};for(let x=0;x<=f[b];x++)m[f[x].name]=f[x].type;return m},hasViewTagAtIndex(R,f){return R?.[_]?.includes(f)}};function Je(R){return{indexes:{},operations:[],queueRootNode:R}}function at(){return{next:void 0,tail:void 0}}function G(R,f){let m=R.indexes[f];m===void 0?R.indexes[f]=R.operations.push(f)-1:R.operations[m]=f}function Ie(R,f){let m=R.indexes[f];m===void 0&&(m=Object.values(R.indexes).at(-1),f=Object.entries(R.indexes).find(([x,T])=>T===m)?.[0]),R.operations[m]=void 0,delete R.indexes[f]}class be{constructor(f){this.isFiltered=!1,this.indexedOperations={},this.changes={indexes:{},operations:[]},this.allChanges={indexes:{},operations:[]},this.isNew=!0,this.ref=f,this.metadata=f.constructor[Symbol.metadata],this.metadata?.[_]&&(this.allFilteredChanges={indexes:{},operations:[]},this.filteredChanges={indexes:{},operations:[]})}setRoot(f){this.root=f;let m=this.root.add(this);this.checkIsFiltered(this.parent,this.parentIndex,m),m&&this.forEachChild((x,T)=>{x.root!==f?x.setRoot(f):f.add(x)})}setParent(f,m,x){if(this.addParent(f,x),!m)return;let T=m.add(this);m!==this.root&&(this.root=m,this.checkIsFiltered(f,x,T)),T&&this.forEachChild((B,Y)=>{if(B.root===m){m.add(B),m.moveNextToParent(B);return}B.setParent(this.ref,m,Y)})}forEachChild(f){if(this.ref[h]){if(typeof this.ref[h]!="string")for(let[m,x]of this.ref.entries())x&&f(x[l],this.indexes?.[m]??m)}else for(let m of this.metadata?.[v]??[]){let x=this.metadata[m],T=this.ref[x.name];T&&f(T[l],m)}}operation(f){this.filteredChanges!==void 0?(this.filteredChanges.operations.push(-f),this.root?.enqueueChangeTree(this,"filteredChanges")):(this.changes.operations.push(-f),this.root?.enqueueChangeTree(this,"changes"))}change(f,m=i.OPERATION.ADD){let x=this.isFiltered||this.metadata?.[f]?.tag!==void 0,T=x?this.filteredChanges:this.changes,B=this.indexedOperations[f];if(!B||B===i.OPERATION.DELETE){let Y=B&&B===i.OPERATION.DELETE?i.OPERATION.DELETE_AND_ADD:m;this.indexedOperations[f]=Y}G(T,f),x?(G(this.allFilteredChanges,f),this.root&&(this.root.enqueueChangeTree(this,"filteredChanges"),this.root.enqueueChangeTree(this,"allFilteredChanges"))):(G(this.allChanges,f),this.root?.enqueueChangeTree(this,"changes"))}shiftChangeIndexes(f){let m=this.isFiltered?this.filteredChanges:this.changes,x={},T={};for(let B in this.indexedOperations)x[Number(B)+f]=this.indexedOperations[B],T[Number(B)+f]=m.indexes[B];this.indexedOperations=x,m.indexes=T,m.operations=m.operations.map(B=>B+f)}shiftAllChangeIndexes(f,m=0){this.filteredChanges!==void 0?(this._shiftAllChangeIndexes(f,m,this.allFilteredChanges),this._shiftAllChangeIndexes(f,m,this.allChanges)):this._shiftAllChangeIndexes(f,m,this.allChanges)}_shiftAllChangeIndexes(f,m=0,x){let T={},B=0;for(let Y in x.indexes)T[B++]=x.indexes[Y];x.indexes=T;for(let Y=0;Y<x.operations.length;Y++){let me=x.operations[Y];me>m&&(x.operations[Y]=me+f)}}indexedOperation(f,m,x=f){this.indexedOperations[f]=m,this.filteredChanges!==void 0?(G(this.allFilteredChanges,x),G(this.filteredChanges,f),this.root?.enqueueChangeTree(this,"filteredChanges")):(G(this.allChanges,x),G(this.changes,f),this.root?.enqueueChangeTree(this,"changes"))}getType(f){return this.ref[h]||this.metadata[f].type}getChange(f){return this.indexedOperations[f]}getValue(f,m=!1){return this.ref[o](f,m)}delete(f,m,x=f){if(f===void 0){try{throw new Error(`@colyseus/schema ${this.ref.constructor.name}: trying to delete non-existing index '${f}'`)}catch(Y){console.warn(Y)}return}let T=this.filteredChanges!==void 0?this.filteredChanges:this.changes;this.indexedOperations[f]=m??i.OPERATION.DELETE,G(T,f),Ie(this.allChanges,x);let B=this.getValue(f);return B&&B[l]&&this.root?.remove(B[l]),this.filteredChanges!==void 0?(Ie(this.allFilteredChanges,x),this.root?.enqueueChangeTree(this,"filteredChanges")):this.root?.enqueueChangeTree(this,"changes"),B}endEncode(f){this.indexedOperations={},this[f]=Je(),this.ref[u]?.(),this.isNew=!1}discard(f=!1){this.ref[u]?.(),this.indexedOperations={},this.changes=Je(this.changes.queueRootNode),this.filteredChanges!==void 0&&(this.filteredChanges=Je(this.filteredChanges.queueRootNode)),f&&(this.allChanges=Je(this.allChanges.queueRootNode),this.allFilteredChanges!==void 0&&(this.allFilteredChanges=Je(this.allFilteredChanges.queueRootNode)))}discardAll(){let f=Object.keys(this.indexedOperations);for(let m=0,x=f.length;m<x;m++){let T=this.getValue(Number(f[m]));T&&T[l]&&T[l].discardAll()}this.discard()}get changed(){return Object.entries(this.indexedOperations).length>0}checkIsFiltered(f,m,x){this.root.types.hasFilters&&(this._checkFilteredByParent(f,m),this.filteredChanges!==void 0&&(this.root?.enqueueChangeTree(this,"filteredChanges"),x&&this.root?.enqueueChangeTree(this,"allFilteredChanges"))),this.isFiltered||(this.root?.enqueueChangeTree(this,"changes"),x&&this.root?.enqueueChangeTree(this,"allChanges"))}_checkFilteredByParent(f,m){if(!f)return;let x=Fe.isValidInstance(this.ref)?this.ref.constructor:this.ref[h],T,B=!Fe.isValidInstance(f);B?(T=f[l],f=T.parent,m=T.parentIndex):T=f[l];let Y=f.constructor,me=`${this.root.types.getTypeId(x)}`;Y&&(me+=`-${this.root.types.schemas.get(Y)}`),me+=`-${m}`;let ae=Fe.hasViewTagAtIndex(Y?.[Symbol.metadata],m);this.isFiltered=f[l].isFiltered||this.root.types.parentFiltered[me]||ae,this.isFiltered&&(this.isVisibilitySharedWithParent=T.isFiltered&&typeof x!="string"&&!ae&&B,this.filteredChanges||(this.filteredChanges=Je(),this.allFilteredChanges=Je()),this.changes.operations.length>0&&(this.changes.operations.forEach(ue=>G(this.filteredChanges,ue)),this.allChanges.operations.forEach(ue=>G(this.allFilteredChanges,ue)),this.changes=Je(),this.allChanges=Je()))}get parent(){return this.parentChain?.ref}get parentIndex(){return this.parentChain?.index}addParent(f,m){if(this.hasParent((x,T)=>x[l]===f[l])){this.parentChain.index=m;return}this.parentChain={ref:f,index:m,next:this.parentChain}}removeParent(f=this.parent){let m=this.parentChain,x=null;for(;m;){if(m.ref[l]===f[l])return x?x.next=m.next:this.parentChain=m.next,!0;x=m,m=m.next}return this.parentChain===void 0}findParent(f){let m=this.parentChain;for(;m;){if(f(m.ref,m.index))return m;m=m.next}}hasParent(f){return this.findParent(f)!==void 0}getAllParents(){let f=[],m=this.parentChain;for(;m;)f.push({ref:m.ref,index:m.index}),m=m.next;return f}}function Re(R,f,m,x,T,B){typeof m=="string"?Qe[m]?.(f,x,B):m[Symbol.metadata]!==void 0?(Qe.number(f,x[l].refId,B),(T&i.OPERATION.ADD)===i.OPERATION.ADD&&R.tryEncodeTypeId(f,m,x.constructor,B)):Qe.number(f,x[l].refId,B)}let Be=function(R,f,m,x,T,B,Y,me,ae){if(f[B.offset++]=(x|T)&255,T===i.OPERATION.DELETE)return;let ue=m.ref,pe=ae[x];Re(R,f,ae[x].type,ue[pe.name],T,B)},ye=function(R,f,m,x,T,B){if(f[B.offset++]=T&255,Qe.number(f,x,B),T===i.OPERATION.DELETE)return;let Y=m.ref;if((T&i.OPERATION.ADD)===i.OPERATION.ADD&&typeof Y.set=="function"){let ue=m.ref.$indexes.get(x);Qe.string(f,ue,B)}let me=Y[h],ae=Y[o](x);Re(R,f,me,ae,T,B)},et=function(R,f,m,x,T,B,Y,me){let ae=m.ref,ue=me&&m.isFiltered&&typeof m.getType(x)!="string",pe;if(ue){let Oe=ae.tmpItems[x];if(!Oe)return;pe=Oe[l].refId,T===i.OPERATION.DELETE?T=i.OPERATION.DELETE_BY_REFID:T===i.OPERATION.ADD&&(T=i.OPERATION.ADD_BY_REFID)}else pe=x;if(f[B.offset++]=T&255,Qe.number(f,pe,B),T===i.OPERATION.DELETE||T===i.OPERATION.DELETE_BY_REFID)return;let he=m.getType(x),ze=m.getValue(x,Y);Re(R,f,he,ze,T,B)},Ye=-1;function Ut(R,f,m,x,T,B,Y,me){let ae=R.root,ue=m[o](x),pe;if((f&i.OPERATION.DELETE)===i.OPERATION.DELETE){let he=ae.refIds.get(ue);he!==void 0&&ae.removeRef(he),f!==i.OPERATION.DELETE_AND_ADD&&m[c](x),pe=void 0}if(f!==i.OPERATION.DELETE)if(we.is(T)){let he=ce.number(B,Y);if(pe=ae.refs.get(he),(f&i.OPERATION.ADD)===i.OPERATION.ADD){let ze=R.getInstanceType(B,Y,T);pe||(pe=R.createInstanceOfType(ze)),ae.addRef(he,pe,pe!==ue||f===i.OPERATION.DELETE_AND_ADD&&pe===ue)}}else if(typeof T=="string")pe=ce[T](B,Y);else{let he=xe(Object.keys(T)[0]),ze=ce.number(B,Y),Oe=ae.refs.has(ze)?ue||ae.refs.get(ze):new he.constructor;if(pe=Oe.clone(!0),pe[h]=Object.values(T)[0],ue){let Te=ae.refIds.get(ue);if(Te!==void 0&&ze!==Te){let Me=ue.entries(),Xe;for(;(Xe=Me.next())&&!Xe.done;){let[on,cn]=Xe.value;typeof cn=="object"&&(Te=ae.refIds.get(cn),ae.removeRef(Te)),me.push({ref:ue,refId:Te,op:i.OPERATION.DELETE,field:on,value:void 0,previousValue:cn})}}}ae.addRef(ze,pe,Oe!==ue||f===i.OPERATION.DELETE_AND_ADD&&Oe===ue)}return{value:pe,previousValue:ue}}let Pt=function(R,f,m,x,T){let B=f[m.offset++],Y=x.constructor[Symbol.metadata],me=B>>6<<6,ae=B%(me||255),ue=Y[ae];if(ue===void 0)return console.warn("@colyseus/schema: field not defined at",{index:ae,ref:x.constructor.name,metadata:Y}),Ye;let{value:pe,previousValue:he}=Ut(R,me,x,ae,ue.type,f,m,T);pe!=null&&(x[ue.name]=pe),he!==pe&&T.push({ref:x,refId:R.currentRefId,op:me,field:ue.name,value:pe,previousValue:he})},zn=function(R,f,m,x,T){let B=f[m.offset++];if(B===i.OPERATION.CLEAR){R.removeChildRefs(x,T),x.clear();return}let Y=ce.number(f,m),me=x[h],ae;(B&i.OPERATION.ADD)===i.OPERATION.ADD?typeof x.set=="function"?(ae=ce.string(f,m),x.setIndex(Y,ae)):ae=Y:ae=x.getIndex(Y);let{value:ue,previousValue:pe}=Ut(R,B,x,Y,me,f,m,T);if(ue!=null){if(typeof x.set=="function")x.$items.set(ae,ue);else if(typeof x.$setAt=="function")x.$setAt(Y,ue,B);else if(typeof x.add=="function"){let he=x.add(ue);typeof he=="number"&&x.setIndex(he,he)}}pe!==ue&&T.push({ref:x,refId:R.currentRefId,op:B,field:"",dynamicIndex:ae,value:ue,previousValue:pe})},Ai=function(R,f,m,x,T){let B=f[m.offset++],Y;if(B===i.OPERATION.CLEAR){R.removeChildRefs(x,T),x.clear();return}else if(B===i.OPERATION.REVERSE){x.reverse();return}else if(B===i.OPERATION.DELETE_BY_REFID){let he=ce.number(f,m),ze=R.root.refs.get(he);Y=x.findIndex(Oe=>Oe===ze),x[c](Y),T.push({ref:x,refId:R.currentRefId,op:i.OPERATION.DELETE,field:"",dynamicIndex:Y,value:void 0,previousValue:ze});return}else if(B===i.OPERATION.ADD_BY_REFID){let he=ce.number(f,m),ze=R.root.refs.get(he);ze&&(Y=x.findIndex(Oe=>Oe===ze)),(Y===-1||Y===void 0)&&(Y=x.length)}else Y=ce.number(f,m);let me=x[h],ae=Y,{value:ue,previousValue:pe}=Ut(R,B,x,Y,me,f,m,T);ue!=null&&ue!==pe&&x.$setAt(Y,ue,B),pe!==ue&&T.push({ref:x,refId:R.currentRefId,op:B,field:"",dynamicIndex:ae,value:ue,previousValue:pe})};class Ml extends Error{}function ud(R,f,m,x){let T,B=!1;switch(f){case"number":case"int8":case"uint8":case"int16":case"uint16":case"int32":case"uint32":case"int64":case"uint64":case"float32":case"float64":T="number",isNaN(R)&&console.log(`trying to encode "NaN" in ${m.constructor.name}#${x}`);break;case"bigint64":case"biguint64":T="bigint";break;case"string":T="string",B=!0;break;case"boolean":return;default:return}if(typeof R!==T&&(!B||B&&R!==null)){let Y=`'${JSON.stringify(R)}'${R&&R.constructor&&` (${R.constructor.name})`||""}`;throw new Ml(`a '${T}' was expected, but ${Y} was provided in ${m.constructor.name}#${x}`)}}function Fr(R,f,m,x){if(!(R instanceof f))throw new Ml(`a '${f.name}' was expected, but '${R&&R.constructor.name}' was provided in ${m.constructor.name}#${x}`)}var Ma,El;let Al=(R,f)=>{let m=R.toString(),x=f.toString();return m<x?-1:m>x?1:0},an=class an{static[(Ma=s,El=r,a)](f,m,x){return!x||typeof f[h]=="string"||x.isChangeTreeVisible(f.tmpItems[m]?.[l])}static is(f){return Array.isArray(f)||f.array!==void 0}static from(f){return new an(...Array.from(f))}constructor(...f){this.items=[],this.tmpItems=[],this.deletedIndexes={},this.isMovingItems=!1,Object.defineProperty(this,h,{value:void 0,enumerable:!1,writable:!0,configurable:!0});let m=new Proxy(this,{get:(x,T)=>typeof T!="symbol"&&!isNaN(T)?this.items[T]:Reflect.get(x,T),set:(x,T,B)=>{if(typeof T!="symbol"&&!isNaN(T)){if(B==null)x.$deleteAt(T);else{if(B[l]){Fr(B,x[h],x,T);let Y=x.items[T];x.isMovingItems?(Y!==void 0?B[l].isNew?x[l].indexedOperation(Number(T),i.OPERATION.MOVE_AND_ADD):(x[l].getChange(Number(T))&i.OPERATION.DELETE)===i.OPERATION.DELETE?x[l].indexedOperation(Number(T),i.OPERATION.DELETE_AND_MOVE):x[l].indexedOperation(Number(T),i.OPERATION.MOVE):B[l].isNew&&x[l].indexedOperation(Number(T),i.OPERATION.ADD),B[l].setParent(this,x[l].root,T)):x.$changeAt(Number(T),B),Y!==void 0&&Y[l].root?.remove(Y[l])}else x.$changeAt(Number(T),B);x.items[T]=B,x.tmpItems[T]=B}return!0}else return Reflect.set(x,T,B)},deleteProperty:(x,T)=>(typeof T=="number"?x.$deleteAt(T):delete x[T],!0),has:(x,T)=>typeof T!="symbol"&&!isNaN(Number(T))?Reflect.has(this.items,T):Reflect.has(x,T)});return Object.defineProperty(this,l,{value:new be(m),enumerable:!1,writable:!0}),f.length>0&&this.push(...f),m}set length(f){f===0?this.clear():f<this.items.length?this.splice(f,this.length-f):console.warn("ArraySchema: can't set .length to a higher value than its length.")}get length(){return this.items.length}push(...f){let m=this.tmpItems.length,x=this[l];for(let T=0,B=f.length;T<B;T++,m++){let Y=f[T];if(Y==null)return;typeof Y=="object"&&this[h]&&Fr(Y,this[h],this,T),x.indexedOperation(m,i.OPERATION.ADD,this.items.length),this.items.push(Y),this.tmpItems.push(Y),Y[l]?.setParent(this,x.root,m)}return m}pop(){let f=-1;for(let m=this.tmpItems.length-1;m>=0;m--)if(this.deletedIndexes[m]!==!0){f=m;break}if(!(f<0))return this[l].delete(f,void 0,this.items.length-1),this.deletedIndexes[f]=!0,this.items.pop()}at(f){return f<0&&(f+=this.length),this.items[f]}$changeAt(f,m){if(m==null){console.error("ArraySchema items cannot be null nor undefined; Use `deleteAt(index)` instead.");return}if(this.items[f]===m)return;let x=this.items[f]!==void 0?typeof m=="object"?i.OPERATION.DELETE_AND_ADD:i.OPERATION.REPLACE:i.OPERATION.ADD,T=this[l];T.change(f,x),m[l]?.setParent(this,T.root,f)}$deleteAt(f,m){this[l].delete(f,m)}$setAt(f,m,x){f===0&&x===i.OPERATION.ADD&&this.items[f]!==void 0?this.items.unshift(m):x===i.OPERATION.DELETE_AND_MOVE?(this.items.splice(f,1),this.items[f]=m):this.items[f]=m}clear(){if(this.items.length===0)return;let f=this[l];f.forEachChild((m,x)=>{f.root?.remove(m)}),f.discard(!0),f.operation(i.OPERATION.CLEAR),this.items.length=0,this.tmpItems.length=0}concat(...f){return new an(...this.items.concat(...f))}join(f){return this.items.join(f)}reverse(){return this[l].operation(i.OPERATION.REVERSE),this.items.reverse(),this.tmpItems.reverse(),this}shift(){if(this.items.length===0)return;let f=this[l],m=this.tmpItems.findIndex(T=>T===this.items[0]),x=this.items.findIndex(T=>T===this.items[0]);return f.delete(m,i.OPERATION.DELETE,x),f.shiftAllChangeIndexes(-1,x),this.deletedIndexes[m]=!0,this.items.shift()}slice(f,m){let x=new an;return x.push(...this.items.slice(f,m)),x}sort(f=Al){this.isMovingItems=!0;let m=this[l];return this.items.sort(f).forEach((T,B)=>m.change(B,i.OPERATION.REPLACE)),this.tmpItems.sort(f),this.isMovingItems=!1,this}splice(f,m,...x){let T=this[l],B=this.items.length,Y=this.tmpItems.length,me=x.length,ae=[];for(let ue=0;ue<Y;ue++)this.deletedIndexes[ue]!==!0&&ae.push(ue);if(B>f){m===void 0&&(m=B-f);for(let ue=f;ue<f+m;ue++){let pe=ae[ue];T.delete(pe,i.OPERATION.DELETE),this.deletedIndexes[pe]=!0}}else m=0;if(me>0){if(me>m)throw console.error("Inserting more elements than deleting during ArraySchema#splice()"),new Error("ArraySchema#splice(): insertCount must be equal or lower than deleteCount.");for(let ue=0;ue<me;ue++){let pe=(ae[f]??B)+ue;T.indexedOperation(pe,this.deletedIndexes[pe]?i.OPERATION.DELETE_AND_ADD:i.OPERATION.ADD),x[ue][l]?.setParent(this,T.root,pe)}}return m>me&&T.shiftAllChangeIndexes(-(m-me),ae[f+me]),T.filteredChanges!==void 0?T.root?.enqueueChangeTree(T,"filteredChanges"):T.root?.enqueueChangeTree(T,"changes"),this.items.splice(f,m,...x)}unshift(...f){let m=this[l];return m.shiftChangeIndexes(f.length),m.isFiltered?G(m.filteredChanges,this.items.length):G(m.allChanges,this.items.length),f.forEach((x,T)=>{m.change(T,i.OPERATION.ADD)}),this.tmpItems.unshift(...f),this.items.unshift(...f)}indexOf(f,m){return this.items.indexOf(f,m)}lastIndexOf(f,m=this.length-1){return this.items.lastIndexOf(f,m)}every(f,m){return this.items.every(f,m)}some(f,m){return this.items.some(f,m)}forEach(f,m){return this.items.forEach(f,m)}map(f,m){return this.items.map(f,m)}filter(f,m){return this.items.filter(f,m)}reduce(f,m){return this.items.reduce(f,m)}reduceRight(f,m){return this.items.reduceRight(f,m)}find(f,m){return this.items.find(f,m)}findIndex(f,m){return this.items.findIndex(f,m)}fill(f,m,x){throw new Error("ArraySchema#fill() not implemented")}copyWithin(f,m,x){throw new Error("ArraySchema#copyWithin() not implemented")}toString(){return this.items.toString()}toLocaleString(){return this.items.toLocaleString()}[Symbol.iterator](){return this.items[Symbol.iterator]()}static get[Symbol.species](){return an}entries(){return this.items.entries()}keys(){return this.items.keys()}values(){return this.items.values()}includes(f,m){return this.items.includes(f,m)}flatMap(f,m){throw new Error("ArraySchema#flatMap() is not supported.")}flat(f){throw new Error("ArraySchema#flat() is not supported.")}findLast(){return this.items.findLast.apply(this.items,arguments)}findLastIndex(...f){return this.items.findLastIndex.apply(this.items,arguments)}with(f,m){let x=this.items.slice();return f<0&&(f+=this.length),x[f]=m,new an(...x)}toReversed(){return this.items.slice().reverse()}toSorted(f){return this.items.slice().sort(f)}toSpliced(f,m,...x){return this.items.toSpliced.apply(copy,arguments)}shuffle(){return this.move(f=>{let m=this.items.length;for(;m!=0;){let x=Math.floor(Math.random()*m);m--,[this[m],this[x]]=[this[x],this[m]]}})}move(f){return this.isMovingItems=!0,f(this),this.isMovingItems=!1,this}[o](f,m=!1){return m?this.items[f]:this.deletedIndexes[f]?this.items[f]:this.tmpItems[f]||this.items[f]}[c](f){this.items[f]=void 0,this.tmpItems[f]=void 0}[u](){this.tmpItems=this.items.slice(),this.deletedIndexes={}}[d](){this.items=this.items.filter(f=>f!==void 0),this.tmpItems=this.items.slice()}toArray(){return this.items.slice(0)}toJSON(){return this.toArray().map(f=>typeof f.toJSON=="function"?f.toJSON():f)}clone(f){let m;return f?(m=new an,m.push(...this.items)):m=new an(...this.map(x=>x[l]?x.clone():x)),m}};an[Ma]=et,an[El]=Ai;let ni=an;de("array",{constructor:ni});var ls,Ea;let Dn=class Dn{static[(ls=s,Ea=r,a)](f,m,x){return!x||typeof f[h]=="string"||x.isChangeTreeVisible((f[o](m)??f.deletedItems[m])[l])}static is(f){return f.map!==void 0}constructor(f){this.$items=new Map,this.$indexes=new Map,this.deletedItems={};let m=new be(this);if(m.indexes={},Object.defineProperty(this,l,{value:m,enumerable:!1,writable:!0}),f)if(f instanceof Map||f instanceof Dn)f.forEach((x,T)=>this.set(T,x));else for(let x in f)this.set(x,f[x]);Object.defineProperty(this,h,{value:void 0,enumerable:!1,writable:!0,configurable:!0})}[Symbol.iterator](){return this.$items[Symbol.iterator]()}get[Symbol.toStringTag](){return this.$items[Symbol.toStringTag]}static get[Symbol.species](){return Dn}set(f,m){if(m==null)throw new Error(`MapSchema#set('${f}', ${m}): trying to set ${m} value on '${f}'.`);typeof m=="object"&&this[h]&&Fr(m,this[h],this,f),f=f.toString();let x=this[l],T=m[l]!==void 0,B,Y;if(typeof x.indexes[f]<"u"){B=x.indexes[f],Y=i.OPERATION.REPLACE;let me=this.$items.get(f);if(me===m)return;T&&(Y=i.OPERATION.DELETE_AND_ADD,me!==void 0&&me[l].root?.remove(me[l])),this.deletedItems[B]&&delete this.deletedItems[B]}else B=x.indexes[b]??0,Y=i.OPERATION.ADD,this.$indexes.set(B,f),x.indexes[f]=B,x.indexes[b]=B+1;return this.$items.set(f,m),x.change(B,Y),T&&m[l].setParent(this,x.root,B),this}get(f){return this.$items.get(f)}delete(f){if(!this.$items.has(f))return!1;let m=this[l].indexes[f];return this.deletedItems[m]=this[l].delete(m),this.$items.delete(f)}clear(){let f=this[l];f.discard(!0),f.indexes={},f.forEachChild((m,x)=>{f.root?.remove(m)}),this.$indexes.clear(),this.$items.clear(),f.operation(i.OPERATION.CLEAR)}has(f){return this.$items.has(f)}forEach(f){this.$items.forEach(f)}entries(){return this.$items.entries()}keys(){return this.$items.keys()}values(){return this.$items.values()}get size(){return this.$items.size}setIndex(f,m){this.$indexes.set(f,m)}getIndex(f){return this.$indexes.get(f)}[o](f){return this.$items.get(this.$indexes.get(f))}[c](f){let m=this.$indexes.get(f);this.$items.delete(m),this.$indexes.delete(f)}[u](){let f=this[l];for(let m in this.deletedItems){let x=parseInt(m),T=this.$indexes.get(x);delete f.indexes[T],this.$indexes.delete(x)}this.deletedItems={}}toJSON(){let f={};return this.forEach((m,x)=>{f[x]=typeof m.toJSON=="function"?m.toJSON():m}),f}clone(f){let m;return f?m=Object.assign(new Dn,this):(m=new Dn,this.forEach((x,T)=>{x[l]?m.set(T,x.clone()):m.set(T,x)})),m}};Dn[ls]=ye,Dn[Ea]=zn;let Ti=Dn;de("map",{constructor:Ti});var Lo,kr;let fi=class fi{static[(Lo=s,kr=r,a)](f,m,x){return!x||typeof f[h]=="string"||x.isChangeTreeVisible((f[o](m)??f.deletedItems[m])[l])}static is(f){return f.collection!==void 0}constructor(f){this.$items=new Map,this.$indexes=new Map,this.deletedItems={},this.$refId=0,this[l]=new be(this),this[l].indexes={},f&&f.forEach(m=>this.add(m)),Object.defineProperty(this,h,{value:void 0,enumerable:!1,writable:!0,configurable:!0})}add(f){let m=this.$refId++;return f[l]!==void 0&&f[l].setParent(this,this[l].root,m),this[l].indexes[m]=m,this.$indexes.set(m,m),this.$items.set(m,f),this[l].change(m),m}at(f){let m=Array.from(this.$items.keys())[f];return this.$items.get(m)}entries(){return this.$items.entries()}delete(f){let m=this.$items.entries(),x,T;for(;(T=m.next())&&!T.done;)if(f===T.value[1]){x=T.value[0];break}return x===void 0?!1:(this.deletedItems[x]=this[l].delete(x),this.$indexes.delete(x),this.$items.delete(x))}clear(){let f=this[l];f.discard(!0),f.indexes={},f.forEachChild((m,x)=>{f.root?.remove(m)}),this.$indexes.clear(),this.$items.clear(),f.operation(i.OPERATION.CLEAR)}has(f){return Array.from(this.$items.values()).some(m=>m===f)}forEach(f){this.$items.forEach((m,x,T)=>f(m,x,this))}values(){return this.$items.values()}get size(){return this.$items.size}[Symbol.iterator](){return this.$items.values()}setIndex(f,m){this.$indexes.set(f,m)}getIndex(f){return this.$indexes.get(f)}[o](f){return this.$items.get(this.$indexes.get(f))}[c](f){let m=this.$indexes.get(f);this.$items.delete(m),this.$indexes.delete(f)}[u](){this.deletedItems={}}toArray(){return Array.from(this.$items.values())}toJSON(){let f=[];return this.forEach((m,x)=>{f.push(typeof m.toJSON=="function"?m.toJSON():m)}),f}clone(f){let m;return f?m=Object.assign(new fi,this):(m=new fi,this.forEach(x=>{x[l]?m.add(x.clone()):m.add(x)})),m}};fi[Lo]=ye,fi[kr]=zn;let Cs=fi;de("collection",{constructor:Cs});var Ur,Do;let Tt=class Tt{static[(Ur=s,Do=r,a)](f,m,x){return!x||typeof f[h]=="string"||x.visible.has((f[o](m)??f.deletedItems[m])[l])}static is(f){return f.set!==void 0}constructor(f){this.$items=new Map,this.$indexes=new Map,this.deletedItems={},this.$refId=0,this[l]=new be(this),this[l].indexes={},f&&f.forEach(m=>this.add(m)),Object.defineProperty(this,h,{value:void 0,enumerable:!1,writable:!0,configurable:!0})}add(f){if(this.has(f))return!1;let m=this.$refId++;f[l]!==void 0&&f[l].setParent(this,this[l].root,m);let x=this[l].indexes[m]?.op??i.OPERATION.ADD;return this[l].indexes[m]=m,this.$indexes.set(m,m),this.$items.set(m,f),this[l].change(m,x),m}entries(){return this.$items.entries()}delete(f){let m=this.$items.entries(),x,T;for(;(T=m.next())&&!T.done;)if(f===T.value[1]){x=T.value[0];break}return x===void 0?!1:(this.deletedItems[x]=this[l].delete(x),this.$indexes.delete(x),this.$items.delete(x))}clear(){let f=this[l];f.discard(!0),f.indexes={},this.$indexes.clear(),this.$items.clear(),f.operation(i.OPERATION.CLEAR)}has(f){let m=this.$items.values(),x=!1,T;for(;(T=m.next())&&!T.done;)if(f===T.value){x=!0;break}return x}forEach(f){this.$items.forEach((m,x,T)=>f(m,x,this))}values(){return this.$items.values()}get size(){return this.$items.size}[Symbol.iterator](){return this.$items.values()}setIndex(f,m){this.$indexes.set(f,m)}getIndex(f){return this.$indexes.get(f)}[o](f){return this.$items.get(this.$indexes.get(f))}[c](f){let m=this.$indexes.get(f);this.$items.delete(m),this.$indexes.delete(f)}[u](){this.deletedItems={}}toArray(){return Array.from(this.$items.values())}toJSON(){let f=[];return this.forEach((m,x)=>{f.push(typeof m.toJSON=="function"?m.toJSON():m)}),f}clone(f){let m;return f?m=Object.assign(new Tt,this):(m=new Tt,this.forEach(x=>{x[l]?m.add(x.clone()):m.add(x)})),m}};Tt[Ur]=ye,Tt[Do]=zn;let Is=Tt;de("set",{constructor:Is});let zi=-1;function fd(R){return qe.register(R),R}function Tl(R=zi){return function(f,m){let x=f.constructor,B=Object.getPrototypeOf(x)[Symbol.metadata],Y=x[Symbol.metadata]??=Object.assign({},x[Symbol.metadata],B??Object.create(null));Fe.setTag(Y,m,R)}}function ui(R,f){return function(m,x){let T=m.constructor;if(!R)throw new Error(`${T.name}: @type() reference provided for "${x}" is undefined. Make sure you don't have any circular dependencies.`);R=Ae(R),qe.register(T);let Y=Object.getPrototypeOf(T)[Symbol.metadata],me=Fe.initialize(T),ae=me[x];if(me[ae]!==void 0){if(me[ae].deprecated)return;if(me[ae].type!==void 0)try{throw new Error(`@colyseus/schema: Duplicate '${x}' definition on '${T.name}'.
+Check @type() annotation`)}catch(ue){let pe=ue.stack.split(`
+`)[4].trim();throw new Error(`${ue.message} ${pe}`)}}else ae=me[b]??(Y&&Y[b])??-1,ae++;if(f&&f.manual)Fe.addField(me,ae,x,R,{enumerable:!0,configurable:!0,writable:!0});else{let ue=typeof Object.keys(R)[0]=="string"&&xe(Object.keys(R)[0]),pe=ue?Object.values(R)[0]:R;Fe.addField(me,ae,x,R,No(`_${x}`,ae,pe,ue))}}}function No(R,f,m,x){return{get:function(){return this[R]},set:function(T){let B=this[R]??void 0;if(T!==B){if(T!=null){x?(x.constructor===ni&&!(T instanceof ni)&&(T=new ni(...T)),x.constructor===Ti&&!(T instanceof Ti)&&(T=new Ti(T)),T[h]=m):typeof m!="string"?Fr(T,m,this,R.substring(1)):ud(T,m,this,R.substring(1));let Y=this[l];B!==void 0&&B[l]?(Y.root?.remove(B[l]),this.constructor[n](Y,f,i.OPERATION.DELETE_AND_ADD)):this.constructor[n](Y,f,i.OPERATION.ADD),T[l]?.setParent(this,Y.root,f)}else B!==void 0&&this[l].delete(f);this[R]=T}},enumerable:!0,configurable:!0}}function D(R=!0){return function(f,m){let x=f.constructor,B=Object.getPrototypeOf(x)[Symbol.metadata],Y=x[Symbol.metadata]??=Object.assign({},x[Symbol.metadata],B??Object.create(null)),me=Y[m];Y[me].deprecated=!0,R&&(Y[p]??={},Y[p][m]={get:function(){throw new Error(`${m} is deprecated.`)},set:function(ae){},enumerable:!1,configurable:!0}),Object.defineProperty(Y,me,{value:Y[me],enumerable:!1,configurable:!0})}}function W(R,f,m){for(let x in f)ui(f[x],m)(R.prototype,x);return R}function oe(R,f,m=we){let x={},T={},B={},Y={};for(let pe in R){let he=R[pe];typeof he=="object"?(he.view!==void 0&&(Y[pe]=typeof he.view=="boolean"?zi:he.view),x[pe]=Ae(he),Object.prototype.hasOwnProperty.call(he,"default")?B[pe]=he.default:Array.isArray(he)||he.array!==void 0?B[pe]=new ni:he.map!==void 0?B[pe]=new Ti:he.collection!==void 0?B[pe]=new Cs:he.set!==void 0?B[pe]=new Is:he.type!==void 0&&we.is(he.type)&&(!he.type.prototype.initialize||he.type.prototype.initialize.length===0)&&(B[pe]=new he.type)):typeof he=="function"?we.is(he)?((!he.prototype.initialize||he.prototype.initialize.length===0)&&(B[pe]=new he),x[pe]=Ae(he)):T[pe]=he:x[pe]=Ae(he)}let me=()=>{let pe={};for(let he in B){let ze=B[he];ze&&typeof ze.clone=="function"?pe[he]=ze.clone():pe[he]=ze}return pe},ae=pe=>{let he=Object.keys(x),ze={};for(let Oe in pe)he.includes(Oe)||(ze[Oe]=pe[Oe]);return ze},ue=Fe.setFields(class extends m{constructor(...pe){T.initialize&&typeof T.initialize=="function"?(super(Object.assign({},me(),ae(pe[0]||{}))),new.target===ue&&T.initialize.apply(this,pe)):super(Object.assign({},me(),pe[0]||{}))}},x);ue._getDefaultValues=me,Object.assign(ue.prototype,T);for(let pe in Y)Tl(Y[pe])(ue.prototype,pe);return f&&Object.defineProperty(ue,"name",{value:f}),ue.extends=(pe,he)=>oe(pe,he,ue),ue}function ne(R){return new Array(R).fill(0).map((f,m)=>m===R-1?"\u2514\u2500 ":" ").join("")}function ie(R){let f=R[l].root,m={ops:{},refs:[]},x=f.changes.next;for(;x;){let T=x.changeTree;if(T===void 0){x=x.next;continue}let B=T.indexedOperations;m.refs.push(`refId#${T.refId}`);for(let Y in B){let me=B[Y],ae=i.OPERATION[me];m.ops[ae]||(m.ops[ae]=0),m.ops[i.OPERATION[me]]++}x=x.next}return m}var Ne,We;let $t=class $t{static initialize(f){Object.defineProperty(f,l,{value:new be(f),enumerable:!1,writable:!0}),Object.defineProperties(f,f.constructor[Symbol.metadata]?.[p]||{})}static is(f){return typeof f[Symbol.metadata]=="object"}static[(Ne=s,We=r,n)](f,m,x=i.OPERATION.ADD){f.change(m,x)}static[a](f,m,x){let B=f.constructor[Symbol.metadata][m]?.tag;if(x===void 0)return B===void 0;if(B===void 0)return!0;if(B===zi)return x.isChangeTreeVisible(f[l]);{let Y=x.tags?.get(f[l]);return Y&&Y.has(B)}}constructor(f){$t.initialize(this),f&&Object.assign(this,f)}assign(f){return Object.assign(this,f),this}setDirty(f,m){let x=this.constructor[Symbol.metadata];this[l].change(x[x[f]].index,m)}clone(){let f=Object.create(this.constructor.prototype);$t.initialize(f);let m=this.constructor[Symbol.metadata];for(let x in m){let T=m[x].name;typeof this[T]=="object"&&typeof this[T]?.clone=="function"?f[T]=this[T].clone():f[T]=this[T]}return f}toJSON(){let f={},m=this.constructor[Symbol.metadata];for(let x in m){let T=m[x],B=T.name;!T.deprecated&&this[B]!==null&&typeof this[B]<"u"&&(f[B]=typeof this[B].toJSON=="function"?this[B].toJSON():this[B])}return f}discardAllChanges(){this[l].discardAll()}[o](f){let m=this.constructor[Symbol.metadata];return this[m[f].name]}[c](f){let m=this.constructor[Symbol.metadata];this[m[f].name]=void 0}static debugRefIds(f,m=!1,x=0,T,B=""){let Y=m?` - ${JSON.stringify(f.toJSON())}`:"",me=f[l],ae=T?T.root.refIds.get(f):me.refId,ue=T?T.root:me.root,pe=ue?.refCount?.[ae]>1?` [\xD7${ue.refCount[ae]}]`:"",he=`${ne(x)}${B}${f.constructor.name} (refId: ${ae})${pe}${Y}
+`;return me.forEachChild((ze,Oe)=>{let Te=Oe;typeof Oe=="number"&&f.$indexes&&(Te=f.$indexes.get(Oe)??Oe);let Me=f.forEach!==void 0&&Te!==void 0?`["${Te}"]: `:"";he+=this.debugRefIds(ze.ref,m,x+1,T,Me)}),he}static debugRefIdEncodingOrder(f,m="allChanges"){let x=[],T=f[l].root[m].next;for(;T;)T.changeTree&&x.push(T.changeTree.refId),T=T.next;return x}static debugRefIdsFromDecoder(f){return this.debugRefIds(f.state,!1,0,f)}static debugChanges(f,m=!1){let x=f[l],T=m?x.allChanges:x.changes,B=m?"allChanges":"changes",Y=`${f.constructor.name} (${x.refId}) -> .${B}:
+`;function me(ae){ae.operations.filter(ue=>ue).forEach(ue=>{let pe=x.indexedOperations[ue];Y+=`- [${ue}]: ${i.OPERATION[pe]} (${JSON.stringify(x.getValue(Number(ue),m))})
+`})}return me(T),!m&&x.filteredChanges&&x.filteredChanges.operations.filter(ae=>ae).length>0&&(Y+=`${f.constructor.name} (${x.refId}) -> .filteredChanges:
+`,me(x.filteredChanges)),m&&x.allFilteredChanges&&x.allFilteredChanges.operations.filter(ae=>ae).length>0&&(Y+=`${f.constructor.name} (${x.refId}) -> .allFilteredChanges:
+`,me(x.allFilteredChanges)),Y}static debugChangesDeep(f,m="changes"){let x="",T=f[l],B=T.root,Y=new Map,me=[],ae=0;for(let[pe,he]of Object.entries(B[m])){let ze=B.changeTrees[pe];if(!ze)continue;let Oe=!1,Te=[],Me=ze.parent?.[l];if(ze===T)Oe=!0;else for(;Me!==void 0;){if(Te.push(Me),Me.ref===f){Oe=!0;break}Me=Me.parent?.[l]}Oe&&(me.push(ze.refId),ae+=Object.keys(he).length,Y.set(ze,Te.reverse()))}x+=`---
+`,x+=`root refId: ${T.refId}
+`,x+=`Total instances: ${me.length} (refIds: ${me.join(", ")})
+`,x+=`Total changes: ${ae}
+`,x+=`---
+`;let ue=new WeakSet;for(let[pe,he]of Y.entries()){he.forEach((Xe,on)=>{ue.has(Xe)||(x+=`${ne(on)}${Xe.ref.constructor.name} (refId: ${Xe.refId})
+`,ue.add(Xe))});let ze=pe.indexedOperations,Oe=he.length,Te=ne(Oe),Me=Oe>0?`(${pe.parentIndex}) `:"";x+=`${Te}${Me}${pe.ref.constructor.name} (refId: ${pe.refId}) - changes: ${Object.keys(ze).length}
+`;for(let Xe in ze){let on=ze[Xe];x+=`${ne(Oe+1)}${i.OPERATION[on]}: ${Xe}
+`}}return`${x}`}};$t[Ne]=Be,$t[We]=Pt;let we=$t;function Ge(R,f,m,x){var T=arguments.length,B=T<3?f:x===null?x=Object.getOwnPropertyDescriptor(f,m):x,Y;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")B=Reflect.decorate(R,f,m,x);else for(var me=R.length-1;me>=0;me--)(Y=R[me])&&(B=(T<3?Y(B):T>3?Y(f,m,B):Y(f,m))||B);return T>3&&B&&Object.defineProperty(f,m,B),B}typeof SuppressedError=="function"&&SuppressedError;class Ze{constructor(f){this.types=f,this.nextUniqueId=0,this.refCount={},this.changeTrees={},this.allChanges=at(),this.allFilteredChanges=at(),this.changes=at(),this.filteredChanges=at()}getNextUniqueId(){return this.nextUniqueId++}add(f){f.refId===void 0&&(f.refId=this.getNextUniqueId());let m=this.changeTrees[f.refId]===void 0;m&&(this.changeTrees[f.refId]=f);let x=this.refCount[f.refId];if(x===0){let T=f.allChanges.operations,B=T.length;for(;B--;)f.indexedOperations[T[B]]=i.OPERATION.ADD,G(f.changes,B)}return this.refCount[f.refId]=(x||0)+1,m}remove(f){let m=this.refCount[f.refId]-1;return m<=0?(f.root=void 0,delete this.changeTrees[f.refId],this.removeChangeFromChangeSet("allChanges",f),this.removeChangeFromChangeSet("changes",f),f.filteredChanges&&(this.removeChangeFromChangeSet("allFilteredChanges",f),this.removeChangeFromChangeSet("filteredChanges",f)),this.refCount[f.refId]=0,f.forEachChild((x,T)=>{x.removeParent(f.ref)&&(x.parentChain===void 0||x.parentChain&&this.refCount[x.refId]>0?this.remove(x):x.parentChain&&this.moveNextToParent(x))})):(this.refCount[f.refId]=m,this.recursivelyMoveNextToParent(f)),m}recursivelyMoveNextToParent(f){this.moveNextToParent(f),f.forEachChild((m,x)=>this.recursivelyMoveNextToParent(m))}moveNextToParent(f){f.filteredChanges?(this.moveNextToParentInChangeTreeList("filteredChanges",f),this.moveNextToParentInChangeTreeList("allFilteredChanges",f)):(this.moveNextToParentInChangeTreeList("changes",f),this.moveNextToParentInChangeTreeList("allChanges",f))}moveNextToParentInChangeTreeList(f,m){let x=this[f],T=m[f].queueRootNode;if(!T)return;let B=m.parent;if(!B||!B[l])return;let Y=B[l][f]?.queueRootNode;if(!Y||Y===T)return;let me=Y.position;T.position>me||(T.prev?T.prev.next=T.next:x.next=T.next,T.next?T.next.prev=T.prev:x.tail=T.prev,T.prev=Y,T.next=Y.next,Y.next?Y.next.prev=T:x.tail=T,Y.next=T,this.updatePositionsAfterMove(x,T,me+1))}enqueueChangeTree(f,m,x=f[m].queueRootNode){x||(f[m].queueRootNode=this.addToChangeTreeList(this[m],f))}addToChangeTreeList(f,m){let x={changeTree:m,next:void 0,prev:void 0,position:f.tail?f.tail.position+1:0};return f.next?(x.prev=f.tail,f.tail.next=x,f.tail=x):(f.next=x,f.tail=x),x}updatePositionsAfterRemoval(f,m){let x=f.next,T=0;for(;x;)T>=m&&(x.position=T),x=x.next,T++}updatePositionsAfterMove(f,m,x){let T=f.next,B=0;for(;T;)T.position=B,T=T.next,B++}removeChangeFromChangeSet(f,m){let x=this[f],T=m[f].queueRootNode;if(T&&T.changeTree===m){let B=T.position;return T.prev?T.prev.next=T.next:x.next=T.next,T.next?T.next.prev=T.prev:x.tail=T.prev,this.updatePositionsAfterRemoval(x,B),m[f].queueRootNode=void 0,!0}return!1}}let di=class di{constructor(f){this.sharedBuffer=Buffer.allocUnsafe(di.BUFFER_SIZE),this.context=qe.cache(f.constructor),this.root=new Ze(this.context),this.setState(f)}setState(f){this.state=f,this.state[l].setRoot(this.root)}encode(f={offset:0},m,x=this.sharedBuffer,T="changes",B=T==="allChanges",Y=f.offset){let me=m!==void 0,ae=this.state[l],ue=this.root[T];for(;ue=ue.next;){let pe=ue.changeTree;if(me){if(!m.isChangeTreeVisible(pe)){m.invisible.add(pe);continue}m.invisible.delete(pe)}let he=pe[T],ze=pe.ref,Oe=he.operations.length;if(Oe===0)continue;let Te=ze.constructor,Me=Te[s],Xe=Te[a],on=Te[Symbol.metadata];(me||f.offset>Y||pe!==ae)&&(x[f.offset++]=255,Qe.number(x,pe.refId,f));for(let cn=0;cn<Oe;cn++){let pi=he.operations[cn];if(pi<0){x[f.offset++]=Math.abs(pi)&255;continue}let Ri=B?i.OPERATION.ADD:pe.indexedOperations[pi];pi===void 0||Ri===void 0||Xe&&!Xe(ze,pi,m)||Me(this,x,pe,pi,Ri,f,B,me,on)}}if(f.offset>x.byteLength){let pe=Math.ceil(f.offset/(Buffer.poolSize??8192))*(Buffer.poolSize??8192);return console.warn(`@colyseus/schema buffer overflow. Encoded state is higher than default BUFFER_SIZE. Use the following to increase default BUFFER_SIZE:
+
+ import { Encoder } from "@colyseus/schema";
+ Encoder.BUFFER_SIZE = ${Math.round(pe/1024)} * 1024; // ${Math.round(pe/1024)} KB
+`),x=Buffer.alloc(pe,x),x===this.sharedBuffer&&(this.sharedBuffer=x),this.encode({offset:Y},m,x,T,B)}else return x.subarray(0,f.offset)}encodeAll(f={offset:0},m=this.sharedBuffer){return this.encode(f,void 0,m,"allChanges",!0)}encodeAllView(f,m,x,T=this.sharedBuffer){let B=x.offset;return this.encode(x,f,T,"allFilteredChanges",!0,B),Buffer.concat([T.subarray(0,m),T.subarray(B,x.offset)])}encodeView(f,m,x,T=this.sharedBuffer){let B=x.offset;for(let[Y,me]of f.changes){let ae=this.root.changeTrees[Y];if(ae===void 0){f.changes.delete(Y);continue}let ue=Object.keys(me);if(ue.length===0)continue;let he=ae.ref.constructor,ze=he[s],Oe=he[Symbol.metadata];T[x.offset++]=255,Qe.number(T,ae.refId,x);for(let Te=0,Me=ue.length;Te<Me;Te++){let Xe=Number(ue[Te]),cn=ae.ref[o](Xe)!==void 0&&me[Xe]||i.OPERATION.DELETE;ze(this,T,ae,Xe,cn,x,!1,!0,Oe)}}return f.changes.clear(),this.encode(x,f,T,"filteredChanges",!1,B),Buffer.concat([T.subarray(0,m),T.subarray(B,x.offset)])}discardChanges(){let f=this.root.changes.next;for(;f;)f.changeTree.endEncode("changes"),f=f.next;for(this.root.changes=at(),f=this.root.filteredChanges.next;f;)f.changeTree.endEncode("filteredChanges"),f=f.next;this.root.filteredChanges=at()}tryEncodeTypeId(f,m,x,T){let B=this.context.getTypeId(m),Y=this.context.getTypeId(x);if(Y===void 0){console.warn(`@colyseus/schema WARNING: Class "${x.name}" is not registered on TypeRegistry - Please either tag the class with @entity or define a @type() field.`);return}B!==Y&&(f[T.offset++]=213,Qe.number(f,Y,T))}get hasChanges(){return this.root.changes.next!==void 0||this.root.filteredChanges.next!==void 0}};di.BUFFER_SIZE=typeof Buffer<"u"&&Buffer.poolSize||8*1024;let lt=di;function bt(R,f){if(f===-1||f>=R.length)return!1;let m=R.length-1;for(let x=f;x<m;x++)R[x]=R[x+1];return R.length=m,!0}class Ke extends Error{constructor(f){super(f),this.name="DecodingWarning"}}class Dt{constructor(){this.refs=new Map,this.refIds=new WeakMap,this.refCount={},this.deletedRefs=new Set,this.callbacks={},this.nextUniqueId=0}getNextUniqueId(){return this.nextUniqueId++}addRef(f,m,x=!0){this.refs.set(f,m),this.refIds.set(m,f),x&&(this.refCount[f]=(this.refCount[f]||0)+1),this.deletedRefs.has(f)&&this.deletedRefs.delete(f)}removeRef(f){let m=this.refCount[f];if(m===void 0){try{throw new Ke("trying to remove refId that doesn't exist: "+f)}catch(x){console.warn(x)}return}if(m===0){try{let x=this.refs.get(f);throw new Ke(`trying to remove refId '${f}' with 0 refCount (${x.constructor.name}: ${JSON.stringify(x)})`)}catch(x){console.warn(x)}return}(this.refCount[f]=m-1)<=0&&this.deletedRefs.add(f)}clearRefs(){this.refs.clear(),this.deletedRefs.clear(),this.callbacks={},this.refCount={}}garbageCollectDeletedRefs(){this.deletedRefs.forEach(f=>{if(this.refCount[f]>0)return;let m=this.refs.get(f);if(m.constructor[Symbol.metadata]!==void 0){let x=m.constructor[Symbol.metadata];for(let T in x){let B=x[T].name,Y=typeof m[B]=="object"&&this.refIds.get(m[B]);Y&&!this.deletedRefs.has(Y)&&this.removeRef(Y)}}else typeof m[h]=="function"&&Array.from(m.values()).forEach(x=>{let T=this.refIds.get(x);this.deletedRefs.has(T)||this.removeRef(T)});this.refs.delete(f),delete this.refCount[f],delete this.callbacks[f]}),this.deletedRefs.clear()}addCallback(f,m,x){if(f===void 0){let T=typeof m=="number"?i.OPERATION[m]:m;throw new Error(`Can't addCallback on '${T}' (refId is undefined)`)}return this.callbacks[f]||(this.callbacks[f]={}),this.callbacks[f][m]||(this.callbacks[f][m]=[]),this.callbacks[f][m].push(x),()=>this.removeCallback(f,m,x)}removeCallback(f,m,x){let T=this.callbacks?.[f]?.[m]?.indexOf(x);T!==void 0&&T!==-1&&bt(this.callbacks[f][m],T)}}class Zt{constructor(f,m){this.currentRefId=0,this.setState(f),this.context=m||new qe(f.constructor)}setState(f){this.state=f,this.root=new Dt,this.root.addRef(0,f)}decode(f,m={offset:0},x=this.state){let T=[],B=this.root,Y=f.byteLength,me=x.constructor[r];for(this.currentRefId=0;m.offset<Y;){if(f[m.offset]==255){m.offset++,x[d]?.();let ue=ce.number(f,m),pe=B.refs.get(ue);pe?(x=pe,me=x.constructor[r],this.currentRefId=ue):(console.error(`"refId" not found: ${ue}`,{previousRef:x,previousRefId:this.currentRefId}),console.warn("Please report this issue to the developers."),this.skipCurrentStructure(f,m,Y));continue}if(me(this,f,m,x,T)===Ye){console.warn("@colyseus/schema: definition mismatch"),this.skipCurrentStructure(f,m,Y);continue}}return x[d]?.(),this.triggerChanges?.(T),B.garbageCollectDeletedRefs(),T}skipCurrentStructure(f,m,x){let T={offset:m.offset};for(;m.offset<x&&!(f[m.offset]===255&&(T.offset=m.offset+1,this.root.refs.has(ce.number(f,T))));)m.offset++}getInstanceType(f,m,x){let T;if(f[m.offset]===213){m.offset++;let B=ce.number(f,m);T=this.context.get(B)}return T||x}createInstanceOfType(f){return new f}removeChildRefs(f,m){let x=typeof f[h]!="string",T=this.root.refIds.get(f);f.forEach((B,Y)=>{m.push({ref:f,refId:T,op:i.OPERATION.DELETE,field:Y,value:void 0,previousValue:B}),x&&this.root.removeRef(this.root.refIds.get(B))})}}class Nt extends we{}Ge([ui("string")],Nt.prototype,"name",void 0),Ge([ui("string")],Nt.prototype,"type",void 0),Ge([ui("number")],Nt.prototype,"referencedType",void 0);class Ct extends we{constructor(){super(...arguments),this.fields=new ni}}Ge([ui("number")],Ct.prototype,"id",void 0),Ge([ui("number")],Ct.prototype,"extendsId",void 0),Ge([ui([Nt])],Ct.prototype,"fields",void 0);class tn extends we{constructor(){super(...arguments),this.types=new ni}static encode(f,m={offset:0}){let x=f.context,T=new tn,B=new lt(T),Y=x.schemas.get(f.state.constructor);Y>0&&(T.rootType=Y);let me=new Set,ae={},ue=he=>{if(he.extendsId===void 0||me.has(he.extendsId)){me.add(he.id),T.types.push(he);let ze=ae[he.id];ze!==void 0&&(delete ae[he.id],ze.forEach(Oe=>ue(Oe)))}else ae[he.extendsId]===void 0&&(ae[he.extendsId]=[]),ae[he.extendsId].push(he)};x.schemas.forEach((he,ze)=>{let Oe=new Ct;Oe.id=Number(he);let Te=Object.getPrototypeOf(ze);Te!==we&&(Oe.extendsId=x.schemas.get(Te));let Me=ze[Symbol.metadata];if(Me!==Te[Symbol.metadata])for(let Xe in Me){let on=Number(Xe),cn=Me[on].name;if(!Object.prototype.hasOwnProperty.call(Me,cn))continue;let pi=new Nt;pi.name=cn;let Ri,Qs=Me[on];if(typeof Qs.type=="string")Ri=Qs.type;else{let Rl;we.is(Qs.type)?(Ri="ref",Rl=Qs.type):(Ri=Object.keys(Qs.type)[0],typeof Qs.type[Ri]=="string"?Ri+=":"+Qs.type[Ri]:Rl=Qs.type[Ri]),pi.referencedType=Rl?x.getTypeId(Rl):-1}pi.type=Ri,Oe.fields.push(pi)}ue(Oe)});for(let he in ae)ae[he].forEach(ze=>T.types.push(ze));return B.encodeAll(m).slice(0,m.offset)}static decode(f,m){let x=new tn;new Zt(x).decode(f,m);let B=new qe;x.types.forEach(ae=>{let ue=B.get(ae.extendsId)??we,pe=class extends ue{};qe.register(pe),B.add(pe,ae.id)},{});let Y=(ae,ue,pe)=>{ue.fields.forEach((he,ze)=>{let Oe=pe+ze;if(he.referencedType!==void 0){let Te=he.type,Me=B.get(he.referencedType);if(!Me){let Xe=he.type.split(":");Te=Xe[0],Me=Xe[1]}Te==="ref"?Fe.addField(ae,Oe,he.name,Me):Fe.addField(ae,Oe,he.name,{[Te]:Me})}else Fe.addField(ae,Oe,he.name,he.type)})};x.types.forEach(ae=>{let ue=B.get(ae.id),pe=Fe.initialize(ue),he=[],ze=ae;do he.push(ze),ze=x.types.find(Te=>Te.id===ze.extendsId);while(ze);let Oe=0;he.reverse().forEach(Te=>{Y(pe,Te,Oe),Oe+=Te.fields.length})});let me=new(B.get(x.rootType||0));return new Zt(me,B)}}Ge([ui([Ct])],tn.prototype,"types",void 0),Ge([ui("number")],tn.prototype,"rootType",void 0);function $e(R){let f=R.root,m=f.callbacks,x=new WeakMap,T;R.triggerChanges=function(me){let ae=new Set;for(let ue=0,pe=me.length;ue<pe;ue++){let he=me[ue],ze=he.refId,Oe=he.ref,Te=m[ze];if(Te){if((he.op&i.OPERATION.DELETE)===i.OPERATION.DELETE&&he.previousValue instanceof we){let Me=m[f.refIds.get(he.previousValue)]?.[i.OPERATION.DELETE];for(let Xe=Me?.length-1;Xe>=0;Xe--)Me[Xe]()}if(Oe instanceof we){if(!ae.has(ze)){let Me=Te?.[i.OPERATION.REPLACE];for(let Xe=Me?.length-1;Xe>=0;Xe--)Me[Xe]()}if(Te.hasOwnProperty(he.field)){let Me=Te[he.field];for(let Xe=Me?.length-1;Xe>=0;Xe--)Me[Xe](he.value,he.previousValue)}}else{if((he.op&i.OPERATION.DELETE)===i.OPERATION.DELETE){if(he.previousValue!==void 0){let Me=Te[i.OPERATION.DELETE];for(let Xe=Me?.length-1;Xe>=0;Xe--)Me[Xe](he.previousValue,he.dynamicIndex??he.field)}if((he.op&i.OPERATION.ADD)===i.OPERATION.ADD){let Me=Te[i.OPERATION.ADD];for(let Xe=Me?.length-1;Xe>=0;Xe--)Me[Xe](he.value,he.dynamicIndex??he.field)}}else if((he.op&i.OPERATION.ADD)===i.OPERATION.ADD&&he.previousValue!==he.value){let Me=Te[i.OPERATION.ADD];for(let Xe=Me?.length-1;Xe>=0;Xe--)Me[Xe](he.value,he.dynamicIndex??he.field)}if(he.value!==he.previousValue&&(he.value!==void 0||he.previousValue!==void 0)){let Me=Te[i.OPERATION.REPLACE];for(let Xe=Me?.length-1;Xe>=0;Xe--)Me[Xe](he.value,he.dynamicIndex??he.field)}}ae.add(ze)}}};function B(me,ae){let ue=ae.instance?.constructor[Symbol.metadata]||me,pe=ae.instance&&typeof ae.instance.forEach=="function"||me&&typeof me[Symbol.metadata]>"u";if(ue&&!pe){let he=function(ze,Oe,Te,Me){return Me&&ae.instance[Oe]!==void 0&&!x.has(T)&&Te(ae.instance[Oe],void 0),f.addCallback(f.refIds.get(ze),Oe,Te)};return new Proxy({listen:function(Oe,Te,Me=!0){if(ae.instance)return he(ae.instance,Oe,Te,Me);{let Xe=()=>{};return ae.onInstanceAvailable((on,cn)=>{Xe=he(on,Oe,Te,Me&&cn&&!x.has(T))}),()=>Xe()}},onChange:function(Oe){return f.addCallback(f.refIds.get(ae.instance),i.OPERATION.REPLACE,Oe)},bindTo:function(Oe,Te){return Te||(Te=Object.keys(ue).map(Me=>ue[Me].name)),f.addCallback(f.refIds.get(ae.instance),i.OPERATION.REPLACE,()=>{Te.forEach(Me=>Oe[Me]=ae.instance[Me])})}},{get(ze,Oe){let Te=ue[ue[Oe]];if(Te){let Me=ae.instance?.[Oe],Xe=(on=>{let cn=Y(ae.instance).listen(Oe,(pi,Ri)=>{on(pi,!1),cn?.()},!1);f.refIds.get(Me)!==void 0&&on(Me,!0)});return B(Te.type,{instance:f.refIds.get(Me)&&Me,parentInstance:ae.instance,onInstanceAvailable:Xe})}else return ze[Oe]},has(ze,Oe){return ue[Oe]!==void 0},set(ze,Oe,Te){throw new Error("not allowed")},deleteProperty(ze,Oe){throw new Error("not allowed")}})}else{let he=function(Te,Me,Xe){return Xe&&Te.forEach((on,cn)=>Me(on,cn)),f.addCallback(f.refIds.get(Te),i.OPERATION.ADD,(on,cn)=>{x.set(Me,!0),T=Me,Me(on,cn),x.delete(Me),T=void 0})},ze=function(Te,Me){return f.addCallback(f.refIds.get(Te),i.OPERATION.DELETE,Me)},Oe=function(Te,Me){return f.addCallback(f.refIds.get(Te),i.OPERATION.REPLACE,Me)};return new Proxy({onAdd:function(Te,Me=!0){if(ae.instance)return he(ae.instance,Te,Me&&!x.has(T));if(ae.onInstanceAvailable){let Xe=()=>{};return ae.onInstanceAvailable((on,cn)=>{Xe=he(on,Te,Me&&cn&&!x.has(T))}),()=>Xe()}},onRemove:function(Te){if(ae.instance)return ze(ae.instance,Te);if(ae.onInstanceAvailable){let Me=()=>{};return ae.onInstanceAvailable(Xe=>{Me=ze(Xe,Te)}),()=>Me()}},onChange:function(Te){if(ae.instance)return Oe(ae.instance,Te);if(ae.onInstanceAvailable){let Me=()=>{};return ae.onInstanceAvailable(Xe=>{Me=Oe(Xe,Te)}),()=>Me()}}},{get(Te,Me){if(!Te[Me])throw new Error(`Can't access '${Me}' through callback proxy. access the instance directly.`);return Te[Me]},has(Te,Me){return Te[Me]!==void 0},set(Te,Me,Xe){throw new Error("not allowed")},deleteProperty(Te,Me){throw new Error("not allowed")}})}}function Y(me){return B(void 0,{instance:me})}return Y}function Ln(R,f){R.triggerChanges=f}class At{constructor(f=!1){this.iterable=f,this.visible=new WeakSet,this.invisible=new WeakSet,this.changes=new Map,f&&(this.items=[])}add(f,m=zi,x=!0){let T=f?.[l],B=T.parent;if(T){if(!B&&T.refId!==0)throw new Error(`Cannot add a detached instance to the StateView. Make sure to assign the "${T.ref.constructor.name}" instance to the state before calling view.add()`)}else return console.warn("StateView#add(), invalid object:",f),!1;let Y=f.constructor[Symbol.metadata];this.visible.add(T),this.iterable&&x&&this.items.push(f),x&&B&&this.addParentOf(T,m);let me=this.changes.get(T.refId);me===void 0&&(me={},this.changes.set(T.refId,me));let ae=!1;if(T.forEachChild((ue,pe)=>{Y&&Y[pe].tag!==void 0&&Y[pe].tag!==m||this.add(ue.ref,m,!1)&&(ae=!0)}),m!==zi){this.tags||(this.tags=new WeakMap);let ue;this.tags.has(T)?ue=this.tags.get(T):(ue=new Set,this.tags.set(T,ue)),ue.add(m),Y?.[g]?.[m]?.forEach(pe=>{T.getChange(pe)!==i.OPERATION.DELETE&&(me[pe]=i.OPERATION.ADD)})}else if(!T.isNew||ae){let ue=T.filteredChanges!==void 0?T.allFilteredChanges:T.allChanges,pe=this.invisible.has(T);for(let he=0,ze=ue.operations.length;he<ze;he++){let Oe=ue.operations[he];if(Oe===void 0)continue;let Te=T.indexedOperations[Oe]??i.OPERATION.ADD,Me=Y?.[Oe].tag;Te!==i.OPERATION.DELETE&&(pe||Me===void 0||Me===m)&&(me[Oe]=Te,ae=!0)}}return ae}addParentOf(f,m){let x=f.parent[l],T=f.parentIndex;if(!this.visible.has(x)){this.visible.add(x);let B=x.parent?.[l];B&&B.filteredChanges!==void 0&&this.addParentOf(x,m)}if(x.getChange(T)!==i.OPERATION.DELETE){let B=this.changes.get(x.refId);B===void 0&&(B={},this.changes.set(x.refId,B)),this.tags||(this.tags=new WeakMap);let Y;this.tags.has(x)?Y=this.tags.get(x):(Y=new Set,this.tags.set(x,Y)),Y.add(m),B[T]=i.OPERATION.ADD}}remove(f,m=zi,x=!1){let T=f[l];if(!T)return console.warn("StateView#remove(), invalid object:",f),this;this.visible.delete(T),this.iterable&&!x&&bt(this.items,this.items.indexOf(f));let Y=T.ref.constructor[Symbol.metadata],me=this.changes.get(T.refId);if(me===void 0&&(me={},this.changes.set(T.refId,me)),m===zi){let ae=T.parent;if(ae&&!Fe.isValidInstance(ae)&&T.isFiltered){let ue=ae[l],pe=this.changes.get(ue.refId);pe===void 0?(pe={},this.changes.set(ue.refId,pe)):pe[T.parentIndex]===i.OPERATION.ADD&&this.changes.delete(T.refId),pe[T.parentIndex]=i.OPERATION.DELETE,this._recursiveDeleteVisibleChangeTree(T)}else Y?.[_]?.forEach(ue=>me[ue]=i.OPERATION.DELETE)}else Y?.[g][m].forEach(ae=>me[ae]=i.OPERATION.DELETE);if(this.tags&&this.tags.has(T)){let ae=this.tags.get(T);m===void 0?this.tags.delete(T):(ae.delete(m),ae.size===0&&this.tags.delete(T))}return this}has(f){return this.visible.has(f[l])}hasTag(f,m=zi){return this.tags?.get(f[l])?.has(m)??!1}clear(){if(!this.iterable)throw new Error("StateView#clear() is only available for iterable StateView's. Use StateView(iterable: true) constructor.");for(let f=0,m=this.items.length;f<m;f++)this.remove(this.items[f],zi,!0);this.items.length=0}isChangeTreeVisible(f){let m=this.visible.has(f);return!m&&f.isVisibilitySharedWithParent&&this.visible.has(f.parent[l])&&(this.visible.add(f),m=!0),m}_recursiveDeleteVisibleChangeTree(f){f.forEachChild(m=>{this.visible.delete(m),this._recursiveDeleteVisibleChangeTree(m)})}}de("map",{constructor:Ti}),de("array",{constructor:ni}),de("set",{constructor:Is}),de("collection",{constructor:Cs}),i.$changes=l,i.$childType=h,i.$decoder=r,i.$deleteByIndex=c,i.$encoder=s,i.$filter=a,i.$getByIndex=o,i.$track=n,i.ArraySchema=ni,i.ChangeTree=be,i.CollectionSchema=Cs,i.Decoder=Zt,i.Encoder=lt,i.MapSchema=Ti,i.Metadata=Fe,i.Reflection=tn,i.ReflectionField=Nt,i.ReflectionType=Ct,i.Schema=we,i.SetSchema=Is,i.StateView=At,i.TypeContext=qe,i.decode=ce,i.decodeKeyValueOperation=zn,i.decodeSchemaOperation=Pt,i.defineCustomTypes=Pe,i.defineTypes=W,i.deprecated=D,i.dumpChanges=ie,i.encode=Qe,i.encodeArray=et,i.encodeKeyValueOperation=ye,i.encodeSchemaOperation=Be,i.entity=fd,i.getDecoderStateCallbacks=$e,i.getRawChangesCallback=Ln,i.registerType=de,i.schema=oe,i.type=ui,i.view=Tl}))});var qv=xn($v=>{"use strict";var Wv=(Jc(),Aa(Yc)),pa=yf(),Gg=class{constructor(e){this.events=e,this.isOpen=!1,this.lengthPrefixBuffer=new Uint8Array(9)}connect(e,t={}){let n=t.fingerprint&&{serverCertificateHashes:[{algorithm:"sha-256",value:new Uint8Array(t.fingerprint).buffer}]}||void 0;this.wt=new WebTransport(e,n),this.wt.ready.then(s=>{console.log("WebTransport ready!",s),this.isOpen=!0,this.unreliableReader=this.wt.datagrams.readable.getReader(),this.unreliableWriter=this.wt.datagrams.writable.getWriter(),this.wt.incomingBidirectionalStreams.getReader().read().then(a=>{this.reader=a.value.readable.getReader(),this.writer=a.value.writable.getWriter(),this.sendSeatReservation(t.room.roomId,t.sessionId,t.reconnectionToken),this.readIncomingData(),this.readIncomingUnreliableData()}).catch(a=>{console.error("failed to read incoming stream",a),console.error("TODO: close the connection")})}).catch(s=>{console.log("WebTransport not ready!",s),this._close()}),this.wt.closed.then(s=>{console.log("WebTransport closed w/ success",s),this.events.onclose({code:s.closeCode,reason:s.reason})}).catch(s=>{console.log("WebTransport closed w/ error",s),this.events.onerror(s),this.events.onclose({code:s.closeCode,reason:s.reason})}).finally(()=>{this._close()})}send(e){let t=pa.encode.number(this.lengthPrefixBuffer,e.length,{offset:0}),n=new Uint8Array(t+e.length);n.set(this.lengthPrefixBuffer.subarray(0,t),0),n.set(e,t),this.writer.write(n)}sendUnreliable(e){let t=pa.encode.number(this.lengthPrefixBuffer,e.length,{offset:0}),n=new Uint8Array(t+e.length);n.set(this.lengthPrefixBuffer.subarray(0,t),0),n.set(e,t),this.unreliableWriter.write(n)}close(e,t){try{this.wt.close({closeCode:e,reason:t})}catch(n){console.error(n)}}readIncomingData(){return Wv.__awaiter(this,void 0,void 0,function*(){let e;for(;this.isOpen;){try{e=yield this.reader.read();let t=e.value,n={offset:0};do{let s=pa.decode.number(t,n);this.events.onmessage({data:t.subarray(n.offset,n.offset+s)}),n.offset+=s}while(n.offset<t.length)}catch(t){t.message.indexOf("session is closed")===-1&&console.error("H3Transport: failed to read incoming data",t);break}if(e.done)break}})}readIncomingUnreliableData(){return Wv.__awaiter(this,void 0,void 0,function*(){let e;for(;this.isOpen;){try{e=yield this.unreliableReader.read();let t=e.value,n={offset:0};do{let s=pa.decode.number(t,n);this.events.onmessage({data:t.subarray(n.offset,n.offset+s)}),n.offset+=s}while(n.offset<t.length)}catch(t){t.message.indexOf("session is closed")===-1&&console.error("H3Transport: failed to read incoming data",t);break}if(e.done)break}})}sendSeatReservation(e,t,n){let s={offset:0},r=[];pa.encode.string(r,e,s),pa.encode.string(r,t,s),n&&pa.encode.string(r,n,s),this.writer.write(new Uint8Array(r).buffer)}_close(){this.isOpen=!1}};$v.H3TransportTransport=Gg});var Xv=xn((dk,jv)=>{"use strict";jv.exports=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}});var Yv=xn(Kv=>{"use strict";var UI=Xv(),Wg=globalThis.WebSocket||UI,$g=class{constructor(e){this.events=e}send(e){this.ws.send(e)}sendUnreliable(e){console.warn("colyseus.js: The WebSocket transport does not support unreliable messages")}connect(e,t){try{this.ws=new Wg(e,{headers:t,protocols:this.protocols})}catch{this.ws=new Wg(e,this.protocols)}this.ws.binaryType="arraybuffer",this.ws.onopen=this.events.onopen,this.ws.onmessage=this.events.onmessage,this.ws.onclose=this.events.onclose,this.ws.onerror=this.events.onerror}close(e,t){this.ws.close(e,t)}get isOpen(){return this.ws.readyState===Wg.OPEN}};Kv.WebSocketTransport=$g});var Zv=xn(Jv=>{"use strict";var BI=qv(),zI=Yv(),qg=class{constructor(e){this.events={},e==="h3"?this.transport=new BI.H3TransportTransport(this.events):this.transport=new zI.WebSocketTransport(this.events)}connect(e,t){this.transport.connect.call(this.transport,e,t)}send(e){this.transport.send(e)}sendUnreliable(e){this.transport.sendUnreliable(e)}close(e,t){this.transport.close(e,t)}get isOpen(){return this.transport.isOpen}};Jv.Connection=qg});var jg=xn(ma=>{"use strict";ma.Protocol=void 0;(function(i){i[i.HANDSHAKE=9]="HANDSHAKE",i[i.JOIN_ROOM=10]="JOIN_ROOM",i[i.ERROR=11]="ERROR",i[i.LEAVE_ROOM=12]="LEAVE_ROOM",i[i.ROOM_DATA=13]="ROOM_DATA",i[i.ROOM_STATE=14]="ROOM_STATE",i[i.ROOM_STATE_PATCH=15]="ROOM_STATE_PATCH",i[i.ROOM_DATA_SCHEMA=16]="ROOM_DATA_SCHEMA",i[i.ROOM_DATA_BYTES=17]="ROOM_DATA_BYTES"})(ma.Protocol||(ma.Protocol={}));ma.ErrorCode=void 0;(function(i){i[i.MATCHMAKE_NO_HANDLER=4210]="MATCHMAKE_NO_HANDLER",i[i.MATCHMAKE_INVALID_CRITERIA=4211]="MATCHMAKE_INVALID_CRITERIA",i[i.MATCHMAKE_INVALID_ROOM_ID=4212]="MATCHMAKE_INVALID_ROOM_ID",i[i.MATCHMAKE_UNHANDLED=4213]="MATCHMAKE_UNHANDLED",i[i.MATCHMAKE_EXPIRED=4214]="MATCHMAKE_EXPIRED",i[i.AUTH_FAILED=4215]="AUTH_FAILED",i[i.APPLICATION_ERROR=4216]="APPLICATION_ERROR"})(ma.ErrorCode||(ma.ErrorCode={}))});var Kg=xn(Xg=>{"use strict";var Qv={};function HI(i,e){Qv[i]=e}function VI(i){let e=Qv[i];if(!e)throw new Error("missing serializer: "+i);return e}Xg.getSerializer=VI;Xg.registerSerializer=HI});var Yg=xn(eS=>{"use strict";var GI=()=>({emit(i,...e){let t=this.events[i]||[];for(let n=0,s=t.length;n<s;n++)t[n](...e)},events:{},on(i,e){var t;return!((t=this.events[i])===null||t===void 0)&&t.push(e)||(this.events[i]=[e]),()=>{var n;this.events[i]=(n=this.events[i])===null||n===void 0?void 0:n.filter(s=>e!==s)}}});eS.createNanoEvents=GI});var tS=xn(Jg=>{"use strict";var vf=class{constructor(){this.handlers=[]}register(e,t=!1){return this.handlers.push(e),this}invoke(...e){this.handlers.forEach(t=>t.apply(this,e))}invokeAsync(...e){return Promise.all(this.handlers.map(t=>t.apply(this,e)))}remove(e){let t=this.handlers.indexOf(e);this.handlers[t]=this.handlers[this.handlers.length-1],this.handlers.pop()}clear(){this.handlers=[]}};function WI(){let i=new vf;function e(t){return i.register(t,this===null)}return e.once=t=>{let n=function(...s){t.apply(this,s),i.remove(n)};i.register(n)},e.remove=t=>i.remove(t),e.invoke=(...t)=>i.invoke(...t),e.invokeAsync=(...t)=>i.invokeAsync(...t),e.clear=()=>i.clear(),e}Jg.EventEmitter=vf;Jg.createSignal=WI});var e0=xn(Qg=>{"use strict";var Sf=yf();function $I(i){try{return Sf.getDecoderStateCallbacks(i.serializer.decoder)}catch{return}}var Zg=class{setState(e,t){this.decoder.decode(e,t)}getState(){return this.state}patch(e,t){return this.decoder.decode(e,t)}teardown(){this.decoder.root.clearRefs()}handshake(e,t){this.state?(Sf.Reflection.decode(e,t),this.decoder=new Sf.Decoder(this.state)):(this.decoder=Sf.Reflection.decode(e,t),this.state=this.decoder.state)}};Qg.SchemaSerializer=Zg;Qg.getStateCallbacks=$I});function wf(i){try{if(!jt.trusted&&!Tr){let t=Rt.sharedLength||0;t<Rt.length&&(Rt.length=t)}let e;if(jt.randomAccessStructure&&De[X]<64&&De[X]>=32&&iS?(e=iS(De,X,ki,jt),De=null,!(i&&i.lazy)&&e&&(e=e.toJSON()),X=ki):e=gn(),In&&(X=In.postBundlePosition,In=null),Tr&&(Rt.restoreStructures=null),X==ki)Rt&&Rt.restoreStructures&&aS(),Rt=null,De=null,qs&&(qs=null);else{if(X>ki)throw new Error("Unexpected end of MessagePack data");if(!Tr){let t;try{t=JSON.stringify(e,(n,s)=>typeof s=="bigint"?`${s}n`:s).slice(0,100)}catch(n){t="(JSON view not available "+n+")"}throw new Error("Data read, but end of buffer not reached "+t)}}return e}catch(e){throw Rt&&Rt.restoreStructures&&aS(),el(),(e instanceof RangeError||e.message.startsWith("Unexpected end of buffer")||X>ki)&&(e.incomplete=!0),e}}function aS(){for(let i in Rt.restoreStructures)Rt[i]=Rt.restoreStructures[i];Rt.restoreStructures=null}function gn(){let i=De[X++];if(i<160)if(i<128){if(i<64)return i;{let e=Rt[i&63]||jt.getStructures&&gS()[i&63];return e?(e.read||(e.read=a0(e,i&63)),e.read()):i}}else if(i<144)if(i-=128,jt.mapsAsObjects){let e={};for(let t=0;t<i;t++){let n=xS();n==="__proto__"&&(n="__proto_"),e[n]=gn()}return e}else{let e=new Map;for(let t=0;t<i;t++)e.set(gn(),gn());return e}else{i-=144;let e=new Array(i);for(let t=0;t<i;t++)e[t]=gn();return jt.freezeData?Object.freeze(e):e}else if(i<192){let e=i-160;if(ws>=X)return Ar.slice(X-Fi,(X+=e)-Fi);if(ws==0&&ki<140){let t=e<16?o0(e):_S(e);if(t!=null)return t}return r0(e)}else{let e;switch(i){case 192:return null;case 193:return In?(e=gn(),e>0?In[1].slice(In.position1,In.position1+=e):In[0].slice(In.position0,In.position0-=e)):Mf;case 194:return!1;case 195:return!0;case 196:if(e=De[X++],e===void 0)throw new Error("Unexpected end of buffer");return t0(e);case 197:return e=Mt.getUint16(X),X+=2,t0(e);case 198:return e=Mt.getUint32(X),X+=4,t0(e);case 199:return ga(De[X++]);case 200:return e=Mt.getUint16(X),X+=2,ga(e);case 201:return e=Mt.getUint32(X),X+=4,ga(e);case 202:if(e=Mt.getFloat32(X),jt.useFloat32>2){let t=nl[(De[X]&127)<<1|De[X+1]>>7];return X+=4,(t*e+(e>0?.5:-.5)>>0)/t}return X+=4,e;case 203:return e=Mt.getFloat64(X),X+=8,e;case 204:return De[X++];case 205:return e=Mt.getUint16(X),X+=2,e;case 206:return e=Mt.getUint32(X),X+=4,e;case 207:return jt.int64AsType==="number"?(e=Mt.getUint32(X)*4294967296,e+=Mt.getUint32(X+4)):jt.int64AsType==="string"?e=Mt.getBigUint64(X).toString():jt.int64AsType==="auto"?(e=Mt.getBigUint64(X),e<=BigInt(2)<<BigInt(52)&&(e=Number(e))):e=Mt.getBigUint64(X),X+=8,e;case 208:return Mt.getInt8(X++);case 209:return e=Mt.getInt16(X),X+=2,e;case 210:return e=Mt.getInt32(X),X+=4,e;case 211:return jt.int64AsType==="number"?(e=Mt.getInt32(X)*4294967296,e+=Mt.getUint32(X+4)):jt.int64AsType==="string"?e=Mt.getBigInt64(X).toString():jt.int64AsType==="auto"?(e=Mt.getBigInt64(X),e>=BigInt(-2)<<BigInt(52)&&e<=BigInt(2)<<BigInt(52)&&(e=Number(e))):e=Mt.getBigInt64(X),X+=8,e;case 212:if(e=De[X++],e==114)return fS(De[X++]&63);{let t=Kn[e];if(t)return t.read?(X++,t.read(gn())):t.noBuffer?(X++,t()):t(De.subarray(X,++X));throw new Error("Unknown extension "+e)}case 213:return e=De[X],e==114?(X++,fS(De[X++]&63,De[X++])):ga(2);case 214:return ga(4);case 215:return ga(8);case 216:return ga(16);case 217:return e=De[X++],ws>=X?Ar.slice(X-Fi,(X+=e)-Fi):jI(e);case 218:return e=Mt.getUint16(X),X+=2,ws>=X?Ar.slice(X-Fi,(X+=e)-Fi):XI(e);case 219:return e=Mt.getUint32(X),X+=4,ws>=X?Ar.slice(X-Fi,(X+=e)-Fi):KI(e);case 220:return e=Mt.getUint16(X),X+=2,cS(e);case 221:return e=Mt.getUint32(X),X+=4,cS(e);case 222:return e=Mt.getUint16(X),X+=2,lS(e);case 223:return e=Mt.getUint32(X),X+=4,lS(e);default:if(i>=224)return i-256;if(i===void 0){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}throw new Error("Unknown MessagePack token "+i)}}}function a0(i,e){function t(){if(t.count++>mS){let s=i.read=new Function("r","return function(){return "+(jt.freezeData?"Object.freeze":"")+"({"+i.map(r=>r==="__proto__"?"__proto_:r()":qI.test(r)?r+":r()":"["+JSON.stringify(r)+"]:r()").join(",")+"})}")(gn);return i.highByte===0&&(i.read=oS(e,i.read)),s()}let n={};for(let s=0,r=i.length;s<r;s++){let a=i[s];a==="__proto__"&&(a="__proto_"),n[a]=gn()}return jt.freezeData?Object.freeze(n):n}return t.count=0,i.highByte===0?oS(e,t):t}function gS(){let i=vS(()=>(De=null,jt.getStructures()));return Rt=jt._mergeStructures(i,Rt)}function tl(i){let e;if(i<16&&(e=o0(i)))return e;if(i>64&&n0)return n0.decode(De.subarray(X,X+=i));let t=X+i,n=[];for(e="";X<t;){let s=De[X++];if((s&128)===0)n.push(s);else if((s&224)===192){let r=De[X++]&63;n.push((s&31)<<6|r)}else if((s&240)===224){let r=De[X++]&63,a=De[X++]&63;n.push((s&31)<<12|r<<6|a)}else if((s&248)===240){let r=De[X++]&63,a=De[X++]&63,o=De[X++]&63,c=(s&7)<<18|r<<12|a<<6|o;c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|c&1023),n.push(c)}else n.push(s);n.length>=4096&&(e+=Cn.apply(String,n),n.length=0)}return n.length>0&&(e+=Cn.apply(String,n)),e}function cS(i){let e=new Array(i);for(let t=0;t<i;t++)e[t]=gn();return jt.freezeData?Object.freeze(e):e}function lS(i){if(jt.mapsAsObjects){let e={};for(let t=0;t<i;t++){let n=xS();n==="__proto__"&&(n="__proto_"),e[n]=gn()}return e}else{let e=new Map;for(let t=0;t<i;t++)e.set(gn(),gn());return e}}function _S(i){let e=X,t=new Array(i);for(let n=0;n<i;n++){let s=De[X++];if((s&128)>0){X=e;return}t[n]=s}return Cn.apply(String,t)}function o0(i){if(i<4)if(i<2){if(i===0)return"";{let e=De[X++];if((e&128)>1){X-=1;return}return Cn(e)}}else{let e=De[X++],t=De[X++];if((e&128)>0||(t&128)>0){X-=2;return}if(i<3)return Cn(e,t);let n=De[X++];if((n&128)>0){X-=3;return}return Cn(e,t,n)}else{let e=De[X++],t=De[X++],n=De[X++],s=De[X++];if((e&128)>0||(t&128)>0||(n&128)>0||(s&128)>0){X-=4;return}if(i<6){if(i===4)return Cn(e,t,n,s);{let r=De[X++];if((r&128)>0){X-=5;return}return Cn(e,t,n,s,r)}}else if(i<8){let r=De[X++],a=De[X++];if((r&128)>0||(a&128)>0){X-=6;return}if(i<7)return Cn(e,t,n,s,r,a);let o=De[X++];if((o&128)>0){X-=7;return}return Cn(e,t,n,s,r,a,o)}else{let r=De[X++],a=De[X++],o=De[X++],c=De[X++];if((r&128)>0||(a&128)>0||(o&128)>0||(c&128)>0){X-=8;return}if(i<10){if(i===8)return Cn(e,t,n,s,r,a,o,c);{let l=De[X++];if((l&128)>0){X-=9;return}return Cn(e,t,n,s,r,a,o,c,l)}}else if(i<12){let l=De[X++],h=De[X++];if((l&128)>0||(h&128)>0){X-=10;return}if(i<11)return Cn(e,t,n,s,r,a,o,c,l,h);let u=De[X++];if((u&128)>0){X-=11;return}return Cn(e,t,n,s,r,a,o,c,l,h,u)}else{let l=De[X++],h=De[X++],u=De[X++],d=De[X++];if((l&128)>0||(h&128)>0||(u&128)>0||(d&128)>0){X-=12;return}if(i<14){if(i===12)return Cn(e,t,n,s,r,a,o,c,l,h,u,d);{let p=De[X++];if((p&128)>0){X-=13;return}return Cn(e,t,n,s,r,a,o,c,l,h,u,d,p)}}else{let p=De[X++],b=De[X++];if((p&128)>0||(b&128)>0){X-=14;return}if(i<15)return Cn(e,t,n,s,r,a,o,c,l,h,u,d,p,b);let v=De[X++];if((v&128)>0){X-=15;return}return Cn(e,t,n,s,r,a,o,c,l,h,u,d,p,b,v)}}}}}function hS(){let i=De[X++],e;if(i<192)e=i-160;else switch(i){case 217:e=De[X++];break;case 218:e=Mt.getUint16(X),X+=2;break;case 219:e=Mt.getUint32(X),X+=4;break;default:throw new Error("Expected string")}return tl(e)}function t0(i){return jt.copyBuffers?Uint8Array.prototype.slice.call(De,X,X+=i):De.subarray(X,X+=i)}function ga(i){let e=De[X++];if(Kn[e]){let t;return Kn[e](De.subarray(X,t=X+=i),n=>{X=n;try{return gn()}finally{X=t}})}else throw new Error("Unknown extension type "+e)}function xS(){let i=De[X++];if(i>=160&&i<192){if(i=i-160,ws>=X)return Ar.slice(X-Fi,(X+=i)-Fi);if(!(ws==0&&ki<180))return r0(i)}else return X--,yS(gn());let e=(i<<5^(i>1?Mt.getUint16(X):i>0?De[X]:0))&4095,t=uS[e],n=X,s=X+i-3,r,a=0;if(t&&t.bytes==i){for(;n<s;){if(r=Mt.getUint32(n),r!=t[a++]){n=1879048192;break}n+=4}for(s+=3;n<s;)if(r=De[n++],r!=t[a++]){n=1879048192;break}if(n===s)return X=n,t.string;s-=3,n=X}for(t=[],uS[e]=t,t.bytes=i;n<s;)r=Mt.getUint32(n),t.push(r),n+=4;for(s+=3;n<s;)r=De[n++],t.push(r);let o=i<16?o0(i):_S(i);return o!=null?t.string=o:t.string=r0(i)}function yS(i){if(typeof i=="string")return i;if(typeof i=="number"||typeof i=="boolean"||typeof i=="bigint")return i.toString();if(i==null)return i+"";if(jt.allowArraysInMapKeys&&Array.isArray(i)&&i.flat().every(e=>["string","number","boolean","bigint"].includes(typeof e)))return i.flat().toString();throw new Error(`Invalid property type for record: ${typeof i}`)}function vS(i){rS&&rS();let e=ki,t=X,n=s0,s=Fi,r=ws,a=Ar,o=i0,c=qs,l=In,h=new Uint8Array(De.slice(0,ki)),u=Rt,d=Rt.slice(0,Rt.length),p=jt,b=Tr,v=i();return ki=e,X=t,s0=n,Fi=s,ws=r,Ar=a,i0=o,qs=c,In=l,De=h,Tr=b,Rt=u,Rt.splice(0,Rt.length,...d),jt=p,Mt=new DataView(De.buffer,De.byteOffset,De.byteLength),v}function el(){De=null,qs=null,Rt=null}function SS(i){i.unpack?Kn[i.type]=i.unpack:Kn[i.type]=i}function RS(i){TS[0]=i;let e=nl[(dS[3]&127)<<1|dS[2]>>7];return(e*i+(i>0?.5:-.5)>>0)/e}var n0,De,ki,X,pS,i0,s0,jt,Rt,Ar,Fi,ws,In,qs,Kn,Mt,nS,Qc,Mf,Tr,mS,iS,sS,rS,Ms,qI,oS,r0,jI,XI,KI,bS,Cn,uS,fS,YI,c0,JI,ZI,nl,wS,Ef,MS,ES,AS,il,TS,dS,Eo=un(()=>{try{n0=new TextDecoder}catch{}X=0,pS=[],i0=pS,s0=0,jt={},Fi=0,ws=0,Kn=[],nS={useRecords:!1,mapsAsObjects:!0},Qc=class{},Mf=new Qc;Mf.name="MessagePack 0xC1";Tr=!1,mS=2;try{new Function("")}catch{mS=1/0}Ms=class i{constructor(e){e&&(e.useRecords===!1&&e.mapsAsObjects===void 0&&(e.mapsAsObjects=!0),e.sequential&&e.trusted!==!1&&(e.trusted=!0,!e.structures&&e.useRecords!=!1&&(e.structures=[],e.maxSharedStructures||(e.maxSharedStructures=0))),e.structures?e.structures.sharedLength=e.structures.length:e.getStructures&&((e.structures=[]).uninitialized=!0,e.structures.sharedLength=0),e.int64AsNumber&&(e.int64AsType="number")),Object.assign(this,e)}unpack(e,t){if(De)return vS(()=>(el(),this?this.unpack(e,t):i.prototype.unpack.call(nS,e,t)));!e.buffer&&e.constructor===ArrayBuffer&&(e=typeof Buffer<"u"?Buffer.from(e):new Uint8Array(e)),typeof t=="object"?(ki=t.end||e.length,X=t.start||0):(X=0,ki=t>-1?t:e.length),s0=0,ws=0,Ar=null,i0=pS,In=null,De=e;try{Mt=e.dataView||(e.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength))}catch(n){throw De=null,e instanceof Uint8Array?n:new Error("Source must be a Uint8Array or Buffer but was a "+(e&&typeof e=="object"?e.constructor.name:typeof e))}if(this instanceof i){if(jt=this,this.structures)return Rt=this.structures,wf(t);(!Rt||Rt.length>0)&&(Rt=[])}else jt=nS,(!Rt||Rt.length>0)&&(Rt=[]);return wf(t)}unpackMultiple(e,t){let n,s=0;try{Tr=!0;let r=e.length,a=this?this.unpack(e,r):Ef.unpack(e,r);if(t){if(t(a,s,X)===!1)return;for(;X<r;)if(s=X,t(wf(),s,X)===!1)return}else{for(n=[a];X<r;)s=X,n.push(wf());return n}}catch(r){throw r.lastPosition=s,r.values=n,r}finally{Tr=!1,el()}}_mergeStructures(e,t){sS&&(e=sS.call(this,e)),e=e||[],Object.isFrozen(e)&&(e=e.map(n=>n.slice(0)));for(let n=0,s=e.length;n<s;n++){let r=e[n];r&&(r.isShared=!0,n>=32&&(r.highByte=n-32>>5))}e.sharedLength=e.length;for(let n in t||[])if(n>=0){let s=e[n],r=t[n];r&&(s&&((e.restoreStructures||(e.restoreStructures=[]))[n]=s),e[n]=r)}return this.structures=e}decode(e,t){return this.unpack(e,t)}};qI=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;oS=(i,e)=>function(){let t=De[X++];if(t===0)return e();let n=i<32?-(i+(t<<5)):i+(t<<5),s=Rt[n]||gS()[n];if(!s)throw new Error("Record id is not defined for "+n);return s.read||(s.read=a0(s,i)),s.read()};r0=tl,jI=tl,XI=tl,KI=tl,bS=!1;Cn=String.fromCharCode;uS=new Array(4096);fS=(i,e)=>{let t=gn().map(yS),n=i;e!==void 0&&(i=i<32?-((e<<5)+i):(e<<5)+i,t.highByte=e);let s=Rt[i];return s&&(s.isShared||Tr)&&((Rt.restoreStructures||(Rt.restoreStructures=[]))[i]=s),Rt[i]=t,t.read=a0(t,n),t.read()};Kn[0]=()=>{};Kn[0].noBuffer=!0;Kn[66]=i=>{let e=i.length,t=BigInt(i[0]&128?i[0]-256:i[0]);for(let n=1;n<e;n++)t<<=BigInt(8),t+=BigInt(i[n]);return t};YI={Error,TypeError,ReferenceError};Kn[101]=()=>{let i=gn();return(YI[i[0]]||Error)(i[1],{cause:i[2]})};Kn[105]=i=>{if(jt.structuredClone===!1)throw new Error("Structured clone extension is disabled");let e=Mt.getUint32(X-4);qs||(qs=new Map);let t=De[X],n;t>=144&&t<160||t==220||t==221?n=[]:n={};let s={target:n};qs.set(e,s);let r=gn();return s.used?Object.assign(n,r):(s.target=r,r)};Kn[112]=i=>{if(jt.structuredClone===!1)throw new Error("Structured clone extension is disabled");let e=Mt.getUint32(X-4),t=qs.get(e);return t.used=!0,t.target};Kn[115]=()=>new Set(gn());c0=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(i=>i+"Array"),JI=typeof globalThis=="object"?globalThis:window;Kn[116]=i=>{let e=i[0],t=c0[e];if(!t){if(e===16){let n=new ArrayBuffer(i.length-1);return new Uint8Array(n).set(i.subarray(1)),n}throw new Error("Could not find typed array for code "+e)}return new JI[t](Uint8Array.prototype.slice.call(i,1).buffer)};Kn[120]=()=>{let i=gn();return new RegExp(i[0],i[1])};ZI=[];Kn[98]=i=>{let e=(i[0]<<24)+(i[1]<<16)+(i[2]<<8)+i[3],t=X;return X+=e-i.length,In=ZI,In=[hS(),hS()],In.position0=0,In.position1=0,In.postBundlePosition=X,X=t,gn()};Kn[255]=i=>i.length==4?new Date((i[0]*16777216+(i[1]<<16)+(i[2]<<8)+i[3])*1e3):i.length==8?new Date(((i[0]<<22)+(i[1]<<14)+(i[2]<<6)+(i[3]>>2))/1e6+((i[3]&3)*4294967296+i[4]*16777216+(i[5]<<16)+(i[6]<<8)+i[7])*1e3):i.length==12?new Date(((i[0]<<24)+(i[1]<<16)+(i[2]<<8)+i[3])/1e6+((i[4]&128?-281474976710656:0)+i[6]*1099511627776+i[7]*4294967296+i[8]*16777216+(i[9]<<16)+(i[10]<<8)+i[11])*1e3):new Date("invalid");nl=new Array(147);for(let i=0;i<256;i++)nl[i]=+("1e"+Math.floor(45.15-i*.30103));wS=Ms,Ef=new Ms({useRecords:!1}),MS=Ef.unpack,ES=Ef.unpackMultiple,AS=Ef.unpack,il={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},TS=new Float32Array(1),dS=new Uint8Array(TS.buffer,0,4)});function IS(i,e,t,n){let s=i.byteLength;if(s+1<256){var{target:r,position:a}=t(4+s);r[a++]=199,r[a++]=s+1}else if(s+1<65536){var{target:r,position:a}=t(5+s);r[a++]=200,r[a++]=s+1>>8,r[a++]=s+1&255}else{var{target:r,position:a,targetView:o}=t(7+s);r[a++]=201,o.setUint32(a,s+1),a+=4}r[a++]=116,r[a++]=e,i.buffer||(i=new Uint8Array(i)),r.set(new Uint8Array(i.buffer,i.byteOffset,i.byteLength),a)}function PS(i,e){let t=i.byteLength;var n,s;if(t<256){var{target:n,position:s}=e(t+2);n[s++]=196,n[s++]=t}else if(t<65536){var{target:n,position:s}=e(t+3);n[s++]=197,n[s++]=t>>8,n[s++]=t&255}else{var{target:n,position:s,targetView:r}=e(t+5);n[s++]=198,r.setUint32(s,t),s+=4}n.set(i,s)}function n3(i,e,t,n){let s=i.length;switch(s){case 1:e[t++]=212;break;case 2:e[t++]=213;break;case 4:e[t++]=214;break;case 8:e[t++]=215;break;case 16:e[t++]=216;break;default:s<256?(e[t++]=199,e[t++]=s):s<65536?(e[t++]=200,e[t++]=s>>8,e[t++]=s&255):(e[t++]=201,e[t++]=s>>24,e[t++]=s>>16&255,e[t++]=s>>8&255,e[t++]=s&255)}return e[t++]=n,e.set(i,t),t+=s,t}function i3(i,e){let t,n=e.length*6,s=i.length-n;for(;t=e.pop();){let r=t.offset,a=t.id;i.copyWithin(r+n,r,s),n-=6;let o=r+n;i[o++]=214,i[o++]=105,i[o++]=a>>24,i[o++]=a>>16&255,i[o++]=a>>8&255,i[o++]=a&255,s=r}return i}function LS(i,e,t){if(rn.length>0){Xt.setUint32(rn.position+i,J+t-rn.position-i),rn.stringsPosition=J-i;let n=rn;rn=null,e(n[0]),e(n[1])}}function NS(i){if(i.Class){if(!i.pack&&!i.write)throw new Error("Extension has no pack or write function");if(i.pack&&!i.type)throw new Error("Extension has no type (numeric code to identify the extension)");l0.unshift(i.Class),Rf.unshift(i)}SS(i)}function s3(i,e){return i.isCompatible=t=>{let n=!t||(e.lastNamedStructuresLength||0)===t.length;return n||e._mergeStructures(t),n},i}var Tf,Rf,l0,Cf,Af,DS,CS,se,sl,Xt,J,ei,rn,QI,e3,t3,Ao,js,OS,FS,kS,US,BS,zS,HS,VS,h0,u0,f0,d0=un(()=>{Eo();Eo();Eo();try{Tf=new TextEncoder}catch{}Cf=typeof Buffer<"u",Af=Cf?function(i){return Buffer.allocUnsafeSlow(i)}:Uint8Array,DS=Cf?Buffer:Uint8Array,CS=Cf?4294967296:2144337920,J=0,rn=null,e3=21760,t3=/[\u0080-\uFFFF]/,Ao=Symbol("record-id"),js=class extends Ms{constructor(e){super(e),this.offset=0;let t,n,s,r,a,o=DS.prototype.utf8Write?function(P,N){return se.utf8Write(P,N,se.byteLength-N)}:Tf&&Tf.encodeInto?function(P,N){return Tf.encodeInto(P,se.subarray(N)).written}:!1,c=this;e||(e={});let l=e&&e.sequential,h=e.structures||e.saveStructures,u=e.maxSharedStructures;if(u==null&&(u=h?32:0),u>8160)throw new Error("Maximum maxSharedStructure is 8160");e.structuredClone&&e.moreTypes==null&&(this.moreTypes=!0);let d=e.maxOwnStructures;d==null&&(d=h?32:64),!this.structures&&e.useRecords!=!1&&(this.structures=[]);let p=u>32||d+u>64,b=u+64,v=u+d+64;if(v>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let _=[],g=0,E=0;this.pack=this.encode=function(P,N){if(se||(se=new Af(8192),Xt=se.dataView||(se.dataView=new DataView(se.buffer,0,8192)),J=0),ei=se.length-10,ei-J<2048?(se=new Af(se.length),Xt=se.dataView||(se.dataView=new DataView(se.buffer,0,se.length)),ei=se.length-10,J=0):J=J+7&2147483640,n=J,N&f0&&(J+=N&255),a=c.structuredClone?new Map:null,c.bundleStrings&&typeof P!="string"?(rn=[],rn.size=1/0):rn=null,r=c.structures,r){r.uninitialized&&(r=c._mergeStructures(c.getStructures()));let F=r.sharedLength||0;if(F>u)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+r.sharedLength);if(!r.transitions){r.transitions=Object.create(null);for(let H=0;H<F;H++){let V=r[H];if(!V)continue;let Q,te=r.transitions;for(let Se=0,ve=V.length;Se<ve;Se++){let nt=V[Se];Q=te[nt],Q||(Q=te[nt]=Object.create(null)),te=Q}te[Ao]=H+64}this.lastNamedStructuresLength=F}l||(r.nextId=F+64)}s&&(s=!1);let O;try{c.randomAccessStructure&&P&&P.constructor&&P.constructor===Object?K(P):M(P);let F=rn;if(rn&&LS(n,M,0),a&&a.idsToInsert){let H=a.idsToInsert.sort((Se,ve)=>Se.offset>ve.offset?1:-1),V=H.length,Q=-1;for(;F&&V>0;){let Se=H[--V].offset+n;Se<F.stringsPosition+n&&Q===-1&&(Q=0),Se>F.position+n?Q>=0&&(Q+=6):(Q>=0&&(Xt.setUint32(F.position+n,Xt.getUint32(F.position+n)+Q),Q=-1),F=F.previous,V++)}Q>=0&&F&&Xt.setUint32(F.position+n,Xt.getUint32(F.position+n)+Q),J+=H.length*6,J>ei&&k(J),c.offset=J;let te=i3(se.subarray(n,J),H);return a=null,te}return c.offset=J,N&h0?(se.start=n,se.end=J,se):se.subarray(n,J)}catch(F){throw O=F,F}finally{if(r&&(L(),s&&c.saveStructures)){let F=r.sharedLength||0,H=se.subarray(n,J),V=s3(r,c);if(!O)return c.saveStructures(V,V.isCompatible)===!1?c.pack(P,N):(c.lastNamedStructuresLength=F,se.length>1073741824&&(se=null),H)}se.length>1073741824&&(se=null),N&u0&&(J=n)}};let L=()=>{E<10&&E++;let P=r.sharedLength||0;if(r.length>P&&!l&&(r.length=P),g>1e4)r.transitions=null,E=0,g=0,_.length>0&&(_=[]);else if(_.length>0&&!l){for(let N=0,O=_.length;N<O;N++)_[N][Ao]=0;_=[]}},S=P=>{var N=P.length;N<16?se[J++]=144|N:N<65536?(se[J++]=220,se[J++]=N>>8,se[J++]=N&255):(se[J++]=221,Xt.setUint32(J,N),J+=4);for(let O=0;O<N;O++)M(P[O])},M=P=>{J>ei&&(se=k(J));var N=typeof P,O;if(N==="string"){let F=P.length;if(rn&&F>=4&&F<4096){if((rn.size+=F)>e3){let te,Se=(rn[0]?rn[0].length*3+rn[1].length:0)+10;J+Se>ei&&(se=k(J+Se));let ve;rn.position?(ve=rn,se[J]=200,J+=3,se[J++]=98,te=J-n,J+=4,LS(n,M,0),Xt.setUint16(te+n-3,J-n-te)):(se[J++]=214,se[J++]=98,te=J-n,J+=4),rn=["",""],rn.previous=ve,rn.size=0,rn.position=te}let Q=t3.test(P);rn[Q?0:1]+=P,se[J++]=193,M(Q?-F:F);return}let H;F<32?H=1:F<256?H=2:F<65536?H=3:H=5;let V=F*3;if(J+V>ei&&(se=k(J+V)),F<64||!o){let Q,te,Se,ve=J+H;for(Q=0;Q<F;Q++)te=P.charCodeAt(Q),te<128?se[ve++]=te:te<2048?(se[ve++]=te>>6|192,se[ve++]=te&63|128):(te&64512)===55296&&((Se=P.charCodeAt(Q+1))&64512)===56320?(te=65536+((te&1023)<<10)+(Se&1023),Q++,se[ve++]=te>>18|240,se[ve++]=te>>12&63|128,se[ve++]=te>>6&63|128,se[ve++]=te&63|128):(se[ve++]=te>>12|224,se[ve++]=te>>6&63|128,se[ve++]=te&63|128);O=ve-J-H}else O=o(P,J+H);O<32?se[J++]=160|O:O<256?(H<2&&se.copyWithin(J+2,J+1,J+1+O),se[J++]=217,se[J++]=O):O<65536?(H<3&&se.copyWithin(J+3,J+2,J+2+O),se[J++]=218,se[J++]=O>>8,se[J++]=O&255):(H<5&&se.copyWithin(J+5,J+3,J+3+O),se[J++]=219,Xt.setUint32(J,O),J+=4),J+=O}else if(N==="number")if(P>>>0===P)P<32||P<128&&this.useRecords===!1||P<64&&!this.randomAccessStructure?se[J++]=P:P<256?(se[J++]=204,se[J++]=P):P<65536?(se[J++]=205,se[J++]=P>>8,se[J++]=P&255):(se[J++]=206,Xt.setUint32(J,P),J+=4);else if(P>>0===P)P>=-32?se[J++]=256+P:P>=-128?(se[J++]=208,se[J++]=P+256):P>=-32768?(se[J++]=209,Xt.setInt16(J,P),J+=2):(se[J++]=210,Xt.setInt32(J,P),J+=4);else{let F;if((F=this.useFloat32)>0&&P<4294967296&&P>=-2147483648){se[J++]=202,Xt.setFloat32(J,P);let H;if(F<4||(H=P*nl[(se[J]&127)<<1|se[J+1]>>7])>>0===H){J+=4;return}else J--}se[J++]=203,Xt.setFloat64(J,P),J+=8}else if(N==="object"||N==="function")if(!P)se[J++]=192;else{if(a){let H=a.get(P);if(H){if(!H.id){let V=a.idsToInsert||(a.idsToInsert=[]);H.id=V.push(H)}se[J++]=214,se[J++]=112,Xt.setUint32(J,H.id),J+=4;return}else a.set(P,{offset:J-n})}let F=P.constructor;if(F===Object)C(P);else if(F===Array)S(P);else if(F===Map)if(this.mapAsEmptyObject)se[J++]=128;else{O=P.size,O<16?se[J++]=128|O:O<65536?(se[J++]=222,se[J++]=O>>8,se[J++]=O&255):(se[J++]=223,Xt.setUint32(J,O),J+=4);for(let[H,V]of P)M(H),M(V)}else{for(let H=0,V=Rf.length;H<V;H++){let Q=l0[H];if(P instanceof Q){let te=Rf[H];if(te.write){te.type&&(se[J++]=212,se[J++]=te.type,se[J++]=0);let Qe=te.write.call(this,P);Qe===P?Array.isArray(P)?S(P):C(P):M(Qe);return}let Se=se,ve=Xt,nt=J;se=null;let je;try{je=te.pack.call(this,P,Qe=>(se=Se,Se=null,J+=Qe,J>ei&&k(J),{target:se,targetView:Xt,position:J-Qe}),M)}finally{Se&&(se=Se,Xt=ve,J=nt,ei=se.length-10)}je&&(je.length+J>ei&&k(je.length+J),J=n3(je,se,J,te.type));return}}if(Array.isArray(P))S(P);else{if(P.toJSON){let H=P.toJSON();if(H!==P)return M(H)}if(N==="function")return M(this.writeFunction&&this.writeFunction(P));C(P)}}}else if(N==="boolean")se[J++]=P?195:194;else if(N==="bigint"){if(P<BigInt(1)<<BigInt(63)&&P>=-(BigInt(1)<<BigInt(63)))se[J++]=211,Xt.setBigInt64(J,P);else if(P<BigInt(1)<<BigInt(64)&&P>0)se[J++]=207,Xt.setBigUint64(J,P);else if(this.largeBigIntToFloat)se[J++]=203,Xt.setFloat64(J,Number(P));else{if(this.largeBigIntToString)return M(P.toString());if(this.useBigIntExtension&&P<BigInt(2)**BigInt(1023)&&P>-(BigInt(2)**BigInt(1023))){se[J++]=199,J++,se[J++]=66;let F=[],H;do{let V=P&BigInt(255);H=(V&BigInt(128))===(P<BigInt(0)?BigInt(128):BigInt(0)),F.push(V),P>>=BigInt(8)}while(!((P===BigInt(0)||P===BigInt(-1))&&H));se[J-2]=F.length;for(let V=F.length;V>0;)se[J++]=Number(F[--V]);return}else throw new RangeError(P+" was too large to fit in MessagePack 64-bit integer format, use useBigIntExtension, or set largeBigIntToFloat to convert to float-64, or set largeBigIntToString to convert to string")}J+=8}else if(N==="undefined")this.encodeUndefinedAsNil?se[J++]=192:(se[J++]=212,se[J++]=0,se[J++]=0);else throw new Error("Unknown type: "+N)},A=this.variableMapSize||this.coercibleKeyAsNumber||this.skipValues?P=>{let N;if(this.skipValues){N=[];for(let H in P)(typeof P.hasOwnProperty!="function"||P.hasOwnProperty(H))&&!this.skipValues.includes(P[H])&&N.push(H)}else N=Object.keys(P);let O=N.length;O<16?se[J++]=128|O:O<65536?(se[J++]=222,se[J++]=O>>8,se[J++]=O&255):(se[J++]=223,Xt.setUint32(J,O),J+=4);let F;if(this.coercibleKeyAsNumber)for(let H=0;H<O;H++){F=N[H];let V=Number(F);M(isNaN(V)?F:V),M(P[F])}else for(let H=0;H<O;H++)M(F=N[H]),M(P[F])}:P=>{se[J++]=222;let N=J-n;J+=2;let O=0;for(let F in P)(typeof P.hasOwnProperty!="function"||P.hasOwnProperty(F))&&(M(F),M(P[F]),O++);if(O>65535)throw new Error('Object is too large to serialize with fast 16-bit map size, use the "variableMapSize" option to serialize this object');se[N+++n]=O>>8,se[N+n]=O&255},I=this.useRecords===!1?A:e.progressiveRecords&&!p?P=>{let N,O=r.transitions||(r.transitions=Object.create(null)),F=J++-n,H;for(let V in P)if(typeof P.hasOwnProperty!="function"||P.hasOwnProperty(V)){if(N=O[V],N)O=N;else{let Q=Object.keys(P),te=O;O=r.transitions;let Se=0;for(let ve=0,nt=Q.length;ve<nt;ve++){let je=Q[ve];N=O[je],N||(N=O[je]=Object.create(null),Se++),O=N}F+n+1==J?(J--,z(O,Q,Se)):$(O,Q,F,Se),H=!0,O=te[V]}M(P[V])}if(!H){let V=O[Ao];V?se[F+n]=V:$(O,Object.keys(P),F,0)}}:P=>{let N,O=r.transitions||(r.transitions=Object.create(null)),F=0;for(let V in P)(typeof P.hasOwnProperty!="function"||P.hasOwnProperty(V))&&(N=O[V],N||(N=O[V]=Object.create(null),F++),O=N);let H=O[Ao];H?H>=96&&p?(se[J++]=((H-=96)&31)+96,se[J++]=H>>5):se[J++]=H:z(O,O.__keys__||Object.keys(P),F);for(let V in P)(typeof P.hasOwnProperty!="function"||P.hasOwnProperty(V))&&M(P[V])},y=typeof this.useRecords=="function"&&this.useRecords,C=y?P=>{y(P)?I(P):A(P)}:I,k=P=>{let N;if(P>16777216){if(P-n>CS)throw new Error("Packed buffer would be larger than maximum buffer size");N=Math.min(CS,Math.round(Math.max((P-n)*(P>67108864?1.25:2),4194304)/4096)*4096)}else N=(Math.max(P-n<<2,se.length-1)>>12)+1<<12;let O=new Af(N);return Xt=O.dataView||(O.dataView=new DataView(O.buffer,0,N)),P=Math.min(P,se.length),se.copy?se.copy(O,0,n,P):O.set(se.slice(n,P)),J-=n,n=0,ei=O.length-10,se=O},z=(P,N,O)=>{let F=r.nextId;F||(F=64),F<b&&this.shouldShareStructure&&!this.shouldShareStructure(N)?(F=r.nextOwnId,F<v||(F=b),r.nextOwnId=F+1):(F>=v&&(F=b),r.nextId=F+1);let H=N.highByte=F>=96&&p?F-96>>5:-1;P[Ao]=F,P.__keys__=N,r[F-64]=N,F<b?(N.isShared=!0,r.sharedLength=F-63,s=!0,H>=0?(se[J++]=(F&31)+96,se[J++]=H):se[J++]=F):(H>=0?(se[J++]=213,se[J++]=114,se[J++]=(F&31)+96,se[J++]=H):(se[J++]=212,se[J++]=114,se[J++]=F),O&&(g+=E*O),_.length>=d&&(_.shift()[Ao]=0),_.push(P),M(N))},$=(P,N,O,F)=>{let H=se,V=J,Q=ei,te=n;se=sl,J=0,n=0,se||(sl=se=new Af(8192)),ei=se.length-10,z(P,N,F),sl=se;let Se=J;if(se=H,J=V,ei=Q,n=te,Se>1){let ve=J+Se-1;ve>ei&&k(ve);let nt=O+n;se.copyWithin(nt+Se,nt+1,J),se.set(sl.slice(0,Se),nt),J=ve}else se[O+n]=sl[0]},K=P=>{let N=QI(P,se,n,J,r,k,(O,F,H)=>{if(H)return s=!0;J=F;let V=se;return M(O),L(),V!==se?{position:J,targetView:Xt,target:se}:J},this);if(N===0)return C(P);J=N}}useBuffer(e){se=e,se.dataView||(se.dataView=new DataView(se.buffer,se.byteOffset,se.byteLength)),Xt=se.dataView,J=0}set position(e){J=e}get position(){return J}set buffer(e){se=e}get buffer(){return se}clearSharedData(){this.structures&&(this.structures=[]),this.typedStructs&&(this.typedStructs=[])}};l0=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,Qc];Rf=[{pack(i,e,t){let n=i.getTime()/1e3;if((this.useTimestamp32||i.getMilliseconds()===0)&&n>=0&&n<4294967296){let{target:s,targetView:r,position:a}=e(6);s[a++]=214,s[a++]=255,r.setUint32(a,n)}else if(n>0&&n<4294967296){let{target:s,targetView:r,position:a}=e(10);s[a++]=215,s[a++]=255,r.setUint32(a,i.getMilliseconds()*4e6+(n/1e3/4294967296>>0)),r.setUint32(a+4,n)}else if(isNaN(n)){if(this.onInvalidDate)return e(0),t(this.onInvalidDate());let{target:s,targetView:r,position:a}=e(3);s[a++]=212,s[a++]=255,s[a++]=255}else{let{target:s,targetView:r,position:a}=e(15);s[a++]=199,s[a++]=12,s[a++]=255,r.setUint32(a,i.getMilliseconds()*1e6),r.setBigInt64(a+4,BigInt(Math.floor(n)))}}},{pack(i,e,t){if(this.setAsEmptyObject)return e(0),t({});let n=Array.from(i),{target:s,position:r}=e(this.moreTypes?3:0);this.moreTypes&&(s[r++]=212,s[r++]=115,s[r++]=0),t(n)}},{pack(i,e,t){let{target:n,position:s}=e(this.moreTypes?3:0);this.moreTypes&&(n[s++]=212,n[s++]=101,n[s++]=0),t([i.name,i.message,i.cause])}},{pack(i,e,t){let{target:n,position:s}=e(this.moreTypes?3:0);this.moreTypes&&(n[s++]=212,n[s++]=120,n[s++]=0),t([i.source,i.flags])}},{pack(i,e){this.moreTypes?IS(i,16,e):PS(Cf?Buffer.from(i):new Uint8Array(i),e)}},{pack(i,e){let t=i.constructor;t!==DS&&this.moreTypes?IS(i,c0.indexOf(t.name),e):PS(i,e)}},{pack(i,e){let{target:t,position:n}=e(1);t[n]=193}}];OS=new js({useRecords:!1}),FS=OS.pack,kS=OS.pack,US=js,{NEVER:BS,ALWAYS:zS,DECIMAL_ROUND:HS,DECIMAL_FIT:VS}=il,h0=512,u0=1024,f0=2048});function r3(i,e={}){if(!i||typeof i!="object")throw new Error("first argument must be an Iterable, Async Iterable, or a Promise for an Async Iterable");if(typeof i[Symbol.iterator]=="function")return a3(i,e);if(typeof i.then=="function"||typeof i[Symbol.asyncIterator]=="function")return o3(i,e);throw new Error("first argument must be an Iterable, Async Iterable, Iterator, Async Iterator, or a Promise")}function*a3(i,e){let t=new js(e);for(let n of i)yield t.pack(n)}async function*o3(i,e){let t=new js(e);for await(let n of i)yield t.pack(n)}function c3(i,e={}){if(!i||typeof i!="object")throw new Error("first argument must be an Iterable, Async Iterable, Iterator, Async Iterator, or a promise");let t=new Ms(e),n,s=r=>{let a;n&&(r=Buffer.concat([n,r]),n=void 0);try{a=t.unpackMultiple(r)}catch(o){if(o.incomplete)n=r.slice(o.lastPosition),a=o.values;else throw o}return a};if(typeof i[Symbol.iterator]=="function")return(function*(){for(let a of i)yield*s(a)})();if(typeof i[Symbol.asyncIterator]=="function")return(async function*(){for await(let a of i)yield*s(a)})()}var GS,WS,$S=un(()=>{d0();Eo();GS=c3,WS=r3});var qS={};er(qS,{ALWAYS:()=>zS,C1:()=>Mf,DECIMAL_FIT:()=>VS,DECIMAL_ROUND:()=>HS,Decoder:()=>wS,Encoder:()=>US,FLOAT32_OPTIONS:()=>il,NEVER:()=>BS,Packr:()=>js,RESERVE_START_SPACE:()=>f0,RESET_BUFFER_MODE:()=>u0,REUSE_BUFFER_MODE:()=>h0,Unpackr:()=>Ms,addExtension:()=>NS,clearSource:()=>el,decode:()=>AS,decodeIter:()=>GS,encode:()=>kS,encodeIter:()=>WS,isNativeAccelerationEnabled:()=>bS,mapsAsObjects:()=>h3,pack:()=>FS,roundFloat32:()=>RS,unpack:()=>MS,unpackMultiple:()=>ES,useRecords:()=>l3});var l3,h3,jS=un(()=>{d0();Eo();$S();l3=!1,h3=!0});var m0=xn(JS=>{"use strict";var u3=Zv(),Ui=jg(),XS=Kg(),f3=Yg(),If=tS(),Yn=yf(),d3=e0(),KS=Zc(),YS=(jS(),Aa(qS)),p0=class i{constructor(e,t){this.onStateChange=If.createSignal(),this.onError=If.createSignal(),this.onLeave=If.createSignal(),this.onJoin=If.createSignal(),this.hasJoined=!1,this.onMessageHandlers=f3.createNanoEvents(),this.roomId=null,this.name=e,this.packr=new YS.Packr,this.packr.encode(void 0),t&&(this.serializer=new(XS.getSerializer("schema")),this.rootSchema=t,this.serializer.state=new t),this.onError((n,s)=>{var r;return(r=console.warn)===null||r===void 0?void 0:r.call(console,`colyseus.js - onError => (${n}) ${s}`)}),this.onLeave(()=>this.removeAllListeners())}connect(e,t,n=this,s,r){let a=new u3.Connection(s.protocol);if(n.connection=a,a.events.onmessage=i.prototype.onMessageCallback.bind(n),a.events.onclose=function(o){var c;if(!n.hasJoined){(c=console.warn)===null||c===void 0||c.call(console,`Room connection was closed unexpectedly (${o.code}): ${o.reason}`),n.onError.invoke(o.code,o.reason);return}o.code===KS.CloseCode.DEVMODE_RESTART&&t?t():(n.onLeave.invoke(o.code,o.reason),n.destroy())},a.events.onerror=function(o){var c;(c=console.warn)===null||c===void 0||c.call(console,`Room, onError (${o.code}): ${o.reason}`),n.onError.invoke(o.code,o.reason)},s.protocol==="h3"){let o=new URL(e);a.connect(o.origin,s)}else a.connect(e,r)}leave(e=!0){return new Promise(t=>{this.onLeave(n=>t(n)),this.connection?e?(this.packr.buffer[0]=Ui.Protocol.LEAVE_ROOM,this.connection.send(this.packr.buffer.subarray(0,1))):this.connection.close():this.onLeave.invoke(KS.CloseCode.CONSENTED)})}onMessage(e,t){return this.onMessageHandlers.on(this.getMessageHandlerKey(e),t)}send(e,t){let n={offset:1};this.packr.buffer[0]=Ui.Protocol.ROOM_DATA,typeof e=="string"?Yn.encode.string(this.packr.buffer,e,n):Yn.encode.number(this.packr.buffer,e,n),this.packr.position=0;let s=t!==void 0?this.packr.pack(t,2048+n.offset):this.packr.buffer.subarray(0,n.offset);this.connection.send(s)}sendUnreliable(e,t){let n={offset:1};this.packr.buffer[0]=Ui.Protocol.ROOM_DATA,typeof e=="string"?Yn.encode.string(this.packr.buffer,e,n):Yn.encode.number(this.packr.buffer,e,n),this.packr.position=0;let s=t!==void 0?this.packr.pack(t,2048+n.offset):this.packr.buffer.subarray(0,n.offset);this.connection.sendUnreliable(s)}sendBytes(e,t){let n={offset:1};if(this.packr.buffer[0]=Ui.Protocol.ROOM_DATA_BYTES,typeof e=="string"?Yn.encode.string(this.packr.buffer,e,n):Yn.encode.number(this.packr.buffer,e,n),t.byteLength+n.offset>this.packr.buffer.byteLength){let s=new Uint8Array(n.offset+t.byteLength);s.set(this.packr.buffer),this.packr.useBuffer(s)}this.packr.buffer.set(t,n.offset),this.connection.send(this.packr.buffer.subarray(0,n.offset+t.byteLength))}get state(){return this.serializer.getState()}removeAllListeners(){this.onJoin.clear(),this.onStateChange.clear(),this.onError.clear(),this.onLeave.clear(),this.onMessageHandlers.events={},this.serializer instanceof d3.SchemaSerializer&&(this.serializer.decoder.root.callbacks={})}onMessageCallback(e){let t=new Uint8Array(e.data),n={offset:1},s=t[0];if(s===Ui.Protocol.JOIN_ROOM){let r=Yn.decode.utf8Read(t,n,t[n.offset++]);if(this.serializerId=Yn.decode.utf8Read(t,n,t[n.offset++]),!this.serializer){let a=XS.getSerializer(this.serializerId);this.serializer=new a}t.byteLength>n.offset&&this.serializer.handshake&&this.serializer.handshake(t,n),this.reconnectionToken=`${this.roomId}:${r}`,this.hasJoined=!0,this.onJoin.invoke(),this.packr.buffer[0]=Ui.Protocol.JOIN_ROOM,this.connection.send(this.packr.buffer.subarray(0,1))}else if(s===Ui.Protocol.ERROR){let r=Yn.decode.number(t,n),a=Yn.decode.string(t,n);this.onError.invoke(r,a)}else if(s===Ui.Protocol.LEAVE_ROOM)this.leave();else if(s===Ui.Protocol.ROOM_STATE)this.serializer.setState(t,n),this.onStateChange.invoke(this.serializer.getState());else if(s===Ui.Protocol.ROOM_STATE_PATCH)this.serializer.patch(t,n),this.onStateChange.invoke(this.serializer.getState());else if(s===Ui.Protocol.ROOM_DATA){let r=Yn.decode.stringCheck(t,n)?Yn.decode.string(t,n):Yn.decode.number(t,n),a=t.byteLength>n.offset?YS.unpack(t,{start:n.offset}):void 0;this.dispatchMessage(r,a)}else if(s===Ui.Protocol.ROOM_DATA_BYTES){let r=Yn.decode.stringCheck(t,n)?Yn.decode.string(t,n):Yn.decode.number(t,n);this.dispatchMessage(r,t.subarray(n.offset))}}dispatchMessage(e,t){var n;let s=this.getMessageHandlerKey(e);this.onMessageHandlers.events[s]?this.onMessageHandlers.emit(s,t):this.onMessageHandlers.events["*"]?this.onMessageHandlers.emit("*",e,t):(n=console.warn)===null||n===void 0||n.call(console,`colyseus.js: onMessage() not registered for type '${e}'.`)}destroy(){this.serializer&&this.serializer.teardown()}getMessageHandlerKey(e){switch(typeof e){case"string":return e;case"number":return`i${e}`;default:throw new Error("invalid message type.")}}};JS.Room=p0});var QS={};er(QS,{del:()=>b3,get:()=>p3,patch:()=>g3,post:()=>m3,put:()=>_3,send:()=>es});function ZS(i,e){e.headers=i.headers||{},e.statusMessage=i.statusText,e.statusCode=i.status,e.data=i.response}function es(i,e,t){return new Promise(function(n,s){t=t||{};var r=new XMLHttpRequest,a,o,c,l=t.body,h=t.headers||{};t.timeout&&(r.timeout=t.timeout),r.ontimeout=r.onerror=function(u){u.timeout=u.type=="timeout",s(u)},r.onabort=function(u){u.aborted=!0,s(u)},r.open(i,e.href||e),r.onload=function(){for(c=r.getAllResponseHeaders().trim().split(/[\r\n]+/),ZS(r,r);o=c.shift();)o=o.split(": "),r.headers[o.shift().toLowerCase()]=o.join(": ");if(o=r.headers["content-type"],o&&~o.indexOf("application/json"))try{r.data=JSON.parse(r.data,t.reviver)}catch(u){return ZS(r,u),s(u)}(r.status>=400?s:n)(r)},typeof FormData<"u"&&l instanceof FormData||l&&typeof l=="object"&&(h["content-type"]="application/json",l=JSON.stringify(l)),r.withCredentials=!!t.withCredentials;for(a in h)r.setRequestHeader(a,h[a]);r.send(l),t.signal&&t.signal.addEventListener("abort",function(){r.abort()})})}var p3,m3,g3,b3,_3,ew=un(()=>{p3=es.bind(es,"GET"),m3=es.bind(es,"POST"),g3=es.bind(es,"PATCH"),b3=es.bind(es,"DELETE"),_3=es.bind(es,"PUT")});var iw=xn(nw=>{"use strict";var tw=Zc(),x3=(ew(),Aa(QS));function y3(i){var e=Object.create(null);return i&&Object.keys(i).forEach(function(t){if(t!=="default"){var n=Object.getOwnPropertyDescriptor(i,t);Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:function(){return i[t]}})}}),e.default=i,Object.freeze(e)}var v3=y3(x3),g0=class{constructor(e,t={}){this.client=e,this.headers=t}get(e,t={}){return this.request("get",e,t)}post(e,t={}){return this.request("post",e,t)}del(e,t={}){return this.request("del",e,t)}put(e,t={}){return this.request("put",e,t)}request(e,t,n={}){return v3[e](this.client.getHttpEndpoint(t),this.getOptions(n)).catch(s=>{var r;if(s.aborted)throw new tw.AbortError("Request aborted");let a=s.statusCode,o=((r=s.data)===null||r===void 0?void 0:r.error)||s.statusMessage||s.message;throw!a&&!o?s:new tw.ServerError(a,o)})}getOptions(e){return e.headers=Object.assign({},this.headers,e.headers),this.authToken&&(e.headers.Authorization=`Bearer ${this.authToken}`),typeof cc<"u"&&cc.sys&&cc.sys.isNative||(e.withCredentials=!0),e}};nw.HTTP=g0});var rw=xn(Pf=>{"use strict";var sw=(Jc(),Aa(Yc)),ba;function _0(){if(!ba)try{ba=typeof cc<"u"&&cc.sys&&cc.sys.localStorage?cc.sys.localStorage:window.localStorage}catch{}return!ba&&typeof globalThis.indexedDB<"u"&&(ba=new b0),ba||(ba={cache:{},setItem:function(i,e){this.cache[i]=e},getItem:function(i){this.cache[i]},removeItem:function(i){delete this.cache[i]}}),ba}function S3(i,e){_0().setItem(i,e)}function w3(i){_0().removeItem(i)}function M3(i,e){let t=_0().getItem(i);typeof Promise>"u"||!(t instanceof Promise)?e(t):t.then(n=>e(n))}var b0=class{constructor(){this.dbPromise=new Promise(e=>{let t=indexedDB.open("_colyseus_storage",1);t.onupgradeneeded=()=>t.result.createObjectStore("store"),t.onsuccess=()=>e(t.result)})}tx(e,t){return sw.__awaiter(this,void 0,void 0,function*(){let s=(yield this.dbPromise).transaction("store",e).objectStore("store");return t(s)})}setItem(e,t){return this.tx("readwrite",n=>n.put(t,e)).then()}getItem(e){return sw.__awaiter(this,void 0,void 0,function*(){let t=yield this.tx("readonly",n=>n.get(e));return new Promise(n=>{t.onsuccess=()=>n(t.result)})})}removeItem(e){return this.tx("readwrite",t=>t.delete(e)).then()}};Pf.getItem=M3;Pf.removeItem=w3;Pf.setItem=S3});var S0=xn(aw=>{"use strict";var Pn=(Jc(),Aa(Yc)),x0=rw(),E3=Yg(),Lf,y0,Rr,Df,v0=class{constructor(e){this.http=e,this.settings={path:"/auth",key:"colyseus-auth-token"},Lf.set(this,!1),y0.set(this,void 0),Rr.set(this,void 0),Df.set(this,E3.createNanoEvents()),x0.getItem(this.settings.key,t=>this.token=t)}set token(e){this.http.authToken=e}get token(){return this.http.authToken}onChange(e){let t=Pn.__classPrivateFieldGet(this,Df,"f").on("change",e);return Pn.__classPrivateFieldGet(this,Lf,"f")||Pn.__classPrivateFieldSet(this,y0,new Promise((n,s)=>{this.getUserData().then(r=>{this.emitChange(Object.assign(Object.assign({},r),{token:this.token}))}).catch(r=>{this.emitChange({user:null,token:void 0})}).finally(()=>{n()})}),"f"),Pn.__classPrivateFieldSet(this,Lf,!0,"f"),t}getUserData(){return Pn.__awaiter(this,void 0,void 0,function*(){if(this.token)return(yield this.http.get(`${this.settings.path}/userdata`)).data;throw new Error("missing auth.token")})}registerWithEmailAndPassword(e,t,n){return Pn.__awaiter(this,void 0,void 0,function*(){let s=(yield this.http.post(`${this.settings.path}/register`,{body:{email:e,password:t,options:n}})).data;return this.emitChange(s),s})}signInWithEmailAndPassword(e,t){return Pn.__awaiter(this,void 0,void 0,function*(){let n=(yield this.http.post(`${this.settings.path}/login`,{body:{email:e,password:t}})).data;return this.emitChange(n),n})}signInAnonymously(e){return Pn.__awaiter(this,void 0,void 0,function*(){let t=(yield this.http.post(`${this.settings.path}/anonymous`,{body:{options:e}})).data;return this.emitChange(t),t})}sendPasswordResetEmail(e){return Pn.__awaiter(this,void 0,void 0,function*(){return(yield this.http.post(`${this.settings.path}/forgot-password`,{body:{email:e}})).data})}signInWithProvider(e){return Pn.__awaiter(this,arguments,void 0,function*(t,n={}){return new Promise((s,r)=>{let a=n.width||480,o=n.height||768,c=this.token?`?token=${this.token}`:"",l=`Login with ${t[0].toUpperCase()+t.substring(1)}`,h=this.http.client.getHttpEndpoint(`${n.prefix||`${this.settings.path}/provider`}/${t}${c}`),u=screen.width/2-a/2,d=screen.height/2-o/2;Pn.__classPrivateFieldSet(this,Rr,window.open(h,l,"toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width="+a+", height="+o+", top="+d+", left="+u),"f");let p=v=>{v.data.user===void 0&&v.data.token===void 0||(clearInterval(b),Pn.__classPrivateFieldGet(this,Rr,"f").close(),Pn.__classPrivateFieldSet(this,Rr,void 0,"f"),window.removeEventListener("message",p),v.data.error!==void 0?r(v.data.error):(s(v.data),this.emitChange(v.data)))},b=setInterval(()=>{(!Pn.__classPrivateFieldGet(this,Rr,"f")||Pn.__classPrivateFieldGet(this,Rr,"f").closed)&&(Pn.__classPrivateFieldSet(this,Rr,void 0,"f"),r("cancelled"),window.removeEventListener("message",p))},200);window.addEventListener("message",p)})})}signOut(){return Pn.__awaiter(this,void 0,void 0,function*(){this.emitChange({user:null,token:null})})}emitChange(e){e.token!==void 0&&(this.token=e.token,e.token===null?x0.removeItem(this.settings.key):x0.setItem(this.settings.key,e.token)),Pn.__classPrivateFieldGet(this,Df,"f").emit("change",e)}};Lf=new WeakMap,y0=new WeakMap,Rr=new WeakMap,Df=new WeakMap;aw.Auth=v0});var cw=xn(ow=>{"use strict";function A3(i){var e;let t=((e=window?.location)===null||e===void 0?void 0:e.hostname)||"localhost",n=i.hostname.split("."),s=!i.hostname.includes("trycloudflare.com")&&!i.hostname.includes("discordsays.com")&&n.length>2?`/${n[0]}`:"";return i.pathname.startsWith("/.proxy")?`${i.protocol}//${t}${s}${i.pathname}${i.search}`:`${i.protocol}//${t}/.proxy/colyseus${s}${i.pathname}${i.search}`}ow.discordURLBuilder=A3});var hw=xn(M0=>{"use strict";var Xs=(Jc(),Aa(Yc)),T3=Zc(),R3=m0(),C3=iw(),I3=S0(),P3=cw(),w0,Nf=class i extends Error{constructor(e,t){super(e),this.code=t,this.name="MatchMakeError",Object.setPrototypeOf(this,i.prototype)}},lw=typeof window<"u"&&typeof((w0=window?.location)===null||w0===void 0?void 0:w0.hostname)<"u"?`${window.location.protocol.replace("http","ws")}//${window.location.hostname}${window.location.port&&`:${window.location.port}`}`:"ws://127.0.0.1:2567",Of=class{constructor(e=lw,t){var n,s;if(typeof e=="string"){let r=e.startsWith("/")?new URL(e,lw):new URL(e),a=r.protocol==="https:"||r.protocol==="wss:",o=Number(r.port||(a?443:80));this.settings={hostname:r.hostname,pathname:r.pathname,port:o,secure:a,searchParams:r.searchParams.toString()||void 0}}else e.port===void 0&&(e.port=e.secure?443:80),e.pathname===void 0&&(e.pathname=""),this.settings=e;this.settings.pathname.endsWith("/")&&(this.settings.pathname=this.settings.pathname.slice(0,-1)),this.http=new C3.HTTP(this,t?.headers||{}),this.auth=new I3.Auth(this.http),this.urlBuilder=t?.urlBuilder,!this.urlBuilder&&typeof window<"u"&&(!((s=(n=window?.location)===null||n===void 0?void 0:n.hostname)===null||s===void 0)&&s.includes("discordsays.com"))&&(this.urlBuilder=P3.discordURLBuilder,console.log("Colyseus SDK: Discord Embedded SDK detected. Using custom URL builder."))}joinOrCreate(e){return Xs.__awaiter(this,arguments,void 0,function*(t,n={},s){return yield this.createMatchMakeRequest("joinOrCreate",t,n,s)})}create(e){return Xs.__awaiter(this,arguments,void 0,function*(t,n={},s){return yield this.createMatchMakeRequest("create",t,n,s)})}join(e){return Xs.__awaiter(this,arguments,void 0,function*(t,n={},s){return yield this.createMatchMakeRequest("join",t,n,s)})}joinById(e){return Xs.__awaiter(this,arguments,void 0,function*(t,n={},s){return yield this.createMatchMakeRequest("joinById",t,n,s)})}reconnect(e,t){return Xs.__awaiter(this,void 0,void 0,function*(){if(typeof e=="string"&&typeof t=="string")throw new Error("DEPRECATED: .reconnect() now only accepts 'reconnectionToken' as argument.\nYou can get this token from previously connected `room.reconnectionToken`");let[n,s]=e.split(":");if(!n||!s)throw new Error(`Invalid reconnection token format.
+The format should be roomId:reconnectionToken`);return yield this.createMatchMakeRequest("reconnect",n,{reconnectionToken:s},t)})}consumeSeatReservation(e,t,n){return Xs.__awaiter(this,void 0,void 0,function*(){let s=this.createRoom(e.room.name,t);s.roomId=e.room.roomId,s.sessionId=e.sessionId;let r={sessionId:s.sessionId};e.reconnectionToken&&(r.reconnectionToken=e.reconnectionToken);let a=n||s;return s.connect(this.buildEndpoint(e.room,r,e.protocol),e.devMode&&(()=>Xs.__awaiter(this,void 0,void 0,function*(){console.info(`[Colyseus devMode]: ${String.fromCodePoint(128260)} Re-establishing connection with room id '${s.roomId}'...`);let o=0,c=8,l=()=>Xs.__awaiter(this,void 0,void 0,function*(){o++;try{yield this.consumeSeatReservation(e,t,a),console.info(`[Colyseus devMode]: ${String.fromCodePoint(9989)} Successfully re-established connection with room '${s.roomId}'`)}catch{o<c?(console.info(`[Colyseus devMode]: ${String.fromCodePoint(128260)} retrying... (${o} out of ${c})`),setTimeout(l,2e3)):console.info(`[Colyseus devMode]: ${String.fromCodePoint(10060)} Failed to reconnect. Is your server running? Please check server logs.`)}});setTimeout(l,2e3)})),a,e,this.http.headers),new Promise((o,c)=>{let l=(h,u)=>c(new T3.ServerError(h,u));a.onError.once(l),a.onJoin.once(()=>{a.onError.remove(l),o(a)})})})}createMatchMakeRequest(e,t){return Xs.__awaiter(this,arguments,void 0,function*(n,s,r={},a,o){let c=(yield this.http.post(`matchmake/${n}/${s}`,{headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(r)})).data;if(c.error)throw new Nf(c.error,c.code);return n==="reconnect"&&(c.reconnectionToken=r.reconnectionToken),yield this.consumeSeatReservation(c,a,o)})}createRoom(e,t){return new R3.Room(e,t)}buildEndpoint(e,t={},n="ws"){let s=this.settings.searchParams||"";this.http.authToken&&(t._authToken=this.http.authToken);for(let o in t)t.hasOwnProperty(o)&&(s+=(s?"&":"")+`${o}=${t[o]}`);n==="h3"&&(n="http");let r=this.settings.secure?`${n}s://`:`${n}://`;e.publicAddress?r+=`${e.publicAddress}`:r+=`${this.settings.hostname}${this.getEndpointPort()}${this.settings.pathname}`;let a=`${r}/${e.processId}/${e.roomId}?${s}`;return this.urlBuilder?this.urlBuilder(new URL(a)):a}getHttpEndpoint(e=""){let t=e.startsWith("/")?e:`/${e}`,n=`${this.settings.secure?"https":"http"}://${this.settings.hostname}${this.getEndpointPort()}${this.settings.pathname}${t}`;return this.settings.searchParams&&(n+=`?${this.settings.searchParams}`),this.urlBuilder?this.urlBuilder(new URL(n)):n}getEndpointPort(){return this.settings.port!==80&&this.settings.port!==443?`:${this.settings.port}`:""}};Of.VERSION="0.16.22";M0.Client=Of;M0.MatchMakeError=Nf});var fw=xn(uw=>{"use strict";var E0=class{setState(e){}getState(){return null}patch(e){}teardown(){}handshake(e){}};uw.NoneSerializer=E0});var mw=xn(ts=>{"use strict";mv();var dw=hw(),pw=jg(),L3=m0(),D3=S0(),N3=Zc(),A0=e0(),O3=fw(),T0=Kg();T0.registerSerializer("schema",A0.SchemaSerializer);T0.registerSerializer("none",O3.NoneSerializer);ts.Client=dw.Client;ts.MatchMakeError=dw.MatchMakeError;Object.defineProperty(ts,"ErrorCode",{enumerable:!0,get:function(){return pw.ErrorCode}});Object.defineProperty(ts,"Protocol",{enumerable:!0,get:function(){return pw.Protocol}});ts.Room=L3.Room;ts.Auth=D3.Auth;ts.ServerError=N3.ServerError;ts.SchemaSerializer=A0.SchemaSerializer;ts.getStateCallbacks=A0.getStateCallbacks;ts.registerSerializer=T0.registerSerializer});function Rw(i){Object.defineProperty(i,Symbol.metadata,{value:void 0,writable:!0,configurable:!0,enumerable:!1})}function Lw(i,e,t){for(var n=0,s=0,r=e.length;s<r;s++)n=e.charCodeAt(s),n<128?i[t.offset++]=n:n<2048?(i[t.offset]=192|n>>6,i[t.offset+1]=128|n&63,t.offset+=2):n<55296||n>=57344?(i[t.offset]=224|n>>12,i[t.offset+1]=128|n>>6&63,i[t.offset+2]=128|n&63,t.offset+=3):(s++,n=65536+((n&1023)<<10|e.charCodeAt(s)&1023),i[t.offset]=240|n>>18,i[t.offset+1]=128|n>>12&63,i[t.offset+2]=128|n>>6&63,i[t.offset+3]=128|n&63,t.offset+=4)}function Dw(i,e,t){i[t.offset++]=e&255}function B3(i,e,t){i[t.offset++]=e&255}function Nw(i,e,t){i[t.offset++]=e&255,i[t.offset++]=e>>8&255}function z0(i,e,t){i[t.offset++]=e&255,i[t.offset++]=e>>8&255}function Ys(i,e,t){i[t.offset++]=e&255,i[t.offset++]=e>>8&255,i[t.offset++]=e>>16&255,i[t.offset++]=e>>24&255}function ya(i,e,t){let n=e>>24,s=e>>16,r=e>>8,a=e;i[t.offset++]=a&255,i[t.offset++]=r&255,i[t.offset++]=s&255,i[t.offset++]=n&255}function Ow(i,e,t){let n=Math.floor(e/Math.pow(2,32)),s=e>>>0;ya(i,s,t),ya(i,n,t)}function Fw(i,e,t){let n=e/Math.pow(2,32)>>0,s=e>>>0;ya(i,s,t),ya(i,n,t)}function z3(i,e,t){Iw[0]=BigInt.asIntN(64,e),Ys(i,xa[0],t),Ys(i,xa[1],t)}function H3(i,e,t){Iw[0]=BigInt.asIntN(64,e),Ys(i,xa[0],t),Ys(i,xa[1],t)}function kw(i,e,t){L0[0]=e,Ys(i,xa[0],t)}function Uw(i,e,t){k3[0]=e,Ys(i,xa[0],t),Ys(i,xa[1],t)}function V3(i,e,t){i[t.offset++]=e?1:0}function G3(i,e,t){e||(e="");let n=Pw(e,"utf8"),s=0;if(n<32)i[t.offset++]=n|160,s=1;else if(n<256)i[t.offset++]=217,i[t.offset++]=n,s=2;else if(n<65536)i[t.offset++]=218,z0(i,n,t),s=3;else if(n<4294967296)i[t.offset++]=219,ya(i,n,t),s=5;else throw new Error("String too long");return Lw(i,e,t),s+n}function D0(i,e,t){if(isNaN(e))return D0(i,0,t);if(isFinite(e)){if(e!==(e|0))return Math.abs(e)<=34028235e31&&(L0[0]=e,Math.abs(Math.abs(L0[0])-Math.abs(e))<1e-4)?(i[t.offset++]=202,kw(i,e,t),5):(i[t.offset++]=203,Uw(i,e,t),9)}else return D0(i,e>0?Number.MAX_SAFE_INTEGER:-Number.MAX_SAFE_INTEGER,t);return e>=0?e<128?(i[t.offset++]=e&255,1):e<256?(i[t.offset++]=204,i[t.offset++]=e&255,2):e<65536?(i[t.offset++]=205,z0(i,e,t),3):e<4294967296?(i[t.offset++]=206,ya(i,e,t),5):(i[t.offset++]=207,Fw(i,e,t),9):e>=-32?(i[t.offset++]=224|e+32,1):e>=-128?(i[t.offset++]=208,Dw(i,e,t),2):e>=-32768?(i[t.offset++]=209,Nw(i,e,t),3):e>=-2147483648?(i[t.offset++]=210,Ys(i,e,t),5):(i[t.offset++]=211,Ow(i,e,t),9)}function Bw(i,e,t){t>i.length-e.offset&&(t=i.length-e.offset);for(var n="",s=0,r=e.offset,a=e.offset+t;r<a;r++){var o=i[r];if((o&128)===0){n+=String.fromCharCode(o);continue}if((o&224)===192){n+=String.fromCharCode((o&31)<<6|i[++r]&63);continue}if((o&240)===224){n+=String.fromCharCode((o&15)<<12|(i[++r]&63)<<6|(i[++r]&63)<<0);continue}if((o&248)===240){s=(o&7)<<18|(i[++r]&63)<<12|(i[++r]&63)<<6|(i[++r]&63)<<0,s>=65536?(s-=65536,n+=String.fromCharCode((s>>>10)+55296,(s&1023)+56320)):n+=String.fromCharCode(s);continue}console.error("decode.utf8Read(): Invalid byte "+o+" at offset "+r+". Skip to end of string: "+(e.offset+t));break}return e.offset+=t,n}function zw(i,e){return ml(i,e)<<24>>24}function ml(i,e){return i[e.offset++]}function Hw(i,e){return Zf(i,e)<<16>>16}function Zf(i,e){return i[e.offset++]|i[e.offset++]<<8}function cs(i,e){return i[e.offset++]|i[e.offset++]<<8|i[e.offset++]<<16|i[e.offset++]<<24}function Co(i,e){return cs(i,e)>>>0}function Vw(i,e){return va[0]=cs(i,e),W3[0]}function Gw(i,e){return va[0]=cs(i,e),va[1]=cs(i,e),$3[0]}function Ww(i,e){let t=Co(i,e);return cs(i,e)*Math.pow(2,32)+t}function $w(i,e){let t=Co(i,e);return Co(i,e)*Math.pow(2,32)+t}function X3(i,e){return va[0]=cs(i,e),va[1]=cs(i,e),j3[0]}function K3(i,e){return va[0]=cs(i,e),va[1]=cs(i,e),q3[0]}function Y3(i,e){return ml(i,e)>0}function J3(i,e){let t=i[e.offset++],n;return t<192?n=t&31:t===217?n=ml(i,e):t===218?n=Zf(i,e):t===219&&(n=Co(i,e)),Bw(i,e,n)}function Z3(i,e){let t=i[e.offset++];if(t<128)return t;if(t===202)return Vw(i,e);if(t===203)return Gw(i,e);if(t===204)return ml(i,e);if(t===205)return Zf(i,e);if(t===206)return Co(i,e);if(t===207)return $w(i,e);if(t===208)return zw(i,e);if(t===209)return Hw(i,e);if(t===210)return cs(i,e);if(t===211)return Ww(i,e);if(t>223)return(255-t+1)*-1}function Q3(i,e){let t=i[e.offset];return t<192&&t>160||t===217||t===218||t===219}function Zs(i,e){e.constructor&&(Object.prototype.hasOwnProperty.call(e,"constructor")&&e.constructor[Symbol.metadata]==null&&Rw(e.constructor),eP.set(e.constructor,i),H0[i]=e),e.encode&&(Bn[i]=e.encode),e.decode&&(Mi[i]=e.decode)}function qw(i){return H0[i]}function Js(){return{pendingByView:new Map,sentByView:new Map,broadcastPending:new Set,sentBroadcast:new Set,broadcastDeletes:new Set,maxPerTick:32}}function V0(i){return i._stream??=Js()}function Qf(i,e,t){e.activeViews.size===0&&V0(i).broadcastPending.add(t)}function ed(i,e,t,n){let s=i._stream;if(s===void 0)return!0;let r=!1;return s.broadcastPending.delete(n)?r=!0:s.sentBroadcast.delete(n)&&s.broadcastDeletes.add(n),e.forEachActiveView(a=>{let o=s.pendingByView.get(a.id);if(o?.has(n)){o.delete(n),r=!0;return}let c=s.sentByView.get(a.id);if(c?.has(n)){c.delete(n);let l=a.changes.get(t);l===void 0&&(l=new Map,a.changes.set(t,l)),l.set(n,_e.DELETE)}}),r}function tP(i,e,t){let n=i._stream;if(n!==void 0){n.broadcastPending.clear();for(let s of n.sentBroadcast)n.broadcastDeletes.add(s);n.sentBroadcast.clear(),e.forEachActiveView(s=>{n.pendingByView.get(s.id)?.clear();let r=n.sentByView.get(s.id);if(r!==void 0&&r.size>0){let a=s.changes.get(t);a===void 0&&(a=new Map,s.changes.set(t,a));for(let o of r)a.set(o,_e.DELETE);r.clear()}})}}function nP(i,e){let t=i._stream?.pendingByView;if(t===void 0)return!1;for(let[n,s]of t)if(s.size>0&&e.activeViews.get(n)?.deref()!==void 0)return!0;return!1}function iP(i){let e=i._stream;return e!==void 0&&(e.broadcastPending.size>0||e.broadcastDeletes.size>0)}function sP(i,e,t){let n=V0(i),s=n.pendingByView.get(e);s===void 0&&(s=new Set,n.pendingByView.set(e,s)),s.add(t)}function td(i,e){let t=i._stream;t!==void 0&&(t.pendingByView.delete(e),t.sentByView.delete(e),t.priorityByView?.delete(e))}function G0(i){if(i==null||typeof i!="object")throw new Error("t.quantized(): options object with { min, max } is required.");let{min:e,max:t}=i;if(typeof e!="number"||typeof t!="number"||!(t>e)||!Number.isFinite(e)||!Number.isFinite(t))throw new Error(`t.quantized(): require finite min < max (got min=${e}, max=${t}).`);let n=i.bits??16;if(n!==8&&n!==16&&n!==32)throw new Error(`t.quantized(): bits must be 8, 16 or 32 (got ${n}).`);let s=i.mode??"clamp";if(s!=="clamp"&&s!=="wrap")throw new Error(`t.quantized(): mode must be "clamp" or "wrap" (got ${JSON.stringify(s)}).`);let r=s==="wrap",a=Math.pow(2,n);return{min:e,max:t,bits:n,wrap:r,wire:rP[n],range:t-e,span:r?a:e===-t?a-2:a-1}}function Lr(i){return i!==null&&typeof i=="object"&&i.quantized!==void 0}function Xw(i,e){if(i.wrap){if(!Number.isFinite(e))return 0;let n=i.range,s=(e-i.min)%n;s<0&&(s+=n);let r=i.span;return Math.floor(s/n*r+.5)%r}if(e!==e)return 0;let t=e<i.min?i.min:e>i.max?i.max:e;return Math.floor((t-i.min)/i.range*i.span+.5)}function Kw(i,e){return i.min+e/i.span*i.range}function Yw(i){let e=Bn[i.wire];return(t,n,s)=>e(t,Xw(i,n),s)}function aP(i,e,t){let n=Mi[i.wire];return Kw(i,n(e,t))}function Jw(i){let e=typeof Object.keys(i)[0]=="string"&&qw(Object.keys(i)[0]);return{complexTypeKlass:e,childType:e?Object.values(i)[0]:i}}function Sa(i){if(Array.isArray(i))return{array:Sa(i[0])};if(Lr(i))return typeof i.quantized.wire=="string"?i:{quantized:G0(i.quantized)};if(typeof i.type<"u")return i.type;if(oP(i))return Object.keys(i).every(e=>typeof i[e]=="string")?"string":"number";if(typeof i=="object"&&i!==null){let e=Object.keys(i).find(t=>H0[t]!==void 0);if(e)return i[e]=Sa(i[e]),i}return i}function oP(i){if(typeof i=="function"&&i[Symbol.metadata])return!1;let e=Object.keys(i),t=e.filter(n=>/\d+/.test(n));return!!(t.length>0&&t.length===e.length/2&&i[i[t[0]]]==t[0]||e.length>0&&e.every(n=>typeof i[n]=="string"&&i[n]===n))}function kf(i,e,t){i[e]||Object.defineProperty(i,e,{value:[],enumerable:!1,configurable:!0,writable:!0}),i[e].push(t)}function Wf(i){return i=i-(i>>>1&1431655765),i=(i&858993459)+(i>>>2&858993459),(i+(i>>>4)&252645135)*16843009>>>24}function Uf(i){if(i===void 0)return 0;let e=0;for(let t=0,n=i.length;t<n;t++){let s=i[t];s<32&&(e|=1<<s)}return e}function lP(i){let e=[],t=[],n=[],s=[],r=i?.[Un];if(r===void 0)return{names:e,types:t,tags:n,encoders:s};let a=i[Bi];for(let o=0;o<=r;o++){let c=i[o];if(c===void 0){e[o]=void 0,t[o]=void 0,n[o]=void 0,s[o]=void 0;continue}e[o]=c.name,t[o]=c.type,n[o]=c.tag,s[o]=a?.[o]}return{names:e,types:t,tags:n,encoders:s}}function hP(i){let e=i.constructor;if(Object.prototype.hasOwnProperty.call(e,al))return e[al];let t=e[Symbol.metadata],n=It.isValidInstance(i),s=(t?.[ns]?.length??0)>0,r=lP(t),a=n&&!s?void 0:e[wa],o={encoder:e[Ts],filter:a,metadata:t,isSchema:n,filterBitmask:n?Uf(t?.[ns]):0,hasAnyFullStateOnly:(t?.[Ro]?.length??0)>0,hasAnyUnreliable:(t?.[_a]?.length??0)>0,hasAnyStream:(t?.[wi]?.length??0)>0,hasAnyView:s,fullStateOnlyBitmask:Uf(t?.[Ro]),unreliableBitmask:Uf(t?.[_a]),streamBitmask:Uf(t?.[wi]),names:r.names,types:r.types,tags:r.tags,encoders:r.encoders};return Object.defineProperty(e,al,{value:o,enumerable:!1,writable:!0,configurable:!0}),o}function uP(i,e,t){if(i.parentRef){if(i.parentRef[Z]===e[Z]){i._parentIndex=t;return}if(Qw(i,(n,s)=>n[Z]===e[Z])){i._parentIndex=t;return}}i.parentRef===void 0?(i.parentRef=e,i._parentIndex=t):(i.extraParents={ref:i.parentRef,index:i._parentIndex,next:i.extraParents},i.parentRef=e,i._parentIndex=t)}function fP(i,e,t){if(i.extraParents===void 0){i._parentIndex=t;return}if(i.parentRef[Z]===e[Z]){i._parentIndex=t;return}for(let n=i.extraParents;n!==void 0;n=n.next)if(n.ref[Z]===e[Z]){n.index=t;return}}function dP(i,e){if(i.parentRef&&i.parentRef[Z]===e[Z])return i.extraParents?(i.parentRef=i.extraParents.ref,i._parentIndex=i.extraParents.index,i.extraParents=i.extraParents.next):(i.parentRef=void 0,i._parentIndex=void 0),!0;let t=i.extraParents,n=null;for(;t;){if(t.ref[Z]===e[Z])return n?n.next=t.next:i.extraParents=t.next,!0;n=t,t=t.next}return i.parentRef===void 0}function pP(i,e){if(i.parentRef!==void 0&&e(i.parentRef,i._parentIndex))return{ref:i.parentRef,index:i._parentIndex};for(let t=i.extraParents;t!==void 0;t=t.next)if(e(t.ref,t.index))return{ref:t.ref,index:t.index}}function Qw(i,e){if(i.parentRef!==void 0&&e(i.parentRef,i._parentIndex))return!0;for(let t=i.extraParents;t!==void 0;t=t.next)if(e(t.ref,t.index))return!0;return!1}function mP(i,e){if(i.parentRef&&i.parentRef[Z]===e[Z])return i._parentIndex;for(let t=i.extraParents;t!==void 0;t=t.next)if(t.ref[Z]===e[Z])return t.index}function gP(i){let e=[];i.parentRef&&e.push({ref:i.parentRef,index:i._parentIndex});let t=i.extraParents;for(;t;)e.push({ref:t.ref,index:t.index}),t=t.next;return e}function bP(i,e,t){let n=e.refTarget;if(e.isArray){let r=n.items,a=r[t];if(a!==void 0&&a[Z]===i)return!0;for(let o=0,c=r.length;o<c;o++){let l=r[o];if(l!==void 0&&l[Z]===i)return!0}return!1}let s=e.getValue(t);return s!==void 0&&s[Z]===i}function xP(i,e){W0(i,e,_P)}function W0(i,e,t){let n=i.refTarget;if(n[pt]!==void 0){if(i.isPatchOnly)return;if(Array.isArray(n.items)){let s=n.items;for(let r=0,a=s.length;r<a;r++)s[r]!==void 0&&t(e,r)}else if(n.journal!==void 0)for(let[s,r]of n.journal.keyByIndex)n.$items.has(r)&&t(e,s);else if(n.$items!==void 0)for(let s of n.$items.keys())t(e,s)}else{let s=i.metadata;if(!s)return;let r=s[Un]??-1,a=s[Gf],o=i.encDescriptor.names;for(let c=0;c<=r;c++){let l=o[c];if(l===void 0||a&&a.includes(c))continue;let h=n[l];h!=null&&t(e,c)}}}function t1(i,e,t,n){yP(i,e,t),!i.isFullStateOnly&&(i.has()&&i.root?.enqueueChangeTree(i),i.unreliableRecorder?.has()&&i.root?.enqueueUnreliable(i),!i.has()&&!i.unreliableRecorder?.has()&&i.root?.enqueueChangeTree(i))}function yP(i,e,t){if(!e)return;let n=e[Z],s=!n._isSchema,r;s?(e=n.parent,t=n.parentIndex,r=e?.[Z].metadata):r=n.metadata;let a=(r?.[cl]?.includes(t)?ol:0)|(r?.[Ro]?.includes(t)?To:0),o=n.flags&LP|a,c=i.flags;if(i.flags=c|o,o&~c&To&&(i.reset(),i.unreliableRecorder?.reset()),!i.root?.types?.hasFilters)return;let u=r?.[ns]?.includes(t)??!1,d=r?.[wi]?.includes(t)??!1,p=n.isFiltered||u||d;if(i.isFiltered=p,d&&!s){i.isStreamCollection=!0;let b=V0(i.ref);if(b.priority===void 0){let v=It.getStreamPriority(r,t);v!==void 0&&(b.priority=v)}i.root?.registerStream(i.ref)}if(p){let b=n1(i);i.isVisibilitySharedWithParent=n.isFiltered&&b&&!d&&(!u||s&&r[t].tag!==rd)}}function _w(i){let e=i.pendingFilterRefresh;for(let t=0;t<e.length;t++){let n=e[t];(n.flags&ll)!==0&&$0(n)}e.length=0}function n1(i){return i._isSchema||typeof i.refTarget[pt]!="string"}function $0(i){i.flags&=~ll;let e=i.root;if(e===void 0||i.parentRef===void 0)return;let t=n1(i),n=xw(i,i.parentRef,i._parentIndex,t);for(let r=i.extraParents;r!==void 0&&n!==vP;r=r.next)n|=xw(i,r.ref,r.index,t);if(n===0)return;i.isVisibilitySharedWithParent=(n&qf)!==0;let s=(n&$f)===0;s!==i.isFiltered&&(i.isFiltered=s,!s&&!i.isFullStateOnly&&(i.forEachLiveWithCtx(i,e1),i.has()&&e.enqueueChangeTree(i),i.unreliableRecorder?.has()&&e.enqueueUnreliable(i)),i.forEachChildWithCtx(i,SP))}function xw(i,e,t,n){let s=e[Z];if(s.root!==i.root||!bP(i,s,t))return 0;s.flags&ll&&$0(s);let r=i1;if(s._isSchema)s.encDescriptor.tags[t]!==void 0||s.isFieldStream(t)||(s.isFiltered?n&&(r|=qf):r|=$f);else if(!s.isFiltered)r|=$f;else if(n&&!s.isStreamCollection){let a=s.parent?.[Z];(a?._isSchema?a.encDescriptor.tags[s.parentIndex]:void 0)!==rd&&(r|=qf)}return r}function wP(i,e,t,n){let s=i.subscribedViews;if(s===void 0)return;let r=i.isStreamCollection,a=r?i.ref:void 0,o=r?void 0:t[Z];for(let c=0,l=s.length;c<l;c++){let h=s[c];for(;h!==0;){let u=h&-h;h^=u;let d=c*32+(31-Math.clz32(u)),b=n.activeViews.get(d)?.deref();if(b===void 0){s[c]&=~u;continue}r?sP(a,d,e):o!==void 0&&b.markVisible(o)}}}function MP(i,e){i.root=e;let t=e.add(i);t1(i,i.parent,i.parentIndex),t&&gl(i,e,RP)}function EP(i,e,t,n){if(i.addParent(e,n),!t)return;let s=t.add(i);t!==i.root&&(i.root=t,t1(i,e,n));let r=e?.[Z];if(r!==void 0&&r.subscribedViews!==void 0&&e[pt]!==void 0&&wP(r,n,i.ref,t),s){let a=yw[Bf];a===void 0&&(a={parentRef:void 0,root:void 0},yw[Bf]=a),a.parentRef=i.ref,a.root=t,Bf++,gl(i,a,CP),Bf--}}function AP(i,e){gl(i,e,TP)}function TP(i,e,t){i(e,t)}function gl(i,e,t){let n=i.refTarget;if(n[pt]){if(typeof n[pt]!="string"){let s=n.items;if(s!==void 0)for(let r=0,a=s.length;r<a;r++){let o=s[r];o&&t(e,o[Z],r)}else{let r=n.$items,a=n._collectionIndexes;for(let o of r.keys()){let c=r.get(o);c&&t(e,c[Z],a?.[o]??o)}}}}else{let r=i.metadata?.[Ir];if(!r)return;let a=i.encDescriptor.names;for(let o=0,c=r.length;o<c;o++){let l=r[o],h=n[a[l]];h&&t(e,h[Z],l)}}}function RP(i,e,t){e.root!==i?e.setRoot(i):i.add(e)}function CP(i,e,t){if(e.root===i.root){i.root.add(e),i.root.moveNextToParent(e);return}e.setParent(i.parentRef,i.root,t)}function IP(i,e,t){let n=(t&3)<<3;return t<4?i>>>n&255:e>>>n&255}function vw(){return{next:void 0,tail:void 0,nextPosition:0}}function DP(i){return new F0(i)}function Po(i,e=i){Object.defineProperty(i,Z,{value:DP(e),enumerable:!1,writable:!0})}function nd(i,e,t,n,s,r,a){a!==void 0?a(e,n,r):typeof t=="string"?Bn[t]?.(e,n,r):t[Symbol.metadata]!=null?(Bn.number(e,n[rt],r),(s&_e.ADD)===_e.ADD&&i.tryEncodeTypeId(e,t,n.constructor,r)):Bn.number(e,n[rt],r)}function s1(i,e,t,n,s,r,a){let o=i.resyncVisited,c=o.get(i.currentRefId);if(c===void 0&&o.set(i.currentRefId,c=new Set),c.add(n),s!==void 0&&t===_e.ADD&&s!==r){let l=s[rt];l!==void 0&&(i.root.removeRef(l),a?.push({ref:e,refId:i.currentRefId,op:_e.DELETE,dynamicIndex:n,value:void 0,previousValue:s}))}}function kP(i,e){let t=i.resyncVisited;t.has(e)||t.set(e,new Set)}function UP(i,e){if(i.resyncDamaged){console.warn("@colyseus/schema: resync sweep skipped \u2014 parts of the payload could not be decoded. Stale entries may persist until the next resync.");return}X0(i,i.state,new Set,e)}function X0(i,e,t,n){let s=e[rt];if(s===void 0||t.has(s))return;t.add(s);let r=e.constructor[Symbol.metadata],a=r?.[Ir];if(a===void 0)return;let o=r[cl];for(let c=0;c<a.length;c++){let l=a[c];if(o!==void 0&&o.includes(l))continue;let h=r[l],u=e[h.name];u&&(en.is(h.type)?X0(i,u,t,n):BP(i,u,t,n))}}function BP(i,e,t,n){let s=e[wn]??e,r=s[rt];if(r===void 0||t.has(r))return;t.add(r);let a=i.resyncVisited.get(r);if(a===void 0)return;let o=i.root;s[Io](a,(c,l)=>{n?.push({ref:e,refId:r,op:_e.DELETE,dynamicIndex:l,value:void 0,previousValue:c});let h=c?.[rt];h!==void 0&&o.removeRef(h)},c=>{en.isSchema(c)&&X0(i,c,t,n)})}function K0(i,e,t,n,s,r,a,o,c){let l=i.root,h;if((e&_e.DELETE)===_e.DELETE){let u=s?.[rt];u!==void 0&&l.removeRef(u),e!==_e.DELETE_AND_ADD&&t[os](n),h=void 0}if(e!==_e.DELETE)if(typeof r=="string")h=Mi[r](a,o);else if(Lr(r))h=aP(r.quantized,a,o);else if(en.is(r)){let u=Mi.number(a,o);if(h=l.refs.get(u),(e&_e.ADD)===_e.ADD){let d=i.getInstanceType(a,o,r);h||(h=i.createInstanceOfType(d)),l.addRef(u,h,h!==s||e===_e.DELETE_AND_ADD&&h===s)}}else{let u=qw(Object.keys(r)[0]),d=Mi.number(a,o);i.resyncVisited!==null&&kP(i,d);let p=l.refs.has(d)?s||l.refs.get(d):u.constructor.initializeForDecoder();if(h=p.clone(!0),h[pt]=Object.values(r)[0],s){let b=s[rt];if(b!==void 0&&d!==b){(e&_e.DELETE)!==_e.DELETE&&l.removeRef(b);let v=s.entries(),_;for(;(_=v.next())&&!_.done;){let[g,E]=_.value;typeof E=="object"&&(b=E[rt]),c?.push({ref:s,refId:b,op:_e.DELETE,field:g,value:void 0,previousValue:E})}}}l.addRef(d,h,p!==s||e===_e.DELETE_AND_ADD&&p===s)}return h}function sd(i,e,t,n){if(!(i instanceof e))throw new hl(`a '${e.name}' was expected, but '${i&&i.constructor.name}' was provided in ${t.constructor.name}#${n}`)}function a1(i){return i!=null&&i[Cw]===!0}function ti(i){return(()=>new Rs(i))}function bl(i){if(a1(i)){let e=i._type,t=typeof e=="string"?`use the type name instead: t.array("${e}")`:'collections accept a Schema class or a primitive type name ("string", "number", \u2026)';throw new Error(`t.array/map/set/collection(): a t.* builder is not a valid element type \u2014 ${t}.`)}return i}function ww(i){return new Rs({quantized:G0(i)})}function KP(i=rd){return function(e,t){let n=It.initialize(e.constructor);It.setTag(n,t,i)}}function YP(i,e){let t=It.initialize(i.constructor);It.setUnreliable(t,e)}function JP(i,e){let t=It.initialize(i.constructor);It.setPatchOnly(t,e)}function ZP(i,e){return function(t,n){let s=t.constructor;if(!i)throw new Error(`${s.name}: @type() reference provided for "${n}" is undefined. Make sure you don't have any circular dependencies.`);i=Sa(i),Dr.register(s);let a=Object.getPrototypeOf(s)[Symbol.metadata],o=It.initialize(s),c=o[n];if(o[c]!==void 0){if(o[c].deprecated)return;if(o[c].type!==void 0)try{throw new Error(`@colyseus/schema: Duplicate '${n}' definition on '${s.name}'.
+Check @type() annotation`)}catch(l){let h=l.stack.split(`
+`)[4].trim();throw new Error(`${l.message} ${h}`)}}else c=o[Un]??(a&&a[Un])??-1,c++;if(e&&e.manual)It.addField(o,c,n,i,{enumerable:!0,configurable:!0,writable:!0});else{let{complexTypeKlass:l,childType:h}=Jw(i);It.addField(o,c,n,i,o1(n,c,h,l))}o[Si][n]&&Object.defineProperty(t,n,o[Si][n]),(typeof i=="string"||Lr(i))&&(o[Bi]||Object.defineProperty(o,Bi,{value:[],enumerable:!1,configurable:!0,writable:!0}),o[Bi][c]=typeof i=="string"?Bn[i]:Yw(i.quantized))}}function eL(i,e,t){let n=QP[t],s=t==="string",r=t==="boolean";return function(a){let o=this[Es],c=o[e];if(a!==c){if(a!=null){if(!r&&n!==void 0&&typeof a!==n&&!(s&&a===null)){let l=a&&a.constructor?` (${a.constructor.name})`:"";throw new hl(`a '${n}' was expected, but '${JSON.stringify(a)}'${l} was provided in ${this.constructor.name}#${i}`)}this.constructor[As](this[Z],e,_e.ADD)}else c!=null&&this[Z].delete(e);o[e]=a}}}function tL(i,e,t){return function(n){let s=this[Es],r=s[e];if(n!==r){if(n!=null){sd(n,t,this,i);let a=this[Z],o=this.constructor;r!=null&&r[Z]?(a.root?.remove(r[Z]),o[As](a,e,_e.DELETE_AND_ADD)):o[As](a,e,_e.ADD),n[Z]?.setParent(this,a.root,e)}else r!=null&&this[Z].delete(e);s[e]=n}}}function nL(i,e,t,n){let s=n.constructor===Pr,r=n.constructor===as;return function(a){let o=this[Es],c=o[e];if(a!==c){if(a!=null){if(s&&!(a instanceof Pr)){let u=new Pr;u[pt]=t,u.push(...a),a=u}else if(r&&!(a instanceof as)){let u=new as;if(u[pt]=t,a instanceof Map)a.forEach((d,p)=>u.set(p,d));else for(let d in a)u.set(d,a[d]);a=u}else a[pt]=t;let l=this[Z],h=this.constructor;c!=null&&c[Z]?(l.root?.remove(c[Z]),h[As](l,e,_e.DELETE_AND_ADD)):h[As](l,e,_e.ADD),a[Z]?.setParent(this,l.root,e)}else c!=null&&this[Z].delete(e);o[e]=a}}}function iL(i,e,t){return function(n){let s=this[Es],r=s[e];if(n!=null){if(typeof n!="number")throw new hl(`a 'number' was expected, but '${JSON.stringify(n)}' was provided in ${this.constructor.name}#${i}`);if(n=Kw(t,Xw(t,n)),n===r)return;this.constructor[As](this[Z],e,_e.ADD)}else{if(n===r)return;r!=null&&this[Z].delete(e)}s[e]=n}}function o1(i,e,t,n){let s;return n?s=nL(i,e,t,n):typeof t=="string"?s=eL(i,e,t):Lr(t)?s=iL(i,e,t.quantized):s=tL(i,e,t),{get:function(){return this[Es][e]},set:s,enumerable:!0,configurable:!0}}function sL(i=!0){return function(e,t){let n=It.initialize(e.constructor);It.setDeprecated(n,t),i&&(n[Si]??={},n[Si][t]={get:function(){throw new Error(`${t} is deprecated.`)},set:function(s){},enumerable:!1,configurable:!0},Object.defineProperty(e,t,n[Si][t]))}}function ad(i,e,t){Mw||(Mw=!0,console.warn("@colyseus/schema: defineTypes() is deprecated and will be removed in a future release. Use schema() with t.* field builders instead \u2192 https://docs.colyseus.io/state/schema"));for(let n in e)ZP(e[n],t)(i.prototype,n);return i}function rL(i){if(i&&typeof i=="object"){if(i.array!==void 0)return()=>new Pr;if(i.map!==void 0)return()=>new as;if(i.set!==void 0)return()=>new fl;if(i.collection!==void 0)return()=>new ul;if(i.stream!==void 0)return()=>new Xf}else if(typeof i=="function"&&en.is(i)&&(!i.prototype.initialize||i.prototype.initialize.length===0))return()=>new i}function _l(i,e,t=en){if(i==null||typeof i!="object")throw new Error(`schema(): first argument must be a fields object (got ${typeof i}).`);let n={},s={},r={},a={},o=(I,y)=>{typeof y=="function"?a[I]=y:y&&typeof y.clone=="function"?a[I]=()=>y.clone():r[I]=y},c=(I,y)=>{if(y.hasDefault)o(I,y.default);else if(!y.optional){let C=rL(y.type);C&&(a[I]=C)}},l={},h=[],u=[],d={},p=[],b=[],v={},_=[];for(let I in i){let y=i[I];if(a1(y)){let C=y.toDefinition();if(C.noSync){if(C.view!==void 0||C.unreliable||C.patchOnly||C.fullStateOnly||C.stream)throw new Error(`schema(${e?`'${e}'`:""}): field '${I}' uses .noSync() together with a sync-only modifier (.view/.unreliable/.patchOnly/.fullStateOnly/.stream). A local-only field cannot be synchronized.`);c(I,C);continue}if(C.patchOnly&&C.fullStateOnly)throw new Error(`schema(${e?`'${e}'`:""}): field '${I}' uses .patchOnly() together with .fullStateOnly(). Those are the only two delivery channels, so the field would never reach a client \u2014 use .noSync() if that is intended.`);let k=Sa(C.type);if(typeof k=="function"&&!en.is(k))throw new Error(`schema(${e?`'${e}'`:""}): field '${I}' is a synced ref to non-Schema class '${k.name||"(anonymous)"}' \u2014 use .noSync(), or Metadata.setFields().`);n[I]=k,C.view!==void 0&&(l[I]=C.view),C.unreliable&&h.push(I),C.patchOnly&&u.push(I),C.deprecated&&(d[I]=C.deprecatedThrows),C.fullStateOnly&&p.push(I),C.stream&&b.push(I),C.streamPriority!==void 0&&(v[I]=C.streamPriority),C.optional&&_.push(I),c(I,C)}else if(typeof y=="function")en.is(y)?(n[I]=Sa(y),(!y.prototype.initialize||y.prototype.initialize.length===0)&&(a[I]=()=>new y)):s[I]=y;else throw new Error(`schema(${e?`'${e}'`:""}): field '${I}' must be a t.* builder, Schema subclass, or method (got ${typeof y}).`)}let g=I=>{for(let y in r)I[y]=r[y];for(let y in a)I[y]=a[y]()},E=()=>{let I={};return g(I),I},L=I=>{let y=Object.keys(n),C={};for(let k in I)y.includes(k)||(C[k]=I[k]);return C},S=typeof s.initialize=="function",M=s.initialize??t._initialize,A=class extends t{constructor(...I){let y=I[0];y===void 0?(super(),g(this)):super(Object.assign(E(),S?L(y):y)),M&&new.target===A&&M.apply(this,I)}};e&&Object.defineProperty(A,"name",{value:e}),It.setFields(A,n),A._getDefaultValues=E,A._initialize=M,Object.assign(A.prototype,s);for(let I in l)KP(l[I])(A.prototype,I);for(let I of h)YP(A.prototype,I);for(let I of u)JP(A.prototype,I);for(let I in d)sL(d[I])(A.prototype,I);if(p.length>0||b.length>0){let I=A[Symbol.metadata];for(let y of p)It.setFullStateOnly(I,y);for(let y of b)It.setStream(I,y);for(let y in v)It.setStreamPriority(I,y,v[y])}if(_.length>0){let I=A[Symbol.metadata];for(let y of _)I[I[y]].optional=!0}return A.extend=(I,y)=>_l(I,y,A),A}function aL(i){return new Array(i).fill(0).map((e,t)=>t===i-1?"\u2514\u2500 ":" ").join("")}function oL(i,e){if(e===-1||e>=i.length)return!1;let t=i.length-1;for(let n=e;n<t;n++)i[n]=i[n+1];return i.length=t,!0}function cL(i,e,t){let n=~t,s=i.changeTrees;for(let r in s){let a=s[r],o=a.visibleViews;o!==void 0&&e<o.length&&(o[e]&=n);let c=a.subscribedViews;c!==void 0&&e<c.length&&(c[e]&=n);let l=a.tagViews;l!==void 0&&l.forEach(h=>{e<h.length&&(h[e]&=n)})}}function Aw(i){i.structSwitchEmitted||(i.shouldEmitSwitch&&(i.buffer[i.it.offset++]=255,Bn.number(i.buffer,i.ref[rt],i.it)),i.structSwitchEmitted=!0)}function hL(i,e){l1(i,e,_e.ADD)}function c1(i,e){if(e._fullSyncGen===i.gen)return;if(e._fullSyncGen=i.gen,!i.hasView||i.view.isChangeTreeVisible(e)){let n=e.encDescriptor;i.changeTree=e,i.ref=e.ref,i.encoder=n.encoder,i.filter=n.filter,i.metadata=n.metadata,i.treeIsFiltered=e.isFiltered,i.isSchema=n.isSchema,i.filterBitmask=n.filterBitmask,i.tags=n.tags,i.structSwitchEmitted=!1,i.shouldEmitSwitch=i.hasView||i.it.offset>i.initialOffset||e!==i.rootChangeTree,e.isArray&&e.collDirty.size>0&&(e.flags|=q0),W0(e,i,hL)}gl(e,i,uL)}function uL(i,e,t){c1(i,e)}function l1(i,e,t){if(e<0){if(i.treeIsFiltered!==i.emitFiltered)return;Aw(i),i.buffer[i.it.offset++]=Math.abs(e)&255;return}if((i.isSchema?i.treeIsFiltered||(e<32?(i.filterBitmask&1<<e)!==0:i.tags[e]!==void 0):i.treeIsFiltered)!==i.emitFiltered)return;let s=i.isEncodeAll?_e.ADD:t;s!==void 0&&(i.filter!==void 0&&!i.filter(i.ref,e,i.view)||(Aw(i),i.encoder(i.self,i.buffer,i.changeTree,e,s,i.it,i.isEncodeAll,i.hasView,i.metadata)))}function P0(i,e){let t=new Uint8Array(i.length+e.length);return t.set(i,0),t.set(e,i.length),t}var _e,gw,rt,As,Ts,ss,wa,bn,os,Io,Z,pt,wn,Cr,rs,Vf,Es,Cw,Si,al,Bi,Un,Ir,ns,Ks,_a,cl,Gf,Ro,wi,Ff,F3,Jf,xa,L0,k3,Iw,U3,Pw,Bn,pl,va,W3,$3,q3,j3,Mi,H0,eP,jw,rP,Dr,bw,cP,It,Zw,N0,O0,e1,_P,i1,$f,qf,vP,SP,yw,Bf,PP,R0,C0,rl,I0,ol,To,Hf,zf,ll,q0,LP,Nr,F0,NP,OP,j0,FP,r1,is,zP,id,HP,hl,VP,Sw,Pr,jf,as,ul,fl,Xf,Rs,GP,WP,$P,qP,jP,XP,hi,rd,QP,Mw,en,Ew,k0,zk,lL,U0,Kf,Tw,B0,Yf,h1,u1,f1,dl,d1=un(()=>{(function(i){i[i.ADD=128]="ADD",i[i.REPLACE=0]="REPLACE",i[i.DELETE=64]="DELETE",i[i.DELETE_AND_MOVE=96]="DELETE_AND_MOVE",i[i.MOVE_AND_ADD=160]="MOVE_AND_ADD",i[i.DELETE_AND_ADD=192]="DELETE_AND_ADD",i[i.CLEAR=10]="CLEAR",i[i.REVERSE=15]="REVERSE",i[i.MOVE=32]="MOVE",i[i.DELETE_BY_REFID=33]="DELETE_BY_REFID",i[i.ADD_BY_REFID=129]="ADD_BY_REFID"})(_e||(_e={}));Symbol.metadata??=Symbol.for("Symbol.metadata");gw=(function(){return typeof globalThis<"u"?globalThis:typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{}})();if(typeof Symbol=="function"&&typeof Symbol.for!="function"){let i="colyseus.symbolRegistry",e=gw[i]||(gw[i]=Object.create(null));Symbol.for=function(t){return e[t]||(e[t]=Symbol(t))},Symbol.keyFor=function(t){for(let n in e)if(e[n]===t)return n}}rt=Symbol.for("$refId"),As="~track",Ts="~encoder",ss="~decoder",wa="~filter",bn="~getByIndex",os="~deleteByIndex",Io="~resyncPrune",Z=Symbol.for("$changes"),pt=Symbol.for("$childType"),wn=Symbol.for("$proxyTarget"),Cr="~onEncodeEnd",rs="~reset",Vf="~onDecodeEnd",Es=Symbol.for("$values"),Cw="~builder",Si="~descriptors",al="~__encodeDescriptor",Bi="~encoders",Un="~__numFields",Ir="~__refTypeFieldIndexes",ns="~__viewFieldIndexes",Ks="$__fieldIndexesByViewTag",_a="~__unreliableFieldIndexes",cl="~__patchOnlyFieldIndexes",Gf="~__fullSyncSkipIndexes",Ro="~__fullStateOnlyFieldIndexes",wi="~__streamFieldIndexes",Ff="~__streamPriorities";try{F3=new TextEncoder}catch{}Jf=new ArrayBuffer(8),xa=new Int32Array(Jf),L0=new Float32Array(Jf),k3=new Float64Array(Jf),Iw=new BigInt64Array(Jf),U3=typeof Buffer<"u"&&Buffer.byteLength,Pw=U3?Buffer.byteLength:function(i,e){for(var t=0,n=0,s=0,r=i.length;s<r;s++)t=i.charCodeAt(s),t<128?n+=1:t<2048?n+=2:t<55296||t>=57344?n+=3:(s++,n+=4);return n};Bn={int8:Dw,uint8:B3,int16:Nw,uint16:z0,int32:Ys,uint32:ya,int64:Ow,uint64:Fw,bigint64:z3,biguint64:H3,float32:kw,float64:Uw,boolean:V3,string:G3,number:D0,utf8Write:Lw,utf8Length:Pw},pl=new ArrayBuffer(8),va=new Int32Array(pl),W3=new Float32Array(pl),$3=new Float64Array(pl),q3=new BigUint64Array(pl),j3=new BigInt64Array(pl);Mi={utf8Read:Bw,int8:zw,uint8:ml,int16:Hw,uint16:Zf,int32:cs,uint32:Co,float32:Vw,float64:Gw,int64:Ww,uint64:$w,bigint64:X3,biguint64:K3,boolean:Y3,string:J3,number:Z3,stringCheck:Q3},H0={},eP=new Map;jw="ArraySchema does not support streaming \u2014 positional ops (splice / unshift / reverse) shift subsequent indexes, so holding ADDs back for a later tick under `maxPerTick` would desync the decoder. Use `t.stream(X)` (stable monotonic positions) or `t.map(X).stream()` (stable keys) instead.";rP={8:"uint8",16:"uint16",32:"uint32"};Dr=class i{types={};schemas=new Map;hasFilters=!1;static inheritedTypes=new WeakMap;static cachedContexts=new WeakMap;static register(e){let t=Object.getPrototypeOf(e);if(t!==en){let n=i.inheritedTypes.get(t);n||(n=new Set,i.inheritedTypes.set(t,n)),n.add(e)}}static cache(e){let t=i.cachedContexts.get(e);return t||(t=new i(e),i.cachedContexts.set(e,t)),t}constructor(e){e&&this.discoverTypes(e)}has(e){return this.schemas.has(e)}get(e){return this.types[e]}add(e,t=this.schemas.size){return this.schemas.has(e)?!1:(this.types[t]=e,e[Symbol.metadata]==null&&It.initialize(e),this.schemas.set(e,t),!0)}getTypeId(e){return this.schemas.get(e)}discoverTypes(e){if(!this.add(e))return;i.inheritedTypes.get(e)?.forEach(s=>{this.discoverTypes(s)});let t=e;for(;(t=Object.getPrototypeOf(t))&&t!==en&&t!==Function.prototype;)this.discoverTypes(t);let n=e[Symbol.metadata];(n[ns]||n[wi])&&(this.hasFilters=!0);for(let s in n){let a=n[s].type;if(typeof a!="string"&&!Lr(a))if(typeof a=="function")this.discoverTypes(a);else{let o=Object.values(a)[0];if(typeof o=="string")continue;this.discoverTypes(o)}}}debug(){return`TypeContext ->
+ Schema types: ${this.schemas.size}
+ hasFilters: ${this.hasFilters}`}},bw=63;cP=[Ir,_a,cl,Gf,Ro,wi,Bi];It={addField(i,e,t,n,s){if(e>=bw)throw new Error(`Can't define field '${t}'.
+Schema instances may only have up to ${bw} fields.`);i[e]=Object.assign(i[e]||{},{type:Sa(n),index:e,name:t}),Object.defineProperty(i,Si,{value:i[Si]||{},enumerable:!1,configurable:!0}),s?i[Si][t]=s:i[Si][t]={value:void 0,writable:!0,enumerable:!0,configurable:!0},Object.defineProperty(i,Un,{value:e,enumerable:!1,configurable:!0}),Object.defineProperty(i,t,{value:e,enumerable:!1,configurable:!0}),typeof i[e].type!="string"&&!Lr(i[e].type)&&(i[Ir]===void 0&&Object.defineProperty(i,Ir,{value:[],enumerable:!1,configurable:!0}),i[Ir].push(e));let r=i[e].type;if(r&&typeof r=="object"&&r.stream!==void 0){if(r.array!==void 0)throw new Error(jw);i[e].stream=!0,i[wi]||Object.defineProperty(i,wi,{value:[],enumerable:!1,configurable:!0,writable:!0}),i[wi].includes(e)||i[wi].push(e);let a=n?.priority;typeof a=="function"&&It.setStreamPriority(i,t,a)}},setTag(i,e,t){let n=i[e],s=i[n];if(s.tag=t,i[ns]||(Object.defineProperty(i,ns,{value:[],enumerable:!1,configurable:!0}),Object.defineProperty(i,Ks,{value:{},enumerable:!1,configurable:!0})),i[ns].push(n),t<0)i[Ks][t]||(i[Ks][t]=[]),i[Ks][t].push(n);else for(let r=t;r>0;r&=r-1){let a=r&-r;i[Ks][a]||(i[Ks][a]=[]),i[Ks][a].push(n)}},setUnreliable(i,e){let t=i[e];if(typeof i[t].type!="string")throw new Error(`@unreliable cannot be applied to ref-type field "${e}". For ref-type fields, mark each primitive sub-field with @unreliable instead. See README "Limitations and best practices".`);i[t].unreliable=!0,i[_a]||Object.defineProperty(i,_a,{value:[],enumerable:!1,configurable:!0,writable:!0}),i[_a].push(t)},setPatchOnly(i,e){let t=i[e];if(i[t].fullStateOnly)throw new Error(`field "${e}" cannot be both patchOnly and fullStateOnly \u2014 those are the only two delivery channels, so the field would never reach a client.`);i[t].patchOnly=!0,kf(i,cl,t),kf(i,Gf,t)},setDeprecated(i,e){let t=i[e];i[t].deprecated=!0,kf(i,Gf,t),Object.defineProperty(i,t,{value:i[t],enumerable:!1,configurable:!0})},setFullStateOnly(i,e){let t=i[e];if(i[t].patchOnly)throw new Error(`field "${e}" cannot be both patchOnly and fullStateOnly \u2014 those are the only two delivery channels, so the field would never reach a client.`);i[t].fullStateOnly=!0,kf(i,Ro,t)},setStream(i,e){let t=i[e];i[t].stream=!0,i[wi]||Object.defineProperty(i,wi,{value:[],enumerable:!1,configurable:!0,writable:!0}),i[wi].push(t)},setStreamPriority(i,e,t){let n=i[e];i[Ff]||Object.defineProperty(i,Ff,{value:{},enumerable:!1,configurable:!0,writable:!0}),i[Ff][n]=t},getStreamPriority(i,e){return i?.[Ff]?.[e]},defineField(i,e,t,n,s){let r=Sa(s),{complexTypeKlass:a,childType:o}=Jw(r);It.addField(e,t,n,r,o1(n,t,o,a)),e[Si][n]&&Object.defineProperty(i.prototype,n,e[Si][n]),(typeof r=="string"||Lr(r))&&(e[Bi]||Object.defineProperty(e,Bi,{value:[],enumerable:!1,configurable:!0,writable:!0}),e[Bi][t]=typeof r=="string"?Bn[r]:Yw(r.quantized))},setFields(i,e){let t=i.prototype.constructor;Dr.register(t);let n=Object.getPrototypeOf(t),s=n&&n[Symbol.metadata],r=It.initialize(t);t[As]||(t[As]=en[As]),t[Ts]||(t[Ts]=en[Ts]),t[ss]||(t[ss]=en[ss]),t.prototype.toJSON||(t.prototype.toJSON=en.prototype.toJSON);let a=r[Un]??(s&&s[Un])??-1;a++,r[Bi]||Object.defineProperty(r,Bi,{value:s?.[Bi]?[...s[Bi]]:[],enumerable:!1,configurable:!0,writable:!0});for(let o in e){if(r[o]!==void 0)throw new Error(`@colyseus/schema: Duplicate '${o}' definition on '${t.name||"(anonymous)"}'.`);It.defineField(t,r,a,o,e[o]),a++}return i},isDeprecated(i,e){return i[e].deprecated===!0},initialize(i){let e=Object.getPrototypeOf(i),t=e[Symbol.metadata],n=i[Symbol.metadata]??Object.create(null);if(e!==en&&n===t&&(n=Object.create(null),t)){Object.setPrototypeOf(n,t),Object.defineProperty(n,Un,{value:t[Un],enumerable:!1,configurable:!0,writable:!0}),t[ns]!==void 0&&(Object.defineProperty(n,ns,{value:[...t[ns]],enumerable:!1,configurable:!0,writable:!0}),Object.defineProperty(n,Ks,{value:{...t[Ks]},enumerable:!1,configurable:!0,writable:!0}));for(let s of cP){let r=t[s];r!==void 0&&Object.defineProperty(n,s,{value:[...r],enumerable:!1,configurable:!0,writable:!0})}Object.defineProperty(n,Si,{value:{...t[Si]},enumerable:!1,configurable:!0,writable:!0})}return Object.defineProperty(i,Symbol.metadata,{value:n,writable:!1,configurable:!0}),n},isValidInstance(i){return i.constructor[Symbol.metadata]&&Object.prototype.hasOwnProperty.call(i.constructor[Symbol.metadata],Un)},getFields(i){let e=i[Symbol.metadata],t={};for(let n=0;n<=e[Un];n++)t[e[n].name]=e[n].type;return t},hasViewTagAtIndex(i,e){return i?.[ns]?.includes(e)},hasUnreliableAtIndex(i,e){return i?.[_a]?.includes(e)},hasPatchOnlyAtIndex(i,e){return i?.[cl]?.includes(e)},hasFullStateOnlyAtIndex(i,e){return i?.[Ro]?.includes(e)},hasStreamAtIndex(i,e){return i?.[wi]?.includes(e)}},Zw=(i,e,t)=>i(e,t),N0=class{dirtyLow=0;dirtyHigh=0;ops;constructor(e){this.ops=new Uint8Array(Math.max(e+1,1))}record(e,t){let n=this.ops[e];n===0?this.ops[e]=t:n===_e.DELETE?this.ops[e]=_e.DELETE_AND_ADD:n===_e.ADD&&t===_e.DELETE_AND_ADD&&(this.ops[e]=_e.DELETE_AND_ADD),e<32?this.dirtyLow|=1<<e:this.dirtyHigh|=1<<e-32}recordDelete(e,t){this.ops[e]=t,e<32?this.dirtyLow|=1<<e:this.dirtyHigh|=1<<e-32}recordRaw(e,t){this.record(e,t)}operationAt(e){let t=this.ops[e];return t===0?void 0:t}setOperationAt(e,t){this.ops[e]=t}forEach(e){this.forEachWithCtx(e,Zw)}forEachWithCtx(e,t){let n=this.dirtyLow,s=this.dirtyHigh,r=this.ops;for(;n!==0;){let a=n&-n,o=31-Math.clz32(a);n^=a,t(e,o,r[o])}for(;s!==0;){let a=s&-s,o=31-Math.clz32(a)+32;s^=a,t(e,o,r[o])}}size(){return Wf(this.dirtyLow)+Wf(this.dirtyHigh)}has(){return(this.dirtyLow|this.dirtyHigh)!==0}reset(){this.dirtyLow=0,this.dirtyHigh=0,this.ops.fill(0)}},O0=class{dirty=new Map;pureOps=[];record(e,t){let n=this.dirty.get(e);n===void 0?this.dirty.set(e,t):n===_e.DELETE?this.dirty.set(e,_e.DELETE_AND_ADD):n===_e.ADD&&t===_e.DELETE_AND_ADD&&this.dirty.set(e,_e.DELETE_AND_ADD)}recordDelete(e,t){this.dirty.set(e,t)}recordRaw(e,t){this.dirty.set(e,t)}recordPure(e){this.pureOps.push([this.dirty.size,e])}operationAt(e){return this.dirty.get(e)}setOperationAt(e,t){this.dirty.has(e)&&this.dirty.set(e,t)}forEach(e){this.forEachWithCtx(e,Zw)}forEachWithCtx(e,t){let n=this.pureOps;if(n.length>0){let s=0,r=0;for(let[a,o]of this.dirty){for(;s<n.length&&n[s][0]<=r;){let c=n[s++][1];t(e,-c,c)}t(e,a,o),r++}for(;s<n.length;){let a=n[s++][1];t(e,-a,a)}}else for(let[s,r]of this.dirty)t(e,s,r)}size(){return this.dirty.size+this.pureOps.length}has(){return this.dirty.size>0||this.pureOps.length>0}reset(){this.dirty.clear(),this.pureOps.length=0}shift(e){let t=new Map;for(let[n,s]of this.dirty)t.set(n+e,s);this.dirty=t}};e1=(i,e)=>{i.isFieldUnreliable(e)?i.ensureUnreliableRecorder().record(e,_e.ADD):i.record(e,_e.ADD)},_P=(i,e)=>i(e);i1=1,$f=2,qf=4,vP=i1|$f|qf;SP=(i,e,t)=>{$0(e)};yw=[],Bf=0;PP=(i,e,t)=>i(e,t);R0=1,C0=2,rl=4,I0=8,ol=16,To=32,Hf=64,zf=128,ll=256,q0=512,LP=ol|To,Nr=class{ref;refTarget;get isArray(){return this.refTarget!==this.ref}metadata;encDescriptor;root;parentRef;_parentIndex;extraParents;flags=rl;refCount=0;_fullSyncGen=0;_isSchema=!1;dirtyLow=0;dirtyHigh=0;opsLow=0;opsHigh=0;ops;collDirty;collPureOps;unreliableRecorder;paused=!1;changesNode;unreliableChangesNode;visibleViews;tagViews;subscribedViews;get isFiltered(){return(this.flags&R0)!==0}set isFiltered(e){this.flags=e?this.flags|R0:this.flags&~R0}get isVisibilitySharedWithParent(){return(this.flags&C0)!==0}set isVisibilitySharedWithParent(e){this.flags=e?this.flags|C0:this.flags&~C0}get isNew(){return(this.flags&rl)!==0}set isNew(e){this.flags=e?this.flags|rl:this.flags&~rl}get isUnreliable(){return(this.flags&I0)!==0}set isUnreliable(e){this.flags=e?this.flags|I0:this.flags&~I0}get isPatchOnly(){return(this.flags&ol)!==0}set isPatchOnly(e){this.flags=e?this.flags|ol:this.flags&~ol}get isFullStateOnly(){return(this.flags&To)!==0}set isFullStateOnly(e){this.flags=e?this.flags|To:this.flags&~To}get isStreamCollection(){return(this.flags&Hf)!==0}set isStreamCollection(e){this.flags=e?this.flags|Hf:this.flags&~Hf}get needsRestage(){return(this.flags&zf)!==0}set needsRestage(e){this.flags=e?this.flags|zf:this.flags&~zf}get hasFilteredFields(){return this.isFiltered||this.encDescriptor.hasAnyView}ensureUnreliableRecorder(){return this.unreliableRecorder===void 0&&(this.unreliableRecorder=this._isSchema?new N0(this.metadata?.[Un]??0):new O0),this.unreliableRecorder}isFieldUnreliable(e){let t=this.encDescriptor;return t.hasAnyUnreliable?e<32?(t.unreliableBitmask&1<<e)!==0:It.hasUnreliableAtIndex(this.metadata,e):!1}isFieldFullStateOnly(e){if(this.isFullStateOnly)return!0;let t=this.encDescriptor;return t.hasAnyFullStateOnly?e<32?(t.fullStateOnlyBitmask&1<<e)!==0:It.hasFullStateOnlyAtIndex(this.metadata,e):!1}isFieldStream(e){let t=this.encDescriptor;return t.hasAnyStream?e<32?(t.streamBitmask&1<<e)!==0:It.hasStreamAtIndex(this.metadata,e):!1}constructor(e,t=e){this.ref=e,this.refTarget=t;let n=hP(e);this.encDescriptor=n,this.metadata=n.metadata;let s=n.isSchema;if(this._isSchema=s,this.ops=void 0,this.collDirty=void 0,this.collPureOps=void 0,s){let r=this.metadata?.[Un]??0;r>7&&(this.ops=new Uint8Array(r+1))}else this.collDirty=new Map}_opAt(e){let t=this.ops;if(t!==void 0)return t[e];let n=(e&3)<<3;return e<4?this.opsLow>>>n&255:this.opsHigh>>>n&255}_opPut(e,t){let n=this.ops;if(n!==void 0){n[e]=t;return}let s=(e&3)<<3,r=~(255<<s);e<4?this.opsLow=this.opsLow&r|t<<s:this.opsHigh=this.opsHigh&r|t<<s}_markDirty(e){e<32?this.dirtyLow|=1<<e:this.dirtyHigh|=1<<e-32}record(e,t){if(this._isSchema){let n=this._opAt(e);n===0?this._opPut(e,t):n===_e.DELETE?this._opPut(e,_e.DELETE_AND_ADD):n===_e.ADD&&t===_e.DELETE_AND_ADD&&this._opPut(e,_e.DELETE_AND_ADD),this._markDirty(e)}else{let n=this.collDirty,s=n.get(e),r;s===void 0?r=t:s===_e.DELETE||s===_e.ADD&&t===_e.DELETE_AND_ADD?r=_e.DELETE_AND_ADD:r=s,n.set(e,r)}}recordDelete(e,t){this._isSchema?(this._opPut(e,t),this._markDirty(e)):this.collDirty.set(e,t)}recordRaw(e,t){this._isSchema?(this._opPut(e,t),this._markDirty(e)):this.collDirty.set(e,t)}recordPure(e){if(this._isSchema)throw new Error("ChangeTree (Schema): pure operations are not supported");(this.collPureOps??=[]).push([this.collDirty.size,e])}operationAt(e){if(this._isSchema){let t=this._opAt(e);return t===0?void 0:t}return this.collDirty.get(e)}setOperationAt(e,t){if(this._isSchema)this._opPut(e,t);else{let n=this.collDirty;n.has(e)&&n.set(e,t)}}forEach(e){this.forEachWithCtx(e,PP)}forEachWithCtx(e,t){if(this._isSchema){let r=this.dirtyLow,a=this.dirtyHigh,o=this.ops;if(o!==void 0){for(;r!==0;){let c=r&-r,l=31-Math.clz32(c);r^=c,t(e,l,o[l])}for(;a!==0;){let c=a&-a,l=31-Math.clz32(c)+32;a^=c,t(e,l,o[l])}}else{let c=this.opsLow,l=this.opsHigh;for(;r!==0;){let h=r&-r,u=31-Math.clz32(h);r^=h,t(e,u,IP(c,l,u))}}return}let n=this.collDirty,s=this.collPureOps;if(s!==void 0&&s.length>0){let r=0,a=0;for(let[o,c]of n){for(;r<s.length&&s[r][0]<=a;){let l=s[r++][1];t(e,-l,l)}t(e,o,c),a++}for(;r<s.length;){let o=s[r++][1];t(e,-o,o)}}else for(let[r,a]of n)t(e,r,a)}size(){return this._isSchema?Wf(this.dirtyLow)+Wf(this.dirtyHigh):this.collDirty.size+(this.collPureOps?.length??0)}has(){return this._isSchema?(this.dirtyLow|this.dirtyHigh)!==0:this.collDirty.size>0||this.collPureOps!==void 0&&this.collPureOps.length>0}reset(){if(this._isSchema){this.dirtyLow=0,this.dirtyHigh=0,this.ops!==void 0?this.ops.fill(0):(this.opsLow=0,this.opsHigh=0);return}this.collDirty.clear(),this.collPureOps!==void 0&&(this.collPureOps.length=0),this.flags&=~q0}recycle(){if(this.root!==void 0)throw new Error(`@colyseus/schema: cannot recycle an attached ChangeTree (${this.ref?.constructor?.name}). Remove the instance from its parent collection before releasing it to a pool.`);this.reset(),this.unreliableRecorder?.reset(),this.flags=rl|zf,this._fullSyncGen=0,this.parentRef=void 0,this._parentIndex=void 0,this.extraParents=void 0,this.changesNode=void 0,this.unreliableChangesNode=void 0,this.paused=!1,this.visibleViews=void 0,this.tagViews=void 0,this.subscribedViews=void 0}insertAt(e,t){if(this._isSchema)throw new Error("ChangeTree (Schema): insertAt is not supported");let n=this.collDirty,s=new Map,r=!this.paused&&!this.isFullStateOnly;if(e>0)for(let[a,o]of n)a<e&&s.set(a,o);if(r)for(let a=0;a<t;a++)s.set(e+a,_e.ADD);for(let[a,o]of n)a>=e&&s.set(a+t,o);this.collDirty=s,r&&this.root?.enqueueChangeTree(this)}removeAt(e,t){if(this._isSchema)throw new Error("ChangeTree (Schema): removeAt is not supported");let n=this.collDirty,s=e+t,r=!1;for(let o of n.keys())if(o>=s){r=!0;break}if(!r){for(let o=e;o<s;o++)n.delete(o);return}let a=new Map;for(let[o,c]of n)o<e?a.set(o,c):o>=s&&a.set(o-t,c);this.collDirty=a}unshift(e){this.insertAt(0,e)}setRoot(e){MP(this,e)}setParent(e,t,n){EP(this,e,t,n)}forEachChild(e){AP(this,e)}forEachChildWithCtx(e,t){gl(this,e,t)}forEachLive(e){xP(this,e)}forEachLiveWithCtx(e,t){W0(this,e,t)}operation(e){this.paused||this.isFullStateOnly||(this.recordPure(e),this.root?.enqueueChangeTree(this))}_routeAndRecord(e,t,n){if(!(this.paused||this.isFieldFullStateOnly(e))){if(this.isFieldUnreliable(e)&&!this.isNew){let s=this.ensureUnreliableRecorder();n?s.recordRaw(e,t):s.record(e,t),this.root?.enqueueUnreliable(this);return}n?this.recordRaw(e,t):this.record(e,t),this.root?.enqueueChangeTree(this)}}change(e,t=_e.ADD){this._routeAndRecord(e,t,!1)}indexedOperation(e,t){this._routeAndRecord(e,t,!0)}getChange(e){return this.operationAt(e)}pause(){this.paused=!0}resume(){this.paused=!1}untracked(e){let t=this.paused;this.paused=!0;try{return e()}finally{this.paused=t}}markDirty(e,t=_e.ADD){let n=this.paused;this.paused=!1;try{this.change(e,t)}finally{this.paused=n}}getValue(e,t=!1){return this.refTarget[bn](e,t)}delete(e,t){if(e===void 0){try{throw new Error(`@colyseus/schema ${this.ref.constructor.name}: trying to delete non-existing index '${e}'`)}catch(r){console.warn(r)}return}if(this.paused||this.isFieldFullStateOnly(e))return this.getValue(e);let n=this.isFieldUnreliable(e)&&!this.isNew;n?this.ensureUnreliableRecorder().recordDelete(e,t??_e.DELETE):this.recordDelete(e,t??_e.DELETE);let s=this.getValue(e);return s&&s[Z]&&this.root?.remove(s[Z]),n?this.root?.enqueueUnreliable(this):this.root?.enqueueChangeTree(this),s}endEncode(){this.reset(),this.changesNode=void 0,this._isSchema||this.refTarget[Cr]?.(),this.isNew=!1}endEncodeUnreliable(){this.unreliableRecorder?.reset(),this.unreliableChangesNode=void 0,this._isSchema||this.refTarget[Cr]?.()}discard(){this._isSchema||this.refTarget[Cr]?.(),this.reset(),this.unreliableRecorder?.reset()}discardAll(){let e=t=>{if(t<0)return;let n=this.getValue(t);n&&n[Z]&&n[Z].discardAll()};this.forEach(e),this.unreliableRecorder?.forEach(e),this.discard()}get changed(){return this.has()||(this.unreliableRecorder?.has()??!1)}get parent(){return this.parentRef}get parentIndex(){return this._parentIndex}addParent(e,t){uP(this,e,t)}setParentIndex(e,t){fP(this,e,t)}removeParent(e=this.parent){return dP(this,e)}findParent(e){return pP(this,e)}hasParent(e){return Qw(this,e)}indexInParent(e){return mP(this,e)}getAllParents(){return gP(this)}},F0=class{ref;root=void 0;parentRef=void 0;paused=!1;isNew=!1;flags=0;constructor(e){this.ref=e}change(){}delete(){}indexedOperation(){}operation(){}setParent(){}addParent(){}setParentIndex(){}removeParent(){return!1}getChange(){return 0}discard(){}discardAll(){}pause(){}resume(){}untracked(e){return e()}markDirty(){}forEachChild(e){let t=this.ref;if(t[pt]){if(typeof t[pt]!="string")for(let[a,o]of t.entries())o&&e(o[Z],t._collectionIndexes?.[a]??a);return}let s=t.constructor?.[Symbol.metadata];if(!s)return;let r=s[Ir]??[];for(let a=0;a<r.length;a++){let o=r[a],c=t[s[o].name];c&&e(c[Z],o)}}forEachChildWithCtx(e,t){this.forEachChild((n,s)=>t(e,n,s))}forEachLive(){}forEachLiveWithCtx(){}forEach(){}};NP=function(i,e,t,n,s,r,a,o){if(e[r.offset++]=(n|s)&255,s===_e.DELETE)return;let c=t.encDescriptor,l=t.ref,h=l[Es][n]??l[c.names[n]];nd(i,e,c.types[n],h,s,r,c.encoders[n])},OP=function(i,e,t,n,s,r){if(e[r.offset++]=s&255,Bn.number(e,n,r),s===_e.DELETE)return;let a=t.ref;if((s&_e.ADD)===_e.ADD){let o=a.$indexes.get(n);Bn.string(e,o,r)}nd(i,e,a[pt],a[bn](n),s,r)},j0=function(i,e,t,n,s,r){if(e[r.offset++]=s&255,Bn.number(e,n,r),s===_e.DELETE)return;let a=t.ref;nd(i,e,a[pt],a[bn](n),s,r)},FP=function(i,e,t,n,s,r,a,o){let c=t.refTarget,l=c[pt],h=typeof l!="string",u=o&&t.isFiltered&&h,d;if(u){let b=c.tmpItems[n];if(!b)return;if(d=b[rt],s===_e.DELETE)s=_e.DELETE_BY_REFID;else if((s&_e.ADD)===_e.ADD)s=_e.ADD_BY_REFID;else if((s&_e.MOVE)===_e.MOVE)return}else if(s===_e.DELETE&&h){let b=c.tmpItems[n];if(!b)return;d=b[rt],s=_e.DELETE_BY_REFID}else d=n;if(e[r.offset++]=s&255,Bn.number(e,d,r),s===_e.DELETE||s===_e.DELETE_BY_REFID)return;let p=c[bn](n,a);nd(i,e,l,p,s,r)};r1=-1,is={Map:1,Array:2,Set:3,Collection:4,Stream:5};zP=function(i,e,t,n,s){let r=e[t.offset++],a=n.constructor[Symbol.metadata],o=r>>6<<6,c=r%(o||255),l=a[c];if(l===void 0)return console.warn("@colyseus/schema: field not defined at",{index:c,ref:n.constructor.name,metadata:a}),r1;let h=l.deprecated===!0,u=h?void 0:n[bn](c),d=K0(i,o,n,c,u,l.type,e,t,s);h||(d!=null&&(n[l.name]=d),u!==d&&s?.push({ref:n,refId:i.currentRefId,op:o,field:l.name,value:d,previousValue:u}))},id=function(i,e,t,n,s){let r=n[wn]??n,a=e[t.offset++];if(a===_e.CLEAR){i.removeChildRefs(r,s),r.clear();return}let o=Mi.number(e,t),c=r[pt],l=r.constructor.COLLECTION_KIND,h;(a&_e.ADD)===_e.ADD?l===is.Map?(h=Mi.string(e,t),r.setIndex(o,h)):h=o:h=r.getIndex(o);let u=r[bn](o),d=K0(i,a,n,o,u,c,e,t,s);if(i.resyncVisited!==null&&s1(i,n,a,h,u,d,s),d!=null)switch(l){case is.Map:r.$items.set(h,d);break;case is.Array:r.$setAt(o,d,i.resyncVisited!==null&&a===_e.ADD?_e.REPLACE:a);break;case is.Set:case is.Collection:case is.Stream:r.$items.has(o)||(r.$items.set(o,d),typeof r.$refId=="number"&&o>=r.$refId&&(r.$refId=o+1));break;default:console.warn(`@colyseus/schema: missing COLLECTION_KIND on ${r.constructor?.name} \u2014 item at index ${o} was not stored.`);break}u!==d&&s?.push({ref:n,refId:i.currentRefId,op:a,dynamicIndex:h,value:d,previousValue:u})},HP=function(i,e,t,n,s){let r=n[wn]??n,a=e[t.offset++],o;if(a===_e.CLEAR){i.removeChildRefs(r,s),r.clear();return}else if(a===_e.REVERSE){r.items.reverse();return}else if(a===_e.DELETE_BY_REFID){let d=Mi.number(e,t),p=i.root.refs.get(d);if(p===void 0||(i.root.removeRef(d),o=r.findIndex(b=>b===p),o===-1))return;r[os](o),s?.push({ref:n,refId:i.currentRefId,op:_e.DELETE,dynamicIndex:o,value:void 0,previousValue:p});return}else if(a===_e.ADD_BY_REFID){let d=Mi.number(e,t),p=i.root.refs.get(d);p&&(o=r.findIndex(b=>b===p)),(o===-1||o===void 0)&&(o=r.length)}else o=Mi.number(e,t);let c=r[pt],l=o,h=r.items[o],u=K0(i,a,n,o,h,c,e,t,s);i.resyncVisited!==null&&s1(i,n,a,o,h,u,s),u!=null&&u!==h&&r.$setAt(o,u,i.resyncVisited!==null&&a===_e.ADD?_e.REPLACE:a),h!==u&&s?.push({ref:n,refId:i.currentRefId,op:a,dynamicIndex:l,value:u,previousValue:h})},hl=class extends Error{};VP=(i,e)=>{let t=i.toString(),n=e.toString();return t<n?-1:t>n?1:0},Sw={get:(i,e)=>typeof e!="symbol"&&!isNaN(e)?i.items[e]:Reflect.get(i,e),set:(i,e,t)=>{if(typeof e!="symbol"&&!isNaN(e)){if(t==null)i.$deleteAt(e);else{let n;if(t[Z]){sd(t,i[pt],i,e);let s=i.items[e];i.isMovingItems?(n=i.$wireIndex(Number(e)),s!==void 0?t[Z].isNew?i[Z].indexedOperation(n,_e.MOVE_AND_ADD):(i[Z].getChange(n)&_e.DELETE)===_e.DELETE?i[Z].indexedOperation(n,_e.DELETE_AND_MOVE):i[Z].indexedOperation(n,_e.MOVE):t[Z].isNew&&i[Z].indexedOperation(n,_e.ADD),t[Z].setParent(i,i[Z].root,n)):n=i.$changeAt(Number(e),t),s!==void 0&&s[Z].root?.remove(s[Z])}else n=i.$changeAt(Number(e),t);i.items[e]=t,n!==void 0&&(i.tmpItems[n]=t)}return!0}return Reflect.set(i,e,t)},deleteProperty:(i,e)=>(typeof e=="number"?i.$deleteAt(e):delete i[e],!0),has:(i,e)=>typeof e!="symbol"&&!isNaN(Number(e))?Reflect.has(i.items,e):Reflect.has(i,e)},Pr=class i{[Z];[rt];[wn];[pt];items=[];tmpItems=[];deletedIndexes=[];isMovingItems=!1;_needsCompaction=!1;static[Ts]=FP;static[ss]=HP;static COLLECTION_KIND=is.Array;static[wa](e,t,n){if(!n)return!0;let s=e[wn]??e;return typeof s[pt]=="string"||n.isChangeTreeVisible(s.tmpItems[t]?.[Z])}static is(e){return Array.isArray(e)||e.array!==void 0}static from(e){return new i(...Array.from(e))}constructor(...e){this[pt]=void 0,this[wn]=this;let t=new Proxy(this,Sw);return Object.defineProperty(this,Z,{value:new Nr(t,this),enumerable:!1,writable:!0}),e.length>0&&this.push(...e),t}static initializeForDecoder(){let e=Object.create(i.prototype);e.items=[],e.isMovingItems=!1,e._needsCompaction=!1,e[pt]=void 0,e[wn]=e;let t=new Proxy(e,Sw);return Po(e,t),t}set length(e){e===0?this.clear():e<this.items.length?this.splice(e,this.length-e):console.warn("ArraySchema: can't set .length to a higher value than its length.")}get length(){return this.items.length}pauseTracking(){this[Z].pause()}resumeTracking(){this[Z].resume()}untracked(e){return this[Z].untracked(e)}get isTrackingPaused(){return this[Z].paused}push(...e){let t=this[wn],n=t.items,s=t.tmpItems,r=t[Z],a=t[pt],o=s.length;for(let c=0,l=e.length;c<l;c++,o++){let h=e[c];if(h==null)return;typeof h=="object"&&a&&sd(h,a,t,c),r.indexedOperation(o,_e.ADD),n.push(h),s.push(h),h[Z]?.setParent(this,r.root,o)}return o}pop(){let e=this[wn],t=e.tmpItems,n=e.deletedIndexes,s=-1;for(let a=t.length-1;a>=0;a--)if(n[a]!==!0){s=a;break}if(s<0)return;let r=e.$isUnsentAdd(s);return e[Z].delete(s),r?e.$cancelAdd(s):n[s]=!0,e.items.pop()}at(e){return e<0&&(e+=this.length),this.items[e]}$wireIndex(e){let t=this.deletedIndexes;if(t.length===0)return e;let n=this.tmpItems,s=0;for(let r=0;r<n.length;r++)if(t[r]!==!0){if(s===e)return r;s++}return n.length+(e-s)}$isUnsentAdd(e){let t=this[Z];return(t.flags&(q0|Hf))===0&&!t.paused&&typeof this[pt]!="string"&&t.operationAt(e)===_e.ADD}$cancelAdd(e,t=!0){let n=this[Z],s=this.tmpItems[e];this.tmpItems.splice(e,1),this.deletedIndexes.length>0&&this.deletedIndexes.splice(e,1),n.removeAt(e,1);let r=s?.[Z];r!==void 0&&r.root===void 0&&r.removeParent(this),t&&this.$reindexChildren(e)}$reindexChildren(e,t){if(!this[Z].hasFilteredFields||typeof this[pt]=="string")return;let n=this.tmpItems,s=n.length;if(t!==void 0)for(;e<s&&n[e]===t[e];)e++;for(let r=e;r<s;r++)n[r]?.[Z]?.setParentIndex(this,r)}$changeAt(e,t){if(t==null){console.error("ArraySchema items cannot be null nor undefined; Use `splice(index, 1)` instead.");return}if(this.items[e]===t)return;let n=this.items[e]!==void 0?typeof t=="object"?_e.DELETE_AND_ADD:_e.REPLACE:_e.ADD,s=this.$wireIndex(e),r=this[Z];return r.change(s,n),t[Z]?.setParent(this,r.root,s),s}$deleteAt(e,t){this[Z].delete(this.$wireIndex(e),t)}$setAt(e,t,n){n===_e.ADD&&this.items[e]!==void 0?this.items.splice(e,0,t):n===_e.DELETE_AND_MOVE?(this.items.splice(e,1),this.items[e]=t):(e>this.items.length&&(this._needsCompaction=!0),this.items[e]=t)}clear(){let e=this[wn];if(e.items.length===0)return;let t=e[Z];t.forEachChild((n,s)=>{t.root?.remove(n)}),t.discard(),t.operation(_e.CLEAR),e.items.length=0,e.tmpItems.length=0}[rs](){let e=this[wn]??this,t=e[Z];if(t.isStreamCollection)throw new Error("@colyseus/schema: cannot reset a streamed ArraySchema (pooling not supported).");let n=e.items;for(let s=0;s<n.length;s++)n[s]?.[rs]?.();e.items.length=0,e.tmpItems.length=0,e.deletedIndexes.length=0,t.recycle(),e[rt]=void 0}concat(...e){return new i(...this.items.concat(...e))}join(e){return this.items.join(e)}reverse(){let e=this[wn],t=e[Z];if(t.has()||e.deletedIndexes.length>0){let n=e.items.slice().reverse();return this.clear(),this.push(...n),this}return t.operation(_e.REVERSE),e.items.reverse(),e.tmpItems.reverse(),e.$reindexChildren(0),this}shift(){let e=this[wn],t=e.items;if(t.length===0)return;let n=e[Z],s=e.deletedIndexes,r=0;for(;s[r]===!0;)r++;let a=e.$isUnsentAdd(r);return n.delete(r,_e.DELETE),a?e.$cancelAdd(r):s[r]=!0,t.shift()}slice(e,t){let n=new i;return n.push(...this.items.slice(e,t)),n}sort(e=VP){let t=this[wn];t.isMovingItems=!0;let n=t[Z];return t.items.sort(e).forEach((r,a)=>n.change(a,_e.REPLACE)),t.tmpItems.sort(e),t.$reindexChildren(0),t.isMovingItems=!1,this}splice(e,t,...n){let s=this[wn],r=s[Z],a=s.items,o=s.tmpItems,c=s.deletedIndexes,l=a.length,h=o.length,u=n.length,d=[];for(let b=0;b<h;b++)c[b]!==!0&&d.push(b);let p;if(l>e){t===void 0&&(t=l-e);for(let b=e;b<e+t;b++){let v=d[b],_=s.$isUnsentAdd(v);r.delete(v,_e.DELETE),_?(p??=[]).push(v):c[v]=!0}}else t=0;if(u>0){let b=d[e]??l,v=Math.min(u,t);for(let g=0;g<v;g++){let E=b+g,L,S=p!==void 0?p.indexOf(E):-1;S!==-1?(p.splice(S,1),L=_e.ADD):L=c[E]?_e.DELETE_AND_ADD:_e.ADD,r.indexedOperation(E,L),o[E]=n[g],c[E]=!1,n[g][Z]?.setParent(this,r.root,E)}let _=u-v;if(_>0){let g=b+v;r.insertAt(g,_);for(let E=0;E<_;E++)n[v+E][Z]?.setParent(this,r.root,g+E);c.length>0&&c.splice(g,0,...new Array(_).fill(!1)),o.splice(g,0,...n.slice(v)),s.$reindexChildren(g+_)}}if(p!==void 0&&p.length>0){for(let b=p.length-1;b>=0;b--)s.$cancelAdd(p[b],!1);s.$reindexChildren(p[0])}return r.root?.enqueueChangeTree(r),a.splice(e,t,...n)}unshift(...e){let t=this[wn],n=t[Z];n.unshift(e.length);for(let r=0;r<e.length;r++)e[r]?.[Z]?.setParent(this,n.root,r);let s=t.deletedIndexes;return s.length>0&&s.unshift(...new Array(e.length).fill(!1)),t.tmpItems.unshift(...e),t.$reindexChildren(e.length),t.items.unshift(...e)}indexOf(e,t){return this.items.indexOf(e,t)}lastIndexOf(e,t=this.length-1){return this.items.lastIndexOf(e,t)}every(e,t){return this.items.every(e,t)}some(e,t){return this.items.some(e,t)}forEach(e,t){return this.items.forEach(e,t)}map(e,t){return this.items.map(e,t)}filter(e,t){return this.items.filter(e,t)}reduce(e,t){return this.items.reduce.apply(this.items,arguments)}reduceRight(e,t){return this.items.reduceRight.apply(this.items,arguments)}find(e,t){return this.items.find(e,t)}findIndex(e,t){return this.items.findIndex(e,t)}fill(e,t,n){throw new Error("ArraySchema#fill() not implemented")}copyWithin(e,t,n){throw new Error("ArraySchema#copyWithin() not implemented")}toString(){return this.items.toString()}toLocaleString(){return this.items.toLocaleString()}[Symbol.iterator](){return this.items[Symbol.iterator]()}static get[Symbol.species](){return i}[Symbol.unscopables];entries(){return this.items.entries()}keys(){return this.items.keys()}values(){return this.items.values()}includes(e,t){return this.items.includes(e,t)}flatMap(e,t){throw new Error("ArraySchema#flatMap() is not supported.")}flat(e){throw new Error("ArraySchema#flat() is not supported.")}findLast(){return this.items.findLast.apply(this.items,arguments)}findLastIndex(...e){return this.items.findLastIndex.apply(this.items,arguments)}with(e,t){let n=this.items.slice();return e<0&&(e+=this.length),n[e]=t,new i(...n)}toReversed(){return this.items.slice().reverse()}toSorted(e){return this.items.slice().sort(e)}toSpliced(e,t,...n){let s=this.items.slice();return s.splice.apply(s,arguments),s}shuffle(){return this.move(e=>{let t=this.items.length;for(;t!=0;){let n=Math.floor(Math.random()*t);t--,[this[t],this[n]]=[this[n],this[t]]}})}move(e){return this.isMovingItems=!0,e(this),this.isMovingItems=!1,this}[bn](e,t=!1){let n=this[wn]??this;return t||n.deletedIndexes[e]?n.items[e]:n.tmpItems[e]||n.items[e]}[os](e){let t=this[wn]??this;t.items[e]=void 0,t._needsCompaction=!0}[Cr](){let e=this.tmpItems;this.tmpItems=this.items.slice(),this.deletedIndexes.length>0&&(this.$reindexChildren(0,e),this.deletedIndexes.length=0)}[Vf](){let e=this[wn]??this;e._needsCompaction&&(e._needsCompaction=!1,e.items=e.items.filter(t=>t!==void 0))}[Io](e,t,n){let s=this[wn]??this,r=s.items,a=!1;for(let o=0;o<r.length;o++){let c=r[o];if(e.has(o)){n(c);continue}a=!0,t(c,o),s[os](o)}a&&s[Vf]()}toArray(){return this.items.slice(0)}toJSON(){return this.toArray().map(e=>typeof e.toJSON=="function"?e.toJSON():e)}clone(e){let t;return e?(t=new i,t.push(...this.items)):t=new i(...this.map(n=>n[Z]?n.clone():n)),t}};Zs("array",{constructor:Pr});jf=class{keyByIndex=new Map;indexByKey=Object.create(null);nextIndex=0;snapshots;indexOf(e){let t=this.indexByKey[e];return t===void 0?void 0:t}assign(e){let t=this.nextIndex++;return this.indexByKey[e]=t,this.keyByIndex.set(t,e),t}snapshot(e,t){(this.snapshots??=new Map).set(e,t)}forgetSnapshot(e){this.snapshots?.delete(e)}snapshotAt(e){return this.snapshots?.get(e)}setIndex(e,t){this.keyByIndex.set(e,t),this.indexByKey[t]=e}keyOf(e){return this.keyByIndex.get(e)}cleanupAfterEncode(){if(this.snapshots!==void 0){for(let[e]of this.snapshots){let t=this.keyByIndex.get(e);t!==void 0&&(delete this.indexByKey[t],this.keyByIndex.delete(e))}this.snapshots.clear()}}reset(){this.indexByKey=Object.create(null),this.keyByIndex.clear(),this.snapshots?.clear(),this.nextIndex=0}},as=class i{[Z];[rt];childType;[pt];$items=new Map;journal=new jf;_stream;get maxPerTick(){return this._stream?.maxPerTick??32}set maxPerTick(e){(this._stream??=Js()).maxPerTick=e}get priority(){return this._stream?.priority}set priority(e){(this._stream??=Js()).priority=e}get $indexes(){return this.journal.keyByIndex}get _collectionIndexes(){return this.journal.indexByKey}static[Ts]=OP;static[ss]=id;static COLLECTION_KIND=is.Map;static[wa](e,t,n){if(!n||typeof e[pt]=="string")return!0;let s=e[bn](t)??e.journal.snapshotAt(t);return n.isChangeTreeVisible(s[Z])}static is(e){return e.map!==void 0}constructor(e){if(Object.defineProperty(this,Z,{value:new Nr(this),enumerable:!1,writable:!0}),this[pt]=void 0,e)if(e instanceof Map||e instanceof i)e.forEach((t,n)=>this.set(n,t));else for(let t in e)this.set(t,e[t])}static initializeForDecoder(){let e=Object.create(i.prototype);return e.$items=new Map,e.journal=new jf,e[pt]=void 0,Po(e),e}[Symbol.iterator](){return this.$items[Symbol.iterator]()}get[Symbol.toStringTag](){return this.$items[Symbol.toStringTag]}static get[Symbol.species](){return i}set(e,t){if(t==null)throw new Error(`MapSchema#set('${e}', ${t}): trying to set ${t} value on '${e}'.`);typeof t=="object"&&this[pt]&&sd(t,this[pt],this,e),e=e.toString();let n=this[Z],s=t[Z]!==void 0,r=this.journal,a=r.indexOf(e),o;if(a!==void 0){o=_e.REPLACE;let c=this.$items.get(e);if(c===t)return;s&&(o=_e.DELETE_AND_ADD,c!==void 0&&c[Z].root?.remove(c[Z])),r.snapshotAt(a)!==void 0&&r.forgetSnapshot(a)}else a=r.assign(e),o=_e.ADD;return this.$items.set(e,t),o===_e.ADD&&n.isStreamCollection?n.root!==void 0&&Qf(this,n.root,a):n.change(a,o),s&&t[Z].setParent(this,n.root,a),this}get(e){return this.$items.get(e)}getOrInsert(e,t){return this.$items.has(e)?this.$items.get(e):(this.set(e,t),t)}getOrInsertComputed(e,t){if(this.$items.has(e))return this.$items.get(e);let n=t(e);return this.set(e,n),n}delete(e){if(!this.$items.has(e))return!1;let t=this.journal.indexOf(e),n=this.$items.get(e),s=this[Z];if(s.isStreamCollection){let r=s.root,a=!1;return r!==void 0&&(a=ed(this,r,this[rt],t)),n?.[Z]!==void 0&&r?.remove(n[Z]),this.$items.delete(e),a||this.journal.snapshot(t,n),!0}return this.journal.snapshot(t,n),s.delete(t),this.$items.delete(e)}clear(){let e=this[Z];e.discard(),e.forEachChild((t,n)=>{e.root?.remove(t)}),this.journal.reset(),this.$items.clear(),e.operation(_e.CLEAR)}[rs](){let e=this[Z];if(e.isStreamCollection)throw new Error("@colyseus/schema: cannot reset a streamed MapSchema (pooling not supported).");this.$items.forEach(t=>t?.[rs]?.()),this.$items.clear(),this.journal.reset(),e.recycle(),this[rt]=void 0}has(e){return this.$items.has(e)}forEach(e){this.$items.forEach(e)}entries(){return this.$items.entries()}keys(){return this.$items.keys()}values(){return this.$items.values()}get size(){return this.$items.size}pauseTracking(){this[Z].pause()}resumeTracking(){this[Z].resume()}untracked(e){return this[Z].untracked(e)}get isTrackingPaused(){return this[Z].paused}setIndex(e,t){this.journal.setIndex(e,t)}getIndex(e){return this.journal.keyOf(e)}[bn](e){let t=this.journal.keyOf(e);return t!==void 0?this.$items.get(t):void 0}[os](e){let t=this.journal.keyOf(e);t!==void 0&&(this.$items.delete(t),this.journal.keyByIndex.delete(e))}[Io](e,t,n){let s=null;if(this.$items.forEach((r,a)=>{if(e.has(a)){n(r);return}(s??=new Set).add(a),t(r,a)}),s!==null){s.forEach(a=>{this.$items.delete(a),delete this.journal.indexByKey[a]});let r=[];this.journal.keyByIndex.forEach((a,o)=>{s.has(a)&&r.push(o)});for(let a=0;a<r.length;a++)this.journal.keyByIndex.delete(r[a])}}[Cr](){this.journal.cleanupAfterEncode()}_dropView(e){td(this,e)}_unregister(){}toJSON(){return Object.fromEntries(Array.from(this,([t,n])=>[t,typeof n.toJSON=="function"?n.toJSON():n]))}clone(e){let t;return e?t=Object.assign(new i,this):(t=new i,this.forEach((n,s)=>{n[Z]?t.set(s,n.clone()):t.set(s,n)})),t}};Zs("map",{constructor:as});ul=class i{[Z];[rt];[pt];$items=new Map;deletedItems={};$refId=0;_stream;get maxPerTick(){return this._stream?.maxPerTick??32}set maxPerTick(e){(this._stream??=Js()).maxPerTick=e}get priority(){return this._stream?.priority}set priority(e){(this._stream??=Js()).priority=e}static[Ts]=j0;static[ss]=id;static COLLECTION_KIND=is.Collection;static[wa](e,t,n){return!n||typeof e[pt]=="string"||n.isChangeTreeVisible((e[bn](t)??e.deletedItems[t])[Z])}static is(e){return e.collection!==void 0}constructor(e){Object.defineProperty(this,Z,{value:new Nr(this),enumerable:!1,writable:!0}),this[pt]=void 0,e&&e.forEach(t=>this.add(t))}static initializeForDecoder(){let e=Object.create(i.prototype);return e.$items=new Map,e.deletedItems={},e.$refId=0,e[pt]=void 0,Po(e),e}add(e){let t=this.$refId++,n=this[Z];return this.$items.set(t,e),n.isStreamCollection?n.root!==void 0&&Qf(this,n.root,t):n.change(t),e[Z]!==void 0&&e[Z].setParent(this,n.root,t),t}at(e){let t=Array.from(this.$items.keys())[e];return this.$items.get(t)}entries(){return this.$items.entries()}delete(e){let t=this.$items.entries(),n,s;for(;(s=t.next())&&!s.done;)if(e===s.value[1]){n=s.value[0];break}if(n===void 0)return!1;let r=this[Z];if(r.isStreamCollection){let a=r.root,o=this.$items.get(n);return a!==void 0&&ed(this,a,this[rt],n),o?.[Z]!==void 0&&a?.remove(o[Z]),this.deletedItems[n]=o,this.$items.delete(n)}return this.deletedItems[n]=r.delete(n),this.$items.delete(n)}clear(){let e=this[Z];e.discard(),e.forEachChild((t,n)=>{e.root?.remove(t)}),this.$items.clear(),e.operation(_e.CLEAR)}[rs](){let e=this[Z];if(e.isStreamCollection)throw new Error("@colyseus/schema: cannot reset a streamed CollectionSchema (pooling not supported).");this.$items.forEach(t=>t?.[rs]?.()),this.$items.clear(),this.deletedItems={},this.$refId=0,e.recycle(),this[rt]=void 0}has(e){return Array.from(this.$items.values()).some(t=>t===e)}forEach(e){this.$items.forEach((t,n,s)=>e(t,n,this))}values(){return this.$items.values()}get size(){return this.$items.size}pauseTracking(){this[Z].pause()}resumeTracking(){this[Z].resume()}untracked(e){return this[Z].untracked(e)}get isTrackingPaused(){return this[Z].paused}[Symbol.iterator](){return this.$items.values()}setIndex(e,t){}getIndex(e){return e}[bn](e){return this.$items.get(e)}[os](e){this.$items.delete(e)}[Io](e,t,n){let s=null;if(this.$items.forEach((r,a)=>{if(e.has(a)){n(r);return}(s??=[]).push(a),t(r,a)}),s!==null)for(let r=0;r<s.length;r++)this[os](s[r])}[Cr](){for(let e in this.deletedItems)delete this.deletedItems[e]}_dropView(e){td(this,e)}_unregister(){}toArray(){return Array.from(this.$items.values())}toJSON(){let e=[];return this.forEach((t,n)=>{e.push(typeof t.toJSON=="function"?t.toJSON():t)}),e}clone(e){let t;return e?t=Object.assign(new i,this):(t=new i,this.forEach(n=>{n[Z]?t.add(n.clone()):t.add(n)})),t}};Zs("collection",{constructor:ul});fl=class i{[Z];[rt];[pt];$items=new Map;deletedItems={};$refId=0;_stream;get maxPerTick(){return this._stream?.maxPerTick??32}set maxPerTick(e){(this._stream??=Js()).maxPerTick=e}get priority(){return this._stream?.priority}set priority(e){(this._stream??=Js()).priority=e}static[Ts]=j0;static[ss]=id;static COLLECTION_KIND=is.Set;static[wa](e,t,n){return!n||typeof e[pt]=="string"||n.isVisible((e[bn](t)??e.deletedItems[t])[Z])}static is(e){return e.set!==void 0}constructor(e){Object.defineProperty(this,Z,{value:new Nr(this),enumerable:!1,writable:!0}),this[pt]=void 0,e&&e.forEach(t=>this.add(t))}static initializeForDecoder(){let e=Object.create(i.prototype);return e.$items=new Map,e.deletedItems={},e.$refId=0,e[pt]=void 0,Po(e),e}add(e){if(this.has(e))return!1;let t=this.$refId++,n=this[Z];return this.$items.set(t,e),n.isStreamCollection?n.root!==void 0&&Qf(this,n.root,t):n.change(t,_e.ADD),e[Z]!==void 0&&e[Z].setParent(this,n.root,t),t}entries(){return this.$items.entries()}delete(e){let t=this.$items.entries(),n,s;for(;(s=t.next())&&!s.done;)if(e===s.value[1]){n=s.value[0];break}if(n===void 0)return!1;let r=this[Z];if(r.isStreamCollection){let a=r.root,o=this.$items.get(n);return a!==void 0&&ed(this,a,this[rt],n),o?.[Z]!==void 0&&a?.remove(o[Z]),this.deletedItems[n]=o,this.$items.delete(n)}return this.deletedItems[n]=r.delete(n),this.$items.delete(n)}clear(){let e=this[Z];e.discard(),this.$items.clear(),e.operation(_e.CLEAR)}[rs](){let e=this[Z];if(e.isStreamCollection)throw new Error("@colyseus/schema: cannot reset a streamed SetSchema (pooling not supported).");this.$items.forEach(t=>t?.[rs]?.()),this.$items.clear(),this.deletedItems={},this.$refId=0,e.recycle(),this[rt]=void 0}has(e){let t=this.$items.values(),n=!1,s;for(;(s=t.next())&&!s.done;)if(e===s.value){n=!0;break}return n}forEach(e){this.$items.forEach((t,n,s)=>e(t,n,this))}values(){return this.$items.values()}get size(){return this.$items.size}pauseTracking(){this[Z].pause()}resumeTracking(){this[Z].resume()}untracked(e){return this[Z].untracked(e)}get isTrackingPaused(){return this[Z].paused}[Symbol.iterator](){return this.$items.values()}setIndex(e,t){}getIndex(e){return e}[bn](e){return this.$items.get(e)}[os](e){this.$items.delete(e)}[Io](e,t,n){let s=null;if(this.$items.forEach((r,a)=>{if(e.has(a)){n(r);return}(s??=[]).push(a),t(r,a)}),s!==null)for(let r=0;r<s.length;r++)this[os](s[r])}[Cr](){for(let e in this.deletedItems)delete this.deletedItems[e]}_dropView(e){td(this,e)}_unregister(){}toArray(){return Array.from(this.$items.values())}toJSON(){let e=[];return this.forEach((t,n)=>{e.push(typeof t.toJSON=="function"?t.toJSON():t)}),e}clone(e){let t;return e?t=Object.assign(new i,this):(t=new i,this.forEach(n=>{n[Z]?t.add(n.clone()):t.add(n)})),t}};Zs("set",{constructor:fl});Xf=class i{[Z];[rt];[pt];$items=new Map;$nextPosition=0;_itemIndex=new Map;_stream;get maxPerTick(){return this._stream?.maxPerTick??32}set maxPerTick(e){(this._stream??=Js()).maxPerTick=e}get priority(){return this._stream?.priority}set priority(e){(this._stream??=Js()).priority=e}static $isStream=!0;static[Ts]=j0;static[ss]=id;static COLLECTION_KIND=is.Stream;static[wa](e,t,n){if(!n)return!0;let s=e[bn](t);return s===void 0?!1:n.isVisible(s[Z])}static is(e){return e&&e.stream!==void 0}constructor(){Object.defineProperty(this,Z,{value:new Nr(this),enumerable:!1,writable:!0}),this[pt]=void 0}static initializeForDecoder(){let e=Object.create(i.prototype);return e.$items=new Map,e.$nextPosition=0,e._itemIndex=new Map,e[pt]=void 0,Po(e),e}add(e){if(this._itemIndex.has(e))return-1;let t=this.$nextPosition++;this.$items.set(t,e),this._itemIndex.set(e,t);let s=this[Z].root;return e[Z]!==void 0&&e[Z].setParent(this,s,t),s!==void 0&&Qf(this,s,t),t}remove(e){let t=this._itemIndex.get(e);if(t===void 0)return!1;this._itemIndex.delete(e),this.$items.delete(t);let n=this[Z].root;return n!==void 0&&(ed(this,n,this[rt],t),e[Z]!==void 0&&n.remove(e[Z])),!0}has(e){return this._itemIndex.has(e)}clear(){let e=this[Z].root;if(e!==void 0){tP(this,e,this[rt]);for(let t of this.$items.values())t[Z]!==void 0&&e.remove(t[Z])}this.$items.clear(),this._itemIndex.clear()}forEach(e){for(let[t,n]of this.$items)e(n,t,this)}values(){return this.$items.values()}entries(){return this.$items.entries()}[Symbol.iterator](){return this.$items.values()}get size(){return this.$items.size}get length(){return this.$items.size}setIndex(e,t){}getIndex(e){return e}[bn](e){return this.$items.get(e)}[os](e){let t=this.$items.get(e);t!==void 0&&(this._itemIndex.delete(t),this.$items.delete(e))}[Io](){}[Cr](){}toArray(){return Array.from(this.$items.values())}toJSON(){let e=[];return this.forEach(t=>{e.push(typeof t?.toJSON=="function"?t.toJSON():t)}),e}clone(e){if(e)return Object.assign(new i,this);let t=new i;return t.maxPerTick=this.maxPerTick,this.forEach(n=>{t.add(typeof n?.clone=="function"?n.clone():n)}),t}_dropView(e){td(this,e)}_unregister(){}};Zs("stream",{constructor:Xf});Rs=class{[Cw]=!0;_type;_default=void 0;_hasDefault=!1;_view=void 0;_unreliable=!1;_patchOnly=!1;_deprecated=!1;_deprecatedThrows=!0;_fullStateOnly=!1;_stream=!1;_optional=!1;_noSync=!1;_streamPriority=void 0;constructor(e){this._type=e}default(e){return this._default=e,this._hasDefault=!0,this}view(e){return this._view=e??-1,this}unreliable(){return this._unreliable=!0,this}patchOnly(){return this._patchOnly=!0,this}fullStateOnly(){return this._fullStateOnly=!0,this}noSync(){return this._noSync=!0,this}stream(){let e=this._type;if(e&&typeof e=="object"&&e.array!==void 0)throw new Error(jw);return this._stream=!0,this}priority(e){return this._streamPriority=e,this}deprecated(e=!0){return this._deprecated=!0,this._deprecatedThrows=e,this}optional(){return this._optional=!0,this}toDefinition(){return{type:this._type,default:this._default,hasDefault:this._hasDefault,view:this._view,unreliable:this._unreliable,patchOnly:this._patchOnly,deprecated:this._deprecated,deprecatedThrows:this._deprecatedThrows,fullStateOnly:this._fullStateOnly,stream:this._stream,optional:this._optional,noSync:this._noSync,streamPriority:this._streamPriority}}};GP=(i=>new Rs({array:bl(i)})),WP=(i=>new Rs({map:bl(i)})),$P=(i=>new Rs({set:bl(i)})),qP=(i=>new Rs({collection:bl(i)})),jP=(i=>{let e=new Rs({stream:bl(i)});return e._stream=!0,e}),XP=(i=>new Rs(i));hi=Object.freeze({string:ti("string"),number:ti("number"),boolean:ti("boolean"),int8:ti("int8"),uint8:ti("uint8"),int16:ti("int16"),uint16:ti("uint16"),int32:ti("int32"),uint32:ti("uint32"),int64:ti("int64"),uint64:ti("uint64"),float32:ti("float32"),float64:ti("float64"),bigint64:ti("bigint64"),biguint64:ti("biguint64"),ref:XP,array:GP,map:WP,set:$P,collection:qP,stream:jP,quantized:ww,angle:i=>ww({min:0,max:Math.PI*2,mode:"wrap",bits:i?.bits??16})}),rd=-1;QP={number:"number",int8:"number",uint8:"number",int16:"number",uint16:"number",int32:"number",uint32:"number",int64:"number",uint64:"number",float32:"number",float64:"number",bigint64:"bigint",biguint64:"bigint",string:"string",boolean:"boolean"};Mw=!1;en=class i{static[Ts]=NP;static[ss]=zP;[rt];[Es];static initialize(e){Object.defineProperty(e,Z,{value:new Nr(e),enumerable:!1,writable:!0}),e[Es]=[]}static initializeForDecoder(){let e=Object.create(this.prototype);return Po(e),e[Es]=[],e}static reset(e){let t=e?.[Z];if(t===void 0||typeof t.recycle!="function")throw new Error("@colyseus/schema: Schema.reset() requires a tracked (encoder-side) instance.");if(t.extraParents!==void 0)throw new Error(`@colyseus/schema: cannot reset a shared instance (${e.constructor.name}) with multiple parents.`);e[rs]()}[rs](){let t=this.constructor[Symbol.metadata]?.[Ir]??[],n=this[Es];for(let s=0;s<t.length;s++)n[t[s]]?.[rs]?.();this[Z].recycle(),this[rt]=void 0}static is(e){let t=e[Symbol.metadata];return typeof t=="object"&&t!==null}static isSchema(e){return typeof e?.assign=="function"}static[As](e,t,n=_e.ADD){e.change(t,n)}static[wa](e,t,n){let r=e.constructor[Symbol.metadata][t]?.tag;return n===void 0?r===void 0:r===void 0?!0:r===rd?n.isChangeTreeVisible(e[Z]):n.hasTagOnTree(e[Z],r)}constructor(e){i.initialize(this),e&&i.assignProps(this,e)}assign(e){return i.assignProps(this,e),this}static assignProps(e,t){let n=e.constructor[Symbol.metadata];if(n&&n[Un]!==void 0)for(let r=0;r<=n[Un];r++){let a=n[r];if(!a)continue;let o=t[a.name];o!==void 0&&(e[a.name]=o)}let s=Object.keys(t);for(let r=0;r<s.length;r++){let a=s[r];n&&n[a]!==void 0||(e[a]=t[a])}}restore(e){let t=this.constructor[Symbol.metadata];for(let n in t){let s=t[n],r=s.name,a=s.type,o=e[r];if(o!=null){if(typeof a=="string")this[r]=o;else if(i.is(a)){let c=new a;c.restore(o),this[r]=c}else if(typeof a=="object"){let c=Object.keys(a)[0],l=a[c];if(c==="map"){let h=this[r];for(let u in o)if(i.is(l)){let d=new l;d.restore(o[u]),h.set(u,d)}else h.set(u,o[u])}else if(c==="array"){let h=this[r];for(let u=0;u<o.length;u++)if(i.is(l)){let d=new l;d.restore(o[u]),h.push(d)}else h.push(o[u])}}}}return this}setDirty(e,t){let n=this.constructor[Symbol.metadata];this[Z].change(n[n[e]].index,t)}pauseTracking(){this[Z].pause()}resumeTracking(){this[Z].resume()}untracked(e){return this[Z].untracked(e)}get isTrackingPaused(){return this[Z].paused}clone(){let e=Object.create(this.constructor.prototype);i.initialize(e);let t=this.constructor[Symbol.metadata];for(let n in t){let s=t[n].name;typeof this[s]=="object"&&typeof this[s]?.clone=="function"?e[s]=this[s].clone():e[s]=this[s]}return e}toJSON(){let e={},t=this.constructor[Symbol.metadata];for(let n in t){let s=t[n],r=s.name;!s.deprecated&&this[r]!==null&&typeof this[r]<"u"&&(e[r]=typeof this[r].toJSON=="function"?this[r].toJSON():this[r])}return e}discardAllChanges(){this[Z].discardAll()}[bn](e){let t=this.constructor[Symbol.metadata];return this[t[e].name]}[os](e){let t=this.constructor[Symbol.metadata];this[t[e].name]=void 0}static debugRefIds(e,t=!1,n=0,s,r=""){let a=t?` - ${JSON.stringify(e.toJSON())}`:"",o=e[Z],c=e[rt],l=s?s.root.refCount[c]:o.refCount,h=l>1?` [\xD7${l}]`:"",u=`${aL(n)}${r}${e.constructor.name} (refId: ${c})${h}${a}
+`;return o.forEachChild((d,p)=>{let b=p;typeof p=="number"&&e.$indexes&&(b=e.$indexes.get(p)??p);let v=e.forEach!==void 0&&b!==void 0?`["${b}"]: `:"";u+=this.debugRefIds(d.ref,t,n+1,s,v)}),u}static debugRefIdEncodingOrder(e,t="allChanges"){let n=[],s=e[Z];if(t==="changes"){let c=s.root.changes?.next;for(;c;)c.changeTree&&n.push(c.changeTree.ref[rt]),c=c.next;return n}let r=t==="allFilteredChanges",a=new Set,o=c=>{a.has(c)||(a.add(c),c.isFiltered===r&&n.push(c.ref[rt]),c.forEachChild((l,h)=>o(l)))};return o(s),n}static debugRefIdsFromDecoder(e){return this.debugRefIds(e.state,!1,0,e)}static debugChanges(e,t=!1){let n=e[Z],s=t?"allChanges":"changes",r=`${e.constructor.name} (${e[rt]}) -> .${s}:
+`;return t?n.forEachLive(a=>{r+=`- [${a}]: ADD (${JSON.stringify(n.getValue(Number(a),!0))})
+`}):n.forEach((a,o)=>{a<0||!o||(r+=`- [${a}]: ${_e[o]} (${JSON.stringify(n.getValue(Number(a),!1))})
+`)}),r}};Rw(en);Ew={value:0,enumerable:!1,writable:!0},k0=class{types;nextUniqueId=0;changeTrees={};get refCount(){let e={};for(let t in this.changeTrees)e[t]=this.changeTrees[t].refCount;return e}changes=vw();unreliableChanges=vw();pendingFilterRefresh=[];enqueueFilterRefresh(e){this.types.hasFilters&&(e.flags&ll||(e.flags|=ll,this.pendingFilterRefresh.push(e)))}_nodePool=[];_nextViewId=0;_freeViewIds=[];acquireViewId(){return this._freeViewIds.length>0?this._freeViewIds.pop():this._nextViewId++}releaseViewId(e){this._freeViewIds.push(e)}activeViews=new Map;streamTrees=new Set;registerView(e){this.activeViews.set(e.id,new WeakRef(e))}unregisterView(e){this.activeViews.delete(e.id);let t=e.id;for(let n of this.streamTrees)n._dropView(t)}forEachActiveView(e){for(let[t,n]of this.activeViews){let s=n.deref();if(s===void 0){this.activeViews.delete(t);for(let r of this.streamTrees)r._dropView(t);continue}e(s)}}registerStream(e){this.streamTrees.add(e)}unregisterStream(e){this.streamTrees.delete(e)}constructor(e,t=0){this.types=e,this.nextUniqueId=t}add(e){let t=e.ref;t[rt]===void 0&&(Ew.value=this.nextUniqueId++,Object.defineProperty(t,rt,Ew));let n=t[rt],s=this.changeTrees[n]===void 0;s&&(this.changeTrees[n]=e),e.needsRestage&&(e.needsRestage=!1,e.forEachLiveWithCtx(e,e1));let r=s?0:e.refCount;return e.refCount=r+1,r>0&&this.enqueueFilterRefresh(e),s}remove(e){let t=e.refCount-1;if(t<=0){if(e.root=void 0,delete this.changeTrees[e.ref[rt]],e.isStreamCollection){let n=e.ref;n._unregister?.(),this.unregisterStream(n)}this.removeFromQueue(e),this.removeFromUnreliableQueue(e),e.refCount=0,e.needsRestage=!0,e.forEachChild((n,s)=>{n.removeParent(e.ref)&&(n.parentRef===void 0||n.refCount>0?this.remove(n):this.moveNextToParent(n))})}else e.refCount=t,this.enqueueFilterRefresh(e),this.recursivelyMoveNextToParent(e);return t}recursivelyMoveNextToParent(e){this.moveNextToParent(e),e.forEachChild((t,n)=>this.recursivelyMoveNextToParent(t))}moveNextToParent(e){e.changesNode&&this._moveNextToParentInList(this.changes,e,e.changesNode,"changesNode"),e.unreliableChangesNode&&this._moveNextToParentInList(this.unreliableChanges,e,e.unreliableChangesNode,"unreliableChangesNode")}_moveNextToParentInList(e,t,n,s){let r=t.parent;if(!r||!r[Z])return;let a=r[Z][s];!a||a===n||n.position>a.position||(n.prev?n.prev.next=n.next:e.next=n.next,n.next?n.next.prev=n.prev:e.tail=n.prev,n.prev=e.tail,n.next=void 0,e.tail.next=n,e.tail=n,n.position=e.nextPosition++)}enqueueChangeTree(e,t=e.changesNode){t||(e.changesNode=this._appendToList(this.changes,e))}enqueueUnreliable(e,t=e.unreliableChangesNode){t||(e.unreliableChangesNode=this._appendToList(this.unreliableChanges,e))}_appendToList(e,t){let n=this._nodePool,s;return n.length>0?(s=n.pop(),s.changeTree=t,s.next=void 0,s.prev=void 0):s={changeTree:t,next:void 0,prev:void 0,position:0},e.next?(s.prev=e.tail,e.tail.next=s,e.tail=s):(e.nextPosition=0,e.next=s,e.tail=s),s.position=e.nextPosition++,s}releaseNode(e){e.changeTree=void 0,e.prev=void 0,e.next=void 0,this._nodePool.push(e)}removeFromQueue(e){return this._removeNode(this.changes,e,e.changesNode,"changesNode")}removeFromUnreliableQueue(e){return this._removeNode(this.unreliableChanges,e,e.unreliableChangesNode,"unreliableChangesNode")}_removeNode(e,t,n,s){return!n||n.changeTree!==t?!1:(n.prev?n.prev.next=n.next:e.next=n.next,n.next?n.next.prev=n.prev:e.tail=n.prev,t[s]=void 0,this.releaseNode(n),!0)}};zk=new FinalizationRegistry(({root:i,id:e,slot:t,bit:n})=>{cL(i,t,n),i.activeViews.delete(e);for(let s of i.streamTrees)s._dropView(e);i.releaseViewId(e)}),lL=-1;U0=class i{static BUFFER_SIZE=16*1024;sharedBuffer=new Uint8Array(i.BUFFER_SIZE);context;state;root;constructor(e,t){this.context=Dr.cache(e.constructor),this.root=t??new k0(this.context),this.setState(e)}setState(e){this.state=e,this.state[Z].setRoot(this.root)}_encodeCtx={self:void 0,buffer:void 0,it:void 0,changeTree:void 0,ref:void 0,encoder:void 0,filter:void 0,metadata:void 0,view:void 0,isEncodeAll:!1,hasView:!1,treeIsFiltered:!1,isSchema:!1,emitFiltered:!1,filterBitmask:0,tags:void 0,structSwitchEmitted:!1,isRootTree:!1,shouldEmitSwitch:!1,gen:0,initialOffset:0,rootChangeTree:void 0};_fullSyncGen=0;encode(e={offset:0},t,n=this.sharedBuffer,s=e.offset){return this._encodeChannel(e,t,n,s,!1)}encodeUnreliable(e={offset:0},t,n=this.sharedBuffer,s=e.offset){return this._encodeChannel(e,t,n,s,!0)}_encodeChannel(e,t,n,s,r){this.root.pendingFilterRefresh.length>0&&_w(this.root);let a=t!==void 0,o=this.state[Z],c=this._encodeCtx;c.self=this,c.buffer=n,c.it=e,c.view=t,c.isEncodeAll=!1,c.hasView=a,c.emitFiltered=a;let h=r?this.root.unreliableChanges:this.root.changes;for(;h=h.next;){let u=h.changeTree;if(a&&!t.isChangeTreeVisible(u))continue;let d=r?u.unreliableRecorder:u;if(!d||!d.has())continue;let p=u.encDescriptor;c.changeTree=u,c.ref=u.ref,c.encoder=p.encoder,c.filter=p.filter,c.metadata=p.metadata,c.treeIsFiltered=u.isFiltered,c.isSchema=p.isSchema,c.filterBitmask=p.filterBitmask,c.tags=p.tags,c.structSwitchEmitted=!1,c.isRootTree=u===o,c.shouldEmitSwitch=a||e.offset>s||!c.isRootTree,d.forEachWithCtx(c,l1)}return!r&&!a&&this._isStreamBroadcastMode&&this._emitStreamBroadcast(n,e),e.offset>n.byteLength?(n=this._resizeBuffer(n,e.offset),e.offset=s,this._encodeChannel(e,t,n,s,r)):n.subarray(0,e.offset)}encodeFullSync(e,t,n,s,r=e.offset){this.root.pendingFilterRefresh.length>0&&_w(this.root);let a=s!==void 0,o=this.state[Z],c=this._encodeCtx;return c.self=this,c.buffer=t,c.it=e,c.view=s,c.isEncodeAll=!0,c.hasView=a,c.emitFiltered=n,c.gen=++this._fullSyncGen,c.initialOffset=r,c.rootChangeTree=o,c1(c,o),e.offset>t.byteLength?(t=this._resizeBuffer(t,e.offset),e.offset=r,this.encodeFullSync(e,t,n,s,r)):t.subarray(0,e.offset)}_resizeBuffer(e,t){let n=Math.ceil(t/i.BUFFER_SIZE)*i.BUFFER_SIZE;console.warn(`@colyseus/schema buffer overflow. Encoded state is higher than default BUFFER_SIZE. Use the following to increase default BUFFER_SIZE:
import { Encoder } from "@colyseus/schema";
- Encoder.BUFFER_SIZE = ${Math.round(he/1024)} * 1024; // ${Math.round(he/1024)} KB
-`),_=Buffer.alloc(he,_),_===this.sharedBuffer&&(this.sharedBuffer=_),this.encode({offset:X},m,_,w,z)}else return _.subarray(0,u.offset)}encodeAll(u={offset:0},m=this.sharedBuffer){return this.encode(u,void 0,m,"allChanges",!0)}encodeAllView(u,m,_,w=this.sharedBuffer){let z=_.offset;return this.encode(_,u,w,"allFilteredChanges",!0,z),Buffer.concat([w.subarray(0,m),w.subarray(z,_.offset)])}encodeView(u,m,_,w=this.sharedBuffer){let z=_.offset;for(let[X,ue]of u.changes){let ne=this.root.changeTrees[X];if(ne===void 0){u.changes.delete(X);continue}let ae=Object.keys(ue);if(ae.length===0)continue;let se=ne.ref.constructor,Ge=se[r],Oe=se[Symbol.metadata];w[_.offset++]=255,oe.number(w,ne.refId,_);for(let Re=0,ye=ae.length;Re<ye;Re++){let $e=Number(ae[Re]),nn=ne.ref[o]($e)!==void 0&&ue[$e]||i.OPERATION.DELETE;Ge(this,w,ne,$e,nn,_,!1,!0,Oe)}}return u.changes.clear(),this.encode(_,u,w,"filteredChanges",!1,z),Buffer.concat([w.subarray(0,m),w.subarray(z,_.offset)])}discardChanges(){let u=this.root.changes.next;for(;u;)u.changeTree.endEncode("changes"),u=u.next;for(this.root.changes=pt(),u=this.root.filteredChanges.next;u;)u.changeTree.endEncode("filteredChanges"),u=u.next;this.root.filteredChanges=pt()}tryEncodeTypeId(u,m,_,w){let z=this.context.getTypeId(m),X=this.context.getTypeId(_);if(X===void 0){console.warn(`@colyseus/schema WARNING: Class "${_.name}" is not registered on TypeRegistry - Please either tag the class with @entity or define a @type() field.`);return}z!==X&&(u[w.offset++]=213,oe.number(u,X,w))}get hasChanges(){return this.root.changes.next!==void 0||this.root.filteredChanges.next!==void 0}};It.BUFFER_SIZE=typeof Buffer<"u"&&Buffer.poolSize||8*1024;let at=It;function Ye(R,u){if(u===-1||u>=R.length)return!1;let m=R.length-1;for(let _=u;_<m;_++)R[_]=R[_+1];return R.length=m,!0}class Ct extends Error{constructor(u){super(u),this.name="DecodingWarning"}}class Jt{constructor(){this.refs=new Map,this.refIds=new WeakMap,this.refCount={},this.deletedRefs=new Set,this.callbacks={},this.nextUniqueId=0}getNextUniqueId(){return this.nextUniqueId++}addRef(u,m,_=!0){this.refs.set(u,m),this.refIds.set(m,u),_&&(this.refCount[u]=(this.refCount[u]||0)+1),this.deletedRefs.has(u)&&this.deletedRefs.delete(u)}removeRef(u){let m=this.refCount[u];if(m===void 0){try{throw new Ct("trying to remove refId that doesn't exist: "+u)}catch(_){console.warn(_)}return}if(m===0){try{let _=this.refs.get(u);throw new Ct(`trying to remove refId '${u}' with 0 refCount (${_.constructor.name}: ${JSON.stringify(_)})`)}catch(_){console.warn(_)}return}(this.refCount[u]=m-1)<=0&&this.deletedRefs.add(u)}clearRefs(){this.refs.clear(),this.deletedRefs.clear(),this.callbacks={},this.refCount={}}garbageCollectDeletedRefs(){this.deletedRefs.forEach(u=>{if(this.refCount[u]>0)return;let m=this.refs.get(u);if(m.constructor[Symbol.metadata]!==void 0){let _=m.constructor[Symbol.metadata];for(let w in _){let z=_[w].name,X=typeof m[z]=="object"&&this.refIds.get(m[z]);X&&!this.deletedRefs.has(X)&&this.removeRef(X)}}else typeof m[h]=="function"&&Array.from(m.values()).forEach(_=>{let w=this.refIds.get(_);this.deletedRefs.has(w)||this.removeRef(w)});this.refs.delete(u),delete this.refCount[u],delete this.callbacks[u]}),this.deletedRefs.clear()}addCallback(u,m,_){if(u===void 0){let w=typeof m=="number"?i.OPERATION[m]:m;throw new Error(`Can't addCallback on '${w}' (refId is undefined)`)}return this.callbacks[u]||(this.callbacks[u]={}),this.callbacks[u][m]||(this.callbacks[u][m]=[]),this.callbacks[u][m].push(_),()=>this.removeCallback(u,m,_)}removeCallback(u,m,_){let w=this.callbacks?.[u]?.[m]?.indexOf(_);w!==void 0&&w!==-1&&Ye(this.callbacks[u][m],w)}}class Wt{constructor(u,m){this.currentRefId=0,this.setState(u),this.context=m||new Le(u.constructor)}setState(u){this.state=u,this.root=new Jt,this.root.addRef(0,u)}decode(u,m={offset:0},_=this.state){let w=[],z=this.root,X=u.byteLength,ue=_.constructor[s];for(this.currentRefId=0;m.offset<X;){if(u[m.offset]==255){m.offset++,_[f]?.();let ae=ge.number(u,m),he=z.refs.get(ae);he?(_=he,ue=_.constructor[s],this.currentRefId=ae):(console.error(`"refId" not found: ${ae}`,{previousRef:_,previousRefId:this.currentRefId}),console.warn("Please report this issue to the developers."),this.skipCurrentStructure(u,m,X));continue}if(ue(this,u,m,_,w)===rt){console.warn("@colyseus/schema: definition mismatch"),this.skipCurrentStructure(u,m,X);continue}}return _[f]?.(),this.triggerChanges?.(w),z.garbageCollectDeletedRefs(),w}skipCurrentStructure(u,m,_){let w={offset:m.offset};for(;m.offset<_&&!(u[m.offset]===255&&(w.offset=m.offset+1,this.root.refs.has(ge.number(u,w))));)m.offset++}getInstanceType(u,m,_){let w;if(u[m.offset]===213){m.offset++;let z=ge.number(u,m);w=this.context.get(z)}return w||_}createInstanceOfType(u){return new u}removeChildRefs(u,m){let _=typeof u[h]!="string",w=this.root.refIds.get(u);u.forEach((z,X)=>{m.push({ref:u,refId:w,op:i.OPERATION.DELETE,field:X,value:void 0,previousValue:z}),_&&this.root.removeRef(this.root.refIds.get(z))})}}class Mt extends Ie{}qe([ni("string")],Mt.prototype,"name",void 0),qe([ni("string")],Mt.prototype,"type",void 0),qe([ni("number")],Mt.prototype,"referencedType",void 0);class Zt extends Ie{constructor(){super(...arguments),this.fields=new jn}}qe([ni("number")],Zt.prototype,"id",void 0),qe([ni("number")],Zt.prototype,"extendsId",void 0),qe([ni([Mt])],Zt.prototype,"fields",void 0);class ze extends Ie{constructor(){super(...arguments),this.types=new jn}static encode(u,m={offset:0}){let _=u.context,w=new ze,z=new at(w),X=_.schemas.get(u.state.constructor);X>0&&(w.rootType=X);let ue=new Set,ne={},ae=se=>{if(se.extendsId===void 0||ue.has(se.extendsId)){ue.add(se.id),w.types.push(se);let Ge=ne[se.id];Ge!==void 0&&(delete ne[se.id],Ge.forEach(Oe=>ae(Oe)))}else ne[se.extendsId]===void 0&&(ne[se.extendsId]=[]),ne[se.extendsId].push(se)};_.schemas.forEach((se,Ge)=>{let Oe=new Zt;Oe.id=Number(se);let Re=Object.getPrototypeOf(Ge);Re!==Ie&&(Oe.extendsId=_.schemas.get(Re));let ye=Ge[Symbol.metadata];if(ye!==Re[Symbol.metadata])for(let $e in ye){let tn=Number($e),nn=ye[tn].name;if(!Object.prototype.hasOwnProperty.call(ye,nn))continue;let ii=new Mt;ii.name=nn;let fi,Mr=ye[tn];if(typeof Mr.type=="string")fi=Mr.type;else{let Sc;Ie.is(Mr.type)?(fi="ref",Sc=Mr.type):(fi=Object.keys(Mr.type)[0],typeof Mr.type[fi]=="string"?fi+=":"+Mr.type[fi]:Sc=Mr.type[fi]),ii.referencedType=Sc?_.getTypeId(Sc):-1}ii.type=fi,Oe.fields.push(ii)}ae(Oe)});for(let se in ne)ne[se].forEach(Ge=>w.types.push(Ge));return z.encodeAll(m).slice(0,m.offset)}static decode(u,m){let _=new ze;new Wt(_).decode(u,m);let z=new Le;_.types.forEach(ne=>{let ae=z.get(ne.extendsId)??Ie,he=class extends ae{};Le.register(he),z.add(he,ne.id)},{});let X=(ne,ae,he)=>{ae.fields.forEach((se,Ge)=>{let Oe=he+Ge;if(se.referencedType!==void 0){let Re=se.type,ye=z.get(se.referencedType);if(!ye){let $e=se.type.split(":");Re=$e[0],ye=$e[1]}Re==="ref"?je.addField(ne,Oe,se.name,ye):je.addField(ne,Oe,se.name,{[Re]:ye})}else je.addField(ne,Oe,se.name,se.type)})};_.types.forEach(ne=>{let ae=z.get(ne.id),he=je.initialize(ae),se=[],Ge=ne;do se.push(Ge),Ge=_.types.find(Re=>Re.id===Ge.extendsId);while(Ge);let Oe=0;se.reverse().forEach(Re=>{X(he,Re,Oe),Oe+=Re.fields.length})});let ue=new(z.get(_.rootType||0));return new Wt(ue,z)}}qe([ni([Zt])],ze.prototype,"types",void 0),qe([ni("number")],ze.prototype,"rootType",void 0);function Un(R){let u=R.root,m=u.callbacks,_=new WeakMap,w;R.triggerChanges=function(ue){let ne=new Set;for(let ae=0,he=ue.length;ae<he;ae++){let se=ue[ae],Ge=se.refId,Oe=se.ref,Re=m[Ge];if(Re){if((se.op&i.OPERATION.DELETE)===i.OPERATION.DELETE&&se.previousValue instanceof Ie){let ye=m[u.refIds.get(se.previousValue)]?.[i.OPERATION.DELETE];for(let $e=ye?.length-1;$e>=0;$e--)ye[$e]()}if(Oe instanceof Ie){if(!ne.has(Ge)){let ye=Re?.[i.OPERATION.REPLACE];for(let $e=ye?.length-1;$e>=0;$e--)ye[$e]()}if(Re.hasOwnProperty(se.field)){let ye=Re[se.field];for(let $e=ye?.length-1;$e>=0;$e--)ye[$e](se.value,se.previousValue)}}else{if((se.op&i.OPERATION.DELETE)===i.OPERATION.DELETE){if(se.previousValue!==void 0){let ye=Re[i.OPERATION.DELETE];for(let $e=ye?.length-1;$e>=0;$e--)ye[$e](se.previousValue,se.dynamicIndex??se.field)}if((se.op&i.OPERATION.ADD)===i.OPERATION.ADD){let ye=Re[i.OPERATION.ADD];for(let $e=ye?.length-1;$e>=0;$e--)ye[$e](se.value,se.dynamicIndex??se.field)}}else if((se.op&i.OPERATION.ADD)===i.OPERATION.ADD&&se.previousValue!==se.value){let ye=Re[i.OPERATION.ADD];for(let $e=ye?.length-1;$e>=0;$e--)ye[$e](se.value,se.dynamicIndex??se.field)}if(se.value!==se.previousValue&&(se.value!==void 0||se.previousValue!==void 0)){let ye=Re[i.OPERATION.REPLACE];for(let $e=ye?.length-1;$e>=0;$e--)ye[$e](se.value,se.dynamicIndex??se.field)}}ne.add(Ge)}}};function z(ue,ne){let ae=ne.instance?.constructor[Symbol.metadata]||ue,he=ne.instance&&typeof ne.instance.forEach=="function"||ue&&typeof ue[Symbol.metadata]>"u";if(ae&&!he){let se=function(Ge,Oe,Re,ye){return ye&&ne.instance[Oe]!==void 0&&!_.has(w)&&Re(ne.instance[Oe],void 0),u.addCallback(u.refIds.get(Ge),Oe,Re)};return new Proxy({listen:function(Oe,Re,ye=!0){if(ne.instance)return se(ne.instance,Oe,Re,ye);{let $e=()=>{};return ne.onInstanceAvailable((tn,nn)=>{$e=se(tn,Oe,Re,ye&&nn&&!_.has(w))}),()=>$e()}},onChange:function(Oe){return u.addCallback(u.refIds.get(ne.instance),i.OPERATION.REPLACE,Oe)},bindTo:function(Oe,Re){return Re||(Re=Object.keys(ae).map(ye=>ae[ye].name)),u.addCallback(u.refIds.get(ne.instance),i.OPERATION.REPLACE,()=>{Re.forEach(ye=>Oe[ye]=ne.instance[ye])})}},{get(Ge,Oe){let Re=ae[ae[Oe]];if(Re){let ye=ne.instance?.[Oe],$e=(tn=>{let nn=X(ne.instance).listen(Oe,(ii,fi)=>{tn(ii,!1),nn?.()},!1);u.refIds.get(ye)!==void 0&&tn(ye,!0)});return z(Re.type,{instance:u.refIds.get(ye)&&ye,parentInstance:ne.instance,onInstanceAvailable:$e})}else return Ge[Oe]},has(Ge,Oe){return ae[Oe]!==void 0},set(Ge,Oe,Re){throw new Error("not allowed")},deleteProperty(Ge,Oe){throw new Error("not allowed")}})}else{let se=function(Re,ye,$e){return $e&&Re.forEach((tn,nn)=>ye(tn,nn)),u.addCallback(u.refIds.get(Re),i.OPERATION.ADD,(tn,nn)=>{_.set(ye,!0),w=ye,ye(tn,nn),_.delete(ye),w=void 0})},Ge=function(Re,ye){return u.addCallback(u.refIds.get(Re),i.OPERATION.DELETE,ye)},Oe=function(Re,ye){return u.addCallback(u.refIds.get(Re),i.OPERATION.REPLACE,ye)};return new Proxy({onAdd:function(Re,ye=!0){if(ne.instance)return se(ne.instance,Re,ye&&!_.has(w));if(ne.onInstanceAvailable){let $e=()=>{};return ne.onInstanceAvailable((tn,nn)=>{$e=se(tn,Re,ye&&nn&&!_.has(w))}),()=>$e()}},onRemove:function(Re){if(ne.instance)return Ge(ne.instance,Re);if(ne.onInstanceAvailable){let ye=()=>{};return ne.onInstanceAvailable($e=>{ye=Ge($e,Re)}),()=>ye()}},onChange:function(Re){if(ne.instance)return Oe(ne.instance,Re);if(ne.onInstanceAvailable){let ye=()=>{};return ne.onInstanceAvailable($e=>{ye=Oe($e,Re)}),()=>ye()}}},{get(Re,ye){if(!Re[ye])throw new Error(`Can't access '${ye}' through callback proxy. access the instance directly.`);return Re[ye]},has(Re,ye){return Re[ye]!==void 0},set(Re,ye,$e){throw new Error("not allowed")},deleteProperty(Re,ye){throw new Error("not allowed")}})}}function X(ue){return z(void 0,{instance:ue})}return X}function vt(R,u){R.triggerChanges=u}class Xn{constructor(u=!1){this.iterable=u,this.visible=new WeakSet,this.invisible=new WeakSet,this.changes=new Map,u&&(this.items=[])}add(u,m=Mi,_=!0){let w=u?.[c],z=w.parent;if(w){if(!z&&w.refId!==0)throw new Error(`Cannot add a detached instance to the StateView. Make sure to assign the "${w.ref.constructor.name}" instance to the state before calling view.add()`)}else return console.warn("StateView#add(), invalid object:",u),!1;let X=u.constructor[Symbol.metadata];this.visible.add(w),this.iterable&&_&&this.items.push(u),_&&z&&this.addParentOf(w,m);let ue=this.changes.get(w.refId);ue===void 0&&(ue={},this.changes.set(w.refId,ue));let ne=!1;if(w.forEachChild((ae,he)=>{X&&X[he].tag!==void 0&&X[he].tag!==m||this.add(ae.ref,m,!1)&&(ne=!0)}),m!==Mi){this.tags||(this.tags=new WeakMap);let ae;this.tags.has(w)?ae=this.tags.get(w):(ae=new Set,this.tags.set(w,ae)),ae.add(m),X?.[g]?.[m]?.forEach(he=>{w.getChange(he)!==i.OPERATION.DELETE&&(ue[he]=i.OPERATION.ADD)})}else if(!w.isNew||ne){let ae=w.filteredChanges!==void 0?w.allFilteredChanges:w.allChanges,he=this.invisible.has(w);for(let se=0,Ge=ae.operations.length;se<Ge;se++){let Oe=ae.operations[se];if(Oe===void 0)continue;let Re=w.indexedOperations[Oe]??i.OPERATION.ADD,ye=X?.[Oe].tag;Re!==i.OPERATION.DELETE&&(he||ye===void 0||ye===m)&&(ue[Oe]=Re,ne=!0)}}return ne}addParentOf(u,m){let _=u.parent[c],w=u.parentIndex;if(!this.visible.has(_)){this.visible.add(_);let z=_.parent?.[c];z&&z.filteredChanges!==void 0&&this.addParentOf(_,m)}if(_.getChange(w)!==i.OPERATION.DELETE){let z=this.changes.get(_.refId);z===void 0&&(z={},this.changes.set(_.refId,z)),this.tags||(this.tags=new WeakMap);let X;this.tags.has(_)?X=this.tags.get(_):(X=new Set,this.tags.set(_,X)),X.add(m),z[w]=i.OPERATION.ADD}}remove(u,m=Mi,_=!1){let w=u[c];if(!w)return console.warn("StateView#remove(), invalid object:",u),this;this.visible.delete(w),this.iterable&&!_&&Ye(this.items,this.items.indexOf(u));let X=w.ref.constructor[Symbol.metadata],ue=this.changes.get(w.refId);if(ue===void 0&&(ue={},this.changes.set(w.refId,ue)),m===Mi){let ne=w.parent;if(ne&&!je.isValidInstance(ne)&&w.isFiltered){let ae=ne[c],he=this.changes.get(ae.refId);he===void 0?(he={},this.changes.set(ae.refId,he)):he[w.parentIndex]===i.OPERATION.ADD&&this.changes.delete(w.refId),he[w.parentIndex]=i.OPERATION.DELETE,this._recursiveDeleteVisibleChangeTree(w)}else X?.[b]?.forEach(ae=>ue[ae]=i.OPERATION.DELETE)}else X?.[g][m].forEach(ne=>ue[ne]=i.OPERATION.DELETE);if(this.tags&&this.tags.has(w)){let ne=this.tags.get(w);m===void 0?this.tags.delete(w):(ne.delete(m),ne.size===0&&this.tags.delete(w))}return this}has(u){return this.visible.has(u[c])}hasTag(u,m=Mi){return this.tags?.get(u[c])?.has(m)??!1}clear(){if(!this.iterable)throw new Error("StateView#clear() is only available for iterable StateView's. Use StateView(iterable: true) constructor.");for(let u=0,m=this.items.length;u<m;u++)this.remove(this.items[u],Mi,!0);this.items.length=0}isChangeTreeVisible(u){let m=this.visible.has(u);return!m&&u.isVisibilitySharedWithParent&&this.visible.has(u.parent[c])&&(this.visible.add(u),m=!0),m}_recursiveDeleteVisibleChangeTree(u){u.forEachChild(m=>{this.visible.delete(m),this._recursiveDeleteVisibleChangeTree(m)})}}ce("map",{constructor:di}),ce("array",{constructor:jn}),ce("set",{constructor:wr}),ce("collection",{constructor:sr}),i.$changes=c,i.$childType=h,i.$decoder=s,i.$deleteByIndex=l,i.$encoder=r,i.$filter=a,i.$getByIndex=o,i.$track=n,i.ArraySchema=jn,i.ChangeTree=de,i.CollectionSchema=sr,i.Decoder=Wt,i.Encoder=at,i.MapSchema=di,i.Metadata=je,i.Reflection=ze,i.ReflectionField=Mt,i.ReflectionType=Zt,i.Schema=Ie,i.SetSchema=wr,i.StateView=Xn,i.TypeContext=Le,i.decode=ge,i.decodeKeyValueOperation=$n,i.decodeSchemaOperation=Rt,i.defineCustomTypes=Be,i.defineTypes=ie,i.deprecated=j,i.dumpChanges=Fe,i.encode=oe,i.encodeArray=Xe,i.encodeKeyValueOperation=xe,i.encodeSchemaOperation=Ae,i.entity=Fu,i.getDecoderStateCallbacks=Un,i.getRawChangesCallback=vt,i.registerType=ce,i.schema=ee,i.type=ni,i.view=vc}))});var W_=dn(V_=>{"use strict";var G_=(rc(),Gs(ic)),Us=ac(),mm=class{constructor(e){this.events=e,this.isOpen=!1,this.lengthPrefixBuffer=new Uint8Array(9)}connect(e,t={}){let n=t.fingerprint&&{serverCertificateHashes:[{algorithm:"sha-256",value:new Uint8Array(t.fingerprint).buffer}]}||void 0;this.wt=new WebTransport(e,n),this.wt.ready.then(r=>{console.log("WebTransport ready!",r),this.isOpen=!0,this.unreliableReader=this.wt.datagrams.readable.getReader(),this.unreliableWriter=this.wt.datagrams.writable.getWriter(),this.wt.incomingBidirectionalStreams.getReader().read().then(a=>{this.reader=a.value.readable.getReader(),this.writer=a.value.writable.getWriter(),this.sendSeatReservation(t.room.roomId,t.sessionId,t.reconnectionToken),this.readIncomingData(),this.readIncomingUnreliableData()}).catch(a=>{console.error("failed to read incoming stream",a),console.error("TODO: close the connection")})}).catch(r=>{console.log("WebTransport not ready!",r),this._close()}),this.wt.closed.then(r=>{console.log("WebTransport closed w/ success",r),this.events.onclose({code:r.closeCode,reason:r.reason})}).catch(r=>{console.log("WebTransport closed w/ error",r),this.events.onerror(r),this.events.onclose({code:r.closeCode,reason:r.reason})}).finally(()=>{this._close()})}send(e){let t=Us.encode.number(this.lengthPrefixBuffer,e.length,{offset:0}),n=new Uint8Array(t+e.length);n.set(this.lengthPrefixBuffer.subarray(0,t),0),n.set(e,t),this.writer.write(n)}sendUnreliable(e){let t=Us.encode.number(this.lengthPrefixBuffer,e.length,{offset:0}),n=new Uint8Array(t+e.length);n.set(this.lengthPrefixBuffer.subarray(0,t),0),n.set(e,t),this.unreliableWriter.write(n)}close(e,t){try{this.wt.close({closeCode:e,reason:t})}catch(n){console.error(n)}}readIncomingData(){return G_.__awaiter(this,void 0,void 0,function*(){let e;for(;this.isOpen;){try{e=yield this.reader.read();let t=e.value,n={offset:0};do{let r=Us.decode.number(t,n);this.events.onmessage({data:t.subarray(n.offset,n.offset+r)}),n.offset+=r}while(n.offset<t.length)}catch(t){t.message.indexOf("session is closed")===-1&&console.error("H3Transport: failed to read incoming data",t);break}if(e.done)break}})}readIncomingUnreliableData(){return G_.__awaiter(this,void 0,void 0,function*(){let e;for(;this.isOpen;){try{e=yield this.unreliableReader.read();let t=e.value,n={offset:0};do{let r=Us.decode.number(t,n);this.events.onmessage({data:t.subarray(n.offset,n.offset+r)}),n.offset+=r}while(n.offset<t.length)}catch(t){t.message.indexOf("session is closed")===-1&&console.error("H3Transport: failed to read incoming data",t);break}if(e.done)break}})}sendSeatReservation(e,t,n){let r={offset:0},s=[];Us.encode.string(s,e,r),Us.encode.string(s,t,r),n&&Us.encode.string(s,n,r),this.writer.write(new Uint8Array(s).buffer)}_close(){this.isOpen=!1}};V_.H3TransportTransport=mm});var $_=dn((wL,q_)=>{"use strict";q_.exports=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}});var X_=dn(j_=>{"use strict";var ER=$_(),gm=globalThis.WebSocket||ER,bm=class{constructor(e){this.events=e}send(e){this.ws.send(e)}sendUnreliable(e){console.warn("colyseus.js: The WebSocket transport does not support unreliable messages")}connect(e,t){try{this.ws=new gm(e,{headers:t,protocols:this.protocols})}catch{this.ws=new gm(e,this.protocols)}this.ws.binaryType="arraybuffer",this.ws.onopen=this.events.onopen,this.ws.onmessage=this.events.onmessage,this.ws.onclose=this.events.onclose,this.ws.onerror=this.events.onerror}close(e,t){this.ws.close(e,t)}get isOpen(){return this.ws.readyState===gm.OPEN}};j_.WebSocketTransport=bm});var Y_=dn(K_=>{"use strict";var RR=W_(),CR=X_(),xm=class{constructor(e){this.events={},e==="h3"?this.transport=new RR.H3TransportTransport(this.events):this.transport=new CR.WebSocketTransport(this.events)}connect(e,t){this.transport.connect.call(this.transport,e,t)}send(e){this.transport.send(e)}sendUnreliable(e){this.transport.sendUnreliable(e)}close(e,t){this.transport.close(e,t)}get isOpen(){return this.transport.isOpen}};K_.Connection=xm});var _m=dn(ks=>{"use strict";ks.Protocol=void 0;(function(i){i[i.HANDSHAKE=9]="HANDSHAKE",i[i.JOIN_ROOM=10]="JOIN_ROOM",i[i.ERROR=11]="ERROR",i[i.LEAVE_ROOM=12]="LEAVE_ROOM",i[i.ROOM_DATA=13]="ROOM_DATA",i[i.ROOM_STATE=14]="ROOM_STATE",i[i.ROOM_STATE_PATCH=15]="ROOM_STATE_PATCH",i[i.ROOM_DATA_SCHEMA=16]="ROOM_DATA_SCHEMA",i[i.ROOM_DATA_BYTES=17]="ROOM_DATA_BYTES"})(ks.Protocol||(ks.Protocol={}));ks.ErrorCode=void 0;(function(i){i[i.MATCHMAKE_NO_HANDLER=4210]="MATCHMAKE_NO_HANDLER",i[i.MATCHMAKE_INVALID_CRITERIA=4211]="MATCHMAKE_INVALID_CRITERIA",i[i.MATCHMAKE_INVALID_ROOM_ID=4212]="MATCHMAKE_INVALID_ROOM_ID",i[i.MATCHMAKE_UNHANDLED=4213]="MATCHMAKE_UNHANDLED",i[i.MATCHMAKE_EXPIRED=4214]="MATCHMAKE_EXPIRED",i[i.AUTH_FAILED=4215]="AUTH_FAILED",i[i.APPLICATION_ERROR=4216]="APPLICATION_ERROR"})(ks.ErrorCode||(ks.ErrorCode={}))});var vm=dn(ym=>{"use strict";var J_={};function IR(i,e){J_[i]=e}function PR(i){let e=J_[i];if(!e)throw new Error("missing serializer: "+i);return e}ym.getSerializer=PR;ym.registerSerializer=IR});var Sm=dn(Z_=>{"use strict";var LR=()=>({emit(i,...e){let t=this.events[i]||[];for(let n=0,r=t.length;n<r;n++)t[n](...e)},events:{},on(i,e){var t;return!((t=this.events[i])===null||t===void 0)&&t.push(e)||(this.events[i]=[e]),()=>{var n;this.events[i]=(n=this.events[i])===null||n===void 0?void 0:n.filter(r=>e!==r)}}});Z_.createNanoEvents=LR});var Q_=dn(wm=>{"use strict";var gu=class{constructor(){this.handlers=[]}register(e,t=!1){return this.handlers.push(e),this}invoke(...e){this.handlers.forEach(t=>t.apply(this,e))}invokeAsync(...e){return Promise.all(this.handlers.map(t=>t.apply(this,e)))}remove(e){let t=this.handlers.indexOf(e);this.handlers[t]=this.handlers[this.handlers.length-1],this.handlers.pop()}clear(){this.handlers=[]}};function DR(){let i=new gu;function e(t){return i.register(t,this===null)}return e.once=t=>{let n=function(...r){t.apply(this,r),i.remove(n)};i.register(n)},e.remove=t=>i.remove(t),e.invoke=(...t)=>i.invoke(...t),e.invokeAsync=(...t)=>i.invokeAsync(...t),e.clear=()=>i.clear(),e}wm.EventEmitter=gu;wm.createSignal=DR});var Tm=dn(Am=>{"use strict";var bu=ac();function NR(i){try{return bu.getDecoderStateCallbacks(i.serializer.decoder)}catch{return}}var Mm=class{setState(e,t){this.decoder.decode(e,t)}getState(){return this.state}patch(e,t){return this.decoder.decode(e,t)}teardown(){this.decoder.root.clearRefs()}handshake(e,t){this.state?(bu.Reflection.decode(e,t),this.decoder=new bu.Decoder(this.state)):(this.decoder=bu.Reflection.decode(e,t),this.state=this.decoder.state)}};Am.SchemaSerializer=Mm;Am.getStateCallbacks=NR});function xu(i){try{if(!Gt.trusted&&!Qr){let t=St.sharedLength||0;t<St.length&&(St.length=t)}let e;if(Gt.randomAccessStructure&&Ne[$]<64&&Ne[$]>=32&&ty?(e=ty(Ne,$,Si,Gt),Ne=null,!(i&&i.lazy)&&e&&(e=e.toJSON()),$=Si):e=ln(),wn&&($=wn.postBundlePosition,wn=null),Qr&&(St.restoreStructures=null),$==Si)St&&St.restoreStructures&&ry(),St=null,Ne=null,yr&&(yr=null);else{if($>Si)throw new Error("Unexpected end of MessagePack data");if(!Qr){let t;try{t=JSON.stringify(e,(n,r)=>typeof r=="bigint"?`${r}n`:r).slice(0,100)}catch(n){t="(JSON view not available "+n+")"}throw new Error("Data read, but end of buffer not reached "+t)}}return e}catch(e){throw St&&St.restoreStructures&&ry(),lc(),(e instanceof RangeError||e.message.startsWith("Unexpected end of buffer")||$>Si)&&(e.incomplete=!0),e}}function ry(){for(let i in St.restoreStructures)St[i]=St.restoreStructures[i];St.restoreStructures=null}function ln(){let i=Ne[$++];if(i<160)if(i<128){if(i<64)return i;{let e=St[i&63]||Gt.getStructures&&py()[i&63];return e?(e.read||(e.read=Lm(e,i&63)),e.read()):i}}else if(i<144)if(i-=128,Gt.mapsAsObjects){let e={};for(let t=0;t<i;t++){let n=by();n==="__proto__"&&(n="__proto_"),e[n]=ln()}return e}else{let e=new Map;for(let t=0;t<i;t++)e.set(ln(),ln());return e}else{i-=144;let e=new Array(i);for(let t=0;t<i;t++)e[t]=ln();return Gt.freezeData?Object.freeze(e):e}else if(i<192){let e=i-160;if(ir>=$)return Zr.slice($-vi,($+=e)-vi);if(ir==0&&Si<140){let t=e<16?Dm(e):gy(e);if(t!=null)return t}return Pm(e)}else{let e;switch(i){case 192:return null;case 193:return wn?(e=ln(),e>0?wn[1].slice(wn.position1,wn.position1+=e):wn[0].slice(wn.position0,wn.position0-=e)):_u;case 194:return!1;case 195:return!0;case 196:if(e=Ne[$++],e===void 0)throw new Error("Unexpected end of buffer");return Em(e);case 197:return e=yt.getUint16($),$+=2,Em(e);case 198:return e=yt.getUint32($),$+=4,Em(e);case 199:return Bs(Ne[$++]);case 200:return e=yt.getUint16($),$+=2,Bs(e);case 201:return e=yt.getUint32($),$+=4,Bs(e);case 202:if(e=yt.getFloat32($),Gt.useFloat32>2){let t=uc[(Ne[$]&127)<<1|Ne[$+1]>>7];return $+=4,(t*e+(e>0?.5:-.5)>>0)/t}return $+=4,e;case 203:return e=yt.getFloat64($),$+=8,e;case 204:return Ne[$++];case 205:return e=yt.getUint16($),$+=2,e;case 206:return e=yt.getUint32($),$+=4,e;case 207:return Gt.int64AsType==="number"?(e=yt.getUint32($)*4294967296,e+=yt.getUint32($+4)):Gt.int64AsType==="string"?e=yt.getBigUint64($).toString():Gt.int64AsType==="auto"?(e=yt.getBigUint64($),e<=BigInt(2)<<BigInt(52)&&(e=Number(e))):e=yt.getBigUint64($),$+=8,e;case 208:return yt.getInt8($++);case 209:return e=yt.getInt16($),$+=2,e;case 210:return e=yt.getInt32($),$+=4,e;case 211:return Gt.int64AsType==="number"?(e=yt.getInt32($)*4294967296,e+=yt.getUint32($+4)):Gt.int64AsType==="string"?e=yt.getBigInt64($).toString():Gt.int64AsType==="auto"?(e=yt.getBigInt64($),e>=BigInt(-2)<<BigInt(52)&&e<=BigInt(2)<<BigInt(52)&&(e=Number(e))):e=yt.getBigInt64($),$+=8,e;case 212:if(e=Ne[$++],e==114)return hy(Ne[$++]&63);{let t=On[e];if(t)return t.read?($++,t.read(ln())):t.noBuffer?($++,t()):t(Ne.subarray($,++$));throw new Error("Unknown extension "+e)}case 213:return e=Ne[$],e==114?($++,hy(Ne[$++]&63,Ne[$++])):Bs(2);case 214:return Bs(4);case 215:return Bs(8);case 216:return Bs(16);case 217:return e=Ne[$++],ir>=$?Zr.slice($-vi,($+=e)-vi):FR(e);case 218:return e=yt.getUint16($),$+=2,ir>=$?Zr.slice($-vi,($+=e)-vi):UR(e);case 219:return e=yt.getUint32($),$+=4,ir>=$?Zr.slice($-vi,($+=e)-vi):kR(e);case 220:return e=yt.getUint16($),$+=2,ay(e);case 221:return e=yt.getUint32($),$+=4,ay(e);case 222:return e=yt.getUint16($),$+=2,oy(e);case 223:return e=yt.getUint32($),$+=4,oy(e);default:if(i>=224)return i-256;if(i===void 0){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}throw new Error("Unknown MessagePack token "+i)}}}function Lm(i,e){function t(){if(t.count++>fy){let r=i.read=new Function("r","return function(){return "+(Gt.freezeData?"Object.freeze":"")+"({"+i.map(s=>s==="__proto__"?"__proto_:r()":OR.test(s)?s+":r()":"["+JSON.stringify(s)+"]:r()").join(",")+"})}")(ln);return i.highByte===0&&(i.read=sy(e,i.read)),r()}let n={};for(let r=0,s=i.length;r<s;r++){let a=i[r];a==="__proto__"&&(a="__proto_"),n[a]=ln()}return Gt.freezeData?Object.freeze(n):n}return t.count=0,i.highByte===0?sy(e,t):t}function py(){let i=_y(()=>(Ne=null,Gt.getStructures()));return St=Gt._mergeStructures(i,St)}function hc(i){let e;if(i<16&&(e=Dm(i)))return e;if(i>64&&Rm)return Rm.decode(Ne.subarray($,$+=i));let t=$+i,n=[];for(e="";$<t;){let r=Ne[$++];if((r&128)===0)n.push(r);else if((r&224)===192){let s=Ne[$++]&63;n.push((r&31)<<6|s)}else if((r&240)===224){let s=Ne[$++]&63,a=Ne[$++]&63;n.push((r&31)<<12|s<<6|a)}else if((r&248)===240){let s=Ne[$++]&63,a=Ne[$++]&63,o=Ne[$++]&63,l=(r&7)<<18|s<<12|a<<6|o;l>65535&&(l-=65536,n.push(l>>>10&1023|55296),l=56320|l&1023),n.push(l)}else n.push(r);n.length>=4096&&(e+=Sn.apply(String,n),n.length=0)}return n.length>0&&(e+=Sn.apply(String,n)),e}function ay(i){let e=new Array(i);for(let t=0;t<i;t++)e[t]=ln();return Gt.freezeData?Object.freeze(e):e}function oy(i){if(Gt.mapsAsObjects){let e={};for(let t=0;t<i;t++){let n=by();n==="__proto__"&&(n="__proto_"),e[n]=ln()}return e}else{let e=new Map;for(let t=0;t<i;t++)e.set(ln(),ln());return e}}function gy(i){let e=$,t=new Array(i);for(let n=0;n<i;n++){let r=Ne[$++];if((r&128)>0){$=e;return}t[n]=r}return Sn.apply(String,t)}function Dm(i){if(i<4)if(i<2){if(i===0)return"";{let e=Ne[$++];if((e&128)>1){$-=1;return}return Sn(e)}}else{let e=Ne[$++],t=Ne[$++];if((e&128)>0||(t&128)>0){$-=2;return}if(i<3)return Sn(e,t);let n=Ne[$++];if((n&128)>0){$-=3;return}return Sn(e,t,n)}else{let e=Ne[$++],t=Ne[$++],n=Ne[$++],r=Ne[$++];if((e&128)>0||(t&128)>0||(n&128)>0||(r&128)>0){$-=4;return}if(i<6){if(i===4)return Sn(e,t,n,r);{let s=Ne[$++];if((s&128)>0){$-=5;return}return Sn(e,t,n,r,s)}}else if(i<8){let s=Ne[$++],a=Ne[$++];if((s&128)>0||(a&128)>0){$-=6;return}if(i<7)return Sn(e,t,n,r,s,a);let o=Ne[$++];if((o&128)>0){$-=7;return}return Sn(e,t,n,r,s,a,o)}else{let s=Ne[$++],a=Ne[$++],o=Ne[$++],l=Ne[$++];if((s&128)>0||(a&128)>0||(o&128)>0||(l&128)>0){$-=8;return}if(i<10){if(i===8)return Sn(e,t,n,r,s,a,o,l);{let c=Ne[$++];if((c&128)>0){$-=9;return}return Sn(e,t,n,r,s,a,o,l,c)}}else if(i<12){let c=Ne[$++],h=Ne[$++];if((c&128)>0||(h&128)>0){$-=10;return}if(i<11)return Sn(e,t,n,r,s,a,o,l,c,h);let d=Ne[$++];if((d&128)>0){$-=11;return}return Sn(e,t,n,r,s,a,o,l,c,h,d)}else{let c=Ne[$++],h=Ne[$++],d=Ne[$++],f=Ne[$++];if((c&128)>0||(h&128)>0||(d&128)>0||(f&128)>0){$-=12;return}if(i<14){if(i===12)return Sn(e,t,n,r,s,a,o,l,c,h,d,f);{let p=Ne[$++];if((p&128)>0){$-=13;return}return Sn(e,t,n,r,s,a,o,l,c,h,d,f,p)}}else{let p=Ne[$++],x=Ne[$++];if((p&128)>0||(x&128)>0){$-=14;return}if(i<15)return Sn(e,t,n,r,s,a,o,l,c,h,d,f,p,x);let y=Ne[$++];if((y&128)>0){$-=15;return}return Sn(e,t,n,r,s,a,o,l,c,h,d,f,p,x,y)}}}}}function cy(){let i=Ne[$++],e;if(i<192)e=i-160;else switch(i){case 217:e=Ne[$++];break;case 218:e=yt.getUint16($),$+=2;break;case 219:e=yt.getUint32($),$+=4;break;default:throw new Error("Expected string")}return hc(e)}function Em(i){return Gt.copyBuffers?Uint8Array.prototype.slice.call(Ne,$,$+=i):Ne.subarray($,$+=i)}function Bs(i){let e=Ne[$++];if(On[e]){let t;return On[e](Ne.subarray($,t=$+=i),n=>{$=n;try{return ln()}finally{$=t}})}else throw new Error("Unknown extension type "+e)}function by(){let i=Ne[$++];if(i>=160&&i<192){if(i=i-160,ir>=$)return Zr.slice($-vi,($+=i)-vi);if(!(ir==0&&Si<180))return Pm(i)}else return $--,xy(ln());let e=(i<<5^(i>1?yt.getUint16($):i>0?Ne[$]:0))&4095,t=ly[e],n=$,r=$+i-3,s,a=0;if(t&&t.bytes==i){for(;n<r;){if(s=yt.getUint32(n),s!=t[a++]){n=1879048192;break}n+=4}for(r+=3;n<r;)if(s=Ne[n++],s!=t[a++]){n=1879048192;break}if(n===r)return $=n,t.string;r-=3,n=$}for(t=[],ly[e]=t,t.bytes=i;n<r;)s=yt.getUint32(n),t.push(s),n+=4;for(r+=3;n<r;)s=Ne[n++],t.push(s);let o=i<16?Dm(i):gy(i);return o!=null?t.string=o:t.string=Pm(i)}function xy(i){if(typeof i=="string")return i;if(typeof i=="number"||typeof i=="boolean"||typeof i=="bigint")return i.toString();if(i==null)return i+"";if(Gt.allowArraysInMapKeys&&Array.isArray(i)&&i.flat().every(e=>["string","number","boolean","bigint"].includes(typeof e)))return i.flat().toString();throw new Error(`Invalid property type for record: ${typeof i}`)}function _y(i){iy&&iy();let e=Si,t=$,n=Im,r=vi,s=ir,a=Zr,o=Cm,l=yr,c=wn,h=new Uint8Array(Ne.slice(0,Si)),d=St,f=St.slice(0,St.length),p=Gt,x=Qr,y=i();return Si=e,$=t,Im=n,vi=r,ir=s,Zr=a,Cm=o,yr=l,wn=c,Ne=h,Qr=x,St=d,St.splice(0,St.length,...f),Gt=p,yt=new DataView(Ne.buffer,Ne.byteOffset,Ne.byteLength),y}function lc(){Ne=null,yr=null,St=null}function yy(i){i.unpack?On[i.type]=i.unpack:On[i.type]=i}function Ty(i){Ay[0]=i;let e=uc[(uy[3]&127)<<1|uy[2]>>7];return(e*i+(i>0?.5:-.5)>>0)/e}var Rm,Ne,Si,$,dy,Cm,Im,Gt,St,Zr,vi,ir,wn,yr,On,yt,ey,oc,_u,Qr,fy,ty,ny,iy,rr,OR,sy,Pm,FR,UR,kR,my,Sn,ly,hy,BR,Nm,zR,HR,uc,vy,yu,Sy,wy,My,dc,Ay,uy,Fa=un(()=>{try{Rm=new TextDecoder}catch{}$=0,dy=[],Cm=dy,Im=0,Gt={},vi=0,ir=0,On=[],ey={useRecords:!1,mapsAsObjects:!0},oc=class{},_u=new oc;_u.name="MessagePack 0xC1";Qr=!1,fy=2;try{new Function("")}catch{fy=1/0}rr=class i{constructor(e){e&&(e.useRecords===!1&&e.mapsAsObjects===void 0&&(e.mapsAsObjects=!0),e.sequential&&e.trusted!==!1&&(e.trusted=!0,!e.structures&&e.useRecords!=!1&&(e.structures=[],e.maxSharedStructures||(e.maxSharedStructures=0))),e.structures?e.structures.sharedLength=e.structures.length:e.getStructures&&((e.structures=[]).uninitialized=!0,e.structures.sharedLength=0),e.int64AsNumber&&(e.int64AsType="number")),Object.assign(this,e)}unpack(e,t){if(Ne)return _y(()=>(lc(),this?this.unpack(e,t):i.prototype.unpack.call(ey,e,t)));!e.buffer&&e.constructor===ArrayBuffer&&(e=typeof Buffer<"u"?Buffer.from(e):new Uint8Array(e)),typeof t=="object"?(Si=t.end||e.length,$=t.start||0):($=0,Si=t>-1?t:e.length),Im=0,ir=0,Zr=null,Cm=dy,wn=null,Ne=e;try{yt=e.dataView||(e.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength))}catch(n){throw Ne=null,e instanceof Uint8Array?n:new Error("Source must be a Uint8Array or Buffer but was a "+(e&&typeof e=="object"?e.constructor.name:typeof e))}if(this instanceof i){if(Gt=this,this.structures)return St=this.structures,xu(t);(!St||St.length>0)&&(St=[])}else Gt=ey,(!St||St.length>0)&&(St=[]);return xu(t)}unpackMultiple(e,t){let n,r=0;try{Qr=!0;let s=e.length,a=this?this.unpack(e,s):yu.unpack(e,s);if(t){if(t(a,r,$)===!1)return;for(;$<s;)if(r=$,t(xu(),r,$)===!1)return}else{for(n=[a];$<s;)r=$,n.push(xu());return n}}catch(s){throw s.lastPosition=r,s.values=n,s}finally{Qr=!1,lc()}}_mergeStructures(e,t){ny&&(e=ny.call(this,e)),e=e||[],Object.isFrozen(e)&&(e=e.map(n=>n.slice(0)));for(let n=0,r=e.length;n<r;n++){let s=e[n];s&&(s.isShared=!0,n>=32&&(s.highByte=n-32>>5))}e.sharedLength=e.length;for(let n in t||[])if(n>=0){let r=e[n],s=t[n];s&&(r&&((e.restoreStructures||(e.restoreStructures=[]))[n]=r),e[n]=s)}return this.structures=e}decode(e,t){return this.unpack(e,t)}};OR=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;sy=(i,e)=>function(){let t=Ne[$++];if(t===0)return e();let n=i<32?-(i+(t<<5)):i+(t<<5),r=St[n]||py()[n];if(!r)throw new Error("Record id is not defined for "+n);return r.read||(r.read=Lm(r,i)),r.read()};Pm=hc,FR=hc,UR=hc,kR=hc,my=!1;Sn=String.fromCharCode;ly=new Array(4096);hy=(i,e)=>{let t=ln().map(xy),n=i;e!==void 0&&(i=i<32?-((e<<5)+i):(e<<5)+i,t.highByte=e);let r=St[i];return r&&(r.isShared||Qr)&&((St.restoreStructures||(St.restoreStructures=[]))[i]=r),St[i]=t,t.read=Lm(t,n),t.read()};On[0]=()=>{};On[0].noBuffer=!0;On[66]=i=>{let e=i.length,t=BigInt(i[0]&128?i[0]-256:i[0]);for(let n=1;n<e;n++)t<<=BigInt(8),t+=BigInt(i[n]);return t};BR={Error,TypeError,ReferenceError};On[101]=()=>{let i=ln();return(BR[i[0]]||Error)(i[1],{cause:i[2]})};On[105]=i=>{if(Gt.structuredClone===!1)throw new Error("Structured clone extension is disabled");let e=yt.getUint32($-4);yr||(yr=new Map);let t=Ne[$],n;t>=144&&t<160||t==220||t==221?n=[]:n={};let r={target:n};yr.set(e,r);let s=ln();return r.used?Object.assign(n,s):(r.target=s,s)};On[112]=i=>{if(Gt.structuredClone===!1)throw new Error("Structured clone extension is disabled");let e=yt.getUint32($-4),t=yr.get(e);return t.used=!0,t.target};On[115]=()=>new Set(ln());Nm=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(i=>i+"Array"),zR=typeof globalThis=="object"?globalThis:window;On[116]=i=>{let e=i[0],t=Nm[e];if(!t){if(e===16){let n=new ArrayBuffer(i.length-1);return new Uint8Array(n).set(i.subarray(1)),n}throw new Error("Could not find typed array for code "+e)}return new zR[t](Uint8Array.prototype.slice.call(i,1).buffer)};On[120]=()=>{let i=ln();return new RegExp(i[0],i[1])};HR=[];On[98]=i=>{let e=(i[0]<<24)+(i[1]<<16)+(i[2]<<8)+i[3],t=$;return $+=e-i.length,wn=HR,wn=[cy(),cy()],wn.position0=0,wn.position1=0,wn.postBundlePosition=$,$=t,ln()};On[255]=i=>i.length==4?new Date((i[0]*16777216+(i[1]<<16)+(i[2]<<8)+i[3])*1e3):i.length==8?new Date(((i[0]<<22)+(i[1]<<14)+(i[2]<<6)+(i[3]>>2))/1e6+((i[3]&3)*4294967296+i[4]*16777216+(i[5]<<16)+(i[6]<<8)+i[7])*1e3):i.length==12?new Date(((i[0]<<24)+(i[1]<<16)+(i[2]<<8)+i[3])/1e6+((i[4]&128?-281474976710656:0)+i[6]*1099511627776+i[7]*4294967296+i[8]*16777216+(i[9]<<16)+(i[10]<<8)+i[11])*1e3):new Date("invalid");uc=new Array(147);for(let i=0;i<256;i++)uc[i]=+("1e"+Math.floor(45.15-i*.30103));vy=rr,yu=new rr({useRecords:!1}),Sy=yu.unpack,wy=yu.unpackMultiple,My=yu.unpack,dc={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},Ay=new Float32Array(1),uy=new Uint8Array(Ay.buffer,0,4)});function Ry(i,e,t,n){let r=i.byteLength;if(r+1<256){var{target:s,position:a}=t(4+r);s[a++]=199,s[a++]=r+1}else if(r+1<65536){var{target:s,position:a}=t(5+r);s[a++]=200,s[a++]=r+1>>8,s[a++]=r+1&255}else{var{target:s,position:a,targetView:o}=t(7+r);s[a++]=201,o.setUint32(a,r+1),a+=4}s[a++]=116,s[a++]=e,i.buffer||(i=new Uint8Array(i)),s.set(new Uint8Array(i.buffer,i.byteOffset,i.byteLength),a)}function Cy(i,e){let t=i.byteLength;var n,r;if(t<256){var{target:n,position:r}=e(t+2);n[r++]=196,n[r++]=t}else if(t<65536){var{target:n,position:r}=e(t+3);n[r++]=197,n[r++]=t>>8,n[r++]=t&255}else{var{target:n,position:r,targetView:s}=e(t+5);n[r++]=198,s.setUint32(r,t),r+=4}n.set(i,r)}function qR(i,e,t,n){let r=i.length;switch(r){case 1:e[t++]=212;break;case 2:e[t++]=213;break;case 4:e[t++]=214;break;case 8:e[t++]=215;break;case 16:e[t++]=216;break;default:r<256?(e[t++]=199,e[t++]=r):r<65536?(e[t++]=200,e[t++]=r>>8,e[t++]=r&255):(e[t++]=201,e[t++]=r>>24,e[t++]=r>>16&255,e[t++]=r>>8&255,e[t++]=r&255)}return e[t++]=n,e.set(i,t),t+=r,t}function $R(i,e){let t,n=e.length*6,r=i.length-n;for(;t=e.pop();){let s=t.offset,a=t.id;i.copyWithin(s+n,s,r),n-=6;let o=s+n;i[o++]=214,i[o++]=105,i[o++]=a>>24,i[o++]=a>>16&255,i[o++]=a>>8&255,i[o++]=a&255,r=s}return i}function Iy(i,e,t){if(en.length>0){Vt.setUint32(en.position+i,K+t-en.position-i),en.stringsPosition=K-i;let n=en;en=null,e(n[0]),e(n[1])}}function Ly(i){if(i.Class){if(!i.pack&&!i.write)throw new Error("Extension has no pack or write function");if(i.pack&&!i.type)throw new Error("Extension has no type (numeric code to identify the extension)");Om.unshift(i.Class),wu.unshift(i)}yy(i)}function jR(i,e){return i.isCompatible=t=>{let n=!t||(e.lastNamedStructuresLength||0)===t.length;return n||e._mergeStructures(t),n},i}var Su,wu,Om,Mu,vu,Py,Ey,te,fc,Vt,K,qn,en,GR,VR,WR,Ua,vr,Dy,Ny,Oy,Fy,Uy,ky,By,zy,Fm,Um,km,Bm=un(()=>{Fa();Fa();Fa();try{Su=new TextEncoder}catch{}Mu=typeof Buffer<"u",vu=Mu?function(i){return Buffer.allocUnsafeSlow(i)}:Uint8Array,Py=Mu?Buffer:Uint8Array,Ey=Mu?4294967296:2144337920,K=0,en=null,VR=21760,WR=/[\u0080-\uFFFF]/,Ua=Symbol("record-id"),vr=class extends rr{constructor(e){super(e),this.offset=0;let t,n,r,s,a,o=Py.prototype.utf8Write?function(L,E){return te.utf8Write(L,E,te.byteLength-E)}:Su&&Su.encodeInto?function(L,E){return Su.encodeInto(L,te.subarray(E)).written}:!1,l=this;e||(e={});let c=e&&e.sequential,h=e.structures||e.saveStructures,d=e.maxSharedStructures;if(d==null&&(d=h?32:0),d>8160)throw new Error("Maximum maxSharedStructure is 8160");e.structuredClone&&e.moreTypes==null&&(this.moreTypes=!0);let f=e.maxOwnStructures;f==null&&(f=h?32:64),!this.structures&&e.useRecords!=!1&&(this.structures=[]);let p=d>32||f+d>64,x=d+64,y=d+f+64;if(y>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let b=[],g=0,S=0;this.pack=this.encode=function(L,E){if(te||(te=new vu(8192),Vt=te.dataView||(te.dataView=new DataView(te.buffer,0,8192)),K=0),qn=te.length-10,qn-K<2048?(te=new vu(te.length),Vt=te.dataView||(te.dataView=new DataView(te.buffer,0,te.length)),qn=te.length-10,K=0):K=K+7&2147483640,n=K,E&km&&(K+=E&255),a=l.structuredClone?new Map:null,l.bundleStrings&&typeof L!="string"?(en=[],en.size=1/0):en=null,s=l.structures,s){s.uninitialized&&(s=l._mergeStructures(l.getStructures()));let O=s.sharedLength||0;if(O>d)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+s.sharedLength);if(!s.transitions){s.transitions=Object.create(null);for(let H=0;H<O;H++){let Y=s[H];if(!Y)continue;let le,fe=s.transitions;for(let be=0,Te=Y.length;be<Te;be++){let Je=Y[be];le=fe[Je],le||(le=fe[Je]=Object.create(null)),fe=le}fe[Ua]=H+64}this.lastNamedStructuresLength=O}c||(s.nextId=O+64)}r&&(r=!1);let D;try{l.randomAccessStructure&&L&&L.constructor&&L.constructor===Object?J(L):N(L);let O=en;if(en&&Iy(n,N,0),a&&a.idsToInsert){let H=a.idsToInsert.sort((be,Te)=>be.offset>Te.offset?1:-1),Y=H.length,le=-1;for(;O&&Y>0;){let be=H[--Y].offset+n;be<O.stringsPosition+n&&le===-1&&(le=0),be>O.position+n?le>=0&&(le+=6):(le>=0&&(Vt.setUint32(O.position+n,Vt.getUint32(O.position+n)+le),le=-1),O=O.previous,Y++)}le>=0&&O&&Vt.setUint32(O.position+n,Vt.getUint32(O.position+n)+le),K+=H.length*6,K>qn&&B(K),l.offset=K;let fe=$R(te.subarray(n,K),H);return a=null,fe}return l.offset=K,E&Fm?(te.start=n,te.end=K,te):te.subarray(n,K)}catch(O){throw D=O,O}finally{if(s&&(A(),r&&l.saveStructures)){let O=s.sharedLength||0,H=te.subarray(n,K),Y=jR(s,l);if(!D)return l.saveStructures(Y,Y.isCompatible)===!1?l.pack(L,E):(l.lastNamedStructuresLength=O,te.length>1073741824&&(te=null),H)}te.length>1073741824&&(te=null),E&Um&&(K=n)}};let A=()=>{S<10&&S++;let L=s.sharedLength||0;if(s.length>L&&!c&&(s.length=L),g>1e4)s.transitions=null,S=0,g=0,b.length>0&&(b=[]);else if(b.length>0&&!c){for(let E=0,D=b.length;E<D;E++)b[E][Ua]=0;b=[]}},T=L=>{var E=L.length;E<16?te[K++]=144|E:E<65536?(te[K++]=220,te[K++]=E>>8,te[K++]=E&255):(te[K++]=221,Vt.setUint32(K,E),K+=4);for(let D=0;D<E;D++)N(L[D])},N=L=>{K>qn&&(te=B(K));var E=typeof L,D;if(E==="string"){let O=L.length;if(en&&O>=4&&O<4096){if((en.size+=O)>VR){let fe,be=(en[0]?en[0].length*3+en[1].length:0)+10;K+be>qn&&(te=B(K+be));let Te;en.position?(Te=en,te[K]=200,K+=3,te[K++]=98,fe=K-n,K+=4,Iy(n,N,0),Vt.setUint16(fe+n-3,K-n-fe)):(te[K++]=214,te[K++]=98,fe=K-n,K+=4),en=["",""],en.previous=Te,en.size=0,en.position=fe}let le=WR.test(L);en[le?0:1]+=L,te[K++]=193,N(le?-O:O);return}let H;O<32?H=1:O<256?H=2:O<65536?H=3:H=5;let Y=O*3;if(K+Y>qn&&(te=B(K+Y)),O<64||!o){let le,fe,be,Te=K+H;for(le=0;le<O;le++)fe=L.charCodeAt(le),fe<128?te[Te++]=fe:fe<2048?(te[Te++]=fe>>6|192,te[Te++]=fe&63|128):(fe&64512)===55296&&((be=L.charCodeAt(le+1))&64512)===56320?(fe=65536+((fe&1023)<<10)+(be&1023),le++,te[Te++]=fe>>18|240,te[Te++]=fe>>12&63|128,te[Te++]=fe>>6&63|128,te[Te++]=fe&63|128):(te[Te++]=fe>>12|224,te[Te++]=fe>>6&63|128,te[Te++]=fe&63|128);D=Te-K-H}else D=o(L,K+H);D<32?te[K++]=160|D:D<256?(H<2&&te.copyWithin(K+2,K+1,K+1+D),te[K++]=217,te[K++]=D):D<65536?(H<3&&te.copyWithin(K+3,K+2,K+2+D),te[K++]=218,te[K++]=D>>8,te[K++]=D&255):(H<5&&te.copyWithin(K+5,K+3,K+3+D),te[K++]=219,Vt.setUint32(K,D),K+=4),K+=D}else if(E==="number")if(L>>>0===L)L<32||L<128&&this.useRecords===!1||L<64&&!this.randomAccessStructure?te[K++]=L:L<256?(te[K++]=204,te[K++]=L):L<65536?(te[K++]=205,te[K++]=L>>8,te[K++]=L&255):(te[K++]=206,Vt.setUint32(K,L),K+=4);else if(L>>0===L)L>=-32?te[K++]=256+L:L>=-128?(te[K++]=208,te[K++]=L+256):L>=-32768?(te[K++]=209,Vt.setInt16(K,L),K+=2):(te[K++]=210,Vt.setInt32(K,L),K+=4);else{let O;if((O=this.useFloat32)>0&&L<4294967296&&L>=-2147483648){te[K++]=202,Vt.setFloat32(K,L);let H;if(O<4||(H=L*uc[(te[K]&127)<<1|te[K+1]>>7])>>0===H){K+=4;return}else K--}te[K++]=203,Vt.setFloat64(K,L),K+=8}else if(E==="object"||E==="function")if(!L)te[K++]=192;else{if(a){let H=a.get(L);if(H){if(!H.id){let Y=a.idsToInsert||(a.idsToInsert=[]);H.id=Y.push(H)}te[K++]=214,te[K++]=112,Vt.setUint32(K,H.id),K+=4;return}else a.set(L,{offset:K-n})}let O=L.constructor;if(O===Object)I(L);else if(O===Array)T(L);else if(O===Map)if(this.mapAsEmptyObject)te[K++]=128;else{D=L.size,D<16?te[K++]=128|D:D<65536?(te[K++]=222,te[K++]=D>>8,te[K++]=D&255):(te[K++]=223,Vt.setUint32(K,D),K+=4);for(let[H,Y]of L)N(H),N(Y)}else{for(let H=0,Y=wu.length;H<Y;H++){let le=Om[H];if(L instanceof le){let fe=wu[H];if(fe.write){fe.type&&(te[K++]=212,te[K++]=fe.type,te[K++]=0);let oe=fe.write.call(this,L);oe===L?Array.isArray(L)?T(L):I(L):N(oe);return}let be=te,Te=Vt,Je=K;te=null;let ke;try{ke=fe.pack.call(this,L,oe=>(te=be,be=null,K+=oe,K>qn&&B(K),{target:te,targetView:Vt,position:K-oe}),N)}finally{be&&(te=be,Vt=Te,K=Je,qn=te.length-10)}ke&&(ke.length+K>qn&&B(ke.length+K),K=qR(ke,te,K,fe.type));return}}if(Array.isArray(L))T(L);else{if(L.toJSON){let H=L.toJSON();if(H!==L)return N(H)}if(E==="function")return N(this.writeFunction&&this.writeFunction(L));I(L)}}}else if(E==="boolean")te[K++]=L?195:194;else if(E==="bigint"){if(L<BigInt(1)<<BigInt(63)&&L>=-(BigInt(1)<<BigInt(63)))te[K++]=211,Vt.setBigInt64(K,L);else if(L<BigInt(1)<<BigInt(64)&&L>0)te[K++]=207,Vt.setBigUint64(K,L);else if(this.largeBigIntToFloat)te[K++]=203,Vt.setFloat64(K,Number(L));else{if(this.largeBigIntToString)return N(L.toString());if(this.useBigIntExtension&&L<BigInt(2)**BigInt(1023)&&L>-(BigInt(2)**BigInt(1023))){te[K++]=199,K++,te[K++]=66;let O=[],H;do{let Y=L&BigInt(255);H=(Y&BigInt(128))===(L<BigInt(0)?BigInt(128):BigInt(0)),O.push(Y),L>>=BigInt(8)}while(!((L===BigInt(0)||L===BigInt(-1))&&H));te[K-2]=O.length;for(let Y=O.length;Y>0;)te[K++]=Number(O[--Y]);return}else throw new RangeError(L+" was too large to fit in MessagePack 64-bit integer format, use useBigIntExtension, or set largeBigIntToFloat to convert to float-64, or set largeBigIntToString to convert to string")}K+=8}else if(E==="undefined")this.encodeUndefinedAsNil?te[K++]=192:(te[K++]=212,te[K++]=0,te[K++]=0);else throw new Error("Unknown type: "+E)},P=this.variableMapSize||this.coercibleKeyAsNumber||this.skipValues?L=>{let E;if(this.skipValues){E=[];for(let H in L)(typeof L.hasOwnProperty!="function"||L.hasOwnProperty(H))&&!this.skipValues.includes(L[H])&&E.push(H)}else E=Object.keys(L);let D=E.length;D<16?te[K++]=128|D:D<65536?(te[K++]=222,te[K++]=D>>8,te[K++]=D&255):(te[K++]=223,Vt.setUint32(K,D),K+=4);let O;if(this.coercibleKeyAsNumber)for(let H=0;H<D;H++){O=E[H];let Y=Number(O);N(isNaN(Y)?O:Y),N(L[O])}else for(let H=0;H<D;H++)N(O=E[H]),N(L[O])}:L=>{te[K++]=222;let E=K-n;K+=2;let D=0;for(let O in L)(typeof L.hasOwnProperty!="function"||L.hasOwnProperty(O))&&(N(O),N(L[O]),D++);if(D>65535)throw new Error('Object is too large to serialize with fast 16-bit map size, use the "variableMapSize" option to serialize this object');te[E+++n]=D>>8,te[E+n]=D&255},U=this.useRecords===!1?P:e.progressiveRecords&&!p?L=>{let E,D=s.transitions||(s.transitions=Object.create(null)),O=K++-n,H;for(let Y in L)if(typeof L.hasOwnProperty!="function"||L.hasOwnProperty(Y)){if(E=D[Y],E)D=E;else{let le=Object.keys(L),fe=D;D=s.transitions;let be=0;for(let Te=0,Je=le.length;Te<Je;Te++){let ke=le[Te];E=D[ke],E||(E=D[ke]=Object.create(null),be++),D=E}O+n+1==K?(K--,k(D,le,be)):V(D,le,O,be),H=!0,D=fe[Y]}N(L[Y])}if(!H){let Y=D[Ua];Y?te[O+n]=Y:V(D,Object.keys(L),O,0)}}:L=>{let E,D=s.transitions||(s.transitions=Object.create(null)),O=0;for(let Y in L)(typeof L.hasOwnProperty!="function"||L.hasOwnProperty(Y))&&(E=D[Y],E||(E=D[Y]=Object.create(null),O++),D=E);let H=D[Ua];H?H>=96&&p?(te[K++]=((H-=96)&31)+96,te[K++]=H>>5):te[K++]=H:k(D,D.__keys__||Object.keys(L),O);for(let Y in L)(typeof L.hasOwnProperty!="function"||L.hasOwnProperty(Y))&&N(L[Y])},v=typeof this.useRecords=="function"&&this.useRecords,I=v?L=>{v(L)?U(L):P(L)}:U,B=L=>{let E;if(L>16777216){if(L-n>Ey)throw new Error("Packed buffer would be larger than maximum buffer size");E=Math.min(Ey,Math.round(Math.max((L-n)*(L>67108864?1.25:2),4194304)/4096)*4096)}else E=(Math.max(L-n<<2,te.length-1)>>12)+1<<12;let D=new vu(E);return Vt=D.dataView||(D.dataView=new DataView(D.buffer,0,E)),L=Math.min(L,te.length),te.copy?te.copy(D,0,n,L):D.set(te.slice(n,L)),K-=n,n=0,qn=D.length-10,te=D},k=(L,E,D)=>{let O=s.nextId;O||(O=64),O<x&&this.shouldShareStructure&&!this.shouldShareStructure(E)?(O=s.nextOwnId,O<y||(O=x),s.nextOwnId=O+1):(O>=y&&(O=x),s.nextId=O+1);let H=E.highByte=O>=96&&p?O-96>>5:-1;L[Ua]=O,L.__keys__=E,s[O-64]=E,O<x?(E.isShared=!0,s.sharedLength=O-63,r=!0,H>=0?(te[K++]=(O&31)+96,te[K++]=H):te[K++]=O):(H>=0?(te[K++]=213,te[K++]=114,te[K++]=(O&31)+96,te[K++]=H):(te[K++]=212,te[K++]=114,te[K++]=O),D&&(g+=S*D),b.length>=f&&(b.shift()[Ua]=0),b.push(L),N(E))},V=(L,E,D,O)=>{let H=te,Y=K,le=qn,fe=n;te=fc,K=0,n=0,te||(fc=te=new vu(8192)),qn=te.length-10,k(L,E,O),fc=te;let be=K;if(te=H,K=Y,qn=le,n=fe,be>1){let Te=K+be-1;Te>qn&&B(Te);let Je=D+n;te.copyWithin(Je+be,Je+1,K),te.set(fc.slice(0,be),Je),K=Te}else te[D+n]=fc[0]},J=L=>{let E=GR(L,te,n,K,s,B,(D,O,H)=>{if(H)return r=!0;K=O;let Y=te;return N(D),A(),Y!==te?{position:K,targetView:Vt,target:te}:K},this);if(E===0)return I(L);K=E}}useBuffer(e){te=e,te.dataView||(te.dataView=new DataView(te.buffer,te.byteOffset,te.byteLength)),Vt=te.dataView,K=0}set position(e){K=e}get position(){return K}set buffer(e){te=e}get buffer(){return te}clearSharedData(){this.structures&&(this.structures=[]),this.typedStructs&&(this.typedStructs=[])}};Om=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,oc];wu=[{pack(i,e,t){let n=i.getTime()/1e3;if((this.useTimestamp32||i.getMilliseconds()===0)&&n>=0&&n<4294967296){let{target:r,targetView:s,position:a}=e(6);r[a++]=214,r[a++]=255,s.setUint32(a,n)}else if(n>0&&n<4294967296){let{target:r,targetView:s,position:a}=e(10);r[a++]=215,r[a++]=255,s.setUint32(a,i.getMilliseconds()*4e6+(n/1e3/4294967296>>0)),s.setUint32(a+4,n)}else if(isNaN(n)){if(this.onInvalidDate)return e(0),t(this.onInvalidDate());let{target:r,targetView:s,position:a}=e(3);r[a++]=212,r[a++]=255,r[a++]=255}else{let{target:r,targetView:s,position:a}=e(15);r[a++]=199,r[a++]=12,r[a++]=255,s.setUint32(a,i.getMilliseconds()*1e6),s.setBigInt64(a+4,BigInt(Math.floor(n)))}}},{pack(i,e,t){if(this.setAsEmptyObject)return e(0),t({});let n=Array.from(i),{target:r,position:s}=e(this.moreTypes?3:0);this.moreTypes&&(r[s++]=212,r[s++]=115,r[s++]=0),t(n)}},{pack(i,e,t){let{target:n,position:r}=e(this.moreTypes?3:0);this.moreTypes&&(n[r++]=212,n[r++]=101,n[r++]=0),t([i.name,i.message,i.cause])}},{pack(i,e,t){let{target:n,position:r}=e(this.moreTypes?3:0);this.moreTypes&&(n[r++]=212,n[r++]=120,n[r++]=0),t([i.source,i.flags])}},{pack(i,e){this.moreTypes?Ry(i,16,e):Cy(Mu?Buffer.from(i):new Uint8Array(i),e)}},{pack(i,e){let t=i.constructor;t!==Py&&this.moreTypes?Ry(i,Nm.indexOf(t.name),e):Cy(i,e)}},{pack(i,e){let{target:t,position:n}=e(1);t[n]=193}}];Dy=new vr({useRecords:!1}),Ny=Dy.pack,Oy=Dy.pack,Fy=vr,{NEVER:Uy,ALWAYS:ky,DECIMAL_ROUND:By,DECIMAL_FIT:zy}=dc,Fm=512,Um=1024,km=2048});function XR(i,e={}){if(!i||typeof i!="object")throw new Error("first argument must be an Iterable, Async Iterable, or a Promise for an Async Iterable");if(typeof i[Symbol.iterator]=="function")return KR(i,e);if(typeof i.then=="function"||typeof i[Symbol.asyncIterator]=="function")return YR(i,e);throw new Error("first argument must be an Iterable, Async Iterable, Iterator, Async Iterator, or a Promise")}function*KR(i,e){let t=new vr(e);for(let n of i)yield t.pack(n)}async function*YR(i,e){let t=new vr(e);for await(let n of i)yield t.pack(n)}function JR(i,e={}){if(!i||typeof i!="object")throw new Error("first argument must be an Iterable, Async Iterable, Iterator, Async Iterator, or a promise");let t=new rr(e),n,r=s=>{let a;n&&(s=Buffer.concat([n,s]),n=void 0);try{a=t.unpackMultiple(s)}catch(o){if(o.incomplete)n=s.slice(o.lastPosition),a=o.values;else throw o}return a};if(typeof i[Symbol.iterator]=="function")return(function*(){for(let a of i)yield*r(a)})();if(typeof i[Symbol.asyncIterator]=="function")return(async function*(){for await(let a of i)yield*r(a)})()}var Hy,Gy,Vy=un(()=>{Bm();Fa();Hy=JR,Gy=XR});var Wy={};Ar(Wy,{ALWAYS:()=>ky,C1:()=>_u,DECIMAL_FIT:()=>zy,DECIMAL_ROUND:()=>By,Decoder:()=>vy,Encoder:()=>Fy,FLOAT32_OPTIONS:()=>dc,NEVER:()=>Uy,Packr:()=>vr,RESERVE_START_SPACE:()=>km,RESET_BUFFER_MODE:()=>Um,REUSE_BUFFER_MODE:()=>Fm,Unpackr:()=>rr,addExtension:()=>Ly,clearSource:()=>lc,decode:()=>My,decodeIter:()=>Hy,encode:()=>Oy,encodeIter:()=>Gy,isNativeAccelerationEnabled:()=>my,mapsAsObjects:()=>QR,pack:()=>Ny,roundFloat32:()=>Ty,unpack:()=>Sy,unpackMultiple:()=>wy,useRecords:()=>ZR});var ZR,QR,qy=un(()=>{Bm();Fa();Vy();ZR=!1,QR=!0});var Hm=dn(Ky=>{"use strict";var eC=Y_(),wi=_m(),$y=vm(),tC=Sm(),Au=Q_(),Fn=ac(),nC=Tm(),jy=sc(),Xy=(qy(),Gs(Wy)),zm=class i{constructor(e,t){this.onStateChange=Au.createSignal(),this.onError=Au.createSignal(),this.onLeave=Au.createSignal(),this.onJoin=Au.createSignal(),this.hasJoined=!1,this.onMessageHandlers=tC.createNanoEvents(),this.roomId=null,this.name=e,this.packr=new Xy.Packr,this.packr.encode(void 0),t&&(this.serializer=new($y.getSerializer("schema")),this.rootSchema=t,this.serializer.state=new t),this.onError((n,r)=>{var s;return(s=console.warn)===null||s===void 0?void 0:s.call(console,`colyseus.js - onError => (${n}) ${r}`)}),this.onLeave(()=>this.removeAllListeners())}connect(e,t,n=this,r,s){let a=new eC.Connection(r.protocol);if(n.connection=a,a.events.onmessage=i.prototype.onMessageCallback.bind(n),a.events.onclose=function(o){var l;if(!n.hasJoined){(l=console.warn)===null||l===void 0||l.call(console,`Room connection was closed unexpectedly (${o.code}): ${o.reason}`),n.onError.invoke(o.code,o.reason);return}o.code===jy.CloseCode.DEVMODE_RESTART&&t?t():(n.onLeave.invoke(o.code,o.reason),n.destroy())},a.events.onerror=function(o){var l;(l=console.warn)===null||l===void 0||l.call(console,`Room, onError (${o.code}): ${o.reason}`),n.onError.invoke(o.code,o.reason)},r.protocol==="h3"){let o=new URL(e);a.connect(o.origin,r)}else a.connect(e,s)}leave(e=!0){return new Promise(t=>{this.onLeave(n=>t(n)),this.connection?e?(this.packr.buffer[0]=wi.Protocol.LEAVE_ROOM,this.connection.send(this.packr.buffer.subarray(0,1))):this.connection.close():this.onLeave.invoke(jy.CloseCode.CONSENTED)})}onMessage(e,t){return this.onMessageHandlers.on(this.getMessageHandlerKey(e),t)}send(e,t){let n={offset:1};this.packr.buffer[0]=wi.Protocol.ROOM_DATA,typeof e=="string"?Fn.encode.string(this.packr.buffer,e,n):Fn.encode.number(this.packr.buffer,e,n),this.packr.position=0;let r=t!==void 0?this.packr.pack(t,2048+n.offset):this.packr.buffer.subarray(0,n.offset);this.connection.send(r)}sendUnreliable(e,t){let n={offset:1};this.packr.buffer[0]=wi.Protocol.ROOM_DATA,typeof e=="string"?Fn.encode.string(this.packr.buffer,e,n):Fn.encode.number(this.packr.buffer,e,n),this.packr.position=0;let r=t!==void 0?this.packr.pack(t,2048+n.offset):this.packr.buffer.subarray(0,n.offset);this.connection.sendUnreliable(r)}sendBytes(e,t){let n={offset:1};if(this.packr.buffer[0]=wi.Protocol.ROOM_DATA_BYTES,typeof e=="string"?Fn.encode.string(this.packr.buffer,e,n):Fn.encode.number(this.packr.buffer,e,n),t.byteLength+n.offset>this.packr.buffer.byteLength){let r=new Uint8Array(n.offset+t.byteLength);r.set(this.packr.buffer),this.packr.useBuffer(r)}this.packr.buffer.set(t,n.offset),this.connection.send(this.packr.buffer.subarray(0,n.offset+t.byteLength))}get state(){return this.serializer.getState()}removeAllListeners(){this.onJoin.clear(),this.onStateChange.clear(),this.onError.clear(),this.onLeave.clear(),this.onMessageHandlers.events={},this.serializer instanceof nC.SchemaSerializer&&(this.serializer.decoder.root.callbacks={})}onMessageCallback(e){let t=new Uint8Array(e.data),n={offset:1},r=t[0];if(r===wi.Protocol.JOIN_ROOM){let s=Fn.decode.utf8Read(t,n,t[n.offset++]);if(this.serializerId=Fn.decode.utf8Read(t,n,t[n.offset++]),!this.serializer){let a=$y.getSerializer(this.serializerId);this.serializer=new a}t.byteLength>n.offset&&this.serializer.handshake&&this.serializer.handshake(t,n),this.reconnectionToken=`${this.roomId}:${s}`,this.hasJoined=!0,this.onJoin.invoke(),this.packr.buffer[0]=wi.Protocol.JOIN_ROOM,this.connection.send(this.packr.buffer.subarray(0,1))}else if(r===wi.Protocol.ERROR){let s=Fn.decode.number(t,n),a=Fn.decode.string(t,n);this.onError.invoke(s,a)}else if(r===wi.Protocol.LEAVE_ROOM)this.leave();else if(r===wi.Protocol.ROOM_STATE)this.serializer.setState(t,n),this.onStateChange.invoke(this.serializer.getState());else if(r===wi.Protocol.ROOM_STATE_PATCH)this.serializer.patch(t,n),this.onStateChange.invoke(this.serializer.getState());else if(r===wi.Protocol.ROOM_DATA){let s=Fn.decode.stringCheck(t,n)?Fn.decode.string(t,n):Fn.decode.number(t,n),a=t.byteLength>n.offset?Xy.unpack(t,{start:n.offset}):void 0;this.dispatchMessage(s,a)}else if(r===wi.Protocol.ROOM_DATA_BYTES){let s=Fn.decode.stringCheck(t,n)?Fn.decode.string(t,n):Fn.decode.number(t,n);this.dispatchMessage(s,t.subarray(n.offset))}}dispatchMessage(e,t){var n;let r=this.getMessageHandlerKey(e);this.onMessageHandlers.events[r]?this.onMessageHandlers.emit(r,t):this.onMessageHandlers.events["*"]?this.onMessageHandlers.emit("*",e,t):(n=console.warn)===null||n===void 0||n.call(console,`colyseus.js: onMessage() not registered for type '${e}'.`)}destroy(){this.serializer&&this.serializer.teardown()}getMessageHandlerKey(e){switch(typeof e){case"string":return e;case"number":return`i${e}`;default:throw new Error("invalid message type.")}}};Ky.Room=zm});var Jy={};Ar(Jy,{del:()=>aC,get:()=>iC,patch:()=>sC,post:()=>rC,put:()=>oC,send:()=>Ui});function Yy(i,e){e.headers=i.headers||{},e.statusMessage=i.statusText,e.statusCode=i.status,e.data=i.response}function Ui(i,e,t){return new Promise(function(n,r){t=t||{};var s=new XMLHttpRequest,a,o,l,c=t.body,h=t.headers||{};t.timeout&&(s.timeout=t.timeout),s.ontimeout=s.onerror=function(d){d.timeout=d.type=="timeout",r(d)},s.onabort=function(d){d.aborted=!0,r(d)},s.open(i,e.href||e),s.onload=function(){for(l=s.getAllResponseHeaders().trim().split(/[\r\n]+/),Yy(s,s);o=l.shift();)o=o.split(": "),s.headers[o.shift().toLowerCase()]=o.join(": ");if(o=s.headers["content-type"],o&&~o.indexOf("application/json"))try{s.data=JSON.parse(s.data,t.reviver)}catch(d){return Yy(s,d),r(d)}(s.status>=400?r:n)(s)},typeof FormData<"u"&&c instanceof FormData||c&&typeof c=="object"&&(h["content-type"]="application/json",c=JSON.stringify(c)),s.withCredentials=!!t.withCredentials;for(a in h)s.setRequestHeader(a,h[a]);s.send(c),t.signal&&t.signal.addEventListener("abort",function(){s.abort()})})}var iC,rC,sC,aC,oC,Zy=un(()=>{iC=Ui.bind(Ui,"GET"),rC=Ui.bind(Ui,"POST"),sC=Ui.bind(Ui,"PATCH"),aC=Ui.bind(Ui,"DELETE"),oC=Ui.bind(Ui,"PUT")});var tv=dn(ev=>{"use strict";var Qy=sc(),cC=(Zy(),Gs(Jy));function lC(i){var e=Object.create(null);return i&&Object.keys(i).forEach(function(t){if(t!=="default"){var n=Object.getOwnPropertyDescriptor(i,t);Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:function(){return i[t]}})}}),e.default=i,Object.freeze(e)}var hC=lC(cC),Gm=class{constructor(e,t={}){this.client=e,this.headers=t}get(e,t={}){return this.request("get",e,t)}post(e,t={}){return this.request("post",e,t)}del(e,t={}){return this.request("del",e,t)}put(e,t={}){return this.request("put",e,t)}request(e,t,n={}){return hC[e](this.client.getHttpEndpoint(t),this.getOptions(n)).catch(r=>{var s;if(r.aborted)throw new Qy.AbortError("Request aborted");let a=r.statusCode,o=((s=r.data)===null||s===void 0?void 0:s.error)||r.statusMessage||r.message;throw!a&&!o?r:new Qy.ServerError(a,o)})}getOptions(e){return e.headers=Object.assign({},this.headers,e.headers),this.authToken&&(e.headers.Authorization=`Bearer ${this.authToken}`),typeof cc<"u"&&cc.sys&&cc.sys.isNative||(e.withCredentials=!0),e}};ev.HTTP=Gm});var iv=dn(Tu=>{"use strict";var nv=(rc(),Gs(ic)),zs;function Wm(){if(!zs)try{zs=typeof cc<"u"&&cc.sys&&cc.sys.localStorage?cc.sys.localStorage:window.localStorage}catch{}return!zs&&typeof globalThis.indexedDB<"u"&&(zs=new Vm),zs||(zs={cache:{},setItem:function(i,e){this.cache[i]=e},getItem:function(i){this.cache[i]},removeItem:function(i){delete this.cache[i]}}),zs}function uC(i,e){Wm().setItem(i,e)}function dC(i){Wm().removeItem(i)}function fC(i,e){let t=Wm().getItem(i);typeof Promise>"u"||!(t instanceof Promise)?e(t):t.then(n=>e(n))}var Vm=class{constructor(){this.dbPromise=new Promise(e=>{let t=indexedDB.open("_colyseus_storage",1);t.onupgradeneeded=()=>t.result.createObjectStore("store"),t.onsuccess=()=>e(t.result)})}tx(e,t){return nv.__awaiter(this,void 0,void 0,function*(){let r=(yield this.dbPromise).transaction("store",e).objectStore("store");return t(r)})}setItem(e,t){return this.tx("readwrite",n=>n.put(t,e)).then()}getItem(e){return nv.__awaiter(this,void 0,void 0,function*(){let t=yield this.tx("readonly",n=>n.get(e));return new Promise(n=>{t.onsuccess=()=>n(t.result)})})}removeItem(e){return this.tx("readwrite",t=>t.delete(e)).then()}};Tu.getItem=fC;Tu.removeItem=dC;Tu.setItem=uC});var Xm=dn(rv=>{"use strict";var Mn=(rc(),Gs(ic)),qm=iv(),pC=Sm(),Eu,$m,es,Ru,jm=class{constructor(e){this.http=e,this.settings={path:"/auth",key:"colyseus-auth-token"},Eu.set(this,!1),$m.set(this,void 0),es.set(this,void 0),Ru.set(this,pC.createNanoEvents()),qm.getItem(this.settings.key,t=>this.token=t)}set token(e){this.http.authToken=e}get token(){return this.http.authToken}onChange(e){let t=Mn.__classPrivateFieldGet(this,Ru,"f").on("change",e);return Mn.__classPrivateFieldGet(this,Eu,"f")||Mn.__classPrivateFieldSet(this,$m,new Promise((n,r)=>{this.getUserData().then(s=>{this.emitChange(Object.assign(Object.assign({},s),{token:this.token}))}).catch(s=>{this.emitChange({user:null,token:void 0})}).finally(()=>{n()})}),"f"),Mn.__classPrivateFieldSet(this,Eu,!0,"f"),t}getUserData(){return Mn.__awaiter(this,void 0,void 0,function*(){if(this.token)return(yield this.http.get(`${this.settings.path}/userdata`)).data;throw new Error("missing auth.token")})}registerWithEmailAndPassword(e,t,n){return Mn.__awaiter(this,void 0,void 0,function*(){let r=(yield this.http.post(`${this.settings.path}/register`,{body:{email:e,password:t,options:n}})).data;return this.emitChange(r),r})}signInWithEmailAndPassword(e,t){return Mn.__awaiter(this,void 0,void 0,function*(){let n=(yield this.http.post(`${this.settings.path}/login`,{body:{email:e,password:t}})).data;return this.emitChange(n),n})}signInAnonymously(e){return Mn.__awaiter(this,void 0,void 0,function*(){let t=(yield this.http.post(`${this.settings.path}/anonymous`,{body:{options:e}})).data;return this.emitChange(t),t})}sendPasswordResetEmail(e){return Mn.__awaiter(this,void 0,void 0,function*(){return(yield this.http.post(`${this.settings.path}/forgot-password`,{body:{email:e}})).data})}signInWithProvider(e){return Mn.__awaiter(this,arguments,void 0,function*(t,n={}){return new Promise((r,s)=>{let a=n.width||480,o=n.height||768,l=this.token?`?token=${this.token}`:"",c=`Login with ${t[0].toUpperCase()+t.substring(1)}`,h=this.http.client.getHttpEndpoint(`${n.prefix||`${this.settings.path}/provider`}/${t}${l}`),d=screen.width/2-a/2,f=screen.height/2-o/2;Mn.__classPrivateFieldSet(this,es,window.open(h,c,"toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width="+a+", height="+o+", top="+f+", left="+d),"f");let p=y=>{y.data.user===void 0&&y.data.token===void 0||(clearInterval(x),Mn.__classPrivateFieldGet(this,es,"f").close(),Mn.__classPrivateFieldSet(this,es,void 0,"f"),window.removeEventListener("message",p),y.data.error!==void 0?s(y.data.error):(r(y.data),this.emitChange(y.data)))},x=setInterval(()=>{(!Mn.__classPrivateFieldGet(this,es,"f")||Mn.__classPrivateFieldGet(this,es,"f").closed)&&(Mn.__classPrivateFieldSet(this,es,void 0,"f"),s("cancelled"),window.removeEventListener("message",p))},200);window.addEventListener("message",p)})})}signOut(){return Mn.__awaiter(this,void 0,void 0,function*(){this.emitChange({user:null,token:null})})}emitChange(e){e.token!==void 0&&(this.token=e.token,e.token===null?qm.removeItem(this.settings.key):qm.setItem(this.settings.key,e.token)),Mn.__classPrivateFieldGet(this,Ru,"f").emit("change",e)}};Eu=new WeakMap,$m=new WeakMap,es=new WeakMap,Ru=new WeakMap;rv.Auth=jm});var av=dn(sv=>{"use strict";function mC(i){var e;let t=((e=window?.location)===null||e===void 0?void 0:e.hostname)||"localhost",n=i.hostname.split("."),r=!i.hostname.includes("trycloudflare.com")&&!i.hostname.includes("discordsays.com")&&n.length>2?`/${n[0]}`:"";return i.pathname.startsWith("/.proxy")?`${i.protocol}//${t}${r}${i.pathname}${i.search}`:`${i.protocol}//${t}/.proxy/colyseus${r}${i.pathname}${i.search}`}sv.discordURLBuilder=mC});var cv=dn(Ym=>{"use strict";var Sr=(rc(),Gs(ic)),gC=sc(),bC=Hm(),xC=tv(),_C=Xm(),yC=av(),Km,Cu=class i extends Error{constructor(e,t){super(e),this.code=t,this.name="MatchMakeError",Object.setPrototypeOf(this,i.prototype)}},ov=typeof window<"u"&&typeof((Km=window?.location)===null||Km===void 0?void 0:Km.hostname)<"u"?`${window.location.protocol.replace("http","ws")}//${window.location.hostname}${window.location.port&&`:${window.location.port}`}`:"ws://127.0.0.1:2567",Iu=class{constructor(e=ov,t){var n,r;if(typeof e=="string"){let s=e.startsWith("/")?new URL(e,ov):new URL(e),a=s.protocol==="https:"||s.protocol==="wss:",o=Number(s.port||(a?443:80));this.settings={hostname:s.hostname,pathname:s.pathname,port:o,secure:a,searchParams:s.searchParams.toString()||void 0}}else e.port===void 0&&(e.port=e.secure?443:80),e.pathname===void 0&&(e.pathname=""),this.settings=e;this.settings.pathname.endsWith("/")&&(this.settings.pathname=this.settings.pathname.slice(0,-1)),this.http=new xC.HTTP(this,t?.headers||{}),this.auth=new _C.Auth(this.http),this.urlBuilder=t?.urlBuilder,!this.urlBuilder&&typeof window<"u"&&(!((r=(n=window?.location)===null||n===void 0?void 0:n.hostname)===null||r===void 0)&&r.includes("discordsays.com"))&&(this.urlBuilder=yC.discordURLBuilder,console.log("Colyseus SDK: Discord Embedded SDK detected. Using custom URL builder."))}joinOrCreate(e){return Sr.__awaiter(this,arguments,void 0,function*(t,n={},r){return yield this.createMatchMakeRequest("joinOrCreate",t,n,r)})}create(e){return Sr.__awaiter(this,arguments,void 0,function*(t,n={},r){return yield this.createMatchMakeRequest("create",t,n,r)})}join(e){return Sr.__awaiter(this,arguments,void 0,function*(t,n={},r){return yield this.createMatchMakeRequest("join",t,n,r)})}joinById(e){return Sr.__awaiter(this,arguments,void 0,function*(t,n={},r){return yield this.createMatchMakeRequest("joinById",t,n,r)})}reconnect(e,t){return Sr.__awaiter(this,void 0,void 0,function*(){if(typeof e=="string"&&typeof t=="string")throw new Error("DEPRECATED: .reconnect() now only accepts 'reconnectionToken' as argument.\nYou can get this token from previously connected `room.reconnectionToken`");let[n,r]=e.split(":");if(!n||!r)throw new Error(`Invalid reconnection token format.
-The format should be roomId:reconnectionToken`);return yield this.createMatchMakeRequest("reconnect",n,{reconnectionToken:r},t)})}consumeSeatReservation(e,t,n){return Sr.__awaiter(this,void 0,void 0,function*(){let r=this.createRoom(e.room.name,t);r.roomId=e.room.roomId,r.sessionId=e.sessionId;let s={sessionId:r.sessionId};e.reconnectionToken&&(s.reconnectionToken=e.reconnectionToken);let a=n||r;return r.connect(this.buildEndpoint(e.room,s,e.protocol),e.devMode&&(()=>Sr.__awaiter(this,void 0,void 0,function*(){console.info(`[Colyseus devMode]: ${String.fromCodePoint(128260)} Re-establishing connection with room id '${r.roomId}'...`);let o=0,l=8,c=()=>Sr.__awaiter(this,void 0,void 0,function*(){o++;try{yield this.consumeSeatReservation(e,t,a),console.info(`[Colyseus devMode]: ${String.fromCodePoint(9989)} Successfully re-established connection with room '${r.roomId}'`)}catch{o<l?(console.info(`[Colyseus devMode]: ${String.fromCodePoint(128260)} retrying... (${o} out of ${l})`),setTimeout(c,2e3)):console.info(`[Colyseus devMode]: ${String.fromCodePoint(10060)} Failed to reconnect. Is your server running? Please check server logs.`)}});setTimeout(c,2e3)})),a,e,this.http.headers),new Promise((o,l)=>{let c=(h,d)=>l(new gC.ServerError(h,d));a.onError.once(c),a.onJoin.once(()=>{a.onError.remove(c),o(a)})})})}createMatchMakeRequest(e,t){return Sr.__awaiter(this,arguments,void 0,function*(n,r,s={},a,o){let l=(yield this.http.post(`matchmake/${n}/${r}`,{headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(s)})).data;if(l.error)throw new Cu(l.error,l.code);return n==="reconnect"&&(l.reconnectionToken=s.reconnectionToken),yield this.consumeSeatReservation(l,a,o)})}createRoom(e,t){return new bC.Room(e,t)}buildEndpoint(e,t={},n="ws"){let r=this.settings.searchParams||"";this.http.authToken&&(t._authToken=this.http.authToken);for(let o in t)t.hasOwnProperty(o)&&(r+=(r?"&":"")+`${o}=${t[o]}`);n==="h3"&&(n="http");let s=this.settings.secure?`${n}s://`:`${n}://`;e.publicAddress?s+=`${e.publicAddress}`:s+=`${this.settings.hostname}${this.getEndpointPort()}${this.settings.pathname}`;let a=`${s}/${e.processId}/${e.roomId}?${r}`;return this.urlBuilder?this.urlBuilder(new URL(a)):a}getHttpEndpoint(e=""){let t=e.startsWith("/")?e:`/${e}`,n=`${this.settings.secure?"https":"http"}://${this.settings.hostname}${this.getEndpointPort()}${this.settings.pathname}${t}`;return this.settings.searchParams&&(n+=`?${this.settings.searchParams}`),this.urlBuilder?this.urlBuilder(new URL(n)):n}getEndpointPort(){return this.settings.port!==80&&this.settings.port!==443?`:${this.settings.port}`:""}};Iu.VERSION="0.16.22";Ym.Client=Iu;Ym.MatchMakeError=Cu});var hv=dn(lv=>{"use strict";var Jm=class{setState(e){}getState(){return null}patch(e){}teardown(){}handshake(e){}};lv.NoneSerializer=Jm});var fv=dn(ki=>{"use strict";f_();var uv=cv(),dv=_m(),vC=Hm(),SC=Xm(),wC=sc(),Zm=Tm(),MC=hv(),Qm=vm();Qm.registerSerializer("schema",Zm.SchemaSerializer);Qm.registerSerializer("none",MC.NoneSerializer);ki.Client=uv.Client;ki.MatchMakeError=uv.MatchMakeError;Object.defineProperty(ki,"ErrorCode",{enumerable:!0,get:function(){return dv.ErrorCode}});Object.defineProperty(ki,"Protocol",{enumerable:!0,get:function(){return dv.Protocol}});ki.Room=vC.Room;ki.Auth=SC.Auth;ki.ServerError=wC.ServerError;ki.SchemaSerializer=Zm.SchemaSerializer;ki.getStateCallbacks=Zm.getStateCallbacks;ki.registerSerializer=Qm.registerSerializer});var pv={};Ar(pv,{StudioModel:()=>pc,StudioState:()=>Pu,StudioViewer:()=>mc});var Bi,pc,mc,Pu,mv=un(()=>{Bi=og(ac(),1),pc=class extends Bi.Schema{constructor(){super(),this.id="",this.src="",this.title="",this.relEast=0,this.relNorth=0,this.yawDeg=0,this.scale=1,this.height=0,this.ownerId="",this.ts=0}};(0,Bi.defineTypes)(pc,{id:"string",src:"string",title:"string",relEast:"float32",relNorth:"float32",yawDeg:"float32",scale:"float32",height:"float32",ownerId:"string",ts:"float64"});mc=class extends Bi.Schema{constructor(){super(),this.id="",this.name="",this.ownerId="",this.tsServer=0}};(0,Bi.defineTypes)(mc,{id:"string",name:"string",ownerId:"string",tsServer:"float64"});Pu=class extends Bi.Schema{constructor(){super(),this.roomKey="",this.models=new Bi.MapSchema,this.viewers=new Bi.MapSchema}};(0,Bi.defineTypes)(Pu,{roomKey:"string",models:{map:pc},viewers:{map:mc}})});Vn();wh();var En={origin:"https://three.ws",objectsManifest:"https://three.ws/cdn/objects/library/manifest.json",studioMcp:"https://three.ws/api/mcp-studio",animationManifest:"https://three.ws/animations/manifest.json",hdri:{studio:"https://three.ws/hdri/studio.hdr",outdoor:"https://three.ws/hdri/outdoor.hdr",sunset:"https://three.ws/hdri/sunset.hdr"},arLaunch:"https://three.ws/api/ar",roomServer:"wss://three-ws-multiplayer-93741856042.us-central1.run.app"},lb={assets:"three.ws",allowUrlOverride:!0,generate:{enabled:!0,endpoint:En.studioMcp,kind:"model",tier:"standard",timeoutMs:3e5,pollMs:3e3},rooms:{enabled:!0,server:En.roomServer},animations:{enabled:!0,manifestUrl:En.animationManifest,clip:"idle"},lighting:{preset:"studio",urls:En.hdri},arLaunchUrl:En.arLaunch,branding:{title:"AR Studio",backHref:null,backLabel:"Back",accent:"#8b7cf8"},shareBaseUrl:"",persistKey:"ar-studio:scene:v1",maxPlacements:20,persist:!0,onEvent:null};function mf(i){return!!i&&typeof i=="object"&&!Array.isArray(i)}function gf(i,e){if(!mf(e))return i;let t={...i};for(let[n,r]of Object.entries(e))r!==void 0&&(t[n]=mf(r)&&mf(i?.[n])?gf(i[n],r):r);return t}function er(i){let e=String(i??"").trim();if(!e)return null;if(e.startsWith("/")&&!e.startsWith("//"))return e;try{let t=new URL(e);return t.protocol==="https:"?t.href:null}catch{return null}}function bf(i={},e){let t=gf(lb,i),n=e instanceof URLSearchParams?e:new URLSearchParams(typeof e=="string"?e:typeof location<"u"?location.search:""),r=[],s="",a="";if(t.allowUrlOverride){let o=n.get("assets")||n.get("source"),l=o?er(o):null;l&&(t.assets=l);let c=n.getAll("src"),h=n.getAll("title");for(let d=0;d<c.length&&r.length<t.maxPlacements;d++){let f=er(c[d]);f&&r.push({src:f,title:String(h[d]||"").slice(0,120)})}s=String(n.get("room")||"").trim(),a=String(n.get("forge")||n.get("prompt")||"").trim()}return!t.shareBaseUrl&&typeof location<"u"&&(t.shareBaseUrl=`${location.origin}${location.pathname}`),{...t,urlModels:r,urlRoom:s,urlPrompt:a}}var mT=()=>{};function gT(){if(typeof window>"u")return!1;try{let i=new URLSearchParams(window.location.search);return i.has("ar-debug")&&i.get("ar-debug")!=="0"?!0:window.localStorage?.getItem("ar-studio:debug")==="1"}catch{return!1}}var Ps=gT(),Is=i=>typeof console<"u"&&typeof console[i]=="function"?console[i].bind(console):mT;function bT(i){Ps=!!i}function xT(){return Ps}var Mh=i=>(...e)=>{Ps&&Is(i)(...e)},ei={error:(...i)=>Is("error")(...i),warn:Mh("warn"),info:Mh("info"),debug:Mh("debug"),log:Mh("log")};function Ls(i){let e=`[${i}]`;return{error:(...t)=>Is("error")(e,...t),warn:(...t)=>{Ps&&Is("warn")(e,...t)},info:(...t)=>{Ps&&Is("info")(e,...t)},debug:(...t)=>{Ps&&Is("debug")(e,...t)},log:(...t)=>{Ps&&Is("log")(e,...t)}}}var hb=[[7,10,15,20,26,18,20,24,30,18]],ub=[[1,1,1,1,1,2,2,2,2,4]];function _T(i){return i*4+17}function db(i){let e=fb(i)>>>3,t=ub[0][i-1],n=hb[0][i-1];return e-n*t}function fb(i){let e=(16*i+128)*i+64;if(i>=2){let t=Math.floor(i/7)+2;e-=(25*t-10)*t-55,i>=7&&(e-=36)}return e}function yT(i){let e=new Uint8Array(i);e[i-1]=1;let t=1;for(let n=0;n<i;n++){for(let r=0;r<i;r++)e[r]=xf(e[r],t),r+1<i&&(e[r]^=e[r+1]);t=xf(t,2)}return e}function xf(i,e){let t=0;for(let n=7;n>=0;n--)t=t<<1^(t>>>7)*285,t^=(e>>>n&1)*i;return t&255}function vT(i,e){let t=new Uint8Array(e.length);for(let n of i){let r=n^t[0];t.copyWithin(0,1),t[t.length-1]=0;for(let s=0;s<t.length;s++)t[s]^=xf(e[s],r)}return t}function ST(i){for(let e=1;e<=10;e++){let t=db(e)*8;if(4+(e<10?8:16)+i*8<=t)return e}throw new Error("QR payload too large (>10 versions)")}function _f(i){let e=new TextEncoder().encode(i),t=ST(e.length),n=_T(t),r=t<10?8:16,s=[],a=(E,D)=>{for(let O=D-1;O>=0;O--)s.push(E>>>O&1)};a(4,4),a(e.length,r);for(let E of e)a(E,8);let o=db(t),l=o*8;for(let E=0;E<4&&s.length<l;E++)s.push(0);for(;s.length%8!==0;)s.push(0);let c=[236,17],h=0;for(;s.length<l;)a(c[h%2],8),h++;let d=new Uint8Array(o);for(let E=0;E<o;E++){let D=0;for(let O=0;O<8;O++)D=D<<1|s[E*8+O];d[E]=D}let f=ub[0][t-1],p=hb[0][t-1],x=fb(t)>>>3,y=Math.floor(x/f),b=f-x%f,g=[],S=yT(p),A=0;for(let E=0;E<f;E++){let D=y-p+(E<b?0:1),O=d.slice(A,A+D);A+=D;let H=vT(O,S);g.push({dat:O,ec:H})}let T=[];for(let E=0;E<y-p+1;E++)for(let D of g)E<D.dat.length&&T.push(D.dat[E]);for(let E=0;E<p;E++)for(let D of g)T.push(D.ec[E]);let N=Array.from({length:n},()=>new Array(n).fill(!1)),P=Array.from({length:n},()=>new Array(n).fill(!1)),U=(E,D,O)=>{N[D][E]=O,P[D][E]=!0},v=(E,D)=>{for(let O=-4;O<=4;O++)for(let H=-4;H<=4;H++){let Y=E+H,le=D+O;if(Y<0||Y>=n||le<0||le>=n)continue;let fe=Math.max(Math.abs(H),Math.abs(O));U(Y,le,fe!==2&&fe!==4)}};v(3,3),v(n-4,3),v(3,n-4);for(let E=0;E<n;E++)P[6][E]||U(E,6,E%2===0),P[E][6]||U(6,E,E%2===0);let B=(E=>{if(E===1)return[];let D=Math.floor(E/7)+2,O=E===32?26:Math.ceil((E*4+4)/(D*2-2))*2,H=[6];for(let Y=n-7;H.length<D;Y-=O)H.splice(1,0,Y);return H})(t);for(let E of B)for(let D of B)if(!(E===6&&D===6||E===6&&D===n-7||E===n-7&&D===6))for(let O=-2;O<=2;O++)for(let H=-2;H<=2;H++){let Y=Math.max(Math.abs(H),Math.abs(O));U(E+H,D+O,Y!==1)}for(let E=0;E<9;E++)U(8,E,!1);for(let E=0;E<8;E++)U(E,8,!1);for(let E=0;E<8;E++)U(n-1-E,8,!1);for(let E=0;E<7;E++)U(8,n-1-E,!1);if(U(8,n-8,!0),t>=7){let E=t;for(let O=0;O<12;O++)E=E<<1^(E>>>11)*7973;let D=(t<<12|E)>>>0;for(let O=0;O<18;O++){let H=(D>>>O&1)===1,Y=n-11+O%3,le=Math.floor(O/3);U(Y,le,H),U(le,Y,H)}}let k=0,V=E=>(T[E>>>3]>>>7-(E&7)&1)===1;for(let E=n-1;E>=1;E-=2){E===6&&(E=5);for(let D=0;D<n;D++)for(let O=0;O<2;O++){let H=E-O,le=(E+1&2)===0?n-1-D:D;!P[le][H]&&k<T.length*8&&(N[le][H]=V(k),k++)}}let J=1/0,L=null;for(let E=0;E<8;E++){let D=N.map(H=>H.slice());MT(D,P,E),AT(D,E);let O=ET(D);O<J&&(J=O,L=D)}return{size:n,modules:L}}function wT(i,e,t){switch(i){case 0:return(e+t)%2===0;case 1:return t%2===0;case 2:return e%3===0;case 3:return(e+t)%3===0;case 4:return(Math.floor(e/3)+Math.floor(t/2))%2===0;case 5:return e*t%2+e*t%3===0;case 6:return(e*t%2+e*t%3)%2===0;case 7:return((e+t)%2+e*t%3)%2===0}return!1}function MT(i,e,t){let n=i.length;for(let r=0;r<n;r++)for(let s=0;s<n;s++)!e[r][s]&&wT(t,s,r)&&(i[r][s]=!i[r][s])}function AT(i,e){let t=i.length,n=TT[0]<<3|e,r=n;for(let o=0;o<10;o++)r=r<<1^(r>>>9)*1335;let s=((n<<10|r)^21522)>>>0,a=(o,l,c)=>{i[l][o]=c};for(let o=0;o<=5;o++)a(8,o,(s>>>o&1)===1);a(8,7,(s>>>6&1)===1),a(8,8,(s>>>7&1)===1),a(7,8,(s>>>8&1)===1);for(let o=9;o<15;o++)a(14-o,8,(s>>>o&1)===1);for(let o=0;o<8;o++)a(t-1-o,8,(s>>>o&1)===1);for(let o=8;o<15;o++)a(8,t-15+o,(s>>>o&1)===1);a(8,t-8,!0)}var TT=[1,0,3,2];function ET(i){let e=i.length,t=0;for(let a=0;a<e;a++){let o=1;for(let l=1;l<e;l++)i[a][l]===i[a][l-1]?(o++,o===5?t+=3:o>5&&t++):o=1}for(let a=0;a<e;a++){let o=1;for(let l=1;l<e;l++)i[l][a]===i[l-1][a]?(o++,o===5?t+=3:o>5&&t++):o=1}for(let a=0;a<e-1;a++)for(let o=0;o<e-1;o++){let l=i[a][o];i[a][o+1]===l&&i[a+1][o]===l&&i[a+1][o+1]===l&&(t+=3)}let n=0;for(let a=0;a<e;a++)for(let o=0;o<e;o++)i[a][o]&&n++;let r=e*e,s=Math.floor(Math.abs(n*20-r*10)/r);return t+=s*10,t}function Vo(i,e={}){let t=e.scale??8,n=e.margin??2,r=e.dark??"#000",s=e.light??"#fff",{size:a,modules:o}=_f(i),l=(a+n*2)*t,c="";for(let h=0;h<a;h++)for(let d=0;d<a;d++)o[h][d]&&(c+=`<rect x="${(d+n)*t}" y="${(h+n)*t}" width="${t}" height="${t}"/>`);return`<svg xmlns="http://www.w3.org/2000/svg" width="${l}" height="${l}" viewBox="0 0 ${l} ${l}" shape-rendering="crispEdges"><rect width="${l}" height="${l}" fill="${s}"/><g fill="${r}">${c}</g></svg>`}function RT(i,e={}){let t=e.scale??8,n=e.margin??2,{size:r,modules:s}=_f(i),a=(r+n*2)*t,o=document.createElement("canvas");o.width=a,o.height=a;let l=o.getContext("2d");l.fillStyle="#fff",l.fillRect(0,0,a,a),l.fillStyle="#000";for(let c=0;c<r;c++)for(let h=0;h<r;h++)s[c][h]&&l.fillRect((h+n)*t,(c+n)*t,t,t);return o}var CT=1;function yf({endpoint:i,headers:e={},fetchImpl:t}={}){if(!i)throw new Error("ar-studio: MCP client needs an endpoint");let n=t||(typeof fetch<"u"?fetch.bind(globalThis):null);if(!n)throw new Error("ar-studio: no fetch implementation available");let r="";async function s(a,o,{signal:l}={}){let c=CT++,h=await n(i,{method:"POST",signal:l,headers:{"content-type":"application/json",accept:"application/json, text/event-stream",...r?{"mcp-session-id":r}:{},...e},body:JSON.stringify({jsonrpc:"2.0",id:c,method:a,...o?{params:o}:{}})}),d=h.headers.get("mcp-session-id");if(d&&(r=d),!h.ok){let p=await h.text().catch(()=>"");throw new Ta(`${a} failed (${h.status})`,{status:h.status,detail:p})}let f=await IT(h,c);if(f?.error)throw new Ta(f.error.message||"MCP error",{code:f.error.code});return f?.result??null}return{get sessionId(){return r},rpc:s,listTools(a){return s("tools/list",void 0,a).then(o=>o?.tools||[])},callTool(a,o={},l){return s("tools/call",{name:a,arguments:o},l)}}}var Ta=class extends Error{constructor(e,t={}){super(e),this.name="McpError",Object.assign(this,t)}};async function IT(i,e){if(!String(i.headers.get("content-type")||"").includes("text/event-stream"))return i.json();let n=await i.text();for(let r of n.split(/\n\n+/)){let s=r.split(`
-`).filter(a=>a.startsWith("data:")).map(a=>a.slice(5).trim()).join("");if(s)try{let a=JSON.parse(s);if(a.id===e||a.error)return a}catch{}}throw new Ta("MCP stream ended without a result")}function Ah(i){let e=i?.structuredContent??null,t=(i?.content||[]).filter(n=>n?.type==="text"&&typeof n.text=="string").map(n=>n.text).join(`
-`).trim();return{structured:e,text:t,isError:!!i?.isError}}var PT={nvidia:"free NVIDIA NIM",huggingface:"free Hunyuan3D",trellis:"Fast",trellis_selfhost:"TRELLIS",hunyuan3d:"Hunyuan3D",triposg:"TripoSG",meshy:"Meshy",tripo:"Tripo",rodin:"Rodin",stability:"Stability"};function pb(i){return PT[String(i||"").trim()]||null}function vf(i={}){let e=String(i.status||"").toLowerCase(),t=Number(i.etaSeconds)>0?Math.round(Number(i.etaSeconds)):null,n=t?`: ~${t}s`:"",r=pb(i.backend),s=r?` on the ${r} lane`:" on the free lane",a=!!i.coldStart,o=Number(i.coldSeconds)>0?Math.round(Number(i.coldSeconds)):null,l=r?` ${r}`:"";switch(e){case"submitting":case"submit":return`Sending your prompt${s}\u2026`;case"queued":case"pending":case"queue":return a?o?`Waking up the${l} GPU worker (about ${o}s), then sculpting starts`:`Waking up the${l} GPU worker, then sculpting starts`:`Queued${s}${n}`;case"image":case"texturing":return"Drafting the look\u2026";case"running":case"reconstruct":case"mesh":return`Building geometry & texturing${n}`;case"done":case"ready":return"Model ready: dropping it into the room";case"failed":case"error":return"Generation failed: try a more concrete, single-object prompt";default:return`Working${n}`}}function Sf(i,e=48){let t=String(i||"").replace(/\s+/g," ").trim();if(!t)return"Model";let n=t.split(/[,.;:]|\s+[--]\s+/)[0].trim()||t;if(n.length<=e)return n;let r=n.slice(0,e),s=r.lastIndexOf(" ");return`${(s>e*.6?r.slice(0,s):r).trim()}\u2026`}function LT(i){return i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function DT(i,e){for(let t of e)if(new RegExp(`(^|[^a-z0-9])${LT(t)}([^a-z0-9]|$)`,"i").test(i))return t;return null}var NT=["nude","nudes","naked","nsfw","porn","porno","pornographic","xxx","sex","sexual","sexy","erotic","erotica","hentai","rule34","r34","fetish","bdsm","bondage","lingerie","topless","bottomless","nipple","nipples","genital","genitalia","penis","vagina","vulva","breasts","boobs","cleavage","buttocks","thong","fellatio","cunnilingus","masturbation","orgasm","cum","creampie","milf","camgirl","stripper","escort","onlyfans"],OT=["loli","lolicon","shota","shotacon","toddlercon","underage","preteen","pre-teen","jailbait","child porn","childporn","child sex","child sexual","minor sex","csam"],FT=["gore","gory","gruesome","dismembered","dismemberment","decapitated","decapitation","beheading","mutilated","mutilation","disembowel","disemboweled","eviscerated","bloodbath","massacre","torture","tortured","snuff"],UT=["nazi","swastika","hitler","kkk","white power","heil","genocide","ethnic cleansing","terrorist","isis","al qaeda","al-qaeda"],kT=["ghost gun","ar-15","ar15","ak-47","ak47","assault rifle","submachine gun","handgun","pistol","firearm","firearms","silencer","suppressor","ammunition magazine","pipe bomb","ied","grenade","landmine","c4 explosive","meth","methamphetamine","cocaine","heroin","fentanyl","crack pipe","bong"],BT=[{id:"csam",terms:OT,message:"This prompt is not allowed."},{id:"sexual",terms:NT,message:"This studio cannot generate sexual or adult content. Describe a character, creature, or object without explicit themes."},{id:"gore",terms:FT,message:"This studio cannot generate graphically violent or gory content. Describe your subject without graphic violence."},{id:"hate",terms:UT,message:"This studio cannot generate hateful or extremist content or iconography."},{id:"weapon_drug",terms:kT,message:"This studio cannot generate real firearms, explosives, or drug paraphernalia. Stylized fantasy props (a sword, a wand) are fine."}];function mb(i){let e=String(i||"").toLowerCase();if(!e.trim())return{allowed:!0};for(let t of BT){let n=DT(e,t.terms);if(n)return{allowed:!1,category:t.id,message:t.message,matched:n}}return{allowed:!0}}function wf(i){let e=String(i??"").trim();if(e.length<3)return{ok:!1,reason:"Describe a concrete object: at least a few characters."};let t=mb(e);return t.allowed?{ok:!0,prompt:e}:{ok:!1,reason:t.message,category:t.category}}var gb={model:"forge_free",avatar:"text_to_avatar",mesh:"mesh_forge"},tr=class extends Error{constructor(e,t="failed"){super(e),this.name="ForgeError",this.code=t}};function Mf({endpoint:i=En.studioMcp,kind:e="model",tier:t="standard",timeoutMs:n=3e5,pollMs:r=3e3,headers:s,tools:a=gb,fetchImpl:o}={}){let l=yf({endpoint:i,headers:s,fetchImpl:o});async function c(h,{onProgress:d,kind:f,imageUrl:p="",signal:x,tier:y}={}){let b=wf(h);if(!b.ok)throw new tr(b.reason,b.category||"invalid_prompt");let g=b.prompt,S=f||e,A=a[S]||a.model,T=Date.now(),N=null,P=(k,V={})=>{d&&d({status:k,message:vf({status:k,etaSeconds:N,...V}),elapsedMs:Date.now()-T,etaSeconds:N})};P("submitting");let U=S==="model"?{prompt:g,...y||t?{tier:y||t}:{}}:{prompt:g,...p?{image_url:p}:{}},v=Ah(await l.callTool(A,U,{signal:x}));if(v.isError)throw new tr(v.structured?.message||v.text||"Generation failed.");let I=v.structured||{};for(;I.status==="pending"&&I.jobId;){if(Date.now()-T>n)throw new tr("Generation timed out. Try a simpler, single-object prompt.","timeout");if(N=Number(I.etaRemainingSeconds)>0?Number(I.etaRemainingSeconds):null,P("queued"),await zT(r,x),v=Ah(await l.callTool("check_job",{job_id:I.jobId},{signal:x})),v.isError)throw new tr(v.structured?.message||v.text||"Generation failed.");I=v.structured||{}}let B=Th(I.glbUrl,I.glb_url,I.url);if(!B)throw new tr(v.text||"The generator returned no model.","no_result");return P("done"),{src:B,title:Sf(g),prompt:g,kind:S,viewerUrl:Th(I.viewerUrl,""),arUrl:Th(I.arUrl,""),poster:Th(I.referenceImageUrl,""),rigged:!!I.rigged}}return{generate:c,mcp:l,endpoint:i}}function Th(...i){for(let e of i)if(typeof e=="string"&&e.trim())return e.trim();return""}function zT(i,e){return new Promise((t,n)=>{if(e?.aborted)return n(new tr("Cancelled.","aborted"));let r=setTimeout(t,i);e?.addEventListener("abort",()=>{clearTimeout(r),n(new tr("Cancelled.","aborted"))},{once:!0})})}function Wo({url:i,id:e,label:t="Models",hint:n="",searchable:r,map:s,rewriteUrl:a,fetchOptions:o}={}){if(!i)throw new Error("ar-studio: manifestSource needs a url");return{id:e||qT(t)||"models",label:t,hint:n,searchable:r,async list(){let l=await fetch(i,o);if(!l.ok)throw new Error(`catalogue ${l.status}`);let c=await l.json();return Ea(c,{map:s,rewriteUrl:a})}}}function bb(i){if(Array.isArray(i))return i;for(let e of["items","objects","avatars","creations","models","assets","results"])if(Array.isArray(i?.[e]))return i[e];return[]}var HT=["src","url","glb","glb_url","glbUrl","file","model","modelUrl"],GT=["title","label","name","prompt","displayName"],VT=["poster","thumb","thumbnail","image","preview_image_url","previewImageUrl","preview"];function Af(i,e){for(let t of e){let n=i?.[t];if(typeof n=="string"&&n.trim())return n.trim()}return""}function Ea(i,{map:e,rewriteUrl:t}={}){let n=bb(i),r=[];for(let s of n){if(!s||typeof s!="object")continue;let a=e?e(s):WT(s);if(!a)continue;let o=er(t?t(a.src):a.src);if(!o)continue;let l=a.poster?er(t?t(a.poster):a.poster):"";r.push({src:o,title:String(a.title||"").slice(0,160),poster:l||"",keywords:String(a.keywords||a.title||"").trim().toLowerCase()})}return r}function WT(i){let e=Af(i,HT);if(!e)return null;let t=Af(i,GT)||xb(e),n=[].concat(Array.isArray(i.categories)?i.categories:[]).concat(Array.isArray(i.tags)?i.tags:[]).join(" ");return{src:e,title:t,poster:Af(i,VT),keywords:`${t} ${n}`.trim().toLowerCase()}}function xb(i){let t=(String(i).split("?")[0].split("/").pop()||"Model").replace(/\.(glb|gltf)$/i,"").replace(/[_-]+/g," ").trim();return t?t.charAt(0).toUpperCase()+t.slice(1):"Model"}function qT(i){return String(i).toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function _b({items:i=[],id:e="catalogue",label:t="Catalogue",hint:n="",searchable:r}={}){let s=Ea(i);return{id:e,label:t,hint:n,searchable:r,async list(){return s}}}var Tf="ar-studio:recent:v1",$T=12;function Ef(i=Tf){try{let e=JSON.parse(localStorage.getItem(i)||"[]");return Array.isArray(e)?e.map(t=>({src:er(t?.src||t?.glb),title:String(t?.title||t?.prompt||"").slice(0,160),poster:t?.poster&&er(t.poster)||"",ts:Number(t?.ts)||0})).filter(t=>t.src):[]}catch{return[]}}function Rf({src:i,title:e="",poster:t=""},n=Tf){let r=er(i);if(r)try{let s=Ef(n).filter(a=>a.src!==r);s.unshift({src:r,title:String(e).slice(0,200),poster:t||"",ts:Date.now()}),localStorage.setItem(n,JSON.stringify(s.slice(0,$T)))}catch{}}function Eh(i={}){let e=i.recentKey||Tf;return{id:"recent",label:"Recent",hint:"",live:!0,emptyCopy:"Nothing here yet. Generate a model below, or paste a GLB link, and it lands in this tab.",async list(){return Ef(e).map(t=>({src:t.src,title:t.title,poster:t.poster,keywords:t.title.toLowerCase()}))}}}function Cf(i,e=En.origin){let t=String(i||""),n=t.match(/^https:\/\/pub-[a-z0-9]+\.r2\.dev\/(.+)$/i);return n?`${e.replace(/\/$/,"")}/cdn/${n[1]}`:t}function Rh(i={}){let e=(i.origin||En.origin).replace(/\/$/,""),t=i.objectsManifest||En.objectsManifest;return{...Wo({url:t,id:"objects",label:"Objects",searchable:!0,rewriteUrl:n=>Cf(n,e)}),hint:"Public-domain (CC0) props from three.ws: free to use anywhere, commercially too.",emptyCopy:"The object library is unreachable right now. Check your connection and retry."}}function If(i={}){let e=(i.origin||En.origin).replace(/\/$/,""),t=i.galleryEndpoint||`${e}/api/forge-gallery`;return{id:"community",label:"Community",hint:"Fresh models generated by the three.ws community.",emptyCopy:"The community feed is quiet right now. Check back in a bit.",async list(){let n=await fetch(`${t}?scope=community&limit=48`);if(!n.ok)throw new Error(`gallery ${n.status}`);return Ea(await n.json(),{rewriteUrl:r=>Cf(r,e)})}}}var Pf={id:"link",label:"Link",kind:"link"};function Lf(i,e={}){let t=Array.isArray(i)?i:[i],n=[];for(let s of t){let a=jT(s,e);Array.isArray(a)?n.push(...a):a&&n.push(a)}n.some(s=>s.kind==="link"||s.id==="link")||n.push(Pf);let r=new Set;return n.filter(s=>r.has(s.id)?!1:(r.add(s.id),!0))}function jT(i,e){if(!i)return null;if(typeof i=="object")return i;let t=String(i).trim();if(t==="three.ws"||t==="default")return[Eh(e),Rh(e)];if(t==="recent"||t==="recents")return Eh(e);if(t==="objects")return Rh(e);if(t==="community")return If(e);if(t==="link")return Pf;if(t==="none"||t==="empty")return null;if(/^https:\/\//i.test(t)||t.startsWith("/"))return Wo({url:t});throw new Error(`ar-studio: unknown asset source "${t}"`)}var Ch="https://three.ws",Ra=class extends Error{constructor(e,t){super(t),this.name="ArUrlError",this.code=e}};function yb(i){let e;try{e=new URL(String(i))}catch{throw new Ra("invalid_url","Provide a valid https URL to a .glb model.")}if(e.protocol!=="https:")throw new Ra("not_https","The model URL must be https.");if(!/\.(glb|gltf)$/i.test(e.pathname))throw new Ra("not_glb","The model URL must point at a .glb or .gltf file.");return e.toString()}function vb(i){let e=String(i||"");return/\b(iphone|ipad|ipod)\b/i.test(e)?"ios":/\bandroid\b/i.test(e)?"android":"desktop"}function Sb(i,{title:e="",fallbackUrl:t=""}={}){let n=new URLSearchParams({file:i,mode:"ar_preferred"});e&&n.set("title",e);let r=t?`S.browser_fallback_url=${encodeURIComponent(t)};`:"";return`intent://arvr.google.com/scene-viewer/1.2?${n.toString()}#Intent;scheme=https;package=com.google.ar.core;action=android.intent.action.VIEW;${r}end;`}function wb(i,e,t=""){let n=String(i||Ch).replace(/\/$/,""),r=t?`&title=${encodeURIComponent(t)}`:"";return`${n}/viewer?src=${encodeURIComponent(e)}${r}`}function Ih(i,e,t="",{live:n=!1,endpoint:r}={}){let s=r||`${String(i||Ch).replace(/\/$/,"")}/api/ar`,a=t?`&title=${encodeURIComponent(t)}`:"",o=n?"&kind=avatar":"";return`${s}?src=${encodeURIComponent(e)}${a}${o}`}function XT({glbUrl:i,userAgent:e,origin:t=Ch,title:n="",live:r=!1}={}){let s=yb(i),a=vb(e),o=wb(t,s,n),l=Sb(s,{title:n,fallbackUrl:o}),c=Ih(t,s,n,{live:r});return{target:a,action:a==="android"&&!r?"redirect":"page",asset:s,viewerUrl:o,sceneViewerUrl:l,launchUrl:c,live:r}}Vn();Vn();var Ph=class extends Or{constructor(){super(),this.name="RoomEnvironment",this.position.y=-3.5;let e=new Hr;e.deleteAttribute("uv");let t=new gi({side:An}),n=new gi,r=new ws(16777215,900,28,2);r.position.set(.418,16.199,.3),this.add(r);let s=new xt(e,t);s.position.set(-.757,13.219,.717),s.scale.set(31.713,28.305,28.591),this.add(s);let a=new _s(e,n,6),o=new qt;o.position.set(-10.906,2.009,1.846),o.rotation.set(0,-.195,0),o.scale.set(2.328,7.905,4.651),o.updateMatrix(),a.setMatrixAt(0,o.matrix),o.position.set(-5.607,-.754,-.758),o.rotation.set(0,.994,0),o.scale.set(1.97,1.534,3.955),o.updateMatrix(),a.setMatrixAt(1,o.matrix),o.position.set(6.167,.857,7.803),o.rotation.set(0,.561,0),o.scale.set(3.927,6.285,3.687),o.updateMatrix(),a.setMatrixAt(2,o.matrix),o.position.set(-2.017,.018,6.124),o.rotation.set(0,.333,0),o.scale.set(2.002,4.566,2.064),o.updateMatrix(),a.setMatrixAt(3,o.matrix),o.position.set(2.291,-.756,-2.621),o.rotation.set(0,-.286,0),o.scale.set(1.546,1.552,1.496),o.updateMatrix(),a.setMatrixAt(4,o.matrix),o.position.set(-2.193,-.369,-5.547),o.rotation.set(0,.516,0),o.scale.set(3.875,3.487,2.986),o.updateMatrix(),a.setMatrixAt(5,o.matrix),this.add(a);let l=new xt(e,Ca(50));l.position.set(-16.116,14.37,8.208),l.scale.set(.1,2.428,2.739),this.add(l);let c=new xt(e,Ca(50));c.position.set(-16.109,18.021,-8.207),c.scale.set(.1,2.425,2.751),this.add(c);let h=new xt(e,Ca(17));h.position.set(14.904,12.198,-1.832),h.scale.set(.15,4.265,6.331),this.add(h);let d=new xt(e,Ca(43));d.position.set(-.462,8.89,14.52),d.scale.set(4.38,5.441,.088),this.add(d);let f=new xt(e,Ca(20));f.position.set(3.235,11.486,-12.541),f.scale.set(2.5,2,.1),this.add(f);let p=new xt(e,Ca(100));p.position.set(0,20,0),p.scale.set(1,.1,1),this.add(p)}dispose(){let e=new Set;this.traverse(t=>{t.isMesh&&(e.add(t.geometry),e.add(t.material))});for(let t of e)t.dispose()}};function Ca(i){return new po({color:0,emissive:16777215,emissiveIntensity:i})}var Nf={high:{pixelRatioCap:2,shadows:!0,hdri:!0},medium:{pixelRatioCap:1.5,shadows:!0,hdri:!0},mobile:{pixelRatioCap:1,shadows:!1,hdri:!1}};function Of(i={}){let e=i.navigator??(typeof navigator<"u"?navigator:{}),t=i.window??(typeof window<"u"?window:{}),n=String(e.userAgent||""),r=/(iPhone|iPad|Android|Mobi)/i.test(n),s=(e.deviceMemory??8)<4,a=(e.hardwareConcurrency??8)<4,o=!!(t.matchMedia&&t.matchMedia("(any-pointer: coarse)").matches);return r&&(s||a)?"mobile":o||s||a?"medium":"high"}function Ff(i,e={}){let t=Nf[e.tier]?e.tier:"high",n=Nf[t];return i.outputColorSpace=Xt,i.toneMapping=Ro,i.toneMappingExposure=e.exposure??1.15,i.setPixelRatio(Math.min(typeof window<"u"?window.devicePixelRatio:1,n.pixelRatioCap)),i.shadowMap.enabled=n.shadows,n.shadows&&(i.shadowMap.type=qr),n}var Tb=new Map;async function Uf(i,e,t="studio",{urls:n=En.hdri}={}){let r=new wa(i);r.compileEquirectangularShader();let s=r.fromScene(new Ph,.04);e.environment=s.texture,e.environmentIntensity??=1;let a=t&&n?n[t]:null;if(!a)return r.dispose(),e.environment;try{let o=Tb.get(a);if(!o){let{HDRLoader:c}=await Promise.resolve().then(()=>(Ab(),Mb));o=await new c().loadAsync(a),Tb.set(a,o)}let l=r.fromEquirectangular(o);return e.environment===s.texture?e.environment=l.texture:l.dispose(),s.dispose(),e.environment}catch{return e.environment}finally{r.dispose()}}function KT(i,e,t,n=.35){let r=new rn().setFromObject(e);if(!Number.isFinite(r.min.y))return t??null;let a=Math.max(r.max.x-r.min.x,r.max.z-r.min.z,1)*6,o=t;return o||(o=new xt(new mi(1,1),new fo({opacity:n})),o.rotation.x=-Math.PI/2,o.receiveShadow=!0,i.add(o)),o.scale.set(a,a,1),o.position.set((r.min.x+r.max.x)/2,r.min.y,(r.min.z+r.max.z)/2),o}function Eb(){return`
+ Encoder.BUFFER_SIZE = ${Math.round(n/1024)} * 1024; // ${Math.round(n/1024)} KB
+`);let s=new Uint8Array(n);return s.set(e),e===this.sharedBuffer&&(this.sharedBuffer=s),s}encodeAll(e={offset:0},t=this.sharedBuffer){return this.encodeFullSync(e,t,!1)}encodeAllView(e,t,n,s=this.sharedBuffer){let r=n.offset;return s=this.encodeFullSync(n,s,!0,e,r),P0(s.subarray(0,t),s.subarray(r,n.offset))}ensureCapacity(e,t){if(t+i.BUFFER_SIZE<=e.byteLength)return e;let n=Math.ceil((t+i.BUFFER_SIZE)/i.BUFFER_SIZE)*i.BUFFER_SIZE,s=new Uint8Array(n);return s.set(e.subarray(0,t)),e===this.sharedBuffer&&(this.sharedBuffer=s),s}encodeView(e,t,n,s=this.sharedBuffer){let r=n.offset;this._emitStreamPriority(e);for(let a of e.changes.keys()){let o=e.changes.get(a),c=this.root.changeTrees[a];if(c===void 0){e.changes.delete(a);continue}if(o.size===0)continue;let l=c.encDescriptor,h=l.encoder,u=l.metadata,d=c.ref,p=c.refTarget;s=this.ensureCapacity(s,n.offset),s[n.offset++]=255,Bn.number(s,d[rt],n);for(let[b,v]of o){let _;if(b===lL){let L=p.tmpItems,S=p.deletedIndexes;for(let M=0;M<L.length;M++)L[M]===void 0||S[M]===!0||h(this,s,c,M,_e.ADD,n,!1,!0,u);continue}if(typeof b=="number")_=b;else{let L=b.indexInParent(d);if(L===void 0)continue;if(_=L,v===_e.ADD&&c.getChange(_)===_e.DELETE){e.changes.delete(b.ref[rt]);continue}}let E=p[bn](_)!==void 0&&v||_e.DELETE;h(this,s,c,_,E,n,!1,!0,u)}}return e.changes.clear(),s=this.encode(n,e,s),P0(s.subarray(0,t),s.subarray(r,n.offset))}encodeUnreliableView(e,t,n,s=this.sharedBuffer){let r=n.offset;return s=this.encodeUnreliable(n,e,s,r),P0(s.subarray(0,t),s.subarray(r,n.offset))}_emitStreamBroadcast(e,t){let n=this.root.streamTrees;for(let s of n){let r=s,a=r[Z],o=r[rt];if(o===void 0)continue;let c=r._stream,l=c.broadcastDeletes,h=c.broadcastPending,u=c.sentBroadcast,d=l.size>0,p=h.size>0,b=a.encDescriptor,v=b.encoder,_=b.metadata;if(d||p){if(e[t.offset++]=255,Bn.number(e,o,t),d){for(let M of l)v(this,e,a,M,_e.DELETE,t,!1,!1,_);l.clear()}let g=c.maxPerTick,E=[],L=0,S=[];for(let M of h){if(L>=g)break;let A=r[bn](M);if(A===void 0){S.push(M);continue}v(this,e,a,M,_e.ADD,t,!1,!1,_),u.add(M),E.push(A),S.push(M),L++}for(let M of S)h.delete(M);for(let M of E){let A=M[Z];if(A===void 0)continue;let I=M[rt];if(I===void 0)continue;e[t.offset++]=255,Bn.number(e,I,t);let y=A.encDescriptor,C=y.encoder,k=y.metadata;A.forEachLive(z=>{It.hasUnreliableAtIndex(k,z)||C(this,e,A,z,_e.ADD,t,!1,!1,k)})}}for(let g of u){let E=r[bn](g);if(E===void 0)continue;let L=E[Z];if(L===void 0||!L.has())continue;let S=E[rt];if(S===void 0)continue;e[t.offset++]=255,Bn.number(e,S,t);let M=L.encDescriptor,A=M.encoder,I=M.metadata;L.forEach((y,C)=>{y<0||It.hasUnreliableAtIndex(I,y)||A(this,e,L,y,C,t,!1,!1,I)})}}}_emitStreamPriority(e){let t=this.root.streamTrees;if(t.size===0)return;let n=e.id;for(let s of t){let r=s,a=r._stream,o=a.pendingByView.get(n);if(o===void 0||o.size===0)continue;let c=a.priorityByView?.get(n),l=c!==void 0,h=a.priority,u=a.maxPerTick,d=[],p=[];if(l||h!==void 0){let _=[],g=[],E=0;for(let L of o){let S=r[bn](L);if(S===void 0){p.push(L);continue}let M=l?c(S):h(e,S);if(E<u){let A=E++;for(;A>0&&g[A-1]<M;)g[A]=g[A-1],_[A]=_[A-1],A--;g[A]=M,_[A]=L}else if(M>g[u-1]){let A=u-1;for(;A>0&&g[A-1]<M;)g[A]=g[A-1],_[A]=_[A-1],A--;g[A]=M,_[A]=L}}for(let L=0;L<E;L++)d.push(_[L])}else for(let _ of o){if(d.length>=u)break;d.push(_)}for(let _ of p)o.delete(_);let b=d.length,v=a.sentByView.get(n);v===void 0&&(v=new Set,a.sentByView.set(n,v));for(let _=0;_<b;_++){let g=d[_],E=r[bn](g);if(E===void 0){o.delete(g);continue}e._addImmediate(E);let L=E[Z];if(L!==void 0){let S=E[rt],M=e.changes.get(S);M===void 0&&(M=new Map,e.changes.set(S,M));let A=L.metadata;L.forEachLive(I=>{It.hasUnreliableAtIndex(A,I)||M.set(I,_e.ADD)})}o.delete(g),v.add(g)}}}discardChanges(){let e=this.root.changes,t=e.next,n=this.root;for(;t;){let s=t.next;t.changeTree.endEncode(),n.releaseNode(t),t=s}e.next=void 0,e.tail=void 0}discardUnreliableChanges(){let e=this.root.unreliableChanges,t=e.next,n=this.root;for(;t;){let s=t.next;t.changeTree.endEncodeUnreliable(),n.releaseNode(t),t=s}e.next=void 0,e.tail=void 0}tryEncodeTypeId(e,t,n,s){let r=this.context.getTypeId(t),a=this.context.getTypeId(n);if(a===void 0){console.warn(`@colyseus/schema WARNING: Class "${n.name}" is not registered on TypeRegistry - Please either tag the class with @entity or define a @type() field.`);return}r!==a&&(e[s.offset++]=213,Bn.number(e,a,s))}get hasChanges(){return this.root.changes.next!==void 0||this._hasStreamBacklog()}get _isStreamBroadcastMode(){return this.root.activeViews.size===0&&this.root.streamTrees.size>0}_hasStreamBacklog(){let e=this.root;if(e.streamTrees.size===0)return!1;let t=e.activeViews.size===0;for(let n of e.streamTrees)if(t?iP(n):nP(n,e))return!0;return!1}get hasUnreliableChanges(){return this.root.unreliableChanges.next!==void 0}},Kf=class extends Error{constructor(e){super(e),this.name="DecodingWarning"}},Tw={value:0,enumerable:!1,writable:!0},B0=class{refs=new Map;refCount={};deletedRefs=new Set;callbacks={};nextUniqueId=0;getNextUniqueId(){return this.nextUniqueId++}addRef(e,t,n=!0){this.refs.set(e,t),t[rt]===void 0?(Tw.value=e,Object.defineProperty(t,rt,Tw)):t[rt]!==e&&(t[rt]=e),n&&(this.refCount[e]=(this.refCount[e]||0)+1),this.deletedRefs.has(e)&&this.deletedRefs.delete(e)}removeRef(e){let t=this.refCount[e];if(t===void 0){try{throw new Kf("trying to remove refId that doesn't exist: "+e)}catch(n){console.warn(n)}return}if(t===0){try{let n=this.refs.get(e);throw new Kf(`trying to remove refId '${e}' with 0 refCount (${n.constructor.name}: ${JSON.stringify(n)})`)}catch(n){console.warn(n)}return}(this.refCount[e]=t-1)<=0&&this.deletedRefs.add(e)}clearRefs(){this.refs.clear(),this.deletedRefs.clear(),this.callbacks={},this.refCount={}}garbageCollectDeletedRefs(){this.deletedRefs.forEach(e=>{if(this.refCount[e]>0)return;let t=this.refs.get(e),n=t.constructor[Symbol.metadata];if(n!=null)for(let s in n){let r=n[s].name,a=t[r];if(typeof a=="object"&&a){let o=a[rt];o!==void 0&&!this.deletedRefs.has(o)&&this.removeRef(o)}}else typeof t[pt]=="function"&&Array.from(t.values()).forEach(s=>{let r=s[rt];r!==void 0&&!this.deletedRefs.has(r)&&this.removeRef(r)});this.refs.delete(e),delete this.refCount[e],delete this.callbacks[e]}),this.deletedRefs.clear()}addCallback(e,t,n){if(e===void 0){let s=typeof t=="number"?_e[t]:t;throw new Error(`Can't addCallback on '${s}' (refId is undefined)`)}return this.callbacks[e]||(this.callbacks[e]={}),this.callbacks[e][t]||(this.callbacks[e][t]=[]),this.callbacks[e][t].push(n),()=>this.removeCallback(e,t,n)}removeCallback(e,t,n){let s=this.callbacks?.[e]?.[t]?.indexOf(n);s!==void 0&&s!==-1&&oL(this.callbacks[e][t],s)}},Yf=class{context;state;root;currentRefId=0;triggerChanges;resyncVisited=null;resyncDamaged=!1;constructor(e,t){this.setState(e),this.context=t||new Dr(e.constructor)}setState(e){this.state=e,this.root=new B0,this.root.addRef(0,e)}decode(e,t={offset:0},n=this.state){let s=this.triggerChanges!==void 0?[]:null,r=this.root,a=e.byteLength,o=n.constructor[ss];for(this.currentRefId=0;t.offset<a;){if(e[t.offset]==255){t.offset++,n[Vf]?.();let l=Mi.number(e,t),h=r.refs.get(l);h?(n=h,o=n.constructor[ss],this.currentRefId=l):(console.error(`"refId" not found: ${l}`,{previousRef:n,previousRefId:this.currentRefId}),console.warn("Please report this issue to the developers."),this.skipCurrentStructure(e,t,a));continue}if(o(this,e,t,n,s)===r1){console.warn("@colyseus/schema: definition mismatch"),this.skipCurrentStructure(e,t,a);continue}}return n[Vf]?.(),this.resyncVisited!==null&&UP(this,s),s!==null&&this.triggerChanges?.(s),r.garbageCollectDeletedRefs(),s}decodeResync(e,t={offset:0}){this.resyncVisited=new Map,this.resyncDamaged=!1;try{return this.decode(e,t)}finally{this.resyncVisited=null}}skipCurrentStructure(e,t,n){this.resyncVisited!==null&&(this.resyncDamaged=!0);let s={offset:t.offset};for(;t.offset<n&&!(e[t.offset]===255&&(s.offset=t.offset+1,this.root.refs.has(Mi.number(e,s))));)t.offset++}getInstanceType(e,t,n){let s;if(e[t.offset]===213){t.offset++;let r=Mi.number(e,t);s=this.context.get(r)}return s||n}createInstanceOfType(e){return e.initializeForDecoder()}removeChildRefs(e,t){let n=typeof e[pt]!="string",s=e[rt];e.forEach((r,a)=>{t?.push({ref:e,refId:s,op:_e.DELETE,field:a,value:void 0,previousValue:r}),n&&this.root.removeRef(r[rt])})}},h1=_l({min:hi.float64(),max:hi.float64(),bits:hi.uint8(),mode:hi.uint8()},"QuantizedDescriptor"),u1=_l({name:hi.string(),type:hi.string(),referencedType:hi.number(),childPrimitive:hi.string(),quantized:hi.ref(h1).optional()},"ReflectionField"),f1=_l({id:hi.number(),extendsId:hi.number(),fields:hi.array(u1)},"ReflectionType"),dl=_l({types:hi.array(f1),rootType:hi.number()},"Reflection");dl.encode=function(i,e={offset:0}){let t=i.context,n=new dl,s=new U0(n),r=t.schemas.get(i.state.constructor);r>0&&(n.rootType=r);let a=new Set,o={},c=h=>{if(h.extendsId===void 0||a.has(h.extendsId)){a.add(h.id),n.types.push(h);let u=o[h.id];u!==void 0&&(delete o[h.id],u.forEach(d=>c(d)))}else o[h.extendsId]===void 0&&(o[h.extendsId]=[]),o[h.extendsId].push(h)};t.schemas.forEach((h,u)=>{let d=new f1;d.id=Number(h);let p=Object.getPrototypeOf(u);p!==en&&(d.extendsId=t.schemas.get(p));let b=u[Symbol.metadata];if(b!==p[Symbol.metadata]){let v=b[Un]??-1;for(let _=0;_<=v;_++){let g=b[_];if(g===void 0)continue;let E=g.name;if(!Object.prototype.hasOwnProperty.call(b,E))continue;let L=new u1;L.name=E;let S;if(typeof g.type=="string")S=g.type;else if(Lr(g.type)){let M=g.type.quantized;S="quantized";let A=new h1;A.min=M.min,A.max=M.max,A.bits=M.bits,A.mode=M.wrap?1:0,L.quantized=A}else{let M;en.is(g.type)?(S="ref",M=g.type):(S=Object.keys(g.type)[0],typeof g.type[S]=="string"?L.childPrimitive=g.type[S]:M=g.type[S]),L.referencedType=M?t.getTypeId(M):-1}L.type=S,d.fields.push(L)}}c(d)});for(let h in o)o[h].forEach(u=>n.types.push(u));return s.encodeAll(e).slice(0,e.offset)};dl.decode=function(i,e){let t=new dl;new Yf(t).decode(i,e);let s=new Dr;t.types.forEach(o=>{let c=s.get(o.extendsId)??en,l=class extends c{};Dr.register(l),s.add(l,o.id)},{});let r=(o,c,l)=>{c.fields.forEach((h,u)=>{let d=l+u;if(h.quantized!==void 0){let p=h.quantized;It.addField(o,d,h.name,{quantized:G0({min:p.min,max:p.max,bits:p.bits,mode:p.mode===1?"wrap":"clamp"})})}else if(h.referencedType!==void 0){let p=h.type,b=s.get(h.referencedType)??h.childPrimitive;p==="ref"?It.addField(o,d,h.name,b):It.addField(o,d,h.name,{[p]:b})}else It.addField(o,d,h.name,h.type)})};t.types.forEach(o=>{let c=s.get(o.id),l=It.initialize(c),h=[],u=o;do h.push(u),u=t.types.find(p=>p.id===u.extendsId);while(u);let d=0;h.reverse().forEach(p=>{r(l,p,d),d+=p.fields.length})});let a=new(s.get(t.rootType||0));return new Yf(a,s)};dl.makeEncodable=function(i){let e=i[Symbol.metadata];if(!e)return i;let t=e[Un];if(t===void 0)return i;for(let n=0;n<=t;n++){let s=e[n];s&&It.defineField(i,e,n,s.name,s.type)}return Object.prototype.hasOwnProperty.call(i,al)&&delete i[al],i};Zs("map",{constructor:as});Zs("array",{constructor:Pr});Zs("set",{constructor:fl});Zs("collection",{constructor:ul})});var p1={};er(p1,{StudioModel:()=>xl,StudioState:()=>od,StudioViewer:()=>yl});var xl,yl,od,m1=un(()=>{"use strict";d1();xl=class extends en{constructor(){super(),this.id="",this.src="",this.title="",this.relEast=0,this.relNorth=0,this.yawDeg=0,this.scale=1,this.height=0,this.ownerId="",this.ts=0}};ad(xl,{id:"string",src:"string",title:"string",relEast:"float32",relNorth:"float32",yawDeg:"float32",scale:"float32",height:"float32",ownerId:"string",ts:"float64"});yl=class extends en{constructor(){super(),this.id="",this.name="",this.ownerId="",this.tsServer=0}};ad(yl,{id:"string",name:"string",ownerId:"string",tsServer:"float64"});od=class extends en{constructor(){super(),this.roomKey="",this.models=new as,this.viewers=new as}};ad(od,{roomKey:"string",models:{map:xl},viewers:{map:yl}})});Qn();Au();var On={origin:"https://three.ws",objectsManifest:"https://three.ws/cdn/objects/library/manifest.json",studioMcp:"https://three.ws/api/mcp-studio",animationManifest:"https://three.ws/animations/manifest.json",hdri:{studio:"https://three.ws/hdri/studio.hdr",outdoor:"https://three.ws/hdri/outdoor.hdr",sunset:"https://three.ws/hdri/sunset.hdr"},arLaunch:"https://three.ws/api/ar",roomServer:"wss://three-ws-multiplayer-93741856042.us-central1.run.app"},ox={assets:"three.ws",allowUrlOverride:!0,generate:{enabled:!0,endpoint:On.studioMcp,kind:"model",tier:"standard",timeoutMs:3e5,pollMs:3e3},rooms:{enabled:!0,server:On.roomServer},animations:{enabled:!0,manifestUrl:On.animationManifest,clip:"idle"},lighting:{preset:"studio",urls:On.hdri},arLaunchUrl:On.arLaunch,branding:{title:"AR Studio",backHref:null,backLabel:"Back",accent:"#8b7cf8"},shareBaseUrl:"",persistKey:"ar-studio:scene:v1",maxPlacements:20,persist:!0,onEvent:null};function Gp(i){return!!i&&typeof i=="object"&&!Array.isArray(i)}function Wp(i,e){if(!Gp(e))return i;let t={...i};for(let[n,s]of Object.entries(e))s!==void 0&&(t[n]=Gp(s)&&Gp(i?.[n])?Wp(i[n],s):s);return t}function ys(i){let e=String(i??"").trim();if(!e)return null;if(e.startsWith("/")&&!e.startsWith("//"))return e;try{let t=new URL(e);return t.protocol==="https:"?t.href:null}catch{return null}}function $p(i={},e){let t=Wp(ox,i),n=e instanceof URLSearchParams?e:new URLSearchParams(typeof e=="string"?e:typeof location<"u"?location.search:""),s=[],r="",a="";if(t.allowUrlOverride){let o=n.get("assets")||n.get("source"),c=o?ys(o):null;c&&(t.assets=c);let l=n.getAll("src"),h=n.getAll("title");for(let u=0;u<l.length&&s.length<t.maxPlacements;u++){let d=ys(l[u]);d&&s.push({src:d,title:String(h[u]||"").slice(0,120)})}r=String(n.get("room")||"").trim(),a=String(n.get("forge")||n.get("prompt")||"").trim()}return!t.shareBaseUrl&&typeof location<"u"&&(t.shareBaseUrl=`${location.origin}${location.pathname}`),{...t,urlModels:s,urlRoom:r,urlPrompt:a}}var yC=()=>{};function vC(){if(typeof window>"u")return!1;try{let i=new URLSearchParams(window.location.search);return i.has("ar-debug")&&i.get("ar-debug")!=="0"?!0:window.localStorage?.getItem("ar-studio:debug")==="1"}catch{return!1}}var ca=vC(),oa=i=>typeof console<"u"&&typeof console[i]=="function"?console[i].bind(console):yC;function SC(i){ca=!!i}function wC(){return ca}var Tu=i=>(...e)=>{ca&&oa(i)(...e)},ci={error:(...i)=>oa("error")(...i),warn:Tu("warn"),info:Tu("info"),debug:Tu("debug"),log:Tu("log")};function la(i){let e=`[${i}]`;return{error:(...t)=>oa("error")(e,...t),warn:(...t)=>{ca&&oa("warn")(e,...t)},info:(...t)=>{ca&&oa("info")(e,...t)},debug:(...t)=>{ca&&oa("debug")(e,...t)},log:(...t)=>{ca&&oa("log")(e,...t)}}}var cx=[[7,10,15,20,26,18,20,24,30,18]],lx=[[1,1,1,1,1,2,2,2,2,4]];function MC(i){return i*4+17}function hx(i){let e=ux(i)>>>3,t=lx[0][i-1],n=cx[0][i-1];return e-n*t}function ux(i){let e=(16*i+128)*i+64;if(i>=2){let t=Math.floor(i/7)+2;e-=(25*t-10)*t-55,i>=7&&(e-=36)}return e}function EC(i){let e=new Uint8Array(i);e[i-1]=1;let t=1;for(let n=0;n<i;n++){for(let s=0;s<i;s++)e[s]=qp(e[s],t),s+1<i&&(e[s]^=e[s+1]);t=qp(t,2)}return e}function qp(i,e){let t=0;for(let n=7;n>=0;n--)t=t<<1^(t>>>7)*285,t^=(e>>>n&1)*i;return t&255}function AC(i,e){let t=new Uint8Array(e.length);for(let n of i){let s=n^t[0];t.copyWithin(0,1),t[t.length-1]=0;for(let r=0;r<t.length;r++)t[r]^=qp(e[r],s)}return t}function TC(i){for(let e=1;e<=10;e++){let t=hx(e)*8;if(4+(e<10?8:16)+i*8<=t)return e}throw new Error("QR payload too large (>10 versions)")}function jp(i){let e=new TextEncoder().encode(i),t=TC(e.length),n=MC(t),s=t<10?8:16,r=[],a=(N,O)=>{for(let F=O-1;F>=0;F--)r.push(N>>>F&1)};a(4,4),a(e.length,s);for(let N of e)a(N,8);let o=hx(t),c=o*8;for(let N=0;N<4&&r.length<c;N++)r.push(0);for(;r.length%8!==0;)r.push(0);let l=[236,17],h=0;for(;r.length<c;)a(l[h%2],8),h++;let u=new Uint8Array(o);for(let N=0;N<o;N++){let O=0;for(let F=0;F<8;F++)O=O<<1|r[N*8+F];u[N]=O}let d=lx[0][t-1],p=cx[0][t-1],b=ux(t)>>>3,v=Math.floor(b/d),_=d-b%d,g=[],E=EC(p),L=0;for(let N=0;N<d;N++){let O=v-p+(N<_?0:1),F=u.slice(L,L+O);L+=O;let H=AC(F,E);g.push({dat:F,ec:H})}let S=[];for(let N=0;N<v-p+1;N++)for(let O of g)N<O.dat.length&&S.push(O.dat[N]);for(let N=0;N<p;N++)for(let O of g)S.push(O.ec[N]);let M=Array.from({length:n},()=>new Array(n).fill(!1)),A=Array.from({length:n},()=>new Array(n).fill(!1)),I=(N,O,F)=>{M[O][N]=F,A[O][N]=!0},y=(N,O)=>{for(let F=-4;F<=4;F++)for(let H=-4;H<=4;H++){let V=N+H,Q=O+F;if(V<0||V>=n||Q<0||Q>=n)continue;let te=Math.max(Math.abs(H),Math.abs(F));I(V,Q,te!==2&&te!==4)}};y(3,3),y(n-4,3),y(3,n-4);for(let N=0;N<n;N++)A[6][N]||I(N,6,N%2===0),A[N][6]||I(6,N,N%2===0);let k=(N=>{if(N===1)return[];let O=Math.floor(N/7)+2,F=N===32?26:Math.ceil((N*4+4)/(O*2-2))*2,H=[6];for(let V=n-7;H.length<O;V-=F)H.splice(1,0,V);return H})(t);for(let N of k)for(let O of k)if(!(N===6&&O===6||N===6&&O===n-7||N===n-7&&O===6))for(let F=-2;F<=2;F++)for(let H=-2;H<=2;H++){let V=Math.max(Math.abs(H),Math.abs(F));I(N+H,O+F,V!==1)}for(let N=0;N<9;N++)I(8,N,!1);for(let N=0;N<8;N++)I(N,8,!1);for(let N=0;N<8;N++)I(n-1-N,8,!1);for(let N=0;N<7;N++)I(8,n-1-N,!1);if(I(8,n-8,!0),t>=7){let N=t;for(let F=0;F<12;F++)N=N<<1^(N>>>11)*7973;let O=(t<<12|N)>>>0;for(let F=0;F<18;F++){let H=(O>>>F&1)===1,V=n-11+F%3,Q=Math.floor(F/3);I(V,Q,H),I(Q,V,H)}}let z=0,$=N=>(S[N>>>3]>>>7-(N&7)&1)===1;for(let N=n-1;N>=1;N-=2){N===6&&(N=5);for(let O=0;O<n;O++)for(let F=0;F<2;F++){let H=N-F,Q=(N+1&2)===0?n-1-O:O;!A[Q][H]&&z<S.length*8&&(M[Q][H]=$(z),z++)}}let K=1/0,P=null;for(let N=0;N<8;N++){let O=M.map(H=>H.slice());CC(O,A,N),IC(O,N);let F=LC(O);F<K&&(K=F,P=O)}return{size:n,modules:P}}function RC(i,e,t){switch(i){case 0:return(e+t)%2===0;case 1:return t%2===0;case 2:return e%3===0;case 3:return(e+t)%3===0;case 4:return(Math.floor(e/3)+Math.floor(t/2))%2===0;case 5:return e*t%2+e*t%3===0;case 6:return(e*t%2+e*t%3)%2===0;case 7:return((e+t)%2+e*t%3)%2===0}return!1}function CC(i,e,t){let n=i.length;for(let s=0;s<n;s++)for(let r=0;r<n;r++)!e[s][r]&&RC(t,r,s)&&(i[s][r]=!i[s][r])}function IC(i,e){let t=i.length,n=PC[0]<<3|e,s=n;for(let o=0;o<10;o++)s=s<<1^(s>>>9)*1335;let r=((n<<10|s)^21522)>>>0,a=(o,c,l)=>{i[c][o]=l};for(let o=0;o<=5;o++)a(8,o,(r>>>o&1)===1);a(8,7,(r>>>6&1)===1),a(8,8,(r>>>7&1)===1),a(7,8,(r>>>8&1)===1);for(let o=9;o<15;o++)a(14-o,8,(r>>>o&1)===1);for(let o=0;o<8;o++)a(t-1-o,8,(r>>>o&1)===1);for(let o=8;o<15;o++)a(8,t-15+o,(r>>>o&1)===1);a(8,t-8,!0)}var PC=[1,0,3,2];function LC(i){let e=i.length,t=0;for(let a=0;a<e;a++){let o=1;for(let c=1;c<e;c++)i[a][c]===i[a][c-1]?(o++,o===5?t+=3:o>5&&t++):o=1}for(let a=0;a<e;a++){let o=1;for(let c=1;c<e;c++)i[c][a]===i[c-1][a]?(o++,o===5?t+=3:o>5&&t++):o=1}for(let a=0;a<e-1;a++)for(let o=0;o<e-1;o++){let c=i[a][o];i[a][o+1]===c&&i[a+1][o]===c&&i[a+1][o+1]===c&&(t+=3)}let n=0;for(let a=0;a<e;a++)for(let o=0;o<e;o++)i[a][o]&&n++;let s=e*e,r=Math.floor(Math.abs(n*20-s*10)/s);return t+=r*10,t}function Fc(i,e={}){let t=e.scale??8,n=e.margin??2,s=e.dark??"#000",r=e.light??"#fff",{size:a,modules:o}=jp(i),c=(a+n*2)*t,l="";for(let h=0;h<a;h++)for(let u=0;u<a;u++)o[h][u]&&(l+=`<rect x="${(u+n)*t}" y="${(h+n)*t}" width="${t}" height="${t}"/>`);return`<svg xmlns="http://www.w3.org/2000/svg" width="${c}" height="${c}" viewBox="0 0 ${c} ${c}" shape-rendering="crispEdges"><rect width="${c}" height="${c}" fill="${r}"/><g fill="${s}">${l}</g></svg>`}function DC(i,e={}){let t=e.scale??8,n=e.margin??2,{size:s,modules:r}=jp(i),a=(s+n*2)*t,o=document.createElement("canvas");o.width=a,o.height=a;let c=o.getContext("2d");c.fillStyle="#fff",c.fillRect(0,0,a,a),c.fillStyle="#000";for(let l=0;l<s;l++)for(let h=0;h<s;h++)r[l][h]&&c.fillRect((h+n)*t,(l+n)*t,t,t);return o}var NC=1;function Xp({endpoint:i,headers:e={},fetchImpl:t}={}){if(!i)throw new Error("ar-studio: MCP client needs an endpoint");let n=t||(typeof fetch<"u"?fetch.bind(globalThis):null);if(!n)throw new Error("ar-studio: no fetch implementation available");let s="";async function r(a,o,{signal:c}={}){let l=NC++,h=await n(i,{method:"POST",signal:c,headers:{"content-type":"application/json",accept:"application/json, text/event-stream",...s?{"mcp-session-id":s}:{},...e},body:JSON.stringify({jsonrpc:"2.0",id:l,method:a,...o?{params:o}:{}})}),u=h.headers.get("mcp-session-id");if(u&&(s=u),!h.ok){let p=await h.text().catch(()=>"");throw new mo(`${a} failed (${h.status})`,{status:h.status,detail:p})}let d=await OC(h,l);if(d?.error)throw new mo(d.error.message||"MCP error",{code:d.error.code});return d?.result??null}return{get sessionId(){return s},rpc:r,listTools(a){return r("tools/list",void 0,a).then(o=>o?.tools||[])},callTool(a,o={},c){return r("tools/call",{name:a,arguments:o},c)}}}var mo=class extends Error{constructor(e,t={}){super(e),this.name="McpError",Object.assign(this,t)}};async function OC(i,e){if(!String(i.headers.get("content-type")||"").includes("text/event-stream"))return i.json();let n=await i.text();for(let s of n.split(/\n\n+/)){let r=s.split(`
+`).filter(a=>a.startsWith("data:")).map(a=>a.slice(5).trim()).join("");if(r)try{let a=JSON.parse(r);if(a.id===e||a.error)return a}catch{}}throw new mo("MCP stream ended without a result")}function Ru(i){let e=i?.structuredContent??null,t=(i?.content||[]).filter(n=>n?.type==="text"&&typeof n.text=="string").map(n=>n.text).join(`
+`).trim();return{structured:e,text:t,isError:!!i?.isError}}var FC={nvidia:"free NVIDIA NIM",huggingface:"free Hunyuan3D",trellis:"Fast",trellis_selfhost:"TRELLIS",hunyuan3d:"Hunyuan3D",triposg:"TripoSG",meshy:"Meshy",tripo:"Tripo",rodin:"Rodin",stability:"Stability"};function fx(i){return FC[String(i||"").trim()]||null}function Kp(i={}){let e=String(i.status||"").toLowerCase(),t=Number(i.etaSeconds)>0?Math.round(Number(i.etaSeconds)):null,n=t?`: ~${t}s`:"",s=fx(i.backend),r=s?` on the ${s} lane`:" on the free lane",a=!!i.coldStart,o=Number(i.coldSeconds)>0?Math.round(Number(i.coldSeconds)):null,c=s?` ${s}`:"";switch(e){case"submitting":case"submit":return`Sending your prompt${r}\u2026`;case"queued":case"pending":case"queue":return a?o?`Waking up the${c} GPU worker (about ${o}s), then sculpting starts`:`Waking up the${c} GPU worker, then sculpting starts`:`Queued${r}${n}`;case"image":case"texturing":return"Drafting the look\u2026";case"running":case"reconstruct":case"mesh":return`Building geometry & texturing${n}`;case"done":case"ready":return"Model ready: dropping it into the room";case"failed":case"error":return"Generation failed: try a more concrete, single-object prompt";default:return`Working${n}`}}function Yp(i,e=48){let t=String(i||"").replace(/\s+/g," ").trim();if(!t)return"Model";let n=t.split(/[,.;:]|\s+[--]\s+/)[0].trim()||t;if(n.length<=e)return n;let s=n.slice(0,e),r=s.lastIndexOf(" ");return`${(r>e*.6?s.slice(0,r):s).trim()}\u2026`}function kC(i){return i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function UC(i,e){for(let t of e)if(new RegExp(`(^|[^a-z0-9])${kC(t)}([^a-z0-9]|$)`,"i").test(i))return t;return null}var BC=["nude","nudes","naked","nsfw","porn","porno","pornographic","xxx","sex","sexual","sexy","erotic","erotica","hentai","rule34","r34","fetish","bdsm","bondage","lingerie","topless","bottomless","nipple","nipples","genital","genitalia","penis","vagina","vulva","breasts","boobs","cleavage","buttocks","thong","fellatio","cunnilingus","masturbation","orgasm","cum","creampie","milf","camgirl","stripper","escort","onlyfans"],zC=["loli","lolicon","shota","shotacon","toddlercon","underage","preteen","pre-teen","jailbait","child porn","childporn","child sex","child sexual","minor sex","csam"],HC=["gore","gory","gruesome","dismembered","dismemberment","decapitated","decapitation","beheading","mutilated","mutilation","disembowel","disemboweled","eviscerated","bloodbath","massacre","torture","tortured","snuff"],VC=["nazi","swastika","hitler","kkk","white power","heil","genocide","ethnic cleansing","terrorist","isis","al qaeda","al-qaeda"],GC=["ghost gun","ar-15","ar15","ak-47","ak47","assault rifle","submachine gun","handgun","pistol","firearm","firearms","silencer","suppressor","ammunition magazine","pipe bomb","ied","grenade","landmine","c4 explosive","meth","methamphetamine","cocaine","heroin","fentanyl","crack pipe","bong"],WC=[{id:"csam",terms:zC,message:"This prompt is not allowed."},{id:"sexual",terms:BC,message:"This studio cannot generate sexual or adult content. Describe a character, creature, or object without explicit themes."},{id:"gore",terms:HC,message:"This studio cannot generate graphically violent or gory content. Describe your subject without graphic violence."},{id:"hate",terms:VC,message:"This studio cannot generate hateful or extremist content or iconography."},{id:"weapon_drug",terms:GC,message:"This studio cannot generate real firearms, explosives, or drug paraphernalia. Stylized fantasy props (a sword, a wand) are fine."}];function dx(i){let e=String(i||"").toLowerCase();if(!e.trim())return{allowed:!0};for(let t of WC){let n=UC(e,t.terms);if(n)return{allowed:!1,category:t.id,message:t.message,matched:n}}return{allowed:!0}}function Jp(i){let e=String(i??"").trim();if(e.length<3)return{ok:!1,reason:"Describe a concrete object: at least a few characters."};let t=dx(e);return t.allowed?{ok:!0,prompt:e}:{ok:!1,reason:t.message,category:t.category}}var px={model:"forge_free",avatar:"text_to_avatar",mesh:"mesh_forge"},vs=class extends Error{constructor(e,t="failed"){super(e),this.name="ForgeError",this.code=t}};function Zp({endpoint:i=On.studioMcp,kind:e="model",tier:t="standard",timeoutMs:n=3e5,pollMs:s=3e3,headers:r,tools:a=px,fetchImpl:o}={}){let c=Xp({endpoint:i,headers:r,fetchImpl:o});async function l(h,{onProgress:u,kind:d,imageUrl:p="",signal:b,tier:v}={}){let _=Jp(h);if(!_.ok)throw new vs(_.reason,_.category||"invalid_prompt");let g=_.prompt,E=d||e,L=a[E]||a.model,S=Date.now(),M=null,A=(z,$={})=>{u&&u({status:z,message:Kp({status:z,etaSeconds:M,...$}),elapsedMs:Date.now()-S,etaSeconds:M})};A("submitting");let I=E==="model"?{prompt:g,...v||t?{tier:v||t}:{}}:{prompt:g,...p?{image_url:p}:{}},y=Ru(await c.callTool(L,I,{signal:b}));if(y.isError)throw new vs(y.structured?.message||y.text||"Generation failed.");let C=y.structured||{};for(;C.status==="pending"&&C.jobId;){if(Date.now()-S>n)throw new vs("Generation timed out. Try a simpler, single-object prompt.","timeout");if(M=Number(C.etaRemainingSeconds)>0?Number(C.etaRemainingSeconds):null,A("queued"),await $C(s,b),y=Ru(await c.callTool("check_job",{job_id:C.jobId},{signal:b})),y.isError)throw new vs(y.structured?.message||y.text||"Generation failed.");C=y.structured||{}}let k=Cu(C.glbUrl,C.glb_url,C.url);if(!k)throw new vs(y.text||"The generator returned no model.","no_result");return A("done"),{src:k,title:Yp(g),prompt:g,kind:E,viewerUrl:Cu(C.viewerUrl,""),arUrl:Cu(C.arUrl,""),poster:Cu(C.referenceImageUrl,""),rigged:!!C.rigged}}return{generate:l,mcp:c,endpoint:i}}function Cu(...i){for(let e of i)if(typeof e=="string"&&e.trim())return e.trim();return""}function $C(i,e){return new Promise((t,n)=>{if(e?.aborted)return n(new vs("Cancelled.","aborted"));let s=setTimeout(t,i);e?.addEventListener("abort",()=>{clearTimeout(s),n(new vs("Cancelled.","aborted"))},{once:!0})})}function kc({url:i,id:e,label:t="Models",hint:n="",searchable:s,map:r,rewriteUrl:a,fetchOptions:o}={}){if(!i)throw new Error("ar-studio: manifestSource needs a url");return{id:e||YC(t)||"models",label:t,hint:n,searchable:s,async list(){let c=await fetch(i,o);if(!c.ok)throw new Error(`catalogue ${c.status}`);let l=await c.json();return go(l,{map:r,rewriteUrl:a})}}}function mx(i){if(Array.isArray(i))return i;for(let e of["items","objects","avatars","creations","models","assets","results"])if(Array.isArray(i?.[e]))return i[e];return[]}var qC=["src","url","glb","glb_url","glbUrl","file","model","modelUrl"],jC=["title","label","name","prompt","displayName"],XC=["poster","thumb","thumbnail","image","preview_image_url","previewImageUrl","preview"];function Qp(i,e){for(let t of e){let n=i?.[t];if(typeof n=="string"&&n.trim())return n.trim()}return""}function go(i,{map:e,rewriteUrl:t}={}){let n=mx(i),s=[];for(let r of n){if(!r||typeof r!="object")continue;let a=e?e(r):KC(r);if(!a)continue;let o=ys(t?t(a.src):a.src);if(!o)continue;let c=a.poster?ys(t?t(a.poster):a.poster):"";s.push({src:o,title:String(a.title||"").slice(0,160),poster:c||"",keywords:String(a.keywords||a.title||"").trim().toLowerCase()})}return s}function KC(i){let e=Qp(i,qC);if(!e)return null;let t=Qp(i,jC)||gx(e),n=[].concat(Array.isArray(i.categories)?i.categories:[]).concat(Array.isArray(i.tags)?i.tags:[]).join(" ");return{src:e,title:t,poster:Qp(i,XC),keywords:`${t} ${n}`.trim().toLowerCase()}}function gx(i){let t=(String(i).split("?")[0].split("/").pop()||"Model").replace(/\.(glb|gltf)$/i,"").replace(/[_-]+/g," ").trim();return t?t.charAt(0).toUpperCase()+t.slice(1):"Model"}function YC(i){return String(i).toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function bx({items:i=[],id:e="catalogue",label:t="Catalogue",hint:n="",searchable:s}={}){let r=go(i);return{id:e,label:t,hint:n,searchable:s,async list(){return r}}}var em="ar-studio:recent:v1",JC=12;function tm(i=em){try{let e=JSON.parse(localStorage.getItem(i)||"[]");return Array.isArray(e)?e.map(t=>({src:ys(t?.src||t?.glb),title:String(t?.title||t?.prompt||"").slice(0,160),poster:t?.poster&&ys(t.poster)||"",ts:Number(t?.ts)||0})).filter(t=>t.src):[]}catch{return[]}}function nm({src:i,title:e="",poster:t=""},n=em){let s=ys(i);if(s)try{let r=tm(n).filter(a=>a.src!==s);r.unshift({src:s,title:String(e).slice(0,200),poster:t||"",ts:Date.now()}),localStorage.setItem(n,JSON.stringify(r.slice(0,JC)))}catch{}}function Iu(i={}){let e=i.recentKey||em;return{id:"recent",label:"Recent",hint:"",live:!0,emptyCopy:"Nothing here yet. Generate a model below, or paste a GLB link, and it lands in this tab.",async list(){return tm(e).map(t=>({src:t.src,title:t.title,poster:t.poster,keywords:t.title.toLowerCase()}))}}}function im(i,e=On.origin){let t=String(i||""),n=t.match(/^https:\/\/pub-[a-z0-9]+\.r2\.dev\/(.+)$/i);return n?`${e.replace(/\/$/,"")}/cdn/${n[1]}`:t}function Pu(i={}){let e=(i.origin||On.origin).replace(/\/$/,""),t=i.objectsManifest||On.objectsManifest;return{...kc({url:t,id:"objects",label:"Objects",searchable:!0,rewriteUrl:n=>im(n,e)}),hint:"Public-domain (CC0) props from three.ws: free to use anywhere, commercially too.",emptyCopy:"The object library is unreachable right now. Check your connection and retry."}}function sm(i={}){let e=(i.origin||On.origin).replace(/\/$/,""),t=i.galleryEndpoint||`${e}/api/forge-gallery`;return{id:"community",label:"Community",hint:"Fresh models generated by the three.ws community.",emptyCopy:"The community feed is quiet right now. Check back in a bit.",async list(){let n=await fetch(`${t}?scope=community&limit=48`);if(!n.ok)throw new Error(`gallery ${n.status}`);return go(await n.json(),{rewriteUrl:s=>im(s,e)})}}}var rm={id:"link",label:"Link",kind:"link"};function am(i,e={}){let t=Array.isArray(i)?i:[i],n=[];for(let r of t){let a=ZC(r,e);Array.isArray(a)?n.push(...a):a&&n.push(a)}n.some(r=>r.kind==="link"||r.id==="link")||n.push(rm);let s=new Set;return n.filter(r=>s.has(r.id)?!1:(s.add(r.id),!0))}function ZC(i,e){if(!i)return null;if(typeof i=="object")return i;let t=String(i).trim();if(t==="three.ws"||t==="default")return[Iu(e),Pu(e)];if(t==="recent"||t==="recents")return Iu(e);if(t==="objects")return Pu(e);if(t==="community")return sm(e);if(t==="link")return rm;if(t==="none"||t==="empty")return null;if(/^https:\/\//i.test(t)||t.startsWith("/"))return kc({url:t});throw new Error(`ar-studio: unknown asset source "${t}"`)}var Lu="https://three.ws",bo=class extends Error{constructor(e,t){super(t),this.name="ArUrlError",this.code=e}};function _x(i){let e;try{e=new URL(String(i))}catch{throw new bo("invalid_url","Provide a valid https URL to a .glb model.")}if(e.protocol!=="https:")throw new bo("not_https","The model URL must be https.");if(!/\.(glb|gltf)$/i.test(e.pathname))throw new bo("not_glb","The model URL must point at a .glb or .gltf file.");return e.toString()}function xx(i){let e=String(i||"");return/\b(iphone|ipad|ipod)\b/i.test(e)?"ios":/\bandroid\b/i.test(e)?"android":"desktop"}function yx(i,{title:e="",fallbackUrl:t=""}={}){let n=new URLSearchParams({file:i,mode:"ar_preferred"});e&&n.set("title",e);let s=t?`S.browser_fallback_url=${encodeURIComponent(t)};`:"";return`intent://arvr.google.com/scene-viewer/1.2?${n.toString()}#Intent;scheme=https;package=com.google.ar.core;action=android.intent.action.VIEW;${s}end;`}function vx(i,e,t=""){let n=String(i||Lu).replace(/\/$/,""),s=t?`&title=${encodeURIComponent(t)}`:"";return`${n}/viewer?src=${encodeURIComponent(e)}${s}`}function Du(i,e,t="",{live:n=!1,endpoint:s}={}){let r=s||`${String(i||Lu).replace(/\/$/,"")}/api/ar`,a=t?`&title=${encodeURIComponent(t)}`:"",o=n?"&kind=avatar":"";return`${r}?src=${encodeURIComponent(e)}${a}${o}`}function QC({glbUrl:i,userAgent:e,origin:t=Lu,title:n="",live:s=!1}={}){let r=_x(i),a=xx(e),o=vx(t,r,n),c=yx(r,{title:n,fallbackUrl:o}),l=Du(t,r,n,{live:s});return{target:a,action:a==="android"&&!s?"redirect":"page",asset:r,viewerUrl:o,sceneViewerUrl:c,launchUrl:l,live:s}}Qn();Qn();var Nu=class extends cr{constructor(){super(),this.name="RoomEnvironment",this.position.y=-3.5;let e=new mr;e.deleteAttribute("uv");let t=new Pi({side:Nn}),n=new Pi,s=new Qr(16777215,900,28,2);s.position.set(.418,16.199,.3),this.add(s);let r=new vt(e,t);r.position.set(-.757,13.219,.717),r.scale.set(31.713,28.305,28.591),this.add(r);let a=new Kr(e,n,6),o=new Yt;o.position.set(-10.906,2.009,1.846),o.rotation.set(0,-.195,0),o.scale.set(2.328,7.905,4.651),o.updateMatrix(),a.setMatrixAt(0,o.matrix),o.position.set(-5.607,-.754,-.758),o.rotation.set(0,.994,0),o.scale.set(1.97,1.534,3.955),o.updateMatrix(),a.setMatrixAt(1,o.matrix),o.position.set(6.167,.857,7.803),o.rotation.set(0,.561,0),o.scale.set(3.927,6.285,3.687),o.updateMatrix(),a.setMatrixAt(2,o.matrix),o.position.set(-2.017,.018,6.124),o.rotation.set(0,.333,0),o.scale.set(2.002,4.566,2.064),o.updateMatrix(),a.setMatrixAt(3,o.matrix),o.position.set(2.291,-.756,-2.621),o.rotation.set(0,-.286,0),o.scale.set(1.546,1.552,1.496),o.updateMatrix(),a.setMatrixAt(4,o.matrix),o.position.set(-2.193,-.369,-5.547),o.rotation.set(0,.516,0),o.scale.set(3.875,3.487,2.986),o.updateMatrix(),a.setMatrixAt(5,o.matrix),this.add(a);let c=new vt(e,_o(50));c.position.set(-16.116,14.37,8.208),c.scale.set(.1,2.428,2.739),this.add(c);let l=new vt(e,_o(50));l.position.set(-16.109,18.021,-8.207),l.scale.set(.1,2.425,2.751),this.add(l);let h=new vt(e,_o(17));h.position.set(14.904,12.198,-1.832),h.scale.set(.15,4.265,6.331),this.add(h);let u=new vt(e,_o(43));u.position.set(-.462,8.89,14.52),u.scale.set(4.38,5.441,.088),this.add(u);let d=new vt(e,_o(20));d.position.set(3.235,11.486,-12.541),d.scale.set(2.5,2,.1),this.add(d);let p=new vt(e,_o(100));p.position.set(0,20,0),p.scale.set(1,.1,1),this.add(p)}dispose(){let e=new Set;this.traverse(t=>{t.isMesh&&(e.add(t.geometry),e.add(t.material))});for(let t of e)t.dispose()}};function _o(i){return new oc({color:0,emissive:16777215,emissiveIntensity:i})}var cm={high:{pixelRatioCap:2,shadows:!0,hdri:!0},medium:{pixelRatioCap:1.5,shadows:!0,hdri:!0},mobile:{pixelRatioCap:1,shadows:!1,hdri:!1}};function lm(i={}){let e=i.navigator??(typeof navigator<"u"?navigator:{}),t=i.window??(typeof window<"u"?window:{}),n=String(e.userAgent||""),s=/(iPhone|iPad|Android|Mobi)/i.test(n),r=(e.deviceMemory??8)<4,a=(e.hardwareConcurrency??8)<4,o=!!(t.matchMedia&&t.matchMedia("(any-pointer: coarse)").matches);return s&&(r||a)?"mobile":o||r||a?"medium":"high"}function hm(i,e={}){let t=cm[e.tier]?e.tier:"high",n=cm[t];return i.outputColorSpace=Jt,i.toneMapping=vc,i.toneMappingExposure=e.exposure??1.15,i.setPixelRatio(Math.min(typeof window<"u"?window.devicePixelRatio:1,n.pixelRatioCap)),i.shadowMap.enabled=n.shadows,n.shadows&&(i.shadowMap.type=yr),n}var Mx=new Map;async function um(i,e,t="studio",{urls:n=On.hdri}={}){let s=new uo(i);s.compileEquirectangularShader();let r=s.fromScene(new Nu,.04);e.environment=r.texture,e.environmentIntensity??=1;let a=t&&n?n[t]:null;if(!a)return s.dispose(),e.environment;try{let o=Mx.get(a);if(!o){let{HDRLoader:l}=await Promise.resolve().then(()=>(wx(),Sx));o=await new l().loadAsync(a),Mx.set(a,o)}let c=s.fromEquirectangular(o);return e.environment===r.texture?e.environment=c.texture:c.dispose(),r.dispose(),e.environment}catch{return e.environment}finally{s.dispose()}}function e2(i,e,t,n=.35){let s=new ln().setFromObject(e);if(!Number.isFinite(s.min.y))return t??null;let a=Math.max(s.max.x-s.min.x,s.max.z-s.min.z,1)*6,o=t;return o||(o=new vt(new Ii(1,1),new ac({opacity:n})),o.rotation.x=-Math.PI/2,o.receiveShadow=!0,i.add(o)),o.scale.set(a,a,1),o.position.set((s.min.x+s.max.x)/2,s.min.y,(s.min.z+s.max.z)/2),o}function Ex(){return`
.ars-root {
--ars-accent: #8b7cf8;
--ars-accent-ink: #dcd6ff;
@@ -4514,7 +4654,7 @@ The format should be roomId:reconnectionToken`);return yield this.createMatchMak
.ars-status { bottom: calc(env(safe-area-inset-bottom, 0px) + 152px); }
.ars-selbar { bottom: calc(env(safe-area-inset-bottom, 0px) + 100px); }
}
-`}var Rb="ar-studio-styles";function YT(i=document){if(i.getElementById(Rb))return;let e=i.createElement("style");e.id=Rb,e.textContent=Eb(),i.head.appendChild(e)}function re(i,e={},t=[]){let n=document.createElement(i);for(let[r,s]of Object.entries(e))s==null||s===!1||(r==="class"?n.className=s:r==="text"?n.textContent=s:r==="html"?n.innerHTML=s:r==="hidden"?n.hidden=!!s:r.startsWith("on")&&typeof s=="function"?n.addEventListener(r.slice(2),s):n.setAttribute(r,s===!0?"":String(s)));for(let r of[].concat(t))r&&n.appendChild(typeof r=="string"?document.createTextNode(r):r);return n}function Cb(i,e){YT(i.ownerDocument||document);let t=e.branding||{},n=e.generate?.enabled!==!1,r=e.rooms?.enabled!==!1,s=re("video",{class:"ars-video",playsinline:!0,muted:!0,"aria-hidden":"true"}),a=re("canvas",{class:"ars-canvas"}),o=t.backHref?re("a",{class:"ars-back",href:t.backHref},[re("span",{"aria-hidden":"true",text:"\u2190"}),t.backLabel||"Back"]):null,l=re("span",{class:"ars-title",text:t.title||"AR Studio"}),c=re("span",{class:"ars-count",hidden:!0,role:"status","aria-live":"polite"}),h=r?re("button",{type:"button",class:"ars-icon-btn","aria-label":"Open a shared room so other people can build in this scene with you"},[re("span",{"aria-hidden":"true",text:"\u{1F465}"}),re("span",{class:"ars-room-label",text:"Share live"}),re("span",{class:"ars-room-code-label",hidden:!0})]):null,d=re("button",{type:"button",class:"ars-icon-btn",hidden:!0,"aria-label":"Show a QR code that opens this scene on your phone"},[re("span",{"aria-hidden":"true",text:"\u{1F4F1}"}),"Open on phone"]),f=re("button",{type:"button",class:"ars-icon-btn",hidden:!0,"aria-pressed":"false","aria-label":"View this in augmented reality"},[re("span",{"aria-hidden":"true",text:"\u2726"}),re("span",{class:"ars-ar-label",text:"AR"})]),p=re("button",{type:"button",class:"ars-icon-btn","aria-pressed":"false","aria-label":"Turn the camera on to see your models in the room"},[re("span",{"aria-hidden":"true",text:"\u{1F4F7}"}),"Camera"]),x=re("div",{class:"ars-top"},[o,l,c,re("span",{class:"ars-spacer"}),h,d,f,p]),y=re("div",{class:"ars-chip",hidden:!0,"data-state":"idle",role:"status","aria-live":"polite"},[re("span",{class:"ars-spinner","aria-hidden":"true"}),re("span",{class:"ars-chip-label"}),re("span",{class:"ars-chip-elapsed"})]),b=re("button",{type:"button",class:"ars-btn ars-btn-primary"},[re("span",{"aria-hidden":"true",text:"\u{1F4F7}"}),"Turn on the camera"]),g=re("button",{type:"button",class:"ars-btn",text:"Browse models"}),S=n?re("button",{type:"button",class:"ars-btn",text:"Generate one"}):null,A=re("div",{class:"ars-empty"},[re("div",{class:"ars-empty-card"},[re("div",{class:"ars-empty-art","aria-hidden":"true",text:"\u{1FA84}"}),re("h2",{text:"Put anything in your room"}),re("p",{text:n?"Add a model, or describe one and watch it appear. Turn on the camera and it stands on your actual floor.":"Add a model from the library, then turn on the camera and it stands on your actual floor."}),re("div",{class:"ars-empty-row"},[b,g,S])])]),T=re("div",{class:"ars-status",hidden:!0,role:"status","aria-live":"polite"}),N=re("span",{class:"ars-sel-name"}),P=re("div",{class:"ars-selbar",hidden:!0,role:"toolbar","aria-label":"Selected model"},[N,re("button",{type:"button",class:"ars-icon-btn","data-act":"rotate","aria-label":"Rotate the selected model"},[re("span",{"aria-hidden":"true",text:"\u27F3"})]),re("button",{type:"button",class:"ars-icon-btn","data-act":"duplicate","aria-label":"Duplicate the selected model"},[re("span",{"aria-hidden":"true",text:"\u29C9"})]),re("button",{type:"button",class:"ars-icon-btn","data-act":"remove","aria-label":"Remove the selected model"},[re("span",{"aria-hidden":"true",text:"\u2715"})])]),U=re("button",{type:"button",class:"ars-icon-btn","aria-expanded":"false","aria-label":"Add a model to the scene"},[re("span",{"aria-hidden":"true",text:"\uFF0B"}),"Add"]),v=re("input",{class:"ars-forge-input",type:"text",name:"prompt",autocomplete:"off",placeholder:"Describe something to generate\u2026","aria-label":"Describe a 3D model to generate",maxlength:"300"}),I=re("button",{type:"submit",class:"ars-forge-go","aria-label":"Generate this model"},["Make"]),B=n?re("form",{class:"ars-forge-form"},[v,I]):re("span",{class:"ars-spacer"}),k=re("button",{type:"button",class:"ars-icon-btn",disabled:!0,"aria-label":"Take a photo of the scene"},[re("span",{"aria-hidden":"true",text:"\u2B24"})]),V=re("button",{type:"button",class:"ars-icon-btn",hidden:!0,"aria-label":"Remove every model from the scene"},["Clear"]),J=re("div",{class:"ars-dock"},[U,B,k,V]),L=re("div",{class:"ars-tabs",role:"tablist","aria-label":"Model sources"}),E=re("div",{class:"ars-tray-body",role:"tabpanel",tabindex:"-1"}),D=re("button",{type:"button",class:"ars-icon-btn","aria-label":"Close the model browser"},[re("span",{"aria-hidden":"true",text:"\u2715"})]),O=re("div",{class:"ars-tray",hidden:!0,role:"dialog","aria-modal":"true","aria-label":"Add a model"},[re("div",{class:"ars-tray-panel"},[re("div",{class:"ars-tray-head"},[re("h2",{text:"Add a model"}),re("span",{class:"ars-spacer"}),D]),L,E])]),H=re("div",{class:"ars-qr-box"}),Y=re("a",{class:"ars-link-out",target:"_blank",rel:"noopener"}),le=re("button",{type:"button",class:"ars-btn",text:"Done"}),fe=re("div",{class:"ars-modal",hidden:!0,role:"dialog","aria-modal":"true","aria-label":"Open this scene on your phone"},[re("div",{class:"ars-dialog"},[re("h2",{text:"Open this scene on your phone"}),re("p",{text:"Scan it and the same models, in the same arrangement, open on the phone: ready to place in your room."}),H,Y,le])]),be=re("span",{class:"ars-ar-thumb","aria-hidden":"true"}),Te=re("span",{class:"ars-ar-name"}),Je=re("div",{class:"ars-ar-picker",hidden:!0,role:"group","aria-label":"Choose which model to place"}),ke=re("p",{class:"ars-ar-hint"}),oe=re("p",{class:"ars-ar-status",role:"status","aria-live":"polite"}),Ee=re("button",{type:"button",class:"ars-btn ars-btn-primary ars-ar-go"},[re("span",{class:"ars-ar-go-icon","aria-hidden":"true",text:"\u2B21"}),re("span",{class:"ars-ar-go-label",text:"Place in your space"})]),_e=re("button",{type:"button",class:"ars-btn ars-ar-xr",hidden:!0},[re("span",{"aria-hidden":"true",text:"\u2726"}),"Immersive AR: place the whole scene"]),Ze=re("button",{type:"button",class:"ars-btn ars-ar-qr",hidden:!0},[re("span",{"aria-hidden":"true",text:"\u{1F4F1}"}),"Open on your phone"]),tt=re("button",{type:"button",class:"ars-btn ars-ar-done",text:"Done"}),Qe=re("div",{class:"ars-modal",hidden:!0,role:"dialog","aria-modal":"true","aria-label":"Place a model in your space"},[re("div",{class:"ars-dialog ars-ar-sheet"},[re("h2",{class:"ars-ar-heading",text:"Place in your space"}),re("div",{class:"ars-ar-target"},[be,Te]),Je,ke,oe,Ee,_e,Ze,tt])]),Et=re("button",{type:"button",class:"ars-btn ars-btn-primary",text:"Start a shared room"}),it=re("input",{class:"ars-search",type:"text",placeholder:"Room code","aria-label":"Room code",maxlength:"20",autocomplete:"off",spellcheck:"false"}),mt=re("form",{class:"ars-link-row"},[it,re("button",{type:"submit",class:"ars-btn",text:"Join"})]),wt=re("div",{},[re("p",{text:"Open a room and anyone who joins sees the same scene. Every move, resize and rotate syncs live."}),re("div",{class:"ars-dialog-row"},[Et]),re("div",{class:"ars-divider"}),re("p",{text:"Got a code from someone?"}),mt]),lt=re("div",{class:"ars-code"}),Bt=re("p",{}),gt=re("div",{class:"ars-qr-box"}),Yt=re("button",{type:"button",class:"ars-btn ars-btn-primary",text:"Copy invite link"}),q=re("button",{type:"button",class:"ars-btn",text:"Leave room"}),$t=re("div",{hidden:!0},[lt,Bt,gt,re("div",{class:"ars-dialog-row"},[Yt,q])]),ht=re("button",{type:"button",class:"ars-btn",text:"Close"}),Tt=re("div",{class:"ars-modal",hidden:!0,role:"dialog","aria-modal":"true","aria-label":"Shared room"},[re("div",{class:"ars-dialog"},[re("h2",{text:"Build together"}),wt,$t,ht])]),Pe=re("div",{class:"ars-hud"},[x,A,T,y,P,J,O,fe,Qe,Tt]),Ot=re("div",{class:"ars-root"},[s,a,Pe]);t.accent&&Ot.style.setProperty("--ars-accent",t.accent),i.appendChild(Ot);let F=i.ownerDocument.defaultView?.getComputedStyle(i);return F&&F.position==="static"&&(i.style.position="relative"),i!==i.ownerDocument.body&&i.clientHeight<80&&!i.style.height&&(i.style.minHeight=i.style.minHeight||"70vh"),{root:Ot,video:s,canvas:a,hud:Pe,top:x,title:l,count:c,status:T,chip:y,cameraBtn:p,xrBtn:f,qrBtn:d,roomBtn:h,addBtn:U,photoBtn:k,clearBtn:V,forgeForm:n?B:null,forgeInput:n?v:null,forgeGo:n?I:null,empty:A,emptyCamera:b,emptyAdd:g,emptyForge:S,selbar:P,selName:N,tray:O,trayTabs:L,trayBody:E,trayClose:D,qrModal:fe,qrBox:H,qrLink:Y,qrClose:le,arModal:Qe,arThumb:be,arName:Te,arPicker:Je,arHint:ke,arStatus:oe,arGo:Ee,arXr:_e,arQr:Ze,arClose:tt,roomModal:Tt,roomIdle:wt,roomLive:$t,roomCreate:Et,roomJoinForm:mt,roomJoinInput:it,roomCode:lt,roomPresence:Bt,roomQr:gt,roomCopy:Yt,roomLeave:q,roomClose:ht}}Vn();var kf=class{constructor(e,t,n,r,s){this.xrLight=e,this.renderer=t,this.lightProbe=n,this.xrWebGLBinding=null,this.estimationStartCallback=s,this.frameCallback=this.onXRFrame.bind(this);let a=t.xr.getSession();if(r&&"XRWebGLBinding"in window){let o=new Ma(16);e.environment=o.texture;let l=t.getContext();switch(a.preferredReflectionFormat){case"srgba8":l.getExtension("EXT_sRGB");break;case"rgba16f":l.getExtension("OES_texture_half_float");break}this.xrWebGLBinding=new XRWebGLBinding(a,l),this.lightProbe.addEventListener("reflectionchange",()=>{this.updateReflection()})}a.requestAnimationFrame(this.frameCallback)}updateReflection(){let e=this.renderer.properties.get(this.xrLight.environment);if(e){let t=this.xrWebGLBinding.getReflectionCubeMap(this.lightProbe);t&&(e.__webglTexture=t,this.xrLight.environment.needsPMREMUpdate=!0)}}onXRFrame(e,t){if(!this.xrLight)return;t.session.requestAnimationFrame(this.frameCallback);let r=t.getLightEstimate(this.lightProbe);if(r){this.xrLight.lightProbe.sh.fromArray(r.sphericalHarmonicsCoefficients),this.xrLight.lightProbe.intensity=1;let s=Math.max(1,Math.max(r.primaryLightIntensity.x,Math.max(r.primaryLightIntensity.y,r.primaryLightIntensity.z)));this.xrLight.directionalLight.color.setRGB(r.primaryLightIntensity.x/s,r.primaryLightIntensity.y/s,r.primaryLightIntensity.z/s),this.xrLight.directionalLight.intensity=s,this.xrLight.directionalLight.position.copy(r.primaryLightDirection),this.estimationStartCallback&&(this.estimationStartCallback(),this.estimationStartCallback=null)}}dispose(){this.xrLight=null,this.renderer=null,this.lightProbe=null,this.xrWebGLBinding=null}},Lh=class extends pn{constructor(e,t=!0){super(),this.lightProbe=new wo,this.lightProbe.intensity=0,this.add(this.lightProbe),this.directionalLight=new Di,this.directionalLight.intensity=0,this.add(this.directionalLight),this.environment=null;let n=null,r=!1;e.xr.addEventListener("sessionstart",()=>{let s=e.xr.getSession();"requestLightProbe"in s&&s.requestLightProbe({reflectionFormat:s.preferredReflectionFormat}).then(a=>{n=new kf(this,e,a,t,()=>{r=!0,this.dispatchEvent({type:"estimationstart"})})})}),e.xr.addEventListener("sessionend",()=>{n&&(n.dispose(),n=null),r&&this.dispatchEvent({type:"estimationend"})}),this.dispose=()=>{n&&(n.dispose(),n=null),this.remove(this.lightProbe),this.lightProbe=null,this.remove(this.directionalLight),this.directionalLight=null,this.environment=null}}};var Dh=class{constructor({renderer:e,scene:t,baseLights:n=[],onChange:r}){this._renderer=e,this._scene=t,this._baseLights=n,this._onChange=r,this._xrLight=null,this._active=!1,this._savedEnv=t.environment,this._savedIntensities=n.map(s=>s.intensity),this._onEstimationStart=this._onEstimationStart.bind(this),this._onEstimationEnd=this._onEstimationEnd.bind(this)}start(){if(this._xrLight)return;let e=new Lh(this._renderer,!0);e.addEventListener("estimationstart",this._onEstimationStart),e.addEventListener("estimationend",this._onEstimationEnd),this._scene.add(e),this._xrLight=e}get active(){return this._active}_onEstimationStart(){if(this._xrLight){this._active=!0;for(let e of this._baseLights)e.intensity=0;this._xrLight.environment&&(this._scene.environment=this._xrLight.environment),this._onChange?.(!0)}}_onEstimationEnd(){this._active=!1,this._restoreBase(),this._onChange?.(!1)}_restoreBase(){this._baseLights.forEach((e,t)=>{e.intensity=this._savedIntensities[t]}),this._scene.environment=this._savedEnv}dispose(){this._xrLight&&(this._xrLight.removeEventListener("estimationstart",this._onEstimationStart),this._xrLight.removeEventListener("estimationend",this._onEstimationEnd),this._scene.remove(this._xrLight),this._xrLight.dispose?.(),this._xrLight=null),this._restoreBase(),this._active=!1}};Vn();function Pb(i,e,t=30){let n=i||{misses:0,lost:!1};if(e)return{state:{misses:0,lost:!1},changed:n.lost===!0,lost:!1};let r=n.misses+1,s=r>=t;return{state:{misses:r,lost:s},changed:s&&!n.lost,lost:s}}var JT=new Set(["hidden","visible-blurred"]);function Lb(i){return!JT.has(i)}function Ib(i){return i<0?0:i>1?1:i}function Db(i,e,t=0,n=!1){let r=Ib(e),s=n?0:Ib(t),a=n?.94:.86+s*.1,o=n?.5:.34+s*.18;return i.scale=a+(1-a)*r,i.opacity=o+(.96-o)*r,i.dot=r,i.colorMix=r,i}var ZT=.55;function Nb(i,e,t=ZT){let n=i.t+e,r=n>=t?1:n/t,s=1-(1-r)*(1-r);return i.t=n,i.scale=1+s*2,i.opacity=.85*(1-r),i.done=n>=t,i}var qo=class{constructor(e){this._renderer=e,this._mesh=null,this._enabled=!1}static sessionHasDepth(e){return!!e?.enabledFeatures?.includes?.("depth-sensing")}update(){if(this._mesh)return;let e=this._renderer.xr;if(typeof e.hasDepthSensing!="function"||!e.hasDepthSensing())return;let t=e.getDepthSensingMesh?.();t&&this._configure(t)}_configure(e){let t=e.material;t.colorWrite=!1,t.depthWrite=!0,t.depthTest=!1,e.frustumCulled=!1,this._mesh=e,this._enabled=!0}get enabled(){return this._enabled}dispose(){this._mesh&&(this._mesh.geometry?.dispose(),this._mesh.material?.dispose(),this._mesh=null),this._enabled=!1}};function $o(){return{active:!1,startDist:0,baseScale:1,scale:1}}function Nh(i,e,t){if(!Number.isFinite(e)||e<24)return!1;let n=Number.isFinite(t)&&t>0?t:1;return i.active=!0,i.startDist=e,i.baseScale=n,i.scale=n,!0}function Oh(i,e){if(!i.active||!Number.isFinite(e)||e<=0||i.startDist<=0)return null;let t=i.baseScale*(e/i.startDist);return i.scale=Math.min(4,Math.max(.25,t)),i.scale}function Fh(i){return i.active?(i.active=!1,i.scale):null}function Ia(i){let e=i[0].clientX-i[1].clientX,t=i[0].clientY-i[1].clientY;return Math.hypot(e,t)}function eE(){try{return typeof window<"u"&&!!window.matchMedia?.("(prefers-reduced-motion: reduce)").matches}catch{return!1}}function tE(){try{let e=document.createElement("canvas");e.width=e.height=128;let t=e.getContext("2d"),n=t.createRadialGradient(128/2,128/2,0,128/2,128/2,128/2);return n.addColorStop(0,"rgba(0,0,0,0.42)"),n.addColorStop(.55,"rgba(0,0,0,0.20)"),n.addColorStop(1,"rgba(0,0,0,0)"),t.fillStyle=n,t.fillRect(0,0,128,128),new Ss(e)}catch{return null}}var Uh=class{constructor({renderer:e,scene:t,camera:n,domOverlayRoot:r,getArmedContent:s,onPlaced:a,getScaleTarget:o,onScale:l,onHit:c,onTracking:h,onVisibility:d,onEnd:f,onFrame:p}){this._renderer=e,this._scene=t,this._camera=n,this._domOverlayRoot=r??null,this._getArmedContent=s,this._onPlaced=a,this._getScaleTarget=o,this._onScale=l,this._onHit=c,this._onTracking=h,this._onVisibility=d,this._onEnd=f,this._onFrame=p,this._session=null,this._hitTestSource=null,this._localSpace=null,this._ended=!1,this._paused=!1,this._trackingState={misses:0,lost:!1},this._depthOcclusion=null,this._placements=[],this._latestHit=null,this._latestHitMatrix=new ot,this._hasHit=!1,this._hadHit=!1,this._hitAmount=0,this._reticle=null,this._reticleRing=null,this._reticleDot=null,this._pulseRing=null,this._rv={scale:1,opacity:.9,dot:0,colorMix:0},this._pulse={t:0,scale:1,opacity:0,done:!1,active:!1},this._dimColor=new Ve(8023280),this._lockColor=new Ve(12891645),this._reducedMotion=!1,this._shadowTex=null,this._prevTime=0,this._savedBg=null,this._pinch=$o(),this._pinchEndedAt=-1/0,this._uiTouchActive=!1,this._handleEnd=this._handleEnd.bind(this),this._handleSelect=this._handleSelect.bind(this),this._handleVisibilityChange=this._handleVisibilityChange.bind(this),this._handleTouchStart=this._handleTouchStart.bind(this),this._handleTouchMove=this._handleTouchMove.bind(this),this._handleTouchEnd=this._handleTouchEnd.bind(this),this._handleBeforeSelect=this._handleBeforeSelect.bind(this)}static async isSupported(){try{return!!(navigator.xr&&await navigator.xr.isSessionSupported("immersive-ar"))}catch{return!1}}async start(){let e=this._renderer;e.xr.enabled=!0;let t={requiredFeatures:["hit-test"],optionalFeatures:["anchors","local-floor","depth-sensing","light-estimation"],depthSensing:{usagePreference:["gpu-optimized","cpu-optimized"],dataFormatPreference:["luminance-alpha","float32"]}};this._domOverlayRoot&&(t.optionalFeatures.push("dom-overlay"),t.domOverlay={root:this._domOverlayRoot});let n=await navigator.xr.requestSession("immersive-ar",t);this._session=n,this._ended=!1,this._paused=!1,this._trackingState={misses:0,lost:!1},n.addEventListener("end",this._handleEnd),n.addEventListener("select",this._handleSelect),n.addEventListener("visibilitychange",this._handleVisibilityChange),await e.xr.setSession(n),this._localSpace=await n.requestReferenceSpace("local");let r=await n.requestReferenceSpace("viewer");if(this._hitTestSource=await n.requestHitTestSource({space:r}),this._depthOcclusion=qo.sessionHasDepth(n)?new qo(e):null,this._reducedMotion=eE(),this._hadHit=!1,this._hitAmount=0,this._pulse.active=!1,this._shadowTex=tE(),this._buildReticle(),this._buildPulseRing(),this._savedBg=this._scene.background,this._scene.background=null,e.setClearColor(0,0),this._domOverlayRoot){let s=this._domOverlayRoot;s.addEventListener("touchstart",this._handleTouchStart,{passive:!0}),s.addEventListener("touchmove",this._handleTouchMove,{passive:!0}),s.addEventListener("touchend",this._handleTouchEnd,{passive:!0}),s.addEventListener("touchcancel",this._handleTouchEnd,{passive:!0}),s.addEventListener("beforexrselect",this._handleBeforeSelect)}this._prevTime=0,e.setAnimationLoop((s,a)=>this._tick(s,a))}get placedCount(){return this._placements.length}_tick(e,t){let n=this._renderer,r=this._prevTime?Math.min(.1,(e-this._prevTime)/1e3):.016;if(this._prevTime=e,this._paused){n.render(this._scene,this._camera);return}if(t&&this._localSpace){let s=!!t.getViewerPose(this._localSpace),a=Pb(this._trackingState,s,30);this._trackingState=a.state,a.changed&&this._setTracking(!a.lost)}if(this._onFrame?.(r),t&&this._hitTestSource){let s=t.getHitTestResults(this._hitTestSource),a=s.length>0?s[0].getPose(this._localSpace):null;if(a)this._latestHit=s[0],this._latestHitMatrix.fromArray(a.transform.matrix),this._hadHit=!0,this._reticle&&(this._reticle.visible=!0,this._reticle.position.setFromMatrixPosition(this._latestHitMatrix),this._reticle.quaternion.setFromRotationMatrix(this._latestHitMatrix)),this._setHit(!0);else{this._latestHit=null;let o=this._hadHit&&!this._trackingState.lost;this._reticle&&(this._reticle.visible=o),this._setHit(!1)}}if(t)for(let s of this._placements){if(!s.anchor)continue;let a=t.getPose(s.anchor.anchorSpace,this._localSpace);if(a){let o=a.transform.position;s.group.position.set(o.x,o.y,o.z),s.shadow?.position.set(o.x,o.y+.004,o.z)}}this._updateReticleVisual(e,r),this._updatePulse(r),this._depthOcclusion?.update(),n.render(this._scene,this._camera)}async _handleSelect(){if(!this._latestHit||this._pinch.active||performance.now()-this._pinchEndedAt<350||this._uiTouchActive)return;let e=this._getArmedContent?.();if(!e)return;let t=this._latestHitMatrix.clone();e.position.setFromMatrixPosition(t),e.parent||this._scene.add(e);let n=this._buildShadow();n.position.copy(e.position),n.position.y+=.004,n.scale.setScalar(e.scale.x||1),this._fireConfirmPulse();try{navigator.vibrate?.(15)}catch{}let r=null;try{r=await this._latestHit.createAnchor?.()??null}catch{r=null}this._placements.push({group:e,anchor:r,shadow:n}),this._onPlaced?.(e,{position:{x:e.position.x,y:e.position.y,z:e.position.z},matrix:t},{degraded:r===null})}release(e){let t=this._placements.findIndex(r=>r.group===e);if(t===-1)return;let[n]=this._placements.splice(t,1);try{n.anchor?.delete?.()}catch{}n.shadow&&(this._scene.remove(n.shadow),n.shadow.geometry?.dispose(),n.shadow.material?.dispose())}_scaleTarget(){let e=this._getScaleTarget?.();return e||(this._placements.length?this._placements[this._placements.length-1].group:null)}_handleTouchStart(e){if(e.touches.length===1){this._uiTouchActive=!!e.touches[0].target?.closest?.("[data-xr-ui]");return}if(e.touches.length!==2)return;let t=this._scaleTarget();t&&Nh(this._pinch,Ia(e.touches),t.scale?.x??1)}_handleTouchMove(e){if(!this._pinch.active||e.touches.length!==2)return;let t=Oh(this._pinch,Ia(e.touches));if(t==null)return;let n=this._scaleTarget();if(!n)return;n.scale.setScalar(t),this._placements.find(s=>s.group===n)?.shadow?.scale.setScalar(t),this._onScale?.(t,{final:!1})}_handleTouchEnd(e){(!e.touches||e.touches.length===0)&&(this._uiTouchActive=!1);let t=Fh(this._pinch);t!=null&&(this._pinchEndedAt=performance.now(),this._onScale?.(t,{final:!0}))}_handleBeforeSelect(e){if(this._pinch.active||performance.now()-this._pinchEndedAt<350){e.preventDefault();return}e.target?.closest?.("[data-xr-ui]")&&e.preventDefault()}_buildReticle(){let e=new pn;e.renderOrder=999,e.visible=!1;let t=new xt(new Gr(.08,.11,40).rotateX(-Math.PI/2),new gn({color:this._dimColor.clone(),transparent:!0,opacity:.6,depthTest:!1}));t.renderOrder=999;let n=new xt(new uo(.032,32).rotateX(-Math.PI/2).translate(0,.001,0),new gn({color:this._lockColor.clone(),transparent:!0,opacity:0,depthTest:!1}));n.renderOrder=1e3,e.add(t,n),this._reticle=e,this._reticleRing=t,this._reticleDot=n,this._scene.add(e)}_buildPulseRing(){let e=new xt(new Gr(.1,.13,40).rotateX(-Math.PI/2),new gn({color:this._lockColor.clone(),transparent:!0,opacity:0,depthTest:!1}));e.renderOrder=1001,e.visible=!1,this._pulseRing=e,this._scene.add(e)}_buildShadow(){let e=new mi(.6,.6).rotateX(-Math.PI/2),t=new gn({map:this._shadowTex,color:this._shadowTex?16777215:0,transparent:!0,opacity:.9,depthWrite:!1}),n=new xt(e,t);return n.renderOrder=1,this._scene.add(n),n}_fireConfirmPulse(){this._reducedMotion||!this._pulseRing||(this._pulseRing.position.setFromMatrixPosition(this._latestHitMatrix),this._pulseRing.quaternion.setFromRotationMatrix(this._latestHitMatrix),this._pulse.t=0,this._pulse.active=!0,this._pulseRing.visible=!0)}_updateReticleVisual(e,t){let n=this._reticle;if(!n||!n.visible)return;let r=this._hasHit?1:0,s=Math.min(1,t*(r>this._hitAmount?16:9));this._hitAmount+=(r-this._hitAmount)*s;let a=this._reducedMotion?0:Math.sin(e*.0019)*.5+.5;Db(this._rv,this._hitAmount,a,this._reducedMotion),n.scale.setScalar(this._rv.scale);let o=this._reticleRing.material;o.opacity=this._rv.opacity,o.color.lerpColors(this._dimColor,this._lockColor,this._rv.colorMix),this._reticleDot.material.opacity=this._rv.dot*.95}_updatePulse(e){!this._pulse.active||!this._pulseRing||(Nb(this._pulse,e),this._pulseRing.scale.setScalar(this._pulse.scale),this._pulseRing.material.opacity=this._pulse.opacity,this._pulse.done&&(this._pulse.active=!1,this._pulseRing.visible=!1))}_setHit(e){e!==this._hasHit&&(this._hasHit=e,this._onHit?.(e))}_setTracking(e){!e&&this._reticle&&(this._reticle.visible=!1),this._onTracking?.(e)}_handleVisibilityChange(){let e=Lb(this._session?.visibilityState);this._paused=!e,!e&&this._reticle&&(this._reticle.visible=!1),this._onVisibility?.(e)}async end(){if(this._session)try{await this._session.end()}catch{}}_handleEnd(){if(this._ended)return;this._ended=!0;let e=this._renderer;if(this._session?.removeEventListener("visibilitychange",this._handleVisibilityChange),this._domOverlayRoot){let t=this._domOverlayRoot;t.removeEventListener("touchstart",this._handleTouchStart),t.removeEventListener("touchmove",this._handleTouchMove),t.removeEventListener("touchend",this._handleTouchEnd),t.removeEventListener("touchcancel",this._handleTouchEnd),t.removeEventListener("beforexrselect",this._handleBeforeSelect)}if(this._pinch=$o(),this._pinchEndedAt=-1/0,this._uiTouchActive=!1,e.setAnimationLoop(null),e.xr.enabled=!1,this._hitTestSource){try{this._hitTestSource.cancel()}catch{}this._hitTestSource=null}for(let t of[this._reticleRing,this._reticleDot,this._pulseRing])t?.geometry?.dispose(),t?.material?.dispose();this._reticle&&this._scene.remove(this._reticle),this._pulseRing&&this._scene.remove(this._pulseRing),this._reticle=this._reticleRing=this._reticleDot=this._pulseRing=null,this._pulse.active=!1;for(let t of this._placements){try{t.anchor?.delete?.()}catch{}t.shadow&&(this._scene.remove(t.shadow),t.shadow.geometry?.dispose(),t.shadow.material?.dispose())}this._placements=[],this._shadowTex?.dispose(),this._shadowTex=null,this._depthOcclusion?.dispose(),this._depthOcclusion=null,this._session=null,this._latestHit=null,this._hasHit=!1,this._hadHit=!1,this._hitAmount=0,this._paused=!1,this._trackingState={misses:0,lost:!1},this._scene.background=this._savedBg,e.setClearColor(0,0),this._onEnd?.()}};function Ob({run:i,maxActive:e=5,priorityOf:t=()=>0}){let n=[],r=0,s={run:i,maxActive:e,priorityOf:t};function a(){for(n.length>1&&n.sort((o,l)=>s.priorityOf(o.item)-s.priorityOf(l.item));r<s.maxActive&&n.length;){let o=n.shift();o.cancelled||(r++,Promise.resolve().then(()=>s.run(o.item)).then(o.resolve,o.reject).finally(()=>{r--,a()}))}}return{request(o){return new Promise((l,c)=>{n.push({item:o,resolve:l,reject:c,cancelled:!1}),a()})},cancel(o){let l=0;for(let c of n)!c.cancelled&&o(c.item)&&(c.cancelled=!0,c.reject(new Error("cancelled")),l++);return l},setMaxActive(o){s.maxActive=Math.max(1,o|0),a()},get active(){return r},get pending(){return n.reduce((o,l)=>o+(l.cancelled?0:1),0)}}}Vh();Vn();var mE=Object.freeze(["Hips","Spine","Spine1","Spine2","Neck","Head","LeftShoulder","LeftArm","LeftForeArm","LeftHand","LeftHandIndex1","LeftHandIndex2","LeftHandIndex3","LeftHandMiddle1","LeftHandMiddle2","LeftHandMiddle3","LeftHandPinky1","LeftHandPinky2","LeftHandPinky3","LeftHandRing1","LeftHandRing2","LeftHandRing3","LeftHandThumb1","LeftHandThumb2","LeftHandThumb3","RightShoulder","RightArm","RightForeArm","RightHand","RightHandIndex1","RightHandIndex2","RightHandIndex3","RightHandMiddle1","RightHandMiddle2","RightHandMiddle3","RightHandPinky1","RightHandPinky2","RightHandPinky3","RightHandRing1","RightHandRing2","RightHandRing3","RightHandThumb1","RightHandThumb2","RightHandThumb3","LeftUpLeg","LeftLeg","LeftFoot","LeftToeBase","RightUpLeg","RightLeg","RightFoot","RightToeBase"]),gE=(()=>{let i=new Map;for(let e of mE)i.set(e.toLowerCase(),e);return i})(),gp=new Map(Object.entries({pelvis:"Hips",neck01:"Neck",claviclel:"LeftShoulder",upperarml:"LeftArm",lowerarml:"LeftForeArm",handl:"LeftHand",clavicler:"RightShoulder",upperarmr:"RightArm",lowerarmr:"RightForeArm",handr:"RightHand",thighl:"LeftUpLeg",calfl:"LeftLeg",footl:"LeftFoot",balll:"LeftToeBase",thighr:"RightUpLeg",calfr:"RightLeg",footr:"RightFoot",ballr:"RightToeBase"}));for(let[i,e]of[["thumb","Thumb"],["index","Index"],["middle","Middle"],["ring","Ring"],["pinky","Pinky"]])for(let t=1;t<=3;t++)gp.set(`${i}0${t}l`,`LeftHand${e}${t}`),gp.set(`${i}0${t}r`,`RightHand${e}${t}`);var bE=(()=>{let i=new Map,e=s=>s.replace(/[-_.\s]+/g,"").toLowerCase(),t=(s,a)=>{let o=e(s);i.has(o)||i.set(o,a)},n=[["J_Bip_C_Hips","Hips"],["J_Bip_C_Spine","Spine"],["J_Bip_C_Chest","Spine1"],["J_Bip_C_UpperChest","Spine2"],["J_Bip_C_Neck","Neck"],["J_Bip_C_Head","Head"],["J_Bip_L_Shoulder","LeftShoulder"],["J_Bip_L_UpperArm","LeftArm"],["J_Bip_L_LowerArm","LeftForeArm"],["J_Bip_L_Hand","LeftHand"],["J_Bip_R_Shoulder","RightShoulder"],["J_Bip_R_UpperArm","RightArm"],["J_Bip_R_LowerArm","RightForeArm"],["J_Bip_R_Hand","RightHand"],["J_Bip_L_UpperLeg","LeftUpLeg"],["J_Bip_L_LowerLeg","LeftLeg"],["J_Bip_L_Foot","LeftFoot"],["J_Bip_L_ToeBase","LeftToeBase"],["J_Bip_L_Toes","LeftToeBase"],["J_Bip_R_UpperLeg","RightUpLeg"],["J_Bip_R_LowerLeg","RightLeg"],["J_Bip_R_Foot","RightFoot"],["J_Bip_R_ToeBase","RightToeBase"],["J_Bip_R_Toes","RightToeBase"]];for(let[s,a]of n)t(s,a);for(let[s,a]of[["Thumb","Thumb"],["Index","Index"],["Middle","Middle"],["Ring","Ring"],["Little","Pinky"]])for(let o=1;o<=3;o++)t(`J_Bip_L_${s}${o}`,`LeftHand${a}${o}`),t(`J_Bip_R_${s}${o}`,`RightHand${a}${o}`);for(let[s,a]of[["chest","Spine1"],["lowerChest","Spine1"],["chestLower","Spine1"],["upperChest","Spine2"],["chestUpper","Spine2"],["abdomen","Spine"],["abdomenLower","Spine"],["abdomenUpper","Spine1"],["hip","Hips"],["lowerNeck","Neck"],["upperNeck","Neck"],["neckLower","Neck"],["neckUpper","Neck"],["neckTwist01","Neck"],["neckTwist02","Neck"],["torso","Spine"],["waist","Spine"],["upperTorso","Spine1"],["torsoUpper","Spine1"],["lowerTorso","Hips"],["torsoLower","Hips"],["ribcage","Spine1"],["ribs","Spine1"],["mPelvis","Hips"],["mTorso","Spine"],["mChest","Spine1"],["mNeck","Neck"],["mHead","Head"],["root_M","Hips"],["hip_M","Hips"],["pelvis_M","Hips"],["spine1_M","Spine"],["spine2_M","Spine1"],["spine3_M","Spine2"],["chest_M","Spine2"],["neck_M","Neck"],["head_M","Head"],["spine0","Spine"],["hipMaster","Hips"],["lumbar","Spine"],["thoracic","Spine1"],["sternum","Spine2"],["cervical","Neck"],["cranium","Head"],["skull","Head"]])t(s,a);let r=[["leftUpperArm","LeftArm"],["lUpperArm","LeftArm"],["shoulderL","LeftArm"],["lShldr","LeftArm"],["lShldrBend","LeftArm"],["leftLowerArm","LeftForeArm"],["lLowerArm","LeftForeArm"],["elbowL","LeftForeArm"],["lForeArm","LeftForeArm"],["lForearmBend","LeftForeArm"],["forearmL","LeftForeArm"],["upperArmL","LeftArm"],["wristL","LeftHand"],["lHand","LeftHand"],["lCollar","LeftShoulder"],["collarL","LeftShoulder"],["lClavicle","LeftShoulder"],["leftUpperLeg","LeftUpLeg"],["lUpperLeg","LeftUpLeg"],["hipL","LeftUpLeg"],["lThigh","LeftUpLeg"],["lThighBend","LeftUpLeg"],["leftLowerLeg","LeftLeg"],["lLowerLeg","LeftLeg"],["kneeL","LeftLeg"],["shinL","LeftLeg"],["lShin","LeftLeg"],["lCalf","LeftLeg"],["ankleL","LeftFoot"],["lFoot","LeftFoot"],["leftToes","LeftToeBase"],["toeL","LeftToeBase"],["lToe","LeftToeBase"],["lToeBase","LeftToeBase"],["lArm","LeftArm"],["lShoulder","LeftShoulder"],["lLeg","LeftLeg"],["lUpLeg","LeftUpLeg"],["leftHip","LeftUpLeg"],["leftThigh","LeftUpLeg"],["leftKnee","LeftLeg"],["leftShin","LeftLeg"],["leftCalf","LeftLeg"],["leftAnkle","LeftFoot"],["leftElbow","LeftForeArm"],["leftWrist","LeftHand"],["leftCollar","LeftShoulder"],["leftClavicle","LeftShoulder"],["leftToe","LeftToeBase"],["mCollarLeft","LeftShoulder"],["mShoulderLeft","LeftArm"],["mElbowLeft","LeftForeArm"],["mWristLeft","LeftHand"],["mHipLeft","LeftUpLeg"],["mKneeLeft","LeftLeg"],["mAnkleLeft","LeftFoot"],["mFootLeft","LeftToeBase"],["mToeLeft","LeftToeBase"],["upperLegL","LeftUpLeg"],["lowerLegL","LeftLeg"],["lowerArmL","LeftForeArm"],["scapulaL","LeftShoulder"],["lHip","LeftUpLeg"],["lKnee","LeftLeg"],["lAnkle","LeftFoot"],["lElbow","LeftForeArm"],["lWrist","LeftHand"],["lToes","LeftToeBase"],["humerusL","LeftArm"],["lHumerus","LeftArm"],["ulnaL","LeftForeArm"],["lUlna","LeftForeArm"],["radiusL","LeftForeArm"],["lRadius","LeftForeArm"],["carpusL","LeftHand"],["lCarpus","LeftHand"],["femurL","LeftUpLeg"],["lFemur","LeftUpLeg"],["tibiaL","LeftLeg"],["lTibia","LeftLeg"],["fibulaL","LeftLeg"],["lFibula","LeftLeg"],["talusL","LeftFoot"],["lTalus","LeftFoot"],["tarsusL","LeftFoot"],["lTarsus","LeftFoot"],["calcaneusL","LeftFoot"],["lCalcaneus","LeftFoot"],["metatarsusL","LeftToeBase"],["lMetatarsus","LeftToeBase"]];for(let[s,a]of[["Thumb","Thumb"],["Index","Index"],["Middle","Middle"],["Ring","Ring"],["Pinky","Pinky"],["Little","Pinky"]]){let o=s.toLowerCase();for(let c=1;c<=3;c++){r.push([`l${s}${c}`,`LeftHand${a}${c}`]),r.push([`f_${o}.0${c}.L`,`LeftHand${a}${c}`]),r.push([`${o}.0${c}.L`,`LeftHand${a}${c}`]);let h=["Thumb","Index","Middle","Ring","Pinky"].indexOf(a)+1;h>0&&r.push([`finger${h}-${c}.L`,`LeftHand${a}${c}`])}(a==="Thumb"?["Metacarpal","Proximal","Distal"]:["Proximal","Intermediate","Distal"]).forEach((c,h)=>{r.push([`left${s}${c}`,`LeftHand${a}${h+1}`]),r.push([`${o}_${c.toLowerCase()}.L`,`LeftHand${a}${h+1}`])})}for(let s=1;s<=3;s++)r.push([`lMid${s}`,`LeftHandMiddle${s}`]);for(let[s,a]of[["Thumb","Thumb"],["Index","Index"],["Middle","Middle"],["Ring","Ring"],["Pinky","Pinky"],["Little","Pinky"]]){for(let o=1;o<=3;o++)r.push([`${s}${o}L`,`LeftHand${a}${o}`]),r.push([`${s}Finger${o}L`,`LeftHand${a}${o}`]);r.push([`${s}L`,`LeftHand${a}1`]),r.push([`${s}FingerL`,`LeftHand${a}1`])}for(let[s,a]of r){t(s,a);let o=a.replace(/^Left/,"Right"),l;/^left/.test(s)?l=s.replace(/^left/,"right"):/^l[A-Z]/.test(s)?l="r"+s.slice(1):/Left$/.test(s)?l=s.replace(/Left$/,"Right"):/L$/.test(s)?l=s.replace(/L$/,"R"):l=s,t(l,o)}return i})();function yi(i){if(typeof i!="string"||!i)return null;let e=Yb(i);if(e)return e;let t=i.replace(/[._]\d+$/,"");return t!==i?Yb(t):null}function Yb(i){let e=i;e=e.replace(/^(?:[A-Za-z][\w]*:)+/,""),e=e.replace(/^mixamorig\d*[_:]?/i,""),e=e.replace(/^Armature[_/]?/i,""),e=e.replace(/^(DEF|ORG|MCH)[-_]/i,""),e=e.replace(/^CH[_:]/i,""),e=e.replace(/^CC_Base_/i,""),e=e.replace(/^j_(?!bip|sec|adj)/i,""),e=e.replace(/^\d+\./,"").replace(/^!/,"").replace(/^joint[_:]/i,""),e=e.replace(/^Bip\d+[\s_]?/i,"");let t=e.replace(/[-_.\s]+/g,"").toLowerCase();return gE.get(t)??gp.get(t)??bE.get(t)??null}var xE=/shoulder|clavicle|collar|scapula/i,Jb=/upper.?arm|humerus/i,Zb=/clavicle|collar|scapula/i;function Qb(i,e={}){let t=typeof e.isAncestor=="function"?e.isAncestor:null,n=new Map;for(let o of i)n.set(o.canonical,(n.get(o.canonical)||0)+1);let r=(o,l,c)=>o.length<2||!t?o[0]:o.find(d=>l.some(f=>f!==d&&(c?t(d,f):t(f,d))))||o[0],s=(o,l,c)=>{o.canonical=c,n.set(l,(n.get(l)||1)-1),n.set(c,(n.get(c)||0)+1)},a=0;for(let o of["Left","Right"]){let l=`${o}Arm`,c=`${o}Shoulder`;if((n.get(l)||0)<2||(n.get(c)||0)>0)continue;let h=i.filter(x=>x.canonical===l),d=h.filter(x=>Jb.test(x.raw));if(d.length===0)continue;let f=h.filter(x=>xE.test(x.raw)&&!Jb.test(x.raw)),p=r(f,d,!0);p&&(s(p,l,c),a++)}for(let o of["Left","Right"]){let l=`${o}Arm`,c=`${o}Shoulder`;if((n.get(c)||0)<2||(n.get(l)||0)>0)continue;let h=i.filter(x=>x.canonical===c),d=h.filter(x=>Zb.test(x.raw));if(d.length===0)continue;let f=h.filter(x=>/shoulder/i.test(x.raw)&&!Zb.test(x.raw)),p=r(f,d,!1);p&&(s(p,c,l),a++)}return a}Vn();var ex=Object.freeze({Head:[-.11706881878098431,9438845082943482e-24,372654613409334e-22,.993123804804428],Hips:[.0010741148761599644,6537898515070053e-23,7022659074474357e-26,.9999994231384476],LeftArm:[-.003089573263103852,.08018148459223169,-.025041829737156785,.9964608827384491],LeftFoot:[.5523737034239063,.0002518875693487157,.0036538113016644914,.8335885543726441],LeftForeArm:[-26826767953574183e-23,12816740072681333e-23,.012369379808617674,.9999234962951223],LeftHand:[-.0012910117424963744,.002537815819541244,.010116448936771993,.9999447735952517],LeftHandIndex1:[.028803290204768833,.011362422123976328,.055965724298468224,.9979524555518633],LeftHandIndex2:[-.005195237841915152,.014315447122751807,.00021581682553071412,.9998840087229335],LeftHandIndex3:[-.0013151015878908295,-.016941197343945148,-.006458334440614796,.9998347644768737],LeftHandMiddle1:[.027532617383276645,-.031607746403852485,.016931179482824785,.9989775976007271],LeftHandMiddle2:[-.001267981765488788,.0010468621884392817,-.004466175725402764,.9999886747239598],LeftHandMiddle3:[-.0015803533040544947,.0018352886876119797,.0038040706030556736,.9999898315711762],LeftHandPinky1:[.009345046842530319,-.07377447953394943,-.04207784173776388,.9963430390695086],LeftHandPinky2:[-.0019002180814112143,.0002770864318134059,.0004968185265866393,.9999980327809131],LeftHandPinky3:[-.0014157518824255099,-.005595319155644295,-.004606740515194791,.9999727326242506],LeftHandRing1:[.018207541076892743,-.03436008716699126,-.036855349348364555,.9985637451229231],LeftHandRing2:[-.0006571286469542868,.015477225242721515,.01003471962236163,.9998296495318929],LeftHandRing3:[.001815607007583071,-.003099595768579846,.0072046170631637615,.999967594260012],LeftHandThumb1:[.1900227602341495,-.058826116539083484,.3478783626049766,.9161940209594684],LeftHandThumb2:[.01801363066187901,-.020968588375318502,-.22063576333056306,.9749644544258214],LeftHandThumb3:[-.014498565873099356,.03466160908487025,.011599642488048602,.9992266072970502],LeftLeg:[-.022987686472704008,-.0006608912898930547,7960712093047862e-20,.9997355266049326],LeftShoulder:[.5181706903502131,.5134387363832796,-.48299308003518876,.4843526489955184],LeftToeBase:[.23652217735689587,.0006644108661216591,-.002051152932444189,.9716236982227819],LeftUpLeg:[-4952055077835167e-20,.0032567616062252223,.9999946186652781,-.00039203576089550014],Neck:[.2225107795455935,-23352293238692193e-23,-19647139012020554e-24,.974930229804142],RightArm:[-.003089570938390283,-.08018164882954634,.025041835809991725,.9964608693782484],RightFoot:[.5523737112340288,-.00025188760500252676,-.0036538107149212758,.8335885491999105],RightForeArm:[-2706717415294191e-22,60675494372234465e-25,-.012369382961452784,.9999234962561284],RightHand:[-.0012910114923260908,-.002537815924782367,-.010116450486313036,.9999447735796301],RightHandIndex1:[.028803284769926347,-.01136242475457741,-.05596571258489258,.9979524563349205],RightHandIndex2:[-.005195229421057241,-.014315442233259087,-.00021582506177354608,.9998840088349297],RightHandIndex3:[-.0013151045827228072,.016941319655899355,.006458327385746035,.9998347624459482],RightHandMiddle1:[.027532662650122483,.03160778647114273,-.01693120529165708,.9989775946478099],RightHandMiddle2:[-.0012680273836480952,-.0010469047250576836,.004466199390698661,.9999886745158897],RightHandMiddle3:[-.0015803562094451136,-.001835288773706009,-.003804068167924464,.9999898315756854],RightHandPinky1:[.009345030274151258,.07377446325595405,.04207784564870347,.9963430402658229],RightHandPinky2:[-.0019002008217559384,-.0002769620503994165,-.0004968229018870381,.9999980328459891],RightHandPinky3:[-.0014157497333212687,.0055951881780210025,.004606743315319843,.9999727333471813],RightHandRing1:[.01820754441109714,.03436008722907556,.03685535429214536,.9985637448787448],RightHandRing2:[-.0006571335802527884,-.015477230302375519,-.010034723368684675,.999829649412505],RightHandRing3:[.0018156069598940002,.003099598646436032,-.007204626788931167,.9999675941811231],RightHandThumb1:[.19002276085311107,.05882618704962336,-.3478783387552461,.9161940229953188],RightHandThumb2:[.018013663274561078,.020968550782212388,.22063584956274163,.9749644350943654],RightHandThumb3:[-.014498582331377526,-.03466161961137741,-.011599713293476643,.9992266058762234],RightLeg:[-.022987685898989207,.0006609402907891899,-7960698692017099e-20,.9997355265857409],RightShoulder:[.5181706006117709,-.5134387953473804,.4829931766210871,.4843525890882128],RightToeBase:[.23652222014073046,-.0006644109035597298,.0020511526077556528,.9716236878087238],RightUpLeg:[49438593286575395e-21,.003256759408127677,.9999946186765544,.0003920356017771739],Spine:[-.018332562694809717,-14544833124647894e-23,26976261645093277e-26,.9998319444511763],Spine1:[-.03815628571181615,20010687323521798e-24,534807122500512e-23,.9992717837809081],Spine2:[-.056998031890724846,13546308636882866e-23,-8861325315468363e-25,.9983742907149431]}),tx=Object.freeze({Head:[-.005402766806732544,-15440620455356296e-23,834223242528311e-24,.9999854049488961],Hips:[.0010741148761599644,6537898515070053e-23,7022659074474357e-26,.9999994231384476],LeftArm:[.4889318420664182,.5108287295941205,-.5108290884863605,.48893078190839623],LeftFoot:[-7112359875637768e-20,.5349085331963127,.8448985998862468,-.004383145577274271],LeftForeArm:[.49521300584988104,.5047420653526237,-.5047420379230214,.4952120815979495],LeftHand:[.5009334720626235,.5016127781291206,-.4977959877649929,.49964931327533474],LeftHandIndex1:[.5480286232738694,.46388966319384123,-.47756977349452234,.506357703809076],LeftHandIndex2:[.5522711480640051,.4734474077351049,-.46714980714345783,.5026083894226862],LeftHandIndex3:[.5405471533897316,.46903549072233974,-.4790521335412708,.5082553896043159],LeftHandMiddle1:[.5069366564823887,.46312011824587895,-.5184714785961669,.5096295836965867],LeftHandMiddle2:[.5047591066222094,.46656986579426646,-.5196237813564338,.5074661907650336],LeftHandMiddle3:[.5066805225023663,.46639751835165716,-.5160243364733309,.509379123507728],LeftHandPinky1:[.4459394011607033,.4793433042957962,-.5586434331057456,.5092009093395086],LeftHandPinky2:[.4453638702749085,.48032344738196137,-.5573549331147079,.5101920146245817],LeftHandPinky3:[.4392981168466072,.4802964151504903,-.5615019919023976,.5109286011992389],LeftHandRing1:[.47371996160924823,.4931227775910745,-.5418410288696247,.4886999364902444],LeftHandRing2:[.48665266892609377,.49620490515614146,-.5291888435031511,.48673303168821197],LeftHandRing3:[.48945530931580683,.4902132045285772,-.5280743092981476,.4911843263440915],LeftHandThumb1:[.6991138207882592,.16132571576360077,-.40704633814367386,.5652673372230799],LeftHandThumb2:[.64766423234777,.2923511094450446,-.5391393932239583,.4520957758831027],LeftHandThumb3:[.6626872004096495,.3080994487427915,-.5067905211225114,.45725679518685386],LeftLeg:[.0006202111480182034,-.020805293540463354,.9997832430476497,-.00047118992773536965],LeftShoulder:[.4605450937998788,.4559956590278878,-.537559006794696,.5394409087622226],LeftToeBase:[-.002764355526654178,.7195640056310856,.6944147145329627,-.0028643286082629046],LeftUpLeg:[-4987623525000119e-20,.0021826506059020026,.9999975399461294,-.00039198262713485737],Neck:[.11170149382802401,-1628868597421303e-22,-18309282630496044e-24,.9937418056399563],RightArm:[.48893190585215524,-.510828798312402,.5108290283825504,.48893071200502375],RightFoot:[7112360405196955e-20,.5349085398019146,.844898595705669,.004383145306035045],RightForeArm:[.4952130023257164,-.5047420673116668,.5047420415306929,.49521208229448166],RightHand:[.5009334695181179,-.5016127792807403,.49779599067075153,.49964931459617906],RightHandIndex1:[.5480286139806538,-.4638896746971551,.47756977858103167,.5063577013132781],RightHandIndex2:[.5522711446711094,-.4734474082706649,.4671498147721218,.5026083883587248],RightHandIndex3:[.5405470934413514,-.4690354263302402,.47905220274050364,.5082554503330304],RightHandMiddle1:[.5069366680435416,-.4631200623546733,.5184715098400317,.5096295939664325],RightHandMiddle2:[.5047591061928465,-.46656986723577604,.5196237819671778,.5074661920185282],RightHandMiddle3:[.5066805195140975,-.4663975225827095,.5160243369168757,.5093791249234989],RightHandPinky1:[.44593939683725603,-.4793433241517071,.5586434219640141,.5092009094272859],RightHandPinky2:[.4453638073881448,-.4803233923217868,.5573549834847424,.5101920690951159],RightHandPinky3:[.4392981269307416,-.4802964267888911,.5615019867791732,.5109285899785551],RightHandRing1:[.473719957983008,-.49312277921221886,.541841035805614,.4886999335659278],RightHandRing2:[.48665266754747677,-.4962049100848307,.5291888437972645,.4867330306200585],RightHandRing3:[.4894553112113337,-.49021320332208906,.5280743062058759,.4911843318554558],RightHandThumb1:[.6991137732035737,-.16132569450370315,.40704638897707807,.5652673641991798],RightHandThumb2:[.6476641963757893,-.2923511418798965,.5391394672107036,.45209571648691005],RightHandThumb3:[.6626871862817486,-.3080994479425299,.5067905521115058,.4572567801626834],RightLeg:[-.0006202113471683521,-.020805295090456907,.9997832430151556,.00047119017271936915],RightShoulder:[.46054507521936333,-.45599564278848104,.5375590232993736,.5394409245169026],RightToeBase:[.0027643555231566678,.7195640416379069,.6944146772223956,.0028643286020973192],RightUpLeg:[49925034443819034e-21,.002182648459062353,.9999975399486299,.00039198198974856475],Spine:[-.017258617754264162,-800818266828763e-22,13823133775055108e-25,.9998510589648868],Spine1:[-.055396652424023016,-5997624651397324e-23,332759956947242e-23,.9984644264570511],Spine2:[-.11221710079276989,7513757486198981e-23,-8485311473269302e-24,.9936837134066652]}),UP=Object.freeze({Head:[0,1.644459,-.02811],Hips:[0,.984089,.005022],LeftArm:[.204124,1.50826,-.034115],LeftFoot:[.095793,.088025,-.010018],LeftForeArm:[.458234,1.508259,-.045252],LeftHand:[.725837,1.508259,-.050352],LeftHandIndex1:[.815413,1.499602,-.024435],LeftHandIndex2:[.847794,1.497747,-.020782],LeftHandIndex3:[.872293,1.496601,-.017998],LeftHandMiddle1:[.820067,1.500491,-.048839],LeftHandMiddle2:[.854745,1.498698,-.047572],LeftHandMiddle3:[.881683,1.49736,-.046832],LeftHandPinky1:[.810112,1.495569,-.08743],LeftHandPinky2:[.8359,1.495002,-.089537],LeftHandPinky3:[.856018,1.494638,-.091171],LeftHandRing1:[.81666,1.499944,-.069059],LeftHandRing2:[.850313,1.498728,-.071468],LeftHandRing3:[.87354,1.497943,-.072665],LeftHandThumb1:[.761831,1.487283,-.024616],LeftHandThumb2:[.783931,1.477329,-.003377],LeftHandThumb3:[.806009,1.466616,.003515],LeftLeg:[.09541,.505427,.007362],LeftShoulder:[.056656,1.508576,-.035092],LeftToeBase:[.096919,.022281,.128921],LeftUpLeg:[.095072,.936186,.005482],Neck:[0,1.516499,-.057245],RightArm:[-.204124,1.50826,-.034115],RightFoot:[-.095793,.088025,-.010018],RightForeArm:[-.458234,1.508259,-.045252],RightHand:[-.725837,1.508259,-.050352],RightHandIndex1:[-.815413,1.499602,-.024435],RightHandIndex2:[-.847794,1.497747,-.020783],RightHandIndex3:[-.872293,1.496601,-.017998],RightHandMiddle1:[-.820067,1.500491,-.048839],RightHandMiddle2:[-.854745,1.498698,-.047572],RightHandMiddle3:[-.881683,1.49736,-.046832],RightHandPinky1:[-.810112,1.495569,-.08743],RightHandPinky2:[-.8359,1.495002,-.089537],RightHandPinky3:[-.856018,1.494638,-.091171],RightHandRing1:[-.81666,1.499944,-.069059],RightHandRing2:[-.850313,1.498729,-.071468],RightHandRing3:[-.87354,1.497943,-.072665],RightHandThumb1:[-.761831,1.487283,-.024615],RightHandThumb2:[-.783931,1.477329,-.003377],RightHandThumb3:[-.806009,1.466616,.003515],RightLeg:[-.09541,.505427,.007362],RightShoulder:[-.056656,1.508576,-.035092],RightToeBase:[-.096919,.022281,.128921],RightUpLeg:[-.095072,.936186,.005482],Spine:[0,1.077013,.005222],Spine1:[0,1.184494,.00151],Spine2:[0,1.330917,-.014788]}),kP=Object.freeze({Head:"Neck",Hips:null,LeftArm:"LeftShoulder",LeftFoot:"LeftLeg",LeftForeArm:"LeftArm",LeftHand:"LeftForeArm",LeftHandIndex1:"LeftHand",LeftHandIndex2:"LeftHandIndex1",LeftHandIndex3:"LeftHandIndex2",LeftHandMiddle1:"LeftHand",LeftHandMiddle2:"LeftHandMiddle1",LeftHandMiddle3:"LeftHandMiddle2",LeftHandPinky1:"LeftHand",LeftHandPinky2:"LeftHandPinky1",LeftHandPinky3:"LeftHandPinky2",LeftHandRing1:"LeftHand",LeftHandRing2:"LeftHandRing1",LeftHandRing3:"LeftHandRing2",LeftHandThumb1:"LeftHand",LeftHandThumb2:"LeftHandThumb1",LeftHandThumb3:"LeftHandThumb2",LeftLeg:"LeftUpLeg",LeftShoulder:"Spine2",LeftToeBase:"LeftFoot",LeftUpLeg:"Hips",Neck:"Spine2",RightArm:"RightShoulder",RightFoot:"RightLeg",RightForeArm:"RightArm",RightHand:"RightForeArm",RightHandIndex1:"RightHand",RightHandIndex2:"RightHandIndex1",RightHandIndex3:"RightHandIndex2",RightHandMiddle1:"RightHand",RightHandMiddle2:"RightHandMiddle1",RightHandMiddle3:"RightHandMiddle2",RightHandPinky1:"RightHand",RightHandPinky2:"RightHandPinky1",RightHandPinky3:"RightHandPinky2",RightHandRing1:"RightHand",RightHandRing2:"RightHandRing1",RightHandRing3:"RightHandRing2",RightHandThumb1:"RightHand",RightHandThumb2:"RightHandThumb1",RightHandThumb3:"RightHandThumb2",RightLeg:"RightUpLeg",RightShoulder:"Spine2",RightToeBase:"RightFoot",RightUpLeg:"Hips",Spine:"Hips",Spine1:"Spine",Spine2:"Spine1"});var _E=.5,yE=new Map(Object.entries(ex).map(([i,e])=>[i,new Pt(e[0],e[1],e[2],e[3])])),vE=new Map(Object.entries(tx).map(([i,e])=>[i,new Pt(e[0],e[1],e[2],e[3])])),bp=1e-6,nx="morphTargetInfluences[",Wh=new W,Ns=new Pt;function SE(i,e){for(let t=e?.parent;t;t=t.parent)if(t===i)return!0;return!1}function xp(i){let e=[],t=new Set,n=a=>{if(!a?.name||t.has(a))return;t.add(a);let o=yi(a.name);o&&e.push({node:a,raw:a.name,canonical:o})},r=[];i.traverse(a=>{a.isSkinnedMesh&&r.push(a),a.isBone&&n(a)});for(let a of r)for(let o of a.skeleton?.bones||[])n(o);Qb(e,{isAncestor:(a,o)=>SE(a.node,o.node)});let s=new Set;return e.filter(a=>s.has(a.canonical)?!1:(s.add(a.canonical),!0))}function ix(i){let e=new Map;for(let{canonical:t,node:n}of xp(i))e.set(t,n.name);return e}function rx(i){let e=new Map;for(let{canonical:t,node:n}of xp(i))e.set(t,n.quaternion.clone());return e}function wE(i,e){let t=i.quaternion.clone();for(let n=i.parent;n&&n!==e;n=n.parent)t.premultiply(n.quaternion);return t}function sx(i){let e=new Map;for(let{canonical:t,node:n}of xp(i))e.set(t,wE(n,i));return e}function ax(i){let e=new Map;return i.traverse(t=>{if(!(!t?.morphTargetDictionary||!t.name))for(let n of Object.keys(t.morphTargetDictionary)){e.has(n)||e.set(n,[]);let r=e.get(n);r.includes(t.name)||r.push(t.name)}}),e}function ME(i,e){let t=new Map;if(!(i instanceof Map))return t;let n=e instanceof Map;for(let[r,s]of yE){let a=i.get(r);if(!a)continue;let o=vE.get(r),l=n?e.get(r):null,c,h=null;o&&l?(c=a.clone().multiply(l.clone().invert()).multiply(o).multiply(s.clone().invert()),h=o.clone().invert().multiply(l),1-Math.abs(h.w)<bp&&(h=null)):c=a.clone().multiply(s.clone().invert());let d=1-Math.abs(c.w)<bp;d&&!h||t.set(r,{L:d?null:c,R:h})}return t}function AE(i,{L:e,R:t}){for(let n=0;n<i.length;n+=4)Ns.set(i[n],i[n+1],i[n+2],i[n+3]),e&&Ns.premultiply(e),t&&Ns.multiply(t),i[n]=Ns.x,i[n+1]=Ns.y,i[n+2]=Ns.z,i[n+3]=Ns.w}function TE(i,e){for(let t=0;t<i.length;t+=3)Wh.set(i[t],i[t+1],i[t+2]).applyQuaternion(e),i[t]=Wh.x,i[t+1]=Wh.y,i[t+2]=Wh.z}function EE(i,e){if(i){let t=i.isQuaternion?i.clone():new Pt(i[0],i[1],i[2],i[3]);return t.invert(),1-Math.abs(t.w)<bp?null:t}return e.get("Hips")?.L||null}function ox(i){let e=null;if(i.traverse(n=>{!e&&n.isBone&&n.name&&yi(n.name)==="Hips"&&(e=n)}),e||i.traverse(n=>{!e&&n.name&&yi(n.name)==="Hips"&&(e=n)}),!e||!e.parent)return null;let t=new Pt;for(let n=e.parent;n&&n!==i;n=n.parent)t.premultiply(n.quaternion);return t}function cx(i){try{return new rn().setFromObject(i).min.y}catch{return NaN}}var Da=new W,RE=new Pt,qh=new W;function _p(i){let e=null;if(i.traverse(s=>{!e&&s.isBone&&s.name&&yi(s.name)==="Hips"&&(e=s)}),e||i.traverse(s=>{!e&&s.name&&yi(s.name)==="Hips"&&(e=s)}),!e||!e.parent)return 0;e.updateWorldMatrix(!0,!1),e.getWorldPosition(Da);let t=Da.y,n=cx(i);Number.isFinite(n)&&(t-=n),e.parent.matrixWorld.decompose(Da,RE,qh);let r=(qh.x+qh.y+qh.z)/3;return!(r>1e-6)||!(t>0)||!Number.isFinite(t)?0:t/r}function yp(i){let e=null;if(i.traverse(r=>{!e&&r.isBone&&r.name&&yi(r.name)==="Hips"&&(e=r)}),e||i.traverse(r=>{!e&&r.name&&yi(r.name)==="Hips"&&(e=r)}),!e||!e.parent)return 0;e.updateWorldMatrix(!0,!1);let t=cx(i);if(!Number.isFinite(t))return 0;e.getWorldPosition(Da);let n=e.parent.worldToLocal(new W(Da.x,t,Da.z));return Number.isFinite(n.y)?n.y:0}function lx(i){let e=i.tracks.find(t=>t.name.endsWith(".position")&&yi(t.name.split(".")[0])==="Hips");return!e||e.values.length<3?0:e.values[1]}function hx(i,e,t={}){let n=Number.isFinite(t.hipScale)&&t.hipScale>0?t.hipScale:1,r=Number.isFinite(t.hipOffsetY)?t.hipOffsetY:0,s=t.minCoverage??_E,a=ME(t.targetRest,t.targetWorldRest),o=EE(t.hipsParentWorldQuat,a),l=[],c=[],h=[],d=0;for(let y of i.tracks){let b=y.name.indexOf(".");if(b===-1)continue;let g=y.name.slice(0,b),S=y.name.slice(b+1);if(S.startsWith(nx)){let U=S.slice(nx.length,-1),v=t.morphTargets instanceof Map?t.morphTargets.get(U):null;if(!v?.length){l.push(U);continue}for(let I of v){let B=y.clone();B.name=`${I}.${S}`,h.push(B)}continue}let A=yi(g)||g;if(!(S==="quaternion"||S==="position"&&A==="Hips"))continue;d++;let N=e.get(A);if(!N){l.push(A);continue}let P=y.clone();if(P.name=`${N}.${S}`,S==="quaternion"){let U=a.get(A);U&&AE(P.values,U)}else{if(o&&TE(P.values,o),n!==1)for(let U=0;U<P.values.length;U++)P.values[U]*=n;if(r!==0)for(let U=1;U<P.values.length;U+=3)P.values[U]+=r}c.push(P)}let f=c.length,p=d>0?f/d:0;if(p<s)return{clip:null,matched:f,total:d,coverage:p,dropped:l,hipScale:n,face:0};let x=i.clone();return x.tracks=[...c,...h],{clip:x,matched:f,total:d,coverage:p,dropped:l,hipScale:n,face:h.length}}Vn();var CE=.6,IE=.38,PE=-.4,vp=new W,ux=new W,dx=new W,fx=new W,px=new Pt,mx=new Pt,Sp=new Pt;function LE(i){for(let e of i.children)if(e.isBone)return e;return null}function gx(i,e){if(!i||e&&(e.has("LeftArm")||e.has("RightArm")))return 0;i.updateMatrixWorld(!0);let t=[],n=1/0,r=-1/0;if(i.traverse(c=>{if(!c.isBone)return;let h=LE(c);if(!h)return;c.getWorldPosition(vp),h.getWorldPosition(ux);let d=ux.clone().sub(vp),f=d.length();if(f<1e-5)return;d.multiplyScalar(1/f);let p=vp.y;p<n&&(n=p),p>r&&(r=p),t.push({bone:c,worldY:p,dir:d})}),t.length===0||!Number.isFinite(n)||r<=n)return 0;let s=(n+r)/2,a=null,o=null;for(let c of t){let{dir:h,worldY:d}=c;d<s||Math.abs(h.y)>IE||h.y<PE||Math.abs(h.x)<CE||(h.x>0?(!a||h.x>a.dir.x)&&(a=c):(!o||h.x<o.dir.x)&&(o=c))}let l=0;for(let c of[a,o])c&&DE(c.bone,c.dir)&&l++;return l}function DE(i,e){let t=e.x>=0?1:-1;fx.set(t*.14,-1,.1).normalize(),dx.copy(e),px.setFromUnitVectors(dx,fx),i.getWorldQuaternion(mx),i.parent?i.parent.getWorldQuaternion(Sp):Sp.identity();let n=px.multiply(mx),r=Sp.invert().multiply(n);return i.quaternion.copy(r),i.updateMatrixWorld(!0),!0}var NE=45,bx=new W,xx=new Pt,_x=new W(0,1,0);function OE(i,e,t){if(!i||!e||!t)return null;let n=t.get("Hips");if(!n)return null;let r=e.getObjectByName(n);if(!r)return null;let s=i.tracks.find(f=>f.name===`${n}.quaternion`);if(!s||s.values.length<4)return null;let a=s.values,o=r.quaternion.x,l=r.quaternion.y,c=r.quaternion.z,h=r.quaternion.w;r.quaternion.set(a[0],a[1],a[2],a[3]),r.updateWorldMatrix(!0,!1),r.getWorldQuaternion(xx),bx.copy(_x).applyQuaternion(xx),r.quaternion.set(o,l,c,h),r.updateWorldMatrix(!0,!1);let d=Math.max(-1,Math.min(1,bx.dot(_x)));return Math.acos(d)*180/Math.PI}var FE=8,UE=Object.freeze(["Hips","LeftUpLeg","LeftLeg","LeftFoot","LeftToeBase","RightUpLeg","RightLeg","RightFoot","RightToeBase"]),yx=.35,$h=new Map,jh=class i{constructor(){this.model=null,this.mixer=null,this.clips=new Map,this.actions=new Map,this.currentName=null,this.currentAction=null,this.onChange=null,this._animationDefs=[],this._failed=new Set,this._canonicalToNode=null,this._canonicalClipsSupported=!1,this._avatarContext={},this._fallenReported=new Set,this._fallen=new Set,this._latestCrossfadeTarget=null,this.overlayAction=null,this.overlayName=null,this._overlayClips=new Map,this._overlayFinishHandler=null,this._settleFinishHandler=null}setAvatarContext(e){this._avatarContext=e&&typeof e=="object"?{...e}:{}}attach(e,t){this.detach(),t&&this.setAvatarContext(t),this.model=e,this.mixer=new Ms(e),this.actions.clear(),this.currentAction=null,this.currentName=null,this._fallen.clear(),this._canonicalToNode=ix(e),this._canonicalRest=rx(e),this._canonicalWorldRest=sx(e),this._hipsParentWorldQuat=ox(e),this._morphTargets=ax(e),this._hipTargetLocalY=_p(e),this._hipGroundLocalY=yp(e),this._canonicalClipsSupported=kE(e);for(let[n,r]of this.clips){let s=this._retarget(r);if(!s)continue;let a=this.mixer.clipAction(s);a.enabled=!0,this.actions.set(n,a)}}remeasureRigProportions(){if(!this.model||!this.mixer)return!1;let e=this.currentName;this._hipTargetLocalY=_p(this.model),this._hipGroundLocalY=yp(this.model),this.mixer.stopAllAction();for(let t of this.actions.values()){let n=t.getClip?.();n&&this.mixer.uncacheClip(n)}this.actions.clear(),this.currentAction=null,this.currentName=null,this._latestCrossfadeTarget=null,this.overlayAction=null,this.overlayName=null,this._overlayClips.clear(),this._detachOverlayFinish?.();for(let[t,n]of this.clips){let r=this._retarget(n);if(!r)continue;let s=this.mixer.clipAction(r);s.enabled=!0,this.actions.set(t,s)}return e&&this.actions.has(e)&&this.play(e),!0}_retarget(e){if(!this._canonicalToNode||this._canonicalToNode.size===0)return null;let t=1,n=lx(e);this._hipTargetLocalY>.05&&n>.05&&(t=Math.min(200,Math.max(.2,this._hipTargetLocalY/n)));let{clip:r}=hx(e,this._canonicalToNode,{targetRest:this._canonicalRest,targetWorldRest:this._canonicalWorldRest,hipsParentWorldQuat:this._hipsParentWorldQuat,morphTargets:this._morphTargets,hipScale:t,hipOffsetY:this._hipGroundLocalY||0});return r}_guardAgainstFallenPose(e,t){if(this._fallen.has(e))return!1;let n=t?.getClip?.(),r=OE(n,this.model,this._canonicalToNode);if(r==null||!Number.isFinite(r)||r<=NE)return!0;try{t.stop()}catch(l){ei.warn("[AnimationManager] failed to stop fallen-pose action:",l)}t.enabled=!1,this.actions.delete(e),this._fallen.add(e),this.currentAction===t&&(this.currentAction=null,this.currentName=null);let s=this._avatarContext.avatarUrl||"",a=this._avatarContext.avatarId||"",o=`${a||s}|${e}`;return this._fallenReported.has(o)||(this._fallenReported.add(o),ei.warn(`[AnimationManager] "${e}" retargeted to a fallen pose (${r.toFixed(1)}\xB0 off vertical): falling back to bind pose`),BE({avatarId:a,avatarUrl:s,clip:e,tiltDeg:Math.round(r*10)/10})),!1}detach(){this.mixer&&(this.mixer.stopAllAction(),this.mixer.uncacheRoot(this.mixer.getRoot()),this.mixer=null),this.model=null,this._canonicalToNode=null,this._canonicalRest=null,this._canonicalWorldRest=null,this._hipsParentWorldQuat=null,this._morphTargets=null,this._hipTargetLocalY=0,this._hipGroundLocalY=0,this._canonicalClipsSupported=!1,this.actions.clear(),this.currentAction=null,this.currentName=null,this._latestCrossfadeTarget=null,this._fallen.clear(),this.overlayAction=null,this.overlayName=null,this._overlayClips.clear(),this._overlayFinishHandler=null}setAnimationDefs(e){this._animationDefs=e}appendAnimationDefs(e){let t=new Set(this._animationDefs.map(n=>n.name));for(let n of e)t.has(n.name)||(this._animationDefs.push(n),t.add(n.name))}getAnimationDefs(){return this._animationDefs}isFailed(e){return this._failed.has(e)}supportsCanonicalClips(){return this._canonicalClipsSupported}relaxUndrivenArms(){return this.model?gx(this.model,this._canonicalToNode):0}canPlay(e){return this._fallen.has(e)?!1:this.clips.has(e)?!0:this._failed.has(e)?!1:this._animationDefs.some(t=>t.name===e)}async loadAnimation(e,t,n={}){if(this.clips.has(e))return this.clips.get(e);let r=$h.get(t);r||(r=i._fetchClip(e,t),$h.set(t,r),r.catch(()=>{$h.get(t)===r&&$h.delete(t)}));let s=await r;return this._registerParsedClip(e,s,n)}static async _fetchClip(e,t){let n=t.includes("/api/animations/"),r=new AbortController,s=setTimeout(()=>r.abort(),15e3),a;try{a=await fetch(t,{signal:r.signal,credentials:n?"include":"same-origin",redirect:"error"})}finally{clearTimeout(s)}if(!a.ok)throw new Error(`HTTP ${a.status} loading animation ${e}`);let o=await a.json(),l=n?o?.clip?.clip:o;if(!l&&o?.clip?.paywalled)throw new Error(`animation ${e} is a paid clip, unlock it at ${o.clip.download_url}`);if(!l)throw new Error(`clip payload missing from ${t}`);let c=bi.parse(l);return c.name=e,c}injectClip(e,t,n={}){if(!(!t||this.clips.has(e)))try{let r=bi.parse(t);r.name=e,this._registerParsedClip(e,r,n)}catch(r){ei.warn(`[AnimationManager] injectClip "${e}" parse error:`,r.message)}}_registerParsedClip(e,t,n){if(this.clips.set(e,t),this.model&&this.mixer){let r=this._retarget(t);if(r){let s=this.mixer.clipAction(r);s.enabled=!0,s.setLoop(n.loop===!1?_a:Fo),n.loop===!1&&(s.clampWhenFinished=!0),this.actions.set(e,s)}}return t}async loadAll(){let t=[...this._animationDefs],n=async()=>{let r;for(;r=t.shift();)try{await this.loadAnimation(r.name,r.url,{loop:r.loop!==!1})}catch(s){ei.warn(`[AnimationManager] failed to load "${r.name}":`,s.message),this._failed.add(r.name)}};await Promise.all(Array.from({length:4},n))}async ensureLoaded(e){if(this.clips.has(e))return!0;if(this._failed.has(e))return!1;let t=this._animationDefs.find(n=>n.name===e);if(!t)return!1;try{return await this.loadAnimation(t.name,t.url,{loop:t.loop!==!1}),!0}catch{return this._failed.add(e),!1}}async play(e){if(!await this.ensureLoaded(e))return(this._failed.has(e)||this._animationDefs.some(r=>r.name===e))&&ei.warn(`[AnimationManager] "${e}" unavailable`),!1;if(e===this.currentName)return!0;let n=this.actions.get(e);if(!n||!this._guardAgainstFallenPose(e,n))return!1;this.currentAction&&this.currentAction!==n&&this.currentAction.fadeOut(.01),n.reset().fadeIn(.01).play(),this.currentAction=n,this.currentName=e;try{this.onChange?.(e)}catch(r){ei.warn("[AnimationManager] onChange threw:",r)}return!0}async playOnce(e,{settleTo:t="idle",fade:n=yx}={}){n=Math.max(0,Math.min(n,5));let s=await this.ensureLoaded(e)?this.actions.get(e):null;if(!s||!this._guardAgainstFallenPose(e,s))return t?this.crossfadeTo(t,n):void 0;if(s.reset(),s.setLoop(_a,1),s.clampWhenFinished=!0,s.play(),this.currentAction&&this.currentAction!==s?this.currentAction.crossFadeTo(s,n,!0):s.fadeIn(n),this.currentAction=s,this.currentName=e,this._settleFinishHandler&&this.mixer&&(this.mixer.removeEventListener("finished",this._settleFinishHandler),this._settleFinishHandler=null),t&&this.mixer){let a=o=>{o.action===s&&(this.mixer.removeEventListener("finished",a),this._settleFinishHandler===a&&(this._settleFinishHandler=null),this.currentAction===s&&this.crossfadeTo(t,n))};this._settleFinishHandler=a,this.mixer.addEventListener("finished",a)}try{this.onChange?.(e)}catch(a){ei.warn("[AnimationManager] onChange threw:",a)}}freeze(){this.currentAction&&(this.currentAction.paused=!0),this.currentAction=null,this.currentName=null,this._latestCrossfadeTarget=null}async crossfadeTo(e,t=yx){if(t=Math.max(0,Math.min(t,5)),e===this.currentName)return;if(this._latestCrossfadeTarget=e,!await this.ensureLoaded(e)){(this._failed.has(e)||this._animationDefs.some(s=>s.name===e))&&ei.warn(`[AnimationManager] "${e}" unavailable`);return}if(this._latestCrossfadeTarget!==e||e===this.currentName)return;let r=this.actions.get(e);if(r&&this._guardAgainstFallenPose(e,r)){r.reset().play(),this.currentAction&&this.currentAction!==r?this.currentAction.crossFadeTo(r,t,!0):r.fadeIn(t),this.currentAction=r,this.currentName=e;try{this.onChange?.(e)}catch(s){ei.warn("[AnimationManager] onChange threw:",s)}}}_buildOverlayClip(e,t){let n=`${e}|${t?"upper":"full"}`,r=this._overlayClips.get(n);if(r)return r;let s=this.clips.get(e);if(!s)return null;let a=this._retarget(s);if(!a)return null;let o=a.tracks;if(t&&this._canonicalToNode){let c=new Set;for(let h of UE){let d=this._canonicalToNode.get(h);d&&c.add(d)}if(o=o.filter(h=>{let d=h.name.split(".")[0];return!c.has(d)}),o.length===0)return null}let l=new bi(`${e}__additive`,a.duration,o);return mo.makeClipAdditive(l),this._overlayClips.set(n,l),l}async playOverlay(e,{loop:t=!1,crossfade:n=.25,upperBodyOnly:r=!0,timeScale:s=1,onFinished:a=null}={}){if(n=Math.max(0,Math.min(n,5)),!await this.ensureLoaded(e)||!this.mixer)return!1;let l=this._buildOverlayClip(e,r);if(!l)return!1;let c=this.mixer.clipAction(l,void 0,Uo);this._detachOverlayFinish();let h=this.overlayAction;if(h&&h!==c&&h.fadeOut(n),c.enabled=!0,c.setLoop(t?Fo:_a,t?1/0:1),c.clampWhenFinished=!t,c.setEffectiveTimeScale(s),c.reset(),c.setEffectiveWeight(1),c.fadeIn(n),c.play(),this.overlayAction=c,this.overlayName=e,!t){let d=f=>{if(f.action===c){this.mixer.removeEventListener("finished",d),this._overlayFinishHandler===d&&(this._overlayFinishHandler=null),this.overlayAction===c&&(c.fadeOut(n),this.overlayAction=null,this.overlayName=null);try{a?.(e)}catch(p){ei.warn("[AnimationManager] overlay onFinished threw:",p)}}};this._overlayFinishHandler=d,this.mixer.addEventListener("finished",d)}return!0}_detachOverlayFinish(){this._overlayFinishHandler&&this.mixer&&this.mixer.removeEventListener("finished",this._overlayFinishHandler),this._overlayFinishHandler=null}stopOverlay({crossfade:e=.2}={}){e=Math.max(0,Math.min(e,5)),this._detachOverlayFinish(),this.overlayAction&&(this.overlayAction.fadeOut(e),this.overlayAction=null,this.overlayName=null)}hasOverlay(){return this.overlayAction!=null}setSpeed(e){this.currentAction?.setEffectiveTimeScale(e)}stopAll(){this.mixer?.stopAllAction(),this._detachOverlayFinish(),this.currentAction=null,this.currentName=null,this.overlayAction=null,this.overlayName=null;try{this.onChange?.(null)}catch(e){ei.warn("[AnimationManager] onChange threw:",e)}}update(e){this.mixer?.update(e)}getLoadedNames(){return[...this.clips.keys()]}isLoaded(e){return this.clips.has(e)}dispose(){this.detach(),this.clips.clear(),this._animationDefs=[],this._failed.clear()}};function kE(i){let e=!1,t=new Set;return i.traverse(n=>{if(n.isSkinnedMesh&&(e=!0),n.name){let r=yi(n.name);r&&t.add(r)}}),e&&t.size>=FE}function BE(i){try{let e=typeof window<"u"&&typeof window.reportClientError=="function"?window.reportClientError:null;if(!e)return;e(new Error("fallen-pose retarget"),i)}catch(e){ei.warn("[AnimationManager] fallen-pose report failed:",e)}}var Sx=Ls("ar-studio:idle"),Xo=null,vx="";function wx({manifestUrl:i=En.animationManifest,clip:e="idle"}={}){let t=`${i}#${e}`;return Xo&&vx===t||(vx=t,Xo=(async()=>{let n=await fetch(i,{cache:"force-cache"}).then(l=>{if(!l.ok)throw new Error(`HTTP ${l.status}`);return l.json()}),r=Array.isArray(n)?n:n?.clips||n?.animations||[],s=r.find(l=>l?.name===e)||r[0];if(!s?.url)throw new Error(`clip "${e}" missing from the manifest`);let a=new URL(s.url,i).href,o=await fetch(a,{cache:"force-cache"});if(!o.ok)throw new Error(`HTTP ${o.status}`);return o.json()})().catch(n=>(Sx.warn("idle clip unavailable:",n?.message||n),Xo=null,null))),Xo}async function wp(i,{manifestUrl:e,clip:t="idle",sourceUrl:n=""}={}){let r=await wx({manifestUrl:e,clip:t});if(!r||!i)return null;let s=new jh;try{if(s.attach(i,{avatarUrl:n}),!s.supportsCanonicalClips()||(s.relaxUndrivenArms(),s.injectClip(t,r,{loop:!0}),!await s.play(t)))return s.detach(),null;let o=s.currentAction,l=o?.getClip?.()?.duration||0;return o&&l>0&&(o.time=Math.random()*l),s.update(0),s}catch(a){Sx.warn("idle mount failed:",a?.message||a);try{s.detach()}catch{}return null}}async function Mp({canvas:i,video:e,isAR:t}){if(!i)return null;let n=i.width,r=i.height;if(!n||!r)return null;let s=document.createElement("canvas");s.width=n,s.height=r;let a=s.getContext("2d");if(!a)return null;if(t&&e&&!e.paused&&e.videoWidth)try{a.drawImage(e,0,0,n,r)}catch{}try{a.drawImage(i,0,0)}catch{return null}return new Promise(o=>s.toBlob(o,"image/png"))}async function Ap(i,{filename:e="ar-studio.png",title:t="AR Studio"}={}){let n=new File([i],e,{type:"image/png"});if(navigator.share&&navigator.canShare?.({files:[n]}))return await navigator.share({title:t,files:[n]}),"shared";let r=URL.createObjectURL(i),s=document.createElement("a");return s.href=r,s.download=e,s.click(),setTimeout(()=>URL.revokeObjectURL(r),4e3),"downloaded"}async function Tp(i,{title:e="AR Studio",text:t=""}={}){if(navigator.share)try{return await navigator.share({title:e,url:i,...t?{text:t}:{}}),"shared"}catch(n){if(n?.name==="AbortError")throw n}return await navigator.clipboard.writeText(i),"copied"}function e_(){return typeof navigator>"u"?!1:/iphone|ipad|ipod/i.test(navigator.userAgent)||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1}function em(){return e_()}function t_(){return typeof navigator<"u"&&/android/i.test(navigator.userAgent)}function tm(){return t_()}var au=null,n_="_apple_ar_quicklook_button_tapped";function i_(i){return`${String(i||"").trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,60)||"model"}.usdz`}function r_(i,{onBannerTap:e,name:t=""}={}){au&&(au.remove(),au=null);let n=document.createElement("a");n.rel="ar",n.appendChild(document.createElement("img")),n.href=i,/^blob:/i.test(i)&&n.setAttribute("download",i_(t)),n.style.cssText="position:fixed;left:0;top:0;width:1px;height:1px;opacity:0;pointer-events:none;overflow:hidden;",n.setAttribute("aria-hidden","true"),typeof e=="function"&&n.addEventListener("message",r=>{r.data===n_&&e()}),document.body.appendChild(n),au=n,n.click()}function s_(i,{title:e="",link:t="",fallbackUrl:n=""}={}){let r=new URLSearchParams({file:i,mode:"ar_preferred"});e&&r.set("title",e),t&&r.set("link",t);let s=encodeURIComponent(n||location.href);location.href=`intent://arvr.google.com/scene-viewer/1.2?${r.toString()}#Intent;scheme=https;package=com.google.ar.core;action=android.intent.action.VIEW;S.browser_fallback_url=${s};end;`}async function nm(){try{if(navigator.xr&&await navigator.xr.isSessionSupported("immersive-ar"))return"webxr"}catch{}return em()?"quicklook":tm()?"sceneviewer":"none"}var gR=4,ti=new Map;function bR(){for(;ti.size>gR;){let[i,e]=ti.entries().next().value;ti.delete(i),e.href&&URL.revokeObjectURL(e.href)}}function xR(){for(let i of ti.values())i.href&&URL.revokeObjectURL(i.href);ti.clear()}function ou(i){let e=ti.get(i);return e?(ti.delete(i),e.href&&URL.revokeObjectURL(e.href),!0):!1}function cu(i){return!!(i&&ti.get(i)?.href)}async function a_(i,e){let t=ti.get(i);if(t)return ti.delete(i),ti.set(i,t),t.promise;let n={href:"",promise:null};return n.promise=(async()=>{let r=await e();return n.href=URL.createObjectURL(r),n.href})(),n.promise.catch(()=>{ti.get(i)===n&&ti.delete(i)}),ti.set(i,n),bR(),n.promise}async function ec({src:i="",title:e="",usdz:t="",key:n="",build:r}={},{onProgress:s,fallbackUrl:a="",signal:o}={}){if(!i&&!t&&!r)throw new Error("ar-studio: nothing to place");if(em()){let l=t;if(!l){let c=n||i;if(!c)throw new Error("ar-studio: a cache key or src is required");l=await a_(c,async()=>{if(r)return s?.("convert"),r();let{glbUrlToUsdzBlob:h}=await Promise.resolve().then(()=>(su(),Qp));return h(i,{signal:o,onProgress:s})})}return{viewer:"quicklook",href:l,open:c=>r_(l,{name:e,...c})}}if(tm()){if(!i)throw new Error("ar-studio: Scene Viewer needs a GLB URL");return{viewer:"sceneviewer",href:i,open:()=>s_(i,{title:e,fallbackUrl:a})}}return null}async function im(i={},e={}){let t=await ec(i,e);return t?(e.onProgress?.("open"),t.open(),t.viewer):"none"}var _R=80;function yR(i,{title:e,subtitle:t,callToAction:n}={}){if(typeof i!="string"||!i)return i;let r=[],s=(o,l)=>{let c=typeof l=="string"?l.trim().slice(0,_R):"";c&&r.push(`${o}=${encodeURIComponent(c)}`)};if(!n||typeof n!="string"||!n.trim()||(s("checkoutTitle",e),s("checkoutSubtitle",t),s("callToAction",n),!r.length))return i;let a=r.join("&");return i.includes("#")?`${i}&${a}`:`${i}#${a}`}var vR=Math.PI/180,SR=180/Math.PI;function o_({trackWidth:i,trackHeight:e,viewWidth:t,viewHeight:n,diagFovDeg:r=72}){let s=tc(i,t),a=tc(e,n),o=tc(t,s),l=tc(n,a),c=tc(r,72),h=Math.hypot(s,a)||1,d=2*Math.atan(s/h*Math.tan(c*vR/2)),f=o/l,x=2*Math.atan(Math.tan(d/2)/(f||1))*SR;return Number.isFinite(x)?Math.max(50,Math.min(90,x)):50}function tc(i,e){let t=Number(i);return Number.isFinite(t)&&t>0?t:Number(e)>0?Number(e):1}var c_=Math.PI/180;function wR(i,e,t){let n=(e-i+Math.PI)%(Math.PI*2)-Math.PI;return n<-Math.PI&&(n+=Math.PI*2),i+n*t}function l_(i,e){return Number.isFinite(i)&&Number.isFinite(e)}function h_({useAbsolute:i,prevYaw:e,alpha:t,baseAlpha:n,baseYaw:r,compassHeading:s,absoluteSmooth:a=.4}){if(i){let l=-s*c_;return wR(e,l,a)}let o=t-n;return o>180&&(o-=360),o<-180&&(o+=360),r+o*c_}function lu(i,e,t){let n=Number.isFinite(i)?i:0;return n<e?e:n>t?t:n}function rm(i,e,t=0){let n=(Math.round(Number(t)/90)*90%360+360)%360,r;switch(n){case 90:r=e;break;case 180:r=-i;break;case 270:r=-e;break;default:r=i;break}return Number.isFinite(r)?r:0}eu();var sm=Math.PI*2;function u_(i){return Number.isFinite(i)?(i%sm+sm)%sm:0}function am(i){return Number.isFinite(i)?(i%360+360)%360:0}function om(i){return{relEast:Number(i.x)||0,relNorth:-(Number(i.z)||0)||0,yawDeg:am(u_(i.yaw)*180/Math.PI),scale:Number(i.scale)||1,height:Number(i.height)||0}}function uu(i){return{x:Number(i.relEast)||0,z:-(Number(i.relNorth)||0),yaw:am(i.yawDeg)*Math.PI/180,scale:Number(i.scale)||1}}var hu="ABCDEFGHJKMNPQRSTUVWXYZ23456789",d_=6;function Fs(i){let e=String(i??"").trim();if(!e)return"";let t=e.match(/[?&]room=([^&#\s]+)/i);if(t)try{e=decodeURIComponent(t[1])}catch{e=t[1]}if(e=e.toUpperCase().replace(/[\s-]+/g,""),e.length!==d_)return"";for(let n of e)if(!hu.includes(n))return"";return e}function cm(i=Math.random){let e="";for(let t=0;t<d_;t++)e+=hu[Math.floor(i()*hu.length)%hu.length];return e}function lm(i){return`c-${Fs(i)}`}function nc(i,e){let t=String(i||"").split("#")[0],n=Fs(e);return n?`${t}${t.includes("?")?"&":"?"}room=${n}`:t}var ts=Ls("ar-studio:net"),AC="studio_world",TC=1,EC=15e3,gc=null;async function RC(){if(gc!==null)return gc;try{let[i,e]=await Promise.all([Promise.resolve().then(()=>og(fv(),1)),Promise.resolve().then(()=>(mv(),pv))]);gc={Client:i.Client,getStateCallbacks:i.getStateCallbacks,StudioState:e.StudioState}}catch(i){ts.warn('shared rooms need the optional "colyseus.js" dependency:',i?.message||i),gc=!1}return gc}async function CC(i,e,t){let n,r=new Promise((a,o)=>{n=setTimeout(()=>o(new Error("connect_timeout")),EC)}),s=i.joinOrCreate(AC,e,t);try{return await Promise.race([s,r])}finally{clearTimeout(n),s.then(a=>{try{a&&a.connection?.isOpen&&a.leave()}catch{}}).catch(()=>{})}}var Lu=class{constructor({roomKey:e,clientId:t="",name:n="",url:r=""}={}){this.roomKey=String(e||"").slice(0,64),this.clientId=String(t||"").slice(0,80),this.name=String(n||"").slice(0,120),this.url=String(r||"").replace(/\/$/,""),this.status="idle",this.error="",this.room=null,this.client=null,this._listeners={status:[],models:[],model:[],presence:[],reject:[]},this._retries=0,this._reconnectTimer=null,this._connectGen=0,this._destroyed=!1,this._presenceQueued=!1,this._modelsQueued=!1}on(e,t){return(this._listeners[e]||=[]).push(t),this}_emit(e,t){for(let n of this._listeners[e]||[])try{n(t)}catch(r){ts.warn(`${e} listener error:`,r?.message||r)}}_setStatus(e,t=""){this.status=e,this.error=t,this._emit("status",{status:e,error:t})}_closeRoom(){let e=this.room;if(e){this.room=null;try{e.removeAllListeners()}catch{}try{e.leave()}catch{}}}async connect(){if(this._destroyed)return;if(this._closeRoom(),!this.url||!this.roomKey){this._setStatus("unavailable");return}let e=await RC();if(!e){this._setStatus("unavailable","colyseus.js is not installed");return}let t=++this._connectGen;this._setStatus("connecting");try{this.client=new e.Client(this.url);let n=await CC(this.client,{roomKey:this.roomKey,clientId:this.clientId,name:this.name},e.StudioState);if(this._destroyed||t!==this._connectGen){try{n.leave()}catch{}return}this.room=n,this._retries=0;let r=e.getStateCallbacks(this.room),s=r(this.room.state)?.models;s&&(s.onAdd((o,l)=>{r(o).onChange(()=>this._emit("model",this._modelShape(o,l))),this._queueModels()}),s.onRemove((o,l)=>{this._emit("model",{id:l,removed:!0}),this._queueModels()}));let a=r(this.room.state)?.viewers;a&&(a.onAdd(()=>this._queuePresence()),a.onRemove(()=>this._queuePresence())),this.room.onMessage("model:reject",o=>this._emit("reject",o)),this.room.onLeave(o=>{this._destroyed||o===1e3||(this._setStatus("offline"),this._scheduleReconnect())}),this.room.onError((o,l)=>ts.warn("room error",o,l)),this._setStatus("online"),this._queueModels(),this._queuePresence()}catch(n){let r=n?.message||(n?.code!=null?`code ${n.code}`:String(n));ts.warn("connect failed:",r),this._setStatus("failed",r),this._scheduleReconnect()}}_scheduleReconnect(){if(this._reconnectTimer||this._destroyed)return;if(this._retries>=TC){this._setStatus("unavailable",this.error);return}this._retries++;let e=2500+Math.random()*1500;this._reconnectTimer=setTimeout(()=>{this._reconnectTimer=null,this._destroyed||this.connect()},e)}_modelShape(e,t){return{id:t??e.id,src:e.src,title:e.title,relEast:e.relEast,relNorth:e.relNorth,yawDeg:e.yawDeg,scale:e.scale,height:e.height,ownerId:e.ownerId,mine:!!this.clientId&&e.ownerId===this.clientId}}_queueModels(){this._modelsQueued||this._destroyed||(this._modelsQueued=!0,Promise.resolve().then(()=>{this._modelsQueued=!1;let e=this.room?.state?.models;if(this._destroyed||!e)return;let t=[];e.forEach((n,r)=>t.push(this._modelShape(n,r))),this._emit("models",t)}))}_queuePresence(){this._presenceQueued||this._destroyed||(this._presenceQueued=!0,Promise.resolve().then(()=>{this._presenceQueued=!1;let e=this.room?.state?.viewers;if(this._destroyed||!e)return;let t=0,n=[];e.forEach(r=>{t++,r.name&&n.push(r.name)}),this._emit("presence",{count:t,names:n})}))}_live(){return this.status==="online"&&this.room&&this.room.connection?.isOpen===!0}spawn(e){if(!this._live())return!1;try{return this.room.send("model:spawn",{id:e.id,src:String(e.src||""),title:String(e.title||"").slice(0,120),relEast:Number(e.relEast)||0,relNorth:Number(e.relNorth)||0,yawDeg:Number(e.yawDeg)||0,scale:Number(e.scale)||1,height:Number(e.height)||0}),!0}catch(t){return ts.warn("spawn failed:",t?.message||t),!1}}update(e,t){if(!this._live()||!e)return!1;let n={id:String(e)};for(let r of["relEast","relNorth","yawDeg","scale"])Number.isFinite(t?.[r])&&(n[r]=t[r]);try{return this.room.send("model:update",n),!0}catch(r){return ts.warn("update failed:",r?.message||r),!1}}remove(e){if(!this._live()||!e)return!1;try{return this.room.send("model:remove",{id:String(e)}),!0}catch(t){return ts.warn("remove failed:",t?.message||t),!1}}heartbeat(){if(this._live())try{this.room.send("heartbeat",{})}catch(e){ts.warn("heartbeat failed:",e?.message||e)}}destroy(){this._destroyed=!0,this._reconnectTimer&&(clearTimeout(this._reconnectTimer),this._reconnectTimer=null),this._closeRoom(),this.client=null,this._setStatus("destroyed")}};var hi=Ls("ar-studio"),DC=1.55,eg=-1.25,tg=1.35,ng=1,ig=1.15,Du=60,bc=class{constructor(e,t={}){if(!e)throw new Error("ar-studio: a host element is required");this.host=e,this.config=bf(t),this.clientId=UC(this.config.persistKey),this.sources=Lf(this.config.assets,this.config),this._listeners=new Map,this._destroyed=!1,this.ui=Cb(e,this.config),(this.config.fullscreen??e===document.body)&&this.ui.root.classList.add("is-fullscreen"),this._initScene(),this._initState(),this._wireUI(),this._boot()}on(e,t){return this._listeners.has(e)||this._listeners.set(e,new Set),this._listeners.get(e).add(t),()=>this.off(e,t)}off(e,t){this._listeners.get(e)?.delete(t)}_emit(e,t={}){for(let n of this._listeners.get(e)||[])try{n(t)}catch(r){hi.warn(`${e} listener error`,r)}try{this.config.onEvent?.(e,t)}catch(n){hi.warn("onEvent error",n)}try{this.ui.root.dispatchEvent(new CustomEvent(`ar-studio:${e}`,{detail:t,bubbles:!0}))}catch{}}_initScene(){this.renderer=new yh({canvas:this.ui.canvas,alpha:!0,antialias:!0,preserveDrawingBuffer:!0}),this.renderer.setClearColor(0,0),this.qualityTier=Of(),Ff(this.renderer,{tier:this.qualityTier}),this.scene=new Or,this.camera=new an(58,1,.02,200),this.camera.position.set(0,DC,0),this.cameraYaw=0,this.cameraPitch=-.24;let e=this.qualityTier==="mobile"?null:this.config.lighting?.preset??"studio";if(Uf(this.renderer,this.scene,e,{urls:this.config.lighting?.urls}).catch(t=>hi.warn("environment map failed",t)),this.hemi=new ma(16777215,4473941,ng),this.sun=new Di(16777215,ig),this.sun.position.set(2.5,6,3),this.scene.add(this.hemi,this.sun),this.grid=new To(24,48,3817298,2303802),this.grid.position.y=.001,this.grid.material.transparent=!0,this.grid.material.opacity=.75,this._fog=new no(395018,5,17),this.scene.fog=this._fog,this.scene.add(this.grid),this.rayPlane=new xt(new mi(80,80),new gn({visible:!1,side:2})),this.rayPlane.rotation.x=-Math.PI/2,this.scene.add(this.rayPlane),this.selRing=new xt(new Gr(.3,.34,48).rotateX(-Math.PI/2),new gn({color:9141496,transparent:!0,opacity:.85,depthTest:!1})),this.config.branding?.accent)try{this.selRing.material.color.set(this.config.branding.accent)}catch{}this.selRing.renderOrder=998,this.selRing.visible=!1,this.scene.add(this.selRing),this.shadowTex=OC(),this.reducedMotion=NC(),this._applyCameraLook()}_initState(){this.placements=[],this.selected=null,this.arActive=!1,this.mediaStream=null,this.arTransitioning=!1,this.xrSession=null,this.estimatedLight=null,this.arMode="none",this._cameraYielded=!1,this._cameraWasOn=!1,this._onArReturn=null,this._nativeArBusy=!1,this._arHandoff=null,this._arTarget=null,this._arToken=0,this._arWarmTimer=null,this._arRetry=null,this._arKeys=new Set,this.arTrackW=0,this.arTrackH=0,this._statusTimer=null,this._armed=null,this._templates=new Map,this._templatesReady=new Map,this._trayCache=new Map,this._trayTab=this.sources[0]?.id||"link",this._loadQueue=Ob({run:e=>Gh().loadAsync(e),maxActive:3}),this._maxPlacements=Math.min(Number(this.config.maxPlacements)||20,20),this.net=null,this.roomCode="",this._netModels=new Map,this._presence={count:1,names:[]},this._roomSynced=!1,this._roomHeartbeat=null,this.forge=this.config.generate?.enabled===!1?null:Mf({endpoint:this.config.generate.endpoint,kind:this.config.generate.kind,tier:this.config.generate.tier,timeoutMs:this.config.generate.timeoutMs,pollMs:this.config.generate.pollMs,headers:this.config.generate.headers}),this._forgeSeq=0,this._forgeBusy=!1,this.gyroBase=null,this._devAlpha=0,this._devBeta=90,this._devGamma=0,this._absoluteOrientation=!1,this._raycaster=new Ao,this._ndc=new dt,this._pointer=null,this._userLooked=!1,this._pinch=$o(),this._pinchEndedAt=-1/0,this._twist=null,this._rafId=null,this._prevT=0,this._lightTimer=null,this._roomTint=new Ve,this._lightProbe=FC(),this._recentKey=`${this.config.persistKey}:recent`,this.config.recentKey=this._recentKey}_wireUI(){let e=this.ui,t=(r,s,a,o)=>{r&&r.addEventListener(s,a,o)};t(e.cameraBtn,"click",()=>{this.arTransitioning||this.xrSession||(this.arActive?(this._stopCamera(),this._setStatus("Camera off: preview mode.")):this._startCamera())}),!navigator.mediaDevices?.getUserMedia&&e.cameraBtn&&(e.cameraBtn.disabled=!0,e.cameraBtn.setAttribute("aria-disabled","true"),e.cameraBtn.title="This browser cannot open a camera"),t(e.xrBtn,"click",()=>this._enterAR()),t(e.addBtn,"click",()=>e.tray.hidden?this._openTray():this._closeTray()),t(e.trayClose,"click",()=>this._closeTray()),t(e.tray,"click",r=>{r.target===e.tray&&this._closeTray()}),t(e.emptyAdd,"click",()=>this._openTray()),t(e.emptyCamera,"click",()=>this._startCamera()),t(e.emptyForge,"click",()=>e.forgeInput?.focus()),t(e.forgeForm,"submit",r=>{r.preventDefault(),this._startForge(e.forgeInput?.value)}),t(e.clearBtn,"click",()=>this._clearWithUndo()),t(e.photoBtn,"click",()=>this._capturePhoto()),t(e.qrBtn,"click",()=>this._openQr()),t(e.qrClose,"click",()=>this._closeQr()),t(e.qrModal,"click",r=>{r.target===e.qrModal&&this._closeQr()}),t(e.arClose,"click",()=>this._closeArSheet()),t(e.arModal,"click",r=>{r.target===e.arModal&&this._closeArSheet()}),t(e.arGo,"click",()=>this._onArGo()),t(e.arXr,"click",()=>{this._closeArSheet(),this._toggleXR()}),t(e.arQr,"click",()=>{this._closeArSheet(),this._openQr()}),t(e.arPicker,"click",r=>{let s=r.target.closest("[data-ar-id]");if(!s)return;let a=this.placements.find(o=>o.id===s.dataset.arId);a&&this._showArTarget(a)}),t(e.selbar,"click",r=>this._onSelbarClick(r)),t(e.roomBtn,"click",()=>this._openRoomModal()),t(e.roomClose,"click",()=>this._closeRoomModal()),t(e.roomModal,"click",r=>{r.target===e.roomModal&&this._closeRoomModal()}),t(e.roomCreate,"click",()=>this._createRoomFromUI()),t(e.roomJoinForm,"submit",r=>{r.preventDefault(),this._joinRoomFromUI()}),t(e.roomCopy,"click",()=>this._copyRoomInvite()),t(e.roomLeave,"click",()=>{this._leaveRoom(),this._renderRoomModal()});let n=e.canvas;t(n,"pointerdown",r=>this._onPointerDown(r)),t(n,"pointermove",r=>this._onPointerMove(r)),t(n,"pointerup",r=>this._onPointerUp(r)),t(n,"pointercancel",()=>{this._pointer=null}),t(n,"touchstart",r=>this._onTouchStart(r),{passive:!0}),t(n,"touchmove",r=>this._onTouchMove(r),{passive:!0}),t(n,"touchend",()=>this._onTouchEnd(),{passive:!0}),this._onKeyDown=this._onKeyDown.bind(this),document.addEventListener("keydown",this._onKeyDown),this._onOrientationAbsolute=r=>{this._absoluteOrientation=!0,this._onDeviceOrientation(r)},this._onOrientation=r=>{this._absoluteOrientation||this._onDeviceOrientation(r)},window.addEventListener("deviceorientationabsolute",this._onOrientationAbsolute,!0),window.addEventListener("deviceorientation",this._onOrientation,!0),this._onResize=()=>this._resize(),window.addEventListener("resize",this._onResize),this._onPageHide=()=>{this._stopCamera(),this.xrSession?.end(),this.net?.destroy()},window.addEventListener("pagehide",this._onPageHide),typeof ResizeObserver<"u"&&(this._ro=new ResizeObserver(()=>this._resize()),this._ro.observe(e.root)),this._wireTrayTabs()}_boot(){this._resize(),this._updateCount(),this._updateRoomButton(),this._startLoop(),nm().then(n=>{this.arMode=n;let r=this.ui.xrBtn;if(!r||n==="none")return;r.hidden=!1;let s=r.querySelector(".ars-ar-label");n==="webxr"?(s&&(s.textContent="Immersive AR"),r.setAttribute("aria-label","Enter immersive augmented reality and place models on real surfaces")):(s&&(s.textContent="Place in your space"),r.setAttribute("aria-label","Open this in your device AR viewer and place it in your real space"))}),!window.matchMedia?.("(pointer: coarse)").matches&&this.ui.qrBtn&&(this.ui.qrBtn.hidden=!1);let t=Fs(this.config.urlRoom||"");this._restoreScene({skipLocal:!!t}).then(()=>{t&&this._joinRoom(t),this.config.urlPrompt&&this.config.urlPrompt.length>=3&&this.ui.forgeInput&&(this.ui.forgeInput.value=this.config.urlPrompt,this._startForge(this.config.urlPrompt))})}_setStatus(e,{warn:t=!1,sticky:n=!1,actionLabel:r="",onAction:s=null}={}){let a=this.ui.status;if(a){if(clearTimeout(this._statusTimer),a.textContent="",!e){a.hidden=!0;return}a.hidden=!1,a.classList.toggle("is-warn",t),a.appendChild(re("span",{text:e})),r&&s&&a.appendChild(re("button",{type:"button",class:"ars-status-action",text:r,onclick:()=>{this._setStatus(null),s()}})),n||(this._statusTimer=setTimeout(()=>{a.hidden=!0},5200))}}_updateCount(){let e=this.placements.length,{count:t,clearBtn:n,empty:r,photoBtn:s}=this.ui;t&&(this.net&&this.net.status==="online"&&this._presence.count>1?(t.textContent=`${this._presence.count} here \xB7 ${e} ${e===1?"model":"models"}`,t.hidden=!1):(t.textContent=e===1?"1 model":`${e} models`,t.hidden=e===0)),n&&(n.hidden=e===0),r&&(r.hidden=e>0),s&&(s.disabled=e===0)}_logicalScale(e){return e.spawnT<1?e.group.userData._targetScale??1:e.group.scale.x}_saveScene(){if(this.config.persist!==!1)try{localStorage.setItem(this.config.persistKey,Jh(this.placements.filter(e=>this._isMine(e)).map(e=>({src:e.src,title:e.title,x:e.group.position.x,z:e.group.position.z,yaw:e.yaw,scale:this._logicalScale(e)}))))}catch{}}_select(e){this.selected=e;let{selbar:t,selName:n}=this.ui;if(t){if(!e){t.hidden=!0,this.selRing.visible=!1,this._emit("select",{placement:null});return}t.hidden=!1,n&&(n.textContent=e.title||"Model"),this.selRing.visible=!this.xrSession,this._positionSelRing(),this._warmQuickLook(),this._emit("select",{placement:rg(e,this)})}}_positionSelRing(){let e=this.selected;if(!e)return;this.selRing.position.set(e.group.position.x,e.group.position.y+.006,e.group.position.z);let t=Math.max(.24,e.baseRadius*e.group.scale.x*1.15);this.selRing.scale.setScalar(t/.34)}_loadTemplate(e){let t=this._templates.get(e);return t||(t=this._loadQueue.request(e).then(n=>{let r=!1;n.scene.traverse(c=>{c.isSkinnedMesh&&(r=!0)});let s=new rn().setFromObject(n.scene),a=Ko({min:{x:s.min.x,y:s.min.y,z:s.min.z},max:{x:s.max.x,y:s.max.y,z:s.max.z}},{skinned:r}),o=Math.max((s.max.x-s.min.x)*a.scale,(s.max.z-s.min.z)*a.scale)/2,l=(s.max.y-s.min.y)*a.scale;return{gltf:n,skinned:r,fit:a,radius:Number.isFinite(o)?o:.3,height:Number.isFinite(l)?l:.75}}),this._templates.set(e,t),t.then(n=>this._templatesReady.set(e,n)).catch(()=>this._templates.delete(e))),t}_instantiate(e,t){let n=Cs(e.gltf.scene);n.scale.setScalar(e.fit.scale),n.position.y=e.fit.yOffset;let r=new pn;r.add(n);let s=null;e.gltf.animations?.length&&(s=new Ms(n),s.clipAction(e.gltf.animations[0]).play());let a=null;return!s&&e.skinned&&this.config.animations?.enabled!==!1&&(a=wp(n,{manifestUrl:this.config.animations?.manifestUrl,clip:this.config.animations?.clip,sourceUrl:t}).catch(()=>null)),{group:r,mixer:s,idlePromise:a}}_makeShadow(e){if(!this.shadowTex)return null;let t=Math.max(.4,e*2.4),n=new xt(new mi(t,t).rotateX(-Math.PI/2),new gn({map:this.shadowTex,transparent:!0,opacity:.85,depthWrite:!1}));return n.renderOrder=1,n}_nudgeSpawn(e){let{x:t,z:n}=e;for(let r=0;r<8&&this.placements.some(o=>Math.hypot(o.group.position.x-t,o.group.position.z-n)<.45);r++){let a=r*2.399963;t=e.x+Math.cos(a)*.55*(1+r*.18),n=e.z+Math.sin(a)*.55*(1+r*.18)}return{x:t,z:n}}async _addModel({src:e,title:t="",poster:n=""}={},{x:r=null,z:s=null,yaw:a=null,scale:o=null,announce:l=!0,persist:c=!0,remote:h=!1,netId:d=null,ownerId:f=null}={}){let p=Jr(e);if(!p)return this._setStatus("That link is not a loadable https GLB.",{warn:!0}),null;if(this.placements.length>=this._maxPlacements)return this._setStatus(`Scene is full (${this._maxPlacements} models). Remove one to add more.`,{warn:!0}),null;l&&this._setStatus(`Loading ${t||"model"}\u2026`,{sticky:!0});let x;try{x=await this._loadTemplate(p)}catch(U){return hi.warn("model load failed",p,U),this._setStatus(`Couldn't load ${t||"that model"}: the file may be gone or blocked by CORS.`,{warn:!0,actionLabel:"Retry",onAction:()=>this._addModel({src:p,title:t})}),null}let{group:y,mixer:b,idlePromise:g}=this._instantiate(x,p),S=r,A=s;if(S===null||A===null){let U=Math.max(1.6,(x.height||0)*1.15),v=this.camera.getWorldDirection(new W),I=this._nudgeSpawn(Cp(this.camera.position,v,U));S=I.x,A=I.z}y.position.set(S,0,A);let T=a??Math.atan2(this.camera.position.x-S,this.camera.position.z-A);y.rotation.y=T,o&&y.scale.setScalar(Math.min(4,Math.max(.25,o))),this.scene.add(y);let N=this._makeShadow(x.radius);N&&(N.position.set(S,.004,A),N.scale.setScalar(y.scale.x),N.visible=!this.xrSession,this.scene.add(N));let P={id:`p-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,7)}`,src:p,title:String(t||"").slice(0,160),poster:n,group:y,shadow:N,mixer:b,idle:null,yaw:T,baseRadius:x.radius,height:x.height||0,spawnT:this.reducedMotion?1:0,netId:d||null,ownerId:h?f:null,remote:h,_lastNetSend:0};if(g?.then(U=>{U&&(this.placements.includes(P)?P.idle=U:U.detach())}),y.userData._targetScale=y.scale.x,this.reducedMotion||y.scale.setScalar(.001),this.placements.push(P),P.netId&&this._netModels.set(P.netId,P),h||(this._armed={src:p,title:P.title}),this._updateCount(),h||this._select(P),c&&this._saveScene(),!h&&this.net&&this.net.status==="online"){let U=`m${Date.now().toString(36)}${Math.random().toString(36).slice(2,6)}`.slice(0,40);P.netId=U,P.ownerId=this.clientId,this._netModels.set(U,P),this.net.spawn(this._placementWire(P,U))}return l&&this._setStatus(h?`${t||"A model"} was added by someone in the room.`:"Placed. Drag to move, pinch to resize, twist to rotate."),h||this._framePreview(),this._emit("add",{placement:rg(P,this),remote:h}),P}_removePlacement(e,{persist:t=!0,broadcast:n=!0}={}){let r=this.placements.indexOf(e);r!==-1&&(this.placements.splice(r,1),e.netId&&(this._netModels.delete(e.netId),n&&this.net?.status==="online"&&this._isMine(e)&&this.net.remove(e.netId)),e.idle?.detach(),e.idle=null,this.xrSession?.release(e.group),this.scene.remove(e.group),e.shadow&&(this.scene.remove(e.shadow),e.shadow.geometry?.dispose(),e.shadow.material?.dispose()),this.selected===e&&this._select(this.placements[this.placements.length-1]??null),ou(this._arCacheKey(e)),this._arKeys.delete(this._arCacheKey(e)),this.ui.arModal&&!this.ui.arModal.hidden&&this._showArTarget(this._arTarget===e?this._arDefaultTarget():this._arTarget),this._updateCount(),t&&this._saveScene(),this._emit("remove",{src:e.src,title:e.title}))}_clearWithUndo(){if(!this.placements.length)return;let e=this.getScene();for(let t of[...this.placements])this._removePlacement(t,{persist:!1});this._saveScene(),this._emit("clear",{items:e}),this._setStatus("Scene cleared.",{actionLabel:"Undo",onAction:async()=>{for(let t of e)await this._addModel({src:t.src,title:t.title},{x:t.x,z:t.z,yaw:t.yaw,scale:t.scale,announce:!1})}})}_onSelbarClick(e){let t=e.target.closest("[data-act]"),n=this.selected;if(!t||!n)return;let r=t.dataset.act;if((r==="rotate"||r==="remove")&&!this._isMine(n)){this._setStatus("That model belongs to someone else in the room.",{warn:!0});return}r==="rotate"?(n.yaw+=Math.PI/4,n.group.rotation.y=n.yaw,n._lastNetSend=0,this._netBroadcastTransform(n),this._saveScene()):r==="duplicate"?this._addModel({src:n.src,title:n.title},{yaw:n.yaw,scale:this._logicalScale(n)}):r==="remove"&&(this._removePlacement(n),this._setStatus("Removed.",{actionLabel:"Undo",onAction:()=>this._addModel({src:n.src,title:n.title},{x:n.group.position.x,z:n.group.position.z,yaw:n.yaw,scale:this._logicalScale(n)})}))}async _restoreScene({skipLocal:e=!1}={}){let t=new URLSearchParams(String(location.hash||"").replace(/^#/,"")),n=e?[]:Pp(t.get("s")),r=n;if(!r.length&&!e&&this.config.persist!==!1)try{r=Zh(localStorage.getItem(this.config.persistKey))}catch{r=[]}for(let a of r)await this._addModel({src:a.src,title:a.title},{x:a.x,z:a.z,yaw:a.yaw,scale:a.scale,announce:!1,persist:!1});let s=new Set(this.placements.map(a=>a.src));for(let a of this.config.urlModels||[])s.has(a.src)||await this._addModel(a,{announce:!1});this.placements.length&&(this._select(this.placements[this.placements.length-1]),n.length?this._setStatus("Shared scene loaded, exactly as arranged. Clear to start fresh."):this._setStatus(this.config.urlModels?.length?"Models loaded: turn on the camera to see them in your space.":"Your scene is back.")),this._saveScene()}_applyCameraFov(){let e=this.mediaStream?.getVideoTracks?.()[0];if(e){let r=e.getSettings?.()??{};Number.isFinite(r.width)&&r.width>0&&(this.arTrackW=r.width),Number.isFinite(r.height)&&r.height>0&&(this.arTrackH=r.height)}if(!this.arActive||!(this.arTrackW>0)||!(this.arTrackH>0))return;let{width:t,height:n}=this._viewportSize();this.camera.fov=o_({trackWidth:this.arTrackW,trackHeight:this.arTrackH,viewWidth:t,viewHeight:n,diagFovDeg:72}),this.camera.updateProjectionMatrix()}_sampleCameraLight(){let e=this._lightProbe,t=this.ui.video;if(!this.arActive||!e?.ctx||!t?.videoWidth)return;let n;try{e.ctx.drawImage(t,0,0,16,16),n=e.ctx.getImageData(0,0,16,16).data}catch{return}let{intensity:r,tint:s}=Rp(n);this.hemi.intensity+=(r*ng-this.hemi.intensity)*.4,this.sun.intensity+=(r*ig-this.sun.intensity)*.4,this._roomTint.setRGB(s.r,s.g,s.b),this.hemi.color.lerp(this._roomTint,.4),this.sun.color.lerp(this._roomTint,.4)}_startLightMatching(){this._lightTimer||!this._lightProbe||(this._lightTimer=setInterval(()=>this._sampleCameraLight(),2e3),this._sampleCameraLight())}_stopLightMatching(){clearInterval(this._lightTimer),this._lightTimer=null,this.hemi.intensity=ng,this.sun.intensity=ig,this.hemi.color.setHex(16777215),this.sun.color.setHex(16777215)}async _startCamera(){if(!(this.arTransitioning||this.arActive||this.xrSession)){if(!navigator.mediaDevices?.getUserMedia){this._setStatus("This browser cannot open the camera: the 3D preview still works.",{warn:!0});return}this.arTransitioning=!0;try{this._setStatus("Starting camera\u2026",{sticky:!0});try{this.mediaStream=await navigator.mediaDevices.getUserMedia({video:{facingMode:{ideal:"environment"}},audio:!1})}catch(r){r?.name==="NotAllowedError"?this._setStatus("Camera permission is blocked. Allow it in your browser settings, then try again.",{warn:!0,sticky:!0,actionLabel:"Try again",onAction:()=>this._startCamera()}):this._setStatus(`The camera did not start (${r?.message??r}).`,{warn:!0,actionLabel:"Try again",onAction:()=>this._startCamera()});return}let{video:e,root:t,cameraBtn:n}=this.ui;e&&(e.srcObject=this.mediaStream),this.arActive=!0,t.classList.add("is-ar"),n?.classList.add("is-active"),n?.setAttribute("aria-pressed","true"),this.grid.visible=!1,this.scene.fog=null,this._userLooked=!0,e?.play?.().catch(()=>{}),this._applyCameraFov(),this._startLightMatching(),await this._startGyro(),this.arMode==="quicklook"||this.arMode==="sceneviewer"?this._setStatus("Camera on. This preview turns with your phone; to lock a model to your real floor, place it in AR.",{actionLabel:"Place in AR",onAction:()=>this._openArSheet()}):this._setStatus("Camera on: your models are in the room. Look around."),this._emit("camera",{active:!0})}finally{this.arTransitioning=!1}}}_stopCamera(){this.mediaStream&&(this.mediaStream.getTracks().forEach(s=>{try{s.stop()}catch{}}),this.mediaStream=null);let{video:e,root:t,cameraBtn:n}=this.ui;e&&(e.srcObject=null);let r=this.arActive;this.arActive=!1,this._stopLightMatching(),t?.classList.remove("is-ar"),n?.classList.remove("is-active"),n?.setAttribute("aria-pressed","false"),this.grid.visible=!this.xrSession,this.xrSession||(this.scene.fog=this._fog),this.camera.fov=58,this.camera.updateProjectionMatrix(),this.gyroBase=null,this._userLooked=!1,this.arTrackW=0,this.arTrackH=0,r&&this._emit("camera",{active:!1}),this._framePreview()}_yieldCameraToNativeAr(){this._cameraYielded||(this._cameraYielded=!0,this._cameraWasOn=this.arActive,this._stopCamera(),this._stopLoop(),this._onArReturn=()=>{typeof document<"u"&&document.visibilityState!=="visible"||this._reclaimCameraAfterNativeAr()},document.addEventListener("visibilitychange",this._onArReturn),window.addEventListener("focus",this._onArReturn))}_reclaimCameraAfterNativeAr(){this._cameraYielded&&(this._cameraYielded=!1,this._onArReturn&&(document.removeEventListener("visibilitychange",this._onArReturn),window.removeEventListener("focus",this._onArReturn),this._onArReturn=null),!(this._destroyed||this.xrSession)&&(this._startLoop(),!(this.arActive||!this._cameraWasOn)&&(this._cameraWasOn=!1,this._startCamera().catch(e=>hi.warn("camera did not come back after AR",e)))))}_screenAngle(){try{let e=screen.orientation?.angle;if(Number.isFinite(e))return e}catch{}return Number(window.orientation)||0}_onDeviceOrientation(e){if(l_(e.alpha,e.beta)&&(this._devAlpha=e.alpha,this._devBeta=e.beta,Number.isFinite(e.gamma)&&(this._devGamma=e.gamma)),!this.arActive||!this.gyroBase)return;let t=rm(this._devBeta,this._devGamma,this._screenAngle()),n=h_({useAbsolute:!1,prevYaw:this.cameraYaw,alpha:this._devAlpha,baseAlpha:this.gyroBase.alpha,baseYaw:this.gyroBase.yaw,compassHeading:null}),r=lu(this.gyroBase.pitch-(t-this.gyroBase.beta)*(Math.PI/180),eg,tg);Number.isFinite(n)&&(this.cameraYaw=n),Number.isFinite(r)&&(this.cameraPitch=r)}async _startGyro(){try{if(typeof DeviceOrientationEvent<"u"&&typeof DeviceOrientationEvent.requestPermission=="function"&&await DeviceOrientationEvent.requestPermission()!=="granted"){this._setStatus("Motion access is off: drag to look around instead.",{warn:!0});return}}catch{return}this.gyroBase={alpha:this._devAlpha,beta:rm(this._devBeta,this._devGamma,this._screenAngle()),yaw:this.cameraYaw,pitch:this.cameraPitch}}_viewportSize(){let e=this.ui.root.getBoundingClientRect();return{width:Math.max(1,Math.round(e.width||window.innerWidth)),height:Math.max(1,Math.round(e.height||window.innerHeight)),left:e.left,top:e.top}}_setNdc(e,t){let n=this._viewportSize();this._ndc.set((e-n.left)/n.width*2-1,-((t-n.top)/n.height)*2+1)}_placementAt(e,t){if(!this.placements.length)return null;this._setNdc(e,t),this._raycaster.setFromCamera(this._ndc,this.camera);let n=this._raycaster.intersectObjects(this.placements.map(s=>s.group),!0);if(!n.length)return null;let r=n[0].object;for(;r;){let s=this.placements.find(a=>a.group===r);if(s)return s;r=r.parent}return null}_floorPointAt(e,t){this._setNdc(e,t),this._raycaster.setFromCamera(this._ndc,this.camera);let n=this._raycaster.intersectObject(this.rayPlane);return n.length?n[0].point:null}_onPointerDown(e){this.xrSession||this._pinch.active||performance.now()-this._pinchEndedAt<350||(this._pointer={x:e.clientX,y:e.clientY,placement:this._placementAt(e.clientX,e.clientY),lookYaw:this.cameraYaw,lookPitch:this.cameraPitch,moved:!1})}_onPointerMove(e){let t=this._pointer;if(!t||this.xrSession||this._pinch.active)return;let n=e.clientX-t.x,r=e.clientY-t.y;if(Math.hypot(n,r)>6&&(t.moved=!0),!!t.moved)if(t.placement&&this._isMine(t.placement)){let s=this._floorPointAt(e.clientX,e.clientY);if(!s)return;let a=t.placement;a.group.position.x=s.x,a.group.position.z=s.z,a.shadow?.position.set(s.x,.004,s.z),this.selected===a&&this._positionSelRing(),this._netBroadcastTransform(a)}else!t.placement&&!(this.arActive&&this.gyroBase)&&(this._userLooked=!0,this.cameraYaw=t.lookYaw+n*.0042,this.cameraPitch=lu(t.lookPitch+r*.0032,eg,tg))}_onPointerUp(e){let t=this._pointer;if(!t||this.xrSession)return;!t.moved&&Math.hypot(e.clientX-t.x,e.clientY-t.y)<=8&&!this._pinch.active&&performance.now()-this._pinchEndedAt>=350?this._select(t.placement):t.placement&&t.moved&&this._isMine(t.placement)&&(t.placement._lastNetSend=0,this._netBroadcastTransform(t.placement),this._saveScene(),this._setStatus(null)),this._pointer=null}_gestureTarget(){let e=this.selected??this.placements[this.placements.length-1]??null;return e&&this._isMine(e)?e:null}_onTouchStart(e){if(this.xrSession||e.touches.length!==2)return;let t=this._gestureTarget();t&&(this._pointer=null,Nh(this._pinch,Ia(e.touches),t.group.scale.x),this._twist={startAngle:Yh(e.touches),baseYaw:t.yaw,placement:t})}_onTouchMove(e){if(this.xrSession||e.touches.length!==2)return;let t=this._twist?.placement;if(!t)return;let n=Oh(this._pinch,Ia(e.touches));n!=null&&(t.group.scale.setScalar(n),t.group.userData._targetScale=n,t.shadow?.scale.setScalar(n),this.selected===t&&this._positionSelRing()),t.yaw=this._twist.baseYaw+Ip(this._twist.startAngle,Yh(e.touches)),t.group.rotation.y=t.yaw,this._netBroadcastTransform(t)}_onTouchEnd(){this._warmQuickLook();let e=Fh(this._pinch),t=this._twist?.placement;e!=null&&(this._pinchEndedAt=performance.now(),this._saveScene()),t&&(t._lastNetSend=0,this._netBroadcastTransform(t)),this._twist=null}_onKeyDown(e){if(this._destroyed||!this.ui.root.isConnected)return;if(e.target.closest?.("input, textarea, select")){e.key==="Escape"&&e.target.blur();return}if(e.key==="Escape"){this.ui.tray.hidden?this.ui.roomModal.hidden?this.ui.arModal.hidden?this.ui.qrModal.hidden?this._select(null):this._closeQr():this._closeArSheet():this._closeRoomModal():this._closeTray();return}if(!this.ui.tray.hidden||!this.ui.qrModal.hidden||!this.ui.arModal.hidden||!this.ui.roomModal.hidden||this.xrSession)return;let t=this.selected;if(!t)return;let n=this._isMine(t);if(e.key.startsWith("Arrow")){if(!n)return;e.preventDefault();let r=e.shiftKey?.02:.1,s=this.camera.getWorldDirection(new W);s.y=0,s.lengthSq()<1e-6&&s.set(0,0,-1),s.normalize();let a=new W(-s.z,0,s.x),o=e.key==="ArrowUp"?s:e.key==="ArrowDown"?s.negate():e.key==="ArrowLeft"?a.negate():a;t.group.position.addScaledVector(o,r),t.shadow?.position.set(t.group.position.x,.004,t.group.position.z),this._positionSelRing(),this._netBroadcastTransform(t),this._saveScene()}else if(e.key==="r"||e.key==="R"){if(!n)return;t.yaw+=Math.PI/4,t.group.rotation.y=t.yaw,t._lastNetSend=0,this._netBroadcastTransform(t),this._saveScene()}else if(e.key==="d"||e.key==="D")e.preventDefault(),this._addModel({src:t.src,title:t.title},{yaw:t.yaw,scale:this._logicalScale(t)});else if(e.key==="Delete"||e.key==="Backspace"){if(!n)return;e.preventDefault(),this._removePlacement(t),this._setStatus("Removed.",{actionLabel:"Undo",onAction:()=>this._addModel({src:t.src,title:t.title},{x:t.group.position.x,z:t.group.position.z,yaw:t.yaw,scale:this._logicalScale(t)})})}}_wireTrayTabs(){let e=this.ui.trayTabs;if(e){for(let[t,n]of this.sources.entries()){let r=re("button",{type:"button",class:"ars-tab",role:"tab",id:`ars-tab-${t}-${n.id}`,"aria-selected":String(t===0),tabindex:t===0?"0":"-1","data-tab":n.id,text:n.label||n.id});r.addEventListener("click",()=>this._setTrayTab(n.id)),e.appendChild(r)}e.addEventListener("keydown",t=>{let n=[...e.querySelectorAll(".ars-tab")],r=n.indexOf(document.activeElement);if(r===-1)return;let s=n.length-1,a=t.key==="ArrowRight"?r===s?0:r+1:t.key==="ArrowLeft"?r===0?s:r-1:t.key==="Home"?0:t.key==="End"?s:-1;a!==-1&&(t.preventDefault(),this._setTrayTab(n[a].dataset.tab),n[a].focus())})}}_openTray(e=this._trayTab){let{tray:t,addBtn:n,trayClose:r}=this.ui;t&&(this._lastFocus=document.activeElement,t.hidden=!1,n?.setAttribute("aria-expanded","true"),this._setTrayTab(e),r?.focus?.())}_closeTray(){let{tray:e,addBtn:t}=this.ui;if(!e||e.hidden)return;let n=e.contains(document.activeElement);e.hidden=!0,t?.setAttribute("aria-expanded","false"),n&&this._restoreFocus(t)}_restoreFocus(e){(this._lastFocus&&document.contains(this._lastFocus)&&!this._lastFocus.hidden?this._lastFocus:e)?.focus?.(),this._lastFocus=null}_setTrayTab(e){this._trayTab=e;let t=[...this.ui.trayTabs?.querySelectorAll(".ars-tab")||[]];for(let n of t){let r=n.dataset.tab===e;n.classList.toggle("is-active",r),n.setAttribute("aria-selected",String(r)),n.tabIndex=r?0:-1,r&&(this.ui.trayBody?.setAttribute("aria-labelledby",n.id),n.scrollIntoView?.({block:"nearest",inline:"nearest"}))}this._renderTray()}async _renderTray(){let e=this.ui.trayBody;if(!e)return;let t=this._trayTab,n=this.sources.find(s=>s.id===t);if(!n)return;if(n.kind==="link"||n.id==="link"){this._renderLinkTab(e);return}e.textContent="",e.appendChild(re("div",{class:"ars-tray-loading"},[re("span",{class:"ars-spinner","aria-hidden":"true"}),"Loading models\u2026"]));let r;try{!n.live&&this._trayCache.has(t)?r=this._trayCache.get(t):(r=await n.list(),n.live||this._trayCache.set(t,r))}catch(s){if(hi.warn("source failed",t,s),this._trayTab!==t)return;e.textContent="",e.appendChild(re("div",{class:"ars-tray-empty"},[re("p",{text:`Couldn't load ${n.label||"these models"} right now.`}),re("button",{type:"button",class:"ars-btn",text:"Retry",onclick:()=>{this._trayCache.delete(t),this._renderTray()}})]));return}if(this._trayTab===t){if(!r.length){e.textContent="",e.appendChild(re("div",{class:"ars-tray-empty"},[re("p",{text:n.emptyCopy||"Nothing here yet."}),this.forge?re("button",{type:"button",class:"ars-btn ars-btn-primary",text:"Generate a model",onclick:()=>{this._closeTray(),this.ui.forgeInput?.focus()}}):null]));return}this._renderList(e,n,r)}}_renderList(e,t,n){e.textContent="";let r=t.searchable??n.length>24,s=Du,a=null;r&&(a=re("input",{class:"ars-search",type:"search",autocomplete:"off",placeholder:`Search ${n.length} models\u2026`,"aria-label":`Search ${t.label||"models"}`}),e.appendChild(a)),t.hint&&e.appendChild(re("p",{class:"ars-hint",text:t.hint}));let o=re("ul",{class:"ars-item-list"}),l=re("div",{class:"ars-more"});e.appendChild(o),e.appendChild(l);let c=()=>{let h=(a?.value||"").trim().toLowerCase(),d=h?n.filter(f=>(f.keywords||f.title||"").toLowerCase().includes(h)):n;o.textContent="";for(let f of d.slice(0,s))o.appendChild(this._trayItem(f));if(l.textContent="",d.length>s){let f=d.length-s;l.appendChild(re("button",{type:"button",class:"ars-btn",text:`Show ${Math.min(Du,f)} more (${f} left)`,onclick:()=>{s+=Du,c()}}))}else d.length||l.appendChild(re("p",{class:"ars-hint",text:"Nothing matches that search."}))};a?.addEventListener("input",()=>{s=Du,c()}),c()}_trayItem(e){let t=e.title||"Model",n=re("span",{class:"ars-item-thumb"});if(e.poster){let s=re("img",{src:e.poster,alt:"",loading:"lazy",decoding:"async"});s.addEventListener("error",()=>{n.textContent="",n.appendChild(re("span",{class:"ars-item-cube","aria-hidden":"true",text:"\u25C6"}))},{once:!0}),n.appendChild(s)}else n.appendChild(re("span",{class:"ars-item-cube","aria-hidden":"true",text:"\u25C6"}));let r=re("button",{type:"button",class:"ars-item-add",title:e.title||"","aria-label":`Add ${t} to your space`,onclick:()=>{this._closeTray(),this._addModel({src:e.src,title:t,poster:e.poster})}},[n,re("span",{class:"ars-item-title",text:t}),re("span",{class:"ars-item-cta",text:"Add"})]);return re("li",{class:"ars-item"},[r])}_renderLinkTab(e){e.textContent="";let t=re("input",{class:"ars-search",type:"url",inputmode:"url",required:!0,placeholder:"https://example.com/model.glb","aria-label":"GLB model URL"}),n=re("form",{},[re("label",{class:"ars-hint",for:"",text:"Paste a link to any .glb model"}),re("div",{class:"ars-link-row"},[t,re("button",{type:"submit",class:"ars-btn ars-btn-primary",text:"Add"})]),re("p",{class:"ars-hint",text:"Any https .glb works, as long as the host allows cross-origin requests."})]);n.addEventListener("submit",r=>{r.preventDefault();let s=Jr(t.value);if(!s){this._setStatus("That link is not a loadable https GLB.",{warn:!0}),t.focus();return}this._closeTray(),this._addModel({src:s,title:kC(s)})}),e.appendChild(n)}_forgeChip(e,t="",n=null){let r=this.ui.chip;if(!r)return;r.dataset.state=e,r.hidden=e==="idle";let s=r.querySelector(".ars-chip-label"),a=r.querySelector(".ars-chip-elapsed");s&&(s.textContent=t),a&&(a.textContent=n==null?"":`${Math.round(n)}s`)}async _startForge(e){let t=String(e||"").trim();if(!this.forge||t.length<3||this._forgeBusy)return null;this._forgeBusy=!0;let n=++this._forgeSeq;this.ui.forgeGo&&(this.ui.forgeGo.disabled=!0);let r=Date.now();this._forgeChip("working","Sending your prompt\u2026",0);let s=setInterval(()=>{if(this.ui.chip?.dataset.state==="working"){let a=this.ui.chip.querySelector(".ars-chip-label")?.textContent||"";this._forgeChip("working",a,(Date.now()-r)/1e3)}},1e3);try{let a=await this.forge.generate(t,{onProgress:o=>{n===this._forgeSeq&&this._forgeChip("working",o.message,o.elapsedMs/1e3)}});return n!==this._forgeSeq?null:(Rf({src:a.src,title:a.prompt,poster:a.poster},this._recentKey),this._trayCache.delete("recent"),this._forgeChip("idle"),this.ui.forgeInput&&(this.ui.forgeInput.value=""),await this._addModel({src:a.src,title:a.title,poster:a.poster},{announce:!1}),this._setStatus("Generated and placed. Pinch to resize, drag to move."),this._emit("generate",{model:a}),a)}catch(a){return n===this._forgeSeq&&(this._forgeChip("error",a?.message||"Generation failed."),setTimeout(()=>{this.ui.chip?.dataset.state==="error"&&this._forgeChip("idle")},6500)),this._emit("generate-error",{error:a,prompt:t}),null}finally{clearInterval(s),n===this._forgeSeq&&(this._forgeBusy=!1,this.ui.forgeGo&&(this.ui.forgeGo.disabled=!1))}}_enterAR(){return this.arMode==="webxr"?this._toggleXR():(this._openArSheet(),Promise.resolve())}_arCacheKey(e){return`${e.src}|${e.group.scale.x.toFixed(3)}`}async _targetUsdz(e){let{objectToUsdzBlob:t,glbUrlToUsdzBlob:n}=await Promise.resolve().then(()=>(su(),Qp));try{return await t(e.group)}catch(r){return hi.warn("live-scene USDZ export failed, refetching the source",r),n(e.src)}}_renderArPreview(e,t=384){if(this.xrSession)return null;let n=null;try{let r=Cs(e.group);r.position.set(0,0,0),r.rotation.set(0,0,0),r.updateMatrixWorld(!0);let s=new rn().setFromObject(r);if(s.isEmpty())return null;let a=s.getCenter(new W),o=Math.max(s.getSize(new W).length()/2,.01),l=new Or;l.add(r),l.add(new ma(16777215,3816008,3.4));let c=new Di(16777215,3.6);c.position.set(1.4,2.2,1.8);let h=new Di(14673151,1.5);h.position.set(-1.6,.9,-1.2),l.add(c,h);let d=32,f=new an(d,1,o/100,o*100),p=o/Math.sin(d*Math.PI/360)*1.06;f.position.set(a.x+p*.62,a.y+p*.42,a.z+p*.66),f.lookAt(a),n=new Hn(t,t,{depthBuffer:!0});let x=this.renderer.getRenderTarget();this.renderer.setRenderTarget(n),this.renderer.clear(),this.renderer.render(l,f);let y=new Uint8Array(t*t*4);this.renderer.readRenderTargetPixels(n,0,0,t,t,y),this.renderer.setRenderTarget(x);let b=document.createElement("canvas");b.width=t,b.height=t;let g=b.getContext("2d"),S=g.createImageData(t,t),A=t*4;for(let T=0;T<t;T++)S.data.set(y.subarray((t-1-T)*A,(t-T)*A),T*A);return g.putImageData(S,0,0),b.toDataURL("image/png")}catch(r){return hi.warn("AR preview render failed",r),null}finally{n?.dispose()}}_arDefaultTarget(){return this.selected||this.placements[this.placements.length-1]||null}_warmQuickLook(){this._destroyed||this.arMode!=="quicklook"||(clearTimeout(this._arWarmTimer),this._arWarmTimer=setTimeout(()=>{if(this._destroyed)return;let e=this._arDefaultTarget();if(!e)return;let t=this._arCacheKey(e);cu(t)||(this._arKeys.add(t),ec({src:e.src,title:e.title,key:t,build:()=>this._targetUsdz(e)}).catch(n=>{hi.warn("AR warm-up failed",n)}))},900))}_openArSheet(e){let t=this.ui;t.arModal&&(this._lastFocus=document.activeElement,t.arModal.hidden=!1,this._showArTarget(e||this._arDefaultTarget()),(t.arGo.hidden||t.arGo.disabled?t.arClose:t.arGo)?.focus?.(),this._emit("ar-sheet",{open:!0}))}_closeArSheet(){let{arModal:e,xrBtn:t}=this.ui;if(!e||e.hidden)return;let n=e.contains(document.activeElement);e.hidden=!0,this._arToken++,n&&this._restoreFocus(t),this._emit("ar-sheet",{open:!1})}_setArStatus(e,{state:t=""}={}){let n=this.ui.arStatus;n&&(n.textContent="",n.classList.toggle("is-error",t==="error"),n.classList.toggle("is-ready",t==="ready"),e&&(t==="busy"&&n.appendChild(re("span",{class:"ars-spinner","aria-hidden":"true"})),n.appendChild(re("span",{text:e}))))}_showArTarget(e){let t=this.ui;if(!t.arModal||t.arModal.hidden)return;this._arToken++,this._arHandoff=null,this._arTarget=e||null;let n=t.arGo.querySelector(".ars-ar-go-label");if(this._arRetry=null,t.arXr.hidden=this.arMode!=="webxr",t.arQr.hidden=!0,t.arPicker.hidden=!0,t.arPicker.textContent="",!e){t.arThumb.textContent="\u{1FA84}",t.arName.textContent="Nothing to place yet",t.arHint.textContent="Add a model to the scene and it can stand on your real floor at its real size.",this._setArStatus(null),t.arGo.hidden=!1,t.arGo.disabled=!1,t.arGo.removeAttribute("aria-busy"),n&&(n.textContent="Browse models"),t.arGo.querySelector(".ars-ar-go-icon").hidden=!0;return}t.arThumb.textContent="\u25C6";let r=this._renderArPreview(e)||e.poster;if(r){let s=re("img",{src:r,alt:""});s.addEventListener("error",()=>{t.arThumb.textContent="\u25C6"},{once:!0}),t.arThumb.textContent="",t.arThumb.appendChild(s)}if(t.arName.textContent=e.title||"Model",this.placements.length>1){t.arPicker.hidden=!1;for(let s of this.placements)t.arPicker.appendChild(re("button",{type:"button",class:"ars-ar-chip","data-ar-id":s.id,"aria-pressed":s===e?"true":"false",text:s.title||"Model"}))}if(this.arMode==="none"){t.arHint.textContent="AR needs a phone. Open this scene on your iPhone or Android and the model stands on your real floor.",this._setArStatus(null),t.arGo.hidden=!0,t.arQr.hidden=!1;return}t.arHint.textContent="Point your device at a flat surface, then drag to place it. It arrives at real size.",t.arGo.hidden=!1,t.arGo.querySelector(".ars-ar-go-icon").hidden=!1,n&&(n.textContent="Place in your space"),this._prepareArTarget(e)}async _prepareArTarget(e){let t=this.ui,n=this._arToken,r=this._arCacheKey(e),s=this.arMode!=="quicklook"||cu(r);s||(t.arGo.disabled=!0,t.arGo.setAttribute("aria-busy","true"),this._setArStatus("Preparing it for AR\u2026",{state:"busy"})),this._arKeys.add(r);try{let a=await ec({src:e.src,title:e.title,key:r,build:()=>this._targetUsdz(e)},{fallbackUrl:this.config.shareBaseUrl});if(n!==this._arToken||this._destroyed)return;this._arHandoff=a,t.arGo.disabled=!1,t.arGo.removeAttribute("aria-busy"),this._setArStatus(s?null:"Ready.",{state:"ready"});let o=document.activeElement===document.body||document.activeElement===t.arModal;!s&&o&&t.arGo.focus?.()}catch(a){if(n!==this._arToken||this._destroyed)return;hi.warn("AR preparation failed",a),t.arGo.disabled=!0,t.arGo.removeAttribute("aria-busy"),this._setArStatus(`Could not prepare this model for AR (${a?.message||a}).`,{state:"error"}),this._arRetry=e,t.arGo.disabled=!1,t.arGo.querySelector(".ars-ar-go-label").textContent="Try again",t.arGo.querySelector(".ars-ar-go-icon").hidden=!0,this._emit("native-ar-error",{error:a,src:e.src})}}_onArGo(){if(!this._arTarget){this._closeArSheet(),this._openTray();return}if(this._arRetry){this._showArTarget(this._arRetry);return}let e=this._arHandoff;if(!e)return;let{src:t,title:n}=this._arTarget;this._yieldCameraToNativeAr();try{e.open()}catch(r){hi.warn("native AR failed to open",r),this._setArStatus(`Could not open AR (${r?.message||r}).`,{state:"error"}),this._emit("native-ar-error",{error:r,src:t});return}this._emit("native-ar",{src:t,title:n,viewer:e.viewer}),this._closeArSheet(),this._setStatus("Point at the floor, then drag to place it.")}async _placeNative(e){let t=e||this.selected||this.placements[this.placements.length-1];if(!t)return this._setStatus("Add a model first, then place it in your space.",{warn:!0}),null;if(this._nativeArBusy)return null;this._nativeArBusy=!0;let n=this.ui.xrBtn;n?.setAttribute("aria-busy","true"),this._arKeys.add(this._arCacheKey(t));let r={download:"Fetching the model\u2026",parse:"Reading the model\u2026",convert:"Preparing it for AR\u2026",open:"Opening AR\u2026"};this._setStatus(r.download,{sticky:!0}),(this.arMode==="quicklook"||this.arMode==="sceneviewer")&&this._yieldCameraToNativeAr();try{let s=await im({src:t.src,title:t.title,key:this._arCacheKey(t),build:()=>this._targetUsdz(t)},{onProgress:a=>this._setStatus(r[a]||"Preparing AR\u2026",{sticky:!0}),fallbackUrl:this.config.shareBaseUrl});return s==="none"?this._setStatus("This device has no AR viewer. Open this scene on a phone instead.",{warn:!0,actionLabel:"Show QR",onAction:()=>this._openQr()}):this._setStatus("Point at the floor, then drag to place it."),this._emit("native-ar",{src:t.src,title:t.title,viewer:s}),s}catch(s){return hi.warn("native AR failed",s),this._setStatus(`Could not open AR for this model (${s?.message||s}).`,{warn:!0,actionLabel:"Try again",onAction:()=>this._placeNative(t)}),this._emit("native-ar-error",{error:s,src:t.src}),null}finally{this._nativeArBusy=!1,n?.removeAttribute("aria-busy")}}async _toggleXR(){if(this.xrSession){this.xrSession.end();return}if(!this.arTransitioning){this.arTransitioning=!0;try{this.arActive&&this._stopCamera();let e=new Uh({renderer:this.renderer,scene:this.scene,camera:this.camera,domOverlayRoot:this.ui.hud,getArmedContent:()=>this._armedContent(),onPlaced:t=>{let n=this.placements.find(r=>r.group===t);n&&(n.yaw=0,this._select(null)),this._saveScene(),this._setStatus(`Placed ${this.xrSession?.placedCount??""}: tap another spot to add one more.`)},getScaleTarget:()=>this.placements[this.placements.length-1]?.group??null,onScale:(t,{final:n})=>{n&&this._saveScene()},onHit:t=>this.ui.root.classList.toggle("xr-has-floor",t),onTracking:t=>{t?this._setStatus(null):this._setStatus("Tracking lost: move to a brighter spot with more texture.",{warn:!0,sticky:!0})},onFrame:t=>{for(let n of this.placements)n.mixer?.update(t),n.idle?.update(t)},onEnd:()=>this._onXREnd()});this._stopLoop(),await e.start(),this.xrSession=e,this.estimatedLight=new Dh({renderer:this.renderer,scene:this.scene,baseLights:[this.hemi,this.sun],onChange:t=>{t&&this._setStatus("Lit by your room: reflections and shadows match the real light.")}}),this.estimatedLight.start(),this.ui.root.classList.add("is-xr"),this.grid.visible=!1,this.scene.fog=null,this.selRing.visible=!1;for(let t of this.placements)t.shadow&&(t.shadow.visible=!1);this.ui.xrBtn?.classList.add("is-active"),this.ui.xrBtn?.setAttribute("aria-pressed","true"),this._setStatus("Point at the floor, then tap to place. Every tap adds another model."),this._emit("xr",{active:!0})}catch(e){hi.warn("XR session failed",e),this.estimatedLight?.dispose(),this.estimatedLight=null,this._startLoop(),this._setStatus("Could not start immersive AR on this device. Camera mode still works.",{warn:!0})}finally{this.arTransitioning=!1}}}_armedContent(){let e=this._armed?.src??this.placements[this.placements.length-1]?.src;if(!e)return this._setStatus("Pick a model first: Add or generate one, then tap the floor.",{warn:!0}),null;let t=this._templatesReady.get(e);if(!t)return this._loadTemplate(e),this._setStatus("Model is still loading: one moment, then tap again.",{sticky:!0}),null;let{group:n,mixer:r,idlePromise:s}=this._instantiate(t,e),a={id:`p-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,7)}`,src:e,title:this._armed?.title||"",poster:"",group:n,shadow:null,mixer:r,idle:null,yaw:0,baseRadius:t.radius,height:t.height||0,spawnT:1,netId:null,ownerId:null,remote:!1,_lastNetSend:0};return s?.then(o=>{o&&(this.placements.includes(a)?a.idle=o:o.detach())}),this.placements.push(a),this._updateCount(),this._emit("add",{placement:rg(a,this),remote:!1}),n}_onXREnd(){this.xrSession=null,this.estimatedLight?.dispose(),this.estimatedLight=null,this.ui.root.classList.remove("is-xr","xr-has-floor"),this.ui.xrBtn?.classList.remove("is-active"),this.ui.xrBtn?.setAttribute("aria-pressed","false");for(let e of this.placements)e.group.position.y=0,e.shadow&&(e.shadow.visible=!0,e.shadow.position.set(e.group.position.x,.004,e.group.position.z));this.grid.visible=!this.arActive,this.arActive||(this.scene.fog=this._fog),this._saveScene(),this._startLoop(),this._setStatus("Back to the studio view."),this._emit("xr",{active:!1})}async _capturePhoto(){this.renderer.render(this.scene,this.camera);let e=await Mp({canvas:this.ui.canvas,video:this.ui.video,isAR:this.arActive});if(!e){this._setStatus("Could not capture the frame.",{warn:!0});return}try{let t=await Ap(e,{filename:"ar-studio.png",title:this.config.branding?.title||"AR Studio"});this._setStatus(t==="shared"?"Shared.":"Saved to your downloads.")}catch(t){t?.name!=="AbortError"&&this._setStatus("Could not share that photo.",{warn:!0})}}_openQr(){let{qrModal:e,qrBox:t,qrLink:n}=this.ui;if(!e)return;this._lastFocus=document.activeElement;let r=this.shareUrl();if(t)try{t.innerHTML=Vo(r,{scale:6,margin:2,dark:"#0b0b0b",light:"#ffffff"})}catch{try{t.innerHTML=Vo(Qh(this.config.shareBaseUrl,this.getScene()),{scale:6,margin:2,dark:"#0b0b0b",light:"#ffffff"})}catch{t.textContent=r}}n&&(n.href=r,n.textContent=r.length>72?`${r.slice(0,69)}\u2026`:r),e.hidden=!1,this.ui.qrClose?.focus?.(),this._emit("share",{url:r})}_closeQr(){let{qrModal:e,qrBtn:t}=this.ui;if(!e||e.hidden)return;let n=e.contains(document.activeElement);e.hidden=!0,n&&this._restoreFocus(t)}_isMine(e){return!e.ownerId||e.ownerId===this.clientId}_placementShared(e){return om({x:e.group.position.x,z:e.group.position.z,yaw:e.yaw,scale:this._logicalScale(e),height:e.height||0})}_placementWire(e,t){return{id:t,src:e.src,title:e.title,...this._placementShared(e)}}_netBroadcastTransform(e){if(!this.net||this.net.status!=="online"||!e.netId||!this._isMine(e))return;let t=Date.now();if(t-(e._lastNetSend||0)<80)return;e._lastNetSend=t;let n=this._placementShared(e);this.net.update(e.netId,{relEast:n.relEast,relNorth:n.relNorth,yawDeg:n.yawDeg,scale:n.scale})}_applySharedTransform(e,t){let n=uu(t);e.group.position.set(n.x,0,n.z),e.yaw=n.yaw,e.group.rotation.y=n.yaw,e.group.scale.setScalar(n.scale),e.group.userData._targetScale=n.scale,e.spawnT=1,e.shadow&&(e.shadow.position.set(n.x,.004,n.z),e.shadow.scale.setScalar(n.scale)),this.selected===e&&this._positionSelRing()}_reconcileRemoteModels(e){let t=new Set(e.map(r=>r.id));for(let r of[...this.placements])r.remote&&r.netId&&!t.has(r.netId)&&this._removePlacement(r,{persist:!1,broadcast:!1});let n=0;for(let r of e){let s=this._netModels.get(r.id);if(s){this._isMine(s)||this._applySharedTransform(s,r);continue}let a=uu(r),o=!!r.mine||r.ownerId===this.clientId;o||n++,this._addModel({src:r.src,title:r.title},{x:a.x,z:a.z,yaw:a.yaw,scale:a.scale,remote:!0,netId:r.id,ownerId:o?this.clientId:r.ownerId,announce:!1,persist:!1})}this._updateCount(),this._roomSynced&&n>0&&this._setStatus(n===1?"Someone added a model to the room.":`${n} models were added to the room.`),this._roomSynced=!0}_applyRemoteModelChange(e){let t=this._netModels.get(e.id);if(t){if(e.removed){t.remote&&this._removePlacement(t,{persist:!1,broadcast:!1});return}this._isMine(t)||this._applySharedTransform(t,e)}}_wireNet(e){e.on("status",({status:t})=>{t==="online"?(this._setStatus(`Shared room ${this.roomCode} is live: edits sync to everyone here.`),this.ui.root.classList.add("is-room")):t==="connecting"?this._setStatus(`Joining room ${this.roomCode}\u2026`,{sticky:!0}):t==="unavailable"||t==="failed"?(this._setStatus("Shared rooms are offline right now: you can still build solo.",{warn:!0}),this._leaveRoom({silent:!0})):t==="offline"&&this._setStatus("Reconnecting to the room\u2026",{sticky:!0}),this._updateRoomButton(),this._emit("room",{status:t,code:this.roomCode})}),e.on("models",t=>this._reconcileRemoteModels(t)),e.on("model",t=>this._applyRemoteModelChange(t)),e.on("presence",t=>{let n=this._presence.count;this._presence=t,this._updateCount(),this.ui.roomModal.hidden||this._renderRoomModal(),n>0&&t.count>n?this._setStatus(t.count===2?"Someone joined: you're building together now.":"Someone else joined the room."):n>1&&t.count<n&&t.count>=1&&this._setStatus(t.count===1?"You're on your own in the room now.":"Someone left the room.")}),e.on("reject",t=>{let n=t?.reason==="room_full"?"the room is full":t?.reason==="owner_full"?"you have the maximum models in this room":"the room declined it";this._setStatus(`Couldn't share that model: ${n}.`,{warn:!0})})}_seedRoom(){if(!(!this.net||this.net.status!=="online"))for(let e of this.placements){if(e.netId)continue;let t=`m${Date.now().toString(36)}${Math.random().toString(36).slice(2,6)}`.slice(0,40);e.netId=t,e.ownerId=this.clientId,e.remote=!1,this._netModels.set(t,e),this.net.spawn(this._placementWire(e,t))}}async _joinRoom(e,{seed:t=!1}={}){let n=Fs(e);if(!n){this._setStatus("That room code looks off: check the 6 characters and try again.",{warn:!0});return}this._leaveRoom({silent:!0}),this._roomSynced=!1,this.roomCode=n;let r=new Lu({roomKey:lm(n),clientId:this.clientId,name:"",url:this.config.rooms?.server||""});if(this.net=r,this._wireNet(r),await r.connect(),this.net===r&&r.status==="online"){t&&this._seedRoom(),this._roomHeartbeat=setInterval(()=>this.net?.heartbeat(),15e3);try{let s=new URL(location.href);s.searchParams.set("room",n),history.replaceState(null,"",s)}catch{}}this._updateRoomButton()}_createRoom(){return this._joinRoom(cm(),{seed:!0})}_leaveRoom({silent:e=!1}={}){if(this._roomHeartbeat&&(clearInterval(this._roomHeartbeat),this._roomHeartbeat=null),this.net){try{this.net.destroy()}catch{}this.net=null}for(let t of[...this.placements])t.remote&&!this._isMine(t)?this._removePlacement(t,{persist:!1,broadcast:!1}):(t.netId=null,t.remote=!1);this._netModels.clear(),this.roomCode="",this._presence={count:1,names:[]},this.ui.root.classList.remove("is-room");try{let t=new URL(location.href);t.searchParams.delete("room"),history.replaceState(null,"",t)}catch{}this._updateCount(),this._updateRoomButton(),e||this._setStatus("Left the shared room. Your models are still here.")}_updateRoomButton(){let e=this.ui.roomBtn;if(!e)return;let t=!!this.net&&(this.net.status==="online"||this.net.status==="connecting");e.classList.toggle("is-active",t);let n=e.querySelector(".ars-room-label"),r=e.querySelector(".ars-room-code-label");n&&(n.hidden=t),r&&(r.hidden=!t,r.textContent=t?this.roomCode||"Room":""),this.ui.roomModal.hidden||this._renderRoomModal()}_renderRoomModal(){let e=!!this.net&&this.net.status==="online",{roomIdle:t,roomLive:n,roomCode:r,roomPresence:s,roomQr:a}=this.ui;if(t&&(t.hidden=e),n&&(n.hidden=!e),!!e&&(r&&(r.textContent=this.roomCode),s&&(s.textContent=this._presence.count>1?`${this._presence.count} people are building here.`:"You are the only one here yet: share the code to invite someone."),a)){let o=nc(this.config.shareBaseUrl,this.roomCode);try{a.innerHTML=Vo(o,{scale:5,margin:2,dark:"#0b0b0b",light:"#ffffff"})}catch{a.textContent=o}}}_openRoomModal(){let e=this.ui.roomModal;e&&(this._lastFocus=document.activeElement,e.hidden=!1,this._renderRoomModal(),(this.net?.status==="online"?this.ui.roomCopy:this.ui.roomCreate)?.focus?.())}_closeRoomModal(){let e=this.ui.roomModal;if(!e||e.hidden)return;let t=e.contains(document.activeElement);e.hidden=!0,t&&this._restoreFocus(this.ui.roomBtn)}async _createRoomFromUI(){if(await this._createRoom(),this._renderRoomModal(),this.net?.status==="online"&&navigator.clipboard?.writeText)try{await navigator.clipboard.writeText(nc(this.config.shareBaseUrl,this.roomCode)),this._setStatus(`Room ${this.roomCode} is live: invite link copied. Paste it to a friend.`)}catch{}}async _joinRoomFromUI(){let e=this.ui.roomJoinInput,t=Fs(e?.value);if(!t){this._setStatus("That room code looks off: check the 6 characters.",{warn:!0}),e?.focus?.();return}await this._joinRoom(t),this._renderRoomModal()}async _copyRoomInvite(){let e=nc(this.config.shareBaseUrl,this.roomCode),t=this.ui.roomCopy;try{let n=await Tp(e,{title:"Build with me in AR",text:`Join my AR Studio room: ${this.roomCode}`});if(t){let r=t.textContent;t.textContent=n==="shared"?"Shared \u2713":"Link copied \u2713",setTimeout(()=>{t.textContent=r},1600)}}catch(n){n?.name!=="AbortError"&&window.prompt("Copy this invite link:",e)}}_framePreview(){if(this.arActive||this.xrSession||this._userLooked||!this.placements.length)return;let e=0,t=0,n=0;for(let c of this.placements)e+=c.group.position.x,t+=c.group.position.z,n+=(c.height||.4)*(c.group.userData._targetScale??1);let r=this.placements.length,s=e/r,a=t/r,o=n/r*.5,l=Math.hypot(s-this.camera.position.x,a-this.camera.position.z);l>.05&&(this.cameraYaw=Math.atan2(s-this.camera.position.x,-(a-this.camera.position.z)),this.cameraPitch=lu(-Math.atan2(this.camera.position.y-o,l),eg,tg))}_applyCameraLook(){this.camera.rotation.set(0,0,0),this.camera.rotateY(this.cameraYaw),this.camera.rotateX(this.cameraPitch)}_tick(e){this._rafId=requestAnimationFrame(n=>this._tick(n));let t=this._prevT?Math.min(.1,(e-this._prevT)/1e3):.016;this._prevT=e;for(let n of this.placements)if(n.mixer?.update(t),n.idle?.update(t),n.spawnT<1){n.spawnT=Math.min(1,n.spawnT+t*3.2);let r=1-(1-n.spawnT)**3,s=n.group.userData._targetScale??1;n.group.scale.setScalar(Math.max(.001,s*r)),n.shadow?.scale.setScalar(Math.max(.001,s*r))}this.selected&&this._positionSelRing(),this._applyCameraLook(),this.renderer.render(this.scene,this.camera)}_startLoop(){this._rafId===null&&(this._prevT=0,this._rafId=requestAnimationFrame(e=>this._tick(e)))}_stopLoop(){this._rafId!==null&&(cancelAnimationFrame(this._rafId),this._rafId=null)}_resize(){let{width:e,height:t}=this._viewportSize();this.renderer.setSize(e,t,!1),this.camera.aspect=e/t,this.camera.updateProjectionMatrix(),this._applyCameraFov()}addModel(e,t){return this._addModel(e,t)}clear(){let e=this.getScene();for(let t of[...this.placements])this._removePlacement(t,{persist:!1});return this._saveScene(),this._emit("clear",{items:e}),e}getScene(){return this.placements.map(e=>({src:e.src,title:e.title,x:e.group.position.x,z:e.group.position.z,yaw:e.yaw,scale:this._logicalScale(e)}))}async setScene(e){this.clear();for(let t of Array.isArray(e)?e:[])await this._addModel({src:t.src,title:t.title},{x:t.x,z:t.z,yaw:t.yaw,scale:t.scale,announce:!1,persist:!1});this._saveScene()}shareUrl(){return Lp(this.config.shareBaseUrl,this.getScene())}generate(e){return this._startForge(e)}viewInYourSpace(e,t=""){let n=Jr(e);if(!n)return"";let r=Ih(this.config.origin,n,t,{endpoint:this.config.arLaunchUrl});return window.open(r,"_blank","noopener"),r}startCamera(){return this._startCamera()}stopCamera(){this._stopCamera()}toggleImmersive(){return this._toggleXR()}enterAR(){return this._enterAR()}placeInYourSpace(e){return this._placeNative(e)}openArSheet(e){this._openArSheet(e)}closeArSheet(){this._closeArSheet()}async openRoom(e){return e?await this._joinRoom(e):await this._createRoom(),this.roomCode}leaveRoom(){this._leaveRoom()}destroy(){if(!this._destroyed){this._destroyed=!0,this._stopLoop(),this._stopCamera(),this.xrSession?.end(),this.net?.destroy(),this._roomHeartbeat&&clearInterval(this._roomHeartbeat),clearTimeout(this._statusTimer),clearTimeout(this._arWarmTimer);for(let e of this._arKeys)ou(e);this._arKeys.clear(),clearInterval(this._lightTimer),document.removeEventListener("keydown",this._onKeyDown),window.removeEventListener("deviceorientationabsolute",this._onOrientationAbsolute,!0),window.removeEventListener("deviceorientation",this._onOrientation,!0),window.removeEventListener("resize",this._onResize),window.removeEventListener("pagehide",this._onPageHide),this._onArReturn&&(document.removeEventListener("visibilitychange",this._onArReturn),window.removeEventListener("focus",this._onArReturn),this._onArReturn=null),this._ro?.disconnect();for(let e of[...this.placements])this._removePlacement(e,{persist:!1,broadcast:!1});this.shadowTex?.dispose(),this.selRing.geometry.dispose(),this.selRing.material.dispose(),this.renderer.dispose(),this.ui.root.remove(),this._listeners.clear()}}};function NC(){try{return!!window.matchMedia?.("(prefers-reduced-motion: reduce)").matches}catch{return!1}}function OC(){try{let e=document.createElement("canvas");e.width=128,e.height=128;let t=e.getContext("2d"),n=t.createRadialGradient(128/2,128/2,0,128/2,128/2,128/2);return n.addColorStop(0,"rgba(0,0,0,0.40)"),n.addColorStop(.55,"rgba(0,0,0,0.18)"),n.addColorStop(1,"rgba(0,0,0,0)"),t.fillStyle=n,t.fillRect(0,0,128,128),new Ss(e)}catch{return null}}function FC(){try{let i=document.createElement("canvas");return i.width=16,i.height=16,{cnv:i,ctx:i.getContext("2d",{willReadFrequently:!0})}}catch{return null}}function UC(i){let e=`${i||"ar-studio"}:client`;try{let t=localStorage.getItem(e);return t||(t=crypto?.randomUUID?.()||`c-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`,localStorage.setItem(e,t)),t}catch{return`c-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}}function kC(i){let t=(String(i).split("?")[0].split("/").pop()||"Model").replace(/\.(glb|gltf)$/i,"").replace(/[_-]+/g," ").trim();return t?t.charAt(0).toUpperCase()+t.slice(1):"Linked model"}function rg(i,e){return{id:i.id,src:i.src,title:i.title,x:i.group.position.x,z:i.group.position.z,yaw:i.yaw,scale:e._logicalScale(i),mine:e._isMine(i)}}su();eu();Vh();function xc(i=document.body,e={}){let t=typeof i=="string"?document.querySelector(i):i;if(!t)throw new Error(`ar-studio: no element matched ${JSON.stringify(i)}`);return new bc(t,e)}var gv=(i,e)=>i==null?e:i!=="false"&&i!=="0",Nu=class extends HTMLElement{static get observedAttributes(){return["assets","title","accent","back-href","generate","rooms","room-server","origin","share-base"]}connectedCallback(){this.studio||(this.style.display||(this.style.display="block"),!this.style.minHeight&&!this.hasAttribute("embedded")&&(this.style.minHeight="70vh"),this.studio=xc(this,this.options()))}disconnectedCallback(){this.studio?.destroy(),this.studio=null}options(){let e=n=>this.getAttribute(n),t=e("assets");return{...t?{assets:t.includes(",")?t.split(",").map(n=>n.trim()):t}:{},...e("origin")?{origin:e("origin")}:{},...e("share-base")?{shareBaseUrl:e("share-base")}:{},branding:{title:e("title")||"AR Studio",accent:e("accent")||void 0,backHref:e("back-href")||null},generate:{enabled:gv(e("generate"),!0)},rooms:{enabled:gv(e("rooms"),!0),...e("room-server")?{server:e("room-server")}:{}},fullscreen:!1}}};function sg(i="ar-studio"){typeof customElements>"u"||customElements.get(i)||customElements.define(i,Nu)}sg();function bv(){if(document.querySelector("ar-studio"))return;let i=document.querySelector("[data-ar-studio]");i?xc(i,BC(i)):document.documentElement.hasAttribute("data-ar-studio-auto")&&xc(document.body)}function BC(i){let e=i.getAttribute("data-assets");return e?{assets:e}:{}}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",bv,{once:!0}):bv();export{zE as AVATAR_TARGET_HEIGHT_M,bc as ArStudio,Nu as ArStudioElement,Ra as ArUrlError,lb as DEFAULTS,$b as DEFAULT_DRACO_PATH,Ch as DEFAULT_ORIGIN,tr as ForgeError,gb as GENERATE_TOOLS,Pf as LINK_SOURCE,Yp as MAX_AR_FOOTPRINT_M,Jp as MAX_AR_HEIGHT_M,Kh as MAX_PLACEMENTS,Ta as McpError,HE as PROP_TARGET_SIZE_M,Nf as QUALITY_TIERS,n_ as QUICK_LOOK_BANNER_TAPPED,VE as SCALE_MAX,GE as SCALE_MIN,Ep as SPAWN_DISTANCE_M,En as THREE_WS,Ff as applyCinematicDefaults,nm as arCapability,yb as assertArAssetUrl,Vp as bakeSkinnedMeshes,Ih as buildArLaunchUrl,Sb as buildSceneViewerUrl,wb as buildViewerUrl,a_ as cachedUsdzUrl,em as canUseQuickLook,tm as canUseSceneViewer,Mp as captureComposite,bb as catalogueItems,Cf as cdnUrl,mb as checkPromptSafety,Zp as clampToPlaceableSize,xR as clearQuickLookCache,Wp as coerceMaterialsToStandard,xc as createArStudio,Mf as createForgeClient,Ls as createLogger,yf as createMcpClient,sg as defineArStudio,Zh as deserializeScene,vb as detectArTarget,Of as detectQualityTier,qp as ensureNormals,xb as filenameTitle,Kp as fitToRoomScale,Ko as fitTransform,_f as generateQR,cm as generateRoomCode,wx as getIdleClipJson,Qx as glbUrlToUsdzBlob,Xp as groundOnFloor,t_ as isAndroid,e_ as isIOS,cu as isQuickLookReady,xT as isVerbose,pb as laneLabel,Uf as loadEnvironment,om as localToShared,ei as log,Wo as manifestSource,gf as mergeConfig,wp as mountIdle,am as normDeg,u_ as normRad,Ea as normalizeCatalogue,Jr as normalizeGlbUrl,Fs as normalizeRoomCode,Zx as objectToUsdzBlob,r_ as openQuickLook,s_ as openSceneViewer,im as placeInYourSpace,XT as planArLaunch,ec as prepareNativeAr,Sf as promptTitle,Ef as readRecents,Eh as recentSource,ou as releaseQuickLook,Rf as rememberRecent,RT as renderQRToCanvas,Vo as renderQRToSVG,bf as resolveConfig,Lf as resolveSources,lm as roomKeyForCode,Rp as roomLightFromPixels,nc as roomShareUrl,er as safeUrl,Pp as sceneFromHashParam,Mx as sceneToHashParam,ru as sceneToUsdzBlob,Jh as serializeScene,pE as setDracoPath,bT as setVerbose,Ap as shareOrDownload,Tp as shareUrlOrCopy,Gh as sharedGLTFLoader,uu as sharedToLocal,Cp as spawnPointInFront,vf as stageNarration,_b as staticSource,Lp as studioSceneUrl,Qh as studioShareUrl,If as threeWsCommunitySource,Rh as threeWsObjectsSource,Yh as touchAngle,Ip as twistDelta,Ah as unwrapToolResult,KT as updateGroundContactShadow,$p as usdzExportRoot,i_ as usdzFilename,wf as validatePrompt,yR as withQuickLookBanner};
+`}var Ax="ar-studio-styles";function t2(i=document){if(i.getElementById(Ax))return;let e=i.createElement("style");e.id=Ax,e.textContent=Ex(),i.head.appendChild(e)}function le(i,e={},t=[]){let n=document.createElement(i);for(let[s,r]of Object.entries(e))r==null||r===!1||(s==="class"?n.className=r:s==="text"?n.textContent=r:s==="html"?n.innerHTML=r:s==="hidden"?n.hidden=!!r:s.startsWith("on")&&typeof r=="function"?n.addEventListener(s.slice(2),r):n.setAttribute(s,r===!0?"":String(r)));for(let s of[].concat(t))s&&n.appendChild(typeof s=="string"?document.createTextNode(s):s);return n}function Tx(i,e){t2(i.ownerDocument||document);let t=e.branding||{},n=e.generate?.enabled!==!1,s=e.rooms?.enabled!==!1,r=le("video",{class:"ars-video",playsinline:!0,muted:!0,"aria-hidden":"true"}),a=le("canvas",{class:"ars-canvas"}),o=t.backHref?le("a",{class:"ars-back",href:t.backHref},[le("span",{"aria-hidden":"true",text:"\u2190"}),t.backLabel||"Back"]):null,c=le("span",{class:"ars-title",text:t.title||"AR Studio"}),l=le("span",{class:"ars-count",hidden:!0,role:"status","aria-live":"polite"}),h=s?le("button",{type:"button",class:"ars-icon-btn","aria-label":"Open a shared room so other people can build in this scene with you"},[le("span",{"aria-hidden":"true",text:"\u{1F465}"}),le("span",{class:"ars-room-label",text:"Share live"}),le("span",{class:"ars-room-code-label",hidden:!0})]):null,u=le("button",{type:"button",class:"ars-icon-btn",hidden:!0,"aria-label":"Show a QR code that opens this scene on your phone"},[le("span",{"aria-hidden":"true",text:"\u{1F4F1}"}),"Open on phone"]),d=le("button",{type:"button",class:"ars-icon-btn",hidden:!0,"aria-pressed":"false","aria-label":"View this in augmented reality"},[le("span",{"aria-hidden":"true",text:"\u2726"}),le("span",{class:"ars-ar-label",text:"AR"})]),p=le("button",{type:"button",class:"ars-icon-btn","aria-pressed":"false","aria-label":"Turn the camera on to see your models in the room"},[le("span",{"aria-hidden":"true",text:"\u{1F4F7}"}),"Camera"]),b=le("div",{class:"ars-top"},[o,c,l,le("span",{class:"ars-spacer"}),h,u,d,p]),v=le("div",{class:"ars-chip",hidden:!0,"data-state":"idle",role:"status","aria-live":"polite"},[le("span",{class:"ars-spinner","aria-hidden":"true"}),le("span",{class:"ars-chip-label"}),le("span",{class:"ars-chip-elapsed"})]),_=le("button",{type:"button",class:"ars-btn ars-btn-primary"},[le("span",{"aria-hidden":"true",text:"\u{1F4F7}"}),"Turn on the camera"]),g=le("button",{type:"button",class:"ars-btn",text:"Browse models"}),E=n?le("button",{type:"button",class:"ars-btn",text:"Generate one"}):null,L=le("div",{class:"ars-empty"},[le("div",{class:"ars-empty-card"},[le("div",{class:"ars-empty-art","aria-hidden":"true",text:"\u{1FA84}"}),le("h2",{text:"Put anything in your room"}),le("p",{text:n?"Add a model, or describe one and watch it appear. Turn on the camera and it stands on your actual floor.":"Add a model from the library, then turn on the camera and it stands on your actual floor."}),le("div",{class:"ars-empty-row"},[_,g,E])])]),S=le("div",{class:"ars-status",hidden:!0,role:"status","aria-live":"polite"}),M=le("span",{class:"ars-sel-name"}),A=le("div",{class:"ars-selbar",hidden:!0,role:"toolbar","aria-label":"Selected model"},[M,le("button",{type:"button",class:"ars-icon-btn","data-act":"rotate","aria-label":"Rotate the selected model"},[le("span",{"aria-hidden":"true",text:"\u27F3"})]),le("button",{type:"button",class:"ars-icon-btn","data-act":"duplicate","aria-label":"Duplicate the selected model"},[le("span",{"aria-hidden":"true",text:"\u29C9"})]),le("button",{type:"button",class:"ars-icon-btn","data-act":"remove","aria-label":"Remove the selected model"},[le("span",{"aria-hidden":"true",text:"\u2715"})])]),I=le("button",{type:"button",class:"ars-icon-btn","aria-expanded":"false","aria-label":"Add a model to the scene"},[le("span",{"aria-hidden":"true",text:"\uFF0B"}),"Add"]),y=le("input",{class:"ars-forge-input",type:"text",name:"prompt",autocomplete:"off",placeholder:"Describe something to generate\u2026","aria-label":"Describe a 3D model to generate",maxlength:"300"}),C=le("button",{type:"submit",class:"ars-forge-go","aria-label":"Generate this model"},["Make"]),k=n?le("form",{class:"ars-forge-form"},[y,C]):le("span",{class:"ars-spacer"}),z=le("button",{type:"button",class:"ars-icon-btn",disabled:!0,"aria-label":"Take a photo of the scene"},[le("span",{"aria-hidden":"true",text:"\u2B24"})]),$=le("button",{type:"button",class:"ars-icon-btn",hidden:!0,"aria-label":"Remove every model from the scene"},["Clear"]),K=le("div",{class:"ars-dock"},[I,k,z,$]),P=le("div",{class:"ars-tabs",role:"tablist","aria-label":"Model sources"}),N=le("div",{class:"ars-tray-body",role:"tabpanel",tabindex:"-1"}),O=le("button",{type:"button",class:"ars-icon-btn","aria-label":"Close the model browser"},[le("span",{"aria-hidden":"true",text:"\u2715"})]),F=le("div",{class:"ars-tray",hidden:!0,role:"dialog","aria-modal":"true","aria-label":"Add a model"},[le("div",{class:"ars-tray-panel"},[le("div",{class:"ars-tray-head"},[le("h2",{text:"Add a model"}),le("span",{class:"ars-spacer"}),O]),P,N])]),H=le("div",{class:"ars-qr-box"}),V=le("a",{class:"ars-link-out",target:"_blank",rel:"noopener"}),Q=le("button",{type:"button",class:"ars-btn",text:"Done"}),te=le("div",{class:"ars-modal",hidden:!0,role:"dialog","aria-modal":"true","aria-label":"Open this scene on your phone"},[le("div",{class:"ars-dialog"},[le("h2",{text:"Open this scene on your phone"}),le("p",{text:"Scan it and the same models, in the same arrangement, open on the phone: ready to place in your room."}),H,V,Q])]),Se=le("span",{class:"ars-ar-thumb","aria-hidden":"true"}),ve=le("span",{class:"ars-ar-name"}),nt=le("div",{class:"ars-ar-picker",hidden:!0,role:"group","aria-label":"Choose which model to place"}),je=le("p",{class:"ars-ar-hint"}),Qe=le("p",{class:"ars-ar-status",role:"status","aria-live":"polite"}),fe=le("button",{type:"button",class:"ars-btn ars-btn-primary ars-ar-go"},[le("span",{class:"ars-ar-go-icon","aria-hidden":"true",text:"\u2B21"}),le("span",{class:"ars-ar-go-label",text:"Place in your space"})]),ge=le("button",{type:"button",class:"ars-btn ars-ar-xr",hidden:!0},[le("span",{"aria-hidden":"true",text:"\u2726"}),"Immersive AR: place the whole scene"]),Ve=le("button",{type:"button",class:"ars-btn ars-ar-qr",hidden:!0},[le("span",{"aria-hidden":"true",text:"\u{1F4F1}"}),"Open on your phone"]),it=le("button",{type:"button",class:"ars-btn ars-ar-done",text:"Done"}),Ue=le("div",{class:"ars-modal",hidden:!0,role:"dialog","aria-modal":"true","aria-label":"Place a model in your space"},[le("div",{class:"ars-dialog ars-ar-sheet"},[le("h2",{class:"ars-ar-heading",text:"Place in your space"}),le("div",{class:"ars-ar-target"},[Se,ve]),nt,je,Qe,fe,ge,Ve,it])]),ct=le("button",{type:"button",class:"ars-btn ars-btn-primary",text:"Start a shared room"}),zt=le("input",{class:"ars-search",type:"text",placeholder:"Room code","aria-label":"Room code",maxlength:"20",autocomplete:"off",spellcheck:"false"}),ot=le("form",{class:"ars-link-row"},[zt,le("button",{type:"submit",class:"ars-btn",text:"Join"})]),mt=le("div",{},[le("p",{text:"Open a room and anyone who joins sees the same scene. Every move, resize and rotate syncs live."}),le("div",{class:"ars-dialog-row"},[ct]),le("div",{class:"ars-divider"}),le("p",{text:"Got a code from someone?"}),ot]),Lt=le("div",{class:"ars-code"}),ft=le("p",{}),xt=le("div",{class:"ars-qr-box"}),Wt=le("button",{type:"button",class:"ars-btn ars-btn-primary",text:"Copy invite link"}),_n=le("button",{type:"button",class:"ars-btn",text:"Leave room"}),Ht=le("div",{hidden:!0},[Lt,ft,xt,le("div",{class:"ars-dialog-row"},[Wt,_n])]),Kt=le("button",{type:"button",class:"ars-btn",text:"Close"}),q=le("div",{class:"ars-modal",hidden:!0,role:"dialog","aria-modal":"true","aria-label":"Shared room"},[le("div",{class:"ars-dialog"},[le("h2",{text:"Build together"}),mt,Ht,Kt])]),hn=le("div",{class:"ars-hud"},[b,L,S,v,A,K,F,te,Ue,q]),Et=le("div",{class:"ars-root"},[r,a,hn]);t.accent&&Et.style.setProperty("--ars-accent",t.accent),i.appendChild(Et);let U=i.ownerDocument.defaultView?.getComputedStyle(i);return U&&U.position==="static"&&(i.style.position="relative"),i!==i.ownerDocument.body&&i.clientHeight<80&&!i.style.height&&(i.style.minHeight=i.style.minHeight||"70vh"),{root:Et,video:r,canvas:a,hud:hn,top:b,title:c,count:l,status:S,chip:v,cameraBtn:p,xrBtn:d,qrBtn:u,roomBtn:h,addBtn:I,photoBtn:z,clearBtn:$,forgeForm:n?k:null,forgeInput:n?y:null,forgeGo:n?C:null,empty:L,emptyCamera:_,emptyAdd:g,emptyForge:E,selbar:A,selName:M,tray:F,trayTabs:P,trayBody:N,trayClose:O,qrModal:te,qrBox:H,qrLink:V,qrClose:Q,arModal:Ue,arThumb:Se,arName:ve,arPicker:nt,arHint:je,arStatus:Qe,arGo:fe,arXr:ge,arQr:Ve,arClose:it,roomModal:q,roomIdle:mt,roomLive:Ht,roomCreate:ct,roomJoinForm:ot,roomJoinInput:zt,roomCode:Lt,roomPresence:ft,roomQr:xt,roomCopy:Wt,roomLeave:_n,roomClose:Kt}}Qn();var fm=class{constructor(e,t,n,s,r){this.xrLight=e,this.renderer=t,this.lightProbe=n,this.xrWebGLBinding=null,this.estimationStartCallback=r,this.frameCallback=this.onXRFrame.bind(this);let a=t.xr.getSession();if(s&&"XRWebGLBinding"in window){let o=new fo(16);e.environment=o.texture;let c=t.getContext();switch(a.preferredReflectionFormat){case"srgba8":c.getExtension("EXT_sRGB");break;case"rgba16f":c.getExtension("OES_texture_half_float");break}this.xrWebGLBinding=new XRWebGLBinding(a,c),this.lightProbe.addEventListener("reflectionchange",()=>{this.updateReflection()})}a.requestAnimationFrame(this.frameCallback)}updateReflection(){let e=this.renderer.properties.get(this.xrLight.environment);if(e){let t=this.xrWebGLBinding.getReflectionCubeMap(this.lightProbe);t&&(e.__webglTexture=t,this.xrLight.environment.needsPMREMUpdate=!0)}}onXRFrame(e,t){if(!this.xrLight)return;t.session.requestAnimationFrame(this.frameCallback);let s=t.getLightEstimate(this.lightProbe);if(s){this.xrLight.lightProbe.sh.fromArray(s.sphericalHarmonicsCoefficients),this.xrLight.lightProbe.intensity=1;let r=Math.max(1,Math.max(s.primaryLightIntensity.x,Math.max(s.primaryLightIntensity.y,s.primaryLightIntensity.z)));this.xrLight.directionalLight.color.setRGB(s.primaryLightIntensity.x/r,s.primaryLightIntensity.y/r,s.primaryLightIntensity.z/r),this.xrLight.directionalLight.intensity=r,this.xrLight.directionalLight.position.copy(s.primaryLightDirection),this.estimationStartCallback&&(this.estimationStartCallback(),this.estimationStartCallback=null)}}dispose(){this.xrLight=null,this.renderer=null,this.lightProbe=null,this.xrWebGLBinding=null}},Ou=class extends vn{constructor(e,t=!0){super(),this.lightProbe=new gc,this.lightProbe.intensity=0,this.add(this.lightProbe),this.directionalLight=new Yi,this.directionalLight.intensity=0,this.add(this.directionalLight),this.environment=null;let n=null,s=!1;e.xr.addEventListener("sessionstart",()=>{let r=e.xr.getSession();"requestLightProbe"in r&&r.requestLightProbe({reflectionFormat:r.preferredReflectionFormat}).then(a=>{n=new fm(this,e,a,t,()=>{s=!0,this.dispatchEvent({type:"estimationstart"})})})}),e.xr.addEventListener("sessionend",()=>{n&&(n.dispose(),n=null),s&&this.dispatchEvent({type:"estimationend"})}),this.dispose=()=>{n&&(n.dispose(),n=null),this.remove(this.lightProbe),this.lightProbe=null,this.remove(this.directionalLight),this.directionalLight=null,this.environment=null}}};var Fu=class{constructor({renderer:e,scene:t,baseLights:n=[],onChange:s}){this._renderer=e,this._scene=t,this._baseLights=n,this._onChange=s,this._xrLight=null,this._active=!1,this._savedEnv=t.environment,this._savedIntensities=n.map(r=>r.intensity),this._onEstimationStart=this._onEstimationStart.bind(this),this._onEstimationEnd=this._onEstimationEnd.bind(this)}start(){if(this._xrLight)return;let e=new Ou(this._renderer,!0);e.addEventListener("estimationstart",this._onEstimationStart),e.addEventListener("estimationend",this._onEstimationEnd),this._scene.add(e),this._xrLight=e}get active(){return this._active}_onEstimationStart(){if(this._xrLight){this._active=!0;for(let e of this._baseLights)e.intensity=0;this._xrLight.environment&&(this._scene.environment=this._xrLight.environment),this._onChange?.(!0)}}_onEstimationEnd(){this._active=!1,this._restoreBase(),this._onChange?.(!1)}_restoreBase(){this._baseLights.forEach((e,t)=>{e.intensity=this._savedIntensities[t]}),this._scene.environment=this._savedEnv}dispose(){this._xrLight&&(this._xrLight.removeEventListener("estimationstart",this._onEstimationStart),this._xrLight.removeEventListener("estimationend",this._onEstimationEnd),this._scene.remove(this._xrLight),this._xrLight.dispose?.(),this._xrLight=null),this._restoreBase(),this._active=!1}};Qn();function Cx(i,e,t=30){let n=i||{misses:0,lost:!1};if(e)return{state:{misses:0,lost:!1},changed:n.lost===!0,lost:!1};let s=n.misses+1,r=s>=t;return{state:{misses:s,lost:r},changed:r&&!n.lost,lost:r}}var n2=new Set(["hidden","visible-blurred"]);function Ix(i){return!n2.has(i)}function Rx(i){return i<0?0:i>1?1:i}function Px(i,e,t=0,n=!1){let s=Rx(e),r=n?0:Rx(t),a=n?.94:.86+r*.1,o=n?.5:.34+r*.18;return i.scale=a+(1-a)*s,i.opacity=o+(.96-o)*s,i.dot=s,i.colorMix=s,i}var i2=.55;function Lx(i,e,t=i2){let n=i.t+e,s=n>=t?1:n/t,r=1-(1-s)*(1-s);return i.t=n,i.scale=1+r*2,i.opacity=.85*(1-s),i.done=n>=t,i}var Uc=class{constructor(e){this._renderer=e,this._mesh=null,this._enabled=!1}static sessionHasDepth(e){return!!e?.enabledFeatures?.includes?.("depth-sensing")}update(){if(this._mesh)return;let e=this._renderer.xr;if(typeof e.hasDepthSensing!="function"||!e.hasDepthSensing())return;let t=e.getDepthSensingMesh?.();t&&this._configure(t)}_configure(e){let t=e.material;t.colorWrite=!1,t.depthWrite=!0,t.depthTest=!1,e.frustumCulled=!1,this._mesh=e,this._enabled=!0}get enabled(){return this._enabled}dispose(){this._mesh&&(this._mesh.geometry?.dispose(),this._mesh.material?.dispose(),this._mesh=null),this._enabled=!1}};function Bc(){return{active:!1,startDist:0,baseScale:1,scale:1}}function ku(i,e,t){if(!Number.isFinite(e)||e<24)return!1;let n=Number.isFinite(t)&&t>0?t:1;return i.active=!0,i.startDist=e,i.baseScale=n,i.scale=n,!0}function Uu(i,e){if(!i.active||!Number.isFinite(e)||e<=0||i.startDist<=0)return null;let t=i.baseScale*(e/i.startDist);return i.scale=Math.min(4,Math.max(.25,t)),i.scale}function Bu(i){return i.active?(i.active=!1,i.scale):null}function xo(i){let e=i[0].clientX-i[1].clientX,t=i[0].clientY-i[1].clientY;return Math.hypot(e,t)}function r2(){try{return typeof window<"u"&&!!window.matchMedia?.("(prefers-reduced-motion: reduce)").matches}catch{return!1}}function a2(){try{let e=document.createElement("canvas");e.width=e.height=128;let t=e.getContext("2d"),n=t.createRadialGradient(128/2,128/2,0,128/2,128/2,128/2);return n.addColorStop(0,"rgba(0,0,0,0.42)"),n.addColorStop(.55,"rgba(0,0,0,0.20)"),n.addColorStop(1,"rgba(0,0,0,0)"),t.fillStyle=n,t.fillRect(0,0,128,128),new Zr(e)}catch{return null}}var zu=class{constructor({renderer:e,scene:t,camera:n,domOverlayRoot:s,getArmedContent:r,onPlaced:a,getScaleTarget:o,onScale:c,onHit:l,onTracking:h,onVisibility:u,onEnd:d,onFrame:p}){this._renderer=e,this._scene=t,this._camera=n,this._domOverlayRoot=s??null,this._getArmedContent=r,this._onPlaced=a,this._getScaleTarget=o,this._onScale=c,this._onHit=l,this._onTracking=h,this._onVisibility=u,this._onEnd=d,this._onFrame=p,this._session=null,this._hitTestSource=null,this._localSpace=null,this._ended=!1,this._paused=!1,this._trackingState={misses:0,lost:!1},this._depthOcclusion=null,this._placements=[],this._latestHit=null,this._latestHitMatrix=new ht,this._hasHit=!1,this._hadHit=!1,this._hitAmount=0,this._reticle=null,this._reticleRing=null,this._reticleDot=null,this._pulseRing=null,this._rv={scale:1,opacity:.9,dot:0,colorMix:0},this._pulse={t:0,scale:1,opacity:0,done:!1,active:!1},this._dimColor=new He(8023280),this._lockColor=new He(12891645),this._reducedMotion=!1,this._shadowTex=null,this._prevTime=0,this._savedBg=null,this._pinch=Bc(),this._pinchEndedAt=-1/0,this._uiTouchActive=!1,this._handleEnd=this._handleEnd.bind(this),this._handleSelect=this._handleSelect.bind(this),this._handleVisibilityChange=this._handleVisibilityChange.bind(this),this._handleTouchStart=this._handleTouchStart.bind(this),this._handleTouchMove=this._handleTouchMove.bind(this),this._handleTouchEnd=this._handleTouchEnd.bind(this),this._handleBeforeSelect=this._handleBeforeSelect.bind(this)}static async isSupported(){try{return!!(navigator.xr&&await navigator.xr.isSessionSupported("immersive-ar"))}catch{return!1}}async start(){let e=this._renderer;e.xr.enabled=!0;let t={requiredFeatures:["hit-test"],optionalFeatures:["anchors","local-floor","depth-sensing","light-estimation"],depthSensing:{usagePreference:["gpu-optimized","cpu-optimized"],dataFormatPreference:["luminance-alpha","float32"]}};this._domOverlayRoot&&(t.optionalFeatures.push("dom-overlay"),t.domOverlay={root:this._domOverlayRoot});let n=await navigator.xr.requestSession("immersive-ar",t);this._session=n,this._ended=!1,this._paused=!1,this._trackingState={misses:0,lost:!1},n.addEventListener("end",this._handleEnd),n.addEventListener("select",this._handleSelect),n.addEventListener("visibilitychange",this._handleVisibilityChange),await e.xr.setSession(n),this._localSpace=await n.requestReferenceSpace("local");let s=await n.requestReferenceSpace("viewer");if(this._hitTestSource=await n.requestHitTestSource({space:s}),this._depthOcclusion=Uc.sessionHasDepth(n)?new Uc(e):null,this._reducedMotion=r2(),this._hadHit=!1,this._hitAmount=0,this._pulse.active=!1,this._shadowTex=a2(),this._buildReticle(),this._buildPulseRing(),this._savedBg=this._scene.background,this._scene.background=null,e.setClearColor(0,0),this._domOverlayRoot){let r=this._domOverlayRoot;r.addEventListener("touchstart",this._handleTouchStart,{passive:!0}),r.addEventListener("touchmove",this._handleTouchMove,{passive:!0}),r.addEventListener("touchend",this._handleTouchEnd,{passive:!0}),r.addEventListener("touchcancel",this._handleTouchEnd,{passive:!0}),r.addEventListener("beforexrselect",this._handleBeforeSelect)}this._prevTime=0,e.setAnimationLoop((r,a)=>this._tick(r,a))}get placedCount(){return this._placements.length}_tick(e,t){let n=this._renderer,s=this._prevTime?Math.min(.1,(e-this._prevTime)/1e3):.016;if(this._prevTime=e,this._paused){n.render(this._scene,this._camera);return}if(t&&this._localSpace){let r=!!t.getViewerPose(this._localSpace),a=Cx(this._trackingState,r,30);this._trackingState=a.state,a.changed&&this._setTracking(!a.lost)}if(this._onFrame?.(s),t&&this._hitTestSource){let r=t.getHitTestResults(this._hitTestSource),a=r.length>0?r[0].getPose(this._localSpace):null;if(a)this._latestHit=r[0],this._latestHitMatrix.fromArray(a.transform.matrix),this._hadHit=!0,this._reticle&&(this._reticle.visible=!0,this._reticle.position.setFromMatrixPosition(this._latestHitMatrix),this._reticle.quaternion.setFromRotationMatrix(this._latestHitMatrix)),this._setHit(!0);else{this._latestHit=null;let o=this._hadHit&&!this._trackingState.lost;this._reticle&&(this._reticle.visible=o),this._setHit(!1)}}if(t)for(let r of this._placements){if(!r.anchor)continue;let a=t.getPose(r.anchor.anchorSpace,this._localSpace);if(a){let o=a.transform.position;r.group.position.set(o.x,o.y,o.z),r.shadow?.position.set(o.x,o.y+.004,o.z)}}this._updateReticleVisual(e,s),this._updatePulse(s),this._depthOcclusion?.update(),n.render(this._scene,this._camera)}async _handleSelect(){if(!this._latestHit||this._pinch.active||performance.now()-this._pinchEndedAt<350||this._uiTouchActive)return;let e=this._getArmedContent?.();if(!e)return;let t=this._latestHitMatrix.clone();e.position.setFromMatrixPosition(t),e.parent||this._scene.add(e);let n=this._buildShadow();n.position.copy(e.position),n.position.y+=.004,n.scale.setScalar(e.scale.x||1),this._fireConfirmPulse();try{navigator.vibrate?.(15)}catch{}let s=null;try{s=await this._latestHit.createAnchor?.()??null}catch{s=null}this._placements.push({group:e,anchor:s,shadow:n}),this._onPlaced?.(e,{position:{x:e.position.x,y:e.position.y,z:e.position.z},matrix:t},{degraded:s===null})}release(e){let t=this._placements.findIndex(s=>s.group===e);if(t===-1)return;let[n]=this._placements.splice(t,1);try{n.anchor?.delete?.()}catch{}n.shadow&&(this._scene.remove(n.shadow),n.shadow.geometry?.dispose(),n.shadow.material?.dispose())}_scaleTarget(){let e=this._getScaleTarget?.();return e||(this._placements.length?this._placements[this._placements.length-1].group:null)}_handleTouchStart(e){if(e.touches.length===1){this._uiTouchActive=!!e.touches[0].target?.closest?.("[data-xr-ui]");return}if(e.touches.length!==2)return;let t=this._scaleTarget();t&&ku(this._pinch,xo(e.touches),t.scale?.x??1)}_handleTouchMove(e){if(!this._pinch.active||e.touches.length!==2)return;let t=Uu(this._pinch,xo(e.touches));if(t==null)return;let n=this._scaleTarget();if(!n)return;n.scale.setScalar(t),this._placements.find(r=>r.group===n)?.shadow?.scale.setScalar(t),this._onScale?.(t,{final:!1})}_handleTouchEnd(e){(!e.touches||e.touches.length===0)&&(this._uiTouchActive=!1);let t=Bu(this._pinch);t!=null&&(this._pinchEndedAt=performance.now(),this._onScale?.(t,{final:!0}))}_handleBeforeSelect(e){if(this._pinch.active||performance.now()-this._pinchEndedAt<350){e.preventDefault();return}e.target?.closest?.("[data-xr-ui]")&&e.preventDefault()}_buildReticle(){let e=new vn;e.renderOrder=999,e.visible=!1;let t=new vt(new gr(.08,.11,40).rotateX(-Math.PI/2),new Sn({color:this._dimColor.clone(),transparent:!0,opacity:.6,depthTest:!1}));t.renderOrder=999;let n=new vt(new rc(.032,32).rotateX(-Math.PI/2).translate(0,.001,0),new Sn({color:this._lockColor.clone(),transparent:!0,opacity:0,depthTest:!1}));n.renderOrder=1e3,e.add(t,n),this._reticle=e,this._reticleRing=t,this._reticleDot=n,this._scene.add(e)}_buildPulseRing(){let e=new vt(new gr(.1,.13,40).rotateX(-Math.PI/2),new Sn({color:this._lockColor.clone(),transparent:!0,opacity:0,depthTest:!1}));e.renderOrder=1001,e.visible=!1,this._pulseRing=e,this._scene.add(e)}_buildShadow(){let e=new Ii(.6,.6).rotateX(-Math.PI/2),t=new Sn({map:this._shadowTex,color:this._shadowTex?16777215:0,transparent:!0,opacity:.9,depthWrite:!1}),n=new vt(e,t);return n.renderOrder=1,this._scene.add(n),n}_fireConfirmPulse(){this._reducedMotion||!this._pulseRing||(this._pulseRing.position.setFromMatrixPosition(this._latestHitMatrix),this._pulseRing.quaternion.setFromRotationMatrix(this._latestHitMatrix),this._pulse.t=0,this._pulse.active=!0,this._pulseRing.visible=!0)}_updateReticleVisual(e,t){let n=this._reticle;if(!n||!n.visible)return;let s=this._hasHit?1:0,r=Math.min(1,t*(s>this._hitAmount?16:9));this._hitAmount+=(s-this._hitAmount)*r;let a=this._reducedMotion?0:Math.sin(e*.0019)*.5+.5;Px(this._rv,this._hitAmount,a,this._reducedMotion),n.scale.setScalar(this._rv.scale);let o=this._reticleRing.material;o.opacity=this._rv.opacity,o.color.lerpColors(this._dimColor,this._lockColor,this._rv.colorMix),this._reticleDot.material.opacity=this._rv.dot*.95}_updatePulse(e){!this._pulse.active||!this._pulseRing||(Lx(this._pulse,e),this._pulseRing.scale.setScalar(this._pulse.scale),this._pulseRing.material.opacity=this._pulse.opacity,this._pulse.done&&(this._pulse.active=!1,this._pulseRing.visible=!1))}_setHit(e){e!==this._hasHit&&(this._hasHit=e,this._onHit?.(e))}_setTracking(e){!e&&this._reticle&&(this._reticle.visible=!1),this._onTracking?.(e)}_handleVisibilityChange(){let e=Ix(this._session?.visibilityState);this._paused=!e,!e&&this._reticle&&(this._reticle.visible=!1),this._onVisibility?.(e)}async end(){if(this._session)try{await this._session.end()}catch{}}_handleEnd(){if(this._ended)return;this._ended=!0;let e=this._renderer;if(this._session?.removeEventListener("visibilitychange",this._handleVisibilityChange),this._domOverlayRoot){let t=this._domOverlayRoot;t.removeEventListener("touchstart",this._handleTouchStart),t.removeEventListener("touchmove",this._handleTouchMove),t.removeEventListener("touchend",this._handleTouchEnd),t.removeEventListener("touchcancel",this._handleTouchEnd),t.removeEventListener("beforexrselect",this._handleBeforeSelect)}if(this._pinch=Bc(),this._pinchEndedAt=-1/0,this._uiTouchActive=!1,e.setAnimationLoop(null),e.xr.enabled=!1,this._hitTestSource){try{this._hitTestSource.cancel()}catch{}this._hitTestSource=null}for(let t of[this._reticleRing,this._reticleDot,this._pulseRing])t?.geometry?.dispose(),t?.material?.dispose();this._reticle&&this._scene.remove(this._reticle),this._pulseRing&&this._scene.remove(this._pulseRing),this._reticle=this._reticleRing=this._reticleDot=this._pulseRing=null,this._pulse.active=!1;for(let t of this._placements){try{t.anchor?.delete?.()}catch{}t.shadow&&(this._scene.remove(t.shadow),t.shadow.geometry?.dispose(),t.shadow.material?.dispose())}this._placements=[],this._shadowTex?.dispose(),this._shadowTex=null,this._depthOcclusion?.dispose(),this._depthOcclusion=null,this._session=null,this._latestHit=null,this._hasHit=!1,this._hadHit=!1,this._hitAmount=0,this._paused=!1,this._trackingState={misses:0,lost:!1},this._scene.background=this._savedBg,e.setClearColor(0,0),this._onEnd?.()}};function Dx({run:i,maxActive:e=5,priorityOf:t=()=>0}){let n=[],s=0,r={run:i,maxActive:e,priorityOf:t};function a(){for(n.length>1&&n.sort((o,c)=>r.priorityOf(o.item)-r.priorityOf(c.item));s<r.maxActive&&n.length;){let o=n.shift();o.cancelled||(s++,Promise.resolve().then(()=>r.run(o.item)).then(o.resolve,o.reject).finally(()=>{s--,a()}))}}return{request(o){return new Promise((c,l)=>{n.push({item:o,resolve:c,reject:l,cancelled:!1}),a()})},cancel(o){let c=0;for(let l of n)!l.cancelled&&o(l.item)&&(l.cancelled=!0,l.reject(new Error("cancelled")),c++);return c},setMaxActive(o){r.maxActive=Math.max(1,o|0),a()},get active(){return s},get pending(){return n.reduce((o,c)=>o+(c.cancelled?0:1),0)}}}qu();Qn();var w2=Object.freeze(["Hips","Spine","Spine1","Spine2","Neck","Head","LeftShoulder","LeftArm","LeftForeArm","LeftHand","LeftHandIndex1","LeftHandIndex2","LeftHandIndex3","LeftHandMiddle1","LeftHandMiddle2","LeftHandMiddle3","LeftHandPinky1","LeftHandPinky2","LeftHandPinky3","LeftHandRing1","LeftHandRing2","LeftHandRing3","LeftHandThumb1","LeftHandThumb2","LeftHandThumb3","RightShoulder","RightArm","RightForeArm","RightHand","RightHandIndex1","RightHandIndex2","RightHandIndex3","RightHandMiddle1","RightHandMiddle2","RightHandMiddle3","RightHandPinky1","RightHandPinky2","RightHandPinky3","RightHandRing1","RightHandRing2","RightHandRing3","RightHandThumb1","RightHandThumb2","RightHandThumb3","LeftUpLeg","LeftLeg","LeftFoot","LeftToeBase","RightUpLeg","RightLeg","RightFoot","RightToeBase"]),M2=(()=>{let i=new Map;for(let e of w2)i.set(e.toLowerCase(),e);return i})(),Wm=new Map(Object.entries({pelvis:"Hips",neck01:"Neck",claviclel:"LeftShoulder",upperarml:"LeftArm",lowerarml:"LeftForeArm",handl:"LeftHand",clavicler:"RightShoulder",upperarmr:"RightArm",lowerarmr:"RightForeArm",handr:"RightHand",thighl:"LeftUpLeg",calfl:"LeftLeg",footl:"LeftFoot",balll:"LeftToeBase",thighr:"RightUpLeg",calfr:"RightLeg",footr:"RightFoot",ballr:"RightToeBase"}));for(let[i,e]of[["thumb","Thumb"],["index","Index"],["middle","Middle"],["ring","Ring"],["pinky","Pinky"]])for(let t=1;t<=3;t++)Wm.set(`${i}0${t}l`,`LeftHand${e}${t}`),Wm.set(`${i}0${t}r`,`RightHand${e}${t}`);var E2=(()=>{let i=new Map,e=r=>r.replace(/[-_.\s]+/g,"").toLowerCase(),t=(r,a)=>{let o=e(r);i.has(o)||i.set(o,a)},n=[["J_Bip_C_Hips","Hips"],["J_Bip_C_Spine","Spine"],["J_Bip_C_Chest","Spine1"],["J_Bip_C_UpperChest","Spine2"],["J_Bip_C_Neck","Neck"],["J_Bip_C_Head","Head"],["J_Bip_L_Shoulder","LeftShoulder"],["J_Bip_L_UpperArm","LeftArm"],["J_Bip_L_LowerArm","LeftForeArm"],["J_Bip_L_Hand","LeftHand"],["J_Bip_R_Shoulder","RightShoulder"],["J_Bip_R_UpperArm","RightArm"],["J_Bip_R_LowerArm","RightForeArm"],["J_Bip_R_Hand","RightHand"],["J_Bip_L_UpperLeg","LeftUpLeg"],["J_Bip_L_LowerLeg","LeftLeg"],["J_Bip_L_Foot","LeftFoot"],["J_Bip_L_ToeBase","LeftToeBase"],["J_Bip_L_Toes","LeftToeBase"],["J_Bip_R_UpperLeg","RightUpLeg"],["J_Bip_R_LowerLeg","RightLeg"],["J_Bip_R_Foot","RightFoot"],["J_Bip_R_ToeBase","RightToeBase"],["J_Bip_R_Toes","RightToeBase"]];for(let[r,a]of n)t(r,a);for(let[r,a]of[["Thumb","Thumb"],["Index","Index"],["Middle","Middle"],["Ring","Ring"],["Little","Pinky"]])for(let o=1;o<=3;o++)t(`J_Bip_L_${r}${o}`,`LeftHand${a}${o}`),t(`J_Bip_R_${r}${o}`,`RightHand${a}${o}`);for(let[r,a]of[["chest","Spine1"],["lowerChest","Spine1"],["chestLower","Spine1"],["upperChest","Spine2"],["chestUpper","Spine2"],["abdomen","Spine"],["abdomenLower","Spine"],["abdomenUpper","Spine1"],["hip","Hips"],["lowerNeck","Neck"],["upperNeck","Neck"],["neckLower","Neck"],["neckUpper","Neck"],["neckTwist01","Neck"],["neckTwist02","Neck"],["torso","Spine"],["waist","Spine"],["upperTorso","Spine1"],["torsoUpper","Spine1"],["lowerTorso","Hips"],["torsoLower","Hips"],["ribcage","Spine1"],["ribs","Spine1"],["mPelvis","Hips"],["mTorso","Spine"],["mChest","Spine1"],["mNeck","Neck"],["mHead","Head"],["root_M","Hips"],["hip_M","Hips"],["pelvis_M","Hips"],["spine1_M","Spine"],["spine2_M","Spine1"],["spine3_M","Spine2"],["chest_M","Spine2"],["neck_M","Neck"],["head_M","Head"],["spine0","Spine"],["hipMaster","Hips"],["lumbar","Spine"],["thoracic","Spine1"],["sternum","Spine2"],["cervical","Neck"],["cranium","Head"],["skull","Head"]])t(r,a);let s=[["leftUpperArm","LeftArm"],["lUpperArm","LeftArm"],["shoulderL","LeftArm"],["lShldr","LeftArm"],["lShldrBend","LeftArm"],["leftLowerArm","LeftForeArm"],["lLowerArm","LeftForeArm"],["elbowL","LeftForeArm"],["lForeArm","LeftForeArm"],["lForearmBend","LeftForeArm"],["forearmL","LeftForeArm"],["upperArmL","LeftArm"],["wristL","LeftHand"],["lHand","LeftHand"],["lCollar","LeftShoulder"],["collarL","LeftShoulder"],["lClavicle","LeftShoulder"],["leftUpperLeg","LeftUpLeg"],["lUpperLeg","LeftUpLeg"],["hipL","LeftUpLeg"],["lThigh","LeftUpLeg"],["lThighBend","LeftUpLeg"],["leftLowerLeg","LeftLeg"],["lLowerLeg","LeftLeg"],["kneeL","LeftLeg"],["shinL","LeftLeg"],["lShin","LeftLeg"],["lCalf","LeftLeg"],["ankleL","LeftFoot"],["lFoot","LeftFoot"],["leftToes","LeftToeBase"],["toeL","LeftToeBase"],["lToe","LeftToeBase"],["lToeBase","LeftToeBase"],["lArm","LeftArm"],["lShoulder","LeftShoulder"],["lLeg","LeftLeg"],["lUpLeg","LeftUpLeg"],["leftHip","LeftUpLeg"],["leftThigh","LeftUpLeg"],["leftKnee","LeftLeg"],["leftShin","LeftLeg"],["leftCalf","LeftLeg"],["leftAnkle","LeftFoot"],["leftElbow","LeftForeArm"],["leftWrist","LeftHand"],["leftCollar","LeftShoulder"],["leftClavicle","LeftShoulder"],["leftToe","LeftToeBase"],["mCollarLeft","LeftShoulder"],["mShoulderLeft","LeftArm"],["mElbowLeft","LeftForeArm"],["mWristLeft","LeftHand"],["mHipLeft","LeftUpLeg"],["mKneeLeft","LeftLeg"],["mAnkleLeft","LeftFoot"],["mFootLeft","LeftToeBase"],["mToeLeft","LeftToeBase"],["upperLegL","LeftUpLeg"],["lowerLegL","LeftLeg"],["lowerArmL","LeftForeArm"],["scapulaL","LeftShoulder"],["lHip","LeftUpLeg"],["lKnee","LeftLeg"],["lAnkle","LeftFoot"],["lElbow","LeftForeArm"],["lWrist","LeftHand"],["lToes","LeftToeBase"],["humerusL","LeftArm"],["lHumerus","LeftArm"],["ulnaL","LeftForeArm"],["lUlna","LeftForeArm"],["radiusL","LeftForeArm"],["lRadius","LeftForeArm"],["carpusL","LeftHand"],["lCarpus","LeftHand"],["femurL","LeftUpLeg"],["lFemur","LeftUpLeg"],["tibiaL","LeftLeg"],["lTibia","LeftLeg"],["fibulaL","LeftLeg"],["lFibula","LeftLeg"],["talusL","LeftFoot"],["lTalus","LeftFoot"],["tarsusL","LeftFoot"],["lTarsus","LeftFoot"],["calcaneusL","LeftFoot"],["lCalcaneus","LeftFoot"],["metatarsusL","LeftToeBase"],["lMetatarsus","LeftToeBase"]];for(let[r,a]of[["Thumb","Thumb"],["Index","Index"],["Middle","Middle"],["Ring","Ring"],["Pinky","Pinky"],["Little","Pinky"]]){let o=r.toLowerCase();for(let l=1;l<=3;l++){s.push([`l${r}${l}`,`LeftHand${a}${l}`]),s.push([`f_${o}.0${l}.L`,`LeftHand${a}${l}`]),s.push([`${o}.0${l}.L`,`LeftHand${a}${l}`]);let h=["Thumb","Index","Middle","Ring","Pinky"].indexOf(a)+1;h>0&&s.push([`finger${h}-${l}.L`,`LeftHand${a}${l}`])}(a==="Thumb"?["Metacarpal","Proximal","Distal"]:["Proximal","Intermediate","Distal"]).forEach((l,h)=>{s.push([`left${r}${l}`,`LeftHand${a}${h+1}`]),s.push([`${o}_${l.toLowerCase()}.L`,`LeftHand${a}${h+1}`])})}for(let r=1;r<=3;r++)s.push([`lMid${r}`,`LeftHandMiddle${r}`]);for(let[r,a]of[["Thumb","Thumb"],["Index","Index"],["Middle","Middle"],["Ring","Ring"],["Pinky","Pinky"],["Little","Pinky"]]){for(let o=1;o<=3;o++)s.push([`${r}${o}L`,`LeftHand${a}${o}`]),s.push([`${r}Finger${o}L`,`LeftHand${a}${o}`]);s.push([`${r}L`,`LeftHand${a}1`]),s.push([`${r}FingerL`,`LeftHand${a}1`])}for(let[r,a]of s){t(r,a);let o=a.replace(/^Left/,"Right"),c;/^left/.test(r)?c=r.replace(/^left/,"right"):/^l[A-Z]/.test(r)?c="r"+r.slice(1):/Left$/.test(r)?c=r.replace(/Left$/,"Right"):/L$/.test(r)?c=r.replace(/L$/,"R"):c=r,t(c,o)}return i})();function Oi(i){if(typeof i!="string"||!i)return null;let e=Xx(i);if(e)return e;let t=i.replace(/[._]\d+$/,"");return t!==i?Xx(t):null}function Xx(i){let e=i;e=e.replace(/^(?:[A-Za-z][\w]*:)+/,""),e=e.replace(/^mixamorig\d*[_:]?/i,""),e=e.replace(/^Armature[_/]?/i,""),e=e.replace(/^(DEF|ORG|MCH)[-_]/i,""),e=e.replace(/^CH[_:]/i,""),e=e.replace(/^CC_Base_/i,""),e=e.replace(/^j_(?!bip|sec|adj)/i,""),e=e.replace(/^\d+\./,"").replace(/^!/,"").replace(/^joint[_:]/i,""),e=e.replace(/^Bip\d+[\s_]?/i,"");let t=e.replace(/[-_.\s]+/g,"").toLowerCase();return M2.get(t)??Wm.get(t)??E2.get(t)??null}var A2=/shoulder|clavicle|collar|scapula/i,Kx=/upper.?arm|humerus/i,Yx=/clavicle|collar|scapula/i;function Jx(i,e={}){let t=typeof e.isAncestor=="function"?e.isAncestor:null,n=new Map;for(let o of i)n.set(o.canonical,(n.get(o.canonical)||0)+1);let s=(o,c,l)=>o.length<2||!t?o[0]:o.find(u=>c.some(d=>d!==u&&(l?t(u,d):t(d,u))))||o[0],r=(o,c,l)=>{o.canonical=l,n.set(c,(n.get(c)||1)-1),n.set(l,(n.get(l)||0)+1)},a=0;for(let o of["Left","Right"]){let c=`${o}Arm`,l=`${o}Shoulder`;if((n.get(c)||0)<2||(n.get(l)||0)>0)continue;let h=i.filter(b=>b.canonical===c),u=h.filter(b=>Kx.test(b.raw));if(u.length===0)continue;let d=h.filter(b=>A2.test(b.raw)&&!Kx.test(b.raw)),p=s(d,u,!0);p&&(r(p,c,l),a++)}for(let o of["Left","Right"]){let c=`${o}Arm`,l=`${o}Shoulder`;if((n.get(l)||0)<2||(n.get(c)||0)>0)continue;let h=i.filter(b=>b.canonical===l),u=h.filter(b=>Yx.test(b.raw));if(u.length===0)continue;let d=h.filter(b=>/shoulder/i.test(b.raw)&&!Yx.test(b.raw)),p=s(d,u,!1);p&&(r(p,l,c),a++)}return a}Qn();var Zx=Object.freeze({Head:[-.11706881878098431,9438845082943482e-24,372654613409334e-22,.993123804804428],Hips:[.0010741148761599644,6537898515070053e-23,7022659074474357e-26,.9999994231384476],LeftArm:[-.003089573263103852,.08018148459223169,-.025041829737156785,.9964608827384491],LeftFoot:[.5523737034239063,.0002518875693487157,.0036538113016644914,.8335885543726441],LeftForeArm:[-26826767953574183e-23,12816740072681333e-23,.012369379808617674,.9999234962951223],LeftHand:[-.0012910117424963744,.002537815819541244,.010116448936771993,.9999447735952517],LeftHandIndex1:[.028803290204768833,.011362422123976328,.055965724298468224,.9979524555518633],LeftHandIndex2:[-.005195237841915152,.014315447122751807,.00021581682553071412,.9998840087229335],LeftHandIndex3:[-.0013151015878908295,-.016941197343945148,-.006458334440614796,.9998347644768737],LeftHandMiddle1:[.027532617383276645,-.031607746403852485,.016931179482824785,.9989775976007271],LeftHandMiddle2:[-.001267981765488788,.0010468621884392817,-.004466175725402764,.9999886747239598],LeftHandMiddle3:[-.0015803533040544947,.0018352886876119797,.0038040706030556736,.9999898315711762],LeftHandPinky1:[.009345046842530319,-.07377447953394943,-.04207784173776388,.9963430390695086],LeftHandPinky2:[-.0019002180814112143,.0002770864318134059,.0004968185265866393,.9999980327809131],LeftHandPinky3:[-.0014157518824255099,-.005595319155644295,-.004606740515194791,.9999727326242506],LeftHandRing1:[.018207541076892743,-.03436008716699126,-.036855349348364555,.9985637451229231],LeftHandRing2:[-.0006571286469542868,.015477225242721515,.01003471962236163,.9998296495318929],LeftHandRing3:[.001815607007583071,-.003099595768579846,.0072046170631637615,.999967594260012],LeftHandThumb1:[.1900227602341495,-.058826116539083484,.3478783626049766,.9161940209594684],LeftHandThumb2:[.01801363066187901,-.020968588375318502,-.22063576333056306,.9749644544258214],LeftHandThumb3:[-.014498565873099356,.03466160908487025,.011599642488048602,.9992266072970502],LeftLeg:[-.022987686472704008,-.0006608912898930547,7960712093047862e-20,.9997355266049326],LeftShoulder:[.5181706903502131,.5134387363832796,-.48299308003518876,.4843526489955184],LeftToeBase:[.23652217735689587,.0006644108661216591,-.002051152932444189,.9716236982227819],LeftUpLeg:[-4952055077835167e-20,.0032567616062252223,.9999946186652781,-.00039203576089550014],Neck:[.2225107795455935,-23352293238692193e-23,-19647139012020554e-24,.974930229804142],RightArm:[-.003089570938390283,-.08018164882954634,.025041835809991725,.9964608693782484],RightFoot:[.5523737112340288,-.00025188760500252676,-.0036538107149212758,.8335885491999105],RightForeArm:[-2706717415294191e-22,60675494372234465e-25,-.012369382961452784,.9999234962561284],RightHand:[-.0012910114923260908,-.002537815924782367,-.010116450486313036,.9999447735796301],RightHandIndex1:[.028803284769926347,-.01136242475457741,-.05596571258489258,.9979524563349205],RightHandIndex2:[-.005195229421057241,-.014315442233259087,-.00021582506177354608,.9998840088349297],RightHandIndex3:[-.0013151045827228072,.016941319655899355,.006458327385746035,.9998347624459482],RightHandMiddle1:[.027532662650122483,.03160778647114273,-.01693120529165708,.9989775946478099],RightHandMiddle2:[-.0012680273836480952,-.0010469047250576836,.004466199390698661,.9999886745158897],RightHandMiddle3:[-.0015803562094451136,-.001835288773706009,-.003804068167924464,.9999898315756854],RightHandPinky1:[.009345030274151258,.07377446325595405,.04207784564870347,.9963430402658229],RightHandPinky2:[-.0019002008217559384,-.0002769620503994165,-.0004968229018870381,.9999980328459891],RightHandPinky3:[-.0014157497333212687,.0055951881780210025,.004606743315319843,.9999727333471813],RightHandRing1:[.01820754441109714,.03436008722907556,.03685535429214536,.9985637448787448],RightHandRing2:[-.0006571335802527884,-.015477230302375519,-.010034723368684675,.999829649412505],RightHandRing3:[.0018156069598940002,.003099598646436032,-.007204626788931167,.9999675941811231],RightHandThumb1:[.19002276085311107,.05882618704962336,-.3478783387552461,.9161940229953188],RightHandThumb2:[.018013663274561078,.020968550782212388,.22063584956274163,.9749644350943654],RightHandThumb3:[-.014498582331377526,-.03466161961137741,-.011599713293476643,.9992266058762234],RightLeg:[-.022987685898989207,.0006609402907891899,-7960698692017099e-20,.9997355265857409],RightShoulder:[.5181706006117709,-.5134387953473804,.4829931766210871,.4843525890882128],RightToeBase:[.23652222014073046,-.0006644109035597298,.0020511526077556528,.9716236878087238],RightUpLeg:[49438593286575395e-21,.003256759408127677,.9999946186765544,.0003920356017771739],Spine:[-.018332562694809717,-14544833124647894e-23,26976261645093277e-26,.9998319444511763],Spine1:[-.03815628571181615,20010687323521798e-24,534807122500512e-23,.9992717837809081],Spine2:[-.056998031890724846,13546308636882866e-23,-8861325315468363e-25,.9983742907149431]}),Qx=Object.freeze({Head:[-.005402766806732544,-15440620455356296e-23,834223242528311e-24,.9999854049488961],Hips:[.0010741148761599644,6537898515070053e-23,7022659074474357e-26,.9999994231384476],LeftArm:[.4889318420664182,.5108287295941205,-.5108290884863605,.48893078190839623],LeftFoot:[-7112359875637768e-20,.5349085331963127,.8448985998862468,-.004383145577274271],LeftForeArm:[.49521300584988104,.5047420653526237,-.5047420379230214,.4952120815979495],LeftHand:[.5009334720626235,.5016127781291206,-.4977959877649929,.49964931327533474],LeftHandIndex1:[.5480286232738694,.46388966319384123,-.47756977349452234,.506357703809076],LeftHandIndex2:[.5522711480640051,.4734474077351049,-.46714980714345783,.5026083894226862],LeftHandIndex3:[.5405471533897316,.46903549072233974,-.4790521335412708,.5082553896043159],LeftHandMiddle1:[.5069366564823887,.46312011824587895,-.5184714785961669,.5096295836965867],LeftHandMiddle2:[.5047591066222094,.46656986579426646,-.5196237813564338,.5074661907650336],LeftHandMiddle3:[.5066805225023663,.46639751835165716,-.5160243364733309,.509379123507728],LeftHandPinky1:[.4459394011607033,.4793433042957962,-.5586434331057456,.5092009093395086],LeftHandPinky2:[.4453638702749085,.48032344738196137,-.5573549331147079,.5101920146245817],LeftHandPinky3:[.4392981168466072,.4802964151504903,-.5615019919023976,.5109286011992389],LeftHandRing1:[.47371996160924823,.4931227775910745,-.5418410288696247,.4886999364902444],LeftHandRing2:[.48665266892609377,.49620490515614146,-.5291888435031511,.48673303168821197],LeftHandRing3:[.48945530931580683,.4902132045285772,-.5280743092981476,.4911843263440915],LeftHandThumb1:[.6991138207882592,.16132571576360077,-.40704633814367386,.5652673372230799],LeftHandThumb2:[.64766423234777,.2923511094450446,-.5391393932239583,.4520957758831027],LeftHandThumb3:[.6626872004096495,.3080994487427915,-.5067905211225114,.45725679518685386],LeftLeg:[.0006202111480182034,-.020805293540463354,.9997832430476497,-.00047118992773536965],LeftShoulder:[.4605450937998788,.4559956590278878,-.537559006794696,.5394409087622226],LeftToeBase:[-.002764355526654178,.7195640056310856,.6944147145329627,-.0028643286082629046],LeftUpLeg:[-4987623525000119e-20,.0021826506059020026,.9999975399461294,-.00039198262713485737],Neck:[.11170149382802401,-1628868597421303e-22,-18309282630496044e-24,.9937418056399563],RightArm:[.48893190585215524,-.510828798312402,.5108290283825504,.48893071200502375],RightFoot:[7112360405196955e-20,.5349085398019146,.844898595705669,.004383145306035045],RightForeArm:[.4952130023257164,-.5047420673116668,.5047420415306929,.49521208229448166],RightHand:[.5009334695181179,-.5016127792807403,.49779599067075153,.49964931459617906],RightHandIndex1:[.5480286139806538,-.4638896746971551,.47756977858103167,.5063577013132781],RightHandIndex2:[.5522711446711094,-.4734474082706649,.4671498147721218,.5026083883587248],RightHandIndex3:[.5405470934413514,-.4690354263302402,.47905220274050364,.5082554503330304],RightHandMiddle1:[.5069366680435416,-.4631200623546733,.5184715098400317,.5096295939664325],RightHandMiddle2:[.5047591061928465,-.46656986723577604,.5196237819671778,.5074661920185282],RightHandMiddle3:[.5066805195140975,-.4663975225827095,.5160243369168757,.5093791249234989],RightHandPinky1:[.44593939683725603,-.4793433241517071,.5586434219640141,.5092009094272859],RightHandPinky2:[.4453638073881448,-.4803233923217868,.5573549834847424,.5101920690951159],RightHandPinky3:[.4392981269307416,-.4802964267888911,.5615019867791732,.5109285899785551],RightHandRing1:[.473719957983008,-.49312277921221886,.541841035805614,.4886999335659278],RightHandRing2:[.48665266754747677,-.4962049100848307,.5291888437972645,.4867330306200585],RightHandRing3:[.4894553112113337,-.49021320332208906,.5280743062058759,.4911843318554558],RightHandThumb1:[.6991137732035737,-.16132569450370315,.40704638897707807,.5652673641991798],RightHandThumb2:[.6476641963757893,-.2923511418798965,.5391394672107036,.45209571648691005],RightHandThumb3:[.6626871862817486,-.3080994479425299,.5067905521115058,.4572567801626834],RightLeg:[-.0006202113471683521,-.020805295090456907,.9997832430151556,.00047119017271936915],RightShoulder:[.46054507521936333,-.45599564278848104,.5375590232993736,.5394409245169026],RightToeBase:[.0027643555231566678,.7195640416379069,.6944146772223956,.0028643286020973192],RightUpLeg:[49925034443819034e-21,.002182648459062353,.9999975399486299,.00039198198974856475],Spine:[-.017258617754264162,-800818266828763e-22,13823133775055108e-25,.9998510589648868],Spine1:[-.055396652424023016,-5997624651397324e-23,332759956947242e-23,.9984644264570511],Spine2:[-.11221710079276989,7513757486198981e-23,-8485311473269302e-24,.9936837134066652]}),TF=Object.freeze({Head:[0,1.644459,-.02811],Hips:[0,.984089,.005022],LeftArm:[.204124,1.50826,-.034115],LeftFoot:[.095793,.088025,-.010018],LeftForeArm:[.458234,1.508259,-.045252],LeftHand:[.725837,1.508259,-.050352],LeftHandIndex1:[.815413,1.499602,-.024435],LeftHandIndex2:[.847794,1.497747,-.020782],LeftHandIndex3:[.872293,1.496601,-.017998],LeftHandMiddle1:[.820067,1.500491,-.048839],LeftHandMiddle2:[.854745,1.498698,-.047572],LeftHandMiddle3:[.881683,1.49736,-.046832],LeftHandPinky1:[.810112,1.495569,-.08743],LeftHandPinky2:[.8359,1.495002,-.089537],LeftHandPinky3:[.856018,1.494638,-.091171],LeftHandRing1:[.81666,1.499944,-.069059],LeftHandRing2:[.850313,1.498728,-.071468],LeftHandRing3:[.87354,1.497943,-.072665],LeftHandThumb1:[.761831,1.487283,-.024616],LeftHandThumb2:[.783931,1.477329,-.003377],LeftHandThumb3:[.806009,1.466616,.003515],LeftLeg:[.09541,.505427,.007362],LeftShoulder:[.056656,1.508576,-.035092],LeftToeBase:[.096919,.022281,.128921],LeftUpLeg:[.095072,.936186,.005482],Neck:[0,1.516499,-.057245],RightArm:[-.204124,1.50826,-.034115],RightFoot:[-.095793,.088025,-.010018],RightForeArm:[-.458234,1.508259,-.045252],RightHand:[-.725837,1.508259,-.050352],RightHandIndex1:[-.815413,1.499602,-.024435],RightHandIndex2:[-.847794,1.497747,-.020783],RightHandIndex3:[-.872293,1.496601,-.017998],RightHandMiddle1:[-.820067,1.500491,-.048839],RightHandMiddle2:[-.854745,1.498698,-.047572],RightHandMiddle3:[-.881683,1.49736,-.046832],RightHandPinky1:[-.810112,1.495569,-.08743],RightHandPinky2:[-.8359,1.495002,-.089537],RightHandPinky3:[-.856018,1.494638,-.091171],RightHandRing1:[-.81666,1.499944,-.069059],RightHandRing2:[-.850313,1.498729,-.071468],RightHandRing3:[-.87354,1.497943,-.072665],RightHandThumb1:[-.761831,1.487283,-.024615],RightHandThumb2:[-.783931,1.477329,-.003377],RightHandThumb3:[-.806009,1.466616,.003515],RightLeg:[-.09541,.505427,.007362],RightShoulder:[-.056656,1.508576,-.035092],RightToeBase:[-.096919,.022281,.128921],RightUpLeg:[-.095072,.936186,.005482],Spine:[0,1.077013,.005222],Spine1:[0,1.184494,.00151],Spine2:[0,1.330917,-.014788]}),RF=Object.freeze({Head:"Neck",Hips:null,LeftArm:"LeftShoulder",LeftFoot:"LeftLeg",LeftForeArm:"LeftArm",LeftHand:"LeftForeArm",LeftHandIndex1:"LeftHand",LeftHandIndex2:"LeftHandIndex1",LeftHandIndex3:"LeftHandIndex2",LeftHandMiddle1:"LeftHand",LeftHandMiddle2:"LeftHandMiddle1",LeftHandMiddle3:"LeftHandMiddle2",LeftHandPinky1:"LeftHand",LeftHandPinky2:"LeftHandPinky1",LeftHandPinky3:"LeftHandPinky2",LeftHandRing1:"LeftHand",LeftHandRing2:"LeftHandRing1",LeftHandRing3:"LeftHandRing2",LeftHandThumb1:"LeftHand",LeftHandThumb2:"LeftHandThumb1",LeftHandThumb3:"LeftHandThumb2",LeftLeg:"LeftUpLeg",LeftShoulder:"Spine2",LeftToeBase:"LeftFoot",LeftUpLeg:"Hips",Neck:"Spine2",RightArm:"RightShoulder",RightFoot:"RightLeg",RightForeArm:"RightArm",RightHand:"RightForeArm",RightHandIndex1:"RightHand",RightHandIndex2:"RightHandIndex1",RightHandIndex3:"RightHandIndex2",RightHandMiddle1:"RightHand",RightHandMiddle2:"RightHandMiddle1",RightHandMiddle3:"RightHandMiddle2",RightHandPinky1:"RightHand",RightHandPinky2:"RightHandPinky1",RightHandPinky3:"RightHandPinky2",RightHandRing1:"RightHand",RightHandRing2:"RightHandRing1",RightHandRing3:"RightHandRing2",RightHandThumb1:"RightHand",RightHandThumb2:"RightHandThumb1",RightHandThumb3:"RightHandThumb2",RightLeg:"RightUpLeg",RightShoulder:"Spine2",RightToeBase:"RightFoot",RightUpLeg:"Hips",Spine:"Hips",Spine1:"Spine",Spine2:"Spine1"});var T2=.5,R2=new Map(Object.entries(Zx).map(([i,e])=>[i,new Ft(e[0],e[1],e[2],e[3])])),C2=new Map(Object.entries(Qx).map(([i,e])=>[i,new Ft(e[0],e[1],e[2],e[3])])),$m=1e-6,ey="morphTargetInfluences[",ju=new j,ua=new Ft;function I2(i,e){for(let t=e?.parent;t;t=t.parent)if(t===i)return!0;return!1}function qm(i){let e=[],t=new Set,n=a=>{if(!a?.name||t.has(a))return;t.add(a);let o=Oi(a.name);o&&e.push({node:a,raw:a.name,canonical:o})},s=[];i.traverse(a=>{a.isSkinnedMesh&&s.push(a),a.isBone&&n(a)});for(let a of s)for(let o of a.skeleton?.bones||[])n(o);Jx(e,{isAncestor:(a,o)=>I2(a.node,o.node)});let r=new Set;return e.filter(a=>r.has(a.canonical)?!1:(r.add(a.canonical),!0))}function ty(i){let e=new Map;for(let{canonical:t,node:n}of qm(i))e.set(t,n.name);return e}function ny(i){let e=new Map;for(let{canonical:t,node:n}of qm(i))e.set(t,n.quaternion.clone());return e}function P2(i,e){let t=i.quaternion.clone();for(let n=i.parent;n&&n!==e;n=n.parent)t.premultiply(n.quaternion);return t}function iy(i){let e=new Map;for(let{canonical:t,node:n}of qm(i))e.set(t,P2(n,i));return e}function sy(i){let e=new Map;return i.traverse(t=>{if(!(!t?.morphTargetDictionary||!t.name))for(let n of Object.keys(t.morphTargetDictionary)){e.has(n)||e.set(n,[]);let s=e.get(n);s.includes(t.name)||s.push(t.name)}}),e}function L2(i,e){let t=new Map;if(!(i instanceof Map))return t;let n=e instanceof Map;for(let[s,r]of R2){let a=i.get(s);if(!a)continue;let o=C2.get(s),c=n?e.get(s):null,l,h=null;o&&c?(l=a.clone().multiply(c.clone().invert()).multiply(o).multiply(r.clone().invert()),h=o.clone().invert().multiply(c),1-Math.abs(h.w)<$m&&(h=null)):l=a.clone().multiply(r.clone().invert());let u=1-Math.abs(l.w)<$m;u&&!h||t.set(s,{L:u?null:l,R:h})}return t}function D2(i,{L:e,R:t}){for(let n=0;n<i.length;n+=4)ua.set(i[n],i[n+1],i[n+2],i[n+3]),e&&ua.premultiply(e),t&&ua.multiply(t),i[n]=ua.x,i[n+1]=ua.y,i[n+2]=ua.z,i[n+3]=ua.w}function N2(i,e){for(let t=0;t<i.length;t+=3)ju.set(i[t],i[t+1],i[t+2]).applyQuaternion(e),i[t]=ju.x,i[t+1]=ju.y,i[t+2]=ju.z}function O2(i,e){if(i){let t=i.isQuaternion?i.clone():new Ft(i[0],i[1],i[2],i[3]);return t.invert(),1-Math.abs(t.w)<$m?null:t}return e.get("Hips")?.L||null}function ry(i){let e=null;if(i.traverse(n=>{!e&&n.isBone&&n.name&&Oi(n.name)==="Hips"&&(e=n)}),e||i.traverse(n=>{!e&&n.name&&Oi(n.name)==="Hips"&&(e=n)}),!e||!e.parent)return null;let t=new Ft;for(let n=e.parent;n&&n!==i;n=n.parent)t.premultiply(n.quaternion);return t}function ay(i){try{return new ln().setFromObject(i).min.y}catch{return NaN}}var So=new j,F2=new Ft,Xu=new j;function jm(i){let e=null;if(i.traverse(r=>{!e&&r.isBone&&r.name&&Oi(r.name)==="Hips"&&(e=r)}),e||i.traverse(r=>{!e&&r.name&&Oi(r.name)==="Hips"&&(e=r)}),!e||!e.parent)return 0;e.updateWorldMatrix(!0,!1),e.getWorldPosition(So);let t=So.y,n=ay(i);Number.isFinite(n)&&(t-=n),e.parent.matrixWorld.decompose(So,F2,Xu);let s=(Xu.x+Xu.y+Xu.z)/3;return!(s>1e-6)||!(t>0)||!Number.isFinite(t)?0:t/s}function Xm(i){let e=null;if(i.traverse(s=>{!e&&s.isBone&&s.name&&Oi(s.name)==="Hips"&&(e=s)}),e||i.traverse(s=>{!e&&s.name&&Oi(s.name)==="Hips"&&(e=s)}),!e||!e.parent)return 0;e.updateWorldMatrix(!0,!1);let t=ay(i);if(!Number.isFinite(t))return 0;e.getWorldPosition(So);let n=e.parent.worldToLocal(new j(So.x,t,So.z));return Number.isFinite(n.y)?n.y:0}function oy(i){let e=i.tracks.find(t=>t.name.endsWith(".position")&&Oi(t.name.split(".")[0])==="Hips");return!e||e.values.length<3?0:e.values[1]}function cy(i,e,t={}){let n=Number.isFinite(t.hipScale)&&t.hipScale>0?t.hipScale:1,s=Number.isFinite(t.hipOffsetY)?t.hipOffsetY:0,r=t.minCoverage??T2,a=L2(t.targetRest,t.targetWorldRest),o=O2(t.hipsParentWorldQuat,a),c=[],l=[],h=[],u=0;for(let v of i.tracks){let _=v.name.indexOf(".");if(_===-1)continue;let g=v.name.slice(0,_),E=v.name.slice(_+1);if(E.startsWith(ey)){let I=E.slice(ey.length,-1),y=t.morphTargets instanceof Map?t.morphTargets.get(I):null;if(!y?.length){c.push(I);continue}for(let C of y){let k=v.clone();k.name=`${C}.${E}`,h.push(k)}continue}let L=Oi(g)||g;if(!(E==="quaternion"||E==="position"&&L==="Hips"))continue;u++;let M=e.get(L);if(!M){c.push(L);continue}let A=v.clone();if(A.name=`${M}.${E}`,E==="quaternion"){let I=a.get(L);I&&D2(A.values,I)}else{if(o&&N2(A.values,o),n!==1)for(let I=0;I<A.values.length;I++)A.values[I]*=n;if(s!==0)for(let I=1;I<A.values.length;I+=3)A.values[I]+=s}l.push(A)}let d=l.length,p=u>0?d/u:0;if(p<r)return{clip:null,matched:d,total:u,coverage:p,dropped:c,hipScale:n,face:0};let b=i.clone();return b.tracks=[...l,...h],{clip:b,matched:d,total:u,coverage:p,dropped:c,hipScale:n,face:h.length}}Qn();var k2=.6,U2=.38,B2=-.4,Km=new j,ly=new j,hy=new j,uy=new j,fy=new Ft,dy=new Ft,Ym=new Ft;function z2(i){for(let e of i.children)if(e.isBone)return e;return null}function py(i,e){if(!i||e&&(e.has("LeftArm")||e.has("RightArm")))return 0;i.updateMatrixWorld(!0);let t=[],n=1/0,s=-1/0;if(i.traverse(l=>{if(!l.isBone)return;let h=z2(l);if(!h)return;l.getWorldPosition(Km),h.getWorldPosition(ly);let u=ly.clone().sub(Km),d=u.length();if(d<1e-5)return;u.multiplyScalar(1/d);let p=Km.y;p<n&&(n=p),p>s&&(s=p),t.push({bone:l,worldY:p,dir:u})}),t.length===0||!Number.isFinite(n)||s<=n)return 0;let r=(n+s)/2,a=null,o=null;for(let l of t){let{dir:h,worldY:u}=l;u<r||Math.abs(h.y)>U2||h.y<B2||Math.abs(h.x)<k2||(h.x>0?(!a||h.x>a.dir.x)&&(a=l):(!o||h.x<o.dir.x)&&(o=l))}let c=0;for(let l of[a,o])l&&H2(l.bone,l.dir)&&c++;return c}function H2(i,e){let t=e.x>=0?1:-1;uy.set(t*.14,-1,.1).normalize(),hy.copy(e),fy.setFromUnitVectors(hy,uy),i.getWorldQuaternion(dy),i.parent?i.parent.getWorldQuaternion(Ym):Ym.identity();let n=fy.multiply(dy),s=Ym.invert().multiply(n);return i.quaternion.copy(s),i.updateMatrixWorld(!0),!0}var V2=45,my=new j,gy=new Ft,by=new j(0,1,0);function G2(i,e,t){if(!i||!e||!t)return null;let n=t.get("Hips");if(!n)return null;let s=e.getObjectByName(n);if(!s)return null;let r=i.tracks.find(d=>d.name===`${n}.quaternion`);if(!r||r.values.length<4)return null;let a=r.values,o=s.quaternion.x,c=s.quaternion.y,l=s.quaternion.z,h=s.quaternion.w;s.quaternion.set(a[0],a[1],a[2],a[3]),s.updateWorldMatrix(!0,!1),s.getWorldQuaternion(gy),my.copy(by).applyQuaternion(gy),s.quaternion.set(o,c,l,h),s.updateWorldMatrix(!0,!1);let u=Math.max(-1,Math.min(1,my.dot(by)));return Math.acos(u)*180/Math.PI}var W2=8,$2=Object.freeze(["Hips","LeftUpLeg","LeftLeg","LeftFoot","LeftToeBase","RightUpLeg","RightLeg","RightFoot","RightToeBase"]),_y=.35,Ku=new Map,Yu=class i{constructor(){this.model=null,this.mixer=null,this.clips=new Map,this.actions=new Map,this.currentName=null,this.currentAction=null,this.onChange=null,this._animationDefs=[],this._failed=new Set,this._canonicalToNode=null,this._canonicalClipsSupported=!1,this._avatarContext={},this._fallenReported=new Set,this._fallen=new Set,this._latestCrossfadeTarget=null,this.overlayAction=null,this.overlayName=null,this._overlayClips=new Map,this._overlayFinishHandler=null,this._settleFinishHandler=null}setAvatarContext(e){this._avatarContext=e&&typeof e=="object"?{...e}:{}}attach(e,t){this.detach(),t&&this.setAvatarContext(t),this.model=e,this.mixer=new ea(e),this.actions.clear(),this.currentAction=null,this.currentName=null,this._fallen.clear(),this._canonicalToNode=ty(e),this._canonicalRest=ny(e),this._canonicalWorldRest=iy(e),this._hipsParentWorldQuat=ry(e),this._morphTargets=sy(e),this._hipTargetLocalY=jm(e),this._hipGroundLocalY=Xm(e),this._canonicalClipsSupported=q2(e);for(let[n,s]of this.clips){let r=this._retarget(s);if(!r)continue;let a=this.mixer.clipAction(r);a.enabled=!0,this.actions.set(n,a)}}remeasureRigProportions(){if(!this.model||!this.mixer)return!1;let e=this.currentName;this._hipTargetLocalY=jm(this.model),this._hipGroundLocalY=Xm(this.model),this.mixer.stopAllAction();for(let t of this.actions.values()){let n=t.getClip?.();n&&this.mixer.uncacheClip(n)}this.actions.clear(),this.currentAction=null,this.currentName=null,this._latestCrossfadeTarget=null,this.overlayAction=null,this.overlayName=null,this._overlayClips.clear(),this._detachOverlayFinish?.();for(let[t,n]of this.clips){let s=this._retarget(n);if(!s)continue;let r=this.mixer.clipAction(s);r.enabled=!0,this.actions.set(t,r)}return e&&this.actions.has(e)&&this.play(e),!0}_retarget(e){if(!this._canonicalToNode||this._canonicalToNode.size===0)return null;let t=1,n=oy(e);this._hipTargetLocalY>.05&&n>.05&&(t=Math.min(200,Math.max(.2,this._hipTargetLocalY/n)));let{clip:s}=cy(e,this._canonicalToNode,{targetRest:this._canonicalRest,targetWorldRest:this._canonicalWorldRest,hipsParentWorldQuat:this._hipsParentWorldQuat,morphTargets:this._morphTargets,hipScale:t,hipOffsetY:this._hipGroundLocalY||0});return s}_guardAgainstFallenPose(e,t){if(this._fallen.has(e))return!1;let n=t?.getClip?.(),s=G2(n,this.model,this._canonicalToNode);if(s==null||!Number.isFinite(s)||s<=V2)return!0;try{t.stop()}catch(c){ci.warn("[AnimationManager] failed to stop fallen-pose action:",c)}t.enabled=!1,this.actions.delete(e),this._fallen.add(e),this.currentAction===t&&(this.currentAction=null,this.currentName=null);let r=this._avatarContext.avatarUrl||"",a=this._avatarContext.avatarId||"",o=`${a||r}|${e}`;return this._fallenReported.has(o)||(this._fallenReported.add(o),ci.warn(`[AnimationManager] "${e}" retargeted to a fallen pose (${s.toFixed(1)}\xB0 off vertical): falling back to bind pose`),j2({avatarId:a,avatarUrl:r,clip:e,tiltDeg:Math.round(s*10)/10})),!1}detach(){this.mixer&&(this.mixer.stopAllAction(),this.mixer.uncacheRoot(this.mixer.getRoot()),this.mixer=null),this.model=null,this._canonicalToNode=null,this._canonicalRest=null,this._canonicalWorldRest=null,this._hipsParentWorldQuat=null,this._morphTargets=null,this._hipTargetLocalY=0,this._hipGroundLocalY=0,this._canonicalClipsSupported=!1,this.actions.clear(),this.currentAction=null,this.currentName=null,this._latestCrossfadeTarget=null,this._fallen.clear(),this.overlayAction=null,this.overlayName=null,this._overlayClips.clear(),this._overlayFinishHandler=null}setAnimationDefs(e){this._animationDefs=e}appendAnimationDefs(e){let t=new Set(this._animationDefs.map(n=>n.name));for(let n of e)t.has(n.name)||(this._animationDefs.push(n),t.add(n.name))}getAnimationDefs(){return this._animationDefs}isFailed(e){return this._failed.has(e)}supportsCanonicalClips(){return this._canonicalClipsSupported}relaxUndrivenArms(){return this.model?py(this.model,this._canonicalToNode):0}canPlay(e){return this._fallen.has(e)?!1:this.clips.has(e)?!0:this._failed.has(e)?!1:this._animationDefs.some(t=>t.name===e)}async loadAnimation(e,t,n={}){if(this.clips.has(e))return this.clips.get(e);let s=Ku.get(t);s||(s=i._fetchClip(e,t),Ku.set(t,s),s.catch(()=>{Ku.get(t)===s&&Ku.delete(t)}));let r=await s;return this._registerParsedClip(e,r,n)}static async _fetchClip(e,t){let n=t.includes("/api/animations/"),s=new AbortController,r=setTimeout(()=>s.abort(),15e3),a;try{a=await fetch(t,{signal:s.signal,credentials:n?"include":"same-origin",redirect:"error"})}finally{clearTimeout(r)}if(!a.ok)throw new Error(`HTTP ${a.status} loading animation ${e}`);let o=await a.json(),c=n?o?.clip?.clip:o;if(!c&&o?.clip?.paywalled)throw new Error(`animation ${e} is a paid clip, unlock it at ${o.clip.download_url}`);if(!c)throw new Error(`clip payload missing from ${t}`);let l=Li.parse(c);return l.name=e,l}injectClip(e,t,n={}){if(!(!t||this.clips.has(e)))try{let s=Li.parse(t);s.name=e,this._registerParsedClip(e,s,n)}catch(s){ci.warn(`[AnimationManager] injectClip "${e}" parse error:`,s.message)}}_registerParsedClip(e,t,n){if(this.clips.set(e,t),this.model&&this.mixer){let s=this._retarget(t);if(s){let r=this.mixer.clipAction(s);r.enabled=!0,r.setLoop(n.loop===!1?ao:Cc),n.loop===!1&&(r.clampWhenFinished=!0),this.actions.set(e,r)}}return t}async loadAll(){let t=[...this._animationDefs],n=async()=>{let s;for(;s=t.shift();)try{await this.loadAnimation(s.name,s.url,{loop:s.loop!==!1})}catch(r){ci.warn(`[AnimationManager] failed to load "${s.name}":`,r.message),this._failed.add(s.name)}};await Promise.all(Array.from({length:4},n))}async ensureLoaded(e){if(this.clips.has(e))return!0;if(this._failed.has(e))return!1;let t=this._animationDefs.find(n=>n.name===e);if(!t)return!1;try{return await this.loadAnimation(t.name,t.url,{loop:t.loop!==!1}),!0}catch{return this._failed.add(e),!1}}async play(e){if(!await this.ensureLoaded(e))return(this._failed.has(e)||this._animationDefs.some(s=>s.name===e))&&ci.warn(`[AnimationManager] "${e}" unavailable`),!1;if(e===this.currentName)return!0;let n=this.actions.get(e);if(!n||!this._guardAgainstFallenPose(e,n))return!1;this.currentAction&&this.currentAction!==n&&this.currentAction.fadeOut(.01),n.reset().fadeIn(.01).play(),this.currentAction=n,this.currentName=e;try{this.onChange?.(e)}catch(s){ci.warn("[AnimationManager] onChange threw:",s)}return!0}async playOnce(e,{settleTo:t="idle",fade:n=_y}={}){n=Math.max(0,Math.min(n,5));let r=await this.ensureLoaded(e)?this.actions.get(e):null;if(!r||!this._guardAgainstFallenPose(e,r))return t?this.crossfadeTo(t,n):void 0;if(r.reset(),r.setLoop(ao,1),r.clampWhenFinished=!0,r.play(),this.currentAction&&this.currentAction!==r?this.currentAction.crossFadeTo(r,n,!0):r.fadeIn(n),this.currentAction=r,this.currentName=e,this._settleFinishHandler&&this.mixer&&(this.mixer.removeEventListener("finished",this._settleFinishHandler),this._settleFinishHandler=null),t&&this.mixer){let a=o=>{o.action===r&&(this.mixer.removeEventListener("finished",a),this._settleFinishHandler===a&&(this._settleFinishHandler=null),this.currentAction===r&&this.crossfadeTo(t,n))};this._settleFinishHandler=a,this.mixer.addEventListener("finished",a)}try{this.onChange?.(e)}catch(a){ci.warn("[AnimationManager] onChange threw:",a)}}freeze(){this.currentAction&&(this.currentAction.paused=!0),this.currentAction=null,this.currentName=null,this._latestCrossfadeTarget=null}async crossfadeTo(e,t=_y){if(t=Math.max(0,Math.min(t,5)),e===this.currentName)return;if(this._latestCrossfadeTarget=e,!await this.ensureLoaded(e)){(this._failed.has(e)||this._animationDefs.some(r=>r.name===e))&&ci.warn(`[AnimationManager] "${e}" unavailable`);return}if(this._latestCrossfadeTarget!==e||e===this.currentName)return;let s=this.actions.get(e);if(s&&this._guardAgainstFallenPose(e,s)){s.reset().play(),this.currentAction&&this.currentAction!==s?this.currentAction.crossFadeTo(s,t,!0):s.fadeIn(t),this.currentAction=s,this.currentName=e;try{this.onChange?.(e)}catch(r){ci.warn("[AnimationManager] onChange threw:",r)}}}_buildOverlayClip(e,t){let n=`${e}|${t?"upper":"full"}`,s=this._overlayClips.get(n);if(s)return s;let r=this.clips.get(e);if(!r)return null;let a=this._retarget(r);if(!a)return null;let o=a.tracks;if(t&&this._canonicalToNode){let l=new Set;for(let h of $2){let u=this._canonicalToNode.get(h);u&&l.add(u)}if(o=o.filter(h=>{let u=h.name.split(".")[0];return!l.has(u)}),o.length===0)return null}let c=new Li(`${e}__additive`,a.duration,o);return lc.makeClipAdditive(c),this._overlayClips.set(n,c),c}async playOverlay(e,{loop:t=!1,crossfade:n=.25,upperBodyOnly:s=!0,timeScale:r=1,onFinished:a=null}={}){if(n=Math.max(0,Math.min(n,5)),!await this.ensureLoaded(e)||!this.mixer)return!1;let c=this._buildOverlayClip(e,s);if(!c)return!1;let l=this.mixer.clipAction(c,void 0,Ic);this._detachOverlayFinish();let h=this.overlayAction;if(h&&h!==l&&h.fadeOut(n),l.enabled=!0,l.setLoop(t?Cc:ao,t?1/0:1),l.clampWhenFinished=!t,l.setEffectiveTimeScale(r),l.reset(),l.setEffectiveWeight(1),l.fadeIn(n),l.play(),this.overlayAction=l,this.overlayName=e,!t){let u=d=>{if(d.action===l){this.mixer.removeEventListener("finished",u),this._overlayFinishHandler===u&&(this._overlayFinishHandler=null),this.overlayAction===l&&(l.fadeOut(n),this.overlayAction=null,this.overlayName=null);try{a?.(e)}catch(p){ci.warn("[AnimationManager] overlay onFinished threw:",p)}}};this._overlayFinishHandler=u,this.mixer.addEventListener("finished",u)}return!0}_detachOverlayFinish(){this._overlayFinishHandler&&this.mixer&&this.mixer.removeEventListener("finished",this._overlayFinishHandler),this._overlayFinishHandler=null}stopOverlay({crossfade:e=.2}={}){e=Math.max(0,Math.min(e,5)),this._detachOverlayFinish(),this.overlayAction&&(this.overlayAction.fadeOut(e),this.overlayAction=null,this.overlayName=null)}hasOverlay(){return this.overlayAction!=null}setSpeed(e){this.currentAction?.setEffectiveTimeScale(e)}stopAll(){this.mixer?.stopAllAction(),this._detachOverlayFinish(),this.currentAction=null,this.currentName=null,this.overlayAction=null,this.overlayName=null;try{this.onChange?.(null)}catch(e){ci.warn("[AnimationManager] onChange threw:",e)}}update(e){this.mixer?.update(e)}getLoadedNames(){return[...this.clips.keys()]}isLoaded(e){return this.clips.has(e)}dispose(){this.detach(),this.clips.clear(),this._animationDefs=[],this._failed.clear()}};function q2(i){let e=!1,t=new Set;return i.traverse(n=>{if(n.isSkinnedMesh&&(e=!0),n.name){let s=Oi(n.name);s&&t.add(s)}}),e&&t.size>=W2}function j2(i){try{let e=typeof window<"u"&&typeof window.reportClientError=="function"?window.reportClientError:null;if(!e)return;e(new Error("fallen-pose retarget"),i)}catch(e){ci.warn("[AnimationManager] fallen-pose report failed:",e)}}var yy=la("ar-studio:idle"),Hc=null,xy="";function vy({manifestUrl:i=On.animationManifest,clip:e="idle"}={}){let t=`${i}#${e}`;return Hc&&xy===t||(xy=t,Hc=(async()=>{let n=await fetch(i,{cache:"force-cache"}).then(c=>{if(!c.ok)throw new Error(`HTTP ${c.status}`);return c.json()}),s=Array.isArray(n)?n:n?.clips||n?.animations||[],r=s.find(c=>c?.name===e)||s[0];if(!r?.url)throw new Error(`clip "${e}" missing from the manifest`);let a=new URL(r.url,i).href,o=await fetch(a,{cache:"force-cache"});if(!o.ok)throw new Error(`HTTP ${o.status}`);return o.json()})().catch(n=>(yy.warn("idle clip unavailable:",n?.message||n),Hc=null,null))),Hc}async function Jm(i,{manifestUrl:e,clip:t="idle",sourceUrl:n=""}={}){let s=await vy({manifestUrl:e,clip:t});if(!s||!i)return null;let r=new Yu;try{if(r.attach(i,{avatarUrl:n}),!r.supportsCanonicalClips()||(r.relaxUndrivenArms(),r.injectClip(t,s,{loop:!0}),!await r.play(t)))return r.detach(),null;let o=r.currentAction,c=o?.getClip?.()?.duration||0;return o&&c>0&&(o.time=Math.random()*c),r.update(0),r}catch(a){yy.warn("idle mount failed:",a?.message||a);try{r.detach()}catch{}return null}}async function Zm({canvas:i,video:e,isAR:t}){if(!i)return null;let n=i.width,s=i.height;if(!n||!s)return null;let r=document.createElement("canvas");r.width=n,r.height=s;let a=r.getContext("2d");if(!a)return null;if(t&&e&&!e.paused&&e.videoWidth)try{a.drawImage(e,0,0,n,s)}catch{}try{a.drawImage(i,0,0)}catch{return null}return new Promise(o=>r.toBlob(o,"image/png"))}async function Qm(i,{filename:e="ar-studio.png",title:t="AR Studio"}={}){let n=new File([i],e,{type:"image/png"});if(navigator.share&&navigator.canShare?.({files:[n]}))return await navigator.share({title:t,files:[n]}),"shared";let s=URL.createObjectURL(i),r=document.createElement("a");return r.href=s,r.download=e,r.click(),setTimeout(()=>URL.revokeObjectURL(s),4e3),"downloaded"}async function eg(i,{title:e="AR Studio",text:t=""}={}){if(navigator.share)try{return await navigator.share({title:e,url:i,...t?{text:t}:{}}),"shared"}catch(n){if(n?.name==="AbortError")throw n}return await navigator.clipboard.writeText(i),"copied"}function nv(){return typeof navigator>"u"?!1:/iphone|ipad|ipod/i.test(navigator.userAgent)||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1}function Rg(){return nv()}function iv(){return typeof navigator<"u"&&/android/i.test(navigator.userAgent)}function Cg(){return iv()}var hf=null,sv="_apple_ar_quicklook_button_tapped";function rv(i){return`${String(i||"").trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,60)||"model"}.usdz`}function av(i,{onBannerTap:e,name:t=""}={}){hf&&(hf.remove(),hf=null);let n=document.createElement("a");n.rel="ar",n.appendChild(document.createElement("img")),n.href=i,/^blob:/i.test(i)&&n.setAttribute("download",rv(t)),n.style.cssText="position:fixed;left:0;top:0;width:1px;height:1px;opacity:0;pointer-events:none;overflow:hidden;",n.setAttribute("aria-hidden","true"),typeof e=="function"&&n.addEventListener("message",s=>{s.data===sv&&e()}),document.body.appendChild(n),hf=n,n.click()}function ov(i,{title:e="",link:t="",fallbackUrl:n=""}={}){let s=new URLSearchParams({file:i,mode:"ar_preferred"});e&&s.set("title",e),t&&s.set("link",t);let r=encodeURIComponent(n||location.href);location.href=`intent://arvr.google.com/scene-viewer/1.2?${s.toString()}#Intent;scheme=https;package=com.google.ar.core;action=android.intent.action.VIEW;S.browser_fallback_url=${r};end;`}async function Ig(){try{if(navigator.xr&&await navigator.xr.isSessionSupported("immersive-ar"))return"webxr"}catch{}return Rg()?"quicklook":Cg()?"sceneviewer":"none"}var TI=4,li=new Map;function RI(){for(;li.size>TI;){let[i,e]=li.entries().next().value;li.delete(i),e.href&&URL.revokeObjectURL(e.href)}}function CI(){for(let i of li.values())i.href&&URL.revokeObjectURL(i.href);li.clear()}function uf(i){let e=li.get(i);return e?(li.delete(i),e.href&&URL.revokeObjectURL(e.href),!0):!1}function ff(i){return!!(i&&li.get(i)?.href)}async function cv(i,e){let t=li.get(i);if(t)return li.delete(i),li.set(i,t),t.promise;let n={href:"",promise:null};return n.promise=(async()=>{let s=await e();return n.href=URL.createObjectURL(s),n.href})(),n.promise.catch(()=>{li.get(i)===n&&li.delete(i)}),li.set(i,n),RI(),n.promise}async function jc({src:i="",title:e="",usdz:t="",key:n="",build:s}={},{onProgress:r,fallbackUrl:a="",signal:o}={}){if(!i&&!t&&!s)throw new Error("ar-studio: nothing to place");if(Rg()){let c=t;if(!c){let l=n||i;if(!l)throw new Error("ar-studio: a cache key or src is required");c=await cv(l,async()=>{if(s)return r?.("convert"),s();let{glbUrlToUsdzBlob:h}=await Promise.resolve().then(()=>(lf(),Tg));return h(i,{signal:o,onProgress:r})})}return{viewer:"quicklook",href:c,open:l=>av(c,{name:e,...l})}}if(Cg()){if(!i)throw new Error("ar-studio: Scene Viewer needs a GLB URL");return{viewer:"sceneviewer",href:i,open:()=>ov(i,{title:e,fallbackUrl:a})}}return null}async function Pg(i={},e={}){let t=await jc(i,e);return t?(e.onProgress?.("open"),t.open(),t.viewer):"none"}var II=80;function PI(i,{title:e,subtitle:t,callToAction:n}={}){if(typeof i!="string"||!i)return i;let s=[],r=(o,c)=>{let l=typeof c=="string"?c.trim().slice(0,II):"";l&&s.push(`${o}=${encodeURIComponent(l)}`)};if(!n||typeof n!="string"||!n.trim()||(r("checkoutTitle",e),r("checkoutSubtitle",t),r("callToAction",n),!s.length))return i;let a=s.join("&");return i.includes("#")?`${i}&${a}`:`${i}#${a}`}var LI=Math.PI/180,DI=180/Math.PI;function lv({trackWidth:i,trackHeight:e,viewWidth:t,viewHeight:n,diagFovDeg:s=72}){let r=Xc(i,t),a=Xc(e,n),o=Xc(t,r),c=Xc(n,a),l=Xc(s,72),h=Math.hypot(r,a)||1,u=2*Math.atan(r/h*Math.tan(l*LI/2)),d=o/c,b=2*Math.atan(Math.tan(u/2)/(d||1))*DI;return Number.isFinite(b)?Math.max(50,Math.min(90,b)):50}function Xc(i,e){let t=Number(i);return Number.isFinite(t)&&t>0?t:Number(e)>0?Number(e):1}var hv=Math.PI/180;function NI(i,e,t){let n=(e-i+Math.PI)%(Math.PI*2)-Math.PI;return n<-Math.PI&&(n+=Math.PI*2),i+n*t}function uv(i,e){return Number.isFinite(i)&&Number.isFinite(e)}function fv({useAbsolute:i,prevYaw:e,alpha:t,baseAlpha:n,baseYaw:s,compassHeading:r,absoluteSmooth:a=.4}){if(i){let c=-r*hv;return NI(e,c,a)}let o=t-n;return o>180&&(o-=360),o<-180&&(o+=360),s+o*hv}function df(i,e,t){let n=Number.isFinite(i)?i:0;return n<e?e:n>t?t:n}function Lg(i,e,t=0){let n=(Math.round(Number(t)/90)*90%360+360)%360,s;switch(n){case 90:s=e;break;case 180:s=-i;break;case 270:s=-e;break;default:s=i;break}return Number.isFinite(s)?s:0}sf();var Dg=Math.PI*2;function dv(i){return Number.isFinite(i)?(i%Dg+Dg)%Dg:0}function Ng(i){return Number.isFinite(i)?(i%360+360)%360:0}function Og(i){return{relEast:Number(i.x)||0,relNorth:-(Number(i.z)||0)||0,yawDeg:Ng(dv(i.yaw)*180/Math.PI),scale:Number(i.scale)||1,height:Number(i.height)||0}}function mf(i){return{x:Number(i.relEast)||0,z:-(Number(i.relNorth)||0),yaw:Ng(i.yawDeg)*Math.PI/180,scale:Number(i.scale)||1}}var pf="ABCDEFGHJKMNPQRSTUVWXYZ23456789",pv=6;function da(i){let e=String(i??"").trim();if(!e)return"";let t=e.match(/[?&]room=([^&#\s]+)/i);if(t)try{e=decodeURIComponent(t[1])}catch{e=t[1]}if(e=e.toUpperCase().replace(/[\s-]+/g,""),e.length!==pv)return"";for(let n of e)if(!pf.includes(n))return"";return e}function Fg(i=Math.random){let e="";for(let t=0;t<pv;t++)e+=pf[Math.floor(i()*pf.length)%pf.length];return e}function kg(i){return`c-${da(i)}`}function Kc(i,e){let t=String(i||"").split("#")[0],n=da(e);return n?`${t}${t.includes("?")?"&":"?"}room=${n}`:t}var Or=la("ar-studio:net"),fL="studio_world",dL=1,pL=15e3,vl=null;async function mL(){if(vl!==null)return vl;try{let[i,e]=await Promise.all([Promise.resolve().then(()=>w1(mw(),1)),Promise.resolve().then(()=>(m1(),p1))]);vl={Client:i.Client,getStateCallbacks:i.getStateCallbacks,StudioState:e.StudioState}}catch(i){Or.warn('shared rooms need the optional "colyseus.js" dependency:',i?.message||i),vl=!1}return vl}async function gL(i,e,t){let n,s=new Promise((a,o)=>{n=setTimeout(()=>o(new Error("connect_timeout")),pL)}),r=i.joinOrCreate(fL,e,t);try{return await Promise.race([r,s])}finally{clearTimeout(n),r.then(a=>{try{a&&a.connection?.isOpen&&a.leave()}catch{}}).catch(()=>{})}}var cd=class{constructor({roomKey:e,clientId:t="",name:n="",url:s=""}={}){this.roomKey=String(e||"").slice(0,64),this.clientId=String(t||"").slice(0,80),this.name=String(n||"").slice(0,120),this.url=String(s||"").replace(/\/$/,""),this.status="idle",this.error="",this.room=null,this.client=null,this._listeners={status:[],models:[],model:[],presence:[],reject:[]},this._retries=0,this._reconnectTimer=null,this._connectGen=0,this._destroyed=!1,this._presenceQueued=!1,this._modelsQueued=!1,this._selfHandle=""}on(e,t){return(this._listeners[e]||=[]).push(t),this}_emit(e,t){for(let n of this._listeners[e]||[])try{n(t)}catch(s){Or.warn(`${e} listener error:`,s?.message||s)}}_setStatus(e,t=""){this.status=e,this.error=t,this._emit("status",{status:e,error:t})}_closeRoom(){let e=this.room;if(e){this.room=null;try{e.removeAllListeners()}catch{}try{e.leave()}catch{}}}async connect(){if(this._destroyed)return;if(this._closeRoom(),!this.url||!this.roomKey){this._setStatus("unavailable");return}let e=await mL();if(!e){this._setStatus("unavailable","colyseus.js is not installed");return}let t=++this._connectGen;this._setStatus("connecting");try{this.client=new e.Client(this.url);let n=await gL(this.client,{roomKey:this.roomKey,clientId:this.clientId,name:this.name},e.StudioState);if(this._destroyed||t!==this._connectGen){try{n.leave()}catch{}return}this.room=n,this._retries=0;let s=e.getStateCallbacks(this.room),r=s(this.room.state)?.models;r&&(r.onAdd((o,c)=>{s(o).onChange(()=>this._emit("model",this._modelShape(o,c))),this._queueModels()}),r.onRemove((o,c)=>{this._emit("model",{id:c,removed:!0}),this._queueModels()}));let a=s(this.room.state)?.viewers;a&&(a.onAdd(()=>this._queuePresence()),a.onRemove(()=>this._queuePresence())),this.room.onMessage("self",o=>{this._selfHandle=String(o?.ownerId||""),this._queueModels()}),this.room.onMessage("model:reject",o=>this._emit("reject",o)),this.room.onLeave(o=>{this._destroyed||o===1e3||(this._setStatus("offline"),this._scheduleReconnect())}),this.room.onError((o,c)=>Or.warn("room error",o,c)),this._setStatus("online"),this._queueModels(),this._queuePresence()}catch(n){let s=n?.message||(n?.code!=null?`code ${n.code}`:String(n));Or.warn("connect failed:",s),this._setStatus("failed",s),this._scheduleReconnect()}}_scheduleReconnect(){if(this._reconnectTimer||this._destroyed)return;if(this._retries>=dL){this._setStatus("unavailable",this.error);return}this._retries++;let e=2500+Math.random()*1500;this._reconnectTimer=setTimeout(()=>{this._reconnectTimer=null,this._destroyed||this.connect()},e)}_modelShape(e,t){return{id:t??e.id,src:e.src,title:e.title,relEast:e.relEast,relNorth:e.relNorth,yawDeg:e.yawDeg,scale:e.scale,height:e.height,ownerId:e.ownerId,mine:!!this._selfHandle&&e.ownerId===this._selfHandle}}_queueModels(){this._modelsQueued||this._destroyed||(this._modelsQueued=!0,Promise.resolve().then(()=>{this._modelsQueued=!1;let e=this.room?.state?.models;if(this._destroyed||!e)return;let t=[];e.forEach((n,s)=>t.push(this._modelShape(n,s))),this._emit("models",t)}))}_queuePresence(){this._presenceQueued||this._destroyed||(this._presenceQueued=!0,Promise.resolve().then(()=>{this._presenceQueued=!1;let e=this.room?.state?.viewers;if(this._destroyed||!e)return;let t=0,n=[];e.forEach(s=>{t++,s.name&&n.push(s.name)}),this._emit("presence",{count:t,names:n})}))}_live(){return this.status==="online"&&this.room&&this.room.connection?.isOpen===!0}spawn(e){if(!this._live())return!1;try{return this.room.send("model:spawn",{id:e.id,src:String(e.src||""),title:String(e.title||"").slice(0,120),relEast:Number(e.relEast)||0,relNorth:Number(e.relNorth)||0,yawDeg:Number(e.yawDeg)||0,scale:Number(e.scale)||1,height:Number(e.height)||0}),!0}catch(t){return Or.warn("spawn failed:",t?.message||t),!1}}update(e,t){if(!this._live()||!e)return!1;let n={id:String(e)};for(let s of["relEast","relNorth","yawDeg","scale"])Number.isFinite(t?.[s])&&(n[s]=t[s]);try{return this.room.send("model:update",n),!0}catch(s){return Or.warn("update failed:",s?.message||s),!1}}remove(e){if(!this._live()||!e)return!1;try{return this.room.send("model:remove",{id:String(e)}),!0}catch(t){return Or.warn("remove failed:",t?.message||t),!1}}heartbeat(){if(this._live())try{this.room.send("heartbeat",{})}catch(e){Or.warn("heartbeat failed:",e?.message||e)}}destroy(){this._destroyed=!0,this._reconnectTimer&&(clearTimeout(this._reconnectTimer),this._reconnectTimer=null),this._closeRoom(),this.client=null,this._setStatus("destroyed")}};var Ei=la("ar-studio"),yL=1.55,Y0=-1.25,J0=1.35,Z0=1,Q0=1.15,ld=60,Sl=class{constructor(e,t={}){if(!e)throw new Error("ar-studio: a host element is required");this.host=e,this.config=$p(t),this.clientId=ML(this.config.persistKey),this.sources=am(this.config.assets,this.config),this._listeners=new Map,this._destroyed=!1,this.ui=Tx(e,this.config),(this.config.fullscreen??e===document.body)&&this.ui.root.classList.add("is-fullscreen"),this._initScene(),this._initState(),this._wireUI(),this._boot()}on(e,t){return this._listeners.has(e)||this._listeners.set(e,new Set),this._listeners.get(e).add(t),()=>this.off(e,t)}off(e,t){this._listeners.get(e)?.delete(t)}_emit(e,t={}){for(let n of this._listeners.get(e)||[])try{n(t)}catch(s){Ei.warn(`${e} listener error`,s)}try{this.config.onEvent?.(e,t)}catch(n){Ei.warn("onEvent error",n)}try{this.ui.root.dispatchEvent(new CustomEvent(`ar-studio:${e}`,{detail:t,bubbles:!0}))}catch{}}_initScene(){this.renderer=new wu({canvas:this.ui.canvas,alpha:!0,antialias:!0,preserveDrawingBuffer:!0}),this.renderer.setClearColor(0,0),this.qualityTier=lm(),hm(this.renderer,{tier:this.qualityTier}),this.scene=new cr,this.camera=new fn(58,1,.02,200),this.camera.position.set(0,yL,0),this.cameraYaw=0,this.cameraPitch=-.24;let e=this.qualityTier==="mobile"?null:this.config.lighting?.preset??"studio";if(um(this.renderer,this.scene,e,{urls:this.config.lighting?.urls}).catch(t=>Ei.warn("environment map failed",t)),this.hemi=new eo(16777215,4473941,Z0),this.sun=new Yi(16777215,Q0),this.sun.position.set(2.5,6,3),this.scene.add(this.hemi,this.sun),this.grid=new xc(24,48,3817298,2303802),this.grid.position.y=.001,this.grid.material.transparent=!0,this.grid.material.opacity=.75,this._fog=new Yo(395018,5,17),this.scene.fog=this._fog,this.scene.add(this.grid),this.rayPlane=new vt(new Ii(80,80),new Sn({visible:!1,side:2})),this.rayPlane.rotation.x=-Math.PI/2,this.scene.add(this.rayPlane),this.selRing=new vt(new gr(.3,.34,48).rotateX(-Math.PI/2),new Sn({color:9141496,transparent:!0,opacity:.85,depthTest:!1})),this.config.branding?.accent)try{this.selRing.material.color.set(this.config.branding.accent)}catch{}this.selRing.renderOrder=998,this.selRing.visible=!1,this.scene.add(this.selRing),this.shadowTex=SL(),this.reducedMotion=vL(),this._applyCameraLook()}_initState(){this.placements=[],this.selected=null,this.arActive=!1,this.mediaStream=null,this.arTransitioning=!1,this.xrSession=null,this.estimatedLight=null,this.arMode="none",this._cameraYielded=!1,this._cameraWasOn=!1,this._onArReturn=null,this._nativeArBusy=!1,this._arHandoff=null,this._arTarget=null,this._arToken=0,this._arWarmTimer=null,this._arRetry=null,this._arKeys=new Set,this.arTrackW=0,this.arTrackH=0,this._statusTimer=null,this._armed=null,this._templates=new Map,this._templatesReady=new Map,this._trayCache=new Map,this._trayTab=this.sources[0]?.id||"link",this._loadQueue=Dx({run:e=>$u().loadAsync(e),maxActive:3}),this._maxPlacements=Math.min(Number(this.config.maxPlacements)||20,20),this.net=null,this.roomCode="",this._netModels=new Map,this._presence={count:1,names:[]},this._roomSynced=!1,this._roomHeartbeat=null,this.forge=this.config.generate?.enabled===!1?null:Zp({endpoint:this.config.generate.endpoint,kind:this.config.generate.kind,tier:this.config.generate.tier,timeoutMs:this.config.generate.timeoutMs,pollMs:this.config.generate.pollMs,headers:this.config.generate.headers}),this._forgeSeq=0,this._forgeBusy=!1,this.gyroBase=null,this._devAlpha=0,this._devBeta=90,this._devGamma=0,this._absoluteOrientation=!1,this._raycaster=new _c,this._ndc=new dt,this._pointer=null,this._userLooked=!1,this._pinch=Bc(),this._pinchEndedAt=-1/0,this._twist=null,this._rafId=null,this._prevT=0,this._lightTimer=null,this._roomTint=new He,this._lightProbe=wL(),this._recentKey=`${this.config.persistKey}:recent`,this.config.recentKey=this._recentKey}_wireUI(){let e=this.ui,t=(s,r,a,o)=>{s&&s.addEventListener(r,a,o)};t(e.cameraBtn,"click",()=>{this.arTransitioning||this.xrSession||(this.arActive?(this._stopCamera(),this._setStatus("Camera off: preview mode.")):this._startCamera())}),!navigator.mediaDevices?.getUserMedia&&e.cameraBtn&&(e.cameraBtn.disabled=!0,e.cameraBtn.setAttribute("aria-disabled","true"),e.cameraBtn.title="This browser cannot open a camera"),t(e.xrBtn,"click",()=>this._enterAR()),t(e.addBtn,"click",()=>e.tray.hidden?this._openTray():this._closeTray()),t(e.trayClose,"click",()=>this._closeTray()),t(e.tray,"click",s=>{s.target===e.tray&&this._closeTray()}),t(e.emptyAdd,"click",()=>this._openTray()),t(e.emptyCamera,"click",()=>this._startCamera()),t(e.emptyForge,"click",()=>e.forgeInput?.focus()),t(e.forgeForm,"submit",s=>{s.preventDefault(),this._startForge(e.forgeInput?.value)}),t(e.clearBtn,"click",()=>this._clearWithUndo()),t(e.photoBtn,"click",()=>this._capturePhoto()),t(e.qrBtn,"click",()=>this._openQr()),t(e.qrClose,"click",()=>this._closeQr()),t(e.qrModal,"click",s=>{s.target===e.qrModal&&this._closeQr()}),t(e.arClose,"click",()=>this._closeArSheet()),t(e.arModal,"click",s=>{s.target===e.arModal&&this._closeArSheet()}),t(e.arGo,"click",()=>this._onArGo()),t(e.arXr,"click",()=>{this._closeArSheet(),this._toggleXR()}),t(e.arQr,"click",()=>{this._closeArSheet(),this._openQr()}),t(e.arPicker,"click",s=>{let r=s.target.closest("[data-ar-id]");if(!r)return;let a=this.placements.find(o=>o.id===r.dataset.arId);a&&this._showArTarget(a)}),t(e.selbar,"click",s=>this._onSelbarClick(s)),t(e.roomBtn,"click",()=>this._openRoomModal()),t(e.roomClose,"click",()=>this._closeRoomModal()),t(e.roomModal,"click",s=>{s.target===e.roomModal&&this._closeRoomModal()}),t(e.roomCreate,"click",()=>this._createRoomFromUI()),t(e.roomJoinForm,"submit",s=>{s.preventDefault(),this._joinRoomFromUI()}),t(e.roomCopy,"click",()=>this._copyRoomInvite()),t(e.roomLeave,"click",()=>{this._leaveRoom(),this._renderRoomModal()});let n=e.canvas;t(n,"pointerdown",s=>this._onPointerDown(s)),t(n,"pointermove",s=>this._onPointerMove(s)),t(n,"pointerup",s=>this._onPointerUp(s)),t(n,"pointercancel",()=>{this._pointer=null}),t(n,"touchstart",s=>this._onTouchStart(s),{passive:!0}),t(n,"touchmove",s=>this._onTouchMove(s),{passive:!0}),t(n,"touchend",()=>this._onTouchEnd(),{passive:!0}),this._onKeyDown=this._onKeyDown.bind(this),document.addEventListener("keydown",this._onKeyDown),this._onOrientationAbsolute=s=>{this._absoluteOrientation=!0,this._onDeviceOrientation(s)},this._onOrientation=s=>{this._absoluteOrientation||this._onDeviceOrientation(s)},window.addEventListener("deviceorientationabsolute",this._onOrientationAbsolute,!0),window.addEventListener("deviceorientation",this._onOrientation,!0),this._onResize=()=>this._resize(),window.addEventListener("resize",this._onResize),this._onPageHide=()=>{this._stopCamera(),this.xrSession?.end(),this.net?.destroy()},window.addEventListener("pagehide",this._onPageHide),typeof ResizeObserver<"u"&&(this._ro=new ResizeObserver(()=>this._resize()),this._ro.observe(e.root)),this._wireTrayTabs()}_boot(){this._resize(),this._updateCount(),this._updateRoomButton(),this._startLoop(),Ig().then(n=>{this.arMode=n;let s=this.ui.xrBtn;if(!s||n==="none")return;s.hidden=!1;let r=s.querySelector(".ars-ar-label");n==="webxr"?(r&&(r.textContent="Immersive AR"),s.setAttribute("aria-label","Enter immersive augmented reality and place models on real surfaces")):(r&&(r.textContent="Place in your space"),s.setAttribute("aria-label","Open this in your device AR viewer and place it in your real space"))}),!window.matchMedia?.("(pointer: coarse)").matches&&this.ui.qrBtn&&(this.ui.qrBtn.hidden=!1);let t=da(this.config.urlRoom||"");this._restoreScene({skipLocal:!!t}).then(()=>{t&&this._joinRoom(t),this.config.urlPrompt&&this.config.urlPrompt.length>=3&&this.ui.forgeInput&&(this.ui.forgeInput.value=this.config.urlPrompt,this._startForge(this.config.urlPrompt))})}_setStatus(e,{warn:t=!1,sticky:n=!1,actionLabel:s="",onAction:r=null}={}){let a=this.ui.status;if(a){if(clearTimeout(this._statusTimer),a.textContent="",!e){a.hidden=!0;return}a.hidden=!1,a.classList.toggle("is-warn",t),a.appendChild(le("span",{text:e})),s&&r&&a.appendChild(le("button",{type:"button",class:"ars-status-action",text:s,onclick:()=>{this._setStatus(null),r()}})),n||(this._statusTimer=setTimeout(()=>{a.hidden=!0},5200))}}_updateCount(){let e=this.placements.length,{count:t,clearBtn:n,empty:s,photoBtn:r}=this.ui;t&&(this.net&&this.net.status==="online"&&this._presence.count>1?(t.textContent=`${this._presence.count} here \xB7 ${e} ${e===1?"model":"models"}`,t.hidden=!1):(t.textContent=e===1?"1 model":`${e} models`,t.hidden=e===0)),n&&(n.hidden=e===0),s&&(s.hidden=e>0),r&&(r.disabled=e===0)}_logicalScale(e){return e.spawnT<1?e.group.userData._targetScale??1:e.group.scale.x}_saveScene(){if(this.config.persist!==!1)try{localStorage.setItem(this.config.persistKey,ef(this.placements.filter(e=>this._isMine(e)).map(e=>({src:e.src,title:e.title,x:e.group.position.x,z:e.group.position.z,yaw:e.yaw,scale:this._logicalScale(e)}))))}catch{}}_select(e){this.selected=e;let{selbar:t,selName:n}=this.ui;if(t){if(!e){t.hidden=!0,this.selRing.visible=!1,this._emit("select",{placement:null});return}t.hidden=!1,n&&(n.textContent=e.title||"Model"),this.selRing.visible=!this.xrSession,this._positionSelRing(),this._warmQuickLook(),this._emit("select",{placement:eb(e,this)})}}_positionSelRing(){let e=this.selected;if(!e)return;this.selRing.position.set(e.group.position.x,e.group.position.y+.006,e.group.position.z);let t=Math.max(.24,e.baseRadius*e.group.scale.x*1.15);this.selRing.scale.setScalar(t/.34)}_loadTemplate(e){let t=this._templates.get(e);return t||(t=this._loadQueue.request(e).then(n=>{let s=!1;n.scene.traverse(l=>{l.isSkinnedMesh&&(s=!0)});let r=new ln().setFromObject(n.scene),a=Vc({min:{x:r.min.x,y:r.min.y,z:r.min.z},max:{x:r.max.x,y:r.max.y,z:r.max.z}},{skinned:s}),o=Math.max((r.max.x-r.min.x)*a.scale,(r.max.z-r.min.z)*a.scale)/2,c=(r.max.y-r.min.y)*a.scale;return{gltf:n,skinned:s,fit:a,radius:Number.isFinite(o)?o:.3,height:Number.isFinite(c)?c:.75}}),this._templates.set(e,t),t.then(n=>this._templatesReady.set(e,n)).catch(()=>this._templates.delete(e))),t}_instantiate(e,t){let n=aa(e.gltf.scene);n.scale.setScalar(e.fit.scale),n.position.y=e.fit.yOffset;let s=new vn;s.add(n);let r=null;e.gltf.animations?.length&&(r=new ea(n),r.clipAction(e.gltf.animations[0]).play());let a=null;return!r&&e.skinned&&this.config.animations?.enabled!==!1&&(a=Jm(n,{manifestUrl:this.config.animations?.manifestUrl,clip:this.config.animations?.clip,sourceUrl:t}).catch(()=>null)),{group:s,mixer:r,idlePromise:a}}_makeShadow(e){if(!this.shadowTex)return null;let t=Math.max(.4,e*2.4),n=new vt(new Ii(t,t).rotateX(-Math.PI/2),new Sn({map:this.shadowTex,transparent:!0,opacity:.85,depthWrite:!1}));return n.renderOrder=1,n}_nudgeSpawn(e){let{x:t,z:n}=e;for(let s=0;s<8&&this.placements.some(o=>Math.hypot(o.group.position.x-t,o.group.position.z-n)<.45);s++){let a=s*2.399963;t=e.x+Math.cos(a)*.55*(1+s*.18),n=e.z+Math.sin(a)*.55*(1+s*.18)}return{x:t,z:n}}async _addModel({src:e,title:t="",poster:n=""}={},{x:s=null,z:r=null,yaw:a=null,scale:o=null,announce:c=!0,persist:l=!0,remote:h=!1,netId:u=null,ownerId:d=null}={}){let p=Er(e);if(!p)return this._setStatus("That link is not a loadable https GLB.",{warn:!0}),null;if(this.placements.length>=this._maxPlacements)return this._setStatus(`Scene is full (${this._maxPlacements} models). Remove one to add more.`,{warn:!0}),null;c&&this._setStatus(`Loading ${t||"model"}\u2026`,{sticky:!0});let b;try{b=await this._loadTemplate(p)}catch(I){return Ei.warn("model load failed",p,I),this._setStatus(`Couldn't load ${t||"that model"}: the file may be gone or blocked by CORS.`,{warn:!0,actionLabel:"Retry",onAction:()=>this._addModel({src:p,title:t})}),null}let{group:v,mixer:_,idlePromise:g}=this._instantiate(b,p),E=s,L=r;if(E===null||L===null){let I=Math.max(1.6,(b.height||0)*1.15),y=this.camera.getWorldDirection(new j),C=this._nudgeSpawn(ig(this.camera.position,y,I));E=C.x,L=C.z}v.position.set(E,0,L);let S=a??Math.atan2(this.camera.position.x-E,this.camera.position.z-L);v.rotation.y=S,o&&v.scale.setScalar(Math.min(4,Math.max(.25,o))),this.scene.add(v);let M=this._makeShadow(b.radius);M&&(M.position.set(E,.004,L),M.scale.setScalar(v.scale.x),M.visible=!this.xrSession,this.scene.add(M));let A={id:`p-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,7)}`,src:p,title:String(t||"").slice(0,160),poster:n,group:v,shadow:M,mixer:_,idle:null,yaw:S,baseRadius:b.radius,height:b.height||0,spawnT:this.reducedMotion?1:0,netId:u||null,ownerId:h?d:null,remote:h,_lastNetSend:0};if(g?.then(I=>{I&&(this.placements.includes(A)?A.idle=I:I.detach())}),v.userData._targetScale=v.scale.x,this.reducedMotion||v.scale.setScalar(.001),this.placements.push(A),A.netId&&this._netModels.set(A.netId,A),h||(this._armed={src:p,title:A.title}),this._updateCount(),h||this._select(A),l&&this._saveScene(),!h&&this.net&&this.net.status==="online"){let I=`m${Date.now().toString(36)}${Math.random().toString(36).slice(2,6)}`.slice(0,40);A.netId=I,A.ownerId=this.clientId,this._netModels.set(I,A),this.net.spawn(this._placementWire(A,I))}return c&&this._setStatus(h?`${t||"A model"} was added by someone in the room.`:"Placed. Drag to move, pinch to resize, twist to rotate."),h||this._framePreview(),this._emit("add",{placement:eb(A,this),remote:h}),A}_removePlacement(e,{persist:t=!0,broadcast:n=!0}={}){let s=this.placements.indexOf(e);s!==-1&&(this.placements.splice(s,1),e.netId&&(this._netModels.delete(e.netId),n&&this.net?.status==="online"&&this._isMine(e)&&this.net.remove(e.netId)),e.idle?.detach(),e.idle=null,this.xrSession?.release(e.group),this.scene.remove(e.group),e.shadow&&(this.scene.remove(e.shadow),e.shadow.geometry?.dispose(),e.shadow.material?.dispose()),this.selected===e&&this._select(this.placements[this.placements.length-1]??null),uf(this._arCacheKey(e)),this._arKeys.delete(this._arCacheKey(e)),this.ui.arModal&&!this.ui.arModal.hidden&&this._showArTarget(this._arTarget===e?this._arDefaultTarget():this._arTarget),this._updateCount(),t&&this._saveScene(),this._emit("remove",{src:e.src,title:e.title}))}_clearWithUndo(){if(!this.placements.length)return;let e=this.getScene();for(let t of[...this.placements])this._removePlacement(t,{persist:!1});this._saveScene(),this._emit("clear",{items:e}),this._setStatus("Scene cleared.",{actionLabel:"Undo",onAction:async()=>{for(let t of e)await this._addModel({src:t.src,title:t.title},{x:t.x,z:t.z,yaw:t.yaw,scale:t.scale,announce:!1})}})}_onSelbarClick(e){let t=e.target.closest("[data-act]"),n=this.selected;if(!t||!n)return;let s=t.dataset.act;if((s==="rotate"||s==="remove")&&!this._isMine(n)){this._setStatus("That model belongs to someone else in the room.",{warn:!0});return}s==="rotate"?(n.yaw+=Math.PI/4,n.group.rotation.y=n.yaw,n._lastNetSend=0,this._netBroadcastTransform(n),this._saveScene()):s==="duplicate"?this._addModel({src:n.src,title:n.title},{yaw:n.yaw,scale:this._logicalScale(n)}):s==="remove"&&(this._removePlacement(n),this._setStatus("Removed.",{actionLabel:"Undo",onAction:()=>this._addModel({src:n.src,title:n.title},{x:n.group.position.x,z:n.group.position.z,yaw:n.yaw,scale:this._logicalScale(n)})}))}async _restoreScene({skipLocal:e=!1}={}){let t=new URLSearchParams(String(location.hash||"").replace(/^#/,"")),n=e?[]:rg(t.get("s")),s=n;if(!s.length&&!e&&this.config.persist!==!1)try{s=tf(localStorage.getItem(this.config.persistKey))}catch{s=[]}for(let a of s)await this._addModel({src:a.src,title:a.title},{x:a.x,z:a.z,yaw:a.yaw,scale:a.scale,announce:!1,persist:!1});let r=new Set(this.placements.map(a=>a.src));for(let a of this.config.urlModels||[])r.has(a.src)||await this._addModel(a,{announce:!1});this.placements.length&&(this._select(this.placements[this.placements.length-1]),n.length?this._setStatus("Shared scene loaded, exactly as arranged. Clear to start fresh."):this._setStatus(this.config.urlModels?.length?"Models loaded: turn on the camera to see them in your space.":"Your scene is back.")),this._saveScene()}_applyCameraFov(){let e=this.mediaStream?.getVideoTracks?.()[0];if(e){let s=e.getSettings?.()??{};Number.isFinite(s.width)&&s.width>0&&(this.arTrackW=s.width),Number.isFinite(s.height)&&s.height>0&&(this.arTrackH=s.height)}if(!this.arActive||!(this.arTrackW>0)||!(this.arTrackH>0))return;let{width:t,height:n}=this._viewportSize();this.camera.fov=lv({trackWidth:this.arTrackW,trackHeight:this.arTrackH,viewWidth:t,viewHeight:n,diagFovDeg:72}),this.camera.updateProjectionMatrix()}_sampleCameraLight(){let e=this._lightProbe,t=this.ui.video;if(!this.arActive||!e?.ctx||!t?.videoWidth)return;let n;try{e.ctx.drawImage(t,0,0,16,16),n=e.ctx.getImageData(0,0,16,16).data}catch{return}let{intensity:s,tint:r}=ng(n);this.hemi.intensity+=(s*Z0-this.hemi.intensity)*.4,this.sun.intensity+=(s*Q0-this.sun.intensity)*.4,this._roomTint.setRGB(r.r,r.g,r.b),this.hemi.color.lerp(this._roomTint,.4),this.sun.color.lerp(this._roomTint,.4)}_startLightMatching(){this._lightTimer||!this._lightProbe||(this._lightTimer=setInterval(()=>this._sampleCameraLight(),2e3),this._sampleCameraLight())}_stopLightMatching(){clearInterval(this._lightTimer),this._lightTimer=null,this.hemi.intensity=Z0,this.sun.intensity=Q0,this.hemi.color.setHex(16777215),this.sun.color.setHex(16777215)}async _startCamera(){if(!(this.arTransitioning||this.arActive||this.xrSession)){if(!navigator.mediaDevices?.getUserMedia){this._setStatus("This browser cannot open the camera: the 3D preview still works.",{warn:!0});return}this.arTransitioning=!0;try{this._setStatus("Starting camera\u2026",{sticky:!0});try{this.mediaStream=await navigator.mediaDevices.getUserMedia({video:{facingMode:{ideal:"environment"}},audio:!1})}catch(s){s?.name==="NotAllowedError"?this._setStatus("Camera permission is blocked. Allow it in your browser settings, then try again.",{warn:!0,sticky:!0,actionLabel:"Try again",onAction:()=>this._startCamera()}):this._setStatus(`The camera did not start (${s?.message??s}).`,{warn:!0,actionLabel:"Try again",onAction:()=>this._startCamera()});return}let{video:e,root:t,cameraBtn:n}=this.ui;e&&(e.srcObject=this.mediaStream),this.arActive=!0,t.classList.add("is-ar"),n?.classList.add("is-active"),n?.setAttribute("aria-pressed","true"),this.grid.visible=!1,this.scene.fog=null,this._userLooked=!0,e?.play?.().catch(()=>{}),this._applyCameraFov(),this._startLightMatching(),await this._startGyro(),this.arMode==="quicklook"||this.arMode==="sceneviewer"?this._setStatus("Camera on. This preview turns with your phone; to lock a model to your real floor, place it in AR.",{actionLabel:"Place in AR",onAction:()=>this._openArSheet()}):this._setStatus("Camera on: your models are in the room. Look around."),this._emit("camera",{active:!0})}finally{this.arTransitioning=!1}}}_stopCamera(){this.mediaStream&&(this.mediaStream.getTracks().forEach(r=>{try{r.stop()}catch{}}),this.mediaStream=null);let{video:e,root:t,cameraBtn:n}=this.ui;e&&(e.srcObject=null);let s=this.arActive;this.arActive=!1,this._stopLightMatching(),t?.classList.remove("is-ar"),n?.classList.remove("is-active"),n?.setAttribute("aria-pressed","false"),this.grid.visible=!this.xrSession,this.xrSession||(this.scene.fog=this._fog),this.camera.fov=58,this.camera.updateProjectionMatrix(),this.gyroBase=null,this._userLooked=!1,this.arTrackW=0,this.arTrackH=0,s&&this._emit("camera",{active:!1}),this._framePreview()}_yieldCameraToNativeAr(){this._cameraYielded||(this._cameraYielded=!0,this._cameraWasOn=this.arActive,this._stopCamera(),this._stopLoop(),this._onArReturn=()=>{typeof document<"u"&&document.visibilityState!=="visible"||this._reclaimCameraAfterNativeAr()},document.addEventListener("visibilitychange",this._onArReturn),window.addEventListener("focus",this._onArReturn))}_reclaimCameraAfterNativeAr(){this._cameraYielded&&(this._cameraYielded=!1,this._onArReturn&&(document.removeEventListener("visibilitychange",this._onArReturn),window.removeEventListener("focus",this._onArReturn),this._onArReturn=null),!(this._destroyed||this.xrSession)&&(this._startLoop(),!(this.arActive||!this._cameraWasOn)&&(this._cameraWasOn=!1,this._startCamera().catch(e=>Ei.warn("camera did not come back after AR",e)))))}_screenAngle(){try{let e=screen.orientation?.angle;if(Number.isFinite(e))return e}catch{}return Number(window.orientation)||0}_onDeviceOrientation(e){if(uv(e.alpha,e.beta)&&(this._devAlpha=e.alpha,this._devBeta=e.beta,Number.isFinite(e.gamma)&&(this._devGamma=e.gamma)),!this.arActive||!this.gyroBase)return;let t=Lg(this._devBeta,this._devGamma,this._screenAngle()),n=fv({useAbsolute:!1,prevYaw:this.cameraYaw,alpha:this._devAlpha,baseAlpha:this.gyroBase.alpha,baseYaw:this.gyroBase.yaw,compassHeading:null}),s=df(this.gyroBase.pitch-(t-this.gyroBase.beta)*(Math.PI/180),Y0,J0);Number.isFinite(n)&&(this.cameraYaw=n),Number.isFinite(s)&&(this.cameraPitch=s)}async _startGyro(){try{if(typeof DeviceOrientationEvent<"u"&&typeof DeviceOrientationEvent.requestPermission=="function"&&await DeviceOrientationEvent.requestPermission()!=="granted"){this._setStatus("Motion access is off: drag to look around instead.",{warn:!0});return}}catch{return}this.gyroBase={alpha:this._devAlpha,beta:Lg(this._devBeta,this._devGamma,this._screenAngle()),yaw:this.cameraYaw,pitch:this.cameraPitch}}_viewportSize(){let e=this.ui.root.getBoundingClientRect();return{width:Math.max(1,Math.round(e.width||window.innerWidth)),height:Math.max(1,Math.round(e.height||window.innerHeight)),left:e.left,top:e.top}}_setNdc(e,t){let n=this._viewportSize();this._ndc.set((e-n.left)/n.width*2-1,-((t-n.top)/n.height)*2+1)}_placementAt(e,t){if(!this.placements.length)return null;this._setNdc(e,t),this._raycaster.setFromCamera(this._ndc,this.camera);let n=this._raycaster.intersectObjects(this.placements.map(r=>r.group),!0);if(!n.length)return null;let s=n[0].object;for(;s;){let r=this.placements.find(a=>a.group===s);if(r)return r;s=s.parent}return null}_floorPointAt(e,t){this._setNdc(e,t),this._raycaster.setFromCamera(this._ndc,this.camera);let n=this._raycaster.intersectObject(this.rayPlane);return n.length?n[0].point:null}_onPointerDown(e){this.xrSession||this._pinch.active||performance.now()-this._pinchEndedAt<350||(this._pointer={x:e.clientX,y:e.clientY,placement:this._placementAt(e.clientX,e.clientY),lookYaw:this.cameraYaw,lookPitch:this.cameraPitch,moved:!1})}_onPointerMove(e){let t=this._pointer;if(!t||this.xrSession||this._pinch.active)return;let n=e.clientX-t.x,s=e.clientY-t.y;if(Math.hypot(n,s)>6&&(t.moved=!0),!!t.moved)if(t.placement&&this._isMine(t.placement)){let r=this._floorPointAt(e.clientX,e.clientY);if(!r)return;let a=t.placement;a.group.position.x=r.x,a.group.position.z=r.z,a.shadow?.position.set(r.x,.004,r.z),this.selected===a&&this._positionSelRing(),this._netBroadcastTransform(a)}else!t.placement&&!(this.arActive&&this.gyroBase)&&(this._userLooked=!0,this.cameraYaw=t.lookYaw+n*.0042,this.cameraPitch=df(t.lookPitch+s*.0032,Y0,J0))}_onPointerUp(e){let t=this._pointer;if(!t||this.xrSession)return;!t.moved&&Math.hypot(e.clientX-t.x,e.clientY-t.y)<=8&&!this._pinch.active&&performance.now()-this._pinchEndedAt>=350?this._select(t.placement):t.placement&&t.moved&&this._isMine(t.placement)&&(t.placement._lastNetSend=0,this._netBroadcastTransform(t.placement),this._saveScene(),this._setStatus(null)),this._pointer=null}_gestureTarget(){let e=this.selected??this.placements[this.placements.length-1]??null;return e&&this._isMine(e)?e:null}_onTouchStart(e){if(this.xrSession||e.touches.length!==2)return;let t=this._gestureTarget();t&&(this._pointer=null,ku(this._pinch,xo(e.touches),t.group.scale.x),this._twist={startAngle:Qu(e.touches),baseYaw:t.yaw,placement:t})}_onTouchMove(e){if(this.xrSession||e.touches.length!==2)return;let t=this._twist?.placement;if(!t)return;let n=Uu(this._pinch,xo(e.touches));n!=null&&(t.group.scale.setScalar(n),t.group.userData._targetScale=n,t.shadow?.scale.setScalar(n),this.selected===t&&this._positionSelRing()),t.yaw=this._twist.baseYaw+sg(this._twist.startAngle,Qu(e.touches)),t.group.rotation.y=t.yaw,this._netBroadcastTransform(t)}_onTouchEnd(){this._warmQuickLook();let e=Bu(this._pinch),t=this._twist?.placement;e!=null&&(this._pinchEndedAt=performance.now(),this._saveScene()),t&&(t._lastNetSend=0,this._netBroadcastTransform(t)),this._twist=null}_onKeyDown(e){if(this._destroyed||!this.ui.root.isConnected)return;if(e.target.closest?.("input, textarea, select")){e.key==="Escape"&&e.target.blur();return}if(e.key==="Escape"){this.ui.tray.hidden?this.ui.roomModal.hidden?this.ui.arModal.hidden?this.ui.qrModal.hidden?this._select(null):this._closeQr():this._closeArSheet():this._closeRoomModal():this._closeTray();return}if(!this.ui.tray.hidden||!this.ui.qrModal.hidden||!this.ui.arModal.hidden||!this.ui.roomModal.hidden||this.xrSession)return;let t=this.selected;if(!t)return;let n=this._isMine(t);if(e.key.startsWith("Arrow")){if(!n)return;e.preventDefault();let s=e.shiftKey?.02:.1,r=this.camera.getWorldDirection(new j);r.y=0,r.lengthSq()<1e-6&&r.set(0,0,-1),r.normalize();let a=new j(-r.z,0,r.x),o=e.key==="ArrowUp"?r:e.key==="ArrowDown"?r.negate():e.key==="ArrowLeft"?a.negate():a;t.group.position.addScaledVector(o,s),t.shadow?.position.set(t.group.position.x,.004,t.group.position.z),this._positionSelRing(),this._netBroadcastTransform(t),this._saveScene()}else if(e.key==="r"||e.key==="R"){if(!n)return;t.yaw+=Math.PI/4,t.group.rotation.y=t.yaw,t._lastNetSend=0,this._netBroadcastTransform(t),this._saveScene()}else if(e.key==="d"||e.key==="D")e.preventDefault(),this._addModel({src:t.src,title:t.title},{yaw:t.yaw,scale:this._logicalScale(t)});else if(e.key==="Delete"||e.key==="Backspace"){if(!n)return;e.preventDefault(),this._removePlacement(t),this._setStatus("Removed.",{actionLabel:"Undo",onAction:()=>this._addModel({src:t.src,title:t.title},{x:t.group.position.x,z:t.group.position.z,yaw:t.yaw,scale:this._logicalScale(t)})})}}_wireTrayTabs(){let e=this.ui.trayTabs;if(e){for(let[t,n]of this.sources.entries()){let s=le("button",{type:"button",class:"ars-tab",role:"tab",id:`ars-tab-${t}-${n.id}`,"aria-selected":String(t===0),tabindex:t===0?"0":"-1","data-tab":n.id,text:n.label||n.id});s.addEventListener("click",()=>this._setTrayTab(n.id)),e.appendChild(s)}e.addEventListener("keydown",t=>{let n=[...e.querySelectorAll(".ars-tab")],s=n.indexOf(document.activeElement);if(s===-1)return;let r=n.length-1,a=t.key==="ArrowRight"?s===r?0:s+1:t.key==="ArrowLeft"?s===0?r:s-1:t.key==="Home"?0:t.key==="End"?r:-1;a!==-1&&(t.preventDefault(),this._setTrayTab(n[a].dataset.tab),n[a].focus())})}}_openTray(e=this._trayTab){let{tray:t,addBtn:n,trayClose:s}=this.ui;t&&(this._lastFocus=document.activeElement,t.hidden=!1,n?.setAttribute("aria-expanded","true"),this._setTrayTab(e),s?.focus?.())}_closeTray(){let{tray:e,addBtn:t}=this.ui;if(!e||e.hidden)return;let n=e.contains(document.activeElement);e.hidden=!0,t?.setAttribute("aria-expanded","false"),n&&this._restoreFocus(t)}_restoreFocus(e){(this._lastFocus&&document.contains(this._lastFocus)&&!this._lastFocus.hidden?this._lastFocus:e)?.focus?.(),this._lastFocus=null}_setTrayTab(e){this._trayTab=e;let t=[...this.ui.trayTabs?.querySelectorAll(".ars-tab")||[]];for(let n of t){let s=n.dataset.tab===e;n.classList.toggle("is-active",s),n.setAttribute("aria-selected",String(s)),n.tabIndex=s?0:-1,s&&(this.ui.trayBody?.setAttribute("aria-labelledby",n.id),n.scrollIntoView?.({block:"nearest",inline:"nearest"}))}this._renderTray()}async _renderTray(){let e=this.ui.trayBody;if(!e)return;let t=this._trayTab,n=this.sources.find(r=>r.id===t);if(!n)return;if(n.kind==="link"||n.id==="link"){this._renderLinkTab(e);return}e.textContent="",e.appendChild(le("div",{class:"ars-tray-loading"},[le("span",{class:"ars-spinner","aria-hidden":"true"}),"Loading models\u2026"]));let s;try{!n.live&&this._trayCache.has(t)?s=this._trayCache.get(t):(s=await n.list(),n.live||this._trayCache.set(t,s))}catch(r){if(Ei.warn("source failed",t,r),this._trayTab!==t)return;e.textContent="",e.appendChild(le("div",{class:"ars-tray-empty"},[le("p",{text:`Couldn't load ${n.label||"these models"} right now.`}),le("button",{type:"button",class:"ars-btn",text:"Retry",onclick:()=>{this._trayCache.delete(t),this._renderTray()}})]));return}if(this._trayTab===t){if(!s.length){e.textContent="",e.appendChild(le("div",{class:"ars-tray-empty"},[le("p",{text:n.emptyCopy||"Nothing here yet."}),this.forge?le("button",{type:"button",class:"ars-btn ars-btn-primary",text:"Generate a model",onclick:()=>{this._closeTray(),this.ui.forgeInput?.focus()}}):null]));return}this._renderList(e,n,s)}}_renderList(e,t,n){e.textContent="";let s=t.searchable??n.length>24,r=ld,a=null;s&&(a=le("input",{class:"ars-search",type:"search",autocomplete:"off",placeholder:`Search ${n.length} models\u2026`,"aria-label":`Search ${t.label||"models"}`}),e.appendChild(a)),t.hint&&e.appendChild(le("p",{class:"ars-hint",text:t.hint}));let o=le("ul",{class:"ars-item-list"}),c=le("div",{class:"ars-more"});e.appendChild(o),e.appendChild(c);let l=()=>{let h=(a?.value||"").trim().toLowerCase(),u=h?n.filter(d=>(d.keywords||d.title||"").toLowerCase().includes(h)):n;o.textContent="";for(let d of u.slice(0,r))o.appendChild(this._trayItem(d));if(c.textContent="",u.length>r){let d=u.length-r;c.appendChild(le("button",{type:"button",class:"ars-btn",text:`Show ${Math.min(ld,d)} more (${d} left)`,onclick:()=>{r+=ld,l()}}))}else u.length||c.appendChild(le("p",{class:"ars-hint",text:"Nothing matches that search."}))};a?.addEventListener("input",()=>{r=ld,l()}),l()}_trayItem(e){let t=e.title||"Model",n=le("span",{class:"ars-item-thumb"});if(e.poster){let r=le("img",{src:e.poster,alt:"",loading:"lazy",decoding:"async"});r.addEventListener("error",()=>{n.textContent="",n.appendChild(le("span",{class:"ars-item-cube","aria-hidden":"true",text:"\u25C6"}))},{once:!0}),n.appendChild(r)}else n.appendChild(le("span",{class:"ars-item-cube","aria-hidden":"true",text:"\u25C6"}));let s=le("button",{type:"button",class:"ars-item-add",title:e.title||"","aria-label":`Add ${t} to your space`,onclick:()=>{this._closeTray(),this._addModel({src:e.src,title:t,poster:e.poster})}},[n,le("span",{class:"ars-item-title",text:t}),le("span",{class:"ars-item-cta",text:"Add"})]);return le("li",{class:"ars-item"},[s])}_renderLinkTab(e){e.textContent="";let t=le("input",{class:"ars-search",type:"url",inputmode:"url",required:!0,placeholder:"https://example.com/model.glb","aria-label":"GLB model URL"}),n=le("form",{},[le("label",{class:"ars-hint",for:"",text:"Paste a link to any .glb model"}),le("div",{class:"ars-link-row"},[t,le("button",{type:"submit",class:"ars-btn ars-btn-primary",text:"Add"})]),le("p",{class:"ars-hint",text:"Any https .glb works, as long as the host allows cross-origin requests."})]);n.addEventListener("submit",s=>{s.preventDefault();let r=Er(t.value);if(!r){this._setStatus("That link is not a loadable https GLB.",{warn:!0}),t.focus();return}this._closeTray(),this._addModel({src:r,title:EL(r)})}),e.appendChild(n)}_forgeChip(e,t="",n=null){let s=this.ui.chip;if(!s)return;s.dataset.state=e,s.hidden=e==="idle";let r=s.querySelector(".ars-chip-label"),a=s.querySelector(".ars-chip-elapsed");r&&(r.textContent=t),a&&(a.textContent=n==null?"":`${Math.round(n)}s`)}async _startForge(e){let t=String(e||"").trim();if(!this.forge||t.length<3||this._forgeBusy)return null;this._forgeBusy=!0;let n=++this._forgeSeq;this.ui.forgeGo&&(this.ui.forgeGo.disabled=!0);let s=Date.now();this._forgeChip("working","Sending your prompt\u2026",0);let r=setInterval(()=>{if(this.ui.chip?.dataset.state==="working"){let a=this.ui.chip.querySelector(".ars-chip-label")?.textContent||"";this._forgeChip("working",a,(Date.now()-s)/1e3)}},1e3);try{let a=await this.forge.generate(t,{onProgress:o=>{n===this._forgeSeq&&this._forgeChip("working",o.message,o.elapsedMs/1e3)}});return n!==this._forgeSeq?null:(nm({src:a.src,title:a.prompt,poster:a.poster},this._recentKey),this._trayCache.delete("recent"),this._forgeChip("idle"),this.ui.forgeInput&&(this.ui.forgeInput.value=""),await this._addModel({src:a.src,title:a.title,poster:a.poster},{announce:!1}),this._setStatus("Generated and placed. Pinch to resize, drag to move."),this._emit("generate",{model:a}),a)}catch(a){return n===this._forgeSeq&&(this._forgeChip("error",a?.message||"Generation failed."),setTimeout(()=>{this.ui.chip?.dataset.state==="error"&&this._forgeChip("idle")},6500)),this._emit("generate-error",{error:a,prompt:t}),null}finally{clearInterval(r),n===this._forgeSeq&&(this._forgeBusy=!1,this.ui.forgeGo&&(this.ui.forgeGo.disabled=!1))}}_enterAR(){return this.arMode==="webxr"?this._toggleXR():(this._openArSheet(),Promise.resolve())}_arCacheKey(e){return`${e.src}|${e.group.scale.x.toFixed(3)}`}async _targetUsdz(e){let{objectToUsdzBlob:t,glbUrlToUsdzBlob:n}=await Promise.resolve().then(()=>(lf(),Tg));try{return await t(e.group)}catch(s){return Ei.warn("live-scene USDZ export failed, refetching the source",s),n(e.src)}}_renderArPreview(e,t=384){if(this.xrSession)return null;let n=null;try{let s=aa(e.group);s.position.set(0,0,0),s.rotation.set(0,0,0),s.updateMatrixWorld(!0);let r=new ln().setFromObject(s);if(r.isEmpty())return null;let a=r.getCenter(new j),o=Math.max(r.getSize(new j).length()/2,.01),c=new cr;c.add(s),c.add(new eo(16777215,3816008,3.4));let l=new Yi(16777215,3.6);l.position.set(1.4,2.2,1.8);let h=new Yi(14673151,1.5);h.position.set(-1.6,.9,-1.2),c.add(l,h);let u=32,d=new fn(u,1,o/100,o*100),p=o/Math.sin(u*Math.PI/360)*1.06;d.position.set(a.x+p*.62,a.y+p*.42,a.z+p*.66),d.lookAt(a),n=new Gn(t,t,{depthBuffer:!0});let b=this.renderer.getRenderTarget();this.renderer.setRenderTarget(n),this.renderer.clear(),this.renderer.render(c,d);let v=new Uint8Array(t*t*4);this.renderer.readRenderTargetPixels(n,0,0,t,t,v),this.renderer.setRenderTarget(b);let _=document.createElement("canvas");_.width=t,_.height=t;let g=_.getContext("2d"),E=g.createImageData(t,t),L=t*4;for(let S=0;S<t;S++)E.data.set(v.subarray((t-1-S)*L,(t-S)*L),S*L);return g.putImageData(E,0,0),_.toDataURL("image/png")}catch(s){return Ei.warn("AR preview render failed",s),null}finally{n?.dispose()}}_arDefaultTarget(){return this.selected||this.placements[this.placements.length-1]||null}_warmQuickLook(){this._destroyed||this.arMode!=="quicklook"||(clearTimeout(this._arWarmTimer),this._arWarmTimer=setTimeout(()=>{if(this._destroyed)return;let e=this._arDefaultTarget();if(!e)return;let t=this._arCacheKey(e);ff(t)||(this._arKeys.add(t),jc({src:e.src,title:e.title,key:t,build:()=>this._targetUsdz(e)}).catch(n=>{Ei.warn("AR warm-up failed",n)}))},900))}_openArSheet(e){let t=this.ui;t.arModal&&(this._lastFocus=document.activeElement,t.arModal.hidden=!1,this._showArTarget(e||this._arDefaultTarget()),(t.arGo.hidden||t.arGo.disabled?t.arClose:t.arGo)?.focus?.(),this._emit("ar-sheet",{open:!0}))}_closeArSheet(){let{arModal:e,xrBtn:t}=this.ui;if(!e||e.hidden)return;let n=e.contains(document.activeElement);e.hidden=!0,this._arToken++,n&&this._restoreFocus(t),this._emit("ar-sheet",{open:!1})}_setArStatus(e,{state:t=""}={}){let n=this.ui.arStatus;n&&(n.textContent="",n.classList.toggle("is-error",t==="error"),n.classList.toggle("is-ready",t==="ready"),e&&(t==="busy"&&n.appendChild(le("span",{class:"ars-spinner","aria-hidden":"true"})),n.appendChild(le("span",{text:e}))))}_showArTarget(e){let t=this.ui;if(!t.arModal||t.arModal.hidden)return;this._arToken++,this._arHandoff=null,this._arTarget=e||null;let n=t.arGo.querySelector(".ars-ar-go-label");if(this._arRetry=null,t.arXr.hidden=this.arMode!=="webxr",t.arQr.hidden=!0,t.arPicker.hidden=!0,t.arPicker.textContent="",!e){t.arThumb.textContent="\u{1FA84}",t.arName.textContent="Nothing to place yet",t.arHint.textContent="Add a model to the scene and it can stand on your real floor at its real size.",this._setArStatus(null),t.arGo.hidden=!1,t.arGo.disabled=!1,t.arGo.removeAttribute("aria-busy"),n&&(n.textContent="Browse models"),t.arGo.querySelector(".ars-ar-go-icon").hidden=!0;return}t.arThumb.textContent="\u25C6";let s=this._renderArPreview(e)||e.poster;if(s){let r=le("img",{src:s,alt:""});r.addEventListener("error",()=>{t.arThumb.textContent="\u25C6"},{once:!0}),t.arThumb.textContent="",t.arThumb.appendChild(r)}if(t.arName.textContent=e.title||"Model",this.placements.length>1){t.arPicker.hidden=!1;for(let r of this.placements)t.arPicker.appendChild(le("button",{type:"button",class:"ars-ar-chip","data-ar-id":r.id,"aria-pressed":r===e?"true":"false",text:r.title||"Model"}))}if(this.arMode==="none"){t.arHint.textContent="AR needs a phone. Open this scene on your iPhone or Android and the model stands on your real floor.",this._setArStatus(null),t.arGo.hidden=!0,t.arQr.hidden=!1;return}t.arHint.textContent="Point your device at a flat surface, then drag to place it. It arrives at real size.",t.arGo.hidden=!1,t.arGo.querySelector(".ars-ar-go-icon").hidden=!1,n&&(n.textContent="Place in your space"),this._prepareArTarget(e)}async _prepareArTarget(e){let t=this.ui,n=this._arToken,s=this._arCacheKey(e),r=this.arMode!=="quicklook"||ff(s);r||(t.arGo.disabled=!0,t.arGo.setAttribute("aria-busy","true"),this._setArStatus("Preparing it for AR\u2026",{state:"busy"})),this._arKeys.add(s);try{let a=await jc({src:e.src,title:e.title,key:s,build:()=>this._targetUsdz(e)},{fallbackUrl:this.config.shareBaseUrl});if(n!==this._arToken||this._destroyed)return;this._arHandoff=a,t.arGo.disabled=!1,t.arGo.removeAttribute("aria-busy"),this._setArStatus(r?null:"Ready.",{state:"ready"});let o=document.activeElement===document.body||document.activeElement===t.arModal;!r&&o&&t.arGo.focus?.()}catch(a){if(n!==this._arToken||this._destroyed)return;Ei.warn("AR preparation failed",a),t.arGo.disabled=!0,t.arGo.removeAttribute("aria-busy"),this._setArStatus(`Could not prepare this model for AR (${a?.message||a}).`,{state:"error"}),this._arRetry=e,t.arGo.disabled=!1,t.arGo.querySelector(".ars-ar-go-label").textContent="Try again",t.arGo.querySelector(".ars-ar-go-icon").hidden=!0,this._emit("native-ar-error",{error:a,src:e.src})}}_onArGo(){if(!this._arTarget){this._closeArSheet(),this._openTray();return}if(this._arRetry){this._showArTarget(this._arRetry);return}let e=this._arHandoff;if(!e)return;let{src:t,title:n}=this._arTarget;this._yieldCameraToNativeAr();try{e.open()}catch(s){Ei.warn("native AR failed to open",s),this._setArStatus(`Could not open AR (${s?.message||s}).`,{state:"error"}),this._emit("native-ar-error",{error:s,src:t});return}this._emit("native-ar",{src:t,title:n,viewer:e.viewer}),this._closeArSheet(),this._setStatus("Point at the floor, then drag to place it.")}async _placeNative(e){let t=e||this.selected||this.placements[this.placements.length-1];if(!t)return this._setStatus("Add a model first, then place it in your space.",{warn:!0}),null;if(this._nativeArBusy)return null;this._nativeArBusy=!0;let n=this.ui.xrBtn;n?.setAttribute("aria-busy","true"),this._arKeys.add(this._arCacheKey(t));let s={download:"Fetching the model\u2026",parse:"Reading the model\u2026",convert:"Preparing it for AR\u2026",open:"Opening AR\u2026"};this._setStatus(s.download,{sticky:!0}),(this.arMode==="quicklook"||this.arMode==="sceneviewer")&&this._yieldCameraToNativeAr();try{let r=await Pg({src:t.src,title:t.title,key:this._arCacheKey(t),build:()=>this._targetUsdz(t)},{onProgress:a=>this._setStatus(s[a]||"Preparing AR\u2026",{sticky:!0}),fallbackUrl:this.config.shareBaseUrl});return r==="none"?this._setStatus("This device has no AR viewer. Open this scene on a phone instead.",{warn:!0,actionLabel:"Show QR",onAction:()=>this._openQr()}):this._setStatus("Point at the floor, then drag to place it."),this._emit("native-ar",{src:t.src,title:t.title,viewer:r}),r}catch(r){return Ei.warn("native AR failed",r),this._setStatus(`Could not open AR for this model (${r?.message||r}).`,{warn:!0,actionLabel:"Try again",onAction:()=>this._placeNative(t)}),this._emit("native-ar-error",{error:r,src:t.src}),null}finally{this._nativeArBusy=!1,n?.removeAttribute("aria-busy")}}async _toggleXR(){if(this.xrSession){this.xrSession.end();return}if(!this.arTransitioning){this.arTransitioning=!0;try{this.arActive&&this._stopCamera();let e=new zu({renderer:this.renderer,scene:this.scene,camera:this.camera,domOverlayRoot:this.ui.hud,getArmedContent:()=>this._armedContent(),onPlaced:t=>{let n=this.placements.find(s=>s.group===t);n&&(n.yaw=0,this._select(null)),this._saveScene(),this._setStatus(`Placed ${this.xrSession?.placedCount??""}: tap another spot to add one more.`)},getScaleTarget:()=>this.placements[this.placements.length-1]?.group??null,onScale:(t,{final:n})=>{n&&this._saveScene()},onHit:t=>this.ui.root.classList.toggle("xr-has-floor",t),onTracking:t=>{t?this._setStatus(null):this._setStatus("Tracking lost: move to a brighter spot with more texture.",{warn:!0,sticky:!0})},onFrame:t=>{for(let n of this.placements)n.mixer?.update(t),n.idle?.update(t)},onEnd:()=>this._onXREnd()});this._stopLoop(),await e.start(),this.xrSession=e,this.estimatedLight=new Fu({renderer:this.renderer,scene:this.scene,baseLights:[this.hemi,this.sun],onChange:t=>{t&&this._setStatus("Lit by your room: reflections and shadows match the real light.")}}),this.estimatedLight.start(),this.ui.root.classList.add("is-xr"),this.grid.visible=!1,this.scene.fog=null,this.selRing.visible=!1;for(let t of this.placements)t.shadow&&(t.shadow.visible=!1);this.ui.xrBtn?.classList.add("is-active"),this.ui.xrBtn?.setAttribute("aria-pressed","true"),this._setStatus("Point at the floor, then tap to place. Every tap adds another model."),this._emit("xr",{active:!0})}catch(e){Ei.warn("XR session failed",e),this.estimatedLight?.dispose(),this.estimatedLight=null,this._startLoop(),this._setStatus("Could not start immersive AR on this device. Camera mode still works.",{warn:!0})}finally{this.arTransitioning=!1}}}_armedContent(){let e=this._armed?.src??this.placements[this.placements.length-1]?.src;if(!e)return this._setStatus("Pick a model first: Add or generate one, then tap the floor.",{warn:!0}),null;let t=this._templatesReady.get(e);if(!t)return this._loadTemplate(e),this._setStatus("Model is still loading: one moment, then tap again.",{sticky:!0}),null;let{group:n,mixer:s,idlePromise:r}=this._instantiate(t,e),a={id:`p-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,7)}`,src:e,title:this._armed?.title||"",poster:"",group:n,shadow:null,mixer:s,idle:null,yaw:0,baseRadius:t.radius,height:t.height||0,spawnT:1,netId:null,ownerId:null,remote:!1,_lastNetSend:0};return r?.then(o=>{o&&(this.placements.includes(a)?a.idle=o:o.detach())}),this.placements.push(a),this._updateCount(),this._emit("add",{placement:eb(a,this),remote:!1}),n}_onXREnd(){this.xrSession=null,this.estimatedLight?.dispose(),this.estimatedLight=null,this.ui.root.classList.remove("is-xr","xr-has-floor"),this.ui.xrBtn?.classList.remove("is-active"),this.ui.xrBtn?.setAttribute("aria-pressed","false");for(let e of this.placements)e.group.position.y=0,e.shadow&&(e.shadow.visible=!0,e.shadow.position.set(e.group.position.x,.004,e.group.position.z));this.grid.visible=!this.arActive,this.arActive||(this.scene.fog=this._fog),this._saveScene(),this._startLoop(),this._setStatus("Back to the studio view."),this._emit("xr",{active:!1})}async _capturePhoto(){this.renderer.render(this.scene,this.camera);let e=await Zm({canvas:this.ui.canvas,video:this.ui.video,isAR:this.arActive});if(!e){this._setStatus("Could not capture the frame.",{warn:!0});return}try{let t=await Qm(e,{filename:"ar-studio.png",title:this.config.branding?.title||"AR Studio"});this._setStatus(t==="shared"?"Shared.":"Saved to your downloads.")}catch(t){t?.name!=="AbortError"&&this._setStatus("Could not share that photo.",{warn:!0})}}_openQr(){let{qrModal:e,qrBox:t,qrLink:n}=this.ui;if(!e)return;this._lastFocus=document.activeElement;let s=this.shareUrl();if(t)try{t.innerHTML=Fc(s,{scale:6,margin:2,dark:"#0b0b0b",light:"#ffffff"})}catch{try{t.innerHTML=Fc(nf(this.config.shareBaseUrl,this.getScene()),{scale:6,margin:2,dark:"#0b0b0b",light:"#ffffff"})}catch{t.textContent=s}}n&&(n.href=s,n.textContent=s.length>72?`${s.slice(0,69)}\u2026`:s),e.hidden=!1,this.ui.qrClose?.focus?.(),this._emit("share",{url:s})}_closeQr(){let{qrModal:e,qrBtn:t}=this.ui;if(!e||e.hidden)return;let n=e.contains(document.activeElement);e.hidden=!0,n&&this._restoreFocus(t)}_isMine(e){return!e.ownerId||e.ownerId===this.clientId}_placementShared(e){return Og({x:e.group.position.x,z:e.group.position.z,yaw:e.yaw,scale:this._logicalScale(e),height:e.height||0})}_placementWire(e,t){return{id:t,src:e.src,title:e.title,...this._placementShared(e)}}_netBroadcastTransform(e){if(!this.net||this.net.status!=="online"||!e.netId||!this._isMine(e))return;let t=Date.now();if(t-(e._lastNetSend||0)<80)return;e._lastNetSend=t;let n=this._placementShared(e);this.net.update(e.netId,{relEast:n.relEast,relNorth:n.relNorth,yawDeg:n.yawDeg,scale:n.scale})}_applySharedTransform(e,t){let n=mf(t);e.group.position.set(n.x,0,n.z),e.yaw=n.yaw,e.group.rotation.y=n.yaw,e.group.scale.setScalar(n.scale),e.group.userData._targetScale=n.scale,e.spawnT=1,e.shadow&&(e.shadow.position.set(n.x,.004,n.z),e.shadow.scale.setScalar(n.scale)),this.selected===e&&this._positionSelRing()}_reconcileRemoteModels(e){let t=new Set(e.map(s=>s.id));for(let s of[...this.placements])s.remote&&s.netId&&!t.has(s.netId)&&this._removePlacement(s,{persist:!1,broadcast:!1});let n=0;for(let s of e){let r=this._netModels.get(s.id);if(r){this._isMine(r)||this._applySharedTransform(r,s);continue}let a=mf(s),o=!!s.mine||s.ownerId===this.clientId;o||n++,this._addModel({src:s.src,title:s.title},{x:a.x,z:a.z,yaw:a.yaw,scale:a.scale,remote:!0,netId:s.id,ownerId:o?this.clientId:s.ownerId,announce:!1,persist:!1})}this._updateCount(),this._roomSynced&&n>0&&this._setStatus(n===1?"Someone added a model to the room.":`${n} models were added to the room.`),this._roomSynced=!0}_applyRemoteModelChange(e){let t=this._netModels.get(e.id);if(t){if(e.removed){t.remote&&this._removePlacement(t,{persist:!1,broadcast:!1});return}this._isMine(t)||this._applySharedTransform(t,e)}}_wireNet(e){e.on("status",({status:t})=>{t==="online"?(this._setStatus(`Shared room ${this.roomCode} is live: edits sync to everyone here.`),this.ui.root.classList.add("is-room")):t==="connecting"?this._setStatus(`Joining room ${this.roomCode}\u2026`,{sticky:!0}):t==="unavailable"||t==="failed"?(this._setStatus("Shared rooms are offline right now: you can still build solo.",{warn:!0}),this._leaveRoom({silent:!0})):t==="offline"&&this._setStatus("Reconnecting to the room\u2026",{sticky:!0}),this._updateRoomButton(),this._emit("room",{status:t,code:this.roomCode})}),e.on("models",t=>this._reconcileRemoteModels(t)),e.on("model",t=>this._applyRemoteModelChange(t)),e.on("presence",t=>{let n=this._presence.count;this._presence=t,this._updateCount(),this.ui.roomModal.hidden||this._renderRoomModal(),n>0&&t.count>n?this._setStatus(t.count===2?"Someone joined: you're building together now.":"Someone else joined the room."):n>1&&t.count<n&&t.count>=1&&this._setStatus(t.count===1?"You're on your own in the room now.":"Someone left the room.")}),e.on("reject",t=>{let n=t?.reason==="room_full"?"the room is full":t?.reason==="owner_full"?"you have the maximum models in this room":"the room declined it";this._setStatus(`Couldn't share that model: ${n}.`,{warn:!0})})}_seedRoom(){if(!(!this.net||this.net.status!=="online"))for(let e of this.placements){if(e.netId)continue;let t=`m${Date.now().toString(36)}${Math.random().toString(36).slice(2,6)}`.slice(0,40);e.netId=t,e.ownerId=this.clientId,e.remote=!1,this._netModels.set(t,e),this.net.spawn(this._placementWire(e,t))}}async _joinRoom(e,{seed:t=!1}={}){let n=da(e);if(!n){this._setStatus("That room code looks off: check the 6 characters and try again.",{warn:!0});return}this._leaveRoom({silent:!0}),this._roomSynced=!1,this.roomCode=n;let s=new cd({roomKey:kg(n),clientId:this.clientId,name:"",url:this.config.rooms?.server||""});if(this.net=s,this._wireNet(s),await s.connect(),this.net===s&&s.status==="online"){t&&this._seedRoom(),this._roomHeartbeat=setInterval(()=>this.net?.heartbeat(),15e3);try{let r=new URL(location.href);r.searchParams.set("room",n),history.replaceState(null,"",r)}catch{}}this._updateRoomButton()}_createRoom(){return this._joinRoom(Fg(),{seed:!0})}_leaveRoom({silent:e=!1}={}){if(this._roomHeartbeat&&(clearInterval(this._roomHeartbeat),this._roomHeartbeat=null),this.net){try{this.net.destroy()}catch{}this.net=null}for(let t of[...this.placements])t.remote&&!this._isMine(t)?this._removePlacement(t,{persist:!1,broadcast:!1}):(t.netId=null,t.remote=!1);this._netModels.clear(),this.roomCode="",this._presence={count:1,names:[]},this.ui.root.classList.remove("is-room");try{let t=new URL(location.href);t.searchParams.delete("room"),history.replaceState(null,"",t)}catch{}this._updateCount(),this._updateRoomButton(),e||this._setStatus("Left the shared room. Your models are still here.")}_updateRoomButton(){let e=this.ui.roomBtn;if(!e)return;let t=!!this.net&&(this.net.status==="online"||this.net.status==="connecting");e.classList.toggle("is-active",t);let n=e.querySelector(".ars-room-label"),s=e.querySelector(".ars-room-code-label");n&&(n.hidden=t),s&&(s.hidden=!t,s.textContent=t?this.roomCode||"Room":""),this.ui.roomModal.hidden||this._renderRoomModal()}_renderRoomModal(){let e=!!this.net&&this.net.status==="online",{roomIdle:t,roomLive:n,roomCode:s,roomPresence:r,roomQr:a}=this.ui;if(t&&(t.hidden=e),n&&(n.hidden=!e),!!e&&(s&&(s.textContent=this.roomCode),r&&(r.textContent=this._presence.count>1?`${this._presence.count} people are building here.`:"You are the only one here yet: share the code to invite someone."),a)){let o=Kc(this.config.shareBaseUrl,this.roomCode);try{a.innerHTML=Fc(o,{scale:5,margin:2,dark:"#0b0b0b",light:"#ffffff"})}catch{a.textContent=o}}}_openRoomModal(){let e=this.ui.roomModal;e&&(this._lastFocus=document.activeElement,e.hidden=!1,this._renderRoomModal(),(this.net?.status==="online"?this.ui.roomCopy:this.ui.roomCreate)?.focus?.())}_closeRoomModal(){let e=this.ui.roomModal;if(!e||e.hidden)return;let t=e.contains(document.activeElement);e.hidden=!0,t&&this._restoreFocus(this.ui.roomBtn)}async _createRoomFromUI(){if(await this._createRoom(),this._renderRoomModal(),this.net?.status==="online"&&navigator.clipboard?.writeText)try{await navigator.clipboard.writeText(Kc(this.config.shareBaseUrl,this.roomCode)),this._setStatus(`Room ${this.roomCode} is live: invite link copied. Paste it to a friend.`)}catch{}}async _joinRoomFromUI(){let e=this.ui.roomJoinInput,t=da(e?.value);if(!t){this._setStatus("That room code looks off: check the 6 characters.",{warn:!0}),e?.focus?.();return}await this._joinRoom(t),this._renderRoomModal()}async _copyRoomInvite(){let e=Kc(this.config.shareBaseUrl,this.roomCode),t=this.ui.roomCopy;try{let n=await eg(e,{title:"Build with me in AR",text:`Join my AR Studio room: ${this.roomCode}`});if(t){let s=t.textContent;t.textContent=n==="shared"?"Shared \u2713":"Link copied \u2713",setTimeout(()=>{t.textContent=s},1600)}}catch(n){n?.name!=="AbortError"&&window.prompt("Copy this invite link:",e)}}_framePreview(){if(this.arActive||this.xrSession||this._userLooked||!this.placements.length)return;let e=0,t=0,n=0;for(let l of this.placements)e+=l.group.position.x,t+=l.group.position.z,n+=(l.height||.4)*(l.group.userData._targetScale??1);let s=this.placements.length,r=e/s,a=t/s,o=n/s*.5,c=Math.hypot(r-this.camera.position.x,a-this.camera.position.z);c>.05&&(this.cameraYaw=Math.atan2(r-this.camera.position.x,-(a-this.camera.position.z)),this.cameraPitch=df(-Math.atan2(this.camera.position.y-o,c),Y0,J0))}_applyCameraLook(){this.camera.rotation.set(0,0,0),this.camera.rotateY(this.cameraYaw),this.camera.rotateX(this.cameraPitch)}_tick(e){this._rafId=requestAnimationFrame(n=>this._tick(n));let t=this._prevT?Math.min(.1,(e-this._prevT)/1e3):.016;this._prevT=e;for(let n of this.placements)if(n.mixer?.update(t),n.idle?.update(t),n.spawnT<1){n.spawnT=Math.min(1,n.spawnT+t*3.2);let s=1-(1-n.spawnT)**3,r=n.group.userData._targetScale??1;n.group.scale.setScalar(Math.max(.001,r*s)),n.shadow?.scale.setScalar(Math.max(.001,r*s))}this.selected&&this._positionSelRing(),this._applyCameraLook(),this.renderer.render(this.scene,this.camera)}_startLoop(){this._rafId===null&&(this._prevT=0,this._rafId=requestAnimationFrame(e=>this._tick(e)))}_stopLoop(){this._rafId!==null&&(cancelAnimationFrame(this._rafId),this._rafId=null)}_resize(){let{width:e,height:t}=this._viewportSize();this.renderer.setSize(e,t,!1),this.camera.aspect=e/t,this.camera.updateProjectionMatrix(),this._applyCameraFov()}addModel(e,t){return this._addModel(e,t)}clear(){let e=this.getScene();for(let t of[...this.placements])this._removePlacement(t,{persist:!1});return this._saveScene(),this._emit("clear",{items:e}),e}getScene(){return this.placements.map(e=>({src:e.src,title:e.title,x:e.group.position.x,z:e.group.position.z,yaw:e.yaw,scale:this._logicalScale(e)}))}async setScene(e){this.clear();for(let t of Array.isArray(e)?e:[])await this._addModel({src:t.src,title:t.title},{x:t.x,z:t.z,yaw:t.yaw,scale:t.scale,announce:!1,persist:!1});this._saveScene()}shareUrl(){return ag(this.config.shareBaseUrl,this.getScene())}generate(e){return this._startForge(e)}viewInYourSpace(e,t=""){let n=Er(e);if(!n)return"";let s=Du(this.config.origin,n,t,{endpoint:this.config.arLaunchUrl});return window.open(s,"_blank","noopener"),s}startCamera(){return this._startCamera()}stopCamera(){this._stopCamera()}toggleImmersive(){return this._toggleXR()}enterAR(){return this._enterAR()}placeInYourSpace(e){return this._placeNative(e)}openArSheet(e){this._openArSheet(e)}closeArSheet(){this._closeArSheet()}async openRoom(e){return e?await this._joinRoom(e):await this._createRoom(),this.roomCode}leaveRoom(){this._leaveRoom()}destroy(){if(!this._destroyed){this._destroyed=!0,this._stopLoop(),this._stopCamera(),this.xrSession?.end(),this.net?.destroy(),this._roomHeartbeat&&clearInterval(this._roomHeartbeat),clearTimeout(this._statusTimer),clearTimeout(this._arWarmTimer);for(let e of this._arKeys)uf(e);this._arKeys.clear(),clearInterval(this._lightTimer),document.removeEventListener("keydown",this._onKeyDown),window.removeEventListener("deviceorientationabsolute",this._onOrientationAbsolute,!0),window.removeEventListener("deviceorientation",this._onOrientation,!0),window.removeEventListener("resize",this._onResize),window.removeEventListener("pagehide",this._onPageHide),this._onArReturn&&(document.removeEventListener("visibilitychange",this._onArReturn),window.removeEventListener("focus",this._onArReturn),this._onArReturn=null),this._ro?.disconnect();for(let e of[...this.placements])this._removePlacement(e,{persist:!1,broadcast:!1});this.shadowTex?.dispose(),this.selRing.geometry.dispose(),this.selRing.material.dispose(),this.renderer.dispose(),this.ui.root.remove(),this._listeners.clear()}}};function vL(){try{return!!window.matchMedia?.("(prefers-reduced-motion: reduce)").matches}catch{return!1}}function SL(){try{let e=document.createElement("canvas");e.width=128,e.height=128;let t=e.getContext("2d"),n=t.createRadialGradient(128/2,128/2,0,128/2,128/2,128/2);return n.addColorStop(0,"rgba(0,0,0,0.40)"),n.addColorStop(.55,"rgba(0,0,0,0.18)"),n.addColorStop(1,"rgba(0,0,0,0)"),t.fillStyle=n,t.fillRect(0,0,128,128),new Zr(e)}catch{return null}}function wL(){try{let i=document.createElement("canvas");return i.width=16,i.height=16,{cnv:i,ctx:i.getContext("2d",{willReadFrequently:!0})}}catch{return null}}function ML(i){let e=`${i||"ar-studio"}:client`;try{let t=localStorage.getItem(e);return t||(t=crypto?.randomUUID?.()||`c-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`,localStorage.setItem(e,t)),t}catch{return`c-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}}function EL(i){let t=(String(i).split("?")[0].split("/").pop()||"Model").replace(/\.(glb|gltf)$/i,"").replace(/[_-]+/g," ").trim();return t?t.charAt(0).toUpperCase()+t.slice(1):"Linked model"}function eb(i,e){return{id:i.id,src:i.src,title:i.title,x:i.group.position.x,z:i.group.position.z,yaw:i.yaw,scale:e._logicalScale(i),mine:e._isMine(i)}}lf();sf();qu();function wl(i=document.body,e={}){let t=typeof i=="string"?document.querySelector(i):i;if(!t)throw new Error(`ar-studio: no element matched ${JSON.stringify(i)}`);return new Sl(t,e)}var g1=(i,e)=>i==null?e:i!=="false"&&i!=="0",hd=class extends HTMLElement{static get observedAttributes(){return["assets","title","accent","back-href","generate","rooms","room-server","origin","share-base"]}connectedCallback(){this.studio||(this.style.display||(this.style.display="block"),!this.style.minHeight&&!this.hasAttribute("embedded")&&(this.style.minHeight="70vh"),this.studio=wl(this,this.options()))}disconnectedCallback(){this.studio?.destroy(),this.studio=null}options(){let e=n=>this.getAttribute(n),t=e("assets");return{...t?{assets:t.includes(",")?t.split(",").map(n=>n.trim()):t}:{},...e("origin")?{origin:e("origin")}:{},...e("share-base")?{shareBaseUrl:e("share-base")}:{},branding:{title:e("title")||"AR Studio",accent:e("accent")||void 0,backHref:e("back-href")||null},generate:{enabled:g1(e("generate"),!0)},rooms:{enabled:g1(e("rooms"),!0),...e("room-server")?{server:e("room-server")}:{}},fullscreen:!1}}};function tb(i="ar-studio"){typeof customElements>"u"||customElements.get(i)||customElements.define(i,hd)}tb();function b1(){if(document.querySelector("ar-studio"))return;let i=document.querySelector("[data-ar-studio]");i?wl(i,AL(i)):document.documentElement.hasAttribute("data-ar-studio-auto")&&wl(document.body)}function AL(i){let e=i.getAttribute("data-assets");return e?{assets:e}:{}}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",b1,{once:!0}):b1();export{X2 as AVATAR_TARGET_HEIGHT_M,Sl as ArStudio,hd as ArStudioElement,bo as ArUrlError,ox as DEFAULTS,Wx as DEFAULT_DRACO_PATH,Lu as DEFAULT_ORIGIN,vs as ForgeError,px as GENERATE_TOOLS,rm as LINK_SOURCE,Mg as MAX_AR_FOOTPRINT_M,Eg as MAX_AR_HEIGHT_M,Zu as MAX_PLACEMENTS,mo as McpError,K2 as PROP_TARGET_SIZE_M,cm as QUALITY_TIERS,sv as QUICK_LOOK_BANNER_TAPPED,J2 as SCALE_MAX,Y2 as SCALE_MIN,tg as SPAWN_DISTANCE_M,On as THREE_WS,hm as applyCinematicDefaults,Ig as arCapability,_x as assertArAssetUrl,bg as bakeSkinnedMeshes,Du as buildArLaunchUrl,yx as buildSceneViewerUrl,vx as buildViewerUrl,cv as cachedUsdzUrl,Rg as canUseQuickLook,Cg as canUseSceneViewer,Zm as captureComposite,mx as catalogueItems,im as cdnUrl,dx as checkPromptSafety,Ag as clampToPlaceableSize,CI as clearQuickLookCache,_g as coerceMaterialsToStandard,wl as createArStudio,Zp as createForgeClient,la as createLogger,Xp as createMcpClient,tb as defineArStudio,tf as deserializeScene,xx as detectArTarget,lm as detectQualityTier,xg as ensureNormals,gx as filenameTitle,wg as fitToRoomScale,Vc as fitTransform,jp as generateQR,Fg as generateRoomCode,vy as getIdleClipJson,tv as glbUrlToUsdzBlob,Sg as groundOnFloor,iv as isAndroid,nv as isIOS,ff as isQuickLookReady,wC as isVerbose,fx as laneLabel,um as loadEnvironment,Og as localToShared,ci as log,kc as manifestSource,Wp as mergeConfig,Jm as mountIdle,Ng as normDeg,dv as normRad,go as normalizeCatalogue,Er as normalizeGlbUrl,da as normalizeRoomCode,ev as objectToUsdzBlob,av as openQuickLook,ov as openSceneViewer,Pg as placeInYourSpace,QC as planArLaunch,jc as prepareNativeAr,Yp as promptTitle,tm as readRecents,Iu as recentSource,uf as releaseQuickLook,nm as rememberRecent,DC as renderQRToCanvas,Fc as renderQRToSVG,$p as resolveConfig,am as resolveSources,kg as roomKeyForCode,ng as roomLightFromPixels,Kc as roomShareUrl,ys as safeUrl,rg as sceneFromHashParam,Sy as sceneToHashParam,cf as sceneToUsdzBlob,ef as serializeScene,S2 as setDracoPath,SC as setVerbose,Qm as shareOrDownload,eg as shareUrlOrCopy,$u as sharedGLTFLoader,mf as sharedToLocal,ig as spawnPointInFront,Kp as stageNarration,bx as staticSource,ag as studioSceneUrl,nf as studioShareUrl,sm as threeWsCommunitySource,Pu as threeWsObjectsSource,Qu as touchAngle,sg as twistDelta,Ru as unwrapToolResult,e2 as updateGroundContactShadow,yg as usdzExportRoot,rv as usdzFilename,Jp as validatePrompt,PI as withQuickLookBanner};
/*! Bundled license information:
three/build/three.core.js: