@rainbow-robotics/preview-host 0.11.1 → 0.11.2-dev.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AmrCapabilityControl.DXbqUARU.js → AmrCapabilityControl.5JPgsSoR.js} +1 -1
- package/dist/assets/{RbLocalizationProvider.CyiYW_3b.js → RbLocalizationProvider.6wdT7WY9.js} +96 -91
- package/dist/assets/{__federation_expose_App.ChvTErGr.js → __federation_expose_App.C_beiC6X.js} +378 -287
- package/dist/assets/__federation_fn_import.DdkEuT6t.js +2 -2
- package/dist/assets/{cssMode.BW-HZxjM.js → cssMode.f4FeviXh.js} +1 -1
- package/dist/assets/{freemarker2.DIklnwGm.js → freemarker2.B9IjV80o.js} +1 -1
- package/dist/assets/{handlebars.BiTLM1f9.js → handlebars.ce13EvEW.js} +1 -1
- package/dist/assets/{html.DIeLL-Vk.js → html.DLKUMOEg.js} +1 -1
- package/dist/assets/{htmlMode.CABMQgoF.js → htmlMode.DTPata5W.js} +1 -1
- package/dist/assets/{index.BhggDhnY.js → index.BPi3qPPC.js} +1 -1
- package/dist/assets/{index.BVp99JXC.js → index.Y2rHkgnC.js} +1 -1
- package/dist/assets/{index.BE31HU2F.js → index.jRC7zSWR.js} +2 -2
- package/dist/assets/{javascript.CMV7xmIO.js → javascript.B2eEkT__.js} +1 -1
- package/dist/assets/{jsonMode.Dt3eBS-I.js → jsonMode.B4ss9Cwa.js} +1 -1
- package/dist/assets/{liquid.D8pYTBOf.js → liquid.B_pWb41O.js} +1 -1
- package/dist/assets/{lspLanguageFeatures.Bdjz3Jpq.js → lspLanguageFeatures.Ugz3kGYC.js} +1 -1
- package/dist/assets/{mdx.DjXOLaJ_.js → mdx.DQDtSef7.js} +1 -1
- package/dist/assets/{python.C1nwxt_J.js → python.qjwY-oSU.js} +1 -1
- package/dist/assets/{razor.DITXP4AP.js → razor.ox5OgvAl.js} +1 -1
- package/dist/assets/remoteEntry.js +1 -1
- package/dist/assets/{tsMode.DFW5_70I.js → tsMode.DlZ1E1XF.js} +1 -1
- package/dist/assets/{typescript.DvzPm84D.js → typescript.DddPiD6C.js} +1 -1
- package/dist/assets/{useParsedPointCloudData.DuvJxary.js → useParsedPointCloudData.CjDZIVgK.js} +17 -17
- package/dist/assets/{xml.BhdphMBm.js → xml.BzC2RAU8.js} +1 -1
- package/dist/assets/{yaml.Br9iApwp.js → yaml.DLsEIYG7.js} +1 -1
- package/dist/index.html +5 -5
- package/package.json +1 -1
package/dist/assets/{useParsedPointCloudData.DuvJxary.js → useParsedPointCloudData.CjDZIVgK.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as Pc,
|
|
1
|
+
import{c as Pc,f9 as Eu,cx as Fg,gs as Ug,gt as gc,gu as Iv,gv as Au,gw as yf,gx as kv,gy as Bg,gz as xf,gA as Ov,gB as Fv,G as Uv,j as v,x as $t,cG as Hn,co as tn,H as C,c1 as $,U as we,gC as ba,bJ as wr,fm as zg,a$ as nt,cE as Cu,cn as Ea,cD as hi,av as ts,bF as Nn,fN as Hg,di as Gg,gD as Bv,dj as Pu,fO as Vg,gE as zv,de as Hv,gF as Gv,gG as Vv,S as Wv,gk as Wg,eK as jv,aX as Kn,eE as Ao,bY as Rn,fD as Xv,fT as qv,cp as Zv,bj as Yv,fe as Kv,fo as jg,cU as $v,eQ as Sh,eX as Xg,cM as Qv,er as Jv,bR as qg,bS as vr,bP as Zg,bH as Rc,fJ as ey,fK as ty,eM as Ru,gH as _f,d3 as ny,aW as go,bs as ca,V as Pi,cX as iy,cW as sy,d6 as ry,d7 as ay,_ as oy,cA as ly,cR as Yg,gI as cy,fl as dy,fk as hy,gJ as uy,fq as fy,cP as Co,ag as Po,ab as ii,dc as Mh,cv as py,em as my,en as gy,X as wf,a9 as by,bQ as Xo,eY as vy,gK as yy,gp as xy,gq as Kg,gr as _y,ex as wy,af as Sy,eZ as Sf}from"./RbLocalizationProvider.6wdT7WY9.js";import{importShared as At}from"./__federation_fn_import.DdkEuT6t.js";import{g as My}from"./index.P6snMalu.js";import{c as Nc}from"./emotion-styled-base.browser.esm.BIcjgOzg.js";/**
|
|
2
2
|
* @license lucide-react v0.486.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -31,7 +31,7 @@ import{c as Pc,f7 as Eu,cx as Fg,gq as Ug,gr as gc,gs as Iv,gt as Au,gu as yf,gv
|
|
|
31
31
|
* @license
|
|
32
32
|
* Copyright 2010-2025 Three.js Authors
|
|
33
33
|
* SPDX-License-Identifier: MIT
|
|
34
|
-
*/const yr="174",xr={ROTATE:0,DOLLY:1,PAN:2},Gs={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Qy=0,Ef=1,Jy=2,Qg=1,ex=2,vs=3,Si=0,fi=1,ln=2,qi=0,da=1,Ah=2,Af=3,Cf=4,tx=5,pr=100,nx=101,ix=102,sx=103,rx=104,ax=200,ox=201,lx=202,cx=203,Ch=204,Ph=205,dx=206,hx=207,ux=208,fx=209,px=210,mx=211,gx=212,bx=213,vx=214,Rh=0,Nh=1,Dh=2,va=3,Lh=4,Ih=5,kh=6,Oh=7,Dc=0,yx=1,xx=2,Xs=0,Jg=1,eb=2,tb=3,nb=4,ib=5,sb=6,rb=7,Pf="attached",_x="detached",ab=300,ya=301,xa=302,vc=303,Fh=304,Lc=306,Li=1e3,ui=1001,yc=1002,Sn=1003,ob=1004,ro=1005,bn=1006,oc=1007,ji=1008,Ms=1009,lb=1010,cb=1011,bo=1012,Nu=1013,Zs=1014,_i=1015,Ri=1016,Du=1017,Lu=1018,_a=1020,db=35902,hb=1021,ub=1022,Dn=1023,fb=1024,pb=1025,ha=1026,wa=1027,Iu=1028,Ic=1029,mb=1030,ku=1031,Ou=1033,lc=33776,cc=33777,dc=33778,hc=33779,Uh=35840,Bh=35841,zh=35842,Hh=35843,Gh=36196,Vh=37492,Wh=37496,jh=37808,Xh=37809,qh=37810,Zh=37811,Yh=37812,Kh=37813,$h=37814,Qh=37815,Jh=37816,eu=37817,tu=37818,nu=37819,iu=37820,su=37821,uc=36492,ru=36494,au=36495,gb=36283,ou=36284,lu=36285,cu=36286,vo=2300,yo=2301,Kc=2302,Rf=2400,Nf=2401,Df=2402,wx=2500,Sx=0,bb=1,du=2,Mx=3200,vb=3201,kc=0,Tx=1,zs="",gt="srgb",$n="srgb-linear",xc="linear",Ht="srgb",Dr=7680,HN=7681,GN=517,Lf=519,Ex=512,Ax=513,Cx=514,yb=515,Px=516,Rx=517,Nx=518,Dx=519,hu=35044,qo=35048,If="300 es",_s=2e3,_c=2001;class Er{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){const n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){const n=this._listeners;if(n===void 0)return;const i=n[e];if(i!==void 0){const s=i.indexOf(t);s!==-1&&i.splice(s,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const n=t[e.type];if(n!==void 0){e.target=this;const i=n.slice(0);for(let s=0,a=i.length;s<a;s++)i[s].call(this,e);e.target=null}}}const Vn=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let kf=1234567;const ua=Math.PI/180,Sa=180/Math.PI;function ki(){const r=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(Vn[r&255]+Vn[r>>8&255]+Vn[r>>16&255]+Vn[r>>24&255]+"-"+Vn[e&255]+Vn[e>>8&255]+"-"+Vn[e>>16&15|64]+Vn[e>>24&255]+"-"+Vn[t&63|128]+Vn[t>>8&255]+"-"+Vn[t>>16&255]+Vn[t>>24&255]+Vn[n&255]+Vn[n>>8&255]+Vn[n>>16&255]+Vn[n>>24&255]).toLowerCase()}function yt(r,e,t){return Math.max(e,Math.min(t,r))}function Fu(r,e){return(r%e+e)%e}function Lx(r,e,t,n,i){return n+(r-e)*(i-n)/(t-e)}function Ix(r,e,t){return r!==e?(t-r)/(e-r):0}function co(r,e,t){return(1-t)*r+t*e}function kx(r,e,t,n){return co(r,e,1-Math.exp(-t*n))}function Ox(r,e=1){return e-Math.abs(Fu(r,e*2)-e)}function Fx(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*(3-2*r))}function Ux(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*r*(r*(r*6-15)+10))}function Bx(r,e){return r+Math.floor(Math.random()*(e-r+1))}function zx(r,e){return r+Math.random()*(e-r)}function Hx(r){return r*(.5-Math.random())}function Gx(r){r!==void 0&&(kf=r);let e=kf+=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 Vx(r){return r*ua}function Wx(r){return r*Sa}function jx(r){return(r&r-1)===0&&r!==0}function Xx(r){return Math.pow(2,Math.ceil(Math.log(r)/Math.LN2))}function qx(r){return Math.pow(2,Math.floor(Math.log(r)/Math.LN2))}function Zx(r,e,t,n,i){const s=Math.cos,a=Math.sin,o=s(t/2),l=a(t/2),c=s((e+n)/2),d=a((e+n)/2),h=s((e-n)/2),u=a((e-n)/2),f=s((n-e)/2),m=a((n-e)/2);switch(i){case"XYX":r.set(o*d,l*h,l*u,o*c);break;case"YZY":r.set(l*u,o*d,l*h,o*c);break;case"ZXZ":r.set(l*h,l*u,o*d,o*c);break;case"XZX":r.set(o*d,l*m,l*f,o*c);break;case"YXY":r.set(l*f,o*d,l*m,o*c);break;case"ZYZ":r.set(l*m,l*f,o*d,o*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function Wi(r,e){switch(e.constructor){case Float32Array:return r;case Uint32Array:return r/4294967295;case Uint16Array:return r/65535;case Uint8Array:return r/255;case Int32Array:return Math.max(r/2147483647,-1);case Int16Array:return Math.max(r/32767,-1);case Int8Array:return Math.max(r/127,-1);default:throw new Error("Invalid component type.")}}function Gt(r,e){switch(e.constructor){case Float32Array:return r;case Uint32Array:return Math.round(r*4294967295);case Uint16Array:return Math.round(r*65535);case Uint8Array:return Math.round(r*255);case Int32Array:return Math.round(r*2147483647);case Int16Array:return Math.round(r*32767);case Int8Array:return Math.round(r*127);default:throw new Error("Invalid component type.")}}const bt={DEG2RAD:ua,RAD2DEG:Sa,generateUUID:ki,clamp:yt,euclideanModulo:Fu,mapLinear:Lx,inverseLerp:Ix,lerp:co,damp:kx,pingpong:Ox,smoothstep:Fx,smootherstep:Ux,randInt:Bx,randFloat:zx,randFloatSpread:Hx,seededRandom:Gx,degToRad:Vx,radToDeg:Wx,isPowerOfTwo:jx,ceilPowerOfTwo:Xx,floorPowerOfTwo:qx,setQuaternionFromProperEuler:Zx,normalize:Gt,denormalize:Wi};class me{constructor(e=0,t=0){me.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=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){const 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){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(yt(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),i=Math.sin(t),s=this.x-e.x,a=this.y-e.y;return this.x=s*n-a*i+e.x,this.y=s*i+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class xt{constructor(e,t,n,i,s,a,o,l,c){xt.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,i,s,a,o,l,c)}set(e,t,n,i,s,a,o,l,c){const d=this.elements;return d[0]=e,d[1]=i,d[2]=o,d[3]=t,d[4]=s,d[5]=l,d[6]=n,d[7]=a,d[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,s=this.elements,a=n[0],o=n[3],l=n[6],c=n[1],d=n[4],h=n[7],u=n[2],f=n[5],m=n[8],b=i[0],p=i[3],g=i[6],y=i[1],x=i[4],w=i[7],P=i[2],T=i[5],A=i[8];return s[0]=a*b+o*y+l*P,s[3]=a*p+o*x+l*T,s[6]=a*g+o*w+l*A,s[1]=c*b+d*y+h*P,s[4]=c*p+d*x+h*T,s[7]=c*g+d*w+h*A,s[2]=u*b+f*y+m*P,s[5]=u*p+f*x+m*T,s[8]=u*g+f*w+m*A,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],d=e[8];return t*a*d-t*o*c-n*s*d+n*o*l+i*s*c-i*a*l}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],d=e[8],h=d*a-o*c,u=o*l-d*s,f=c*s-a*l,m=t*h+n*u+i*f;if(m===0)return this.set(0,0,0,0,0,0,0,0,0);const b=1/m;return e[0]=h*b,e[1]=(i*c-d*n)*b,e[2]=(o*n-i*a)*b,e[3]=u*b,e[4]=(d*t-i*l)*b,e[5]=(i*s-o*t)*b,e[6]=f*b,e[7]=(n*l-c*t)*b,e[8]=(a*t-n*s)*b,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,i,s,a,o){const l=Math.cos(s),c=Math.sin(s);return this.set(n*l,n*c,-n*(l*a+c*o)+a+e,-i*c,i*l,-i*(-c*a+l*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply($c.makeScale(e,t)),this}rotate(e){return this.premultiply($c.makeRotation(-e)),this}translate(e,t){return this.premultiply($c.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,n=e.elements;for(let i=0;i<9;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const $c=new xt;function xb(r){for(let e=r.length-1;e>=0;--e)if(r[e]>=65535)return!0;return!1}function xo(r){return document.createElementNS("http://www.w3.org/1999/xhtml",r)}function Yx(){const r=xo("canvas");return r.style.display="block",r}const Of={};function hr(r){r in Of||(Of[r]=!0,console.warn(r))}function Kx(r,e,t){return new Promise(function(n,i){function s(){switch(r.clientWaitSync(e,r.SYNC_FLUSH_COMMANDS_BIT,0)){case r.WAIT_FAILED:i();break;case r.TIMEOUT_EXPIRED:setTimeout(s,t);break;default:n()}}setTimeout(s,t)})}function $x(r){const e=r.elements;e[2]=.5*e[2]+.5*e[3],e[6]=.5*e[6]+.5*e[7],e[10]=.5*e[10]+.5*e[11],e[14]=.5*e[14]+.5*e[15]}function Qx(r){const e=r.elements;e[11]===-1?(e[10]=-e[10]-1,e[14]=-e[14]):(e[10]=-e[10],e[14]=-e[14]+1)}const Ff=new xt().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Uf=new xt().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Jx(){const r={enabled:!0,workingColorSpace:$n,spaces:{},convert:function(i,s,a){return this.enabled===!1||s===a||!s||!a||(this.spaces[s].transfer===Ht&&(i.r=Ss(i.r),i.g=Ss(i.g),i.b=Ss(i.b)),this.spaces[s].primaries!==this.spaces[a].primaries&&(i.applyMatrix3(this.spaces[s].toXYZ),i.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===Ht&&(i.r=fa(i.r),i.g=fa(i.g),i.b=fa(i.b))),i},fromWorkingColorSpace:function(i,s){return this.convert(i,this.workingColorSpace,s)},toWorkingColorSpace:function(i,s){return this.convert(i,s,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===zs?xc:this.spaces[i].transfer},getLuminanceCoefficients:function(i,s=this.workingColorSpace){return i.fromArray(this.spaces[s].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,s,a){return i.copy(this.spaces[s].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(i){return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(i=this.workingColorSpace){return this.spaces[i].workingColorSpaceConfig.unpackColorSpace}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return r.define({[$n]:{primaries:e,whitePoint:n,transfer:xc,toXYZ:Ff,fromXYZ:Uf,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:gt},outputColorSpaceConfig:{drawingBufferColorSpace:gt}},[gt]:{primaries:e,whitePoint:n,transfer:Ht,toXYZ:Ff,fromXYZ:Uf,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:gt}}}),r}const ft=Jx();function Ss(r){return r<.04045?r*.0773993808:Math.pow(r*.9478672986+.0521327014,2.4)}function fa(r){return r<.0031308?r*12.92:1.055*Math.pow(r,.41666)-.055}let Lr;class e0{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{Lr===void 0&&(Lr=xo("canvas")),Lr.width=e.width,Lr.height=e.height;const n=Lr.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=Lr}return t.toDataURL("image/png")}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=xo("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const i=n.getImageData(0,0,e.width,e.height),s=i.data;for(let a=0;a<s.length;a++)s[a]=Ss(s[a]/255)*255;return n.putImageData(i,0,0),t}else if(e.data){const t=e.data.slice(0);for(let n=0;n<t.length;n++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[n]=Math.floor(Ss(t[n]/255)*255):t[n]=Ss(t[n]);return{data:t,width:e.width,height:e.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let t0=0;class Uu{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:t0++}),this.uuid=ki(),this.data=e,this.dataReady=!0,this.version=0}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const n={uuid:this.uuid,url:""},i=this.data;if(i!==null){let s;if(Array.isArray(i)){s=[];for(let a=0,o=i.length;a<o;a++)i[a].isDataTexture?s.push(Qc(i[a].image)):s.push(Qc(i[a]))}else s=Qc(i);n.url=s}return t||(e.images[this.uuid]=n),n}}function Qc(r){return typeof HTMLImageElement<"u"&&r instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&r instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&r instanceof ImageBitmap?e0.getDataURL(r):r.data?{data:Array.from(r.data),width:r.width,height:r.height,type:r.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let n0=0;class Ut extends Er{constructor(e=Ut.DEFAULT_IMAGE,t=Ut.DEFAULT_MAPPING,n=ui,i=ui,s=bn,a=ji,o=Dn,l=Ms,c=Ut.DEFAULT_ANISOTROPY,d=zs){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:n0++}),this.uuid=ki(),this.name="",this.source=new Uu(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=s,this.minFilter=a,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=l,this.offset=new me(0,0),this.repeat=new me(1,1),this.center=new me(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new xt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=d,this.userData={},this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.pmremVersion=0}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const n={metadata:{version:4.6,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==ab)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Li:e.x=e.x-Math.floor(e.x);break;case ui:e.x=e.x<0?0:1;break;case yc: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 Li:e.y=e.y-Math.floor(e.y);break;case ui:e.y=e.y<0?0:1;break;case yc: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++}}Ut.DEFAULT_IMAGE=null;Ut.DEFAULT_MAPPING=ab;Ut.DEFAULT_ANISOTROPY=1;class _t{constructor(e=0,t=0,n=0,i=1){_t.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,s=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*i+a[12]*s,this.y=a[1]*t+a[5]*n+a[9]*i+a[13]*s,this.z=a[2]*t+a[6]*n+a[10]*i+a[14]*s,this.w=a[3]*t+a[7]*n+a[11]*i+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);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,i,s;const l=e.elements,c=l[0],d=l[4],h=l[8],u=l[1],f=l[5],m=l[9],b=l[2],p=l[6],g=l[10];if(Math.abs(d-u)<.01&&Math.abs(h-b)<.01&&Math.abs(m-p)<.01){if(Math.abs(d+u)<.1&&Math.abs(h+b)<.1&&Math.abs(m+p)<.1&&Math.abs(c+f+g-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const x=(c+1)/2,w=(f+1)/2,P=(g+1)/2,T=(d+u)/4,A=(h+b)/4,M=(m+p)/4;return x>w&&x>P?x<.01?(n=0,i=.707106781,s=.707106781):(n=Math.sqrt(x),i=T/n,s=A/n):w>P?w<.01?(n=.707106781,i=0,s=.707106781):(i=Math.sqrt(w),n=T/i,s=M/i):P<.01?(n=.707106781,i=.707106781,s=0):(s=Math.sqrt(P),n=A/s,i=M/s),this.set(n,i,s,t),this}let y=Math.sqrt((p-m)*(p-m)+(h-b)*(h-b)+(u-d)*(u-d));return Math.abs(y)<.001&&(y=1),this.x=(p-m)/y,this.y=(h-b)/y,this.z=(u-d)/y,this.w=Math.acos((c+f+g-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=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){const 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}}class i0 extends Er{constructor(e=1,t=1,n={}){super(),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new _t(0,0,e,t),this.scissorTest=!1,this.viewport=new _t(0,0,e,t);const i={width:e,height:t,depth:1};n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:bn,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1},n);const s=new Ut(i,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace);s.flipY=!1,s.generateMipmaps=n.generateMipmaps,s.internalFormat=n.internalFormat,this.textures=[];const 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.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}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 i=0,s=this.textures.length;i<s;i++)this.textures[i].image.width=e,this.textures[i].image.height=t,this.textures[i].image.depth=n;this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;const i=Object.assign({},e.textures[t].image);this.textures[t].source=new Uu(i)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class ni extends i0{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}}class _b extends Ut{constructor(e=null,t=1,n=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=Sn,this.minFilter=Sn,this.wrapR=ui,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class s0 extends Ut{constructor(e=null,t=1,n=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=Sn,this.minFilter=Sn,this.wrapR=ui,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Lt{constructor(e=0,t=0,n=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=i}static slerpFlat(e,t,n,i,s,a,o){let l=n[i+0],c=n[i+1],d=n[i+2],h=n[i+3];const u=s[a+0],f=s[a+1],m=s[a+2],b=s[a+3];if(o===0){e[t+0]=l,e[t+1]=c,e[t+2]=d,e[t+3]=h;return}if(o===1){e[t+0]=u,e[t+1]=f,e[t+2]=m,e[t+3]=b;return}if(h!==b||l!==u||c!==f||d!==m){let p=1-o;const g=l*u+c*f+d*m+h*b,y=g>=0?1:-1,x=1-g*g;if(x>Number.EPSILON){const P=Math.sqrt(x),T=Math.atan2(P,g*y);p=Math.sin(p*T)/P,o=Math.sin(o*T)/P}const w=o*y;if(l=l*p+u*w,c=c*p+f*w,d=d*p+m*w,h=h*p+b*w,p===1-o){const P=1/Math.sqrt(l*l+c*c+d*d+h*h);l*=P,c*=P,d*=P,h*=P}}e[t]=l,e[t+1]=c,e[t+2]=d,e[t+3]=h}static multiplyQuaternionsFlat(e,t,n,i,s,a){const o=n[i],l=n[i+1],c=n[i+2],d=n[i+3],h=s[a],u=s[a+1],f=s[a+2],m=s[a+3];return e[t]=o*m+d*h+l*f-c*u,e[t+1]=l*m+d*u+c*h-o*f,e[t+2]=c*m+d*f+o*u-l*h,e[t+3]=d*m-o*h-l*u-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const n=e._x,i=e._y,s=e._z,a=e._order,o=Math.cos,l=Math.sin,c=o(n/2),d=o(i/2),h=o(s/2),u=l(n/2),f=l(i/2),m=l(s/2);switch(a){case"XYZ":this._x=u*d*h+c*f*m,this._y=c*f*h-u*d*m,this._z=c*d*m+u*f*h,this._w=c*d*h-u*f*m;break;case"YXZ":this._x=u*d*h+c*f*m,this._y=c*f*h-u*d*m,this._z=c*d*m-u*f*h,this._w=c*d*h+u*f*m;break;case"ZXY":this._x=u*d*h-c*f*m,this._y=c*f*h+u*d*m,this._z=c*d*m+u*f*h,this._w=c*d*h-u*f*m;break;case"ZYX":this._x=u*d*h-c*f*m,this._y=c*f*h+u*d*m,this._z=c*d*m-u*f*h,this._w=c*d*h+u*f*m;break;case"YZX":this._x=u*d*h+c*f*m,this._y=c*f*h+u*d*m,this._z=c*d*m-u*f*h,this._w=c*d*h-u*f*m;break;case"XZY":this._x=u*d*h-c*f*m,this._y=c*f*h-u*d*m,this._z=c*d*m+u*f*h,this._w=c*d*h+u*f*m;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],i=t[4],s=t[8],a=t[1],o=t[5],l=t[9],c=t[2],d=t[6],h=t[10],u=n+o+h;if(u>0){const f=.5/Math.sqrt(u+1);this._w=.25/f,this._x=(d-l)*f,this._y=(s-c)*f,this._z=(a-i)*f}else if(n>o&&n>h){const f=2*Math.sqrt(1+n-o-h);this._w=(d-l)/f,this._x=.25*f,this._y=(i+a)/f,this._z=(s+c)/f}else if(o>h){const f=2*Math.sqrt(1+o-n-h);this._w=(s-c)/f,this._x=(i+a)/f,this._y=.25*f,this._z=(l+d)/f}else{const f=2*Math.sqrt(1+h-n-o);this._w=(a-i)/f,this._x=(s+c)/f,this._y=(l+d)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<Number.EPSILON?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(yt(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const i=Math.min(1,t/n);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,i=e._y,s=e._z,a=e._w,o=t._x,l=t._y,c=t._z,d=t._w;return this._x=n*d+a*o+i*c-s*l,this._y=i*d+a*l+s*o-n*c,this._z=s*d+a*c+n*l-i*o,this._w=a*d-n*o-i*l-s*c,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const n=this._x,i=this._y,s=this._z,a=this._w;let o=a*e._w+n*e._x+i*e._y+s*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=a,this._x=n,this._y=i,this._z=s,this;const l=1-o*o;if(l<=Number.EPSILON){const f=1-t;return this._w=f*a+t*this._w,this._x=f*n+t*this._x,this._y=f*i+t*this._y,this._z=f*s+t*this._z,this.normalize(),this}const c=Math.sqrt(l),d=Math.atan2(c,o),h=Math.sin((1-t)*d)/c,u=Math.sin(t*d)/c;return this._w=a*h+this._w*u,this._x=n*h+this._x*u,this._y=i*h+this._y*u,this._z=s*h+this._z*u,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),s=Math.sqrt(n);return this.set(i*Math.sin(e),i*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}}class I{constructor(e=0,t=0,n=0){I.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Bf.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Bf.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,i=this.z,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6]*i,this.y=s[1]*t+s[4]*n+s[7]*i,this.z=s[2]*t+s[5]*n+s[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,s=e.elements,a=1/(s[3]*t+s[7]*n+s[11]*i+s[15]);return this.x=(s[0]*t+s[4]*n+s[8]*i+s[12])*a,this.y=(s[1]*t+s[5]*n+s[9]*i+s[13])*a,this.z=(s[2]*t+s[6]*n+s[10]*i+s[14])*a,this}applyQuaternion(e){const t=this.x,n=this.y,i=this.z,s=e.x,a=e.y,o=e.z,l=e.w,c=2*(a*i-o*n),d=2*(o*t-s*i),h=2*(s*n-a*t);return this.x=t+l*c+a*h-o*d,this.y=n+l*d+o*c-s*h,this.z=i+l*h+s*d-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){const t=this.x,n=this.y,i=this.z,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*i,this.y=s[1]*t+s[5]*n+s[9]*i,this.z=s[2]*t+s[6]*n+s[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=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){const 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){const n=e.x,i=e.y,s=e.z,a=t.x,o=t.y,l=t.z;return this.x=i*l-s*o,this.y=s*a-n*l,this.z=n*o-i*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Jc.copy(this).projectOnVector(e),this.sub(Jc)}reflect(e){return this.sub(Jc.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(yt(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Jc=new I,Bf=new Lt;class Yt{constructor(e=new I(1/0,1/0,1/0),t=new I(-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(Ui.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(Ui.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=Ui.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);const n=e.geometry;if(n!==void 0){const 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,Ui):Ui.fromBufferAttribute(s,a),Ui.applyMatrix4(e.matrixWorld),this.expandByPoint(Ui);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Zo.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),Zo.copy(n.boundingBox)),Zo.applyMatrix4(e.matrixWorld),this.union(Zo)}const i=e.children;for(let s=0,a=i.length;s<a;s++)this.expandByObject(i[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,Ui),Ui.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(Ua),Yo.subVectors(this.max,Ua),Ir.subVectors(e.a,Ua),kr.subVectors(e.b,Ua),Or.subVectors(e.c,Ua),Ps.subVectors(kr,Ir),Rs.subVectors(Or,kr),er.subVectors(Ir,Or);let t=[0,-Ps.z,Ps.y,0,-Rs.z,Rs.y,0,-er.z,er.y,Ps.z,0,-Ps.x,Rs.z,0,-Rs.x,er.z,0,-er.x,-Ps.y,Ps.x,0,-Rs.y,Rs.x,0,-er.y,er.x,0];return!ed(t,Ir,kr,Or,Yo)||(t=[1,0,0,0,1,0,0,0,1],!ed(t,Ir,kr,Or,Yo))?!1:(Ko.crossVectors(Ps,Rs),t=[Ko.x,Ko.y,Ko.z],ed(t,Ir,kr,Or,Yo))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Ui).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Ui).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:(ds[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),ds[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),ds[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),ds[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),ds[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),ds[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),ds[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),ds[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(ds),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const ds=[new I,new I,new I,new I,new I,new I,new I,new I],Ui=new I,Zo=new Yt,Ir=new I,kr=new I,Or=new I,Ps=new I,Rs=new I,er=new I,Ua=new I,Yo=new I,Ko=new I,tr=new I;function ed(r,e,t,n,i){for(let s=0,a=r.length-3;s<=a;s+=3){tr.fromArray(r,s);const o=i.x*Math.abs(tr.x)+i.y*Math.abs(tr.y)+i.z*Math.abs(tr.z),l=e.dot(tr),c=t.dot(tr),d=n.dot(tr);if(Math.max(-Math.max(l,c,d),Math.min(l,c,d))>o)return!1}return!0}const r0=new Yt,Ba=new I,td=new I;class vn{constructor(e=new I,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;t!==void 0?n.copy(t):r0.setFromPoints(e).getCenter(n);let i=0;for(let s=0,a=e.length;s<a;s++)i=Math.max(i,n.distanceToSquared(e[s]));return this.radius=Math.sqrt(i),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){const n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Ba.subVectors(e,this.center);const t=Ba.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),i=(n-this.radius)*.5;this.center.addScaledVector(Ba,i/n),this.radius+=i}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(Ba.copy(e.center).add(td)),this.expandByPoint(Ba.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)}}const hs=new I,nd=new I,$o=new I,Ns=new I,id=new I,Qo=new I,sd=new I;class Aa{constructor(e=new I,t=new I(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,hs)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=hs.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(hs.copy(this.origin).addScaledVector(this.direction,t),hs.distanceToSquared(e))}distanceSqToSegment(e,t,n,i){nd.copy(e).add(t).multiplyScalar(.5),$o.copy(t).sub(e).normalize(),Ns.copy(this.origin).sub(nd);const s=e.distanceTo(t)*.5,a=-this.direction.dot($o),o=Ns.dot(this.direction),l=-Ns.dot($o),c=Ns.lengthSq(),d=Math.abs(1-a*a);let h,u,f,m;if(d>0)if(h=a*l-o,u=a*o-l,m=s*d,h>=0)if(u>=-m)if(u<=m){const b=1/d;h*=b,u*=b,f=h*(h+a*u+2*o)+u*(a*h+u+2*l)+c}else u=s,h=Math.max(0,-(a*u+o)),f=-h*h+u*(u+2*l)+c;else u=-s,h=Math.max(0,-(a*u+o)),f=-h*h+u*(u+2*l)+c;else u<=-m?(h=Math.max(0,-(-a*s+o)),u=h>0?-s:Math.min(Math.max(-s,-l),s),f=-h*h+u*(u+2*l)+c):u<=m?(h=0,u=Math.min(Math.max(-s,-l),s),f=u*(u+2*l)+c):(h=Math.max(0,-(a*s+o)),u=h>0?s:Math.min(Math.max(-s,-l),s),f=-h*h+u*(u+2*l)+c);else u=a>0?-s:s,h=Math.max(0,-(a*u+o)),f=-h*h+u*(u+2*l)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,h),i&&i.copy(nd).addScaledVector($o,u),f}intersectSphere(e,t){hs.subVectors(e.center,this.origin);const n=hs.dot(this.direction),i=hs.dot(hs)-n*n,s=e.radius*e.radius;if(i>s)return null;const a=Math.sqrt(s-i),o=n-a,l=n+a;return l<0?null:o<0?this.at(l,t):this.at(o,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,i,s,a,o,l;const c=1/this.direction.x,d=1/this.direction.y,h=1/this.direction.z,u=this.origin;return c>=0?(n=(e.min.x-u.x)*c,i=(e.max.x-u.x)*c):(n=(e.max.x-u.x)*c,i=(e.min.x-u.x)*c),d>=0?(s=(e.min.y-u.y)*d,a=(e.max.y-u.y)*d):(s=(e.max.y-u.y)*d,a=(e.min.y-u.y)*d),n>a||s>i||((s>n||isNaN(n))&&(n=s),(a<i||isNaN(i))&&(i=a),h>=0?(o=(e.min.z-u.z)*h,l=(e.max.z-u.z)*h):(o=(e.max.z-u.z)*h,l=(e.min.z-u.z)*h),n>l||o>i)||((o>n||n!==n)&&(n=o),(l<i||i!==i)&&(i=l),i<0)?null:this.at(n>=0?n:i,t)}intersectsBox(e){return this.intersectBox(e,hs)!==null}intersectTriangle(e,t,n,i,s){id.subVectors(t,e),Qo.subVectors(n,e),sd.crossVectors(id,Qo);let a=this.direction.dot(sd),o;if(a>0){if(i)return null;o=1}else if(a<0)o=-1,a=-a;else return null;Ns.subVectors(this.origin,e);const l=o*this.direction.dot(Qo.crossVectors(Ns,Qo));if(l<0)return null;const c=o*this.direction.dot(id.cross(Ns));if(c<0||l+c>a)return null;const d=-o*Ns.dot(sd);return d<0?null:this.at(d/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)}}class Ie{constructor(e,t,n,i,s,a,o,l,c,d,h,u,f,m,b,p){Ie.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,n,i,s,a,o,l,c,d,h,u,f,m,b,p)}set(e,t,n,i,s,a,o,l,c,d,h,u,f,m,b,p){const g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=i,g[1]=s,g[5]=a,g[9]=o,g[13]=l,g[2]=c,g[6]=d,g[10]=h,g[14]=u,g[3]=f,g[7]=m,g[11]=b,g[15]=p,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 Ie().fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,n=e.elements,i=1/Fr.setFromMatrixColumn(e,0).length(),s=1/Fr.setFromMatrixColumn(e,1).length(),a=1/Fr.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*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){const t=this.elements,n=e.x,i=e.y,s=e.z,a=Math.cos(n),o=Math.sin(n),l=Math.cos(i),c=Math.sin(i),d=Math.cos(s),h=Math.sin(s);if(e.order==="XYZ"){const u=a*d,f=a*h,m=o*d,b=o*h;t[0]=l*d,t[4]=-l*h,t[8]=c,t[1]=f+m*c,t[5]=u-b*c,t[9]=-o*l,t[2]=b-u*c,t[6]=m+f*c,t[10]=a*l}else if(e.order==="YXZ"){const u=l*d,f=l*h,m=c*d,b=c*h;t[0]=u+b*o,t[4]=m*o-f,t[8]=a*c,t[1]=a*h,t[5]=a*d,t[9]=-o,t[2]=f*o-m,t[6]=b+u*o,t[10]=a*l}else if(e.order==="ZXY"){const u=l*d,f=l*h,m=c*d,b=c*h;t[0]=u-b*o,t[4]=-a*h,t[8]=m+f*o,t[1]=f+m*o,t[5]=a*d,t[9]=b-u*o,t[2]=-a*c,t[6]=o,t[10]=a*l}else if(e.order==="ZYX"){const u=a*d,f=a*h,m=o*d,b=o*h;t[0]=l*d,t[4]=m*c-f,t[8]=u*c+b,t[1]=l*h,t[5]=b*c+u,t[9]=f*c-m,t[2]=-c,t[6]=o*l,t[10]=a*l}else if(e.order==="YZX"){const u=a*l,f=a*c,m=o*l,b=o*c;t[0]=l*d,t[4]=b-u*h,t[8]=m*h+f,t[1]=h,t[5]=a*d,t[9]=-o*d,t[2]=-c*d,t[6]=f*h+m,t[10]=u-b*h}else if(e.order==="XZY"){const u=a*l,f=a*c,m=o*l,b=o*c;t[0]=l*d,t[4]=-h,t[8]=c*d,t[1]=u*h+b,t[5]=a*d,t[9]=f*h-m,t[2]=m*h-f,t[6]=o*d,t[10]=b*h+u}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(a0,e,o0)}lookAt(e,t,n){const i=this.elements;return mi.subVectors(e,t),mi.lengthSq()===0&&(mi.z=1),mi.normalize(),Ds.crossVectors(n,mi),Ds.lengthSq()===0&&(Math.abs(n.z)===1?mi.x+=1e-4:mi.z+=1e-4,mi.normalize(),Ds.crossVectors(n,mi)),Ds.normalize(),Jo.crossVectors(mi,Ds),i[0]=Ds.x,i[4]=Jo.x,i[8]=mi.x,i[1]=Ds.y,i[5]=Jo.y,i[9]=mi.y,i[2]=Ds.z,i[6]=Jo.z,i[10]=mi.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,s=this.elements,a=n[0],o=n[4],l=n[8],c=n[12],d=n[1],h=n[5],u=n[9],f=n[13],m=n[2],b=n[6],p=n[10],g=n[14],y=n[3],x=n[7],w=n[11],P=n[15],T=i[0],A=i[4],M=i[8],_=i[12],S=i[1],R=i[5],k=i[9],O=i[13],H=i[2],q=i[6],G=i[10],K=i[14],V=i[3],Z=i[7],le=i[11],se=i[15];return s[0]=a*T+o*S+l*H+c*V,s[4]=a*A+o*R+l*q+c*Z,s[8]=a*M+o*k+l*G+c*le,s[12]=a*_+o*O+l*K+c*se,s[1]=d*T+h*S+u*H+f*V,s[5]=d*A+h*R+u*q+f*Z,s[9]=d*M+h*k+u*G+f*le,s[13]=d*_+h*O+u*K+f*se,s[2]=m*T+b*S+p*H+g*V,s[6]=m*A+b*R+p*q+g*Z,s[10]=m*M+b*k+p*G+g*le,s[14]=m*_+b*O+p*K+g*se,s[3]=y*T+x*S+w*H+P*V,s[7]=y*A+x*R+w*q+P*Z,s[11]=y*M+x*k+w*G+P*le,s[15]=y*_+x*O+w*K+P*se,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[4],i=e[8],s=e[12],a=e[1],o=e[5],l=e[9],c=e[13],d=e[2],h=e[6],u=e[10],f=e[14],m=e[3],b=e[7],p=e[11],g=e[15];return m*(+s*l*h-i*c*h-s*o*u+n*c*u+i*o*f-n*l*f)+b*(+t*l*f-t*c*u+s*a*u-i*a*f+i*c*d-s*l*d)+p*(+t*c*h-t*o*f-s*a*h+n*a*f+s*o*d-n*c*d)+g*(-i*o*d-t*l*h+t*o*u+i*a*h-n*a*u+n*l*d)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],d=e[8],h=e[9],u=e[10],f=e[11],m=e[12],b=e[13],p=e[14],g=e[15],y=h*p*c-b*u*c+b*l*f-o*p*f-h*l*g+o*u*g,x=m*u*c-d*p*c-m*l*f+a*p*f+d*l*g-a*u*g,w=d*b*c-m*h*c+m*o*f-a*b*f-d*o*g+a*h*g,P=m*h*l-d*b*l-m*o*u+a*b*u+d*o*p-a*h*p,T=t*y+n*x+i*w+s*P;if(T===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const A=1/T;return e[0]=y*A,e[1]=(b*u*s-h*p*s-b*i*f+n*p*f+h*i*g-n*u*g)*A,e[2]=(o*p*s-b*l*s+b*i*c-n*p*c-o*i*g+n*l*g)*A,e[3]=(h*l*s-o*u*s-h*i*c+n*u*c+o*i*f-n*l*f)*A,e[4]=x*A,e[5]=(d*p*s-m*u*s+m*i*f-t*p*f-d*i*g+t*u*g)*A,e[6]=(m*l*s-a*p*s-m*i*c+t*p*c+a*i*g-t*l*g)*A,e[7]=(a*u*s-d*l*s+d*i*c-t*u*c-a*i*f+t*l*f)*A,e[8]=w*A,e[9]=(m*h*s-d*b*s-m*n*f+t*b*f+d*n*g-t*h*g)*A,e[10]=(a*b*s-m*o*s+m*n*c-t*b*c-a*n*g+t*o*g)*A,e[11]=(d*o*s-a*h*s-d*n*c+t*h*c+a*n*f-t*o*f)*A,e[12]=P*A,e[13]=(d*b*i-m*h*i+m*n*u-t*b*u-d*n*p+t*h*p)*A,e[14]=(m*o*i-a*b*i-m*n*l+t*b*l+a*n*p-t*o*p)*A,e[15]=(a*h*i-d*o*i+d*n*l-t*h*l-a*n*u+t*o*u)*A,this}scale(e){const t=this.elements,n=e.x,i=e.y,s=e.z;return t[0]*=n,t[4]*=i,t[8]*=s,t[1]*=n,t[5]*=i,t[9]*=s,t[2]*=n,t[6]*=i,t[10]*=s,t[3]*=n,t[7]*=i,t[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),i=Math.sin(t),s=1-n,a=e.x,o=e.y,l=e.z,c=s*a,d=s*o;return this.set(c*a+n,c*o-i*l,c*l+i*o,0,c*o+i*l,d*o+n,d*l-i*a,0,c*l-i*o,d*l+i*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,i,s,a){return this.set(1,n,s,0,e,1,a,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){const i=this.elements,s=t._x,a=t._y,o=t._z,l=t._w,c=s+s,d=a+a,h=o+o,u=s*c,f=s*d,m=s*h,b=a*d,p=a*h,g=o*h,y=l*c,x=l*d,w=l*h,P=n.x,T=n.y,A=n.z;return i[0]=(1-(b+g))*P,i[1]=(f+w)*P,i[2]=(m-x)*P,i[3]=0,i[4]=(f-w)*T,i[5]=(1-(u+g))*T,i[6]=(p+y)*T,i[7]=0,i[8]=(m+x)*A,i[9]=(p-y)*A,i[10]=(1-(u+b))*A,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){const i=this.elements;let s=Fr.set(i[0],i[1],i[2]).length();const a=Fr.set(i[4],i[5],i[6]).length(),o=Fr.set(i[8],i[9],i[10]).length();this.determinant()<0&&(s=-s),e.x=i[12],e.y=i[13],e.z=i[14],Bi.copy(this);const c=1/s,d=1/a,h=1/o;return Bi.elements[0]*=c,Bi.elements[1]*=c,Bi.elements[2]*=c,Bi.elements[4]*=d,Bi.elements[5]*=d,Bi.elements[6]*=d,Bi.elements[8]*=h,Bi.elements[9]*=h,Bi.elements[10]*=h,t.setFromRotationMatrix(Bi),n.x=s,n.y=a,n.z=o,this}makePerspective(e,t,n,i,s,a,o=_s){const l=this.elements,c=2*s/(t-e),d=2*s/(n-i),h=(t+e)/(t-e),u=(n+i)/(n-i);let f,m;if(o===_s)f=-(a+s)/(a-s),m=-2*a*s/(a-s);else if(o===_c)f=-a/(a-s),m=-a*s/(a-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=c,l[4]=0,l[8]=h,l[12]=0,l[1]=0,l[5]=d,l[9]=u,l[13]=0,l[2]=0,l[6]=0,l[10]=f,l[14]=m,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,t,n,i,s,a,o=_s){const l=this.elements,c=1/(t-e),d=1/(n-i),h=1/(a-s),u=(t+e)*c,f=(n+i)*d;let m,b;if(o===_s)m=(a+s)*h,b=-2*h;else if(o===_c)m=s*h,b=-1*h;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=2*c,l[4]=0,l[8]=0,l[12]=-u,l[1]=0,l[5]=2*d,l[9]=0,l[13]=-f,l[2]=0,l[6]=0,l[10]=b,l[14]=-m,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let i=0;i<16;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}const Fr=new I,Bi=new Ie,a0=new I(0,0,0),o0=new I(1,1,1),Ds=new I,Jo=new I,mi=new I,zf=new Ie,Hf=new Lt;class hn{constructor(e=0,t=0,n=0,i=hn.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const i=e.elements,s=i[0],a=i[4],o=i[8],l=i[1],c=i[5],d=i[9],h=i[2],u=i[6],f=i[10];switch(t){case"XYZ":this._y=Math.asin(yt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-d,f),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(u,c),this._z=0);break;case"YXZ":this._x=Math.asin(-yt(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-h,s),this._z=0);break;case"ZXY":this._x=Math.asin(yt(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-h,f),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-yt(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(u,f),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-a,c));break;case"YZX":this._z=Math.asin(yt(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-d,c),this._y=Math.atan2(-h,s)):(this._x=0,this._y=Math.atan2(o,f));break;case"XZY":this._z=Math.asin(-yt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(u,c),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-d,f),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return zf.makeRotationFromQuaternion(e),this.setFromRotationMatrix(zf,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Hf.setFromEuler(this),this.setFromQuaternion(Hf,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}}hn.DEFAULT_ORDER="XYZ";class Bu{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}let l0=0;const Gf=new I,Ur=new Lt,us=new Ie,el=new I,za=new I,c0=new I,d0=new Lt,Vf=new I(1,0,0),Wf=new I(0,1,0),jf=new I(0,0,1),Xf={type:"added"},h0={type:"removed"},Br={type:"childadded",child:null},rd={type:"childremoved",child:null};class Pt extends Er{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:l0++}),this.uuid=ki(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Pt.DEFAULT_UP.clone();const e=new I,t=new hn,n=new Lt,i=new I(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:i},modelViewMatrix:{value:new Ie},normalMatrix:{value:new xt}}),this.matrix=new Ie,this.matrixWorld=new Ie,this.matrixAutoUpdate=Pt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Pt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Bu,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return Ur.setFromAxisAngle(e,t),this.quaternion.multiply(Ur),this}rotateOnWorldAxis(e,t){return Ur.setFromAxisAngle(e,t),this.quaternion.premultiply(Ur),this}rotateX(e){return this.rotateOnAxis(Vf,e)}rotateY(e){return this.rotateOnAxis(Wf,e)}rotateZ(e){return this.rotateOnAxis(jf,e)}translateOnAxis(e,t){return Gf.copy(e).applyQuaternion(this.quaternion),this.position.add(Gf.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Vf,e)}translateY(e){return this.translateOnAxis(Wf,e)}translateZ(e){return this.translateOnAxis(jf,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(us.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?el.copy(e):el.set(e,t,n);const i=this.parent;this.updateWorldMatrix(!0,!1),za.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?us.lookAt(za,el,this.up):us.lookAt(el,za,this.up),this.quaternion.setFromRotationMatrix(us),i&&(us.extractRotation(i.matrixWorld),Ur.setFromRotationMatrix(us),this.quaternion.premultiply(Ur.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(Xf),Br.child=e,this.dispatchEvent(Br),Br.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(h0),rd.child=e,this.dispatchEvent(rd),rd.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),us.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),us.multiply(e.parent.matrixWorld)),e.applyMatrix4(us),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Xf),Br.child=e,this.dispatchEvent(Br),Br.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,i=this.children.length;n<i;n++){const a=this.children[n].getObjectByProperty(e,t);if(a!==void 0)return a}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);const i=this.children;for(let s=0,a=i.length;s<a;s++)i[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(za,e,c0),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(za,d0,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverseVisible(e)}traverseAncestors(e){const t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t){const n=this.parent;if(e===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),t===!0){const i=this.children;for(let s=0,a=i.length;s<a;s++)i[s].updateWorldMatrix(!1,!0)}}toJSON(e){const t=e===void 0||typeof e=="string",n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.visibility=this._visibility,i.active=this._active,i.bounds=this._bounds.map(o=>({boxInitialized:o.boxInitialized,boxMin:o.box.min.toArray(),boxMax:o.box.max.toArray(),sphereInitialized:o.sphereInitialized,sphereRadius:o.sphere.radius,sphereCenter:o.sphere.center.toArray()})),i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.geometryCount=this._geometryCount,i.matricesTexture=this._matricesTexture.toJSON(e),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(i.boundingSphere={center:i.boundingSphere.center.toArray(),radius:i.boundingSphere.radius}),this.boundingBox!==null&&(i.boundingBox={min:i.boundingBox.min.toArray(),max:i.boundingBox.max.toArray()}));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?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=s(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let c=0,d=l.length;c<d;c++){const h=l[c];s(e.shapes,h)}else s(e.shapes,l)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let l=0,c=this.material.length;l<c;l++)o.push(s(e.materials,this.material[l]));i.material=o}else i.material=s(e.materials,this.material);if(this.children.length>0){i.children=[];for(let o=0;o<this.children.length;o++)i.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let o=0;o<this.animations.length;o++){const l=this.animations[o];i.animations.push(s(e.animations,l))}}if(t){const o=a(e.geometries),l=a(e.materials),c=a(e.textures),d=a(e.images),h=a(e.shapes),u=a(e.skeletons),f=a(e.animations),m=a(e.nodes);o.length>0&&(n.geometries=o),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),d.length>0&&(n.images=d),h.length>0&&(n.shapes=h),u.length>0&&(n.skeletons=u),f.length>0&&(n.animations=f),m.length>0&&(n.nodes=m)}return n.object=i,n;function a(o){const l=[];for(const c in o){const d=o[c];delete d.metadata,l.push(d)}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.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){const i=e.children[n];this.add(i.clone())}return this}}Pt.DEFAULT_UP=new I(0,1,0);Pt.DEFAULT_MATRIX_AUTO_UPDATE=!0;Pt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const zi=new I,fs=new I,ad=new I,ps=new I,zr=new I,Hr=new I,qf=new I,od=new I,ld=new I,cd=new I,dd=new _t,hd=new _t,ud=new _t;class xi{constructor(e=new I,t=new I,n=new I){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,i){i.subVectors(n,t),zi.subVectors(e,t),i.cross(zi);const s=i.lengthSq();return s>0?i.multiplyScalar(1/Math.sqrt(s)):i.set(0,0,0)}static getBarycoord(e,t,n,i,s){zi.subVectors(i,t),fs.subVectors(n,t),ad.subVectors(e,t);const a=zi.dot(zi),o=zi.dot(fs),l=zi.dot(ad),c=fs.dot(fs),d=fs.dot(ad),h=a*c-o*o;if(h===0)return s.set(0,0,0),null;const u=1/h,f=(c*l-o*d)*u,m=(a*d-o*l)*u;return s.set(1-f-m,m,f)}static containsPoint(e,t,n,i){return this.getBarycoord(e,t,n,i,ps)===null?!1:ps.x>=0&&ps.y>=0&&ps.x+ps.y<=1}static getInterpolation(e,t,n,i,s,a,o,l){return this.getBarycoord(e,t,n,i,ps)===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,ps.x),l.addScaledVector(a,ps.y),l.addScaledVector(o,ps.z),l)}static getInterpolatedAttribute(e,t,n,i,s,a){return dd.setScalar(0),hd.setScalar(0),ud.setScalar(0),dd.fromBufferAttribute(e,t),hd.fromBufferAttribute(e,n),ud.fromBufferAttribute(e,i),a.setScalar(0),a.addScaledVector(dd,s.x),a.addScaledVector(hd,s.y),a.addScaledVector(ud,s.z),a}static isFrontFacing(e,t,n,i){return zi.subVectors(n,t),fs.subVectors(e,t),zi.cross(fs).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return zi.subVectors(this.c,this.b),fs.subVectors(this.a,this.b),zi.cross(fs).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return xi.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return xi.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,i,s){return xi.getInterpolation(e,this.a,this.b,this.c,t,n,i,s)}containsPoint(e){return xi.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return xi.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,i=this.b,s=this.c;let a,o;zr.subVectors(i,n),Hr.subVectors(s,n),od.subVectors(e,n);const l=zr.dot(od),c=Hr.dot(od);if(l<=0&&c<=0)return t.copy(n);ld.subVectors(e,i);const d=zr.dot(ld),h=Hr.dot(ld);if(d>=0&&h<=d)return t.copy(i);const u=l*h-d*c;if(u<=0&&l>=0&&d<=0)return a=l/(l-d),t.copy(n).addScaledVector(zr,a);cd.subVectors(e,s);const f=zr.dot(cd),m=Hr.dot(cd);if(m>=0&&f<=m)return t.copy(s);const b=f*c-l*m;if(b<=0&&c>=0&&m<=0)return o=c/(c-m),t.copy(n).addScaledVector(Hr,o);const p=d*m-f*h;if(p<=0&&h-d>=0&&f-m>=0)return qf.subVectors(s,i),o=(h-d)/(h-d+(f-m)),t.copy(i).addScaledVector(qf,o);const g=1/(p+b+u);return a=b*g,o=u*g,t.copy(n).addScaledVector(zr,a).addScaledVector(Hr,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const wb={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},Ls={h:0,s:0,l:0},tl={h:0,s:0,l:0};function fd(r,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?r+(e-r)*6*t:t<1/2?e:t<2/3?r+(e-r)*6*(2/3-t):r}class Ne{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){const i=e;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=gt){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,ft.toWorkingColorSpace(this,t),this}setRGB(e,t,n,i=ft.workingColorSpace){return this.r=e,this.g=t,this.b=n,ft.toWorkingColorSpace(this,i),this}setHSL(e,t,n,i=ft.workingColorSpace){if(e=Fu(e,1),t=yt(t,0,1),n=yt(n,0,1),t===0)this.r=this.g=this.b=n;else{const s=n<=.5?n*(1+t):n+t-n*t,a=2*n-s;this.r=fd(a,s,e+1/3),this.g=fd(a,s,e),this.b=fd(a,s,e-1/3)}return ft.toWorkingColorSpace(this,i),this}setStyle(e,t=gt){function n(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const a=i[1],o=i[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:console.warn("THREE.Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=i[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);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=gt){const n=wb[e.toLowerCase()];return n!==void 0?this.setHex(n,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Ss(e.r),this.g=Ss(e.g),this.b=Ss(e.b),this}copyLinearToSRGB(e){return this.r=fa(e.r),this.g=fa(e.g),this.b=fa(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=gt){return ft.fromWorkingColorSpace(Wn.copy(this),e),Math.round(yt(Wn.r*255,0,255))*65536+Math.round(yt(Wn.g*255,0,255))*256+Math.round(yt(Wn.b*255,0,255))}getHexString(e=gt){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=ft.workingColorSpace){ft.fromWorkingColorSpace(Wn.copy(this),t);const n=Wn.r,i=Wn.g,s=Wn.b,a=Math.max(n,i,s),o=Math.min(n,i,s);let l,c;const d=(o+a)/2;if(o===a)l=0,c=0;else{const h=a-o;switch(c=d<=.5?h/(a+o):h/(2-a-o),a){case n:l=(i-s)/h+(i<s?6:0);break;case i:l=(s-n)/h+2;break;case s:l=(n-i)/h+4;break}l/=6}return e.h=l,e.s=c,e.l=d,e}getRGB(e,t=ft.workingColorSpace){return ft.fromWorkingColorSpace(Wn.copy(this),t),e.r=Wn.r,e.g=Wn.g,e.b=Wn.b,e}getStyle(e=gt){ft.fromWorkingColorSpace(Wn.copy(this),e);const t=Wn.r,n=Wn.g,i=Wn.b;return e!==gt?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(i*255)})`}offsetHSL(e,t,n){return this.getHSL(Ls),this.setHSL(Ls.h+e,Ls.s+t,Ls.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(Ls),e.getHSL(tl);const n=co(Ls.h,tl.h,t),i=co(Ls.s,tl.s,t),s=co(Ls.l,tl.l,t);return this.setHSL(n,i,s),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,n=this.g,i=this.b,s=e.elements;return this.r=s[0]*t+s[3]*n+s[6]*i,this.g=s[1]*t+s[4]*n+s[7]*i,this.b=s[2]*t+s[5]*n+s[8]*i,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const Wn=new Ne;Ne.NAMES=wb;let u0=0;class wi extends Er{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:u0++}),this.uuid=ki(),this.name="",this.type="Material",this.blending=da,this.side=Si,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Ch,this.blendDst=Ph,this.blendEquation=pr,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Ne(0,0,0),this.blendAlpha=0,this.depthFunc=va,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Lf,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Dr,this.stencilZFail=Dr,this.stencilZPass=Dr,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.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const n=e[t];if(n===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}const i=this[t];if(i===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const n={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==da&&(n.blending=this.blending),this.side!==Si&&(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!==Ch&&(n.blendSrc=this.blendSrc),this.blendDst!==Ph&&(n.blendDst=this.blendDst),this.blendEquation!==pr&&(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!==va&&(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!==Lf&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Dr&&(n.stencilFail=this.stencilFail),this.stencilZFail!==Dr&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==Dr&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function i(s){const a=[];for(const o in s){const l=s[o];delete l.metadata,a.push(l)}return a}if(t){const s=i(e.textures),a=i(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;const t=e.clippingPlanes;let n=null;if(t!==null){const i=t.length;n=new Array(i);for(let s=0;s!==i;++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.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++}onBuild(){console.warn("Material: onBuild() has been removed.")}}class jt extends wi{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Ne(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 hn,this.combine=Dc,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const pn=new I,nl=new me;let f0=0;class rn{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:f0++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=hu,this.updateRanges=[],this.gpuType=_i,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 i=0,s=this.itemSize;i<s;i++)this.array[e+i]=t.array[n+i];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++)nl.fromBufferAttribute(this,t),nl.applyMatrix3(e),this.setXY(t,nl.x,nl.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)pn.fromBufferAttribute(this,t),pn.applyMatrix3(e),this.setXYZ(t,pn.x,pn.y,pn.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)pn.fromBufferAttribute(this,t),pn.applyMatrix4(e),this.setXYZ(t,pn.x,pn.y,pn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)pn.fromBufferAttribute(this,t),pn.applyNormalMatrix(e),this.setXYZ(t,pn.x,pn.y,pn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)pn.fromBufferAttribute(this,t),pn.transformDirection(e),this.setXYZ(t,pn.x,pn.y,pn.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=Wi(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=Gt(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=Wi(t,this.array)),t}setX(e,t){return this.normalized&&(t=Gt(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=Wi(t,this.array)),t}setY(e,t){return this.normalized&&(t=Gt(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=Wi(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Gt(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=Wi(t,this.array)),t}setW(e,t){return this.normalized&&(t=Gt(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=Gt(t,this.array),n=Gt(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,i){return e*=this.itemSize,this.normalized&&(t=Gt(t,this.array),n=Gt(n,this.array),i=Gt(i,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this}setXYZW(e,t,n,i,s){return e*=this.itemSize,this.normalized&&(t=Gt(t,this.array),n=Gt(n,this.array),i=Gt(i,this.array),s=Gt(s,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,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(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==hu&&(e.usage=this.usage),e}}class zu extends rn{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class Hu extends rn{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class ke extends rn{constructor(e,t,n){super(new Float32Array(e),t,n)}}let p0=0;const Mi=new Ie,pd=new Pt,Gr=new I,gi=new Yt,Ha=new Yt,Cn=new I;class ht extends Er{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:p0++}),this.uuid=ki(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(xb(e)?Hu:zu)(e,1):this.index=e,this}setIndirect(e){return this.indirect=e,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const n=this.attributes.normal;if(n!==void 0){const s=new xt().getNormalMatrix(e);n.applyNormalMatrix(s),n.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Mi.makeRotationFromQuaternion(e),this.applyMatrix4(Mi),this}rotateX(e){return Mi.makeRotationX(e),this.applyMatrix4(Mi),this}rotateY(e){return Mi.makeRotationY(e),this.applyMatrix4(Mi),this}rotateZ(e){return Mi.makeRotationZ(e),this.applyMatrix4(Mi),this}translate(e,t,n){return Mi.makeTranslation(e,t,n),this.applyMatrix4(Mi),this}scale(e,t,n){return Mi.makeScale(e,t,n),this.applyMatrix4(Mi),this}lookAt(e){return pd.lookAt(e),pd.updateMatrix(),this.applyMatrix4(pd.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Gr).negate(),this.translate(Gr.x,Gr.y,Gr.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const n=[];for(let i=0,s=e.length;i<s;i++){const a=e[i];n.push(a.x,a.y,a.z||0)}this.setAttribute("position",new ke(n,3))}else{const n=Math.min(e.length,t.count);for(let i=0;i<n;i++){const s=e[i];t.setXYZ(i,s.x,s.y,s.z||0)}e.length>t.count&&console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Yt);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new I(-1/0,-1/0,-1/0),new I(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,i=t.length;n<i;n++){const s=t[n];gi.setFromBufferAttribute(s),this.morphTargetsRelative?(Cn.addVectors(this.boundingBox.min,gi.min),this.boundingBox.expandByPoint(Cn),Cn.addVectors(this.boundingBox.max,gi.max),this.boundingBox.expandByPoint(Cn)):(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))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new vn);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new I,1/0);return}if(e){const n=this.boundingSphere.center;if(gi.setFromBufferAttribute(e),t)for(let s=0,a=t.length;s<a;s++){const o=t[s];Ha.setFromBufferAttribute(o),this.morphTargetsRelative?(Cn.addVectors(gi.min,Ha.min),gi.expandByPoint(Cn),Cn.addVectors(gi.max,Ha.max),gi.expandByPoint(Cn)):(gi.expandByPoint(Ha.min),gi.expandByPoint(Ha.max))}gi.getCenter(n);let i=0;for(let s=0,a=e.count;s<a;s++)Cn.fromBufferAttribute(e,s),i=Math.max(i,n.distanceToSquared(Cn));if(t)for(let s=0,a=t.length;s<a;s++){const o=t[s],l=this.morphTargetsRelative;for(let c=0,d=o.count;c<d;c++)Cn.fromBufferAttribute(o,c),l&&(Gr.fromBufferAttribute(e,c),Cn.add(Gr)),i=Math.max(i,n.distanceToSquared(Cn))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const n=t.position,i=t.normal,s=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new rn(new Float32Array(4*n.count),4));const a=this.getAttribute("tangent"),o=[],l=[];for(let M=0;M<n.count;M++)o[M]=new I,l[M]=new I;const c=new I,d=new I,h=new I,u=new me,f=new me,m=new me,b=new I,p=new I;function g(M,_,S){c.fromBufferAttribute(n,M),d.fromBufferAttribute(n,_),h.fromBufferAttribute(n,S),u.fromBufferAttribute(s,M),f.fromBufferAttribute(s,_),m.fromBufferAttribute(s,S),d.sub(c),h.sub(c),f.sub(u),m.sub(u);const R=1/(f.x*m.y-m.x*f.y);isFinite(R)&&(b.copy(d).multiplyScalar(m.y).addScaledVector(h,-f.y).multiplyScalar(R),p.copy(h).multiplyScalar(f.x).addScaledVector(d,-m.x).multiplyScalar(R),o[M].add(b),o[_].add(b),o[S].add(b),l[M].add(p),l[_].add(p),l[S].add(p))}let y=this.groups;y.length===0&&(y=[{start:0,count:e.count}]);for(let M=0,_=y.length;M<_;++M){const S=y[M],R=S.start,k=S.count;for(let O=R,H=R+k;O<H;O+=3)g(e.getX(O+0),e.getX(O+1),e.getX(O+2))}const x=new I,w=new I,P=new I,T=new I;function A(M){P.fromBufferAttribute(i,M),T.copy(P);const _=o[M];x.copy(_),x.sub(P.multiplyScalar(P.dot(_))).normalize(),w.crossVectors(T,_);const R=w.dot(l[M])<0?-1:1;a.setXYZW(M,x.x,x.y,x.z,R)}for(let M=0,_=y.length;M<_;++M){const S=y[M],R=S.start,k=S.count;for(let O=R,H=R+k;O<H;O+=3)A(e.getX(O+0)),A(e.getX(O+1)),A(e.getX(O+2))}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new rn(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let u=0,f=n.count;u<f;u++)n.setXYZ(u,0,0,0);const i=new I,s=new I,a=new I,o=new I,l=new I,c=new I,d=new I,h=new I;if(e)for(let u=0,f=e.count;u<f;u+=3){const m=e.getX(u+0),b=e.getX(u+1),p=e.getX(u+2);i.fromBufferAttribute(t,m),s.fromBufferAttribute(t,b),a.fromBufferAttribute(t,p),d.subVectors(a,s),h.subVectors(i,s),d.cross(h),o.fromBufferAttribute(n,m),l.fromBufferAttribute(n,b),c.fromBufferAttribute(n,p),o.add(d),l.add(d),c.add(d),n.setXYZ(m,o.x,o.y,o.z),n.setXYZ(b,l.x,l.y,l.z),n.setXYZ(p,c.x,c.y,c.z)}else for(let u=0,f=t.count;u<f;u+=3)i.fromBufferAttribute(t,u+0),s.fromBufferAttribute(t,u+1),a.fromBufferAttribute(t,u+2),d.subVectors(a,s),h.subVectors(i,s),d.cross(h),n.setXYZ(u+0,d.x,d.y,d.z),n.setXYZ(u+1,d.x,d.y,d.z),n.setXYZ(u+2,d.x,d.y,d.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)Cn.fromBufferAttribute(e,t),Cn.normalize(),e.setXYZ(t,Cn.x,Cn.y,Cn.z)}toNonIndexed(){function e(o,l){const c=o.array,d=o.itemSize,h=o.normalized,u=new c.constructor(l.length*d);let f=0,m=0;for(let b=0,p=l.length;b<p;b++){o.isInterleavedBufferAttribute?f=l[b]*o.data.stride+o.offset:f=l[b]*d;for(let g=0;g<d;g++)u[m++]=c[f++]}return new rn(u,d,h)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new ht,n=this.index.array,i=this.attributes;for(const o in i){const l=i[o],c=e(l,n);t.setAttribute(o,c)}const s=this.morphAttributes;for(const o in s){const l=[],c=s[o];for(let d=0,h=c.length;d<h;d++){const u=c[d],f=e(u,n);l.push(f)}t.morphAttributes[o]=l}t.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,l=a.length;o<l;o++){const c=a[o];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){const e={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const l in n){const c=n[l];e.data.attributes[l]=c.toJSON(e.data)}const i={};let s=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],d=[];for(let h=0,u=c.length;h<u;h++){const f=c[h];d.push(f.toJSON(e.data))}d.length>0&&(i[l]=d,s=!0)}s&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere={center:o.center.toArray(),radius:o.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;n!==null&&this.setIndex(n.clone(t));const i=e.attributes;for(const c in i){const d=i[c];this.setAttribute(c,d.clone(t))}const s=e.morphAttributes;for(const c in s){const d=[],h=s[c];for(let u=0,f=h.length;u<f;u++)d.push(h[u].clone(t));this.morphAttributes[c]=d}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let c=0,d=a.length;c<d;c++){const h=a[c];this.addGroup(h.start,h.count,h.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const 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"})}}const Zf=new Ie,nr=new Aa,il=new vn,Yf=new I,sl=new I,rl=new I,al=new I,md=new I,ol=new I,Kf=new I,ll=new I;class Ee extends Pt{constructor(e=new ht,t=new jt){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=i.length;s<a;s++){const o=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}getVertexPosition(e,t){const n=this.geometry,i=n.attributes.position,s=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(i,e);const o=this.morphTargetInfluences;if(s&&o){ol.set(0,0,0);for(let l=0,c=s.length;l<c;l++){const d=o[l],h=s[l];d!==0&&(md.fromBufferAttribute(h,e),a?ol.addScaledVector(md,d):ol.addScaledVector(md.sub(t),d))}t.add(ol)}return t}raycast(e,t){const n=this.geometry,i=this.material,s=this.matrixWorld;i!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),il.copy(n.boundingSphere),il.applyMatrix4(s),nr.copy(e.ray).recast(e.near),!(il.containsPoint(nr.origin)===!1&&(nr.intersectSphere(il,Yf)===null||nr.origin.distanceToSquared(Yf)>(e.far-e.near)**2))&&(Zf.copy(s).invert(),nr.copy(e.ray).applyMatrix4(Zf),!(n.boundingBox!==null&&nr.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,nr)))}_computeIntersections(e,t,n){let i;const s=this.geometry,a=this.material,o=s.index,l=s.attributes.position,c=s.attributes.uv,d=s.attributes.uv1,h=s.attributes.normal,u=s.groups,f=s.drawRange;if(o!==null)if(Array.isArray(a))for(let m=0,b=u.length;m<b;m++){const p=u[m],g=a[p.materialIndex],y=Math.max(p.start,f.start),x=Math.min(o.count,Math.min(p.start+p.count,f.start+f.count));for(let w=y,P=x;w<P;w+=3){const T=o.getX(w),A=o.getX(w+1),M=o.getX(w+2);i=cl(this,g,e,n,c,d,h,T,A,M),i&&(i.faceIndex=Math.floor(w/3),i.face.materialIndex=p.materialIndex,t.push(i))}}else{const m=Math.max(0,f.start),b=Math.min(o.count,f.start+f.count);for(let p=m,g=b;p<g;p+=3){const y=o.getX(p),x=o.getX(p+1),w=o.getX(p+2);i=cl(this,a,e,n,c,d,h,y,x,w),i&&(i.faceIndex=Math.floor(p/3),t.push(i))}}else if(l!==void 0)if(Array.isArray(a))for(let m=0,b=u.length;m<b;m++){const p=u[m],g=a[p.materialIndex],y=Math.max(p.start,f.start),x=Math.min(l.count,Math.min(p.start+p.count,f.start+f.count));for(let w=y,P=x;w<P;w+=3){const T=w,A=w+1,M=w+2;i=cl(this,g,e,n,c,d,h,T,A,M),i&&(i.faceIndex=Math.floor(w/3),i.face.materialIndex=p.materialIndex,t.push(i))}}else{const m=Math.max(0,f.start),b=Math.min(l.count,f.start+f.count);for(let p=m,g=b;p<g;p+=3){const y=p,x=p+1,w=p+2;i=cl(this,a,e,n,c,d,h,y,x,w),i&&(i.faceIndex=Math.floor(p/3),t.push(i))}}}}function m0(r,e,t,n,i,s,a,o){let l;if(e.side===fi?l=n.intersectTriangle(a,s,i,!0,o):l=n.intersectTriangle(i,s,a,e.side===Si,o),l===null)return null;ll.copy(o),ll.applyMatrix4(r.matrixWorld);const c=t.ray.origin.distanceTo(ll);return c<t.near||c>t.far?null:{distance:c,point:ll.clone(),object:r}}function cl(r,e,t,n,i,s,a,o,l,c){r.getVertexPosition(o,sl),r.getVertexPosition(l,rl),r.getVertexPosition(c,al);const d=m0(r,e,t,n,sl,rl,al,Kf);if(d){const h=new I;xi.getBarycoord(Kf,sl,rl,al,h),i&&(d.uv=xi.getInterpolatedAttribute(i,o,l,c,h,new me)),s&&(d.uv1=xi.getInterpolatedAttribute(s,o,l,c,h,new me)),a&&(d.normal=xi.getInterpolatedAttribute(a,o,l,c,h,new I),d.normal.dot(n.direction)>0&&d.normal.multiplyScalar(-1));const u={a:o,b:l,c,normal:new I,materialIndex:0};xi.getNormal(sl,rl,al,u.normal),d.face=u,d.barycoord=h}return d}class Jt extends ht{constructor(e=1,t=1,n=1,i=1,s=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:s,depthSegments:a};const o=this;i=Math.floor(i),s=Math.floor(s),a=Math.floor(a);const l=[],c=[],d=[],h=[];let u=0,f=0;m("z","y","x",-1,-1,n,t,e,a,s,0),m("z","y","x",1,-1,n,t,-e,a,s,1),m("x","z","y",1,1,e,n,t,i,a,2),m("x","z","y",1,-1,e,n,-t,i,a,3),m("x","y","z",1,-1,e,t,n,i,s,4),m("x","y","z",-1,-1,e,t,-n,i,s,5),this.setIndex(l),this.setAttribute("position",new ke(c,3)),this.setAttribute("normal",new ke(d,3)),this.setAttribute("uv",new ke(h,2));function m(b,p,g,y,x,w,P,T,A,M,_){const S=w/A,R=P/M,k=w/2,O=P/2,H=T/2,q=A+1,G=M+1;let K=0,V=0;const Z=new I;for(let le=0;le<G;le++){const se=le*R-O;for(let ge=0;ge<q;ge++){const de=ge*S-k;Z[b]=de*y,Z[p]=se*x,Z[g]=H,c.push(Z.x,Z.y,Z.z),Z[b]=0,Z[p]=0,Z[g]=T>0?1:-1,d.push(Z.x,Z.y,Z.z),h.push(ge/A),h.push(1-le/M),K+=1}}for(let le=0;le<M;le++)for(let se=0;se<A;se++){const ge=u+se+q*le,de=u+se+q*(le+1),X=u+(se+1)+q*(le+1),ee=u+(se+1)+q*le;l.push(ge,de,ee),l.push(de,X,ee),V+=6}o.addGroup(f,V,_),f+=V,u+=K}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Jt(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function Ma(r){const e={};for(const t in r){e[t]={};for(const n in r[t]){const i=r[t][n];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?i.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][n]=null):e[t][n]=i.clone():Array.isArray(i)?e[t][n]=i.slice():e[t][n]=i}}return e}function ei(r){const e={};for(let t=0;t<r.length;t++){const n=Ma(r[t]);for(const i in n)e[i]=n[i]}return e}function g0(r){const e=[];for(let t=0;t<r.length;t++)e.push(r[t].clone());return e}function Sb(r){const e=r.getRenderTarget();return e===null?r.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:ft.workingColorSpace}const Ca={clone:Ma,merge:ei};var b0=`void main() {
|
|
34
|
+
*/const yr="174",xr={ROTATE:0,DOLLY:1,PAN:2},Gs={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Qy=0,Ef=1,Jy=2,Qg=1,ex=2,vs=3,Si=0,fi=1,ln=2,qi=0,da=1,Ah=2,Af=3,Cf=4,tx=5,pr=100,nx=101,ix=102,sx=103,rx=104,ax=200,ox=201,lx=202,cx=203,Ch=204,Ph=205,dx=206,hx=207,ux=208,fx=209,px=210,mx=211,gx=212,bx=213,vx=214,Rh=0,Nh=1,Dh=2,va=3,Lh=4,Ih=5,kh=6,Oh=7,Dc=0,yx=1,xx=2,Xs=0,Jg=1,eb=2,tb=3,nb=4,ib=5,sb=6,rb=7,Pf="attached",_x="detached",ab=300,ya=301,xa=302,vc=303,Fh=304,Lc=306,Li=1e3,ui=1001,yc=1002,Sn=1003,ob=1004,ro=1005,bn=1006,oc=1007,ji=1008,Ms=1009,lb=1010,cb=1011,bo=1012,Nu=1013,Zs=1014,_i=1015,Ri=1016,Du=1017,Lu=1018,_a=1020,db=35902,hb=1021,ub=1022,Dn=1023,fb=1024,pb=1025,ha=1026,wa=1027,Iu=1028,Ic=1029,mb=1030,ku=1031,Ou=1033,lc=33776,cc=33777,dc=33778,hc=33779,Uh=35840,Bh=35841,zh=35842,Hh=35843,Gh=36196,Vh=37492,Wh=37496,jh=37808,Xh=37809,qh=37810,Zh=37811,Yh=37812,Kh=37813,$h=37814,Qh=37815,Jh=37816,eu=37817,tu=37818,nu=37819,iu=37820,su=37821,uc=36492,ru=36494,au=36495,gb=36283,ou=36284,lu=36285,cu=36286,vo=2300,yo=2301,Kc=2302,Rf=2400,Nf=2401,Df=2402,wx=2500,Sx=0,bb=1,du=2,Mx=3200,vb=3201,kc=0,Tx=1,zs="",gt="srgb",$n="srgb-linear",xc="linear",Ht="srgb",Dr=7680,HN=7681,GN=517,Lf=519,Ex=512,Ax=513,Cx=514,yb=515,Px=516,Rx=517,Nx=518,Dx=519,hu=35044,qo=35048,If="300 es",_s=2e3,_c=2001;class Er{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){const n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){const n=this._listeners;if(n===void 0)return;const i=n[e];if(i!==void 0){const s=i.indexOf(t);s!==-1&&i.splice(s,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const n=t[e.type];if(n!==void 0){e.target=this;const i=n.slice(0);for(let s=0,a=i.length;s<a;s++)i[s].call(this,e);e.target=null}}}const Vn=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let kf=1234567;const ua=Math.PI/180,Sa=180/Math.PI;function ki(){const r=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(Vn[r&255]+Vn[r>>8&255]+Vn[r>>16&255]+Vn[r>>24&255]+"-"+Vn[e&255]+Vn[e>>8&255]+"-"+Vn[e>>16&15|64]+Vn[e>>24&255]+"-"+Vn[t&63|128]+Vn[t>>8&255]+"-"+Vn[t>>16&255]+Vn[t>>24&255]+Vn[n&255]+Vn[n>>8&255]+Vn[n>>16&255]+Vn[n>>24&255]).toLowerCase()}function yt(r,e,t){return Math.max(e,Math.min(t,r))}function Fu(r,e){return(r%e+e)%e}function Lx(r,e,t,n,i){return n+(r-e)*(i-n)/(t-e)}function Ix(r,e,t){return r!==e?(t-r)/(e-r):0}function co(r,e,t){return(1-t)*r+t*e}function kx(r,e,t,n){return co(r,e,1-Math.exp(-t*n))}function Ox(r,e=1){return e-Math.abs(Fu(r,e*2)-e)}function Fx(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*(3-2*r))}function Ux(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*r*(r*(r*6-15)+10))}function Bx(r,e){return r+Math.floor(Math.random()*(e-r+1))}function zx(r,e){return r+Math.random()*(e-r)}function Hx(r){return r*(.5-Math.random())}function Gx(r){r!==void 0&&(kf=r);let e=kf+=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 Vx(r){return r*ua}function Wx(r){return r*Sa}function jx(r){return(r&r-1)===0&&r!==0}function Xx(r){return Math.pow(2,Math.ceil(Math.log(r)/Math.LN2))}function qx(r){return Math.pow(2,Math.floor(Math.log(r)/Math.LN2))}function Zx(r,e,t,n,i){const s=Math.cos,a=Math.sin,o=s(t/2),l=a(t/2),c=s((e+n)/2),d=a((e+n)/2),h=s((e-n)/2),u=a((e-n)/2),f=s((n-e)/2),m=a((n-e)/2);switch(i){case"XYX":r.set(o*d,l*h,l*u,o*c);break;case"YZY":r.set(l*u,o*d,l*h,o*c);break;case"ZXZ":r.set(l*h,l*u,o*d,o*c);break;case"XZX":r.set(o*d,l*m,l*f,o*c);break;case"YXY":r.set(l*f,o*d,l*m,o*c);break;case"ZYZ":r.set(l*m,l*f,o*d,o*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function Wi(r,e){switch(e.constructor){case Float32Array:return r;case Uint32Array:return r/4294967295;case Uint16Array:return r/65535;case Uint8Array:return r/255;case Int32Array:return Math.max(r/2147483647,-1);case Int16Array:return Math.max(r/32767,-1);case Int8Array:return Math.max(r/127,-1);default:throw new Error("Invalid component type.")}}function Gt(r,e){switch(e.constructor){case Float32Array:return r;case Uint32Array:return Math.round(r*4294967295);case Uint16Array:return Math.round(r*65535);case Uint8Array:return Math.round(r*255);case Int32Array:return Math.round(r*2147483647);case Int16Array:return Math.round(r*32767);case Int8Array:return Math.round(r*127);default:throw new Error("Invalid component type.")}}const bt={DEG2RAD:ua,RAD2DEG:Sa,generateUUID:ki,clamp:yt,euclideanModulo:Fu,mapLinear:Lx,inverseLerp:Ix,lerp:co,damp:kx,pingpong:Ox,smoothstep:Fx,smootherstep:Ux,randInt:Bx,randFloat:zx,randFloatSpread:Hx,seededRandom:Gx,degToRad:Vx,radToDeg:Wx,isPowerOfTwo:jx,ceilPowerOfTwo:Xx,floorPowerOfTwo:qx,setQuaternionFromProperEuler:Zx,normalize:Gt,denormalize:Wi};class me{constructor(e=0,t=0){me.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=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){const 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){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(yt(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),i=Math.sin(t),s=this.x-e.x,a=this.y-e.y;return this.x=s*n-a*i+e.x,this.y=s*i+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class xt{constructor(e,t,n,i,s,a,o,l,c){xt.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,i,s,a,o,l,c)}set(e,t,n,i,s,a,o,l,c){const d=this.elements;return d[0]=e,d[1]=i,d[2]=o,d[3]=t,d[4]=s,d[5]=l,d[6]=n,d[7]=a,d[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,s=this.elements,a=n[0],o=n[3],l=n[6],c=n[1],d=n[4],h=n[7],u=n[2],f=n[5],m=n[8],b=i[0],p=i[3],g=i[6],y=i[1],x=i[4],w=i[7],P=i[2],T=i[5],A=i[8];return s[0]=a*b+o*y+l*P,s[3]=a*p+o*x+l*T,s[6]=a*g+o*w+l*A,s[1]=c*b+d*y+h*P,s[4]=c*p+d*x+h*T,s[7]=c*g+d*w+h*A,s[2]=u*b+f*y+m*P,s[5]=u*p+f*x+m*T,s[8]=u*g+f*w+m*A,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],d=e[8];return t*a*d-t*o*c-n*s*d+n*o*l+i*s*c-i*a*l}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],d=e[8],h=d*a-o*c,u=o*l-d*s,f=c*s-a*l,m=t*h+n*u+i*f;if(m===0)return this.set(0,0,0,0,0,0,0,0,0);const b=1/m;return e[0]=h*b,e[1]=(i*c-d*n)*b,e[2]=(o*n-i*a)*b,e[3]=u*b,e[4]=(d*t-i*l)*b,e[5]=(i*s-o*t)*b,e[6]=f*b,e[7]=(n*l-c*t)*b,e[8]=(a*t-n*s)*b,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,i,s,a,o){const l=Math.cos(s),c=Math.sin(s);return this.set(n*l,n*c,-n*(l*a+c*o)+a+e,-i*c,i*l,-i*(-c*a+l*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply($c.makeScale(e,t)),this}rotate(e){return this.premultiply($c.makeRotation(-e)),this}translate(e,t){return this.premultiply($c.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,n=e.elements;for(let i=0;i<9;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const $c=new xt;function xb(r){for(let e=r.length-1;e>=0;--e)if(r[e]>=65535)return!0;return!1}function xo(r){return document.createElementNS("http://www.w3.org/1999/xhtml",r)}function Yx(){const r=xo("canvas");return r.style.display="block",r}const Of={};function hr(r){r in Of||(Of[r]=!0,console.warn(r))}function Kx(r,e,t){return new Promise(function(n,i){function s(){switch(r.clientWaitSync(e,r.SYNC_FLUSH_COMMANDS_BIT,0)){case r.WAIT_FAILED:i();break;case r.TIMEOUT_EXPIRED:setTimeout(s,t);break;default:n()}}setTimeout(s,t)})}function $x(r){const e=r.elements;e[2]=.5*e[2]+.5*e[3],e[6]=.5*e[6]+.5*e[7],e[10]=.5*e[10]+.5*e[11],e[14]=.5*e[14]+.5*e[15]}function Qx(r){const e=r.elements;e[11]===-1?(e[10]=-e[10]-1,e[14]=-e[14]):(e[10]=-e[10],e[14]=-e[14]+1)}const Ff=new xt().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Uf=new xt().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Jx(){const r={enabled:!0,workingColorSpace:$n,spaces:{},convert:function(i,s,a){return this.enabled===!1||s===a||!s||!a||(this.spaces[s].transfer===Ht&&(i.r=Ss(i.r),i.g=Ss(i.g),i.b=Ss(i.b)),this.spaces[s].primaries!==this.spaces[a].primaries&&(i.applyMatrix3(this.spaces[s].toXYZ),i.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===Ht&&(i.r=fa(i.r),i.g=fa(i.g),i.b=fa(i.b))),i},fromWorkingColorSpace:function(i,s){return this.convert(i,this.workingColorSpace,s)},toWorkingColorSpace:function(i,s){return this.convert(i,s,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===zs?xc:this.spaces[i].transfer},getLuminanceCoefficients:function(i,s=this.workingColorSpace){return i.fromArray(this.spaces[s].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,s,a){return i.copy(this.spaces[s].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(i){return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(i=this.workingColorSpace){return this.spaces[i].workingColorSpaceConfig.unpackColorSpace}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return r.define({[$n]:{primaries:e,whitePoint:n,transfer:xc,toXYZ:Ff,fromXYZ:Uf,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:gt},outputColorSpaceConfig:{drawingBufferColorSpace:gt}},[gt]:{primaries:e,whitePoint:n,transfer:Ht,toXYZ:Ff,fromXYZ:Uf,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:gt}}}),r}const ft=Jx();function Ss(r){return r<.04045?r*.0773993808:Math.pow(r*.9478672986+.0521327014,2.4)}function fa(r){return r<.0031308?r*12.92:1.055*Math.pow(r,.41666)-.055}let Lr;class e0{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{Lr===void 0&&(Lr=xo("canvas")),Lr.width=e.width,Lr.height=e.height;const n=Lr.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=Lr}return t.toDataURL("image/png")}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=xo("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const i=n.getImageData(0,0,e.width,e.height),s=i.data;for(let a=0;a<s.length;a++)s[a]=Ss(s[a]/255)*255;return n.putImageData(i,0,0),t}else if(e.data){const t=e.data.slice(0);for(let n=0;n<t.length;n++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[n]=Math.floor(Ss(t[n]/255)*255):t[n]=Ss(t[n]);return{data:t,width:e.width,height:e.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let t0=0;class Uu{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:t0++}),this.uuid=ki(),this.data=e,this.dataReady=!0,this.version=0}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const n={uuid:this.uuid,url:""},i=this.data;if(i!==null){let s;if(Array.isArray(i)){s=[];for(let a=0,o=i.length;a<o;a++)i[a].isDataTexture?s.push(Qc(i[a].image)):s.push(Qc(i[a]))}else s=Qc(i);n.url=s}return t||(e.images[this.uuid]=n),n}}function Qc(r){return typeof HTMLImageElement<"u"&&r instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&r instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&r instanceof ImageBitmap?e0.getDataURL(r):r.data?{data:Array.from(r.data),width:r.width,height:r.height,type:r.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let n0=0;class Ut extends Er{constructor(e=Ut.DEFAULT_IMAGE,t=Ut.DEFAULT_MAPPING,n=ui,i=ui,s=bn,a=ji,o=Dn,l=Ms,c=Ut.DEFAULT_ANISOTROPY,d=zs){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:n0++}),this.uuid=ki(),this.name="",this.source=new Uu(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=s,this.minFilter=a,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=l,this.offset=new me(0,0),this.repeat=new me(1,1),this.center=new me(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new xt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=d,this.userData={},this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.pmremVersion=0}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const n={metadata:{version:4.6,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==ab)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Li:e.x=e.x-Math.floor(e.x);break;case ui:e.x=e.x<0?0:1;break;case yc: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 Li:e.y=e.y-Math.floor(e.y);break;case ui:e.y=e.y<0?0:1;break;case yc: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++}}Ut.DEFAULT_IMAGE=null;Ut.DEFAULT_MAPPING=ab;Ut.DEFAULT_ANISOTROPY=1;class _t{constructor(e=0,t=0,n=0,i=1){_t.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,s=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*i+a[12]*s,this.y=a[1]*t+a[5]*n+a[9]*i+a[13]*s,this.z=a[2]*t+a[6]*n+a[10]*i+a[14]*s,this.w=a[3]*t+a[7]*n+a[11]*i+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);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,i,s;const l=e.elements,c=l[0],d=l[4],h=l[8],u=l[1],f=l[5],m=l[9],b=l[2],p=l[6],g=l[10];if(Math.abs(d-u)<.01&&Math.abs(h-b)<.01&&Math.abs(m-p)<.01){if(Math.abs(d+u)<.1&&Math.abs(h+b)<.1&&Math.abs(m+p)<.1&&Math.abs(c+f+g-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const x=(c+1)/2,w=(f+1)/2,P=(g+1)/2,T=(d+u)/4,A=(h+b)/4,M=(m+p)/4;return x>w&&x>P?x<.01?(n=0,i=.707106781,s=.707106781):(n=Math.sqrt(x),i=T/n,s=A/n):w>P?w<.01?(n=.707106781,i=0,s=.707106781):(i=Math.sqrt(w),n=T/i,s=M/i):P<.01?(n=.707106781,i=.707106781,s=0):(s=Math.sqrt(P),n=A/s,i=M/s),this.set(n,i,s,t),this}let y=Math.sqrt((p-m)*(p-m)+(h-b)*(h-b)+(u-d)*(u-d));return Math.abs(y)<.001&&(y=1),this.x=(p-m)/y,this.y=(h-b)/y,this.z=(u-d)/y,this.w=Math.acos((c+f+g-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=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){const 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}}class i0 extends Er{constructor(e=1,t=1,n={}){super(),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new _t(0,0,e,t),this.scissorTest=!1,this.viewport=new _t(0,0,e,t);const i={width:e,height:t,depth:1};n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:bn,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1},n);const s=new Ut(i,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace);s.flipY=!1,s.generateMipmaps=n.generateMipmaps,s.internalFormat=n.internalFormat,this.textures=[];const 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.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}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 i=0,s=this.textures.length;i<s;i++)this.textures[i].image.width=e,this.textures[i].image.height=t,this.textures[i].image.depth=n;this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;const i=Object.assign({},e.textures[t].image);this.textures[t].source=new Uu(i)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class ni extends i0{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}}class _b extends Ut{constructor(e=null,t=1,n=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=Sn,this.minFilter=Sn,this.wrapR=ui,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class s0 extends Ut{constructor(e=null,t=1,n=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=Sn,this.minFilter=Sn,this.wrapR=ui,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Lt{constructor(e=0,t=0,n=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=i}static slerpFlat(e,t,n,i,s,a,o){let l=n[i+0],c=n[i+1],d=n[i+2],h=n[i+3];const u=s[a+0],f=s[a+1],m=s[a+2],b=s[a+3];if(o===0){e[t+0]=l,e[t+1]=c,e[t+2]=d,e[t+3]=h;return}if(o===1){e[t+0]=u,e[t+1]=f,e[t+2]=m,e[t+3]=b;return}if(h!==b||l!==u||c!==f||d!==m){let p=1-o;const g=l*u+c*f+d*m+h*b,y=g>=0?1:-1,x=1-g*g;if(x>Number.EPSILON){const P=Math.sqrt(x),T=Math.atan2(P,g*y);p=Math.sin(p*T)/P,o=Math.sin(o*T)/P}const w=o*y;if(l=l*p+u*w,c=c*p+f*w,d=d*p+m*w,h=h*p+b*w,p===1-o){const P=1/Math.sqrt(l*l+c*c+d*d+h*h);l*=P,c*=P,d*=P,h*=P}}e[t]=l,e[t+1]=c,e[t+2]=d,e[t+3]=h}static multiplyQuaternionsFlat(e,t,n,i,s,a){const o=n[i],l=n[i+1],c=n[i+2],d=n[i+3],h=s[a],u=s[a+1],f=s[a+2],m=s[a+3];return e[t]=o*m+d*h+l*f-c*u,e[t+1]=l*m+d*u+c*h-o*f,e[t+2]=c*m+d*f+o*u-l*h,e[t+3]=d*m-o*h-l*u-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const n=e._x,i=e._y,s=e._z,a=e._order,o=Math.cos,l=Math.sin,c=o(n/2),d=o(i/2),h=o(s/2),u=l(n/2),f=l(i/2),m=l(s/2);switch(a){case"XYZ":this._x=u*d*h+c*f*m,this._y=c*f*h-u*d*m,this._z=c*d*m+u*f*h,this._w=c*d*h-u*f*m;break;case"YXZ":this._x=u*d*h+c*f*m,this._y=c*f*h-u*d*m,this._z=c*d*m-u*f*h,this._w=c*d*h+u*f*m;break;case"ZXY":this._x=u*d*h-c*f*m,this._y=c*f*h+u*d*m,this._z=c*d*m+u*f*h,this._w=c*d*h-u*f*m;break;case"ZYX":this._x=u*d*h-c*f*m,this._y=c*f*h+u*d*m,this._z=c*d*m-u*f*h,this._w=c*d*h+u*f*m;break;case"YZX":this._x=u*d*h+c*f*m,this._y=c*f*h+u*d*m,this._z=c*d*m-u*f*h,this._w=c*d*h-u*f*m;break;case"XZY":this._x=u*d*h-c*f*m,this._y=c*f*h-u*d*m,this._z=c*d*m+u*f*h,this._w=c*d*h+u*f*m;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],i=t[4],s=t[8],a=t[1],o=t[5],l=t[9],c=t[2],d=t[6],h=t[10],u=n+o+h;if(u>0){const f=.5/Math.sqrt(u+1);this._w=.25/f,this._x=(d-l)*f,this._y=(s-c)*f,this._z=(a-i)*f}else if(n>o&&n>h){const f=2*Math.sqrt(1+n-o-h);this._w=(d-l)/f,this._x=.25*f,this._y=(i+a)/f,this._z=(s+c)/f}else if(o>h){const f=2*Math.sqrt(1+o-n-h);this._w=(s-c)/f,this._x=(i+a)/f,this._y=.25*f,this._z=(l+d)/f}else{const f=2*Math.sqrt(1+h-n-o);this._w=(a-i)/f,this._x=(s+c)/f,this._y=(l+d)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<Number.EPSILON?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(yt(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const i=Math.min(1,t/n);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,i=e._y,s=e._z,a=e._w,o=t._x,l=t._y,c=t._z,d=t._w;return this._x=n*d+a*o+i*c-s*l,this._y=i*d+a*l+s*o-n*c,this._z=s*d+a*c+n*l-i*o,this._w=a*d-n*o-i*l-s*c,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const n=this._x,i=this._y,s=this._z,a=this._w;let o=a*e._w+n*e._x+i*e._y+s*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=a,this._x=n,this._y=i,this._z=s,this;const l=1-o*o;if(l<=Number.EPSILON){const f=1-t;return this._w=f*a+t*this._w,this._x=f*n+t*this._x,this._y=f*i+t*this._y,this._z=f*s+t*this._z,this.normalize(),this}const c=Math.sqrt(l),d=Math.atan2(c,o),h=Math.sin((1-t)*d)/c,u=Math.sin(t*d)/c;return this._w=a*h+this._w*u,this._x=n*h+this._x*u,this._y=i*h+this._y*u,this._z=s*h+this._z*u,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),s=Math.sqrt(n);return this.set(i*Math.sin(e),i*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}}class I{constructor(e=0,t=0,n=0){I.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Bf.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Bf.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,i=this.z,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6]*i,this.y=s[1]*t+s[4]*n+s[7]*i,this.z=s[2]*t+s[5]*n+s[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,s=e.elements,a=1/(s[3]*t+s[7]*n+s[11]*i+s[15]);return this.x=(s[0]*t+s[4]*n+s[8]*i+s[12])*a,this.y=(s[1]*t+s[5]*n+s[9]*i+s[13])*a,this.z=(s[2]*t+s[6]*n+s[10]*i+s[14])*a,this}applyQuaternion(e){const t=this.x,n=this.y,i=this.z,s=e.x,a=e.y,o=e.z,l=e.w,c=2*(a*i-o*n),d=2*(o*t-s*i),h=2*(s*n-a*t);return this.x=t+l*c+a*h-o*d,this.y=n+l*d+o*c-s*h,this.z=i+l*h+s*d-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){const t=this.x,n=this.y,i=this.z,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*i,this.y=s[1]*t+s[5]*n+s[9]*i,this.z=s[2]*t+s[6]*n+s[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=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){const 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){const n=e.x,i=e.y,s=e.z,a=t.x,o=t.y,l=t.z;return this.x=i*l-s*o,this.y=s*a-n*l,this.z=n*o-i*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Jc.copy(this).projectOnVector(e),this.sub(Jc)}reflect(e){return this.sub(Jc.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(yt(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Jc=new I,Bf=new Lt;class Yt{constructor(e=new I(1/0,1/0,1/0),t=new I(-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(Ui.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(Ui.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=Ui.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);const n=e.geometry;if(n!==void 0){const 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,Ui):Ui.fromBufferAttribute(s,a),Ui.applyMatrix4(e.matrixWorld),this.expandByPoint(Ui);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Zo.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),Zo.copy(n.boundingBox)),Zo.applyMatrix4(e.matrixWorld),this.union(Zo)}const i=e.children;for(let s=0,a=i.length;s<a;s++)this.expandByObject(i[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,Ui),Ui.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(Ua),Yo.subVectors(this.max,Ua),Ir.subVectors(e.a,Ua),kr.subVectors(e.b,Ua),Or.subVectors(e.c,Ua),Ps.subVectors(kr,Ir),Rs.subVectors(Or,kr),er.subVectors(Ir,Or);let t=[0,-Ps.z,Ps.y,0,-Rs.z,Rs.y,0,-er.z,er.y,Ps.z,0,-Ps.x,Rs.z,0,-Rs.x,er.z,0,-er.x,-Ps.y,Ps.x,0,-Rs.y,Rs.x,0,-er.y,er.x,0];return!ed(t,Ir,kr,Or,Yo)||(t=[1,0,0,0,1,0,0,0,1],!ed(t,Ir,kr,Or,Yo))?!1:(Ko.crossVectors(Ps,Rs),t=[Ko.x,Ko.y,Ko.z],ed(t,Ir,kr,Or,Yo))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Ui).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Ui).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:(ds[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),ds[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),ds[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),ds[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),ds[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),ds[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),ds[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),ds[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(ds),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const ds=[new I,new I,new I,new I,new I,new I,new I,new I],Ui=new I,Zo=new Yt,Ir=new I,kr=new I,Or=new I,Ps=new I,Rs=new I,er=new I,Ua=new I,Yo=new I,Ko=new I,tr=new I;function ed(r,e,t,n,i){for(let s=0,a=r.length-3;s<=a;s+=3){tr.fromArray(r,s);const o=i.x*Math.abs(tr.x)+i.y*Math.abs(tr.y)+i.z*Math.abs(tr.z),l=e.dot(tr),c=t.dot(tr),d=n.dot(tr);if(Math.max(-Math.max(l,c,d),Math.min(l,c,d))>o)return!1}return!0}const r0=new Yt,Ba=new I,td=new I;class vn{constructor(e=new I,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;t!==void 0?n.copy(t):r0.setFromPoints(e).getCenter(n);let i=0;for(let s=0,a=e.length;s<a;s++)i=Math.max(i,n.distanceToSquared(e[s]));return this.radius=Math.sqrt(i),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){const n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Ba.subVectors(e,this.center);const t=Ba.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),i=(n-this.radius)*.5;this.center.addScaledVector(Ba,i/n),this.radius+=i}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(Ba.copy(e.center).add(td)),this.expandByPoint(Ba.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)}}const hs=new I,nd=new I,$o=new I,Ns=new I,id=new I,Qo=new I,sd=new I;class Aa{constructor(e=new I,t=new I(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,hs)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=hs.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(hs.copy(this.origin).addScaledVector(this.direction,t),hs.distanceToSquared(e))}distanceSqToSegment(e,t,n,i){nd.copy(e).add(t).multiplyScalar(.5),$o.copy(t).sub(e).normalize(),Ns.copy(this.origin).sub(nd);const s=e.distanceTo(t)*.5,a=-this.direction.dot($o),o=Ns.dot(this.direction),l=-Ns.dot($o),c=Ns.lengthSq(),d=Math.abs(1-a*a);let h,u,f,m;if(d>0)if(h=a*l-o,u=a*o-l,m=s*d,h>=0)if(u>=-m)if(u<=m){const b=1/d;h*=b,u*=b,f=h*(h+a*u+2*o)+u*(a*h+u+2*l)+c}else u=s,h=Math.max(0,-(a*u+o)),f=-h*h+u*(u+2*l)+c;else u=-s,h=Math.max(0,-(a*u+o)),f=-h*h+u*(u+2*l)+c;else u<=-m?(h=Math.max(0,-(-a*s+o)),u=h>0?-s:Math.min(Math.max(-s,-l),s),f=-h*h+u*(u+2*l)+c):u<=m?(h=0,u=Math.min(Math.max(-s,-l),s),f=u*(u+2*l)+c):(h=Math.max(0,-(a*s+o)),u=h>0?s:Math.min(Math.max(-s,-l),s),f=-h*h+u*(u+2*l)+c);else u=a>0?-s:s,h=Math.max(0,-(a*u+o)),f=-h*h+u*(u+2*l)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,h),i&&i.copy(nd).addScaledVector($o,u),f}intersectSphere(e,t){hs.subVectors(e.center,this.origin);const n=hs.dot(this.direction),i=hs.dot(hs)-n*n,s=e.radius*e.radius;if(i>s)return null;const a=Math.sqrt(s-i),o=n-a,l=n+a;return l<0?null:o<0?this.at(l,t):this.at(o,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,i,s,a,o,l;const c=1/this.direction.x,d=1/this.direction.y,h=1/this.direction.z,u=this.origin;return c>=0?(n=(e.min.x-u.x)*c,i=(e.max.x-u.x)*c):(n=(e.max.x-u.x)*c,i=(e.min.x-u.x)*c),d>=0?(s=(e.min.y-u.y)*d,a=(e.max.y-u.y)*d):(s=(e.max.y-u.y)*d,a=(e.min.y-u.y)*d),n>a||s>i||((s>n||isNaN(n))&&(n=s),(a<i||isNaN(i))&&(i=a),h>=0?(o=(e.min.z-u.z)*h,l=(e.max.z-u.z)*h):(o=(e.max.z-u.z)*h,l=(e.min.z-u.z)*h),n>l||o>i)||((o>n||n!==n)&&(n=o),(l<i||i!==i)&&(i=l),i<0)?null:this.at(n>=0?n:i,t)}intersectsBox(e){return this.intersectBox(e,hs)!==null}intersectTriangle(e,t,n,i,s){id.subVectors(t,e),Qo.subVectors(n,e),sd.crossVectors(id,Qo);let a=this.direction.dot(sd),o;if(a>0){if(i)return null;o=1}else if(a<0)o=-1,a=-a;else return null;Ns.subVectors(this.origin,e);const l=o*this.direction.dot(Qo.crossVectors(Ns,Qo));if(l<0)return null;const c=o*this.direction.dot(id.cross(Ns));if(c<0||l+c>a)return null;const d=-o*Ns.dot(sd);return d<0?null:this.at(d/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)}}class Ie{constructor(e,t,n,i,s,a,o,l,c,d,h,u,f,m,b,p){Ie.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,n,i,s,a,o,l,c,d,h,u,f,m,b,p)}set(e,t,n,i,s,a,o,l,c,d,h,u,f,m,b,p){const g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=i,g[1]=s,g[5]=a,g[9]=o,g[13]=l,g[2]=c,g[6]=d,g[10]=h,g[14]=u,g[3]=f,g[7]=m,g[11]=b,g[15]=p,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 Ie().fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,n=e.elements,i=1/Fr.setFromMatrixColumn(e,0).length(),s=1/Fr.setFromMatrixColumn(e,1).length(),a=1/Fr.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*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){const t=this.elements,n=e.x,i=e.y,s=e.z,a=Math.cos(n),o=Math.sin(n),l=Math.cos(i),c=Math.sin(i),d=Math.cos(s),h=Math.sin(s);if(e.order==="XYZ"){const u=a*d,f=a*h,m=o*d,b=o*h;t[0]=l*d,t[4]=-l*h,t[8]=c,t[1]=f+m*c,t[5]=u-b*c,t[9]=-o*l,t[2]=b-u*c,t[6]=m+f*c,t[10]=a*l}else if(e.order==="YXZ"){const u=l*d,f=l*h,m=c*d,b=c*h;t[0]=u+b*o,t[4]=m*o-f,t[8]=a*c,t[1]=a*h,t[5]=a*d,t[9]=-o,t[2]=f*o-m,t[6]=b+u*o,t[10]=a*l}else if(e.order==="ZXY"){const u=l*d,f=l*h,m=c*d,b=c*h;t[0]=u-b*o,t[4]=-a*h,t[8]=m+f*o,t[1]=f+m*o,t[5]=a*d,t[9]=b-u*o,t[2]=-a*c,t[6]=o,t[10]=a*l}else if(e.order==="ZYX"){const u=a*d,f=a*h,m=o*d,b=o*h;t[0]=l*d,t[4]=m*c-f,t[8]=u*c+b,t[1]=l*h,t[5]=b*c+u,t[9]=f*c-m,t[2]=-c,t[6]=o*l,t[10]=a*l}else if(e.order==="YZX"){const u=a*l,f=a*c,m=o*l,b=o*c;t[0]=l*d,t[4]=b-u*h,t[8]=m*h+f,t[1]=h,t[5]=a*d,t[9]=-o*d,t[2]=-c*d,t[6]=f*h+m,t[10]=u-b*h}else if(e.order==="XZY"){const u=a*l,f=a*c,m=o*l,b=o*c;t[0]=l*d,t[4]=-h,t[8]=c*d,t[1]=u*h+b,t[5]=a*d,t[9]=f*h-m,t[2]=m*h-f,t[6]=o*d,t[10]=b*h+u}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(a0,e,o0)}lookAt(e,t,n){const i=this.elements;return mi.subVectors(e,t),mi.lengthSq()===0&&(mi.z=1),mi.normalize(),Ds.crossVectors(n,mi),Ds.lengthSq()===0&&(Math.abs(n.z)===1?mi.x+=1e-4:mi.z+=1e-4,mi.normalize(),Ds.crossVectors(n,mi)),Ds.normalize(),Jo.crossVectors(mi,Ds),i[0]=Ds.x,i[4]=Jo.x,i[8]=mi.x,i[1]=Ds.y,i[5]=Jo.y,i[9]=mi.y,i[2]=Ds.z,i[6]=Jo.z,i[10]=mi.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,s=this.elements,a=n[0],o=n[4],l=n[8],c=n[12],d=n[1],h=n[5],u=n[9],f=n[13],m=n[2],b=n[6],p=n[10],g=n[14],y=n[3],x=n[7],w=n[11],P=n[15],T=i[0],A=i[4],M=i[8],_=i[12],S=i[1],R=i[5],k=i[9],O=i[13],H=i[2],q=i[6],G=i[10],K=i[14],V=i[3],Y=i[7],le=i[11],se=i[15];return s[0]=a*T+o*S+l*H+c*V,s[4]=a*A+o*R+l*q+c*Y,s[8]=a*M+o*k+l*G+c*le,s[12]=a*_+o*O+l*K+c*se,s[1]=d*T+h*S+u*H+f*V,s[5]=d*A+h*R+u*q+f*Y,s[9]=d*M+h*k+u*G+f*le,s[13]=d*_+h*O+u*K+f*se,s[2]=m*T+b*S+p*H+g*V,s[6]=m*A+b*R+p*q+g*Y,s[10]=m*M+b*k+p*G+g*le,s[14]=m*_+b*O+p*K+g*se,s[3]=y*T+x*S+w*H+P*V,s[7]=y*A+x*R+w*q+P*Y,s[11]=y*M+x*k+w*G+P*le,s[15]=y*_+x*O+w*K+P*se,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[4],i=e[8],s=e[12],a=e[1],o=e[5],l=e[9],c=e[13],d=e[2],h=e[6],u=e[10],f=e[14],m=e[3],b=e[7],p=e[11],g=e[15];return m*(+s*l*h-i*c*h-s*o*u+n*c*u+i*o*f-n*l*f)+b*(+t*l*f-t*c*u+s*a*u-i*a*f+i*c*d-s*l*d)+p*(+t*c*h-t*o*f-s*a*h+n*a*f+s*o*d-n*c*d)+g*(-i*o*d-t*l*h+t*o*u+i*a*h-n*a*u+n*l*d)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],d=e[8],h=e[9],u=e[10],f=e[11],m=e[12],b=e[13],p=e[14],g=e[15],y=h*p*c-b*u*c+b*l*f-o*p*f-h*l*g+o*u*g,x=m*u*c-d*p*c-m*l*f+a*p*f+d*l*g-a*u*g,w=d*b*c-m*h*c+m*o*f-a*b*f-d*o*g+a*h*g,P=m*h*l-d*b*l-m*o*u+a*b*u+d*o*p-a*h*p,T=t*y+n*x+i*w+s*P;if(T===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const A=1/T;return e[0]=y*A,e[1]=(b*u*s-h*p*s-b*i*f+n*p*f+h*i*g-n*u*g)*A,e[2]=(o*p*s-b*l*s+b*i*c-n*p*c-o*i*g+n*l*g)*A,e[3]=(h*l*s-o*u*s-h*i*c+n*u*c+o*i*f-n*l*f)*A,e[4]=x*A,e[5]=(d*p*s-m*u*s+m*i*f-t*p*f-d*i*g+t*u*g)*A,e[6]=(m*l*s-a*p*s-m*i*c+t*p*c+a*i*g-t*l*g)*A,e[7]=(a*u*s-d*l*s+d*i*c-t*u*c-a*i*f+t*l*f)*A,e[8]=w*A,e[9]=(m*h*s-d*b*s-m*n*f+t*b*f+d*n*g-t*h*g)*A,e[10]=(a*b*s-m*o*s+m*n*c-t*b*c-a*n*g+t*o*g)*A,e[11]=(d*o*s-a*h*s-d*n*c+t*h*c+a*n*f-t*o*f)*A,e[12]=P*A,e[13]=(d*b*i-m*h*i+m*n*u-t*b*u-d*n*p+t*h*p)*A,e[14]=(m*o*i-a*b*i-m*n*l+t*b*l+a*n*p-t*o*p)*A,e[15]=(a*h*i-d*o*i+d*n*l-t*h*l-a*n*u+t*o*u)*A,this}scale(e){const t=this.elements,n=e.x,i=e.y,s=e.z;return t[0]*=n,t[4]*=i,t[8]*=s,t[1]*=n,t[5]*=i,t[9]*=s,t[2]*=n,t[6]*=i,t[10]*=s,t[3]*=n,t[7]*=i,t[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),i=Math.sin(t),s=1-n,a=e.x,o=e.y,l=e.z,c=s*a,d=s*o;return this.set(c*a+n,c*o-i*l,c*l+i*o,0,c*o+i*l,d*o+n,d*l-i*a,0,c*l-i*o,d*l+i*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,i,s,a){return this.set(1,n,s,0,e,1,a,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){const i=this.elements,s=t._x,a=t._y,o=t._z,l=t._w,c=s+s,d=a+a,h=o+o,u=s*c,f=s*d,m=s*h,b=a*d,p=a*h,g=o*h,y=l*c,x=l*d,w=l*h,P=n.x,T=n.y,A=n.z;return i[0]=(1-(b+g))*P,i[1]=(f+w)*P,i[2]=(m-x)*P,i[3]=0,i[4]=(f-w)*T,i[5]=(1-(u+g))*T,i[6]=(p+y)*T,i[7]=0,i[8]=(m+x)*A,i[9]=(p-y)*A,i[10]=(1-(u+b))*A,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){const i=this.elements;let s=Fr.set(i[0],i[1],i[2]).length();const a=Fr.set(i[4],i[5],i[6]).length(),o=Fr.set(i[8],i[9],i[10]).length();this.determinant()<0&&(s=-s),e.x=i[12],e.y=i[13],e.z=i[14],Bi.copy(this);const c=1/s,d=1/a,h=1/o;return Bi.elements[0]*=c,Bi.elements[1]*=c,Bi.elements[2]*=c,Bi.elements[4]*=d,Bi.elements[5]*=d,Bi.elements[6]*=d,Bi.elements[8]*=h,Bi.elements[9]*=h,Bi.elements[10]*=h,t.setFromRotationMatrix(Bi),n.x=s,n.y=a,n.z=o,this}makePerspective(e,t,n,i,s,a,o=_s){const l=this.elements,c=2*s/(t-e),d=2*s/(n-i),h=(t+e)/(t-e),u=(n+i)/(n-i);let f,m;if(o===_s)f=-(a+s)/(a-s),m=-2*a*s/(a-s);else if(o===_c)f=-a/(a-s),m=-a*s/(a-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=c,l[4]=0,l[8]=h,l[12]=0,l[1]=0,l[5]=d,l[9]=u,l[13]=0,l[2]=0,l[6]=0,l[10]=f,l[14]=m,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,t,n,i,s,a,o=_s){const l=this.elements,c=1/(t-e),d=1/(n-i),h=1/(a-s),u=(t+e)*c,f=(n+i)*d;let m,b;if(o===_s)m=(a+s)*h,b=-2*h;else if(o===_c)m=s*h,b=-1*h;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=2*c,l[4]=0,l[8]=0,l[12]=-u,l[1]=0,l[5]=2*d,l[9]=0,l[13]=-f,l[2]=0,l[6]=0,l[10]=b,l[14]=-m,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let i=0;i<16;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}const Fr=new I,Bi=new Ie,a0=new I(0,0,0),o0=new I(1,1,1),Ds=new I,Jo=new I,mi=new I,zf=new Ie,Hf=new Lt;class hn{constructor(e=0,t=0,n=0,i=hn.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const i=e.elements,s=i[0],a=i[4],o=i[8],l=i[1],c=i[5],d=i[9],h=i[2],u=i[6],f=i[10];switch(t){case"XYZ":this._y=Math.asin(yt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-d,f),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(u,c),this._z=0);break;case"YXZ":this._x=Math.asin(-yt(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-h,s),this._z=0);break;case"ZXY":this._x=Math.asin(yt(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-h,f),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-yt(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(u,f),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-a,c));break;case"YZX":this._z=Math.asin(yt(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-d,c),this._y=Math.atan2(-h,s)):(this._x=0,this._y=Math.atan2(o,f));break;case"XZY":this._z=Math.asin(-yt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(u,c),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-d,f),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return zf.makeRotationFromQuaternion(e),this.setFromRotationMatrix(zf,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Hf.setFromEuler(this),this.setFromQuaternion(Hf,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}}hn.DEFAULT_ORDER="XYZ";class Bu{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}let l0=0;const Gf=new I,Ur=new Lt,us=new Ie,el=new I,za=new I,c0=new I,d0=new Lt,Vf=new I(1,0,0),Wf=new I(0,1,0),jf=new I(0,0,1),Xf={type:"added"},h0={type:"removed"},Br={type:"childadded",child:null},rd={type:"childremoved",child:null};class Pt extends Er{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:l0++}),this.uuid=ki(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Pt.DEFAULT_UP.clone();const e=new I,t=new hn,n=new Lt,i=new I(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:i},modelViewMatrix:{value:new Ie},normalMatrix:{value:new xt}}),this.matrix=new Ie,this.matrixWorld=new Ie,this.matrixAutoUpdate=Pt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Pt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Bu,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return Ur.setFromAxisAngle(e,t),this.quaternion.multiply(Ur),this}rotateOnWorldAxis(e,t){return Ur.setFromAxisAngle(e,t),this.quaternion.premultiply(Ur),this}rotateX(e){return this.rotateOnAxis(Vf,e)}rotateY(e){return this.rotateOnAxis(Wf,e)}rotateZ(e){return this.rotateOnAxis(jf,e)}translateOnAxis(e,t){return Gf.copy(e).applyQuaternion(this.quaternion),this.position.add(Gf.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Vf,e)}translateY(e){return this.translateOnAxis(Wf,e)}translateZ(e){return this.translateOnAxis(jf,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(us.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?el.copy(e):el.set(e,t,n);const i=this.parent;this.updateWorldMatrix(!0,!1),za.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?us.lookAt(za,el,this.up):us.lookAt(el,za,this.up),this.quaternion.setFromRotationMatrix(us),i&&(us.extractRotation(i.matrixWorld),Ur.setFromRotationMatrix(us),this.quaternion.premultiply(Ur.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(Xf),Br.child=e,this.dispatchEvent(Br),Br.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(h0),rd.child=e,this.dispatchEvent(rd),rd.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),us.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),us.multiply(e.parent.matrixWorld)),e.applyMatrix4(us),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Xf),Br.child=e,this.dispatchEvent(Br),Br.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,i=this.children.length;n<i;n++){const a=this.children[n].getObjectByProperty(e,t);if(a!==void 0)return a}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);const i=this.children;for(let s=0,a=i.length;s<a;s++)i[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(za,e,c0),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(za,d0,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverseVisible(e)}traverseAncestors(e){const t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t){const n=this.parent;if(e===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),t===!0){const i=this.children;for(let s=0,a=i.length;s<a;s++)i[s].updateWorldMatrix(!1,!0)}}toJSON(e){const t=e===void 0||typeof e=="string",n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.visibility=this._visibility,i.active=this._active,i.bounds=this._bounds.map(o=>({boxInitialized:o.boxInitialized,boxMin:o.box.min.toArray(),boxMax:o.box.max.toArray(),sphereInitialized:o.sphereInitialized,sphereRadius:o.sphere.radius,sphereCenter:o.sphere.center.toArray()})),i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.geometryCount=this._geometryCount,i.matricesTexture=this._matricesTexture.toJSON(e),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(i.boundingSphere={center:i.boundingSphere.center.toArray(),radius:i.boundingSphere.radius}),this.boundingBox!==null&&(i.boundingBox={min:i.boundingBox.min.toArray(),max:i.boundingBox.max.toArray()}));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?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=s(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let c=0,d=l.length;c<d;c++){const h=l[c];s(e.shapes,h)}else s(e.shapes,l)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let l=0,c=this.material.length;l<c;l++)o.push(s(e.materials,this.material[l]));i.material=o}else i.material=s(e.materials,this.material);if(this.children.length>0){i.children=[];for(let o=0;o<this.children.length;o++)i.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let o=0;o<this.animations.length;o++){const l=this.animations[o];i.animations.push(s(e.animations,l))}}if(t){const o=a(e.geometries),l=a(e.materials),c=a(e.textures),d=a(e.images),h=a(e.shapes),u=a(e.skeletons),f=a(e.animations),m=a(e.nodes);o.length>0&&(n.geometries=o),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),d.length>0&&(n.images=d),h.length>0&&(n.shapes=h),u.length>0&&(n.skeletons=u),f.length>0&&(n.animations=f),m.length>0&&(n.nodes=m)}return n.object=i,n;function a(o){const l=[];for(const c in o){const d=o[c];delete d.metadata,l.push(d)}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.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){const i=e.children[n];this.add(i.clone())}return this}}Pt.DEFAULT_UP=new I(0,1,0);Pt.DEFAULT_MATRIX_AUTO_UPDATE=!0;Pt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const zi=new I,fs=new I,ad=new I,ps=new I,zr=new I,Hr=new I,qf=new I,od=new I,ld=new I,cd=new I,dd=new _t,hd=new _t,ud=new _t;class xi{constructor(e=new I,t=new I,n=new I){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,i){i.subVectors(n,t),zi.subVectors(e,t),i.cross(zi);const s=i.lengthSq();return s>0?i.multiplyScalar(1/Math.sqrt(s)):i.set(0,0,0)}static getBarycoord(e,t,n,i,s){zi.subVectors(i,t),fs.subVectors(n,t),ad.subVectors(e,t);const a=zi.dot(zi),o=zi.dot(fs),l=zi.dot(ad),c=fs.dot(fs),d=fs.dot(ad),h=a*c-o*o;if(h===0)return s.set(0,0,0),null;const u=1/h,f=(c*l-o*d)*u,m=(a*d-o*l)*u;return s.set(1-f-m,m,f)}static containsPoint(e,t,n,i){return this.getBarycoord(e,t,n,i,ps)===null?!1:ps.x>=0&&ps.y>=0&&ps.x+ps.y<=1}static getInterpolation(e,t,n,i,s,a,o,l){return this.getBarycoord(e,t,n,i,ps)===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,ps.x),l.addScaledVector(a,ps.y),l.addScaledVector(o,ps.z),l)}static getInterpolatedAttribute(e,t,n,i,s,a){return dd.setScalar(0),hd.setScalar(0),ud.setScalar(0),dd.fromBufferAttribute(e,t),hd.fromBufferAttribute(e,n),ud.fromBufferAttribute(e,i),a.setScalar(0),a.addScaledVector(dd,s.x),a.addScaledVector(hd,s.y),a.addScaledVector(ud,s.z),a}static isFrontFacing(e,t,n,i){return zi.subVectors(n,t),fs.subVectors(e,t),zi.cross(fs).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return zi.subVectors(this.c,this.b),fs.subVectors(this.a,this.b),zi.cross(fs).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return xi.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return xi.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,i,s){return xi.getInterpolation(e,this.a,this.b,this.c,t,n,i,s)}containsPoint(e){return xi.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return xi.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,i=this.b,s=this.c;let a,o;zr.subVectors(i,n),Hr.subVectors(s,n),od.subVectors(e,n);const l=zr.dot(od),c=Hr.dot(od);if(l<=0&&c<=0)return t.copy(n);ld.subVectors(e,i);const d=zr.dot(ld),h=Hr.dot(ld);if(d>=0&&h<=d)return t.copy(i);const u=l*h-d*c;if(u<=0&&l>=0&&d<=0)return a=l/(l-d),t.copy(n).addScaledVector(zr,a);cd.subVectors(e,s);const f=zr.dot(cd),m=Hr.dot(cd);if(m>=0&&f<=m)return t.copy(s);const b=f*c-l*m;if(b<=0&&c>=0&&m<=0)return o=c/(c-m),t.copy(n).addScaledVector(Hr,o);const p=d*m-f*h;if(p<=0&&h-d>=0&&f-m>=0)return qf.subVectors(s,i),o=(h-d)/(h-d+(f-m)),t.copy(i).addScaledVector(qf,o);const g=1/(p+b+u);return a=b*g,o=u*g,t.copy(n).addScaledVector(zr,a).addScaledVector(Hr,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const wb={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},Ls={h:0,s:0,l:0},tl={h:0,s:0,l:0};function fd(r,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?r+(e-r)*6*t:t<1/2?e:t<2/3?r+(e-r)*6*(2/3-t):r}class Ne{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){const i=e;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=gt){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,ft.toWorkingColorSpace(this,t),this}setRGB(e,t,n,i=ft.workingColorSpace){return this.r=e,this.g=t,this.b=n,ft.toWorkingColorSpace(this,i),this}setHSL(e,t,n,i=ft.workingColorSpace){if(e=Fu(e,1),t=yt(t,0,1),n=yt(n,0,1),t===0)this.r=this.g=this.b=n;else{const s=n<=.5?n*(1+t):n+t-n*t,a=2*n-s;this.r=fd(a,s,e+1/3),this.g=fd(a,s,e),this.b=fd(a,s,e-1/3)}return ft.toWorkingColorSpace(this,i),this}setStyle(e,t=gt){function n(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const a=i[1],o=i[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:console.warn("THREE.Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=i[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);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=gt){const n=wb[e.toLowerCase()];return n!==void 0?this.setHex(n,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Ss(e.r),this.g=Ss(e.g),this.b=Ss(e.b),this}copyLinearToSRGB(e){return this.r=fa(e.r),this.g=fa(e.g),this.b=fa(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=gt){return ft.fromWorkingColorSpace(Wn.copy(this),e),Math.round(yt(Wn.r*255,0,255))*65536+Math.round(yt(Wn.g*255,0,255))*256+Math.round(yt(Wn.b*255,0,255))}getHexString(e=gt){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=ft.workingColorSpace){ft.fromWorkingColorSpace(Wn.copy(this),t);const n=Wn.r,i=Wn.g,s=Wn.b,a=Math.max(n,i,s),o=Math.min(n,i,s);let l,c;const d=(o+a)/2;if(o===a)l=0,c=0;else{const h=a-o;switch(c=d<=.5?h/(a+o):h/(2-a-o),a){case n:l=(i-s)/h+(i<s?6:0);break;case i:l=(s-n)/h+2;break;case s:l=(n-i)/h+4;break}l/=6}return e.h=l,e.s=c,e.l=d,e}getRGB(e,t=ft.workingColorSpace){return ft.fromWorkingColorSpace(Wn.copy(this),t),e.r=Wn.r,e.g=Wn.g,e.b=Wn.b,e}getStyle(e=gt){ft.fromWorkingColorSpace(Wn.copy(this),e);const t=Wn.r,n=Wn.g,i=Wn.b;return e!==gt?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(i*255)})`}offsetHSL(e,t,n){return this.getHSL(Ls),this.setHSL(Ls.h+e,Ls.s+t,Ls.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(Ls),e.getHSL(tl);const n=co(Ls.h,tl.h,t),i=co(Ls.s,tl.s,t),s=co(Ls.l,tl.l,t);return this.setHSL(n,i,s),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,n=this.g,i=this.b,s=e.elements;return this.r=s[0]*t+s[3]*n+s[6]*i,this.g=s[1]*t+s[4]*n+s[7]*i,this.b=s[2]*t+s[5]*n+s[8]*i,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const Wn=new Ne;Ne.NAMES=wb;let u0=0;class wi extends Er{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:u0++}),this.uuid=ki(),this.name="",this.type="Material",this.blending=da,this.side=Si,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Ch,this.blendDst=Ph,this.blendEquation=pr,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Ne(0,0,0),this.blendAlpha=0,this.depthFunc=va,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Lf,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Dr,this.stencilZFail=Dr,this.stencilZPass=Dr,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.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const n=e[t];if(n===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}const i=this[t];if(i===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const n={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==da&&(n.blending=this.blending),this.side!==Si&&(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!==Ch&&(n.blendSrc=this.blendSrc),this.blendDst!==Ph&&(n.blendDst=this.blendDst),this.blendEquation!==pr&&(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!==va&&(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!==Lf&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Dr&&(n.stencilFail=this.stencilFail),this.stencilZFail!==Dr&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==Dr&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function i(s){const a=[];for(const o in s){const l=s[o];delete l.metadata,a.push(l)}return a}if(t){const s=i(e.textures),a=i(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;const t=e.clippingPlanes;let n=null;if(t!==null){const i=t.length;n=new Array(i);for(let s=0;s!==i;++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.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++}onBuild(){console.warn("Material: onBuild() has been removed.")}}class jt extends wi{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Ne(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 hn,this.combine=Dc,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const pn=new I,nl=new me;let f0=0;class rn{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:f0++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=hu,this.updateRanges=[],this.gpuType=_i,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 i=0,s=this.itemSize;i<s;i++)this.array[e+i]=t.array[n+i];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++)nl.fromBufferAttribute(this,t),nl.applyMatrix3(e),this.setXY(t,nl.x,nl.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)pn.fromBufferAttribute(this,t),pn.applyMatrix3(e),this.setXYZ(t,pn.x,pn.y,pn.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)pn.fromBufferAttribute(this,t),pn.applyMatrix4(e),this.setXYZ(t,pn.x,pn.y,pn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)pn.fromBufferAttribute(this,t),pn.applyNormalMatrix(e),this.setXYZ(t,pn.x,pn.y,pn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)pn.fromBufferAttribute(this,t),pn.transformDirection(e),this.setXYZ(t,pn.x,pn.y,pn.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=Wi(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=Gt(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=Wi(t,this.array)),t}setX(e,t){return this.normalized&&(t=Gt(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=Wi(t,this.array)),t}setY(e,t){return this.normalized&&(t=Gt(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=Wi(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Gt(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=Wi(t,this.array)),t}setW(e,t){return this.normalized&&(t=Gt(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=Gt(t,this.array),n=Gt(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,i){return e*=this.itemSize,this.normalized&&(t=Gt(t,this.array),n=Gt(n,this.array),i=Gt(i,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this}setXYZW(e,t,n,i,s){return e*=this.itemSize,this.normalized&&(t=Gt(t,this.array),n=Gt(n,this.array),i=Gt(i,this.array),s=Gt(s,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,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(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==hu&&(e.usage=this.usage),e}}class zu extends rn{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class Hu extends rn{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class ke extends rn{constructor(e,t,n){super(new Float32Array(e),t,n)}}let p0=0;const Mi=new Ie,pd=new Pt,Gr=new I,gi=new Yt,Ha=new Yt,Cn=new I;class ht extends Er{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:p0++}),this.uuid=ki(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(xb(e)?Hu:zu)(e,1):this.index=e,this}setIndirect(e){return this.indirect=e,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const n=this.attributes.normal;if(n!==void 0){const s=new xt().getNormalMatrix(e);n.applyNormalMatrix(s),n.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Mi.makeRotationFromQuaternion(e),this.applyMatrix4(Mi),this}rotateX(e){return Mi.makeRotationX(e),this.applyMatrix4(Mi),this}rotateY(e){return Mi.makeRotationY(e),this.applyMatrix4(Mi),this}rotateZ(e){return Mi.makeRotationZ(e),this.applyMatrix4(Mi),this}translate(e,t,n){return Mi.makeTranslation(e,t,n),this.applyMatrix4(Mi),this}scale(e,t,n){return Mi.makeScale(e,t,n),this.applyMatrix4(Mi),this}lookAt(e){return pd.lookAt(e),pd.updateMatrix(),this.applyMatrix4(pd.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Gr).negate(),this.translate(Gr.x,Gr.y,Gr.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const n=[];for(let i=0,s=e.length;i<s;i++){const a=e[i];n.push(a.x,a.y,a.z||0)}this.setAttribute("position",new ke(n,3))}else{const n=Math.min(e.length,t.count);for(let i=0;i<n;i++){const s=e[i];t.setXYZ(i,s.x,s.y,s.z||0)}e.length>t.count&&console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Yt);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new I(-1/0,-1/0,-1/0),new I(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,i=t.length;n<i;n++){const s=t[n];gi.setFromBufferAttribute(s),this.morphTargetsRelative?(Cn.addVectors(this.boundingBox.min,gi.min),this.boundingBox.expandByPoint(Cn),Cn.addVectors(this.boundingBox.max,gi.max),this.boundingBox.expandByPoint(Cn)):(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))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new vn);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new I,1/0);return}if(e){const n=this.boundingSphere.center;if(gi.setFromBufferAttribute(e),t)for(let s=0,a=t.length;s<a;s++){const o=t[s];Ha.setFromBufferAttribute(o),this.morphTargetsRelative?(Cn.addVectors(gi.min,Ha.min),gi.expandByPoint(Cn),Cn.addVectors(gi.max,Ha.max),gi.expandByPoint(Cn)):(gi.expandByPoint(Ha.min),gi.expandByPoint(Ha.max))}gi.getCenter(n);let i=0;for(let s=0,a=e.count;s<a;s++)Cn.fromBufferAttribute(e,s),i=Math.max(i,n.distanceToSquared(Cn));if(t)for(let s=0,a=t.length;s<a;s++){const o=t[s],l=this.morphTargetsRelative;for(let c=0,d=o.count;c<d;c++)Cn.fromBufferAttribute(o,c),l&&(Gr.fromBufferAttribute(e,c),Cn.add(Gr)),i=Math.max(i,n.distanceToSquared(Cn))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const n=t.position,i=t.normal,s=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new rn(new Float32Array(4*n.count),4));const a=this.getAttribute("tangent"),o=[],l=[];for(let M=0;M<n.count;M++)o[M]=new I,l[M]=new I;const c=new I,d=new I,h=new I,u=new me,f=new me,m=new me,b=new I,p=new I;function g(M,_,S){c.fromBufferAttribute(n,M),d.fromBufferAttribute(n,_),h.fromBufferAttribute(n,S),u.fromBufferAttribute(s,M),f.fromBufferAttribute(s,_),m.fromBufferAttribute(s,S),d.sub(c),h.sub(c),f.sub(u),m.sub(u);const R=1/(f.x*m.y-m.x*f.y);isFinite(R)&&(b.copy(d).multiplyScalar(m.y).addScaledVector(h,-f.y).multiplyScalar(R),p.copy(h).multiplyScalar(f.x).addScaledVector(d,-m.x).multiplyScalar(R),o[M].add(b),o[_].add(b),o[S].add(b),l[M].add(p),l[_].add(p),l[S].add(p))}let y=this.groups;y.length===0&&(y=[{start:0,count:e.count}]);for(let M=0,_=y.length;M<_;++M){const S=y[M],R=S.start,k=S.count;for(let O=R,H=R+k;O<H;O+=3)g(e.getX(O+0),e.getX(O+1),e.getX(O+2))}const x=new I,w=new I,P=new I,T=new I;function A(M){P.fromBufferAttribute(i,M),T.copy(P);const _=o[M];x.copy(_),x.sub(P.multiplyScalar(P.dot(_))).normalize(),w.crossVectors(T,_);const R=w.dot(l[M])<0?-1:1;a.setXYZW(M,x.x,x.y,x.z,R)}for(let M=0,_=y.length;M<_;++M){const S=y[M],R=S.start,k=S.count;for(let O=R,H=R+k;O<H;O+=3)A(e.getX(O+0)),A(e.getX(O+1)),A(e.getX(O+2))}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new rn(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let u=0,f=n.count;u<f;u++)n.setXYZ(u,0,0,0);const i=new I,s=new I,a=new I,o=new I,l=new I,c=new I,d=new I,h=new I;if(e)for(let u=0,f=e.count;u<f;u+=3){const m=e.getX(u+0),b=e.getX(u+1),p=e.getX(u+2);i.fromBufferAttribute(t,m),s.fromBufferAttribute(t,b),a.fromBufferAttribute(t,p),d.subVectors(a,s),h.subVectors(i,s),d.cross(h),o.fromBufferAttribute(n,m),l.fromBufferAttribute(n,b),c.fromBufferAttribute(n,p),o.add(d),l.add(d),c.add(d),n.setXYZ(m,o.x,o.y,o.z),n.setXYZ(b,l.x,l.y,l.z),n.setXYZ(p,c.x,c.y,c.z)}else for(let u=0,f=t.count;u<f;u+=3)i.fromBufferAttribute(t,u+0),s.fromBufferAttribute(t,u+1),a.fromBufferAttribute(t,u+2),d.subVectors(a,s),h.subVectors(i,s),d.cross(h),n.setXYZ(u+0,d.x,d.y,d.z),n.setXYZ(u+1,d.x,d.y,d.z),n.setXYZ(u+2,d.x,d.y,d.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)Cn.fromBufferAttribute(e,t),Cn.normalize(),e.setXYZ(t,Cn.x,Cn.y,Cn.z)}toNonIndexed(){function e(o,l){const c=o.array,d=o.itemSize,h=o.normalized,u=new c.constructor(l.length*d);let f=0,m=0;for(let b=0,p=l.length;b<p;b++){o.isInterleavedBufferAttribute?f=l[b]*o.data.stride+o.offset:f=l[b]*d;for(let g=0;g<d;g++)u[m++]=c[f++]}return new rn(u,d,h)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new ht,n=this.index.array,i=this.attributes;for(const o in i){const l=i[o],c=e(l,n);t.setAttribute(o,c)}const s=this.morphAttributes;for(const o in s){const l=[],c=s[o];for(let d=0,h=c.length;d<h;d++){const u=c[d],f=e(u,n);l.push(f)}t.morphAttributes[o]=l}t.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,l=a.length;o<l;o++){const c=a[o];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){const e={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const l in n){const c=n[l];e.data.attributes[l]=c.toJSON(e.data)}const i={};let s=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],d=[];for(let h=0,u=c.length;h<u;h++){const f=c[h];d.push(f.toJSON(e.data))}d.length>0&&(i[l]=d,s=!0)}s&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere={center:o.center.toArray(),radius:o.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;n!==null&&this.setIndex(n.clone(t));const i=e.attributes;for(const c in i){const d=i[c];this.setAttribute(c,d.clone(t))}const s=e.morphAttributes;for(const c in s){const d=[],h=s[c];for(let u=0,f=h.length;u<f;u++)d.push(h[u].clone(t));this.morphAttributes[c]=d}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let c=0,d=a.length;c<d;c++){const h=a[c];this.addGroup(h.start,h.count,h.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const 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"})}}const Zf=new Ie,nr=new Aa,il=new vn,Yf=new I,sl=new I,rl=new I,al=new I,md=new I,ol=new I,Kf=new I,ll=new I;class Ee extends Pt{constructor(e=new ht,t=new jt){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=i.length;s<a;s++){const o=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}getVertexPosition(e,t){const n=this.geometry,i=n.attributes.position,s=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(i,e);const o=this.morphTargetInfluences;if(s&&o){ol.set(0,0,0);for(let l=0,c=s.length;l<c;l++){const d=o[l],h=s[l];d!==0&&(md.fromBufferAttribute(h,e),a?ol.addScaledVector(md,d):ol.addScaledVector(md.sub(t),d))}t.add(ol)}return t}raycast(e,t){const n=this.geometry,i=this.material,s=this.matrixWorld;i!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),il.copy(n.boundingSphere),il.applyMatrix4(s),nr.copy(e.ray).recast(e.near),!(il.containsPoint(nr.origin)===!1&&(nr.intersectSphere(il,Yf)===null||nr.origin.distanceToSquared(Yf)>(e.far-e.near)**2))&&(Zf.copy(s).invert(),nr.copy(e.ray).applyMatrix4(Zf),!(n.boundingBox!==null&&nr.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,nr)))}_computeIntersections(e,t,n){let i;const s=this.geometry,a=this.material,o=s.index,l=s.attributes.position,c=s.attributes.uv,d=s.attributes.uv1,h=s.attributes.normal,u=s.groups,f=s.drawRange;if(o!==null)if(Array.isArray(a))for(let m=0,b=u.length;m<b;m++){const p=u[m],g=a[p.materialIndex],y=Math.max(p.start,f.start),x=Math.min(o.count,Math.min(p.start+p.count,f.start+f.count));for(let w=y,P=x;w<P;w+=3){const T=o.getX(w),A=o.getX(w+1),M=o.getX(w+2);i=cl(this,g,e,n,c,d,h,T,A,M),i&&(i.faceIndex=Math.floor(w/3),i.face.materialIndex=p.materialIndex,t.push(i))}}else{const m=Math.max(0,f.start),b=Math.min(o.count,f.start+f.count);for(let p=m,g=b;p<g;p+=3){const y=o.getX(p),x=o.getX(p+1),w=o.getX(p+2);i=cl(this,a,e,n,c,d,h,y,x,w),i&&(i.faceIndex=Math.floor(p/3),t.push(i))}}else if(l!==void 0)if(Array.isArray(a))for(let m=0,b=u.length;m<b;m++){const p=u[m],g=a[p.materialIndex],y=Math.max(p.start,f.start),x=Math.min(l.count,Math.min(p.start+p.count,f.start+f.count));for(let w=y,P=x;w<P;w+=3){const T=w,A=w+1,M=w+2;i=cl(this,g,e,n,c,d,h,T,A,M),i&&(i.faceIndex=Math.floor(w/3),i.face.materialIndex=p.materialIndex,t.push(i))}}else{const m=Math.max(0,f.start),b=Math.min(l.count,f.start+f.count);for(let p=m,g=b;p<g;p+=3){const y=p,x=p+1,w=p+2;i=cl(this,a,e,n,c,d,h,y,x,w),i&&(i.faceIndex=Math.floor(p/3),t.push(i))}}}}function m0(r,e,t,n,i,s,a,o){let l;if(e.side===fi?l=n.intersectTriangle(a,s,i,!0,o):l=n.intersectTriangle(i,s,a,e.side===Si,o),l===null)return null;ll.copy(o),ll.applyMatrix4(r.matrixWorld);const c=t.ray.origin.distanceTo(ll);return c<t.near||c>t.far?null:{distance:c,point:ll.clone(),object:r}}function cl(r,e,t,n,i,s,a,o,l,c){r.getVertexPosition(o,sl),r.getVertexPosition(l,rl),r.getVertexPosition(c,al);const d=m0(r,e,t,n,sl,rl,al,Kf);if(d){const h=new I;xi.getBarycoord(Kf,sl,rl,al,h),i&&(d.uv=xi.getInterpolatedAttribute(i,o,l,c,h,new me)),s&&(d.uv1=xi.getInterpolatedAttribute(s,o,l,c,h,new me)),a&&(d.normal=xi.getInterpolatedAttribute(a,o,l,c,h,new I),d.normal.dot(n.direction)>0&&d.normal.multiplyScalar(-1));const u={a:o,b:l,c,normal:new I,materialIndex:0};xi.getNormal(sl,rl,al,u.normal),d.face=u,d.barycoord=h}return d}class Jt extends ht{constructor(e=1,t=1,n=1,i=1,s=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:s,depthSegments:a};const o=this;i=Math.floor(i),s=Math.floor(s),a=Math.floor(a);const l=[],c=[],d=[],h=[];let u=0,f=0;m("z","y","x",-1,-1,n,t,e,a,s,0),m("z","y","x",1,-1,n,t,-e,a,s,1),m("x","z","y",1,1,e,n,t,i,a,2),m("x","z","y",1,-1,e,n,-t,i,a,3),m("x","y","z",1,-1,e,t,n,i,s,4),m("x","y","z",-1,-1,e,t,-n,i,s,5),this.setIndex(l),this.setAttribute("position",new ke(c,3)),this.setAttribute("normal",new ke(d,3)),this.setAttribute("uv",new ke(h,2));function m(b,p,g,y,x,w,P,T,A,M,_){const S=w/A,R=P/M,k=w/2,O=P/2,H=T/2,q=A+1,G=M+1;let K=0,V=0;const Y=new I;for(let le=0;le<G;le++){const se=le*R-O;for(let ge=0;ge<q;ge++){const de=ge*S-k;Y[b]=de*y,Y[p]=se*x,Y[g]=H,c.push(Y.x,Y.y,Y.z),Y[b]=0,Y[p]=0,Y[g]=T>0?1:-1,d.push(Y.x,Y.y,Y.z),h.push(ge/A),h.push(1-le/M),K+=1}}for(let le=0;le<M;le++)for(let se=0;se<A;se++){const ge=u+se+q*le,de=u+se+q*(le+1),X=u+(se+1)+q*(le+1),ee=u+(se+1)+q*le;l.push(ge,de,ee),l.push(de,X,ee),V+=6}o.addGroup(f,V,_),f+=V,u+=K}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Jt(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function Ma(r){const e={};for(const t in r){e[t]={};for(const n in r[t]){const i=r[t][n];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?i.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][n]=null):e[t][n]=i.clone():Array.isArray(i)?e[t][n]=i.slice():e[t][n]=i}}return e}function ei(r){const e={};for(let t=0;t<r.length;t++){const n=Ma(r[t]);for(const i in n)e[i]=n[i]}return e}function g0(r){const e=[];for(let t=0;t<r.length;t++)e.push(r[t].clone());return e}function Sb(r){const e=r.getRenderTarget();return e===null?r.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:ft.workingColorSpace}const Ca={clone:Ma,merge:ei};var b0=`void main() {
|
|
35
35
|
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
36
36
|
}`,v0=`void main() {
|
|
37
37
|
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
|
|
@@ -3600,7 +3600,7 @@ void main() {
|
|
|
3600
3600
|
#include <tonemapping_fragment>
|
|
3601
3601
|
#include <colorspace_fragment>
|
|
3602
3602
|
#include <fog_fragment>
|
|
3603
|
-
}`,Mt={alphahash_fragment:j_,alphahash_pars_fragment:X_,alphamap_fragment:q_,alphamap_pars_fragment:Z_,alphatest_fragment:Y_,alphatest_pars_fragment:K_,aomap_fragment:$_,aomap_pars_fragment:Q_,batching_pars_vertex:J_,batching_vertex:ew,begin_vertex:tw,beginnormal_vertex:nw,bsdfs:iw,iridescence_fragment:sw,bumpmap_pars_fragment:rw,clipping_planes_fragment:aw,clipping_planes_pars_fragment:ow,clipping_planes_pars_vertex:lw,clipping_planes_vertex:cw,color_fragment:dw,color_pars_fragment:hw,color_pars_vertex:uw,color_vertex:fw,common:pw,cube_uv_reflection_fragment:mw,defaultnormal_vertex:gw,displacementmap_pars_vertex:bw,displacementmap_vertex:vw,emissivemap_fragment:yw,emissivemap_pars_fragment:xw,colorspace_fragment:_w,colorspace_pars_fragment:ww,envmap_fragment:Sw,envmap_common_pars_fragment:Mw,envmap_pars_fragment:Tw,envmap_pars_vertex:Ew,envmap_physical_pars_fragment:Fw,envmap_vertex:Aw,fog_vertex:Cw,fog_pars_vertex:Pw,fog_fragment:Rw,fog_pars_fragment:Nw,gradientmap_pars_fragment:Dw,lightmap_pars_fragment:Lw,lights_lambert_fragment:Iw,lights_lambert_pars_fragment:kw,lights_pars_begin:Ow,lights_toon_fragment:Uw,lights_toon_pars_fragment:Bw,lights_phong_fragment:zw,lights_phong_pars_fragment:Hw,lights_physical_fragment:Gw,lights_physical_pars_fragment:Vw,lights_fragment_begin:Ww,lights_fragment_maps:jw,lights_fragment_end:Xw,logdepthbuf_fragment:qw,logdepthbuf_pars_fragment:Zw,logdepthbuf_pars_vertex:Yw,logdepthbuf_vertex:Kw,map_fragment:$w,map_pars_fragment:Qw,map_particle_fragment:Jw,map_particle_pars_fragment:eS,metalnessmap_fragment:tS,metalnessmap_pars_fragment:nS,morphinstance_vertex:iS,morphcolor_vertex:sS,morphnormal_vertex:rS,morphtarget_pars_vertex:aS,morphtarget_vertex:oS,normal_fragment_begin:lS,normal_fragment_maps:cS,normal_pars_fragment:dS,normal_pars_vertex:hS,normal_vertex:uS,normalmap_pars_fragment:fS,clearcoat_normal_fragment_begin:pS,clearcoat_normal_fragment_maps:mS,clearcoat_pars_fragment:gS,iridescence_pars_fragment:bS,opaque_fragment:vS,packing:yS,premultiplied_alpha_fragment:xS,project_vertex:_S,dithering_fragment:wS,dithering_pars_fragment:SS,roughnessmap_fragment:MS,roughnessmap_pars_fragment:TS,shadowmap_pars_fragment:ES,shadowmap_pars_vertex:AS,shadowmap_vertex:CS,shadowmask_pars_fragment:PS,skinbase_vertex:RS,skinning_pars_vertex:NS,skinning_vertex:DS,skinnormal_vertex:LS,specularmap_fragment:IS,specularmap_pars_fragment:kS,tonemapping_fragment:OS,tonemapping_pars_fragment:FS,transmission_fragment:US,transmission_pars_fragment:BS,uv_pars_fragment:zS,uv_pars_vertex:HS,uv_vertex:GS,worldpos_vertex:VS,background_vert:WS,background_frag:jS,backgroundCube_vert:XS,backgroundCube_frag:qS,cube_vert:ZS,cube_frag:YS,depth_vert:KS,depth_frag:$S,distanceRGBA_vert:QS,distanceRGBA_frag:JS,equirect_vert:eM,equirect_frag:tM,linedashed_vert:nM,linedashed_frag:iM,meshbasic_vert:sM,meshbasic_frag:rM,meshlambert_vert:aM,meshlambert_frag:oM,meshmatcap_vert:lM,meshmatcap_frag:cM,meshnormal_vert:dM,meshnormal_frag:hM,meshphong_vert:uM,meshphong_frag:fM,meshphysical_vert:pM,meshphysical_frag:mM,meshtoon_vert:gM,meshtoon_frag:bM,points_vert:vM,points_frag:yM,shadow_vert:xM,shadow_frag:_M,sprite_vert:wM,sprite_frag:SM},He={common:{diffuse:{value:new Ne(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new xt},alphaMap:{value:null},alphaMapTransform:{value:new xt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new xt}},envmap:{envMap:{value:null},envMapRotation:{value:new xt},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new xt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new xt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new xt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new xt},normalScale:{value:new me(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new xt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new xt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new xt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new xt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Ne(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Ne(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new xt},alphaTest:{value:0},uvTransform:{value:new xt}},sprite:{diffuse:{value:new Ne(16777215)},opacity:{value:1},center:{value:new me(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new xt},alphaMap:{value:null},alphaMapTransform:{value:new xt},alphaTest:{value:0}}},di={basic:{uniforms:ei([He.common,He.specularmap,He.envmap,He.aomap,He.lightmap,He.fog]),vertexShader:Mt.meshbasic_vert,fragmentShader:Mt.meshbasic_frag},lambert:{uniforms:ei([He.common,He.specularmap,He.envmap,He.aomap,He.lightmap,He.emissivemap,He.bumpmap,He.normalmap,He.displacementmap,He.fog,He.lights,{emissive:{value:new Ne(0)}}]),vertexShader:Mt.meshlambert_vert,fragmentShader:Mt.meshlambert_frag},phong:{uniforms:ei([He.common,He.specularmap,He.envmap,He.aomap,He.lightmap,He.emissivemap,He.bumpmap,He.normalmap,He.displacementmap,He.fog,He.lights,{emissive:{value:new Ne(0)},specular:{value:new Ne(1118481)},shininess:{value:30}}]),vertexShader:Mt.meshphong_vert,fragmentShader:Mt.meshphong_frag},standard:{uniforms:ei([He.common,He.envmap,He.aomap,He.lightmap,He.emissivemap,He.bumpmap,He.normalmap,He.displacementmap,He.roughnessmap,He.metalnessmap,He.fog,He.lights,{emissive:{value:new Ne(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Mt.meshphysical_vert,fragmentShader:Mt.meshphysical_frag},toon:{uniforms:ei([He.common,He.aomap,He.lightmap,He.emissivemap,He.bumpmap,He.normalmap,He.displacementmap,He.gradientmap,He.fog,He.lights,{emissive:{value:new Ne(0)}}]),vertexShader:Mt.meshtoon_vert,fragmentShader:Mt.meshtoon_frag},matcap:{uniforms:ei([He.common,He.bumpmap,He.normalmap,He.displacementmap,He.fog,{matcap:{value:null}}]),vertexShader:Mt.meshmatcap_vert,fragmentShader:Mt.meshmatcap_frag},points:{uniforms:ei([He.points,He.fog]),vertexShader:Mt.points_vert,fragmentShader:Mt.points_frag},dashed:{uniforms:ei([He.common,He.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Mt.linedashed_vert,fragmentShader:Mt.linedashed_frag},depth:{uniforms:ei([He.common,He.displacementmap]),vertexShader:Mt.depth_vert,fragmentShader:Mt.depth_frag},normal:{uniforms:ei([He.common,He.bumpmap,He.normalmap,He.displacementmap,{opacity:{value:1}}]),vertexShader:Mt.meshnormal_vert,fragmentShader:Mt.meshnormal_frag},sprite:{uniforms:ei([He.sprite,He.fog]),vertexShader:Mt.sprite_vert,fragmentShader:Mt.sprite_frag},background:{uniforms:{uvTransform:{value:new xt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Mt.background_vert,fragmentShader:Mt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new xt}},vertexShader:Mt.backgroundCube_vert,fragmentShader:Mt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Mt.cube_vert,fragmentShader:Mt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Mt.equirect_vert,fragmentShader:Mt.equirect_frag},distanceRGBA:{uniforms:ei([He.common,He.displacementmap,{referencePosition:{value:new I},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Mt.distanceRGBA_vert,fragmentShader:Mt.distanceRGBA_frag},shadow:{uniforms:ei([He.lights,He.fog,{color:{value:new Ne(0)},opacity:{value:1}}]),vertexShader:Mt.shadow_vert,fragmentShader:Mt.shadow_frag}};di.physical={uniforms:ei([di.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new xt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new xt},clearcoatNormalScale:{value:new me(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new xt},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new xt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new xt},sheen:{value:0},sheenColor:{value:new Ne(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new xt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new xt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new xt},transmissionSamplerSize:{value:new me},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new xt},attenuationDistance:{value:0},attenuationColor:{value:new Ne(0)},specularColor:{value:new Ne(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new xt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new xt},anisotropyVector:{value:new me},anisotropyMap:{value:null},anisotropyMapTransform:{value:new xt}}]),vertexShader:Mt.meshphysical_vert,fragmentShader:Mt.meshphysical_frag};const Nl={r:0,b:0,g:0},ar=new hn,MM=new Ie;function TM(r,e,t,n,i,s,a){const o=new Ne(0);let l=s===!0?0:1,c,d,h=null,u=0,f=null;function m(x){let w=x.isScene===!0?x.background:null;return w&&w.isTexture&&(w=(x.backgroundBlurriness>0?t:e).get(w)),w}function b(x){let w=!1;const P=m(x);P===null?g(o,l):P&&P.isColor&&(g(P,1),w=!0);const T=r.xr.getEnvironmentBlendMode();T==="additive"?n.buffers.color.setClear(0,0,0,1,a):T==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,a),(r.autoClear||w)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),r.clear(r.autoClearColor,r.autoClearDepth,r.autoClearStencil))}function p(x,w){const P=m(w);P&&(P.isCubeTexture||P.mapping===Lc)?(d===void 0&&(d=new Ee(new Jt(1,1,1),new wn({name:"BackgroundCubeMaterial",uniforms:Ma(di.backgroundCube.uniforms),vertexShader:di.backgroundCube.vertexShader,fragmentShader:di.backgroundCube.fragmentShader,side:fi,depthTest:!1,depthWrite:!1,fog:!1})),d.geometry.deleteAttribute("normal"),d.geometry.deleteAttribute("uv"),d.onBeforeRender=function(T,A,M){this.matrixWorld.copyPosition(M.matrixWorld)},Object.defineProperty(d.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(d)),ar.copy(w.backgroundRotation),ar.x*=-1,ar.y*=-1,ar.z*=-1,P.isCubeTexture&&P.isRenderTargetTexture===!1&&(ar.y*=-1,ar.z*=-1),d.material.uniforms.envMap.value=P,d.material.uniforms.flipEnvMap.value=P.isCubeTexture&&P.isRenderTargetTexture===!1?-1:1,d.material.uniforms.backgroundBlurriness.value=w.backgroundBlurriness,d.material.uniforms.backgroundIntensity.value=w.backgroundIntensity,d.material.uniforms.backgroundRotation.value.setFromMatrix4(MM.makeRotationFromEuler(ar)),d.material.toneMapped=ft.getTransfer(P.colorSpace)!==Ht,(h!==P||u!==P.version||f!==r.toneMapping)&&(d.material.needsUpdate=!0,h=P,u=P.version,f=r.toneMapping),d.layers.enableAll(),x.unshift(d,d.geometry,d.material,0,0,null)):P&&P.isTexture&&(c===void 0&&(c=new Ee(new $s(2,2),new wn({name:"BackgroundMaterial",uniforms:Ma(di.background.uniforms),vertexShader:di.background.vertexShader,fragmentShader:di.background.fragmentShader,side:Si,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(c)),c.material.uniforms.t2D.value=P,c.material.uniforms.backgroundIntensity.value=w.backgroundIntensity,c.material.toneMapped=ft.getTransfer(P.colorSpace)!==Ht,P.matrixAutoUpdate===!0&&P.updateMatrix(),c.material.uniforms.uvTransform.value.copy(P.matrix),(h!==P||u!==P.version||f!==r.toneMapping)&&(c.material.needsUpdate=!0,h=P,u=P.version,f=r.toneMapping),c.layers.enableAll(),x.unshift(c,c.geometry,c.material,0,0,null))}function g(x,w){x.getRGB(Nl,Sb(r)),n.buffers.color.setClear(Nl.r,Nl.g,Nl.b,w,a)}function y(){d!==void 0&&(d.geometry.dispose(),d.material.dispose(),d=void 0),c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0)}return{getClearColor:function(){return o},setClearColor:function(x,w=1){o.set(x),l=w,g(o,l)},getClearAlpha:function(){return l},setClearAlpha:function(x){l=x,g(o,l)},render:b,addToRenderList:p,dispose:y}}function EM(r,e){const t=r.getParameter(r.MAX_VERTEX_ATTRIBS),n={},i=u(null);let s=i,a=!1;function o(S,R,k,O,H){let q=!1;const G=h(O,k,R);s!==G&&(s=G,c(s.object)),q=f(S,O,k,H),q&&m(S,O,k,H),H!==null&&e.update(H,r.ELEMENT_ARRAY_BUFFER),(q||a)&&(a=!1,w(S,R,k,O),H!==null&&r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,e.get(H).buffer))}function l(){return r.createVertexArray()}function c(S){return r.bindVertexArray(S)}function d(S){return r.deleteVertexArray(S)}function h(S,R,k){const O=k.wireframe===!0;let H=n[S.id];H===void 0&&(H={},n[S.id]=H);let q=H[R.id];q===void 0&&(q={},H[R.id]=q);let G=q[O];return G===void 0&&(G=u(l()),q[O]=G),G}function u(S){const R=[],k=[],O=[];for(let H=0;H<t;H++)R[H]=0,k[H]=0,O[H]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:R,enabledAttributes:k,attributeDivisors:O,object:S,attributes:{},index:null}}function f(S,R,k,O){const H=s.attributes,q=R.attributes;let G=0;const K=k.getAttributes();for(const V in K)if(K[V].location>=0){const le=H[V];let se=q[V];if(se===void 0&&(V==="instanceMatrix"&&S.instanceMatrix&&(se=S.instanceMatrix),V==="instanceColor"&&S.instanceColor&&(se=S.instanceColor)),le===void 0||le.attribute!==se||se&&le.data!==se.data)return!0;G++}return s.attributesNum!==G||s.index!==O}function m(S,R,k,O){const H={},q=R.attributes;let G=0;const K=k.getAttributes();for(const V in K)if(K[V].location>=0){let le=q[V];le===void 0&&(V==="instanceMatrix"&&S.instanceMatrix&&(le=S.instanceMatrix),V==="instanceColor"&&S.instanceColor&&(le=S.instanceColor));const se={};se.attribute=le,le&&le.data&&(se.data=le.data),H[V]=se,G++}s.attributes=H,s.attributesNum=G,s.index=O}function b(){const S=s.newAttributes;for(let R=0,k=S.length;R<k;R++)S[R]=0}function p(S){g(S,0)}function g(S,R){const k=s.newAttributes,O=s.enabledAttributes,H=s.attributeDivisors;k[S]=1,O[S]===0&&(r.enableVertexAttribArray(S),O[S]=1),H[S]!==R&&(r.vertexAttribDivisor(S,R),H[S]=R)}function y(){const S=s.newAttributes,R=s.enabledAttributes;for(let k=0,O=R.length;k<O;k++)R[k]!==S[k]&&(r.disableVertexAttribArray(k),R[k]=0)}function x(S,R,k,O,H,q,G){G===!0?r.vertexAttribIPointer(S,R,k,H,q):r.vertexAttribPointer(S,R,k,O,H,q)}function w(S,R,k,O){b();const H=O.attributes,q=k.getAttributes(),G=R.defaultAttributeValues;for(const K in q){const V=q[K];if(V.location>=0){let Z=H[K];if(Z===void 0&&(K==="instanceMatrix"&&S.instanceMatrix&&(Z=S.instanceMatrix),K==="instanceColor"&&S.instanceColor&&(Z=S.instanceColor)),Z!==void 0){const le=Z.normalized,se=Z.itemSize,ge=e.get(Z);if(ge===void 0)continue;const de=ge.buffer,X=ge.type,ee=ge.bytesPerElement,ie=X===r.INT||X===r.UNSIGNED_INT||Z.gpuType===Nu;if(Z.isInterleavedBufferAttribute){const Y=Z.data,ue=Y.stride,oe=Z.offset;if(Y.isInstancedInterleavedBuffer){for(let be=0;be<V.locationSize;be++)g(V.location+be,Y.meshPerAttribute);S.isInstancedMesh!==!0&&O._maxInstanceCount===void 0&&(O._maxInstanceCount=Y.meshPerAttribute*Y.count)}else for(let be=0;be<V.locationSize;be++)p(V.location+be);r.bindBuffer(r.ARRAY_BUFFER,de);for(let be=0;be<V.locationSize;be++)x(V.location+be,se/V.locationSize,X,le,ue*ee,(oe+se/V.locationSize*be)*ee,ie)}else{if(Z.isInstancedBufferAttribute){for(let Y=0;Y<V.locationSize;Y++)g(V.location+Y,Z.meshPerAttribute);S.isInstancedMesh!==!0&&O._maxInstanceCount===void 0&&(O._maxInstanceCount=Z.meshPerAttribute*Z.count)}else for(let Y=0;Y<V.locationSize;Y++)p(V.location+Y);r.bindBuffer(r.ARRAY_BUFFER,de);for(let Y=0;Y<V.locationSize;Y++)x(V.location+Y,se/V.locationSize,X,le,se*ee,se/V.locationSize*Y*ee,ie)}}else if(G!==void 0){const le=G[K];if(le!==void 0)switch(le.length){case 2:r.vertexAttrib2fv(V.location,le);break;case 3:r.vertexAttrib3fv(V.location,le);break;case 4:r.vertexAttrib4fv(V.location,le);break;default:r.vertexAttrib1fv(V.location,le)}}}}y()}function P(){M();for(const S in n){const R=n[S];for(const k in R){const O=R[k];for(const H in O)d(O[H].object),delete O[H];delete R[k]}delete n[S]}}function T(S){if(n[S.id]===void 0)return;const R=n[S.id];for(const k in R){const O=R[k];for(const H in O)d(O[H].object),delete O[H];delete R[k]}delete n[S.id]}function A(S){for(const R in n){const k=n[R];if(k[S.id]===void 0)continue;const O=k[S.id];for(const H in O)d(O[H].object),delete O[H];delete k[S.id]}}function M(){_(),a=!0,s!==i&&(s=i,c(s.object))}function _(){i.geometry=null,i.program=null,i.wireframe=!1}return{setup:o,reset:M,resetDefaultState:_,dispose:P,releaseStatesOfGeometry:T,releaseStatesOfProgram:A,initAttributes:b,enableAttribute:p,disableUnusedAttributes:y}}function AM(r,e,t){let n;function i(c){n=c}function s(c,d){r.drawArrays(n,c,d),t.update(d,n,1)}function a(c,d,h){h!==0&&(r.drawArraysInstanced(n,c,d,h),t.update(d,n,h))}function o(c,d,h){if(h===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,c,0,d,0,h);let f=0;for(let m=0;m<h;m++)f+=d[m];t.update(f,n,1)}function l(c,d,h,u){if(h===0)return;const f=e.get("WEBGL_multi_draw");if(f===null)for(let m=0;m<c.length;m++)a(c[m],d[m],u[m]);else{f.multiDrawArraysInstancedWEBGL(n,c,0,d,0,u,0,h);let m=0;for(let b=0;b<h;b++)m+=d[b]*u[b];t.update(m,n,1)}}this.setMode=i,this.render=s,this.renderInstances=a,this.renderMultiDraw=o,this.renderMultiDrawInstances=l}function CM(r,e,t,n){let i;function s(){if(i!==void 0)return i;if(e.has("EXT_texture_filter_anisotropic")===!0){const A=e.get("EXT_texture_filter_anisotropic");i=r.getParameter(A.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function a(A){return!(A!==Dn&&n.convert(A)!==r.getParameter(r.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(A){const M=A===Ri&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(A!==Ms&&n.convert(A)!==r.getParameter(r.IMPLEMENTATION_COLOR_READ_TYPE)&&A!==_i&&!M)}function l(A){if(A==="highp"){if(r.getShaderPrecisionFormat(r.VERTEX_SHADER,r.HIGH_FLOAT).precision>0&&r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.HIGH_FLOAT).precision>0)return"highp";A="mediump"}return A==="mediump"&&r.getShaderPrecisionFormat(r.VERTEX_SHADER,r.MEDIUM_FLOAT).precision>0&&r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=t.precision!==void 0?t.precision:"highp";const d=l(c);d!==c&&(console.warn("THREE.WebGLRenderer:",c,"not supported, using",d,"instead."),c=d);const h=t.logarithmicDepthBuffer===!0,u=t.reverseDepthBuffer===!0&&e.has("EXT_clip_control"),f=r.getParameter(r.MAX_TEXTURE_IMAGE_UNITS),m=r.getParameter(r.MAX_VERTEX_TEXTURE_IMAGE_UNITS),b=r.getParameter(r.MAX_TEXTURE_SIZE),p=r.getParameter(r.MAX_CUBE_MAP_TEXTURE_SIZE),g=r.getParameter(r.MAX_VERTEX_ATTRIBS),y=r.getParameter(r.MAX_VERTEX_UNIFORM_VECTORS),x=r.getParameter(r.MAX_VARYING_VECTORS),w=r.getParameter(r.MAX_FRAGMENT_UNIFORM_VECTORS),P=m>0,T=r.getParameter(r.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:h,reverseDepthBuffer:u,maxTextures:f,maxVertexTextures:m,maxTextureSize:b,maxCubemapSize:p,maxAttributes:g,maxVertexUniforms:y,maxVaryings:x,maxFragmentUniforms:w,vertexTextures:P,maxSamples:T}}function PM(r){const e=this;let t=null,n=0,i=!1,s=!1;const a=new ns,o=new xt,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(h,u){const f=h.length!==0||u||n!==0||i;return i=u,n=h.length,f},this.beginShadows=function(){s=!0,d(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(h,u){t=d(h,u,0)},this.setState=function(h,u,f){const m=h.clippingPlanes,b=h.clipIntersection,p=h.clipShadows,g=r.get(h);if(!i||m===null||m.length===0||s&&!p)s?d(null):c();else{const y=s?0:n,x=y*4;let w=g.clippingState||null;l.value=w,w=d(m,u,x,f);for(let P=0;P!==x;++P)w[P]=t[P];g.clippingState=w,this.numIntersection=b?this.numPlanes:0,this.numPlanes+=y}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function d(h,u,f,m){const b=h!==null?h.length:0;let p=null;if(b!==0){if(p=l.value,m!==!0||p===null){const g=f+b*4,y=u.matrixWorldInverse;o.getNormalMatrix(y),(p===null||p.length<g)&&(p=new Float32Array(g));for(let x=0,w=f;x!==b;++x,w+=4)a.copy(h[x]).applyMatrix4(y,o),a.normal.toArray(p,w),p[w+3]=a.constant}l.value=p,l.needsUpdate=!0}return e.numPlanes=b,e.numIntersection=0,p}}function RM(r){let e=new WeakMap;function t(a,o){return o===vc?a.mapping=ya:o===Fh&&(a.mapping=xa),a}function n(a){if(a&&a.isTexture){const o=a.mapping;if(o===vc||o===Fh)if(e.has(a)){const l=e.get(a).texture;return t(l,a.mapping)}else{const l=a.image;if(l&&l.height>0){const c=new x0(l.height);return c.fromEquirectangularTexture(r,a),e.set(a,c),a.addEventListener("dispose",i),t(c.texture,a.mapping)}else return null}}return a}function i(a){const o=a.target;o.removeEventListener("dispose",i);const l=e.get(o);l!==void 0&&(e.delete(o),l.dispose())}function s(){e=new WeakMap}return{get:n,dispose:s}}const oa=4,kp=[.125,.215,.35,.446,.526,.582],br=20,Dd=new ko,Op=new Ne;let Ld=null,Id=0,kd=0,Od=!1;const ur=(1+Math.sqrt(5))/2,Kr=1/ur,Fp=[new I(-ur,Kr,0),new I(ur,Kr,0),new I(-Kr,0,ur),new I(Kr,0,ur),new I(0,ur,-Kr),new I(0,ur,Kr),new I(-1,1,-1),new I(1,1,-1),new I(-1,1,1),new I(1,1,1)],NM=new I;class Up{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,i=100,s={}){const{size:a=256,position:o=NM}=s;Ld=this._renderer.getRenderTarget(),Id=this._renderer.getActiveCubeFace(),kd=this._renderer.getActiveMipmapLevel(),Od=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const l=this._allocateTargets();return l.depthBuffer=!0,this._sceneToCubeUV(e,n,i,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=Hp(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=zp(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(Ld,Id,kd),this._renderer.xr.enabled=Od,e.scissorTest=!1,Dl(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===ya||e.mapping===xa?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Ld=this._renderer.getRenderTarget(),Id=this._renderer.getActiveCubeFace(),kd=this._renderer.getActiveMipmapLevel(),Od=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:bn,minFilter:bn,generateMipmaps:!1,type:Ri,format:Dn,colorSpace:$n,depthBuffer:!1},i=Bp(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Bp(e,t,n);const{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=DM(s)),this._blurMaterial=LM(s,e,t)}return i}_compileMaterial(e){const t=new Ee(this._lodPlanes[0],e);this._renderer.compile(t,Dd)}_sceneToCubeUV(e,t,n,i,s){const l=new gn(90,1,t,n),c=[1,-1,1,1,1,1],d=[1,1,1,-1,-1,-1],h=this._renderer,u=h.autoClear,f=h.toneMapping;h.getClearColor(Op),h.toneMapping=Xs,h.autoClear=!1;const m=new jt({name:"PMREM.Background",side:fi,depthWrite:!1,depthTest:!1}),b=new Ee(new Jt,m);let p=!1;const g=e.background;g?g.isColor&&(m.color.copy(g),e.background=null,p=!0):(m.color.copy(Op),p=!0);for(let y=0;y<6;y++){const x=y%3;x===0?(l.up.set(0,c[y],0),l.position.set(s.x,s.y,s.z),l.lookAt(s.x+d[y],s.y,s.z)):x===1?(l.up.set(0,0,c[y]),l.position.set(s.x,s.y,s.z),l.lookAt(s.x,s.y+d[y],s.z)):(l.up.set(0,c[y],0),l.position.set(s.x,s.y,s.z),l.lookAt(s.x,s.y,s.z+d[y]));const w=this._cubeSize;Dl(i,x*w,y>2?w:0,w,w),h.setRenderTarget(i),p&&h.render(b,l),h.render(e,l)}b.geometry.dispose(),b.material.dispose(),h.toneMapping=f,h.autoClear=u,e.background=g}_textureToCubeUV(e,t){const n=this._renderer,i=e.mapping===ya||e.mapping===xa;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=Hp()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=zp());const s=i?this._cubemapMaterial:this._equirectMaterial,a=new Ee(this._lodPlanes[0],s),o=s.uniforms;o.envMap.value=e;const l=this._cubeSize;Dl(t,0,0,3*l,2*l),n.setRenderTarget(t),n.render(a,Dd)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const i=this._lodPlanes.length;for(let s=1;s<i;s++){const a=Math.sqrt(this._sigmas[s]*this._sigmas[s]-this._sigmas[s-1]*this._sigmas[s-1]),o=Fp[(i-s-1)%Fp.length];this._blur(e,s-1,s,a,o)}t.autoClear=n}_blur(e,t,n,i,s){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,i,"latitudinal",s),this._halfBlur(a,e,n,n,i,"longitudinal",s)}_halfBlur(e,t,n,i,s,a,o){const l=this._renderer,c=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const d=3,h=new Ee(this._lodPlanes[i],c),u=c.uniforms,f=this._sizeLods[n]-1,m=isFinite(s)?Math.PI/(2*f):2*Math.PI/(2*br-1),b=s/m,p=isFinite(s)?1+Math.floor(d*b):br;p>br&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${p} samples when the maximum is set to ${br}`);const g=[];let y=0;for(let A=0;A<br;++A){const M=A/b,_=Math.exp(-M*M/2);g.push(_),A===0?y+=_:A<p&&(y+=2*_)}for(let A=0;A<g.length;A++)g[A]=g[A]/y;u.envMap.value=e.texture,u.samples.value=p,u.weights.value=g,u.latitudinal.value=a==="latitudinal",o&&(u.poleAxis.value=o);const{_lodMax:x}=this;u.dTheta.value=m,u.mipInt.value=x-n;const w=this._sizeLods[i],P=3*w*(i>x-oa?i-x+oa:0),T=4*(this._cubeSize-w);Dl(t,P,T,3*w,2*w),l.setRenderTarget(t),l.render(h,Dd)}}function DM(r){const e=[],t=[],n=[];let i=r;const s=r-oa+1+kp.length;for(let a=0;a<s;a++){const o=Math.pow(2,i);t.push(o);let l=1/o;a>r-oa?l=kp[a-r+oa-1]:a===0&&(l=0),n.push(l);const c=1/(o-2),d=-c,h=1+c,u=[d,d,h,d,h,h,d,d,h,h,d,h],f=6,m=6,b=3,p=2,g=1,y=new Float32Array(b*m*f),x=new Float32Array(p*m*f),w=new Float32Array(g*m*f);for(let T=0;T<f;T++){const A=T%3*2/3-1,M=T>2?0:-1,_=[A,M,0,A+2/3,M,0,A+2/3,M+1,0,A,M,0,A+2/3,M+1,0,A,M+1,0];y.set(_,b*m*T),x.set(u,p*m*T);const S=[T,T,T,T,T,T];w.set(S,g*m*T)}const P=new ht;P.setAttribute("position",new rn(y,b)),P.setAttribute("uv",new rn(x,p)),P.setAttribute("faceIndex",new rn(w,g)),e.push(P),i>oa&&i--}return{lodPlanes:e,sizeLods:t,sigmas:n}}function Bp(r,e,t){const n=new ni(r,e,t);return n.texture.mapping=Lc,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Dl(r,e,t,n,i){r.viewport.set(e,t,n,i),r.scissor.set(e,t,n,i)}function LM(r,e,t){const n=new Float32Array(br),i=new I(0,1,0);return new wn({name:"SphericalGaussianBlur",defines:{n:br,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${r}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:nf(),fragmentShader:`
|
|
3603
|
+
}`,Mt={alphahash_fragment:j_,alphahash_pars_fragment:X_,alphamap_fragment:q_,alphamap_pars_fragment:Z_,alphatest_fragment:Y_,alphatest_pars_fragment:K_,aomap_fragment:$_,aomap_pars_fragment:Q_,batching_pars_vertex:J_,batching_vertex:ew,begin_vertex:tw,beginnormal_vertex:nw,bsdfs:iw,iridescence_fragment:sw,bumpmap_pars_fragment:rw,clipping_planes_fragment:aw,clipping_planes_pars_fragment:ow,clipping_planes_pars_vertex:lw,clipping_planes_vertex:cw,color_fragment:dw,color_pars_fragment:hw,color_pars_vertex:uw,color_vertex:fw,common:pw,cube_uv_reflection_fragment:mw,defaultnormal_vertex:gw,displacementmap_pars_vertex:bw,displacementmap_vertex:vw,emissivemap_fragment:yw,emissivemap_pars_fragment:xw,colorspace_fragment:_w,colorspace_pars_fragment:ww,envmap_fragment:Sw,envmap_common_pars_fragment:Mw,envmap_pars_fragment:Tw,envmap_pars_vertex:Ew,envmap_physical_pars_fragment:Fw,envmap_vertex:Aw,fog_vertex:Cw,fog_pars_vertex:Pw,fog_fragment:Rw,fog_pars_fragment:Nw,gradientmap_pars_fragment:Dw,lightmap_pars_fragment:Lw,lights_lambert_fragment:Iw,lights_lambert_pars_fragment:kw,lights_pars_begin:Ow,lights_toon_fragment:Uw,lights_toon_pars_fragment:Bw,lights_phong_fragment:zw,lights_phong_pars_fragment:Hw,lights_physical_fragment:Gw,lights_physical_pars_fragment:Vw,lights_fragment_begin:Ww,lights_fragment_maps:jw,lights_fragment_end:Xw,logdepthbuf_fragment:qw,logdepthbuf_pars_fragment:Zw,logdepthbuf_pars_vertex:Yw,logdepthbuf_vertex:Kw,map_fragment:$w,map_pars_fragment:Qw,map_particle_fragment:Jw,map_particle_pars_fragment:eS,metalnessmap_fragment:tS,metalnessmap_pars_fragment:nS,morphinstance_vertex:iS,morphcolor_vertex:sS,morphnormal_vertex:rS,morphtarget_pars_vertex:aS,morphtarget_vertex:oS,normal_fragment_begin:lS,normal_fragment_maps:cS,normal_pars_fragment:dS,normal_pars_vertex:hS,normal_vertex:uS,normalmap_pars_fragment:fS,clearcoat_normal_fragment_begin:pS,clearcoat_normal_fragment_maps:mS,clearcoat_pars_fragment:gS,iridescence_pars_fragment:bS,opaque_fragment:vS,packing:yS,premultiplied_alpha_fragment:xS,project_vertex:_S,dithering_fragment:wS,dithering_pars_fragment:SS,roughnessmap_fragment:MS,roughnessmap_pars_fragment:TS,shadowmap_pars_fragment:ES,shadowmap_pars_vertex:AS,shadowmap_vertex:CS,shadowmask_pars_fragment:PS,skinbase_vertex:RS,skinning_pars_vertex:NS,skinning_vertex:DS,skinnormal_vertex:LS,specularmap_fragment:IS,specularmap_pars_fragment:kS,tonemapping_fragment:OS,tonemapping_pars_fragment:FS,transmission_fragment:US,transmission_pars_fragment:BS,uv_pars_fragment:zS,uv_pars_vertex:HS,uv_vertex:GS,worldpos_vertex:VS,background_vert:WS,background_frag:jS,backgroundCube_vert:XS,backgroundCube_frag:qS,cube_vert:ZS,cube_frag:YS,depth_vert:KS,depth_frag:$S,distanceRGBA_vert:QS,distanceRGBA_frag:JS,equirect_vert:eM,equirect_frag:tM,linedashed_vert:nM,linedashed_frag:iM,meshbasic_vert:sM,meshbasic_frag:rM,meshlambert_vert:aM,meshlambert_frag:oM,meshmatcap_vert:lM,meshmatcap_frag:cM,meshnormal_vert:dM,meshnormal_frag:hM,meshphong_vert:uM,meshphong_frag:fM,meshphysical_vert:pM,meshphysical_frag:mM,meshtoon_vert:gM,meshtoon_frag:bM,points_vert:vM,points_frag:yM,shadow_vert:xM,shadow_frag:_M,sprite_vert:wM,sprite_frag:SM},He={common:{diffuse:{value:new Ne(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new xt},alphaMap:{value:null},alphaMapTransform:{value:new xt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new xt}},envmap:{envMap:{value:null},envMapRotation:{value:new xt},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new xt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new xt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new xt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new xt},normalScale:{value:new me(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new xt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new xt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new xt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new xt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Ne(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Ne(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new xt},alphaTest:{value:0},uvTransform:{value:new xt}},sprite:{diffuse:{value:new Ne(16777215)},opacity:{value:1},center:{value:new me(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new xt},alphaMap:{value:null},alphaMapTransform:{value:new xt},alphaTest:{value:0}}},di={basic:{uniforms:ei([He.common,He.specularmap,He.envmap,He.aomap,He.lightmap,He.fog]),vertexShader:Mt.meshbasic_vert,fragmentShader:Mt.meshbasic_frag},lambert:{uniforms:ei([He.common,He.specularmap,He.envmap,He.aomap,He.lightmap,He.emissivemap,He.bumpmap,He.normalmap,He.displacementmap,He.fog,He.lights,{emissive:{value:new Ne(0)}}]),vertexShader:Mt.meshlambert_vert,fragmentShader:Mt.meshlambert_frag},phong:{uniforms:ei([He.common,He.specularmap,He.envmap,He.aomap,He.lightmap,He.emissivemap,He.bumpmap,He.normalmap,He.displacementmap,He.fog,He.lights,{emissive:{value:new Ne(0)},specular:{value:new Ne(1118481)},shininess:{value:30}}]),vertexShader:Mt.meshphong_vert,fragmentShader:Mt.meshphong_frag},standard:{uniforms:ei([He.common,He.envmap,He.aomap,He.lightmap,He.emissivemap,He.bumpmap,He.normalmap,He.displacementmap,He.roughnessmap,He.metalnessmap,He.fog,He.lights,{emissive:{value:new Ne(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Mt.meshphysical_vert,fragmentShader:Mt.meshphysical_frag},toon:{uniforms:ei([He.common,He.aomap,He.lightmap,He.emissivemap,He.bumpmap,He.normalmap,He.displacementmap,He.gradientmap,He.fog,He.lights,{emissive:{value:new Ne(0)}}]),vertexShader:Mt.meshtoon_vert,fragmentShader:Mt.meshtoon_frag},matcap:{uniforms:ei([He.common,He.bumpmap,He.normalmap,He.displacementmap,He.fog,{matcap:{value:null}}]),vertexShader:Mt.meshmatcap_vert,fragmentShader:Mt.meshmatcap_frag},points:{uniforms:ei([He.points,He.fog]),vertexShader:Mt.points_vert,fragmentShader:Mt.points_frag},dashed:{uniforms:ei([He.common,He.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Mt.linedashed_vert,fragmentShader:Mt.linedashed_frag},depth:{uniforms:ei([He.common,He.displacementmap]),vertexShader:Mt.depth_vert,fragmentShader:Mt.depth_frag},normal:{uniforms:ei([He.common,He.bumpmap,He.normalmap,He.displacementmap,{opacity:{value:1}}]),vertexShader:Mt.meshnormal_vert,fragmentShader:Mt.meshnormal_frag},sprite:{uniforms:ei([He.sprite,He.fog]),vertexShader:Mt.sprite_vert,fragmentShader:Mt.sprite_frag},background:{uniforms:{uvTransform:{value:new xt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Mt.background_vert,fragmentShader:Mt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new xt}},vertexShader:Mt.backgroundCube_vert,fragmentShader:Mt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Mt.cube_vert,fragmentShader:Mt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Mt.equirect_vert,fragmentShader:Mt.equirect_frag},distanceRGBA:{uniforms:ei([He.common,He.displacementmap,{referencePosition:{value:new I},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Mt.distanceRGBA_vert,fragmentShader:Mt.distanceRGBA_frag},shadow:{uniforms:ei([He.lights,He.fog,{color:{value:new Ne(0)},opacity:{value:1}}]),vertexShader:Mt.shadow_vert,fragmentShader:Mt.shadow_frag}};di.physical={uniforms:ei([di.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new xt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new xt},clearcoatNormalScale:{value:new me(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new xt},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new xt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new xt},sheen:{value:0},sheenColor:{value:new Ne(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new xt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new xt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new xt},transmissionSamplerSize:{value:new me},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new xt},attenuationDistance:{value:0},attenuationColor:{value:new Ne(0)},specularColor:{value:new Ne(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new xt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new xt},anisotropyVector:{value:new me},anisotropyMap:{value:null},anisotropyMapTransform:{value:new xt}}]),vertexShader:Mt.meshphysical_vert,fragmentShader:Mt.meshphysical_frag};const Nl={r:0,b:0,g:0},ar=new hn,MM=new Ie;function TM(r,e,t,n,i,s,a){const o=new Ne(0);let l=s===!0?0:1,c,d,h=null,u=0,f=null;function m(x){let w=x.isScene===!0?x.background:null;return w&&w.isTexture&&(w=(x.backgroundBlurriness>0?t:e).get(w)),w}function b(x){let w=!1;const P=m(x);P===null?g(o,l):P&&P.isColor&&(g(P,1),w=!0);const T=r.xr.getEnvironmentBlendMode();T==="additive"?n.buffers.color.setClear(0,0,0,1,a):T==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,a),(r.autoClear||w)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),r.clear(r.autoClearColor,r.autoClearDepth,r.autoClearStencil))}function p(x,w){const P=m(w);P&&(P.isCubeTexture||P.mapping===Lc)?(d===void 0&&(d=new Ee(new Jt(1,1,1),new wn({name:"BackgroundCubeMaterial",uniforms:Ma(di.backgroundCube.uniforms),vertexShader:di.backgroundCube.vertexShader,fragmentShader:di.backgroundCube.fragmentShader,side:fi,depthTest:!1,depthWrite:!1,fog:!1})),d.geometry.deleteAttribute("normal"),d.geometry.deleteAttribute("uv"),d.onBeforeRender=function(T,A,M){this.matrixWorld.copyPosition(M.matrixWorld)},Object.defineProperty(d.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(d)),ar.copy(w.backgroundRotation),ar.x*=-1,ar.y*=-1,ar.z*=-1,P.isCubeTexture&&P.isRenderTargetTexture===!1&&(ar.y*=-1,ar.z*=-1),d.material.uniforms.envMap.value=P,d.material.uniforms.flipEnvMap.value=P.isCubeTexture&&P.isRenderTargetTexture===!1?-1:1,d.material.uniforms.backgroundBlurriness.value=w.backgroundBlurriness,d.material.uniforms.backgroundIntensity.value=w.backgroundIntensity,d.material.uniforms.backgroundRotation.value.setFromMatrix4(MM.makeRotationFromEuler(ar)),d.material.toneMapped=ft.getTransfer(P.colorSpace)!==Ht,(h!==P||u!==P.version||f!==r.toneMapping)&&(d.material.needsUpdate=!0,h=P,u=P.version,f=r.toneMapping),d.layers.enableAll(),x.unshift(d,d.geometry,d.material,0,0,null)):P&&P.isTexture&&(c===void 0&&(c=new Ee(new $s(2,2),new wn({name:"BackgroundMaterial",uniforms:Ma(di.background.uniforms),vertexShader:di.background.vertexShader,fragmentShader:di.background.fragmentShader,side:Si,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(c)),c.material.uniforms.t2D.value=P,c.material.uniforms.backgroundIntensity.value=w.backgroundIntensity,c.material.toneMapped=ft.getTransfer(P.colorSpace)!==Ht,P.matrixAutoUpdate===!0&&P.updateMatrix(),c.material.uniforms.uvTransform.value.copy(P.matrix),(h!==P||u!==P.version||f!==r.toneMapping)&&(c.material.needsUpdate=!0,h=P,u=P.version,f=r.toneMapping),c.layers.enableAll(),x.unshift(c,c.geometry,c.material,0,0,null))}function g(x,w){x.getRGB(Nl,Sb(r)),n.buffers.color.setClear(Nl.r,Nl.g,Nl.b,w,a)}function y(){d!==void 0&&(d.geometry.dispose(),d.material.dispose(),d=void 0),c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0)}return{getClearColor:function(){return o},setClearColor:function(x,w=1){o.set(x),l=w,g(o,l)},getClearAlpha:function(){return l},setClearAlpha:function(x){l=x,g(o,l)},render:b,addToRenderList:p,dispose:y}}function EM(r,e){const t=r.getParameter(r.MAX_VERTEX_ATTRIBS),n={},i=u(null);let s=i,a=!1;function o(S,R,k,O,H){let q=!1;const G=h(O,k,R);s!==G&&(s=G,c(s.object)),q=f(S,O,k,H),q&&m(S,O,k,H),H!==null&&e.update(H,r.ELEMENT_ARRAY_BUFFER),(q||a)&&(a=!1,w(S,R,k,O),H!==null&&r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,e.get(H).buffer))}function l(){return r.createVertexArray()}function c(S){return r.bindVertexArray(S)}function d(S){return r.deleteVertexArray(S)}function h(S,R,k){const O=k.wireframe===!0;let H=n[S.id];H===void 0&&(H={},n[S.id]=H);let q=H[R.id];q===void 0&&(q={},H[R.id]=q);let G=q[O];return G===void 0&&(G=u(l()),q[O]=G),G}function u(S){const R=[],k=[],O=[];for(let H=0;H<t;H++)R[H]=0,k[H]=0,O[H]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:R,enabledAttributes:k,attributeDivisors:O,object:S,attributes:{},index:null}}function f(S,R,k,O){const H=s.attributes,q=R.attributes;let G=0;const K=k.getAttributes();for(const V in K)if(K[V].location>=0){const le=H[V];let se=q[V];if(se===void 0&&(V==="instanceMatrix"&&S.instanceMatrix&&(se=S.instanceMatrix),V==="instanceColor"&&S.instanceColor&&(se=S.instanceColor)),le===void 0||le.attribute!==se||se&&le.data!==se.data)return!0;G++}return s.attributesNum!==G||s.index!==O}function m(S,R,k,O){const H={},q=R.attributes;let G=0;const K=k.getAttributes();for(const V in K)if(K[V].location>=0){let le=q[V];le===void 0&&(V==="instanceMatrix"&&S.instanceMatrix&&(le=S.instanceMatrix),V==="instanceColor"&&S.instanceColor&&(le=S.instanceColor));const se={};se.attribute=le,le&&le.data&&(se.data=le.data),H[V]=se,G++}s.attributes=H,s.attributesNum=G,s.index=O}function b(){const S=s.newAttributes;for(let R=0,k=S.length;R<k;R++)S[R]=0}function p(S){g(S,0)}function g(S,R){const k=s.newAttributes,O=s.enabledAttributes,H=s.attributeDivisors;k[S]=1,O[S]===0&&(r.enableVertexAttribArray(S),O[S]=1),H[S]!==R&&(r.vertexAttribDivisor(S,R),H[S]=R)}function y(){const S=s.newAttributes,R=s.enabledAttributes;for(let k=0,O=R.length;k<O;k++)R[k]!==S[k]&&(r.disableVertexAttribArray(k),R[k]=0)}function x(S,R,k,O,H,q,G){G===!0?r.vertexAttribIPointer(S,R,k,H,q):r.vertexAttribPointer(S,R,k,O,H,q)}function w(S,R,k,O){b();const H=O.attributes,q=k.getAttributes(),G=R.defaultAttributeValues;for(const K in q){const V=q[K];if(V.location>=0){let Y=H[K];if(Y===void 0&&(K==="instanceMatrix"&&S.instanceMatrix&&(Y=S.instanceMatrix),K==="instanceColor"&&S.instanceColor&&(Y=S.instanceColor)),Y!==void 0){const le=Y.normalized,se=Y.itemSize,ge=e.get(Y);if(ge===void 0)continue;const de=ge.buffer,X=ge.type,ee=ge.bytesPerElement,ie=X===r.INT||X===r.UNSIGNED_INT||Y.gpuType===Nu;if(Y.isInterleavedBufferAttribute){const Z=Y.data,ue=Z.stride,oe=Y.offset;if(Z.isInstancedInterleavedBuffer){for(let be=0;be<V.locationSize;be++)g(V.location+be,Z.meshPerAttribute);S.isInstancedMesh!==!0&&O._maxInstanceCount===void 0&&(O._maxInstanceCount=Z.meshPerAttribute*Z.count)}else for(let be=0;be<V.locationSize;be++)p(V.location+be);r.bindBuffer(r.ARRAY_BUFFER,de);for(let be=0;be<V.locationSize;be++)x(V.location+be,se/V.locationSize,X,le,ue*ee,(oe+se/V.locationSize*be)*ee,ie)}else{if(Y.isInstancedBufferAttribute){for(let Z=0;Z<V.locationSize;Z++)g(V.location+Z,Y.meshPerAttribute);S.isInstancedMesh!==!0&&O._maxInstanceCount===void 0&&(O._maxInstanceCount=Y.meshPerAttribute*Y.count)}else for(let Z=0;Z<V.locationSize;Z++)p(V.location+Z);r.bindBuffer(r.ARRAY_BUFFER,de);for(let Z=0;Z<V.locationSize;Z++)x(V.location+Z,se/V.locationSize,X,le,se*ee,se/V.locationSize*Z*ee,ie)}}else if(G!==void 0){const le=G[K];if(le!==void 0)switch(le.length){case 2:r.vertexAttrib2fv(V.location,le);break;case 3:r.vertexAttrib3fv(V.location,le);break;case 4:r.vertexAttrib4fv(V.location,le);break;default:r.vertexAttrib1fv(V.location,le)}}}}y()}function P(){M();for(const S in n){const R=n[S];for(const k in R){const O=R[k];for(const H in O)d(O[H].object),delete O[H];delete R[k]}delete n[S]}}function T(S){if(n[S.id]===void 0)return;const R=n[S.id];for(const k in R){const O=R[k];for(const H in O)d(O[H].object),delete O[H];delete R[k]}delete n[S.id]}function A(S){for(const R in n){const k=n[R];if(k[S.id]===void 0)continue;const O=k[S.id];for(const H in O)d(O[H].object),delete O[H];delete k[S.id]}}function M(){_(),a=!0,s!==i&&(s=i,c(s.object))}function _(){i.geometry=null,i.program=null,i.wireframe=!1}return{setup:o,reset:M,resetDefaultState:_,dispose:P,releaseStatesOfGeometry:T,releaseStatesOfProgram:A,initAttributes:b,enableAttribute:p,disableUnusedAttributes:y}}function AM(r,e,t){let n;function i(c){n=c}function s(c,d){r.drawArrays(n,c,d),t.update(d,n,1)}function a(c,d,h){h!==0&&(r.drawArraysInstanced(n,c,d,h),t.update(d,n,h))}function o(c,d,h){if(h===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,c,0,d,0,h);let f=0;for(let m=0;m<h;m++)f+=d[m];t.update(f,n,1)}function l(c,d,h,u){if(h===0)return;const f=e.get("WEBGL_multi_draw");if(f===null)for(let m=0;m<c.length;m++)a(c[m],d[m],u[m]);else{f.multiDrawArraysInstancedWEBGL(n,c,0,d,0,u,0,h);let m=0;for(let b=0;b<h;b++)m+=d[b]*u[b];t.update(m,n,1)}}this.setMode=i,this.render=s,this.renderInstances=a,this.renderMultiDraw=o,this.renderMultiDrawInstances=l}function CM(r,e,t,n){let i;function s(){if(i!==void 0)return i;if(e.has("EXT_texture_filter_anisotropic")===!0){const A=e.get("EXT_texture_filter_anisotropic");i=r.getParameter(A.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function a(A){return!(A!==Dn&&n.convert(A)!==r.getParameter(r.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(A){const M=A===Ri&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(A!==Ms&&n.convert(A)!==r.getParameter(r.IMPLEMENTATION_COLOR_READ_TYPE)&&A!==_i&&!M)}function l(A){if(A==="highp"){if(r.getShaderPrecisionFormat(r.VERTEX_SHADER,r.HIGH_FLOAT).precision>0&&r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.HIGH_FLOAT).precision>0)return"highp";A="mediump"}return A==="mediump"&&r.getShaderPrecisionFormat(r.VERTEX_SHADER,r.MEDIUM_FLOAT).precision>0&&r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=t.precision!==void 0?t.precision:"highp";const d=l(c);d!==c&&(console.warn("THREE.WebGLRenderer:",c,"not supported, using",d,"instead."),c=d);const h=t.logarithmicDepthBuffer===!0,u=t.reverseDepthBuffer===!0&&e.has("EXT_clip_control"),f=r.getParameter(r.MAX_TEXTURE_IMAGE_UNITS),m=r.getParameter(r.MAX_VERTEX_TEXTURE_IMAGE_UNITS),b=r.getParameter(r.MAX_TEXTURE_SIZE),p=r.getParameter(r.MAX_CUBE_MAP_TEXTURE_SIZE),g=r.getParameter(r.MAX_VERTEX_ATTRIBS),y=r.getParameter(r.MAX_VERTEX_UNIFORM_VECTORS),x=r.getParameter(r.MAX_VARYING_VECTORS),w=r.getParameter(r.MAX_FRAGMENT_UNIFORM_VECTORS),P=m>0,T=r.getParameter(r.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:h,reverseDepthBuffer:u,maxTextures:f,maxVertexTextures:m,maxTextureSize:b,maxCubemapSize:p,maxAttributes:g,maxVertexUniforms:y,maxVaryings:x,maxFragmentUniforms:w,vertexTextures:P,maxSamples:T}}function PM(r){const e=this;let t=null,n=0,i=!1,s=!1;const a=new ns,o=new xt,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(h,u){const f=h.length!==0||u||n!==0||i;return i=u,n=h.length,f},this.beginShadows=function(){s=!0,d(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(h,u){t=d(h,u,0)},this.setState=function(h,u,f){const m=h.clippingPlanes,b=h.clipIntersection,p=h.clipShadows,g=r.get(h);if(!i||m===null||m.length===0||s&&!p)s?d(null):c();else{const y=s?0:n,x=y*4;let w=g.clippingState||null;l.value=w,w=d(m,u,x,f);for(let P=0;P!==x;++P)w[P]=t[P];g.clippingState=w,this.numIntersection=b?this.numPlanes:0,this.numPlanes+=y}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function d(h,u,f,m){const b=h!==null?h.length:0;let p=null;if(b!==0){if(p=l.value,m!==!0||p===null){const g=f+b*4,y=u.matrixWorldInverse;o.getNormalMatrix(y),(p===null||p.length<g)&&(p=new Float32Array(g));for(let x=0,w=f;x!==b;++x,w+=4)a.copy(h[x]).applyMatrix4(y,o),a.normal.toArray(p,w),p[w+3]=a.constant}l.value=p,l.needsUpdate=!0}return e.numPlanes=b,e.numIntersection=0,p}}function RM(r){let e=new WeakMap;function t(a,o){return o===vc?a.mapping=ya:o===Fh&&(a.mapping=xa),a}function n(a){if(a&&a.isTexture){const o=a.mapping;if(o===vc||o===Fh)if(e.has(a)){const l=e.get(a).texture;return t(l,a.mapping)}else{const l=a.image;if(l&&l.height>0){const c=new x0(l.height);return c.fromEquirectangularTexture(r,a),e.set(a,c),a.addEventListener("dispose",i),t(c.texture,a.mapping)}else return null}}return a}function i(a){const o=a.target;o.removeEventListener("dispose",i);const l=e.get(o);l!==void 0&&(e.delete(o),l.dispose())}function s(){e=new WeakMap}return{get:n,dispose:s}}const oa=4,kp=[.125,.215,.35,.446,.526,.582],br=20,Dd=new ko,Op=new Ne;let Ld=null,Id=0,kd=0,Od=!1;const ur=(1+Math.sqrt(5))/2,Kr=1/ur,Fp=[new I(-ur,Kr,0),new I(ur,Kr,0),new I(-Kr,0,ur),new I(Kr,0,ur),new I(0,ur,-Kr),new I(0,ur,Kr),new I(-1,1,-1),new I(1,1,-1),new I(-1,1,1),new I(1,1,1)],NM=new I;class Up{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,i=100,s={}){const{size:a=256,position:o=NM}=s;Ld=this._renderer.getRenderTarget(),Id=this._renderer.getActiveCubeFace(),kd=this._renderer.getActiveMipmapLevel(),Od=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const l=this._allocateTargets();return l.depthBuffer=!0,this._sceneToCubeUV(e,n,i,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=Hp(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=zp(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(Ld,Id,kd),this._renderer.xr.enabled=Od,e.scissorTest=!1,Dl(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===ya||e.mapping===xa?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Ld=this._renderer.getRenderTarget(),Id=this._renderer.getActiveCubeFace(),kd=this._renderer.getActiveMipmapLevel(),Od=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:bn,minFilter:bn,generateMipmaps:!1,type:Ri,format:Dn,colorSpace:$n,depthBuffer:!1},i=Bp(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Bp(e,t,n);const{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=DM(s)),this._blurMaterial=LM(s,e,t)}return i}_compileMaterial(e){const t=new Ee(this._lodPlanes[0],e);this._renderer.compile(t,Dd)}_sceneToCubeUV(e,t,n,i,s){const l=new gn(90,1,t,n),c=[1,-1,1,1,1,1],d=[1,1,1,-1,-1,-1],h=this._renderer,u=h.autoClear,f=h.toneMapping;h.getClearColor(Op),h.toneMapping=Xs,h.autoClear=!1;const m=new jt({name:"PMREM.Background",side:fi,depthWrite:!1,depthTest:!1}),b=new Ee(new Jt,m);let p=!1;const g=e.background;g?g.isColor&&(m.color.copy(g),e.background=null,p=!0):(m.color.copy(Op),p=!0);for(let y=0;y<6;y++){const x=y%3;x===0?(l.up.set(0,c[y],0),l.position.set(s.x,s.y,s.z),l.lookAt(s.x+d[y],s.y,s.z)):x===1?(l.up.set(0,0,c[y]),l.position.set(s.x,s.y,s.z),l.lookAt(s.x,s.y+d[y],s.z)):(l.up.set(0,c[y],0),l.position.set(s.x,s.y,s.z),l.lookAt(s.x,s.y,s.z+d[y]));const w=this._cubeSize;Dl(i,x*w,y>2?w:0,w,w),h.setRenderTarget(i),p&&h.render(b,l),h.render(e,l)}b.geometry.dispose(),b.material.dispose(),h.toneMapping=f,h.autoClear=u,e.background=g}_textureToCubeUV(e,t){const n=this._renderer,i=e.mapping===ya||e.mapping===xa;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=Hp()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=zp());const s=i?this._cubemapMaterial:this._equirectMaterial,a=new Ee(this._lodPlanes[0],s),o=s.uniforms;o.envMap.value=e;const l=this._cubeSize;Dl(t,0,0,3*l,2*l),n.setRenderTarget(t),n.render(a,Dd)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const i=this._lodPlanes.length;for(let s=1;s<i;s++){const a=Math.sqrt(this._sigmas[s]*this._sigmas[s]-this._sigmas[s-1]*this._sigmas[s-1]),o=Fp[(i-s-1)%Fp.length];this._blur(e,s-1,s,a,o)}t.autoClear=n}_blur(e,t,n,i,s){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,i,"latitudinal",s),this._halfBlur(a,e,n,n,i,"longitudinal",s)}_halfBlur(e,t,n,i,s,a,o){const l=this._renderer,c=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const d=3,h=new Ee(this._lodPlanes[i],c),u=c.uniforms,f=this._sizeLods[n]-1,m=isFinite(s)?Math.PI/(2*f):2*Math.PI/(2*br-1),b=s/m,p=isFinite(s)?1+Math.floor(d*b):br;p>br&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${p} samples when the maximum is set to ${br}`);const g=[];let y=0;for(let A=0;A<br;++A){const M=A/b,_=Math.exp(-M*M/2);g.push(_),A===0?y+=_:A<p&&(y+=2*_)}for(let A=0;A<g.length;A++)g[A]=g[A]/y;u.envMap.value=e.texture,u.samples.value=p,u.weights.value=g,u.latitudinal.value=a==="latitudinal",o&&(u.poleAxis.value=o);const{_lodMax:x}=this;u.dTheta.value=m,u.mipInt.value=x-n;const w=this._sizeLods[i],P=3*w*(i>x-oa?i-x+oa:0),T=4*(this._cubeSize-w);Dl(t,P,T,3*w,2*w),l.setRenderTarget(t),l.render(h,Dd)}}function DM(r){const e=[],t=[],n=[];let i=r;const s=r-oa+1+kp.length;for(let a=0;a<s;a++){const o=Math.pow(2,i);t.push(o);let l=1/o;a>r-oa?l=kp[a-r+oa-1]:a===0&&(l=0),n.push(l);const c=1/(o-2),d=-c,h=1+c,u=[d,d,h,d,h,h,d,d,h,h,d,h],f=6,m=6,b=3,p=2,g=1,y=new Float32Array(b*m*f),x=new Float32Array(p*m*f),w=new Float32Array(g*m*f);for(let T=0;T<f;T++){const A=T%3*2/3-1,M=T>2?0:-1,_=[A,M,0,A+2/3,M,0,A+2/3,M+1,0,A,M,0,A+2/3,M+1,0,A,M+1,0];y.set(_,b*m*T),x.set(u,p*m*T);const S=[T,T,T,T,T,T];w.set(S,g*m*T)}const P=new ht;P.setAttribute("position",new rn(y,b)),P.setAttribute("uv",new rn(x,p)),P.setAttribute("faceIndex",new rn(w,g)),e.push(P),i>oa&&i--}return{lodPlanes:e,sizeLods:t,sigmas:n}}function Bp(r,e,t){const n=new ni(r,e,t);return n.texture.mapping=Lc,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Dl(r,e,t,n,i){r.viewport.set(e,t,n,i),r.scissor.set(e,t,n,i)}function LM(r,e,t){const n=new Float32Array(br),i=new I(0,1,0);return new wn({name:"SphericalGaussianBlur",defines:{n:br,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${r}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:nf(),fragmentShader:`
|
|
3604
3604
|
|
|
3605
3605
|
precision mediump float;
|
|
3606
3606
|
precision mediump int;
|
|
@@ -3801,7 +3801,7 @@ Material Type: `+R.type+`
|
|
|
3801
3801
|
|
|
3802
3802
|
Program Info Log: `+k+`
|
|
3803
3803
|
`+K+`
|
|
3804
|
-
`+V)}else k!==""?console.warn("THREE.WebGLProgram: Program Info Log:",k):(O===""||H==="")&&(G=!1);G&&(R.diagnostics={runnable:q,programLog:k,vertexShader:{log:O,prefix:p},fragmentShader:{log:H,prefix:g}})}i.deleteShader(P),i.deleteShader(T),M=new fc(i,b),_=zT(i,b)}let M;this.getUniforms=function(){return M===void 0&&A(this),M};let _;this.getAttributes=function(){return _===void 0&&A(this),_};let S=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return S===!1&&(S=i.getProgramParameter(b,NT)),S},this.destroy=function(){n.releaseStatesOfProgram(this),i.deleteProgram(b),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=DT++,this.cacheKey=e,this.usedTimes=1,this.program=b,this.vertexShader=P,this.fragmentShader=T,this}let QT=0;class JT{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,n=e.fragmentShader,i=this._getShaderStage(t),s=this._getShaderStage(n),a=this._getShaderCacheForMaterial(e);return a.has(i)===!1&&(a.add(i),i.usedTimes++),a.has(s)===!1&&(a.add(s),s.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){const t=this.shaderCache;let n=t.get(e);return n===void 0&&(n=new eE(e),t.set(e,n)),n}}class eE{constructor(e){this.id=QT++,this.code=e,this.usedTimes=0}}function tE(r,e,t,n,i,s,a){const o=new Bu,l=new JT,c=new Set,d=[],h=i.logarithmicDepthBuffer,u=i.vertexTextures;let f=i.precision;const m={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function b(_){return c.add(_),_===0?"uv":`uv${_}`}function p(_,S,R,k,O){const H=k.fog,q=O.geometry,G=_.isMeshStandardMaterial?k.environment:null,K=(_.isMeshStandardMaterial?t:e).get(_.envMap||G),V=K&&K.mapping===Lc?K.image.height:null,Z=m[_.type];_.precision!==null&&(f=i.getMaxPrecision(_.precision),f!==_.precision&&console.warn("THREE.WebGLProgram.getParameters:",_.precision,"not supported, using",f,"instead."));const le=q.morphAttributes.position||q.morphAttributes.normal||q.morphAttributes.color,se=le!==void 0?le.length:0;let ge=0;q.morphAttributes.position!==void 0&&(ge=1),q.morphAttributes.normal!==void 0&&(ge=2),q.morphAttributes.color!==void 0&&(ge=3);let de,X,ee,ie;if(Z){const wt=di[Z];de=wt.vertexShader,X=wt.fragmentShader}else de=_.vertexShader,X=_.fragmentShader,l.update(_),ee=l.getVertexShaderID(_),ie=l.getFragmentShaderID(_);const Y=r.getRenderTarget(),ue=r.state.buffers.depth.getReversed(),oe=O.isInstancedMesh===!0,be=O.isBatchedMesh===!0,Ce=!!_.map,je=!!_.matcap,Fe=!!K,j=!!_.aoMap,Ke=!!_.lightMap,Ue=!!_.bumpMap,Te=!!_.normalMap,Se=!!_.displacementMap,et=!!_.emissiveMap,Be=!!_.metalnessMap,N=!!_.roughnessMap,E=_.anisotropy>0,W=_.clearcoat>0,ae=_.dispersion>0,ve=_.iridescence>0,ce=_.sheen>0,Oe=_.transmission>0,Pe=E&&!!_.anisotropyMap,Ve=W&&!!_.clearcoatMap,te=W&&!!_.clearcoatNormalMap,re=W&&!!_.clearcoatRoughnessMap,De=ve&&!!_.iridescenceMap,Ye=ve&&!!_.iridescenceThicknessMap,xe=ce&&!!_.sheenColorMap,Le=ce&&!!_.sheenRoughnessMap,ct=!!_.specularMap,rt=!!_.specularColorMap,Rt=!!_.specularIntensityMap,Q=Oe&&!!_.transmissionMap,Ge=Oe&&!!_.thicknessMap,ye=!!_.gradientMap,Me=!!_.alphaMap,Ze=_.alphaTest>0,Xe=!!_.alphaHash,vt=!!_.extensions;let Qt=Xs;_.toneMapped&&(Y===null||Y.isXRRenderTarget===!0)&&(Qt=r.toneMapping);const An={shaderID:Z,shaderType:_.type,shaderName:_.name,vertexShader:de,fragmentShader:X,defines:_.defines,customVertexShaderID:ee,customFragmentShaderID:ie,isRawShaderMaterial:_.isRawShaderMaterial===!0,glslVersion:_.glslVersion,precision:f,batching:be,batchingColor:be&&O._colorsTexture!==null,instancing:oe,instancingColor:oe&&O.instanceColor!==null,instancingMorph:oe&&O.morphTexture!==null,supportsVertexTextures:u,outputColorSpace:Y===null?r.outputColorSpace:Y.isXRRenderTarget===!0?Y.texture.colorSpace:$n,alphaToCoverage:!!_.alphaToCoverage,map:Ce,matcap:je,envMap:Fe,envMapMode:Fe&&K.mapping,envMapCubeUVHeight:V,aoMap:j,lightMap:Ke,bumpMap:Ue,normalMap:Te,displacementMap:u&&Se,emissiveMap:et,normalMapObjectSpace:Te&&_.normalMapType===Tx,normalMapTangentSpace:Te&&_.normalMapType===kc,metalnessMap:Be,roughnessMap:N,anisotropy:E,anisotropyMap:Pe,clearcoat:W,clearcoatMap:Ve,clearcoatNormalMap:te,clearcoatRoughnessMap:re,dispersion:ae,iridescence:ve,iridescenceMap:De,iridescenceThicknessMap:Ye,sheen:ce,sheenColorMap:xe,sheenRoughnessMap:Le,specularMap:ct,specularColorMap:rt,specularIntensityMap:Rt,transmission:Oe,transmissionMap:Q,thicknessMap:Ge,gradientMap:ye,opaque:_.transparent===!1&&_.blending===da&&_.alphaToCoverage===!1,alphaMap:Me,alphaTest:Ze,alphaHash:Xe,combine:_.combine,mapUv:Ce&&b(_.map.channel),aoMapUv:j&&b(_.aoMap.channel),lightMapUv:Ke&&b(_.lightMap.channel),bumpMapUv:Ue&&b(_.bumpMap.channel),normalMapUv:Te&&b(_.normalMap.channel),displacementMapUv:Se&&b(_.displacementMap.channel),emissiveMapUv:et&&b(_.emissiveMap.channel),metalnessMapUv:Be&&b(_.metalnessMap.channel),roughnessMapUv:N&&b(_.roughnessMap.channel),anisotropyMapUv:Pe&&b(_.anisotropyMap.channel),clearcoatMapUv:Ve&&b(_.clearcoatMap.channel),clearcoatNormalMapUv:te&&b(_.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:re&&b(_.clearcoatRoughnessMap.channel),iridescenceMapUv:De&&b(_.iridescenceMap.channel),iridescenceThicknessMapUv:Ye&&b(_.iridescenceThicknessMap.channel),sheenColorMapUv:xe&&b(_.sheenColorMap.channel),sheenRoughnessMapUv:Le&&b(_.sheenRoughnessMap.channel),specularMapUv:ct&&b(_.specularMap.channel),specularColorMapUv:rt&&b(_.specularColorMap.channel),specularIntensityMapUv:Rt&&b(_.specularIntensityMap.channel),transmissionMapUv:Q&&b(_.transmissionMap.channel),thicknessMapUv:Ge&&b(_.thicknessMap.channel),alphaMapUv:Me&&b(_.alphaMap.channel),vertexTangents:!!q.attributes.tangent&&(Te||E),vertexColors:_.vertexColors,vertexAlphas:_.vertexColors===!0&&!!q.attributes.color&&q.attributes.color.itemSize===4,pointsUvs:O.isPoints===!0&&!!q.attributes.uv&&(Ce||Me),fog:!!H,useFog:_.fog===!0,fogExp2:!!H&&H.isFogExp2,flatShading:_.flatShading===!0,sizeAttenuation:_.sizeAttenuation===!0,logarithmicDepthBuffer:h,reverseDepthBuffer:ue,skinning:O.isSkinnedMesh===!0,morphTargets:q.morphAttributes.position!==void 0,morphNormals:q.morphAttributes.normal!==void 0,morphColors:q.morphAttributes.color!==void 0,morphTargetsCount:se,morphTextureStride:ge,numDirLights:S.directional.length,numPointLights:S.point.length,numSpotLights:S.spot.length,numSpotLightMaps:S.spotLightMap.length,numRectAreaLights:S.rectArea.length,numHemiLights:S.hemi.length,numDirLightShadows:S.directionalShadowMap.length,numPointLightShadows:S.pointShadowMap.length,numSpotLightShadows:S.spotShadowMap.length,numSpotLightShadowsWithMaps:S.numSpotLightShadowsWithMaps,numLightProbes:S.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:_.dithering,shadowMapEnabled:r.shadowMap.enabled&&R.length>0,shadowMapType:r.shadowMap.type,toneMapping:Qt,decodeVideoTexture:Ce&&_.map.isVideoTexture===!0&&ft.getTransfer(_.map.colorSpace)===Ht,decodeVideoTextureEmissive:et&&_.emissiveMap.isVideoTexture===!0&&ft.getTransfer(_.emissiveMap.colorSpace)===Ht,premultipliedAlpha:_.premultipliedAlpha,doubleSided:_.side===ln,flipSided:_.side===fi,useDepthPacking:_.depthPacking>=0,depthPacking:_.depthPacking||0,index0AttributeName:_.index0AttributeName,extensionClipCullDistance:vt&&_.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(vt&&_.extensions.multiDraw===!0||be)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:_.customProgramCacheKey()};return An.vertexUv1s=c.has(1),An.vertexUv2s=c.has(2),An.vertexUv3s=c.has(3),c.clear(),An}function g(_){const S=[];if(_.shaderID?S.push(_.shaderID):(S.push(_.customVertexShaderID),S.push(_.customFragmentShaderID)),_.defines!==void 0)for(const R in _.defines)S.push(R),S.push(_.defines[R]);return _.isRawShaderMaterial===!1&&(y(S,_),x(S,_),S.push(r.outputColorSpace)),S.push(_.customProgramCacheKey),S.join()}function y(_,S){_.push(S.precision),_.push(S.outputColorSpace),_.push(S.envMapMode),_.push(S.envMapCubeUVHeight),_.push(S.mapUv),_.push(S.alphaMapUv),_.push(S.lightMapUv),_.push(S.aoMapUv),_.push(S.bumpMapUv),_.push(S.normalMapUv),_.push(S.displacementMapUv),_.push(S.emissiveMapUv),_.push(S.metalnessMapUv),_.push(S.roughnessMapUv),_.push(S.anisotropyMapUv),_.push(S.clearcoatMapUv),_.push(S.clearcoatNormalMapUv),_.push(S.clearcoatRoughnessMapUv),_.push(S.iridescenceMapUv),_.push(S.iridescenceThicknessMapUv),_.push(S.sheenColorMapUv),_.push(S.sheenRoughnessMapUv),_.push(S.specularMapUv),_.push(S.specularColorMapUv),_.push(S.specularIntensityMapUv),_.push(S.transmissionMapUv),_.push(S.thicknessMapUv),_.push(S.combine),_.push(S.fogExp2),_.push(S.sizeAttenuation),_.push(S.morphTargetsCount),_.push(S.morphAttributeCount),_.push(S.numDirLights),_.push(S.numPointLights),_.push(S.numSpotLights),_.push(S.numSpotLightMaps),_.push(S.numHemiLights),_.push(S.numRectAreaLights),_.push(S.numDirLightShadows),_.push(S.numPointLightShadows),_.push(S.numSpotLightShadows),_.push(S.numSpotLightShadowsWithMaps),_.push(S.numLightProbes),_.push(S.shadowMapType),_.push(S.toneMapping),_.push(S.numClippingPlanes),_.push(S.numClipIntersection),_.push(S.depthPacking)}function x(_,S){o.disableAll(),S.supportsVertexTextures&&o.enable(0),S.instancing&&o.enable(1),S.instancingColor&&o.enable(2),S.instancingMorph&&o.enable(3),S.matcap&&o.enable(4),S.envMap&&o.enable(5),S.normalMapObjectSpace&&o.enable(6),S.normalMapTangentSpace&&o.enable(7),S.clearcoat&&o.enable(8),S.iridescence&&o.enable(9),S.alphaTest&&o.enable(10),S.vertexColors&&o.enable(11),S.vertexAlphas&&o.enable(12),S.vertexUv1s&&o.enable(13),S.vertexUv2s&&o.enable(14),S.vertexUv3s&&o.enable(15),S.vertexTangents&&o.enable(16),S.anisotropy&&o.enable(17),S.alphaHash&&o.enable(18),S.batching&&o.enable(19),S.dispersion&&o.enable(20),S.batchingColor&&o.enable(21),_.push(o.mask),o.disableAll(),S.fog&&o.enable(0),S.useFog&&o.enable(1),S.flatShading&&o.enable(2),S.logarithmicDepthBuffer&&o.enable(3),S.reverseDepthBuffer&&o.enable(4),S.skinning&&o.enable(5),S.morphTargets&&o.enable(6),S.morphNormals&&o.enable(7),S.morphColors&&o.enable(8),S.premultipliedAlpha&&o.enable(9),S.shadowMapEnabled&&o.enable(10),S.doubleSided&&o.enable(11),S.flipSided&&o.enable(12),S.useDepthPacking&&o.enable(13),S.dithering&&o.enable(14),S.transmission&&o.enable(15),S.sheen&&o.enable(16),S.opaque&&o.enable(17),S.pointsUvs&&o.enable(18),S.decodeVideoTexture&&o.enable(19),S.decodeVideoTextureEmissive&&o.enable(20),S.alphaToCoverage&&o.enable(21),_.push(o.mask)}function w(_){const S=m[_.type];let R;if(S){const k=di[S];R=Ca.clone(k.uniforms)}else R=_.uniforms;return R}function P(_,S){let R;for(let k=0,O=d.length;k<O;k++){const H=d[k];if(H.cacheKey===S){R=H,++R.usedTimes;break}}return R===void 0&&(R=new $T(r,S,_,s),d.push(R)),R}function T(_){if(--_.usedTimes===0){const S=d.indexOf(_);d[S]=d[d.length-1],d.pop(),_.destroy()}}function A(_){l.remove(_)}function M(){l.dispose()}return{getParameters:p,getProgramCacheKey:g,getUniforms:w,acquireProgram:P,releaseProgram:T,releaseShaderCache:A,programs:d,dispose:M}}function nE(){let r=new WeakMap;function e(a){return r.has(a)}function t(a){let o=r.get(a);return o===void 0&&(o={},r.set(a,o)),o}function n(a){r.delete(a)}function i(a,o,l){r.get(a)[o]=l}function s(){r=new WeakMap}return{has:e,get:t,remove:n,update:i,dispose:s}}function iE(r,e){return r.groupOrder!==e.groupOrder?r.groupOrder-e.groupOrder:r.renderOrder!==e.renderOrder?r.renderOrder-e.renderOrder:r.material.id!==e.material.id?r.material.id-e.material.id:r.z!==e.z?r.z-e.z:r.id-e.id}function nm(r,e){return r.groupOrder!==e.groupOrder?r.groupOrder-e.groupOrder:r.renderOrder!==e.renderOrder?r.renderOrder-e.renderOrder:r.z!==e.z?e.z-r.z:r.id-e.id}function im(){const r=[];let e=0;const t=[],n=[],i=[];function s(){e=0,t.length=0,n.length=0,i.length=0}function a(h,u,f,m,b,p){let g=r[e];return g===void 0?(g={id:h.id,object:h,geometry:u,material:f,groupOrder:m,renderOrder:h.renderOrder,z:b,group:p},r[e]=g):(g.id=h.id,g.object=h,g.geometry=u,g.material=f,g.groupOrder=m,g.renderOrder=h.renderOrder,g.z=b,g.group=p),e++,g}function o(h,u,f,m,b,p){const g=a(h,u,f,m,b,p);f.transmission>0?n.push(g):f.transparent===!0?i.push(g):t.push(g)}function l(h,u,f,m,b,p){const g=a(h,u,f,m,b,p);f.transmission>0?n.unshift(g):f.transparent===!0?i.unshift(g):t.unshift(g)}function c(h,u){t.length>1&&t.sort(h||iE),n.length>1&&n.sort(u||nm),i.length>1&&i.sort(u||nm)}function d(){for(let h=e,u=r.length;h<u;h++){const f=r[h];if(f.id===null)break;f.id=null,f.object=null,f.geometry=null,f.material=null,f.group=null}}return{opaque:t,transmissive:n,transparent:i,init:s,push:o,unshift:l,finish:d,sort:c}}function sE(){let r=new WeakMap;function e(n,i){const s=r.get(n);let a;return s===void 0?(a=new im,r.set(n,[a])):i>=s.length?(a=new im,s.push(a)):a=s[i],a}function t(){r=new WeakMap}return{get:e,dispose:t}}function rE(){const r={};return{get:function(e){if(r[e.id]!==void 0)return r[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new I,color:new Ne};break;case"SpotLight":t={position:new I,direction:new I,color:new Ne,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new I,color:new Ne,distance:0,decay:0};break;case"HemisphereLight":t={direction:new I,skyColor:new Ne,groundColor:new Ne};break;case"RectAreaLight":t={color:new Ne,position:new I,halfWidth:new I,halfHeight:new I};break}return r[e.id]=t,t}}}function aE(){const r={};return{get:function(e){if(r[e.id]!==void 0)return r[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new me};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new me};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new me,shadowCameraNear:1,shadowCameraFar:1e3};break}return r[e.id]=t,t}}}let oE=0;function lE(r,e){return(e.castShadow?2:0)-(r.castShadow?2:0)+(e.map?1:0)-(r.map?1:0)}function cE(r){const e=new rE,t=aE(),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 I);const i=new I,s=new Ie,a=new Ie;function o(c){let d=0,h=0,u=0;for(let _=0;_<9;_++)n.probe[_].set(0,0,0);let f=0,m=0,b=0,p=0,g=0,y=0,x=0,w=0,P=0,T=0,A=0;c.sort(lE);for(let _=0,S=c.length;_<S;_++){const R=c[_],k=R.color,O=R.intensity,H=R.distance,q=R.shadow&&R.shadow.map?R.shadow.map.texture:null;if(R.isAmbientLight)d+=k.r*O,h+=k.g*O,u+=k.b*O;else if(R.isLightProbe){for(let G=0;G<9;G++)n.probe[G].addScaledVector(R.sh.coefficients[G],O);A++}else if(R.isDirectionalLight){const G=e.get(R);if(G.color.copy(R.color).multiplyScalar(R.intensity),R.castShadow){const K=R.shadow,V=t.get(R);V.shadowIntensity=K.intensity,V.shadowBias=K.bias,V.shadowNormalBias=K.normalBias,V.shadowRadius=K.radius,V.shadowMapSize=K.mapSize,n.directionalShadow[f]=V,n.directionalShadowMap[f]=q,n.directionalShadowMatrix[f]=R.shadow.matrix,y++}n.directional[f]=G,f++}else if(R.isSpotLight){const G=e.get(R);G.position.setFromMatrixPosition(R.matrixWorld),G.color.copy(k).multiplyScalar(O),G.distance=H,G.coneCos=Math.cos(R.angle),G.penumbraCos=Math.cos(R.angle*(1-R.penumbra)),G.decay=R.decay,n.spot[b]=G;const K=R.shadow;if(R.map&&(n.spotLightMap[P]=R.map,P++,K.updateMatrices(R),R.castShadow&&T++),n.spotLightMatrix[b]=K.matrix,R.castShadow){const V=t.get(R);V.shadowIntensity=K.intensity,V.shadowBias=K.bias,V.shadowNormalBias=K.normalBias,V.shadowRadius=K.radius,V.shadowMapSize=K.mapSize,n.spotShadow[b]=V,n.spotShadowMap[b]=q,w++}b++}else if(R.isRectAreaLight){const G=e.get(R);G.color.copy(k).multiplyScalar(O),G.halfWidth.set(R.width*.5,0,0),G.halfHeight.set(0,R.height*.5,0),n.rectArea[p]=G,p++}else if(R.isPointLight){const G=e.get(R);if(G.color.copy(R.color).multiplyScalar(R.intensity),G.distance=R.distance,G.decay=R.decay,R.castShadow){const K=R.shadow,V=t.get(R);V.shadowIntensity=K.intensity,V.shadowBias=K.bias,V.shadowNormalBias=K.normalBias,V.shadowRadius=K.radius,V.shadowMapSize=K.mapSize,V.shadowCameraNear=K.camera.near,V.shadowCameraFar=K.camera.far,n.pointShadow[m]=V,n.pointShadowMap[m]=q,n.pointShadowMatrix[m]=R.shadow.matrix,x++}n.point[m]=G,m++}else if(R.isHemisphereLight){const G=e.get(R);G.skyColor.copy(R.color).multiplyScalar(O),G.groundColor.copy(R.groundColor).multiplyScalar(O),n.hemi[g]=G,g++}}p>0&&(r.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=He.LTC_FLOAT_1,n.rectAreaLTC2=He.LTC_FLOAT_2):(n.rectAreaLTC1=He.LTC_HALF_1,n.rectAreaLTC2=He.LTC_HALF_2)),n.ambient[0]=d,n.ambient[1]=h,n.ambient[2]=u;const M=n.hash;(M.directionalLength!==f||M.pointLength!==m||M.spotLength!==b||M.rectAreaLength!==p||M.hemiLength!==g||M.numDirectionalShadows!==y||M.numPointShadows!==x||M.numSpotShadows!==w||M.numSpotMaps!==P||M.numLightProbes!==A)&&(n.directional.length=f,n.spot.length=b,n.rectArea.length=p,n.point.length=m,n.hemi.length=g,n.directionalShadow.length=y,n.directionalShadowMap.length=y,n.pointShadow.length=x,n.pointShadowMap.length=x,n.spotShadow.length=w,n.spotShadowMap.length=w,n.directionalShadowMatrix.length=y,n.pointShadowMatrix.length=x,n.spotLightMatrix.length=w+P-T,n.spotLightMap.length=P,n.numSpotLightShadowsWithMaps=T,n.numLightProbes=A,M.directionalLength=f,M.pointLength=m,M.spotLength=b,M.rectAreaLength=p,M.hemiLength=g,M.numDirectionalShadows=y,M.numPointShadows=x,M.numSpotShadows=w,M.numSpotMaps=P,M.numLightProbes=A,n.version=oE++)}function l(c,d){let h=0,u=0,f=0,m=0,b=0;const p=d.matrixWorldInverse;for(let g=0,y=c.length;g<y;g++){const x=c[g];if(x.isDirectionalLight){const w=n.directional[h];w.direction.setFromMatrixPosition(x.matrixWorld),i.setFromMatrixPosition(x.target.matrixWorld),w.direction.sub(i),w.direction.transformDirection(p),h++}else if(x.isSpotLight){const w=n.spot[f];w.position.setFromMatrixPosition(x.matrixWorld),w.position.applyMatrix4(p),w.direction.setFromMatrixPosition(x.matrixWorld),i.setFromMatrixPosition(x.target.matrixWorld),w.direction.sub(i),w.direction.transformDirection(p),f++}else if(x.isRectAreaLight){const w=n.rectArea[m];w.position.setFromMatrixPosition(x.matrixWorld),w.position.applyMatrix4(p),a.identity(),s.copy(x.matrixWorld),s.premultiply(p),a.extractRotation(s),w.halfWidth.set(x.width*.5,0,0),w.halfHeight.set(0,x.height*.5,0),w.halfWidth.applyMatrix4(a),w.halfHeight.applyMatrix4(a),m++}else if(x.isPointLight){const w=n.point[u];w.position.setFromMatrixPosition(x.matrixWorld),w.position.applyMatrix4(p),u++}else if(x.isHemisphereLight){const w=n.hemi[b];w.direction.setFromMatrixPosition(x.matrixWorld),w.direction.transformDirection(p),b++}}}return{setup:o,setupView:l,state:n}}function sm(r){const e=new cE(r),t=[],n=[];function i(d){c.camera=d,t.length=0,n.length=0}function s(d){t.push(d)}function a(d){n.push(d)}function o(){e.setup(t)}function l(d){e.setupView(t,d)}const c={lightsArray:t,shadowsArray:n,camera:null,lights:e,transmissionRenderTarget:{}};return{init:i,state:c,setupLights:o,setupLightsView:l,pushLight:s,pushShadow:a}}function dE(r){let e=new WeakMap;function t(i,s=0){const a=e.get(i);let o;return a===void 0?(o=new sm(r),e.set(i,[o])):s>=a.length?(o=new sm(r),a.push(o)):o=a[s],o}function n(){e=new WeakMap}return{get:t,dispose:n}}const hE=`void main() {
|
|
3804
|
+
`+V)}else k!==""?console.warn("THREE.WebGLProgram: Program Info Log:",k):(O===""||H==="")&&(G=!1);G&&(R.diagnostics={runnable:q,programLog:k,vertexShader:{log:O,prefix:p},fragmentShader:{log:H,prefix:g}})}i.deleteShader(P),i.deleteShader(T),M=new fc(i,b),_=zT(i,b)}let M;this.getUniforms=function(){return M===void 0&&A(this),M};let _;this.getAttributes=function(){return _===void 0&&A(this),_};let S=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return S===!1&&(S=i.getProgramParameter(b,NT)),S},this.destroy=function(){n.releaseStatesOfProgram(this),i.deleteProgram(b),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=DT++,this.cacheKey=e,this.usedTimes=1,this.program=b,this.vertexShader=P,this.fragmentShader=T,this}let QT=0;class JT{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,n=e.fragmentShader,i=this._getShaderStage(t),s=this._getShaderStage(n),a=this._getShaderCacheForMaterial(e);return a.has(i)===!1&&(a.add(i),i.usedTimes++),a.has(s)===!1&&(a.add(s),s.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){const t=this.shaderCache;let n=t.get(e);return n===void 0&&(n=new eE(e),t.set(e,n)),n}}class eE{constructor(e){this.id=QT++,this.code=e,this.usedTimes=0}}function tE(r,e,t,n,i,s,a){const o=new Bu,l=new JT,c=new Set,d=[],h=i.logarithmicDepthBuffer,u=i.vertexTextures;let f=i.precision;const m={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function b(_){return c.add(_),_===0?"uv":`uv${_}`}function p(_,S,R,k,O){const H=k.fog,q=O.geometry,G=_.isMeshStandardMaterial?k.environment:null,K=(_.isMeshStandardMaterial?t:e).get(_.envMap||G),V=K&&K.mapping===Lc?K.image.height:null,Y=m[_.type];_.precision!==null&&(f=i.getMaxPrecision(_.precision),f!==_.precision&&console.warn("THREE.WebGLProgram.getParameters:",_.precision,"not supported, using",f,"instead."));const le=q.morphAttributes.position||q.morphAttributes.normal||q.morphAttributes.color,se=le!==void 0?le.length:0;let ge=0;q.morphAttributes.position!==void 0&&(ge=1),q.morphAttributes.normal!==void 0&&(ge=2),q.morphAttributes.color!==void 0&&(ge=3);let de,X,ee,ie;if(Y){const wt=di[Y];de=wt.vertexShader,X=wt.fragmentShader}else de=_.vertexShader,X=_.fragmentShader,l.update(_),ee=l.getVertexShaderID(_),ie=l.getFragmentShaderID(_);const Z=r.getRenderTarget(),ue=r.state.buffers.depth.getReversed(),oe=O.isInstancedMesh===!0,be=O.isBatchedMesh===!0,Ce=!!_.map,je=!!_.matcap,Fe=!!K,j=!!_.aoMap,Ke=!!_.lightMap,Ue=!!_.bumpMap,Te=!!_.normalMap,Se=!!_.displacementMap,et=!!_.emissiveMap,Be=!!_.metalnessMap,N=!!_.roughnessMap,E=_.anisotropy>0,W=_.clearcoat>0,ae=_.dispersion>0,ve=_.iridescence>0,ce=_.sheen>0,Oe=_.transmission>0,Pe=E&&!!_.anisotropyMap,Ve=W&&!!_.clearcoatMap,te=W&&!!_.clearcoatNormalMap,re=W&&!!_.clearcoatRoughnessMap,De=ve&&!!_.iridescenceMap,Ye=ve&&!!_.iridescenceThicknessMap,xe=ce&&!!_.sheenColorMap,Le=ce&&!!_.sheenRoughnessMap,ct=!!_.specularMap,rt=!!_.specularColorMap,Rt=!!_.specularIntensityMap,Q=Oe&&!!_.transmissionMap,Ge=Oe&&!!_.thicknessMap,ye=!!_.gradientMap,Me=!!_.alphaMap,Ze=_.alphaTest>0,Xe=!!_.alphaHash,vt=!!_.extensions;let Qt=Xs;_.toneMapped&&(Z===null||Z.isXRRenderTarget===!0)&&(Qt=r.toneMapping);const An={shaderID:Y,shaderType:_.type,shaderName:_.name,vertexShader:de,fragmentShader:X,defines:_.defines,customVertexShaderID:ee,customFragmentShaderID:ie,isRawShaderMaterial:_.isRawShaderMaterial===!0,glslVersion:_.glslVersion,precision:f,batching:be,batchingColor:be&&O._colorsTexture!==null,instancing:oe,instancingColor:oe&&O.instanceColor!==null,instancingMorph:oe&&O.morphTexture!==null,supportsVertexTextures:u,outputColorSpace:Z===null?r.outputColorSpace:Z.isXRRenderTarget===!0?Z.texture.colorSpace:$n,alphaToCoverage:!!_.alphaToCoverage,map:Ce,matcap:je,envMap:Fe,envMapMode:Fe&&K.mapping,envMapCubeUVHeight:V,aoMap:j,lightMap:Ke,bumpMap:Ue,normalMap:Te,displacementMap:u&&Se,emissiveMap:et,normalMapObjectSpace:Te&&_.normalMapType===Tx,normalMapTangentSpace:Te&&_.normalMapType===kc,metalnessMap:Be,roughnessMap:N,anisotropy:E,anisotropyMap:Pe,clearcoat:W,clearcoatMap:Ve,clearcoatNormalMap:te,clearcoatRoughnessMap:re,dispersion:ae,iridescence:ve,iridescenceMap:De,iridescenceThicknessMap:Ye,sheen:ce,sheenColorMap:xe,sheenRoughnessMap:Le,specularMap:ct,specularColorMap:rt,specularIntensityMap:Rt,transmission:Oe,transmissionMap:Q,thicknessMap:Ge,gradientMap:ye,opaque:_.transparent===!1&&_.blending===da&&_.alphaToCoverage===!1,alphaMap:Me,alphaTest:Ze,alphaHash:Xe,combine:_.combine,mapUv:Ce&&b(_.map.channel),aoMapUv:j&&b(_.aoMap.channel),lightMapUv:Ke&&b(_.lightMap.channel),bumpMapUv:Ue&&b(_.bumpMap.channel),normalMapUv:Te&&b(_.normalMap.channel),displacementMapUv:Se&&b(_.displacementMap.channel),emissiveMapUv:et&&b(_.emissiveMap.channel),metalnessMapUv:Be&&b(_.metalnessMap.channel),roughnessMapUv:N&&b(_.roughnessMap.channel),anisotropyMapUv:Pe&&b(_.anisotropyMap.channel),clearcoatMapUv:Ve&&b(_.clearcoatMap.channel),clearcoatNormalMapUv:te&&b(_.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:re&&b(_.clearcoatRoughnessMap.channel),iridescenceMapUv:De&&b(_.iridescenceMap.channel),iridescenceThicknessMapUv:Ye&&b(_.iridescenceThicknessMap.channel),sheenColorMapUv:xe&&b(_.sheenColorMap.channel),sheenRoughnessMapUv:Le&&b(_.sheenRoughnessMap.channel),specularMapUv:ct&&b(_.specularMap.channel),specularColorMapUv:rt&&b(_.specularColorMap.channel),specularIntensityMapUv:Rt&&b(_.specularIntensityMap.channel),transmissionMapUv:Q&&b(_.transmissionMap.channel),thicknessMapUv:Ge&&b(_.thicknessMap.channel),alphaMapUv:Me&&b(_.alphaMap.channel),vertexTangents:!!q.attributes.tangent&&(Te||E),vertexColors:_.vertexColors,vertexAlphas:_.vertexColors===!0&&!!q.attributes.color&&q.attributes.color.itemSize===4,pointsUvs:O.isPoints===!0&&!!q.attributes.uv&&(Ce||Me),fog:!!H,useFog:_.fog===!0,fogExp2:!!H&&H.isFogExp2,flatShading:_.flatShading===!0,sizeAttenuation:_.sizeAttenuation===!0,logarithmicDepthBuffer:h,reverseDepthBuffer:ue,skinning:O.isSkinnedMesh===!0,morphTargets:q.morphAttributes.position!==void 0,morphNormals:q.morphAttributes.normal!==void 0,morphColors:q.morphAttributes.color!==void 0,morphTargetsCount:se,morphTextureStride:ge,numDirLights:S.directional.length,numPointLights:S.point.length,numSpotLights:S.spot.length,numSpotLightMaps:S.spotLightMap.length,numRectAreaLights:S.rectArea.length,numHemiLights:S.hemi.length,numDirLightShadows:S.directionalShadowMap.length,numPointLightShadows:S.pointShadowMap.length,numSpotLightShadows:S.spotShadowMap.length,numSpotLightShadowsWithMaps:S.numSpotLightShadowsWithMaps,numLightProbes:S.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:_.dithering,shadowMapEnabled:r.shadowMap.enabled&&R.length>0,shadowMapType:r.shadowMap.type,toneMapping:Qt,decodeVideoTexture:Ce&&_.map.isVideoTexture===!0&&ft.getTransfer(_.map.colorSpace)===Ht,decodeVideoTextureEmissive:et&&_.emissiveMap.isVideoTexture===!0&&ft.getTransfer(_.emissiveMap.colorSpace)===Ht,premultipliedAlpha:_.premultipliedAlpha,doubleSided:_.side===ln,flipSided:_.side===fi,useDepthPacking:_.depthPacking>=0,depthPacking:_.depthPacking||0,index0AttributeName:_.index0AttributeName,extensionClipCullDistance:vt&&_.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(vt&&_.extensions.multiDraw===!0||be)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:_.customProgramCacheKey()};return An.vertexUv1s=c.has(1),An.vertexUv2s=c.has(2),An.vertexUv3s=c.has(3),c.clear(),An}function g(_){const S=[];if(_.shaderID?S.push(_.shaderID):(S.push(_.customVertexShaderID),S.push(_.customFragmentShaderID)),_.defines!==void 0)for(const R in _.defines)S.push(R),S.push(_.defines[R]);return _.isRawShaderMaterial===!1&&(y(S,_),x(S,_),S.push(r.outputColorSpace)),S.push(_.customProgramCacheKey),S.join()}function y(_,S){_.push(S.precision),_.push(S.outputColorSpace),_.push(S.envMapMode),_.push(S.envMapCubeUVHeight),_.push(S.mapUv),_.push(S.alphaMapUv),_.push(S.lightMapUv),_.push(S.aoMapUv),_.push(S.bumpMapUv),_.push(S.normalMapUv),_.push(S.displacementMapUv),_.push(S.emissiveMapUv),_.push(S.metalnessMapUv),_.push(S.roughnessMapUv),_.push(S.anisotropyMapUv),_.push(S.clearcoatMapUv),_.push(S.clearcoatNormalMapUv),_.push(S.clearcoatRoughnessMapUv),_.push(S.iridescenceMapUv),_.push(S.iridescenceThicknessMapUv),_.push(S.sheenColorMapUv),_.push(S.sheenRoughnessMapUv),_.push(S.specularMapUv),_.push(S.specularColorMapUv),_.push(S.specularIntensityMapUv),_.push(S.transmissionMapUv),_.push(S.thicknessMapUv),_.push(S.combine),_.push(S.fogExp2),_.push(S.sizeAttenuation),_.push(S.morphTargetsCount),_.push(S.morphAttributeCount),_.push(S.numDirLights),_.push(S.numPointLights),_.push(S.numSpotLights),_.push(S.numSpotLightMaps),_.push(S.numHemiLights),_.push(S.numRectAreaLights),_.push(S.numDirLightShadows),_.push(S.numPointLightShadows),_.push(S.numSpotLightShadows),_.push(S.numSpotLightShadowsWithMaps),_.push(S.numLightProbes),_.push(S.shadowMapType),_.push(S.toneMapping),_.push(S.numClippingPlanes),_.push(S.numClipIntersection),_.push(S.depthPacking)}function x(_,S){o.disableAll(),S.supportsVertexTextures&&o.enable(0),S.instancing&&o.enable(1),S.instancingColor&&o.enable(2),S.instancingMorph&&o.enable(3),S.matcap&&o.enable(4),S.envMap&&o.enable(5),S.normalMapObjectSpace&&o.enable(6),S.normalMapTangentSpace&&o.enable(7),S.clearcoat&&o.enable(8),S.iridescence&&o.enable(9),S.alphaTest&&o.enable(10),S.vertexColors&&o.enable(11),S.vertexAlphas&&o.enable(12),S.vertexUv1s&&o.enable(13),S.vertexUv2s&&o.enable(14),S.vertexUv3s&&o.enable(15),S.vertexTangents&&o.enable(16),S.anisotropy&&o.enable(17),S.alphaHash&&o.enable(18),S.batching&&o.enable(19),S.dispersion&&o.enable(20),S.batchingColor&&o.enable(21),_.push(o.mask),o.disableAll(),S.fog&&o.enable(0),S.useFog&&o.enable(1),S.flatShading&&o.enable(2),S.logarithmicDepthBuffer&&o.enable(3),S.reverseDepthBuffer&&o.enable(4),S.skinning&&o.enable(5),S.morphTargets&&o.enable(6),S.morphNormals&&o.enable(7),S.morphColors&&o.enable(8),S.premultipliedAlpha&&o.enable(9),S.shadowMapEnabled&&o.enable(10),S.doubleSided&&o.enable(11),S.flipSided&&o.enable(12),S.useDepthPacking&&o.enable(13),S.dithering&&o.enable(14),S.transmission&&o.enable(15),S.sheen&&o.enable(16),S.opaque&&o.enable(17),S.pointsUvs&&o.enable(18),S.decodeVideoTexture&&o.enable(19),S.decodeVideoTextureEmissive&&o.enable(20),S.alphaToCoverage&&o.enable(21),_.push(o.mask)}function w(_){const S=m[_.type];let R;if(S){const k=di[S];R=Ca.clone(k.uniforms)}else R=_.uniforms;return R}function P(_,S){let R;for(let k=0,O=d.length;k<O;k++){const H=d[k];if(H.cacheKey===S){R=H,++R.usedTimes;break}}return R===void 0&&(R=new $T(r,S,_,s),d.push(R)),R}function T(_){if(--_.usedTimes===0){const S=d.indexOf(_);d[S]=d[d.length-1],d.pop(),_.destroy()}}function A(_){l.remove(_)}function M(){l.dispose()}return{getParameters:p,getProgramCacheKey:g,getUniforms:w,acquireProgram:P,releaseProgram:T,releaseShaderCache:A,programs:d,dispose:M}}function nE(){let r=new WeakMap;function e(a){return r.has(a)}function t(a){let o=r.get(a);return o===void 0&&(o={},r.set(a,o)),o}function n(a){r.delete(a)}function i(a,o,l){r.get(a)[o]=l}function s(){r=new WeakMap}return{has:e,get:t,remove:n,update:i,dispose:s}}function iE(r,e){return r.groupOrder!==e.groupOrder?r.groupOrder-e.groupOrder:r.renderOrder!==e.renderOrder?r.renderOrder-e.renderOrder:r.material.id!==e.material.id?r.material.id-e.material.id:r.z!==e.z?r.z-e.z:r.id-e.id}function nm(r,e){return r.groupOrder!==e.groupOrder?r.groupOrder-e.groupOrder:r.renderOrder!==e.renderOrder?r.renderOrder-e.renderOrder:r.z!==e.z?e.z-r.z:r.id-e.id}function im(){const r=[];let e=0;const t=[],n=[],i=[];function s(){e=0,t.length=0,n.length=0,i.length=0}function a(h,u,f,m,b,p){let g=r[e];return g===void 0?(g={id:h.id,object:h,geometry:u,material:f,groupOrder:m,renderOrder:h.renderOrder,z:b,group:p},r[e]=g):(g.id=h.id,g.object=h,g.geometry=u,g.material=f,g.groupOrder=m,g.renderOrder=h.renderOrder,g.z=b,g.group=p),e++,g}function o(h,u,f,m,b,p){const g=a(h,u,f,m,b,p);f.transmission>0?n.push(g):f.transparent===!0?i.push(g):t.push(g)}function l(h,u,f,m,b,p){const g=a(h,u,f,m,b,p);f.transmission>0?n.unshift(g):f.transparent===!0?i.unshift(g):t.unshift(g)}function c(h,u){t.length>1&&t.sort(h||iE),n.length>1&&n.sort(u||nm),i.length>1&&i.sort(u||nm)}function d(){for(let h=e,u=r.length;h<u;h++){const f=r[h];if(f.id===null)break;f.id=null,f.object=null,f.geometry=null,f.material=null,f.group=null}}return{opaque:t,transmissive:n,transparent:i,init:s,push:o,unshift:l,finish:d,sort:c}}function sE(){let r=new WeakMap;function e(n,i){const s=r.get(n);let a;return s===void 0?(a=new im,r.set(n,[a])):i>=s.length?(a=new im,s.push(a)):a=s[i],a}function t(){r=new WeakMap}return{get:e,dispose:t}}function rE(){const r={};return{get:function(e){if(r[e.id]!==void 0)return r[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new I,color:new Ne};break;case"SpotLight":t={position:new I,direction:new I,color:new Ne,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new I,color:new Ne,distance:0,decay:0};break;case"HemisphereLight":t={direction:new I,skyColor:new Ne,groundColor:new Ne};break;case"RectAreaLight":t={color:new Ne,position:new I,halfWidth:new I,halfHeight:new I};break}return r[e.id]=t,t}}}function aE(){const r={};return{get:function(e){if(r[e.id]!==void 0)return r[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new me};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new me};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new me,shadowCameraNear:1,shadowCameraFar:1e3};break}return r[e.id]=t,t}}}let oE=0;function lE(r,e){return(e.castShadow?2:0)-(r.castShadow?2:0)+(e.map?1:0)-(r.map?1:0)}function cE(r){const e=new rE,t=aE(),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 I);const i=new I,s=new Ie,a=new Ie;function o(c){let d=0,h=0,u=0;for(let _=0;_<9;_++)n.probe[_].set(0,0,0);let f=0,m=0,b=0,p=0,g=0,y=0,x=0,w=0,P=0,T=0,A=0;c.sort(lE);for(let _=0,S=c.length;_<S;_++){const R=c[_],k=R.color,O=R.intensity,H=R.distance,q=R.shadow&&R.shadow.map?R.shadow.map.texture:null;if(R.isAmbientLight)d+=k.r*O,h+=k.g*O,u+=k.b*O;else if(R.isLightProbe){for(let G=0;G<9;G++)n.probe[G].addScaledVector(R.sh.coefficients[G],O);A++}else if(R.isDirectionalLight){const G=e.get(R);if(G.color.copy(R.color).multiplyScalar(R.intensity),R.castShadow){const K=R.shadow,V=t.get(R);V.shadowIntensity=K.intensity,V.shadowBias=K.bias,V.shadowNormalBias=K.normalBias,V.shadowRadius=K.radius,V.shadowMapSize=K.mapSize,n.directionalShadow[f]=V,n.directionalShadowMap[f]=q,n.directionalShadowMatrix[f]=R.shadow.matrix,y++}n.directional[f]=G,f++}else if(R.isSpotLight){const G=e.get(R);G.position.setFromMatrixPosition(R.matrixWorld),G.color.copy(k).multiplyScalar(O),G.distance=H,G.coneCos=Math.cos(R.angle),G.penumbraCos=Math.cos(R.angle*(1-R.penumbra)),G.decay=R.decay,n.spot[b]=G;const K=R.shadow;if(R.map&&(n.spotLightMap[P]=R.map,P++,K.updateMatrices(R),R.castShadow&&T++),n.spotLightMatrix[b]=K.matrix,R.castShadow){const V=t.get(R);V.shadowIntensity=K.intensity,V.shadowBias=K.bias,V.shadowNormalBias=K.normalBias,V.shadowRadius=K.radius,V.shadowMapSize=K.mapSize,n.spotShadow[b]=V,n.spotShadowMap[b]=q,w++}b++}else if(R.isRectAreaLight){const G=e.get(R);G.color.copy(k).multiplyScalar(O),G.halfWidth.set(R.width*.5,0,0),G.halfHeight.set(0,R.height*.5,0),n.rectArea[p]=G,p++}else if(R.isPointLight){const G=e.get(R);if(G.color.copy(R.color).multiplyScalar(R.intensity),G.distance=R.distance,G.decay=R.decay,R.castShadow){const K=R.shadow,V=t.get(R);V.shadowIntensity=K.intensity,V.shadowBias=K.bias,V.shadowNormalBias=K.normalBias,V.shadowRadius=K.radius,V.shadowMapSize=K.mapSize,V.shadowCameraNear=K.camera.near,V.shadowCameraFar=K.camera.far,n.pointShadow[m]=V,n.pointShadowMap[m]=q,n.pointShadowMatrix[m]=R.shadow.matrix,x++}n.point[m]=G,m++}else if(R.isHemisphereLight){const G=e.get(R);G.skyColor.copy(R.color).multiplyScalar(O),G.groundColor.copy(R.groundColor).multiplyScalar(O),n.hemi[g]=G,g++}}p>0&&(r.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=He.LTC_FLOAT_1,n.rectAreaLTC2=He.LTC_FLOAT_2):(n.rectAreaLTC1=He.LTC_HALF_1,n.rectAreaLTC2=He.LTC_HALF_2)),n.ambient[0]=d,n.ambient[1]=h,n.ambient[2]=u;const M=n.hash;(M.directionalLength!==f||M.pointLength!==m||M.spotLength!==b||M.rectAreaLength!==p||M.hemiLength!==g||M.numDirectionalShadows!==y||M.numPointShadows!==x||M.numSpotShadows!==w||M.numSpotMaps!==P||M.numLightProbes!==A)&&(n.directional.length=f,n.spot.length=b,n.rectArea.length=p,n.point.length=m,n.hemi.length=g,n.directionalShadow.length=y,n.directionalShadowMap.length=y,n.pointShadow.length=x,n.pointShadowMap.length=x,n.spotShadow.length=w,n.spotShadowMap.length=w,n.directionalShadowMatrix.length=y,n.pointShadowMatrix.length=x,n.spotLightMatrix.length=w+P-T,n.spotLightMap.length=P,n.numSpotLightShadowsWithMaps=T,n.numLightProbes=A,M.directionalLength=f,M.pointLength=m,M.spotLength=b,M.rectAreaLength=p,M.hemiLength=g,M.numDirectionalShadows=y,M.numPointShadows=x,M.numSpotShadows=w,M.numSpotMaps=P,M.numLightProbes=A,n.version=oE++)}function l(c,d){let h=0,u=0,f=0,m=0,b=0;const p=d.matrixWorldInverse;for(let g=0,y=c.length;g<y;g++){const x=c[g];if(x.isDirectionalLight){const w=n.directional[h];w.direction.setFromMatrixPosition(x.matrixWorld),i.setFromMatrixPosition(x.target.matrixWorld),w.direction.sub(i),w.direction.transformDirection(p),h++}else if(x.isSpotLight){const w=n.spot[f];w.position.setFromMatrixPosition(x.matrixWorld),w.position.applyMatrix4(p),w.direction.setFromMatrixPosition(x.matrixWorld),i.setFromMatrixPosition(x.target.matrixWorld),w.direction.sub(i),w.direction.transformDirection(p),f++}else if(x.isRectAreaLight){const w=n.rectArea[m];w.position.setFromMatrixPosition(x.matrixWorld),w.position.applyMatrix4(p),a.identity(),s.copy(x.matrixWorld),s.premultiply(p),a.extractRotation(s),w.halfWidth.set(x.width*.5,0,0),w.halfHeight.set(0,x.height*.5,0),w.halfWidth.applyMatrix4(a),w.halfHeight.applyMatrix4(a),m++}else if(x.isPointLight){const w=n.point[u];w.position.setFromMatrixPosition(x.matrixWorld),w.position.applyMatrix4(p),u++}else if(x.isHemisphereLight){const w=n.hemi[b];w.direction.setFromMatrixPosition(x.matrixWorld),w.direction.transformDirection(p),b++}}}return{setup:o,setupView:l,state:n}}function sm(r){const e=new cE(r),t=[],n=[];function i(d){c.camera=d,t.length=0,n.length=0}function s(d){t.push(d)}function a(d){n.push(d)}function o(){e.setup(t)}function l(d){e.setupView(t,d)}const c={lightsArray:t,shadowsArray:n,camera:null,lights:e,transmissionRenderTarget:{}};return{init:i,state:c,setupLights:o,setupLightsView:l,pushLight:s,pushShadow:a}}function dE(r){let e=new WeakMap;function t(i,s=0){const a=e.get(i);let o;return a===void 0?(o=new sm(r),e.set(i,[o])):s>=a.length?(o=new sm(r),a.push(o)):o=a[s],o}function n(){e=new WeakMap}return{get:t,dispose:n}}const hE=`void main() {
|
|
3805
3805
|
gl_Position = vec4( position, 1.0 );
|
|
3806
3806
|
}`,uE=`uniform sampler2D shadow_pass;
|
|
3807
3807
|
uniform vec2 resolution;
|
|
@@ -3829,7 +3829,7 @@ void main() {
|
|
|
3829
3829
|
squared_mean = squared_mean / samples;
|
|
3830
3830
|
float std_dev = sqrt( squared_mean - mean * mean );
|
|
3831
3831
|
gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
|
|
3832
|
-
}`;function fE(r,e,t){let n=new No;const i=new me,s=new me,a=new _t,o=new Ub({depthPacking:vb}),l=new p_,c={},d=t.maxTextureSize,h={[Si]:fi,[fi]:Si,[ln]:ln},u=new wn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new me},radius:{value:4}},vertexShader:hE,fragmentShader:uE}),f=u.clone();f.defines.HORIZONTAL_PASS=1;const m=new ht;m.setAttribute("position",new rn(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const b=new Ee(m,u),p=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Qg;let g=this.type;this.render=function(T,A,M){if(p.enabled===!1||p.autoUpdate===!1&&p.needsUpdate===!1||T.length===0)return;const _=r.getRenderTarget(),S=r.getActiveCubeFace(),R=r.getActiveMipmapLevel(),k=r.state;k.setBlending(qi),k.buffers.color.setClear(1,1,1,1),k.buffers.depth.setTest(!0),k.setScissorTest(!1);const O=g!==vs&&this.type===vs,H=g===vs&&this.type!==vs;for(let q=0,G=T.length;q<G;q++){const K=T[q],V=K.shadow;if(V===void 0){console.warn("THREE.WebGLShadowMap:",K,"has no shadow.");continue}if(V.autoUpdate===!1&&V.needsUpdate===!1)continue;i.copy(V.mapSize);const Z=V.getFrameExtents();if(i.multiply(Z),s.copy(V.mapSize),(i.x>d||i.y>d)&&(i.x>d&&(s.x=Math.floor(d/Z.x),i.x=s.x*Z.x,V.mapSize.x=s.x),i.y>d&&(s.y=Math.floor(d/Z.y),i.y=s.y*Z.y,V.mapSize.y=s.y)),V.map===null||O===!0||H===!0){const se=this.type!==vs?{minFilter:Sn,magFilter:Sn}:{};V.map!==null&&V.map.dispose(),V.map=new ni(i.x,i.y,se),V.map.texture.name=K.name+".shadowMap",V.camera.updateProjectionMatrix()}r.setRenderTarget(V.map),r.clear();const le=V.getViewportCount();for(let se=0;se<le;se++){const ge=V.getViewport(se);a.set(s.x*ge.x,s.y*ge.y,s.x*ge.z,s.y*ge.w),k.viewport(a),V.updateMatrices(K,se),n=V.getFrustum(),w(A,M,V.camera,K,this.type)}V.isPointLightShadow!==!0&&this.type===vs&&y(V,M),V.needsUpdate=!1}g=this.type,p.needsUpdate=!1,r.setRenderTarget(_,S,R)};function y(T,A){const M=e.update(b);u.defines.VSM_SAMPLES!==T.blurSamples&&(u.defines.VSM_SAMPLES=T.blurSamples,f.defines.VSM_SAMPLES=T.blurSamples,u.needsUpdate=!0,f.needsUpdate=!0),T.mapPass===null&&(T.mapPass=new ni(i.x,i.y)),u.uniforms.shadow_pass.value=T.map.texture,u.uniforms.resolution.value=T.mapSize,u.uniforms.radius.value=T.radius,r.setRenderTarget(T.mapPass),r.clear(),r.renderBufferDirect(A,null,M,u,b,null),f.uniforms.shadow_pass.value=T.mapPass.texture,f.uniforms.resolution.value=T.mapSize,f.uniforms.radius.value=T.radius,r.setRenderTarget(T.map),r.clear(),r.renderBufferDirect(A,null,M,f,b,null)}function x(T,A,M,_){let S=null;const R=M.isPointLight===!0?T.customDistanceMaterial:T.customDepthMaterial;if(R!==void 0)S=R;else if(S=M.isPointLight===!0?l:o,r.localClippingEnabled&&A.clipShadows===!0&&Array.isArray(A.clippingPlanes)&&A.clippingPlanes.length!==0||A.displacementMap&&A.displacementScale!==0||A.alphaMap&&A.alphaTest>0||A.map&&A.alphaTest>0){const k=S.uuid,O=A.uuid;let H=c[k];H===void 0&&(H={},c[k]=H);let q=H[O];q===void 0&&(q=S.clone(),H[O]=q,A.addEventListener("dispose",P)),S=q}if(S.visible=A.visible,S.wireframe=A.wireframe,_===vs?S.side=A.shadowSide!==null?A.shadowSide:A.side:S.side=A.shadowSide!==null?A.shadowSide:h[A.side],S.alphaMap=A.alphaMap,S.alphaTest=A.alphaTest,S.map=A.map,S.clipShadows=A.clipShadows,S.clippingPlanes=A.clippingPlanes,S.clipIntersection=A.clipIntersection,S.displacementMap=A.displacementMap,S.displacementScale=A.displacementScale,S.displacementBias=A.displacementBias,S.wireframeLinewidth=A.wireframeLinewidth,S.linewidth=A.linewidth,M.isPointLight===!0&&S.isMeshDistanceMaterial===!0){const k=r.properties.get(S);k.light=M}return S}function w(T,A,M,_,S){if(T.visible===!1)return;if(T.layers.test(A.layers)&&(T.isMesh||T.isLine||T.isPoints)&&(T.castShadow||T.receiveShadow&&S===vs)&&(!T.frustumCulled||n.intersectsObject(T))){T.modelViewMatrix.multiplyMatrices(M.matrixWorldInverse,T.matrixWorld);const O=e.update(T),H=T.material;if(Array.isArray(H)){const q=O.groups;for(let G=0,K=q.length;G<K;G++){const V=q[G],Z=H[V.materialIndex];if(Z&&Z.visible){const le=x(T,Z,_,S);T.onBeforeShadow(r,T,A,M,O,le,V),r.renderBufferDirect(M,null,O,le,T,V),T.onAfterShadow(r,T,A,M,O,le,V)}}}else if(H.visible){const q=x(T,H,_,S);T.onBeforeShadow(r,T,A,M,O,q,null),r.renderBufferDirect(M,null,O,q,T,null),T.onAfterShadow(r,T,A,M,O,q,null)}}const k=T.children;for(let O=0,H=k.length;O<H;O++)w(k[O],A,M,_,S)}function P(T){T.target.removeEventListener("dispose",P);for(const M in c){const _=c[M],S=T.target.uuid;S in _&&(_[S].dispose(),delete _[S])}}}const pE={[Rh]:Nh,[Dh]:kh,[Lh]:Oh,[va]:Ih,[Nh]:Rh,[kh]:Dh,[Oh]:Lh,[Ih]:va};function mE(r,e){function t(){let Q=!1;const Ge=new _t;let ye=null;const Me=new _t(0,0,0,0);return{setMask:function(Ze){ye!==Ze&&!Q&&(r.colorMask(Ze,Ze,Ze,Ze),ye=Ze)},setLocked:function(Ze){Q=Ze},setClear:function(Ze,Xe,vt,Qt,An){An===!0&&(Ze*=Qt,Xe*=Qt,vt*=Qt),Ge.set(Ze,Xe,vt,Qt),Me.equals(Ge)===!1&&(r.clearColor(Ze,Xe,vt,Qt),Me.copy(Ge))},reset:function(){Q=!1,ye=null,Me.set(-1,0,0,0)}}}function n(){let Q=!1,Ge=!1,ye=null,Me=null,Ze=null;return{setReversed:function(Xe){if(Ge!==Xe){const vt=e.get("EXT_clip_control");Ge?vt.clipControlEXT(vt.LOWER_LEFT_EXT,vt.ZERO_TO_ONE_EXT):vt.clipControlEXT(vt.LOWER_LEFT_EXT,vt.NEGATIVE_ONE_TO_ONE_EXT);const Qt=Ze;Ze=null,this.setClear(Qt)}Ge=Xe},getReversed:function(){return Ge},setTest:function(Xe){Xe?Y(r.DEPTH_TEST):ue(r.DEPTH_TEST)},setMask:function(Xe){ye!==Xe&&!Q&&(r.depthMask(Xe),ye=Xe)},setFunc:function(Xe){if(Ge&&(Xe=pE[Xe]),Me!==Xe){switch(Xe){case Rh:r.depthFunc(r.NEVER);break;case Nh:r.depthFunc(r.ALWAYS);break;case Dh:r.depthFunc(r.LESS);break;case va:r.depthFunc(r.LEQUAL);break;case Lh:r.depthFunc(r.EQUAL);break;case Ih:r.depthFunc(r.GEQUAL);break;case kh:r.depthFunc(r.GREATER);break;case Oh:r.depthFunc(r.NOTEQUAL);break;default:r.depthFunc(r.LEQUAL)}Me=Xe}},setLocked:function(Xe){Q=Xe},setClear:function(Xe){Ze!==Xe&&(Ge&&(Xe=1-Xe),r.clearDepth(Xe),Ze=Xe)},reset:function(){Q=!1,ye=null,Me=null,Ze=null,Ge=!1}}}function i(){let Q=!1,Ge=null,ye=null,Me=null,Ze=null,Xe=null,vt=null,Qt=null,An=null;return{setTest:function(wt){Q||(wt?Y(r.STENCIL_TEST):ue(r.STENCIL_TEST))},setMask:function(wt){Ge!==wt&&!Q&&(r.stencilMask(wt),Ge=wt)},setFunc:function(wt,si,Fi){(ye!==wt||Me!==si||Ze!==Fi)&&(r.stencilFunc(wt,si,Fi),ye=wt,Me=si,Ze=Fi)},setOp:function(wt,si,Fi){(Xe!==wt||vt!==si||Qt!==Fi)&&(r.stencilOp(wt,si,Fi),Xe=wt,vt=si,Qt=Fi)},setLocked:function(wt){Q=wt},setClear:function(wt){An!==wt&&(r.clearStencil(wt),An=wt)},reset:function(){Q=!1,Ge=null,ye=null,Me=null,Ze=null,Xe=null,vt=null,Qt=null,An=null}}}const s=new t,a=new n,o=new i,l=new WeakMap,c=new WeakMap;let d={},h={},u=new WeakMap,f=[],m=null,b=!1,p=null,g=null,y=null,x=null,w=null,P=null,T=null,A=new Ne(0,0,0),M=0,_=!1,S=null,R=null,k=null,O=null,H=null;const q=r.getParameter(r.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let G=!1,K=0;const V=r.getParameter(r.VERSION);V.indexOf("WebGL")!==-1?(K=parseFloat(/^WebGL (\d)/.exec(V)[1]),G=K>=1):V.indexOf("OpenGL ES")!==-1&&(K=parseFloat(/^OpenGL ES (\d)/.exec(V)[1]),G=K>=2);let Z=null,le={};const se=r.getParameter(r.SCISSOR_BOX),ge=r.getParameter(r.VIEWPORT),de=new _t().fromArray(se),X=new _t().fromArray(ge);function ee(Q,Ge,ye,Me){const Ze=new Uint8Array(4),Xe=r.createTexture();r.bindTexture(Q,Xe),r.texParameteri(Q,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(Q,r.TEXTURE_MAG_FILTER,r.NEAREST);for(let vt=0;vt<ye;vt++)Q===r.TEXTURE_3D||Q===r.TEXTURE_2D_ARRAY?r.texImage3D(Ge,0,r.RGBA,1,1,Me,0,r.RGBA,r.UNSIGNED_BYTE,Ze):r.texImage2D(Ge+vt,0,r.RGBA,1,1,0,r.RGBA,r.UNSIGNED_BYTE,Ze);return Xe}const ie={};ie[r.TEXTURE_2D]=ee(r.TEXTURE_2D,r.TEXTURE_2D,1),ie[r.TEXTURE_CUBE_MAP]=ee(r.TEXTURE_CUBE_MAP,r.TEXTURE_CUBE_MAP_POSITIVE_X,6),ie[r.TEXTURE_2D_ARRAY]=ee(r.TEXTURE_2D_ARRAY,r.TEXTURE_2D_ARRAY,1,1),ie[r.TEXTURE_3D]=ee(r.TEXTURE_3D,r.TEXTURE_3D,1,1),s.setClear(0,0,0,1),a.setClear(1),o.setClear(0),Y(r.DEPTH_TEST),a.setFunc(va),Ue(!1),Te(Ef),Y(r.CULL_FACE),j(qi);function Y(Q){d[Q]!==!0&&(r.enable(Q),d[Q]=!0)}function ue(Q){d[Q]!==!1&&(r.disable(Q),d[Q]=!1)}function oe(Q,Ge){return h[Q]!==Ge?(r.bindFramebuffer(Q,Ge),h[Q]=Ge,Q===r.DRAW_FRAMEBUFFER&&(h[r.FRAMEBUFFER]=Ge),Q===r.FRAMEBUFFER&&(h[r.DRAW_FRAMEBUFFER]=Ge),!0):!1}function be(Q,Ge){let ye=f,Me=!1;if(Q){ye=u.get(Ge),ye===void 0&&(ye=[],u.set(Ge,ye));const Ze=Q.textures;if(ye.length!==Ze.length||ye[0]!==r.COLOR_ATTACHMENT0){for(let Xe=0,vt=Ze.length;Xe<vt;Xe++)ye[Xe]=r.COLOR_ATTACHMENT0+Xe;ye.length=Ze.length,Me=!0}}else ye[0]!==r.BACK&&(ye[0]=r.BACK,Me=!0);Me&&r.drawBuffers(ye)}function Ce(Q){return m!==Q?(r.useProgram(Q),m=Q,!0):!1}const je={[pr]:r.FUNC_ADD,[nx]:r.FUNC_SUBTRACT,[ix]:r.FUNC_REVERSE_SUBTRACT};je[sx]=r.MIN,je[rx]=r.MAX;const Fe={[ax]:r.ZERO,[ox]:r.ONE,[lx]:r.SRC_COLOR,[Ch]:r.SRC_ALPHA,[px]:r.SRC_ALPHA_SATURATE,[ux]:r.DST_COLOR,[dx]:r.DST_ALPHA,[cx]:r.ONE_MINUS_SRC_COLOR,[Ph]:r.ONE_MINUS_SRC_ALPHA,[fx]:r.ONE_MINUS_DST_COLOR,[hx]:r.ONE_MINUS_DST_ALPHA,[mx]:r.CONSTANT_COLOR,[gx]:r.ONE_MINUS_CONSTANT_COLOR,[bx]:r.CONSTANT_ALPHA,[vx]:r.ONE_MINUS_CONSTANT_ALPHA};function j(Q,Ge,ye,Me,Ze,Xe,vt,Qt,An,wt){if(Q===qi){b===!0&&(ue(r.BLEND),b=!1);return}if(b===!1&&(Y(r.BLEND),b=!0),Q!==tx){if(Q!==p||wt!==_){if((g!==pr||w!==pr)&&(r.blendEquation(r.FUNC_ADD),g=pr,w=pr),wt)switch(Q){case da:r.blendFuncSeparate(r.ONE,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA);break;case Ah:r.blendFunc(r.ONE,r.ONE);break;case Af:r.blendFuncSeparate(r.ZERO,r.ONE_MINUS_SRC_COLOR,r.ZERO,r.ONE);break;case Cf:r.blendFuncSeparate(r.ZERO,r.SRC_COLOR,r.ZERO,r.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",Q);break}else switch(Q){case da:r.blendFuncSeparate(r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA);break;case Ah:r.blendFunc(r.SRC_ALPHA,r.ONE);break;case Af:r.blendFuncSeparate(r.ZERO,r.ONE_MINUS_SRC_COLOR,r.ZERO,r.ONE);break;case Cf:r.blendFunc(r.ZERO,r.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",Q);break}y=null,x=null,P=null,T=null,A.set(0,0,0),M=0,p=Q,_=wt}return}Ze=Ze||Ge,Xe=Xe||ye,vt=vt||Me,(Ge!==g||Ze!==w)&&(r.blendEquationSeparate(je[Ge],je[Ze]),g=Ge,w=Ze),(ye!==y||Me!==x||Xe!==P||vt!==T)&&(r.blendFuncSeparate(Fe[ye],Fe[Me],Fe[Xe],Fe[vt]),y=ye,x=Me,P=Xe,T=vt),(Qt.equals(A)===!1||An!==M)&&(r.blendColor(Qt.r,Qt.g,Qt.b,An),A.copy(Qt),M=An),p=Q,_=!1}function Ke(Q,Ge){Q.side===ln?ue(r.CULL_FACE):Y(r.CULL_FACE);let ye=Q.side===fi;Ge&&(ye=!ye),Ue(ye),Q.blending===da&&Q.transparent===!1?j(qi):j(Q.blending,Q.blendEquation,Q.blendSrc,Q.blendDst,Q.blendEquationAlpha,Q.blendSrcAlpha,Q.blendDstAlpha,Q.blendColor,Q.blendAlpha,Q.premultipliedAlpha),a.setFunc(Q.depthFunc),a.setTest(Q.depthTest),a.setMask(Q.depthWrite),s.setMask(Q.colorWrite);const Me=Q.stencilWrite;o.setTest(Me),Me&&(o.setMask(Q.stencilWriteMask),o.setFunc(Q.stencilFunc,Q.stencilRef,Q.stencilFuncMask),o.setOp(Q.stencilFail,Q.stencilZFail,Q.stencilZPass)),et(Q.polygonOffset,Q.polygonOffsetFactor,Q.polygonOffsetUnits),Q.alphaToCoverage===!0?Y(r.SAMPLE_ALPHA_TO_COVERAGE):ue(r.SAMPLE_ALPHA_TO_COVERAGE)}function Ue(Q){S!==Q&&(Q?r.frontFace(r.CW):r.frontFace(r.CCW),S=Q)}function Te(Q){Q!==Qy?(Y(r.CULL_FACE),Q!==R&&(Q===Ef?r.cullFace(r.BACK):Q===Jy?r.cullFace(r.FRONT):r.cullFace(r.FRONT_AND_BACK))):ue(r.CULL_FACE),R=Q}function Se(Q){Q!==k&&(G&&r.lineWidth(Q),k=Q)}function et(Q,Ge,ye){Q?(Y(r.POLYGON_OFFSET_FILL),(O!==Ge||H!==ye)&&(r.polygonOffset(Ge,ye),O=Ge,H=ye)):ue(r.POLYGON_OFFSET_FILL)}function Be(Q){Q?Y(r.SCISSOR_TEST):ue(r.SCISSOR_TEST)}function N(Q){Q===void 0&&(Q=r.TEXTURE0+q-1),Z!==Q&&(r.activeTexture(Q),Z=Q)}function E(Q,Ge,ye){ye===void 0&&(Z===null?ye=r.TEXTURE0+q-1:ye=Z);let Me=le[ye];Me===void 0&&(Me={type:void 0,texture:void 0},le[ye]=Me),(Me.type!==Q||Me.texture!==Ge)&&(Z!==ye&&(r.activeTexture(ye),Z=ye),r.bindTexture(Q,Ge||ie[Q]),Me.type=Q,Me.texture=Ge)}function W(){const Q=le[Z];Q!==void 0&&Q.type!==void 0&&(r.bindTexture(Q.type,null),Q.type=void 0,Q.texture=void 0)}function ae(){try{r.compressedTexImage2D(...arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function ve(){try{r.compressedTexImage3D(...arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function ce(){try{r.texSubImage2D(...arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function Oe(){try{r.texSubImage3D(...arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function Pe(){try{r.compressedTexSubImage2D(...arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function Ve(){try{r.compressedTexSubImage3D(...arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function te(){try{r.texStorage2D(...arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function re(){try{r.texStorage3D(...arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function De(){try{r.texImage2D(...arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function Ye(){try{r.texImage3D(...arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function xe(Q){de.equals(Q)===!1&&(r.scissor(Q.x,Q.y,Q.z,Q.w),de.copy(Q))}function Le(Q){X.equals(Q)===!1&&(r.viewport(Q.x,Q.y,Q.z,Q.w),X.copy(Q))}function ct(Q,Ge){let ye=c.get(Ge);ye===void 0&&(ye=new WeakMap,c.set(Ge,ye));let Me=ye.get(Q);Me===void 0&&(Me=r.getUniformBlockIndex(Ge,Q.name),ye.set(Q,Me))}function rt(Q,Ge){const Me=c.get(Ge).get(Q);l.get(Ge)!==Me&&(r.uniformBlockBinding(Ge,Me,Q.__bindingPointIndex),l.set(Ge,Me))}function Rt(){r.disable(r.BLEND),r.disable(r.CULL_FACE),r.disable(r.DEPTH_TEST),r.disable(r.POLYGON_OFFSET_FILL),r.disable(r.SCISSOR_TEST),r.disable(r.STENCIL_TEST),r.disable(r.SAMPLE_ALPHA_TO_COVERAGE),r.blendEquation(r.FUNC_ADD),r.blendFunc(r.ONE,r.ZERO),r.blendFuncSeparate(r.ONE,r.ZERO,r.ONE,r.ZERO),r.blendColor(0,0,0,0),r.colorMask(!0,!0,!0,!0),r.clearColor(0,0,0,0),r.depthMask(!0),r.depthFunc(r.LESS),a.setReversed(!1),r.clearDepth(1),r.stencilMask(4294967295),r.stencilFunc(r.ALWAYS,0,4294967295),r.stencilOp(r.KEEP,r.KEEP,r.KEEP),r.clearStencil(0),r.cullFace(r.BACK),r.frontFace(r.CCW),r.polygonOffset(0,0),r.activeTexture(r.TEXTURE0),r.bindFramebuffer(r.FRAMEBUFFER,null),r.bindFramebuffer(r.DRAW_FRAMEBUFFER,null),r.bindFramebuffer(r.READ_FRAMEBUFFER,null),r.useProgram(null),r.lineWidth(1),r.scissor(0,0,r.canvas.width,r.canvas.height),r.viewport(0,0,r.canvas.width,r.canvas.height),d={},Z=null,le={},h={},u=new WeakMap,f=[],m=null,b=!1,p=null,g=null,y=null,x=null,w=null,P=null,T=null,A=new Ne(0,0,0),M=0,_=!1,S=null,R=null,k=null,O=null,H=null,de.set(0,0,r.canvas.width,r.canvas.height),X.set(0,0,r.canvas.width,r.canvas.height),s.reset(),a.reset(),o.reset()}return{buffers:{color:s,depth:a,stencil:o},enable:Y,disable:ue,bindFramebuffer:oe,drawBuffers:be,useProgram:Ce,setBlending:j,setMaterial:Ke,setFlipSided:Ue,setCullFace:Te,setLineWidth:Se,setPolygonOffset:et,setScissorTest:Be,activeTexture:N,bindTexture:E,unbindTexture:W,compressedTexImage2D:ae,compressedTexImage3D:ve,texImage2D:De,texImage3D:Ye,updateUBOMapping:ct,uniformBlockBinding:rt,texStorage2D:te,texStorage3D:re,texSubImage2D:ce,texSubImage3D:Oe,compressedTexSubImage2D:Pe,compressedTexSubImage3D:Ve,scissor:xe,viewport:Le,reset:Rt}}function gE(r,e,t,n,i,s,a){const 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 me,d=new WeakMap;let h;const u=new WeakMap;let f=!1;try{f=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function m(N,E){return f?new OffscreenCanvas(N,E):xo("canvas")}function b(N,E,W){let ae=1;const ve=Be(N);if((ve.width>W||ve.height>W)&&(ae=W/Math.max(ve.width,ve.height)),ae<1)if(typeof HTMLImageElement<"u"&&N instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&N instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&N instanceof ImageBitmap||typeof VideoFrame<"u"&&N instanceof VideoFrame){const ce=Math.floor(ae*ve.width),Oe=Math.floor(ae*ve.height);h===void 0&&(h=m(ce,Oe));const Pe=E?m(ce,Oe):h;return Pe.width=ce,Pe.height=Oe,Pe.getContext("2d").drawImage(N,0,0,ce,Oe),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+ve.width+"x"+ve.height+") to ("+ce+"x"+Oe+")."),Pe}else return"data"in N&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+ve.width+"x"+ve.height+")."),N;return N}function p(N){return N.generateMipmaps}function g(N){r.generateMipmap(N)}function y(N){return N.isWebGLCubeRenderTarget?r.TEXTURE_CUBE_MAP:N.isWebGL3DRenderTarget?r.TEXTURE_3D:N.isWebGLArrayRenderTarget||N.isCompressedArrayTexture?r.TEXTURE_2D_ARRAY:r.TEXTURE_2D}function x(N,E,W,ae,ve=!1){if(N!==null){if(r[N]!==void 0)return r[N];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+N+"'")}let ce=E;if(E===r.RED&&(W===r.FLOAT&&(ce=r.R32F),W===r.HALF_FLOAT&&(ce=r.R16F),W===r.UNSIGNED_BYTE&&(ce=r.R8)),E===r.RED_INTEGER&&(W===r.UNSIGNED_BYTE&&(ce=r.R8UI),W===r.UNSIGNED_SHORT&&(ce=r.R16UI),W===r.UNSIGNED_INT&&(ce=r.R32UI),W===r.BYTE&&(ce=r.R8I),W===r.SHORT&&(ce=r.R16I),W===r.INT&&(ce=r.R32I)),E===r.RG&&(W===r.FLOAT&&(ce=r.RG32F),W===r.HALF_FLOAT&&(ce=r.RG16F),W===r.UNSIGNED_BYTE&&(ce=r.RG8)),E===r.RG_INTEGER&&(W===r.UNSIGNED_BYTE&&(ce=r.RG8UI),W===r.UNSIGNED_SHORT&&(ce=r.RG16UI),W===r.UNSIGNED_INT&&(ce=r.RG32UI),W===r.BYTE&&(ce=r.RG8I),W===r.SHORT&&(ce=r.RG16I),W===r.INT&&(ce=r.RG32I)),E===r.RGB_INTEGER&&(W===r.UNSIGNED_BYTE&&(ce=r.RGB8UI),W===r.UNSIGNED_SHORT&&(ce=r.RGB16UI),W===r.UNSIGNED_INT&&(ce=r.RGB32UI),W===r.BYTE&&(ce=r.RGB8I),W===r.SHORT&&(ce=r.RGB16I),W===r.INT&&(ce=r.RGB32I)),E===r.RGBA_INTEGER&&(W===r.UNSIGNED_BYTE&&(ce=r.RGBA8UI),W===r.UNSIGNED_SHORT&&(ce=r.RGBA16UI),W===r.UNSIGNED_INT&&(ce=r.RGBA32UI),W===r.BYTE&&(ce=r.RGBA8I),W===r.SHORT&&(ce=r.RGBA16I),W===r.INT&&(ce=r.RGBA32I)),E===r.RGB&&W===r.UNSIGNED_INT_5_9_9_9_REV&&(ce=r.RGB9_E5),E===r.RGBA){const Oe=ve?xc:ft.getTransfer(ae);W===r.FLOAT&&(ce=r.RGBA32F),W===r.HALF_FLOAT&&(ce=r.RGBA16F),W===r.UNSIGNED_BYTE&&(ce=Oe===Ht?r.SRGB8_ALPHA8:r.RGBA8),W===r.UNSIGNED_SHORT_4_4_4_4&&(ce=r.RGBA4),W===r.UNSIGNED_SHORT_5_5_5_1&&(ce=r.RGB5_A1)}return(ce===r.R16F||ce===r.R32F||ce===r.RG16F||ce===r.RG32F||ce===r.RGBA16F||ce===r.RGBA32F)&&e.get("EXT_color_buffer_float"),ce}function w(N,E){let W;return N?E===null||E===Zs||E===_a?W=r.DEPTH24_STENCIL8:E===_i?W=r.DEPTH32F_STENCIL8:E===bo&&(W=r.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):E===null||E===Zs||E===_a?W=r.DEPTH_COMPONENT24:E===_i?W=r.DEPTH_COMPONENT32F:E===bo&&(W=r.DEPTH_COMPONENT16),W}function P(N,E){return p(N)===!0||N.isFramebufferTexture&&N.minFilter!==Sn&&N.minFilter!==bn?Math.log2(Math.max(E.width,E.height))+1:N.mipmaps!==void 0&&N.mipmaps.length>0?N.mipmaps.length:N.isCompressedTexture&&Array.isArray(N.image)?E.mipmaps.length:1}function T(N){const E=N.target;E.removeEventListener("dispose",T),M(E),E.isVideoTexture&&d.delete(E)}function A(N){const E=N.target;E.removeEventListener("dispose",A),S(E)}function M(N){const E=n.get(N);if(E.__webglInit===void 0)return;const W=N.source,ae=u.get(W);if(ae){const ve=ae[E.__cacheKey];ve.usedTimes--,ve.usedTimes===0&&_(N),Object.keys(ae).length===0&&u.delete(W)}n.remove(N)}function _(N){const E=n.get(N);r.deleteTexture(E.__webglTexture);const W=N.source,ae=u.get(W);delete ae[E.__cacheKey],a.memory.textures--}function S(N){const E=n.get(N);if(N.depthTexture&&(N.depthTexture.dispose(),n.remove(N.depthTexture)),N.isWebGLCubeRenderTarget)for(let ae=0;ae<6;ae++){if(Array.isArray(E.__webglFramebuffer[ae]))for(let ve=0;ve<E.__webglFramebuffer[ae].length;ve++)r.deleteFramebuffer(E.__webglFramebuffer[ae][ve]);else r.deleteFramebuffer(E.__webglFramebuffer[ae]);E.__webglDepthbuffer&&r.deleteRenderbuffer(E.__webglDepthbuffer[ae])}else{if(Array.isArray(E.__webglFramebuffer))for(let ae=0;ae<E.__webglFramebuffer.length;ae++)r.deleteFramebuffer(E.__webglFramebuffer[ae]);else r.deleteFramebuffer(E.__webglFramebuffer);if(E.__webglDepthbuffer&&r.deleteRenderbuffer(E.__webglDepthbuffer),E.__webglMultisampledFramebuffer&&r.deleteFramebuffer(E.__webglMultisampledFramebuffer),E.__webglColorRenderbuffer)for(let ae=0;ae<E.__webglColorRenderbuffer.length;ae++)E.__webglColorRenderbuffer[ae]&&r.deleteRenderbuffer(E.__webglColorRenderbuffer[ae]);E.__webglDepthRenderbuffer&&r.deleteRenderbuffer(E.__webglDepthRenderbuffer)}const W=N.textures;for(let ae=0,ve=W.length;ae<ve;ae++){const ce=n.get(W[ae]);ce.__webglTexture&&(r.deleteTexture(ce.__webglTexture),a.memory.textures--),n.remove(W[ae])}n.remove(N)}let R=0;function k(){R=0}function O(){const N=R;return N>=i.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+N+" texture units while this GPU supports only "+i.maxTextures),R+=1,N}function H(N){const E=[];return E.push(N.wrapS),E.push(N.wrapT),E.push(N.wrapR||0),E.push(N.magFilter),E.push(N.minFilter),E.push(N.anisotropy),E.push(N.internalFormat),E.push(N.format),E.push(N.type),E.push(N.generateMipmaps),E.push(N.premultiplyAlpha),E.push(N.flipY),E.push(N.unpackAlignment),E.push(N.colorSpace),E.join()}function q(N,E){const W=n.get(N);if(N.isVideoTexture&&Se(N),N.isRenderTargetTexture===!1&&N.version>0&&W.__version!==N.version){const ae=N.image;if(ae===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(ae.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{X(W,N,E);return}}t.bindTexture(r.TEXTURE_2D,W.__webglTexture,r.TEXTURE0+E)}function G(N,E){const W=n.get(N);if(N.version>0&&W.__version!==N.version){X(W,N,E);return}t.bindTexture(r.TEXTURE_2D_ARRAY,W.__webglTexture,r.TEXTURE0+E)}function K(N,E){const W=n.get(N);if(N.version>0&&W.__version!==N.version){X(W,N,E);return}t.bindTexture(r.TEXTURE_3D,W.__webglTexture,r.TEXTURE0+E)}function V(N,E){const W=n.get(N);if(N.version>0&&W.__version!==N.version){ee(W,N,E);return}t.bindTexture(r.TEXTURE_CUBE_MAP,W.__webglTexture,r.TEXTURE0+E)}const Z={[Li]:r.REPEAT,[ui]:r.CLAMP_TO_EDGE,[yc]:r.MIRRORED_REPEAT},le={[Sn]:r.NEAREST,[ob]:r.NEAREST_MIPMAP_NEAREST,[ro]:r.NEAREST_MIPMAP_LINEAR,[bn]:r.LINEAR,[oc]:r.LINEAR_MIPMAP_NEAREST,[ji]:r.LINEAR_MIPMAP_LINEAR},se={[Ex]:r.NEVER,[Dx]:r.ALWAYS,[Ax]:r.LESS,[yb]:r.LEQUAL,[Cx]:r.EQUAL,[Nx]:r.GEQUAL,[Px]:r.GREATER,[Rx]:r.NOTEQUAL};function ge(N,E){if(E.type===_i&&e.has("OES_texture_float_linear")===!1&&(E.magFilter===bn||E.magFilter===oc||E.magFilter===ro||E.magFilter===ji||E.minFilter===bn||E.minFilter===oc||E.minFilter===ro||E.minFilter===ji)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),r.texParameteri(N,r.TEXTURE_WRAP_S,Z[E.wrapS]),r.texParameteri(N,r.TEXTURE_WRAP_T,Z[E.wrapT]),(N===r.TEXTURE_3D||N===r.TEXTURE_2D_ARRAY)&&r.texParameteri(N,r.TEXTURE_WRAP_R,Z[E.wrapR]),r.texParameteri(N,r.TEXTURE_MAG_FILTER,le[E.magFilter]),r.texParameteri(N,r.TEXTURE_MIN_FILTER,le[E.minFilter]),E.compareFunction&&(r.texParameteri(N,r.TEXTURE_COMPARE_MODE,r.COMPARE_REF_TO_TEXTURE),r.texParameteri(N,r.TEXTURE_COMPARE_FUNC,se[E.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(E.magFilter===Sn||E.minFilter!==ro&&E.minFilter!==ji||E.type===_i&&e.has("OES_texture_float_linear")===!1)return;if(E.anisotropy>1||n.get(E).__currentAnisotropy){const W=e.get("EXT_texture_filter_anisotropic");r.texParameterf(N,W.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(E.anisotropy,i.getMaxAnisotropy())),n.get(E).__currentAnisotropy=E.anisotropy}}}function de(N,E){let W=!1;N.__webglInit===void 0&&(N.__webglInit=!0,E.addEventListener("dispose",T));const ae=E.source;let ve=u.get(ae);ve===void 0&&(ve={},u.set(ae,ve));const ce=H(E);if(ce!==N.__cacheKey){ve[ce]===void 0&&(ve[ce]={texture:r.createTexture(),usedTimes:0},a.memory.textures++,W=!0),ve[ce].usedTimes++;const Oe=ve[N.__cacheKey];Oe!==void 0&&(ve[N.__cacheKey].usedTimes--,Oe.usedTimes===0&&_(E)),N.__cacheKey=ce,N.__webglTexture=ve[ce].texture}return W}function X(N,E,W){let ae=r.TEXTURE_2D;(E.isDataArrayTexture||E.isCompressedArrayTexture)&&(ae=r.TEXTURE_2D_ARRAY),E.isData3DTexture&&(ae=r.TEXTURE_3D);const ve=de(N,E),ce=E.source;t.bindTexture(ae,N.__webglTexture,r.TEXTURE0+W);const Oe=n.get(ce);if(ce.version!==Oe.__version||ve===!0){t.activeTexture(r.TEXTURE0+W);const Pe=ft.getPrimaries(ft.workingColorSpace),Ve=E.colorSpace===zs?null:ft.getPrimaries(E.colorSpace),te=E.colorSpace===zs||Pe===Ve?r.NONE:r.BROWSER_DEFAULT_WEBGL;r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,E.flipY),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,E.premultiplyAlpha),r.pixelStorei(r.UNPACK_ALIGNMENT,E.unpackAlignment),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,te);let re=b(E.image,!1,i.maxTextureSize);re=et(E,re);const De=s.convert(E.format,E.colorSpace),Ye=s.convert(E.type);let xe=x(E.internalFormat,De,Ye,E.colorSpace,E.isVideoTexture);ge(ae,E);let Le;const ct=E.mipmaps,rt=E.isVideoTexture!==!0,Rt=Oe.__version===void 0||ve===!0,Q=ce.dataReady,Ge=P(E,re);if(E.isDepthTexture)xe=w(E.format===wa,E.type),Rt&&(rt?t.texStorage2D(r.TEXTURE_2D,1,xe,re.width,re.height):t.texImage2D(r.TEXTURE_2D,0,xe,re.width,re.height,0,De,Ye,null));else if(E.isDataTexture)if(ct.length>0){rt&&Rt&&t.texStorage2D(r.TEXTURE_2D,Ge,xe,ct[0].width,ct[0].height);for(let ye=0,Me=ct.length;ye<Me;ye++)Le=ct[ye],rt?Q&&t.texSubImage2D(r.TEXTURE_2D,ye,0,0,Le.width,Le.height,De,Ye,Le.data):t.texImage2D(r.TEXTURE_2D,ye,xe,Le.width,Le.height,0,De,Ye,Le.data);E.generateMipmaps=!1}else rt?(Rt&&t.texStorage2D(r.TEXTURE_2D,Ge,xe,re.width,re.height),Q&&t.texSubImage2D(r.TEXTURE_2D,0,0,0,re.width,re.height,De,Ye,re.data)):t.texImage2D(r.TEXTURE_2D,0,xe,re.width,re.height,0,De,Ye,re.data);else if(E.isCompressedTexture)if(E.isCompressedArrayTexture){rt&&Rt&&t.texStorage3D(r.TEXTURE_2D_ARRAY,Ge,xe,ct[0].width,ct[0].height,re.depth);for(let ye=0,Me=ct.length;ye<Me;ye++)if(Le=ct[ye],E.format!==Dn)if(De!==null)if(rt){if(Q)if(E.layerUpdates.size>0){const Ze=Ip(Le.width,Le.height,E.format,E.type);for(const Xe of E.layerUpdates){const vt=Le.data.subarray(Xe*Ze/Le.data.BYTES_PER_ELEMENT,(Xe+1)*Ze/Le.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(r.TEXTURE_2D_ARRAY,ye,0,0,Xe,Le.width,Le.height,1,De,vt)}E.clearLayerUpdates()}else t.compressedTexSubImage3D(r.TEXTURE_2D_ARRAY,ye,0,0,0,Le.width,Le.height,re.depth,De,Le.data)}else t.compressedTexImage3D(r.TEXTURE_2D_ARRAY,ye,xe,Le.width,Le.height,re.depth,0,Le.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else rt?Q&&t.texSubImage3D(r.TEXTURE_2D_ARRAY,ye,0,0,0,Le.width,Le.height,re.depth,De,Ye,Le.data):t.texImage3D(r.TEXTURE_2D_ARRAY,ye,xe,Le.width,Le.height,re.depth,0,De,Ye,Le.data)}else{rt&&Rt&&t.texStorage2D(r.TEXTURE_2D,Ge,xe,ct[0].width,ct[0].height);for(let ye=0,Me=ct.length;ye<Me;ye++)Le=ct[ye],E.format!==Dn?De!==null?rt?Q&&t.compressedTexSubImage2D(r.TEXTURE_2D,ye,0,0,Le.width,Le.height,De,Le.data):t.compressedTexImage2D(r.TEXTURE_2D,ye,xe,Le.width,Le.height,0,Le.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):rt?Q&&t.texSubImage2D(r.TEXTURE_2D,ye,0,0,Le.width,Le.height,De,Ye,Le.data):t.texImage2D(r.TEXTURE_2D,ye,xe,Le.width,Le.height,0,De,Ye,Le.data)}else if(E.isDataArrayTexture)if(rt){if(Rt&&t.texStorage3D(r.TEXTURE_2D_ARRAY,Ge,xe,re.width,re.height,re.depth),Q)if(E.layerUpdates.size>0){const ye=Ip(re.width,re.height,E.format,E.type);for(const Me of E.layerUpdates){const Ze=re.data.subarray(Me*ye/re.data.BYTES_PER_ELEMENT,(Me+1)*ye/re.data.BYTES_PER_ELEMENT);t.texSubImage3D(r.TEXTURE_2D_ARRAY,0,0,0,Me,re.width,re.height,1,De,Ye,Ze)}E.clearLayerUpdates()}else t.texSubImage3D(r.TEXTURE_2D_ARRAY,0,0,0,0,re.width,re.height,re.depth,De,Ye,re.data)}else t.texImage3D(r.TEXTURE_2D_ARRAY,0,xe,re.width,re.height,re.depth,0,De,Ye,re.data);else if(E.isData3DTexture)rt?(Rt&&t.texStorage3D(r.TEXTURE_3D,Ge,xe,re.width,re.height,re.depth),Q&&t.texSubImage3D(r.TEXTURE_3D,0,0,0,0,re.width,re.height,re.depth,De,Ye,re.data)):t.texImage3D(r.TEXTURE_3D,0,xe,re.width,re.height,re.depth,0,De,Ye,re.data);else if(E.isFramebufferTexture){if(Rt)if(rt)t.texStorage2D(r.TEXTURE_2D,Ge,xe,re.width,re.height);else{let ye=re.width,Me=re.height;for(let Ze=0;Ze<Ge;Ze++)t.texImage2D(r.TEXTURE_2D,Ze,xe,ye,Me,0,De,Ye,null),ye>>=1,Me>>=1}}else if(ct.length>0){if(rt&&Rt){const ye=Be(ct[0]);t.texStorage2D(r.TEXTURE_2D,Ge,xe,ye.width,ye.height)}for(let ye=0,Me=ct.length;ye<Me;ye++)Le=ct[ye],rt?Q&&t.texSubImage2D(r.TEXTURE_2D,ye,0,0,De,Ye,Le):t.texImage2D(r.TEXTURE_2D,ye,xe,De,Ye,Le);E.generateMipmaps=!1}else if(rt){if(Rt){const ye=Be(re);t.texStorage2D(r.TEXTURE_2D,Ge,xe,ye.width,ye.height)}Q&&t.texSubImage2D(r.TEXTURE_2D,0,0,0,De,Ye,re)}else t.texImage2D(r.TEXTURE_2D,0,xe,De,Ye,re);p(E)&&g(ae),Oe.__version=ce.version,E.onUpdate&&E.onUpdate(E)}N.__version=E.version}function ee(N,E,W){if(E.image.length!==6)return;const ae=de(N,E),ve=E.source;t.bindTexture(r.TEXTURE_CUBE_MAP,N.__webglTexture,r.TEXTURE0+W);const ce=n.get(ve);if(ve.version!==ce.__version||ae===!0){t.activeTexture(r.TEXTURE0+W);const Oe=ft.getPrimaries(ft.workingColorSpace),Pe=E.colorSpace===zs?null:ft.getPrimaries(E.colorSpace),Ve=E.colorSpace===zs||Oe===Pe?r.NONE:r.BROWSER_DEFAULT_WEBGL;r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,E.flipY),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,E.premultiplyAlpha),r.pixelStorei(r.UNPACK_ALIGNMENT,E.unpackAlignment),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ve);const te=E.isCompressedTexture||E.image[0].isCompressedTexture,re=E.image[0]&&E.image[0].isDataTexture,De=[];for(let Me=0;Me<6;Me++)!te&&!re?De[Me]=b(E.image[Me],!0,i.maxCubemapSize):De[Me]=re?E.image[Me].image:E.image[Me],De[Me]=et(E,De[Me]);const Ye=De[0],xe=s.convert(E.format,E.colorSpace),Le=s.convert(E.type),ct=x(E.internalFormat,xe,Le,E.colorSpace),rt=E.isVideoTexture!==!0,Rt=ce.__version===void 0||ae===!0,Q=ve.dataReady;let Ge=P(E,Ye);ge(r.TEXTURE_CUBE_MAP,E);let ye;if(te){rt&&Rt&&t.texStorage2D(r.TEXTURE_CUBE_MAP,Ge,ct,Ye.width,Ye.height);for(let Me=0;Me<6;Me++){ye=De[Me].mipmaps;for(let Ze=0;Ze<ye.length;Ze++){const Xe=ye[Ze];E.format!==Dn?xe!==null?rt?Q&&t.compressedTexSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Me,Ze,0,0,Xe.width,Xe.height,xe,Xe.data):t.compressedTexImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Me,Ze,ct,Xe.width,Xe.height,0,Xe.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):rt?Q&&t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Me,Ze,0,0,Xe.width,Xe.height,xe,Le,Xe.data):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Me,Ze,ct,Xe.width,Xe.height,0,xe,Le,Xe.data)}}}else{if(ye=E.mipmaps,rt&&Rt){ye.length>0&&Ge++;const Me=Be(De[0]);t.texStorage2D(r.TEXTURE_CUBE_MAP,Ge,ct,Me.width,Me.height)}for(let Me=0;Me<6;Me++)if(re){rt?Q&&t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Me,0,0,0,De[Me].width,De[Me].height,xe,Le,De[Me].data):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Me,0,ct,De[Me].width,De[Me].height,0,xe,Le,De[Me].data);for(let Ze=0;Ze<ye.length;Ze++){const vt=ye[Ze].image[Me].image;rt?Q&&t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Me,Ze+1,0,0,vt.width,vt.height,xe,Le,vt.data):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Me,Ze+1,ct,vt.width,vt.height,0,xe,Le,vt.data)}}else{rt?Q&&t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Me,0,0,0,xe,Le,De[Me]):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Me,0,ct,xe,Le,De[Me]);for(let Ze=0;Ze<ye.length;Ze++){const Xe=ye[Ze];rt?Q&&t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Me,Ze+1,0,0,xe,Le,Xe.image[Me]):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Me,Ze+1,ct,xe,Le,Xe.image[Me])}}}p(E)&&g(r.TEXTURE_CUBE_MAP),ce.__version=ve.version,E.onUpdate&&E.onUpdate(E)}N.__version=E.version}function ie(N,E,W,ae,ve,ce){const Oe=s.convert(W.format,W.colorSpace),Pe=s.convert(W.type),Ve=x(W.internalFormat,Oe,Pe,W.colorSpace),te=n.get(E),re=n.get(W);if(re.__renderTarget=E,!te.__hasExternalTextures){const De=Math.max(1,E.width>>ce),Ye=Math.max(1,E.height>>ce);ve===r.TEXTURE_3D||ve===r.TEXTURE_2D_ARRAY?t.texImage3D(ve,ce,Ve,De,Ye,E.depth,0,Oe,Pe,null):t.texImage2D(ve,ce,Ve,De,Ye,0,Oe,Pe,null)}t.bindFramebuffer(r.FRAMEBUFFER,N),Te(E)?o.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,ae,ve,re.__webglTexture,0,Ue(E)):(ve===r.TEXTURE_2D||ve>=r.TEXTURE_CUBE_MAP_POSITIVE_X&&ve<=r.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&r.framebufferTexture2D(r.FRAMEBUFFER,ae,ve,re.__webglTexture,ce),t.bindFramebuffer(r.FRAMEBUFFER,null)}function Y(N,E,W){if(r.bindRenderbuffer(r.RENDERBUFFER,N),E.depthBuffer){const ae=E.depthTexture,ve=ae&&ae.isDepthTexture?ae.type:null,ce=w(E.stencilBuffer,ve),Oe=E.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,Pe=Ue(E);Te(E)?o.renderbufferStorageMultisampleEXT(r.RENDERBUFFER,Pe,ce,E.width,E.height):W?r.renderbufferStorageMultisample(r.RENDERBUFFER,Pe,ce,E.width,E.height):r.renderbufferStorage(r.RENDERBUFFER,ce,E.width,E.height),r.framebufferRenderbuffer(r.FRAMEBUFFER,Oe,r.RENDERBUFFER,N)}else{const ae=E.textures;for(let ve=0;ve<ae.length;ve++){const ce=ae[ve],Oe=s.convert(ce.format,ce.colorSpace),Pe=s.convert(ce.type),Ve=x(ce.internalFormat,Oe,Pe,ce.colorSpace),te=Ue(E);W&&Te(E)===!1?r.renderbufferStorageMultisample(r.RENDERBUFFER,te,Ve,E.width,E.height):Te(E)?o.renderbufferStorageMultisampleEXT(r.RENDERBUFFER,te,Ve,E.width,E.height):r.renderbufferStorage(r.RENDERBUFFER,Ve,E.width,E.height)}}r.bindRenderbuffer(r.RENDERBUFFER,null)}function ue(N,E){if(E&&E.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(r.FRAMEBUFFER,N),!(E.depthTexture&&E.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const ae=n.get(E.depthTexture);ae.__renderTarget=E,(!ae.__webglTexture||E.depthTexture.image.width!==E.width||E.depthTexture.image.height!==E.height)&&(E.depthTexture.image.width=E.width,E.depthTexture.image.height=E.height,E.depthTexture.needsUpdate=!0),q(E.depthTexture,0);const ve=ae.__webglTexture,ce=Ue(E);if(E.depthTexture.format===ha)Te(E)?o.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,r.DEPTH_ATTACHMENT,r.TEXTURE_2D,ve,0,ce):r.framebufferTexture2D(r.FRAMEBUFFER,r.DEPTH_ATTACHMENT,r.TEXTURE_2D,ve,0);else if(E.depthTexture.format===wa)Te(E)?o.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.TEXTURE_2D,ve,0,ce):r.framebufferTexture2D(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.TEXTURE_2D,ve,0);else throw new Error("Unknown depthTexture format")}function oe(N){const E=n.get(N),W=N.isWebGLCubeRenderTarget===!0;if(E.__boundDepthTexture!==N.depthTexture){const ae=N.depthTexture;if(E.__depthDisposeCallback&&E.__depthDisposeCallback(),ae){const ve=()=>{delete E.__boundDepthTexture,delete E.__depthDisposeCallback,ae.removeEventListener("dispose",ve)};ae.addEventListener("dispose",ve),E.__depthDisposeCallback=ve}E.__boundDepthTexture=ae}if(N.depthTexture&&!E.__autoAllocateDepthBuffer){if(W)throw new Error("target.depthTexture not supported in Cube render targets");ue(E.__webglFramebuffer,N)}else if(W){E.__webglDepthbuffer=[];for(let ae=0;ae<6;ae++)if(t.bindFramebuffer(r.FRAMEBUFFER,E.__webglFramebuffer[ae]),E.__webglDepthbuffer[ae]===void 0)E.__webglDepthbuffer[ae]=r.createRenderbuffer(),Y(E.__webglDepthbuffer[ae],N,!1);else{const ve=N.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,ce=E.__webglDepthbuffer[ae];r.bindRenderbuffer(r.RENDERBUFFER,ce),r.framebufferRenderbuffer(r.FRAMEBUFFER,ve,r.RENDERBUFFER,ce)}}else if(t.bindFramebuffer(r.FRAMEBUFFER,E.__webglFramebuffer),E.__webglDepthbuffer===void 0)E.__webglDepthbuffer=r.createRenderbuffer(),Y(E.__webglDepthbuffer,N,!1);else{const ae=N.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,ve=E.__webglDepthbuffer;r.bindRenderbuffer(r.RENDERBUFFER,ve),r.framebufferRenderbuffer(r.FRAMEBUFFER,ae,r.RENDERBUFFER,ve)}t.bindFramebuffer(r.FRAMEBUFFER,null)}function be(N,E,W){const ae=n.get(N);E!==void 0&&ie(ae.__webglFramebuffer,N,N.texture,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,0),W!==void 0&&oe(N)}function Ce(N){const E=N.texture,W=n.get(N),ae=n.get(E);N.addEventListener("dispose",A);const ve=N.textures,ce=N.isWebGLCubeRenderTarget===!0,Oe=ve.length>1;if(Oe||(ae.__webglTexture===void 0&&(ae.__webglTexture=r.createTexture()),ae.__version=E.version,a.memory.textures++),ce){W.__webglFramebuffer=[];for(let Pe=0;Pe<6;Pe++)if(E.mipmaps&&E.mipmaps.length>0){W.__webglFramebuffer[Pe]=[];for(let Ve=0;Ve<E.mipmaps.length;Ve++)W.__webglFramebuffer[Pe][Ve]=r.createFramebuffer()}else W.__webglFramebuffer[Pe]=r.createFramebuffer()}else{if(E.mipmaps&&E.mipmaps.length>0){W.__webglFramebuffer=[];for(let Pe=0;Pe<E.mipmaps.length;Pe++)W.__webglFramebuffer[Pe]=r.createFramebuffer()}else W.__webglFramebuffer=r.createFramebuffer();if(Oe)for(let Pe=0,Ve=ve.length;Pe<Ve;Pe++){const te=n.get(ve[Pe]);te.__webglTexture===void 0&&(te.__webglTexture=r.createTexture(),a.memory.textures++)}if(N.samples>0&&Te(N)===!1){W.__webglMultisampledFramebuffer=r.createFramebuffer(),W.__webglColorRenderbuffer=[],t.bindFramebuffer(r.FRAMEBUFFER,W.__webglMultisampledFramebuffer);for(let Pe=0;Pe<ve.length;Pe++){const Ve=ve[Pe];W.__webglColorRenderbuffer[Pe]=r.createRenderbuffer(),r.bindRenderbuffer(r.RENDERBUFFER,W.__webglColorRenderbuffer[Pe]);const te=s.convert(Ve.format,Ve.colorSpace),re=s.convert(Ve.type),De=x(Ve.internalFormat,te,re,Ve.colorSpace,N.isXRRenderTarget===!0),Ye=Ue(N);r.renderbufferStorageMultisample(r.RENDERBUFFER,Ye,De,N.width,N.height),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+Pe,r.RENDERBUFFER,W.__webglColorRenderbuffer[Pe])}r.bindRenderbuffer(r.RENDERBUFFER,null),N.depthBuffer&&(W.__webglDepthRenderbuffer=r.createRenderbuffer(),Y(W.__webglDepthRenderbuffer,N,!0)),t.bindFramebuffer(r.FRAMEBUFFER,null)}}if(ce){t.bindTexture(r.TEXTURE_CUBE_MAP,ae.__webglTexture),ge(r.TEXTURE_CUBE_MAP,E);for(let Pe=0;Pe<6;Pe++)if(E.mipmaps&&E.mipmaps.length>0)for(let Ve=0;Ve<E.mipmaps.length;Ve++)ie(W.__webglFramebuffer[Pe][Ve],N,E,r.COLOR_ATTACHMENT0,r.TEXTURE_CUBE_MAP_POSITIVE_X+Pe,Ve);else ie(W.__webglFramebuffer[Pe],N,E,r.COLOR_ATTACHMENT0,r.TEXTURE_CUBE_MAP_POSITIVE_X+Pe,0);p(E)&&g(r.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(Oe){for(let Pe=0,Ve=ve.length;Pe<Ve;Pe++){const te=ve[Pe],re=n.get(te);t.bindTexture(r.TEXTURE_2D,re.__webglTexture),ge(r.TEXTURE_2D,te),ie(W.__webglFramebuffer,N,te,r.COLOR_ATTACHMENT0+Pe,r.TEXTURE_2D,0),p(te)&&g(r.TEXTURE_2D)}t.unbindTexture()}else{let Pe=r.TEXTURE_2D;if((N.isWebGL3DRenderTarget||N.isWebGLArrayRenderTarget)&&(Pe=N.isWebGL3DRenderTarget?r.TEXTURE_3D:r.TEXTURE_2D_ARRAY),t.bindTexture(Pe,ae.__webglTexture),ge(Pe,E),E.mipmaps&&E.mipmaps.length>0)for(let Ve=0;Ve<E.mipmaps.length;Ve++)ie(W.__webglFramebuffer[Ve],N,E,r.COLOR_ATTACHMENT0,Pe,Ve);else ie(W.__webglFramebuffer,N,E,r.COLOR_ATTACHMENT0,Pe,0);p(E)&&g(Pe),t.unbindTexture()}N.depthBuffer&&oe(N)}function je(N){const E=N.textures;for(let W=0,ae=E.length;W<ae;W++){const ve=E[W];if(p(ve)){const ce=y(N),Oe=n.get(ve).__webglTexture;t.bindTexture(ce,Oe),g(ce),t.unbindTexture()}}}const Fe=[],j=[];function Ke(N){if(N.samples>0){if(Te(N)===!1){const E=N.textures,W=N.width,ae=N.height;let ve=r.COLOR_BUFFER_BIT;const ce=N.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,Oe=n.get(N),Pe=E.length>1;if(Pe)for(let Ve=0;Ve<E.length;Ve++)t.bindFramebuffer(r.FRAMEBUFFER,Oe.__webglMultisampledFramebuffer),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+Ve,r.RENDERBUFFER,null),t.bindFramebuffer(r.FRAMEBUFFER,Oe.__webglFramebuffer),r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,r.COLOR_ATTACHMENT0+Ve,r.TEXTURE_2D,null,0);t.bindFramebuffer(r.READ_FRAMEBUFFER,Oe.__webglMultisampledFramebuffer),t.bindFramebuffer(r.DRAW_FRAMEBUFFER,Oe.__webglFramebuffer);for(let Ve=0;Ve<E.length;Ve++){if(N.resolveDepthBuffer&&(N.depthBuffer&&(ve|=r.DEPTH_BUFFER_BIT),N.stencilBuffer&&N.resolveStencilBuffer&&(ve|=r.STENCIL_BUFFER_BIT)),Pe){r.framebufferRenderbuffer(r.READ_FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.RENDERBUFFER,Oe.__webglColorRenderbuffer[Ve]);const te=n.get(E[Ve]).__webglTexture;r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,te,0)}r.blitFramebuffer(0,0,W,ae,0,0,W,ae,ve,r.NEAREST),l===!0&&(Fe.length=0,j.length=0,Fe.push(r.COLOR_ATTACHMENT0+Ve),N.depthBuffer&&N.resolveDepthBuffer===!1&&(Fe.push(ce),j.push(ce),r.invalidateFramebuffer(r.DRAW_FRAMEBUFFER,j)),r.invalidateFramebuffer(r.READ_FRAMEBUFFER,Fe))}if(t.bindFramebuffer(r.READ_FRAMEBUFFER,null),t.bindFramebuffer(r.DRAW_FRAMEBUFFER,null),Pe)for(let Ve=0;Ve<E.length;Ve++){t.bindFramebuffer(r.FRAMEBUFFER,Oe.__webglMultisampledFramebuffer),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+Ve,r.RENDERBUFFER,Oe.__webglColorRenderbuffer[Ve]);const te=n.get(E[Ve]).__webglTexture;t.bindFramebuffer(r.FRAMEBUFFER,Oe.__webglFramebuffer),r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,r.COLOR_ATTACHMENT0+Ve,r.TEXTURE_2D,te,0)}t.bindFramebuffer(r.DRAW_FRAMEBUFFER,Oe.__webglMultisampledFramebuffer)}else if(N.depthBuffer&&N.resolveDepthBuffer===!1&&l){const E=N.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT;r.invalidateFramebuffer(r.DRAW_FRAMEBUFFER,[E])}}}function Ue(N){return Math.min(i.maxSamples,N.samples)}function Te(N){const E=n.get(N);return N.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&E.__useRenderToTexture!==!1}function Se(N){const E=a.render.frame;d.get(N)!==E&&(d.set(N,E),N.update())}function et(N,E){const W=N.colorSpace,ae=N.format,ve=N.type;return N.isCompressedTexture===!0||N.isVideoTexture===!0||W!==$n&&W!==zs&&(ft.getTransfer(W)===Ht?(ae!==Dn||ve!==Ms)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",W)),E}function Be(N){return typeof HTMLImageElement<"u"&&N instanceof HTMLImageElement?(c.width=N.naturalWidth||N.width,c.height=N.naturalHeight||N.height):typeof VideoFrame<"u"&&N instanceof VideoFrame?(c.width=N.displayWidth,c.height=N.displayHeight):(c.width=N.width,c.height=N.height),c}this.allocateTextureUnit=O,this.resetTextureUnits=k,this.setTexture2D=q,this.setTexture2DArray=G,this.setTexture3D=K,this.setTextureCube=V,this.rebindTextures=be,this.setupRenderTarget=Ce,this.updateRenderTargetMipmap=je,this.updateMultisampleRenderTarget=Ke,this.setupDepthRenderbuffer=oe,this.setupFrameBufferTexture=ie,this.useMultisampledRTT=Te}function bE(r,e){function t(n,i=zs){let s;const a=ft.getTransfer(i);if(n===Ms)return r.UNSIGNED_BYTE;if(n===Du)return r.UNSIGNED_SHORT_4_4_4_4;if(n===Lu)return r.UNSIGNED_SHORT_5_5_5_1;if(n===db)return r.UNSIGNED_INT_5_9_9_9_REV;if(n===lb)return r.BYTE;if(n===cb)return r.SHORT;if(n===bo)return r.UNSIGNED_SHORT;if(n===Nu)return r.INT;if(n===Zs)return r.UNSIGNED_INT;if(n===_i)return r.FLOAT;if(n===Ri)return r.HALF_FLOAT;if(n===hb)return r.ALPHA;if(n===ub)return r.RGB;if(n===Dn)return r.RGBA;if(n===fb)return r.LUMINANCE;if(n===pb)return r.LUMINANCE_ALPHA;if(n===ha)return r.DEPTH_COMPONENT;if(n===wa)return r.DEPTH_STENCIL;if(n===Iu)return r.RED;if(n===Ic)return r.RED_INTEGER;if(n===mb)return r.RG;if(n===ku)return r.RG_INTEGER;if(n===Ou)return r.RGBA_INTEGER;if(n===lc||n===cc||n===dc||n===hc)if(a===Ht)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(n===lc)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===cc)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===dc)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===hc)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(n===lc)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===cc)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===dc)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===hc)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===Uh||n===Bh||n===zh||n===Hh)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(n===Uh)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===Bh)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===zh)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Hh)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===Gh||n===Vh||n===Wh)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(n===Gh||n===Vh)return a===Ht?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(n===Wh)return a===Ht?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===jh||n===Xh||n===qh||n===Zh||n===Yh||n===Kh||n===$h||n===Qh||n===Jh||n===eu||n===tu||n===nu||n===iu||n===su)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(n===jh)return a===Ht?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Xh)return a===Ht?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===qh)return a===Ht?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===Zh)return a===Ht?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Yh)return a===Ht?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===Kh)return a===Ht?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===$h)return a===Ht?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===Qh)return a===Ht?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===Jh)return a===Ht?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===eu)return a===Ht?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===tu)return a===Ht?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===nu)return a===Ht?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===iu)return a===Ht?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===su)return a===Ht?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===uc||n===ru||n===au)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(n===uc)return a===Ht?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===ru)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===au)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===gb||n===ou||n===lu||n===cu)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(n===uc)return s.COMPRESSED_RED_RGTC1_EXT;if(n===ou)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===lu)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===cu)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===_a?r.UNSIGNED_INT_24_8:r[n]!==void 0?r[n]:null}return{convert:t}}const vE=`
|
|
3832
|
+
}`;function fE(r,e,t){let n=new No;const i=new me,s=new me,a=new _t,o=new Ub({depthPacking:vb}),l=new p_,c={},d=t.maxTextureSize,h={[Si]:fi,[fi]:Si,[ln]:ln},u=new wn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new me},radius:{value:4}},vertexShader:hE,fragmentShader:uE}),f=u.clone();f.defines.HORIZONTAL_PASS=1;const m=new ht;m.setAttribute("position",new rn(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const b=new Ee(m,u),p=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Qg;let g=this.type;this.render=function(T,A,M){if(p.enabled===!1||p.autoUpdate===!1&&p.needsUpdate===!1||T.length===0)return;const _=r.getRenderTarget(),S=r.getActiveCubeFace(),R=r.getActiveMipmapLevel(),k=r.state;k.setBlending(qi),k.buffers.color.setClear(1,1,1,1),k.buffers.depth.setTest(!0),k.setScissorTest(!1);const O=g!==vs&&this.type===vs,H=g===vs&&this.type!==vs;for(let q=0,G=T.length;q<G;q++){const K=T[q],V=K.shadow;if(V===void 0){console.warn("THREE.WebGLShadowMap:",K,"has no shadow.");continue}if(V.autoUpdate===!1&&V.needsUpdate===!1)continue;i.copy(V.mapSize);const Y=V.getFrameExtents();if(i.multiply(Y),s.copy(V.mapSize),(i.x>d||i.y>d)&&(i.x>d&&(s.x=Math.floor(d/Y.x),i.x=s.x*Y.x,V.mapSize.x=s.x),i.y>d&&(s.y=Math.floor(d/Y.y),i.y=s.y*Y.y,V.mapSize.y=s.y)),V.map===null||O===!0||H===!0){const se=this.type!==vs?{minFilter:Sn,magFilter:Sn}:{};V.map!==null&&V.map.dispose(),V.map=new ni(i.x,i.y,se),V.map.texture.name=K.name+".shadowMap",V.camera.updateProjectionMatrix()}r.setRenderTarget(V.map),r.clear();const le=V.getViewportCount();for(let se=0;se<le;se++){const ge=V.getViewport(se);a.set(s.x*ge.x,s.y*ge.y,s.x*ge.z,s.y*ge.w),k.viewport(a),V.updateMatrices(K,se),n=V.getFrustum(),w(A,M,V.camera,K,this.type)}V.isPointLightShadow!==!0&&this.type===vs&&y(V,M),V.needsUpdate=!1}g=this.type,p.needsUpdate=!1,r.setRenderTarget(_,S,R)};function y(T,A){const M=e.update(b);u.defines.VSM_SAMPLES!==T.blurSamples&&(u.defines.VSM_SAMPLES=T.blurSamples,f.defines.VSM_SAMPLES=T.blurSamples,u.needsUpdate=!0,f.needsUpdate=!0),T.mapPass===null&&(T.mapPass=new ni(i.x,i.y)),u.uniforms.shadow_pass.value=T.map.texture,u.uniforms.resolution.value=T.mapSize,u.uniforms.radius.value=T.radius,r.setRenderTarget(T.mapPass),r.clear(),r.renderBufferDirect(A,null,M,u,b,null),f.uniforms.shadow_pass.value=T.mapPass.texture,f.uniforms.resolution.value=T.mapSize,f.uniforms.radius.value=T.radius,r.setRenderTarget(T.map),r.clear(),r.renderBufferDirect(A,null,M,f,b,null)}function x(T,A,M,_){let S=null;const R=M.isPointLight===!0?T.customDistanceMaterial:T.customDepthMaterial;if(R!==void 0)S=R;else if(S=M.isPointLight===!0?l:o,r.localClippingEnabled&&A.clipShadows===!0&&Array.isArray(A.clippingPlanes)&&A.clippingPlanes.length!==0||A.displacementMap&&A.displacementScale!==0||A.alphaMap&&A.alphaTest>0||A.map&&A.alphaTest>0){const k=S.uuid,O=A.uuid;let H=c[k];H===void 0&&(H={},c[k]=H);let q=H[O];q===void 0&&(q=S.clone(),H[O]=q,A.addEventListener("dispose",P)),S=q}if(S.visible=A.visible,S.wireframe=A.wireframe,_===vs?S.side=A.shadowSide!==null?A.shadowSide:A.side:S.side=A.shadowSide!==null?A.shadowSide:h[A.side],S.alphaMap=A.alphaMap,S.alphaTest=A.alphaTest,S.map=A.map,S.clipShadows=A.clipShadows,S.clippingPlanes=A.clippingPlanes,S.clipIntersection=A.clipIntersection,S.displacementMap=A.displacementMap,S.displacementScale=A.displacementScale,S.displacementBias=A.displacementBias,S.wireframeLinewidth=A.wireframeLinewidth,S.linewidth=A.linewidth,M.isPointLight===!0&&S.isMeshDistanceMaterial===!0){const k=r.properties.get(S);k.light=M}return S}function w(T,A,M,_,S){if(T.visible===!1)return;if(T.layers.test(A.layers)&&(T.isMesh||T.isLine||T.isPoints)&&(T.castShadow||T.receiveShadow&&S===vs)&&(!T.frustumCulled||n.intersectsObject(T))){T.modelViewMatrix.multiplyMatrices(M.matrixWorldInverse,T.matrixWorld);const O=e.update(T),H=T.material;if(Array.isArray(H)){const q=O.groups;for(let G=0,K=q.length;G<K;G++){const V=q[G],Y=H[V.materialIndex];if(Y&&Y.visible){const le=x(T,Y,_,S);T.onBeforeShadow(r,T,A,M,O,le,V),r.renderBufferDirect(M,null,O,le,T,V),T.onAfterShadow(r,T,A,M,O,le,V)}}}else if(H.visible){const q=x(T,H,_,S);T.onBeforeShadow(r,T,A,M,O,q,null),r.renderBufferDirect(M,null,O,q,T,null),T.onAfterShadow(r,T,A,M,O,q,null)}}const k=T.children;for(let O=0,H=k.length;O<H;O++)w(k[O],A,M,_,S)}function P(T){T.target.removeEventListener("dispose",P);for(const M in c){const _=c[M],S=T.target.uuid;S in _&&(_[S].dispose(),delete _[S])}}}const pE={[Rh]:Nh,[Dh]:kh,[Lh]:Oh,[va]:Ih,[Nh]:Rh,[kh]:Dh,[Oh]:Lh,[Ih]:va};function mE(r,e){function t(){let Q=!1;const Ge=new _t;let ye=null;const Me=new _t(0,0,0,0);return{setMask:function(Ze){ye!==Ze&&!Q&&(r.colorMask(Ze,Ze,Ze,Ze),ye=Ze)},setLocked:function(Ze){Q=Ze},setClear:function(Ze,Xe,vt,Qt,An){An===!0&&(Ze*=Qt,Xe*=Qt,vt*=Qt),Ge.set(Ze,Xe,vt,Qt),Me.equals(Ge)===!1&&(r.clearColor(Ze,Xe,vt,Qt),Me.copy(Ge))},reset:function(){Q=!1,ye=null,Me.set(-1,0,0,0)}}}function n(){let Q=!1,Ge=!1,ye=null,Me=null,Ze=null;return{setReversed:function(Xe){if(Ge!==Xe){const vt=e.get("EXT_clip_control");Ge?vt.clipControlEXT(vt.LOWER_LEFT_EXT,vt.ZERO_TO_ONE_EXT):vt.clipControlEXT(vt.LOWER_LEFT_EXT,vt.NEGATIVE_ONE_TO_ONE_EXT);const Qt=Ze;Ze=null,this.setClear(Qt)}Ge=Xe},getReversed:function(){return Ge},setTest:function(Xe){Xe?Z(r.DEPTH_TEST):ue(r.DEPTH_TEST)},setMask:function(Xe){ye!==Xe&&!Q&&(r.depthMask(Xe),ye=Xe)},setFunc:function(Xe){if(Ge&&(Xe=pE[Xe]),Me!==Xe){switch(Xe){case Rh:r.depthFunc(r.NEVER);break;case Nh:r.depthFunc(r.ALWAYS);break;case Dh:r.depthFunc(r.LESS);break;case va:r.depthFunc(r.LEQUAL);break;case Lh:r.depthFunc(r.EQUAL);break;case Ih:r.depthFunc(r.GEQUAL);break;case kh:r.depthFunc(r.GREATER);break;case Oh:r.depthFunc(r.NOTEQUAL);break;default:r.depthFunc(r.LEQUAL)}Me=Xe}},setLocked:function(Xe){Q=Xe},setClear:function(Xe){Ze!==Xe&&(Ge&&(Xe=1-Xe),r.clearDepth(Xe),Ze=Xe)},reset:function(){Q=!1,ye=null,Me=null,Ze=null,Ge=!1}}}function i(){let Q=!1,Ge=null,ye=null,Me=null,Ze=null,Xe=null,vt=null,Qt=null,An=null;return{setTest:function(wt){Q||(wt?Z(r.STENCIL_TEST):ue(r.STENCIL_TEST))},setMask:function(wt){Ge!==wt&&!Q&&(r.stencilMask(wt),Ge=wt)},setFunc:function(wt,si,Fi){(ye!==wt||Me!==si||Ze!==Fi)&&(r.stencilFunc(wt,si,Fi),ye=wt,Me=si,Ze=Fi)},setOp:function(wt,si,Fi){(Xe!==wt||vt!==si||Qt!==Fi)&&(r.stencilOp(wt,si,Fi),Xe=wt,vt=si,Qt=Fi)},setLocked:function(wt){Q=wt},setClear:function(wt){An!==wt&&(r.clearStencil(wt),An=wt)},reset:function(){Q=!1,Ge=null,ye=null,Me=null,Ze=null,Xe=null,vt=null,Qt=null,An=null}}}const s=new t,a=new n,o=new i,l=new WeakMap,c=new WeakMap;let d={},h={},u=new WeakMap,f=[],m=null,b=!1,p=null,g=null,y=null,x=null,w=null,P=null,T=null,A=new Ne(0,0,0),M=0,_=!1,S=null,R=null,k=null,O=null,H=null;const q=r.getParameter(r.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let G=!1,K=0;const V=r.getParameter(r.VERSION);V.indexOf("WebGL")!==-1?(K=parseFloat(/^WebGL (\d)/.exec(V)[1]),G=K>=1):V.indexOf("OpenGL ES")!==-1&&(K=parseFloat(/^OpenGL ES (\d)/.exec(V)[1]),G=K>=2);let Y=null,le={};const se=r.getParameter(r.SCISSOR_BOX),ge=r.getParameter(r.VIEWPORT),de=new _t().fromArray(se),X=new _t().fromArray(ge);function ee(Q,Ge,ye,Me){const Ze=new Uint8Array(4),Xe=r.createTexture();r.bindTexture(Q,Xe),r.texParameteri(Q,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(Q,r.TEXTURE_MAG_FILTER,r.NEAREST);for(let vt=0;vt<ye;vt++)Q===r.TEXTURE_3D||Q===r.TEXTURE_2D_ARRAY?r.texImage3D(Ge,0,r.RGBA,1,1,Me,0,r.RGBA,r.UNSIGNED_BYTE,Ze):r.texImage2D(Ge+vt,0,r.RGBA,1,1,0,r.RGBA,r.UNSIGNED_BYTE,Ze);return Xe}const ie={};ie[r.TEXTURE_2D]=ee(r.TEXTURE_2D,r.TEXTURE_2D,1),ie[r.TEXTURE_CUBE_MAP]=ee(r.TEXTURE_CUBE_MAP,r.TEXTURE_CUBE_MAP_POSITIVE_X,6),ie[r.TEXTURE_2D_ARRAY]=ee(r.TEXTURE_2D_ARRAY,r.TEXTURE_2D_ARRAY,1,1),ie[r.TEXTURE_3D]=ee(r.TEXTURE_3D,r.TEXTURE_3D,1,1),s.setClear(0,0,0,1),a.setClear(1),o.setClear(0),Z(r.DEPTH_TEST),a.setFunc(va),Ue(!1),Te(Ef),Z(r.CULL_FACE),j(qi);function Z(Q){d[Q]!==!0&&(r.enable(Q),d[Q]=!0)}function ue(Q){d[Q]!==!1&&(r.disable(Q),d[Q]=!1)}function oe(Q,Ge){return h[Q]!==Ge?(r.bindFramebuffer(Q,Ge),h[Q]=Ge,Q===r.DRAW_FRAMEBUFFER&&(h[r.FRAMEBUFFER]=Ge),Q===r.FRAMEBUFFER&&(h[r.DRAW_FRAMEBUFFER]=Ge),!0):!1}function be(Q,Ge){let ye=f,Me=!1;if(Q){ye=u.get(Ge),ye===void 0&&(ye=[],u.set(Ge,ye));const Ze=Q.textures;if(ye.length!==Ze.length||ye[0]!==r.COLOR_ATTACHMENT0){for(let Xe=0,vt=Ze.length;Xe<vt;Xe++)ye[Xe]=r.COLOR_ATTACHMENT0+Xe;ye.length=Ze.length,Me=!0}}else ye[0]!==r.BACK&&(ye[0]=r.BACK,Me=!0);Me&&r.drawBuffers(ye)}function Ce(Q){return m!==Q?(r.useProgram(Q),m=Q,!0):!1}const je={[pr]:r.FUNC_ADD,[nx]:r.FUNC_SUBTRACT,[ix]:r.FUNC_REVERSE_SUBTRACT};je[sx]=r.MIN,je[rx]=r.MAX;const Fe={[ax]:r.ZERO,[ox]:r.ONE,[lx]:r.SRC_COLOR,[Ch]:r.SRC_ALPHA,[px]:r.SRC_ALPHA_SATURATE,[ux]:r.DST_COLOR,[dx]:r.DST_ALPHA,[cx]:r.ONE_MINUS_SRC_COLOR,[Ph]:r.ONE_MINUS_SRC_ALPHA,[fx]:r.ONE_MINUS_DST_COLOR,[hx]:r.ONE_MINUS_DST_ALPHA,[mx]:r.CONSTANT_COLOR,[gx]:r.ONE_MINUS_CONSTANT_COLOR,[bx]:r.CONSTANT_ALPHA,[vx]:r.ONE_MINUS_CONSTANT_ALPHA};function j(Q,Ge,ye,Me,Ze,Xe,vt,Qt,An,wt){if(Q===qi){b===!0&&(ue(r.BLEND),b=!1);return}if(b===!1&&(Z(r.BLEND),b=!0),Q!==tx){if(Q!==p||wt!==_){if((g!==pr||w!==pr)&&(r.blendEquation(r.FUNC_ADD),g=pr,w=pr),wt)switch(Q){case da:r.blendFuncSeparate(r.ONE,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA);break;case Ah:r.blendFunc(r.ONE,r.ONE);break;case Af:r.blendFuncSeparate(r.ZERO,r.ONE_MINUS_SRC_COLOR,r.ZERO,r.ONE);break;case Cf:r.blendFuncSeparate(r.ZERO,r.SRC_COLOR,r.ZERO,r.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",Q);break}else switch(Q){case da:r.blendFuncSeparate(r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA);break;case Ah:r.blendFunc(r.SRC_ALPHA,r.ONE);break;case Af:r.blendFuncSeparate(r.ZERO,r.ONE_MINUS_SRC_COLOR,r.ZERO,r.ONE);break;case Cf:r.blendFunc(r.ZERO,r.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",Q);break}y=null,x=null,P=null,T=null,A.set(0,0,0),M=0,p=Q,_=wt}return}Ze=Ze||Ge,Xe=Xe||ye,vt=vt||Me,(Ge!==g||Ze!==w)&&(r.blendEquationSeparate(je[Ge],je[Ze]),g=Ge,w=Ze),(ye!==y||Me!==x||Xe!==P||vt!==T)&&(r.blendFuncSeparate(Fe[ye],Fe[Me],Fe[Xe],Fe[vt]),y=ye,x=Me,P=Xe,T=vt),(Qt.equals(A)===!1||An!==M)&&(r.blendColor(Qt.r,Qt.g,Qt.b,An),A.copy(Qt),M=An),p=Q,_=!1}function Ke(Q,Ge){Q.side===ln?ue(r.CULL_FACE):Z(r.CULL_FACE);let ye=Q.side===fi;Ge&&(ye=!ye),Ue(ye),Q.blending===da&&Q.transparent===!1?j(qi):j(Q.blending,Q.blendEquation,Q.blendSrc,Q.blendDst,Q.blendEquationAlpha,Q.blendSrcAlpha,Q.blendDstAlpha,Q.blendColor,Q.blendAlpha,Q.premultipliedAlpha),a.setFunc(Q.depthFunc),a.setTest(Q.depthTest),a.setMask(Q.depthWrite),s.setMask(Q.colorWrite);const Me=Q.stencilWrite;o.setTest(Me),Me&&(o.setMask(Q.stencilWriteMask),o.setFunc(Q.stencilFunc,Q.stencilRef,Q.stencilFuncMask),o.setOp(Q.stencilFail,Q.stencilZFail,Q.stencilZPass)),et(Q.polygonOffset,Q.polygonOffsetFactor,Q.polygonOffsetUnits),Q.alphaToCoverage===!0?Z(r.SAMPLE_ALPHA_TO_COVERAGE):ue(r.SAMPLE_ALPHA_TO_COVERAGE)}function Ue(Q){S!==Q&&(Q?r.frontFace(r.CW):r.frontFace(r.CCW),S=Q)}function Te(Q){Q!==Qy?(Z(r.CULL_FACE),Q!==R&&(Q===Ef?r.cullFace(r.BACK):Q===Jy?r.cullFace(r.FRONT):r.cullFace(r.FRONT_AND_BACK))):ue(r.CULL_FACE),R=Q}function Se(Q){Q!==k&&(G&&r.lineWidth(Q),k=Q)}function et(Q,Ge,ye){Q?(Z(r.POLYGON_OFFSET_FILL),(O!==Ge||H!==ye)&&(r.polygonOffset(Ge,ye),O=Ge,H=ye)):ue(r.POLYGON_OFFSET_FILL)}function Be(Q){Q?Z(r.SCISSOR_TEST):ue(r.SCISSOR_TEST)}function N(Q){Q===void 0&&(Q=r.TEXTURE0+q-1),Y!==Q&&(r.activeTexture(Q),Y=Q)}function E(Q,Ge,ye){ye===void 0&&(Y===null?ye=r.TEXTURE0+q-1:ye=Y);let Me=le[ye];Me===void 0&&(Me={type:void 0,texture:void 0},le[ye]=Me),(Me.type!==Q||Me.texture!==Ge)&&(Y!==ye&&(r.activeTexture(ye),Y=ye),r.bindTexture(Q,Ge||ie[Q]),Me.type=Q,Me.texture=Ge)}function W(){const Q=le[Y];Q!==void 0&&Q.type!==void 0&&(r.bindTexture(Q.type,null),Q.type=void 0,Q.texture=void 0)}function ae(){try{r.compressedTexImage2D(...arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function ve(){try{r.compressedTexImage3D(...arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function ce(){try{r.texSubImage2D(...arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function Oe(){try{r.texSubImage3D(...arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function Pe(){try{r.compressedTexSubImage2D(...arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function Ve(){try{r.compressedTexSubImage3D(...arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function te(){try{r.texStorage2D(...arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function re(){try{r.texStorage3D(...arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function De(){try{r.texImage2D(...arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function Ye(){try{r.texImage3D(...arguments)}catch(Q){console.error("THREE.WebGLState:",Q)}}function xe(Q){de.equals(Q)===!1&&(r.scissor(Q.x,Q.y,Q.z,Q.w),de.copy(Q))}function Le(Q){X.equals(Q)===!1&&(r.viewport(Q.x,Q.y,Q.z,Q.w),X.copy(Q))}function ct(Q,Ge){let ye=c.get(Ge);ye===void 0&&(ye=new WeakMap,c.set(Ge,ye));let Me=ye.get(Q);Me===void 0&&(Me=r.getUniformBlockIndex(Ge,Q.name),ye.set(Q,Me))}function rt(Q,Ge){const Me=c.get(Ge).get(Q);l.get(Ge)!==Me&&(r.uniformBlockBinding(Ge,Me,Q.__bindingPointIndex),l.set(Ge,Me))}function Rt(){r.disable(r.BLEND),r.disable(r.CULL_FACE),r.disable(r.DEPTH_TEST),r.disable(r.POLYGON_OFFSET_FILL),r.disable(r.SCISSOR_TEST),r.disable(r.STENCIL_TEST),r.disable(r.SAMPLE_ALPHA_TO_COVERAGE),r.blendEquation(r.FUNC_ADD),r.blendFunc(r.ONE,r.ZERO),r.blendFuncSeparate(r.ONE,r.ZERO,r.ONE,r.ZERO),r.blendColor(0,0,0,0),r.colorMask(!0,!0,!0,!0),r.clearColor(0,0,0,0),r.depthMask(!0),r.depthFunc(r.LESS),a.setReversed(!1),r.clearDepth(1),r.stencilMask(4294967295),r.stencilFunc(r.ALWAYS,0,4294967295),r.stencilOp(r.KEEP,r.KEEP,r.KEEP),r.clearStencil(0),r.cullFace(r.BACK),r.frontFace(r.CCW),r.polygonOffset(0,0),r.activeTexture(r.TEXTURE0),r.bindFramebuffer(r.FRAMEBUFFER,null),r.bindFramebuffer(r.DRAW_FRAMEBUFFER,null),r.bindFramebuffer(r.READ_FRAMEBUFFER,null),r.useProgram(null),r.lineWidth(1),r.scissor(0,0,r.canvas.width,r.canvas.height),r.viewport(0,0,r.canvas.width,r.canvas.height),d={},Y=null,le={},h={},u=new WeakMap,f=[],m=null,b=!1,p=null,g=null,y=null,x=null,w=null,P=null,T=null,A=new Ne(0,0,0),M=0,_=!1,S=null,R=null,k=null,O=null,H=null,de.set(0,0,r.canvas.width,r.canvas.height),X.set(0,0,r.canvas.width,r.canvas.height),s.reset(),a.reset(),o.reset()}return{buffers:{color:s,depth:a,stencil:o},enable:Z,disable:ue,bindFramebuffer:oe,drawBuffers:be,useProgram:Ce,setBlending:j,setMaterial:Ke,setFlipSided:Ue,setCullFace:Te,setLineWidth:Se,setPolygonOffset:et,setScissorTest:Be,activeTexture:N,bindTexture:E,unbindTexture:W,compressedTexImage2D:ae,compressedTexImage3D:ve,texImage2D:De,texImage3D:Ye,updateUBOMapping:ct,uniformBlockBinding:rt,texStorage2D:te,texStorage3D:re,texSubImage2D:ce,texSubImage3D:Oe,compressedTexSubImage2D:Pe,compressedTexSubImage3D:Ve,scissor:xe,viewport:Le,reset:Rt}}function gE(r,e,t,n,i,s,a){const 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 me,d=new WeakMap;let h;const u=new WeakMap;let f=!1;try{f=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function m(N,E){return f?new OffscreenCanvas(N,E):xo("canvas")}function b(N,E,W){let ae=1;const ve=Be(N);if((ve.width>W||ve.height>W)&&(ae=W/Math.max(ve.width,ve.height)),ae<1)if(typeof HTMLImageElement<"u"&&N instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&N instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&N instanceof ImageBitmap||typeof VideoFrame<"u"&&N instanceof VideoFrame){const ce=Math.floor(ae*ve.width),Oe=Math.floor(ae*ve.height);h===void 0&&(h=m(ce,Oe));const Pe=E?m(ce,Oe):h;return Pe.width=ce,Pe.height=Oe,Pe.getContext("2d").drawImage(N,0,0,ce,Oe),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+ve.width+"x"+ve.height+") to ("+ce+"x"+Oe+")."),Pe}else return"data"in N&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+ve.width+"x"+ve.height+")."),N;return N}function p(N){return N.generateMipmaps}function g(N){r.generateMipmap(N)}function y(N){return N.isWebGLCubeRenderTarget?r.TEXTURE_CUBE_MAP:N.isWebGL3DRenderTarget?r.TEXTURE_3D:N.isWebGLArrayRenderTarget||N.isCompressedArrayTexture?r.TEXTURE_2D_ARRAY:r.TEXTURE_2D}function x(N,E,W,ae,ve=!1){if(N!==null){if(r[N]!==void 0)return r[N];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+N+"'")}let ce=E;if(E===r.RED&&(W===r.FLOAT&&(ce=r.R32F),W===r.HALF_FLOAT&&(ce=r.R16F),W===r.UNSIGNED_BYTE&&(ce=r.R8)),E===r.RED_INTEGER&&(W===r.UNSIGNED_BYTE&&(ce=r.R8UI),W===r.UNSIGNED_SHORT&&(ce=r.R16UI),W===r.UNSIGNED_INT&&(ce=r.R32UI),W===r.BYTE&&(ce=r.R8I),W===r.SHORT&&(ce=r.R16I),W===r.INT&&(ce=r.R32I)),E===r.RG&&(W===r.FLOAT&&(ce=r.RG32F),W===r.HALF_FLOAT&&(ce=r.RG16F),W===r.UNSIGNED_BYTE&&(ce=r.RG8)),E===r.RG_INTEGER&&(W===r.UNSIGNED_BYTE&&(ce=r.RG8UI),W===r.UNSIGNED_SHORT&&(ce=r.RG16UI),W===r.UNSIGNED_INT&&(ce=r.RG32UI),W===r.BYTE&&(ce=r.RG8I),W===r.SHORT&&(ce=r.RG16I),W===r.INT&&(ce=r.RG32I)),E===r.RGB_INTEGER&&(W===r.UNSIGNED_BYTE&&(ce=r.RGB8UI),W===r.UNSIGNED_SHORT&&(ce=r.RGB16UI),W===r.UNSIGNED_INT&&(ce=r.RGB32UI),W===r.BYTE&&(ce=r.RGB8I),W===r.SHORT&&(ce=r.RGB16I),W===r.INT&&(ce=r.RGB32I)),E===r.RGBA_INTEGER&&(W===r.UNSIGNED_BYTE&&(ce=r.RGBA8UI),W===r.UNSIGNED_SHORT&&(ce=r.RGBA16UI),W===r.UNSIGNED_INT&&(ce=r.RGBA32UI),W===r.BYTE&&(ce=r.RGBA8I),W===r.SHORT&&(ce=r.RGBA16I),W===r.INT&&(ce=r.RGBA32I)),E===r.RGB&&W===r.UNSIGNED_INT_5_9_9_9_REV&&(ce=r.RGB9_E5),E===r.RGBA){const Oe=ve?xc:ft.getTransfer(ae);W===r.FLOAT&&(ce=r.RGBA32F),W===r.HALF_FLOAT&&(ce=r.RGBA16F),W===r.UNSIGNED_BYTE&&(ce=Oe===Ht?r.SRGB8_ALPHA8:r.RGBA8),W===r.UNSIGNED_SHORT_4_4_4_4&&(ce=r.RGBA4),W===r.UNSIGNED_SHORT_5_5_5_1&&(ce=r.RGB5_A1)}return(ce===r.R16F||ce===r.R32F||ce===r.RG16F||ce===r.RG32F||ce===r.RGBA16F||ce===r.RGBA32F)&&e.get("EXT_color_buffer_float"),ce}function w(N,E){let W;return N?E===null||E===Zs||E===_a?W=r.DEPTH24_STENCIL8:E===_i?W=r.DEPTH32F_STENCIL8:E===bo&&(W=r.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):E===null||E===Zs||E===_a?W=r.DEPTH_COMPONENT24:E===_i?W=r.DEPTH_COMPONENT32F:E===bo&&(W=r.DEPTH_COMPONENT16),W}function P(N,E){return p(N)===!0||N.isFramebufferTexture&&N.minFilter!==Sn&&N.minFilter!==bn?Math.log2(Math.max(E.width,E.height))+1:N.mipmaps!==void 0&&N.mipmaps.length>0?N.mipmaps.length:N.isCompressedTexture&&Array.isArray(N.image)?E.mipmaps.length:1}function T(N){const E=N.target;E.removeEventListener("dispose",T),M(E),E.isVideoTexture&&d.delete(E)}function A(N){const E=N.target;E.removeEventListener("dispose",A),S(E)}function M(N){const E=n.get(N);if(E.__webglInit===void 0)return;const W=N.source,ae=u.get(W);if(ae){const ve=ae[E.__cacheKey];ve.usedTimes--,ve.usedTimes===0&&_(N),Object.keys(ae).length===0&&u.delete(W)}n.remove(N)}function _(N){const E=n.get(N);r.deleteTexture(E.__webglTexture);const W=N.source,ae=u.get(W);delete ae[E.__cacheKey],a.memory.textures--}function S(N){const E=n.get(N);if(N.depthTexture&&(N.depthTexture.dispose(),n.remove(N.depthTexture)),N.isWebGLCubeRenderTarget)for(let ae=0;ae<6;ae++){if(Array.isArray(E.__webglFramebuffer[ae]))for(let ve=0;ve<E.__webglFramebuffer[ae].length;ve++)r.deleteFramebuffer(E.__webglFramebuffer[ae][ve]);else r.deleteFramebuffer(E.__webglFramebuffer[ae]);E.__webglDepthbuffer&&r.deleteRenderbuffer(E.__webglDepthbuffer[ae])}else{if(Array.isArray(E.__webglFramebuffer))for(let ae=0;ae<E.__webglFramebuffer.length;ae++)r.deleteFramebuffer(E.__webglFramebuffer[ae]);else r.deleteFramebuffer(E.__webglFramebuffer);if(E.__webglDepthbuffer&&r.deleteRenderbuffer(E.__webglDepthbuffer),E.__webglMultisampledFramebuffer&&r.deleteFramebuffer(E.__webglMultisampledFramebuffer),E.__webglColorRenderbuffer)for(let ae=0;ae<E.__webglColorRenderbuffer.length;ae++)E.__webglColorRenderbuffer[ae]&&r.deleteRenderbuffer(E.__webglColorRenderbuffer[ae]);E.__webglDepthRenderbuffer&&r.deleteRenderbuffer(E.__webglDepthRenderbuffer)}const W=N.textures;for(let ae=0,ve=W.length;ae<ve;ae++){const ce=n.get(W[ae]);ce.__webglTexture&&(r.deleteTexture(ce.__webglTexture),a.memory.textures--),n.remove(W[ae])}n.remove(N)}let R=0;function k(){R=0}function O(){const N=R;return N>=i.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+N+" texture units while this GPU supports only "+i.maxTextures),R+=1,N}function H(N){const E=[];return E.push(N.wrapS),E.push(N.wrapT),E.push(N.wrapR||0),E.push(N.magFilter),E.push(N.minFilter),E.push(N.anisotropy),E.push(N.internalFormat),E.push(N.format),E.push(N.type),E.push(N.generateMipmaps),E.push(N.premultiplyAlpha),E.push(N.flipY),E.push(N.unpackAlignment),E.push(N.colorSpace),E.join()}function q(N,E){const W=n.get(N);if(N.isVideoTexture&&Se(N),N.isRenderTargetTexture===!1&&N.version>0&&W.__version!==N.version){const ae=N.image;if(ae===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(ae.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{X(W,N,E);return}}t.bindTexture(r.TEXTURE_2D,W.__webglTexture,r.TEXTURE0+E)}function G(N,E){const W=n.get(N);if(N.version>0&&W.__version!==N.version){X(W,N,E);return}t.bindTexture(r.TEXTURE_2D_ARRAY,W.__webglTexture,r.TEXTURE0+E)}function K(N,E){const W=n.get(N);if(N.version>0&&W.__version!==N.version){X(W,N,E);return}t.bindTexture(r.TEXTURE_3D,W.__webglTexture,r.TEXTURE0+E)}function V(N,E){const W=n.get(N);if(N.version>0&&W.__version!==N.version){ee(W,N,E);return}t.bindTexture(r.TEXTURE_CUBE_MAP,W.__webglTexture,r.TEXTURE0+E)}const Y={[Li]:r.REPEAT,[ui]:r.CLAMP_TO_EDGE,[yc]:r.MIRRORED_REPEAT},le={[Sn]:r.NEAREST,[ob]:r.NEAREST_MIPMAP_NEAREST,[ro]:r.NEAREST_MIPMAP_LINEAR,[bn]:r.LINEAR,[oc]:r.LINEAR_MIPMAP_NEAREST,[ji]:r.LINEAR_MIPMAP_LINEAR},se={[Ex]:r.NEVER,[Dx]:r.ALWAYS,[Ax]:r.LESS,[yb]:r.LEQUAL,[Cx]:r.EQUAL,[Nx]:r.GEQUAL,[Px]:r.GREATER,[Rx]:r.NOTEQUAL};function ge(N,E){if(E.type===_i&&e.has("OES_texture_float_linear")===!1&&(E.magFilter===bn||E.magFilter===oc||E.magFilter===ro||E.magFilter===ji||E.minFilter===bn||E.minFilter===oc||E.minFilter===ro||E.minFilter===ji)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),r.texParameteri(N,r.TEXTURE_WRAP_S,Y[E.wrapS]),r.texParameteri(N,r.TEXTURE_WRAP_T,Y[E.wrapT]),(N===r.TEXTURE_3D||N===r.TEXTURE_2D_ARRAY)&&r.texParameteri(N,r.TEXTURE_WRAP_R,Y[E.wrapR]),r.texParameteri(N,r.TEXTURE_MAG_FILTER,le[E.magFilter]),r.texParameteri(N,r.TEXTURE_MIN_FILTER,le[E.minFilter]),E.compareFunction&&(r.texParameteri(N,r.TEXTURE_COMPARE_MODE,r.COMPARE_REF_TO_TEXTURE),r.texParameteri(N,r.TEXTURE_COMPARE_FUNC,se[E.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(E.magFilter===Sn||E.minFilter!==ro&&E.minFilter!==ji||E.type===_i&&e.has("OES_texture_float_linear")===!1)return;if(E.anisotropy>1||n.get(E).__currentAnisotropy){const W=e.get("EXT_texture_filter_anisotropic");r.texParameterf(N,W.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(E.anisotropy,i.getMaxAnisotropy())),n.get(E).__currentAnisotropy=E.anisotropy}}}function de(N,E){let W=!1;N.__webglInit===void 0&&(N.__webglInit=!0,E.addEventListener("dispose",T));const ae=E.source;let ve=u.get(ae);ve===void 0&&(ve={},u.set(ae,ve));const ce=H(E);if(ce!==N.__cacheKey){ve[ce]===void 0&&(ve[ce]={texture:r.createTexture(),usedTimes:0},a.memory.textures++,W=!0),ve[ce].usedTimes++;const Oe=ve[N.__cacheKey];Oe!==void 0&&(ve[N.__cacheKey].usedTimes--,Oe.usedTimes===0&&_(E)),N.__cacheKey=ce,N.__webglTexture=ve[ce].texture}return W}function X(N,E,W){let ae=r.TEXTURE_2D;(E.isDataArrayTexture||E.isCompressedArrayTexture)&&(ae=r.TEXTURE_2D_ARRAY),E.isData3DTexture&&(ae=r.TEXTURE_3D);const ve=de(N,E),ce=E.source;t.bindTexture(ae,N.__webglTexture,r.TEXTURE0+W);const Oe=n.get(ce);if(ce.version!==Oe.__version||ve===!0){t.activeTexture(r.TEXTURE0+W);const Pe=ft.getPrimaries(ft.workingColorSpace),Ve=E.colorSpace===zs?null:ft.getPrimaries(E.colorSpace),te=E.colorSpace===zs||Pe===Ve?r.NONE:r.BROWSER_DEFAULT_WEBGL;r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,E.flipY),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,E.premultiplyAlpha),r.pixelStorei(r.UNPACK_ALIGNMENT,E.unpackAlignment),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,te);let re=b(E.image,!1,i.maxTextureSize);re=et(E,re);const De=s.convert(E.format,E.colorSpace),Ye=s.convert(E.type);let xe=x(E.internalFormat,De,Ye,E.colorSpace,E.isVideoTexture);ge(ae,E);let Le;const ct=E.mipmaps,rt=E.isVideoTexture!==!0,Rt=Oe.__version===void 0||ve===!0,Q=ce.dataReady,Ge=P(E,re);if(E.isDepthTexture)xe=w(E.format===wa,E.type),Rt&&(rt?t.texStorage2D(r.TEXTURE_2D,1,xe,re.width,re.height):t.texImage2D(r.TEXTURE_2D,0,xe,re.width,re.height,0,De,Ye,null));else if(E.isDataTexture)if(ct.length>0){rt&&Rt&&t.texStorage2D(r.TEXTURE_2D,Ge,xe,ct[0].width,ct[0].height);for(let ye=0,Me=ct.length;ye<Me;ye++)Le=ct[ye],rt?Q&&t.texSubImage2D(r.TEXTURE_2D,ye,0,0,Le.width,Le.height,De,Ye,Le.data):t.texImage2D(r.TEXTURE_2D,ye,xe,Le.width,Le.height,0,De,Ye,Le.data);E.generateMipmaps=!1}else rt?(Rt&&t.texStorage2D(r.TEXTURE_2D,Ge,xe,re.width,re.height),Q&&t.texSubImage2D(r.TEXTURE_2D,0,0,0,re.width,re.height,De,Ye,re.data)):t.texImage2D(r.TEXTURE_2D,0,xe,re.width,re.height,0,De,Ye,re.data);else if(E.isCompressedTexture)if(E.isCompressedArrayTexture){rt&&Rt&&t.texStorage3D(r.TEXTURE_2D_ARRAY,Ge,xe,ct[0].width,ct[0].height,re.depth);for(let ye=0,Me=ct.length;ye<Me;ye++)if(Le=ct[ye],E.format!==Dn)if(De!==null)if(rt){if(Q)if(E.layerUpdates.size>0){const Ze=Ip(Le.width,Le.height,E.format,E.type);for(const Xe of E.layerUpdates){const vt=Le.data.subarray(Xe*Ze/Le.data.BYTES_PER_ELEMENT,(Xe+1)*Ze/Le.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(r.TEXTURE_2D_ARRAY,ye,0,0,Xe,Le.width,Le.height,1,De,vt)}E.clearLayerUpdates()}else t.compressedTexSubImage3D(r.TEXTURE_2D_ARRAY,ye,0,0,0,Le.width,Le.height,re.depth,De,Le.data)}else t.compressedTexImage3D(r.TEXTURE_2D_ARRAY,ye,xe,Le.width,Le.height,re.depth,0,Le.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else rt?Q&&t.texSubImage3D(r.TEXTURE_2D_ARRAY,ye,0,0,0,Le.width,Le.height,re.depth,De,Ye,Le.data):t.texImage3D(r.TEXTURE_2D_ARRAY,ye,xe,Le.width,Le.height,re.depth,0,De,Ye,Le.data)}else{rt&&Rt&&t.texStorage2D(r.TEXTURE_2D,Ge,xe,ct[0].width,ct[0].height);for(let ye=0,Me=ct.length;ye<Me;ye++)Le=ct[ye],E.format!==Dn?De!==null?rt?Q&&t.compressedTexSubImage2D(r.TEXTURE_2D,ye,0,0,Le.width,Le.height,De,Le.data):t.compressedTexImage2D(r.TEXTURE_2D,ye,xe,Le.width,Le.height,0,Le.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):rt?Q&&t.texSubImage2D(r.TEXTURE_2D,ye,0,0,Le.width,Le.height,De,Ye,Le.data):t.texImage2D(r.TEXTURE_2D,ye,xe,Le.width,Le.height,0,De,Ye,Le.data)}else if(E.isDataArrayTexture)if(rt){if(Rt&&t.texStorage3D(r.TEXTURE_2D_ARRAY,Ge,xe,re.width,re.height,re.depth),Q)if(E.layerUpdates.size>0){const ye=Ip(re.width,re.height,E.format,E.type);for(const Me of E.layerUpdates){const Ze=re.data.subarray(Me*ye/re.data.BYTES_PER_ELEMENT,(Me+1)*ye/re.data.BYTES_PER_ELEMENT);t.texSubImage3D(r.TEXTURE_2D_ARRAY,0,0,0,Me,re.width,re.height,1,De,Ye,Ze)}E.clearLayerUpdates()}else t.texSubImage3D(r.TEXTURE_2D_ARRAY,0,0,0,0,re.width,re.height,re.depth,De,Ye,re.data)}else t.texImage3D(r.TEXTURE_2D_ARRAY,0,xe,re.width,re.height,re.depth,0,De,Ye,re.data);else if(E.isData3DTexture)rt?(Rt&&t.texStorage3D(r.TEXTURE_3D,Ge,xe,re.width,re.height,re.depth),Q&&t.texSubImage3D(r.TEXTURE_3D,0,0,0,0,re.width,re.height,re.depth,De,Ye,re.data)):t.texImage3D(r.TEXTURE_3D,0,xe,re.width,re.height,re.depth,0,De,Ye,re.data);else if(E.isFramebufferTexture){if(Rt)if(rt)t.texStorage2D(r.TEXTURE_2D,Ge,xe,re.width,re.height);else{let ye=re.width,Me=re.height;for(let Ze=0;Ze<Ge;Ze++)t.texImage2D(r.TEXTURE_2D,Ze,xe,ye,Me,0,De,Ye,null),ye>>=1,Me>>=1}}else if(ct.length>0){if(rt&&Rt){const ye=Be(ct[0]);t.texStorage2D(r.TEXTURE_2D,Ge,xe,ye.width,ye.height)}for(let ye=0,Me=ct.length;ye<Me;ye++)Le=ct[ye],rt?Q&&t.texSubImage2D(r.TEXTURE_2D,ye,0,0,De,Ye,Le):t.texImage2D(r.TEXTURE_2D,ye,xe,De,Ye,Le);E.generateMipmaps=!1}else if(rt){if(Rt){const ye=Be(re);t.texStorage2D(r.TEXTURE_2D,Ge,xe,ye.width,ye.height)}Q&&t.texSubImage2D(r.TEXTURE_2D,0,0,0,De,Ye,re)}else t.texImage2D(r.TEXTURE_2D,0,xe,De,Ye,re);p(E)&&g(ae),Oe.__version=ce.version,E.onUpdate&&E.onUpdate(E)}N.__version=E.version}function ee(N,E,W){if(E.image.length!==6)return;const ae=de(N,E),ve=E.source;t.bindTexture(r.TEXTURE_CUBE_MAP,N.__webglTexture,r.TEXTURE0+W);const ce=n.get(ve);if(ve.version!==ce.__version||ae===!0){t.activeTexture(r.TEXTURE0+W);const Oe=ft.getPrimaries(ft.workingColorSpace),Pe=E.colorSpace===zs?null:ft.getPrimaries(E.colorSpace),Ve=E.colorSpace===zs||Oe===Pe?r.NONE:r.BROWSER_DEFAULT_WEBGL;r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,E.flipY),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,E.premultiplyAlpha),r.pixelStorei(r.UNPACK_ALIGNMENT,E.unpackAlignment),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ve);const te=E.isCompressedTexture||E.image[0].isCompressedTexture,re=E.image[0]&&E.image[0].isDataTexture,De=[];for(let Me=0;Me<6;Me++)!te&&!re?De[Me]=b(E.image[Me],!0,i.maxCubemapSize):De[Me]=re?E.image[Me].image:E.image[Me],De[Me]=et(E,De[Me]);const Ye=De[0],xe=s.convert(E.format,E.colorSpace),Le=s.convert(E.type),ct=x(E.internalFormat,xe,Le,E.colorSpace),rt=E.isVideoTexture!==!0,Rt=ce.__version===void 0||ae===!0,Q=ve.dataReady;let Ge=P(E,Ye);ge(r.TEXTURE_CUBE_MAP,E);let ye;if(te){rt&&Rt&&t.texStorage2D(r.TEXTURE_CUBE_MAP,Ge,ct,Ye.width,Ye.height);for(let Me=0;Me<6;Me++){ye=De[Me].mipmaps;for(let Ze=0;Ze<ye.length;Ze++){const Xe=ye[Ze];E.format!==Dn?xe!==null?rt?Q&&t.compressedTexSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Me,Ze,0,0,Xe.width,Xe.height,xe,Xe.data):t.compressedTexImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Me,Ze,ct,Xe.width,Xe.height,0,Xe.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):rt?Q&&t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Me,Ze,0,0,Xe.width,Xe.height,xe,Le,Xe.data):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Me,Ze,ct,Xe.width,Xe.height,0,xe,Le,Xe.data)}}}else{if(ye=E.mipmaps,rt&&Rt){ye.length>0&&Ge++;const Me=Be(De[0]);t.texStorage2D(r.TEXTURE_CUBE_MAP,Ge,ct,Me.width,Me.height)}for(let Me=0;Me<6;Me++)if(re){rt?Q&&t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Me,0,0,0,De[Me].width,De[Me].height,xe,Le,De[Me].data):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Me,0,ct,De[Me].width,De[Me].height,0,xe,Le,De[Me].data);for(let Ze=0;Ze<ye.length;Ze++){const vt=ye[Ze].image[Me].image;rt?Q&&t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Me,Ze+1,0,0,vt.width,vt.height,xe,Le,vt.data):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Me,Ze+1,ct,vt.width,vt.height,0,xe,Le,vt.data)}}else{rt?Q&&t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Me,0,0,0,xe,Le,De[Me]):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Me,0,ct,xe,Le,De[Me]);for(let Ze=0;Ze<ye.length;Ze++){const Xe=ye[Ze];rt?Q&&t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Me,Ze+1,0,0,xe,Le,Xe.image[Me]):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Me,Ze+1,ct,xe,Le,Xe.image[Me])}}}p(E)&&g(r.TEXTURE_CUBE_MAP),ce.__version=ve.version,E.onUpdate&&E.onUpdate(E)}N.__version=E.version}function ie(N,E,W,ae,ve,ce){const Oe=s.convert(W.format,W.colorSpace),Pe=s.convert(W.type),Ve=x(W.internalFormat,Oe,Pe,W.colorSpace),te=n.get(E),re=n.get(W);if(re.__renderTarget=E,!te.__hasExternalTextures){const De=Math.max(1,E.width>>ce),Ye=Math.max(1,E.height>>ce);ve===r.TEXTURE_3D||ve===r.TEXTURE_2D_ARRAY?t.texImage3D(ve,ce,Ve,De,Ye,E.depth,0,Oe,Pe,null):t.texImage2D(ve,ce,Ve,De,Ye,0,Oe,Pe,null)}t.bindFramebuffer(r.FRAMEBUFFER,N),Te(E)?o.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,ae,ve,re.__webglTexture,0,Ue(E)):(ve===r.TEXTURE_2D||ve>=r.TEXTURE_CUBE_MAP_POSITIVE_X&&ve<=r.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&r.framebufferTexture2D(r.FRAMEBUFFER,ae,ve,re.__webglTexture,ce),t.bindFramebuffer(r.FRAMEBUFFER,null)}function Z(N,E,W){if(r.bindRenderbuffer(r.RENDERBUFFER,N),E.depthBuffer){const ae=E.depthTexture,ve=ae&&ae.isDepthTexture?ae.type:null,ce=w(E.stencilBuffer,ve),Oe=E.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,Pe=Ue(E);Te(E)?o.renderbufferStorageMultisampleEXT(r.RENDERBUFFER,Pe,ce,E.width,E.height):W?r.renderbufferStorageMultisample(r.RENDERBUFFER,Pe,ce,E.width,E.height):r.renderbufferStorage(r.RENDERBUFFER,ce,E.width,E.height),r.framebufferRenderbuffer(r.FRAMEBUFFER,Oe,r.RENDERBUFFER,N)}else{const ae=E.textures;for(let ve=0;ve<ae.length;ve++){const ce=ae[ve],Oe=s.convert(ce.format,ce.colorSpace),Pe=s.convert(ce.type),Ve=x(ce.internalFormat,Oe,Pe,ce.colorSpace),te=Ue(E);W&&Te(E)===!1?r.renderbufferStorageMultisample(r.RENDERBUFFER,te,Ve,E.width,E.height):Te(E)?o.renderbufferStorageMultisampleEXT(r.RENDERBUFFER,te,Ve,E.width,E.height):r.renderbufferStorage(r.RENDERBUFFER,Ve,E.width,E.height)}}r.bindRenderbuffer(r.RENDERBUFFER,null)}function ue(N,E){if(E&&E.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(r.FRAMEBUFFER,N),!(E.depthTexture&&E.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const ae=n.get(E.depthTexture);ae.__renderTarget=E,(!ae.__webglTexture||E.depthTexture.image.width!==E.width||E.depthTexture.image.height!==E.height)&&(E.depthTexture.image.width=E.width,E.depthTexture.image.height=E.height,E.depthTexture.needsUpdate=!0),q(E.depthTexture,0);const ve=ae.__webglTexture,ce=Ue(E);if(E.depthTexture.format===ha)Te(E)?o.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,r.DEPTH_ATTACHMENT,r.TEXTURE_2D,ve,0,ce):r.framebufferTexture2D(r.FRAMEBUFFER,r.DEPTH_ATTACHMENT,r.TEXTURE_2D,ve,0);else if(E.depthTexture.format===wa)Te(E)?o.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.TEXTURE_2D,ve,0,ce):r.framebufferTexture2D(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.TEXTURE_2D,ve,0);else throw new Error("Unknown depthTexture format")}function oe(N){const E=n.get(N),W=N.isWebGLCubeRenderTarget===!0;if(E.__boundDepthTexture!==N.depthTexture){const ae=N.depthTexture;if(E.__depthDisposeCallback&&E.__depthDisposeCallback(),ae){const ve=()=>{delete E.__boundDepthTexture,delete E.__depthDisposeCallback,ae.removeEventListener("dispose",ve)};ae.addEventListener("dispose",ve),E.__depthDisposeCallback=ve}E.__boundDepthTexture=ae}if(N.depthTexture&&!E.__autoAllocateDepthBuffer){if(W)throw new Error("target.depthTexture not supported in Cube render targets");ue(E.__webglFramebuffer,N)}else if(W){E.__webglDepthbuffer=[];for(let ae=0;ae<6;ae++)if(t.bindFramebuffer(r.FRAMEBUFFER,E.__webglFramebuffer[ae]),E.__webglDepthbuffer[ae]===void 0)E.__webglDepthbuffer[ae]=r.createRenderbuffer(),Z(E.__webglDepthbuffer[ae],N,!1);else{const ve=N.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,ce=E.__webglDepthbuffer[ae];r.bindRenderbuffer(r.RENDERBUFFER,ce),r.framebufferRenderbuffer(r.FRAMEBUFFER,ve,r.RENDERBUFFER,ce)}}else if(t.bindFramebuffer(r.FRAMEBUFFER,E.__webglFramebuffer),E.__webglDepthbuffer===void 0)E.__webglDepthbuffer=r.createRenderbuffer(),Z(E.__webglDepthbuffer,N,!1);else{const ae=N.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,ve=E.__webglDepthbuffer;r.bindRenderbuffer(r.RENDERBUFFER,ve),r.framebufferRenderbuffer(r.FRAMEBUFFER,ae,r.RENDERBUFFER,ve)}t.bindFramebuffer(r.FRAMEBUFFER,null)}function be(N,E,W){const ae=n.get(N);E!==void 0&&ie(ae.__webglFramebuffer,N,N.texture,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,0),W!==void 0&&oe(N)}function Ce(N){const E=N.texture,W=n.get(N),ae=n.get(E);N.addEventListener("dispose",A);const ve=N.textures,ce=N.isWebGLCubeRenderTarget===!0,Oe=ve.length>1;if(Oe||(ae.__webglTexture===void 0&&(ae.__webglTexture=r.createTexture()),ae.__version=E.version,a.memory.textures++),ce){W.__webglFramebuffer=[];for(let Pe=0;Pe<6;Pe++)if(E.mipmaps&&E.mipmaps.length>0){W.__webglFramebuffer[Pe]=[];for(let Ve=0;Ve<E.mipmaps.length;Ve++)W.__webglFramebuffer[Pe][Ve]=r.createFramebuffer()}else W.__webglFramebuffer[Pe]=r.createFramebuffer()}else{if(E.mipmaps&&E.mipmaps.length>0){W.__webglFramebuffer=[];for(let Pe=0;Pe<E.mipmaps.length;Pe++)W.__webglFramebuffer[Pe]=r.createFramebuffer()}else W.__webglFramebuffer=r.createFramebuffer();if(Oe)for(let Pe=0,Ve=ve.length;Pe<Ve;Pe++){const te=n.get(ve[Pe]);te.__webglTexture===void 0&&(te.__webglTexture=r.createTexture(),a.memory.textures++)}if(N.samples>0&&Te(N)===!1){W.__webglMultisampledFramebuffer=r.createFramebuffer(),W.__webglColorRenderbuffer=[],t.bindFramebuffer(r.FRAMEBUFFER,W.__webglMultisampledFramebuffer);for(let Pe=0;Pe<ve.length;Pe++){const Ve=ve[Pe];W.__webglColorRenderbuffer[Pe]=r.createRenderbuffer(),r.bindRenderbuffer(r.RENDERBUFFER,W.__webglColorRenderbuffer[Pe]);const te=s.convert(Ve.format,Ve.colorSpace),re=s.convert(Ve.type),De=x(Ve.internalFormat,te,re,Ve.colorSpace,N.isXRRenderTarget===!0),Ye=Ue(N);r.renderbufferStorageMultisample(r.RENDERBUFFER,Ye,De,N.width,N.height),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+Pe,r.RENDERBUFFER,W.__webglColorRenderbuffer[Pe])}r.bindRenderbuffer(r.RENDERBUFFER,null),N.depthBuffer&&(W.__webglDepthRenderbuffer=r.createRenderbuffer(),Z(W.__webglDepthRenderbuffer,N,!0)),t.bindFramebuffer(r.FRAMEBUFFER,null)}}if(ce){t.bindTexture(r.TEXTURE_CUBE_MAP,ae.__webglTexture),ge(r.TEXTURE_CUBE_MAP,E);for(let Pe=0;Pe<6;Pe++)if(E.mipmaps&&E.mipmaps.length>0)for(let Ve=0;Ve<E.mipmaps.length;Ve++)ie(W.__webglFramebuffer[Pe][Ve],N,E,r.COLOR_ATTACHMENT0,r.TEXTURE_CUBE_MAP_POSITIVE_X+Pe,Ve);else ie(W.__webglFramebuffer[Pe],N,E,r.COLOR_ATTACHMENT0,r.TEXTURE_CUBE_MAP_POSITIVE_X+Pe,0);p(E)&&g(r.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(Oe){for(let Pe=0,Ve=ve.length;Pe<Ve;Pe++){const te=ve[Pe],re=n.get(te);t.bindTexture(r.TEXTURE_2D,re.__webglTexture),ge(r.TEXTURE_2D,te),ie(W.__webglFramebuffer,N,te,r.COLOR_ATTACHMENT0+Pe,r.TEXTURE_2D,0),p(te)&&g(r.TEXTURE_2D)}t.unbindTexture()}else{let Pe=r.TEXTURE_2D;if((N.isWebGL3DRenderTarget||N.isWebGLArrayRenderTarget)&&(Pe=N.isWebGL3DRenderTarget?r.TEXTURE_3D:r.TEXTURE_2D_ARRAY),t.bindTexture(Pe,ae.__webglTexture),ge(Pe,E),E.mipmaps&&E.mipmaps.length>0)for(let Ve=0;Ve<E.mipmaps.length;Ve++)ie(W.__webglFramebuffer[Ve],N,E,r.COLOR_ATTACHMENT0,Pe,Ve);else ie(W.__webglFramebuffer,N,E,r.COLOR_ATTACHMENT0,Pe,0);p(E)&&g(Pe),t.unbindTexture()}N.depthBuffer&&oe(N)}function je(N){const E=N.textures;for(let W=0,ae=E.length;W<ae;W++){const ve=E[W];if(p(ve)){const ce=y(N),Oe=n.get(ve).__webglTexture;t.bindTexture(ce,Oe),g(ce),t.unbindTexture()}}}const Fe=[],j=[];function Ke(N){if(N.samples>0){if(Te(N)===!1){const E=N.textures,W=N.width,ae=N.height;let ve=r.COLOR_BUFFER_BIT;const ce=N.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,Oe=n.get(N),Pe=E.length>1;if(Pe)for(let Ve=0;Ve<E.length;Ve++)t.bindFramebuffer(r.FRAMEBUFFER,Oe.__webglMultisampledFramebuffer),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+Ve,r.RENDERBUFFER,null),t.bindFramebuffer(r.FRAMEBUFFER,Oe.__webglFramebuffer),r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,r.COLOR_ATTACHMENT0+Ve,r.TEXTURE_2D,null,0);t.bindFramebuffer(r.READ_FRAMEBUFFER,Oe.__webglMultisampledFramebuffer),t.bindFramebuffer(r.DRAW_FRAMEBUFFER,Oe.__webglFramebuffer);for(let Ve=0;Ve<E.length;Ve++){if(N.resolveDepthBuffer&&(N.depthBuffer&&(ve|=r.DEPTH_BUFFER_BIT),N.stencilBuffer&&N.resolveStencilBuffer&&(ve|=r.STENCIL_BUFFER_BIT)),Pe){r.framebufferRenderbuffer(r.READ_FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.RENDERBUFFER,Oe.__webglColorRenderbuffer[Ve]);const te=n.get(E[Ve]).__webglTexture;r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,te,0)}r.blitFramebuffer(0,0,W,ae,0,0,W,ae,ve,r.NEAREST),l===!0&&(Fe.length=0,j.length=0,Fe.push(r.COLOR_ATTACHMENT0+Ve),N.depthBuffer&&N.resolveDepthBuffer===!1&&(Fe.push(ce),j.push(ce),r.invalidateFramebuffer(r.DRAW_FRAMEBUFFER,j)),r.invalidateFramebuffer(r.READ_FRAMEBUFFER,Fe))}if(t.bindFramebuffer(r.READ_FRAMEBUFFER,null),t.bindFramebuffer(r.DRAW_FRAMEBUFFER,null),Pe)for(let Ve=0;Ve<E.length;Ve++){t.bindFramebuffer(r.FRAMEBUFFER,Oe.__webglMultisampledFramebuffer),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+Ve,r.RENDERBUFFER,Oe.__webglColorRenderbuffer[Ve]);const te=n.get(E[Ve]).__webglTexture;t.bindFramebuffer(r.FRAMEBUFFER,Oe.__webglFramebuffer),r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,r.COLOR_ATTACHMENT0+Ve,r.TEXTURE_2D,te,0)}t.bindFramebuffer(r.DRAW_FRAMEBUFFER,Oe.__webglMultisampledFramebuffer)}else if(N.depthBuffer&&N.resolveDepthBuffer===!1&&l){const E=N.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT;r.invalidateFramebuffer(r.DRAW_FRAMEBUFFER,[E])}}}function Ue(N){return Math.min(i.maxSamples,N.samples)}function Te(N){const E=n.get(N);return N.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&E.__useRenderToTexture!==!1}function Se(N){const E=a.render.frame;d.get(N)!==E&&(d.set(N,E),N.update())}function et(N,E){const W=N.colorSpace,ae=N.format,ve=N.type;return N.isCompressedTexture===!0||N.isVideoTexture===!0||W!==$n&&W!==zs&&(ft.getTransfer(W)===Ht?(ae!==Dn||ve!==Ms)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",W)),E}function Be(N){return typeof HTMLImageElement<"u"&&N instanceof HTMLImageElement?(c.width=N.naturalWidth||N.width,c.height=N.naturalHeight||N.height):typeof VideoFrame<"u"&&N instanceof VideoFrame?(c.width=N.displayWidth,c.height=N.displayHeight):(c.width=N.width,c.height=N.height),c}this.allocateTextureUnit=O,this.resetTextureUnits=k,this.setTexture2D=q,this.setTexture2DArray=G,this.setTexture3D=K,this.setTextureCube=V,this.rebindTextures=be,this.setupRenderTarget=Ce,this.updateRenderTargetMipmap=je,this.updateMultisampleRenderTarget=Ke,this.setupDepthRenderbuffer=oe,this.setupFrameBufferTexture=ie,this.useMultisampledRTT=Te}function bE(r,e){function t(n,i=zs){let s;const a=ft.getTransfer(i);if(n===Ms)return r.UNSIGNED_BYTE;if(n===Du)return r.UNSIGNED_SHORT_4_4_4_4;if(n===Lu)return r.UNSIGNED_SHORT_5_5_5_1;if(n===db)return r.UNSIGNED_INT_5_9_9_9_REV;if(n===lb)return r.BYTE;if(n===cb)return r.SHORT;if(n===bo)return r.UNSIGNED_SHORT;if(n===Nu)return r.INT;if(n===Zs)return r.UNSIGNED_INT;if(n===_i)return r.FLOAT;if(n===Ri)return r.HALF_FLOAT;if(n===hb)return r.ALPHA;if(n===ub)return r.RGB;if(n===Dn)return r.RGBA;if(n===fb)return r.LUMINANCE;if(n===pb)return r.LUMINANCE_ALPHA;if(n===ha)return r.DEPTH_COMPONENT;if(n===wa)return r.DEPTH_STENCIL;if(n===Iu)return r.RED;if(n===Ic)return r.RED_INTEGER;if(n===mb)return r.RG;if(n===ku)return r.RG_INTEGER;if(n===Ou)return r.RGBA_INTEGER;if(n===lc||n===cc||n===dc||n===hc)if(a===Ht)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(n===lc)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===cc)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===dc)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===hc)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(n===lc)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===cc)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===dc)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===hc)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===Uh||n===Bh||n===zh||n===Hh)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(n===Uh)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===Bh)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===zh)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Hh)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===Gh||n===Vh||n===Wh)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(n===Gh||n===Vh)return a===Ht?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(n===Wh)return a===Ht?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===jh||n===Xh||n===qh||n===Zh||n===Yh||n===Kh||n===$h||n===Qh||n===Jh||n===eu||n===tu||n===nu||n===iu||n===su)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(n===jh)return a===Ht?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Xh)return a===Ht?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===qh)return a===Ht?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===Zh)return a===Ht?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Yh)return a===Ht?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===Kh)return a===Ht?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===$h)return a===Ht?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===Qh)return a===Ht?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===Jh)return a===Ht?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===eu)return a===Ht?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===tu)return a===Ht?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===nu)return a===Ht?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===iu)return a===Ht?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===su)return a===Ht?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===uc||n===ru||n===au)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(n===uc)return a===Ht?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===ru)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===au)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===gb||n===ou||n===lu||n===cu)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(n===uc)return s.COMPRESSED_RED_RGTC1_EXT;if(n===ou)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===lu)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===cu)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===_a?r.UNSIGNED_INT_24_8:r[n]!==void 0?r[n]:null}return{convert:t}}const vE=`
|
|
3833
3833
|
void main() {
|
|
3834
3834
|
|
|
3835
3835
|
gl_Position = vec4( position, 1.0 );
|
|
@@ -3853,7 +3853,7 @@ void main() {
|
|
|
3853
3853
|
|
|
3854
3854
|
}
|
|
3855
3855
|
|
|
3856
|
-
}`;class xE{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t,n){if(this.texture===null){const i=new Ut,s=e.properties.get(i);s.__webglTexture=t.texture,(t.depthNear!==n.depthNear||t.depthFar!==n.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=i}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,n=new wn({vertexShader:vE,fragmentShader:yE,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Ee(new $s(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class _E extends Er{constructor(e,t){super();const n=this;let i=null,s=1,a=null,o="local-floor",l=1,c=null,d=null,h=null,u=null,f=null,m=null;const b=new xE,p=t.getContextAttributes();let g=null,y=null;const x=[],w=[],P=new me;let T=null;const A=new gn;A.viewport=new _t;const M=new gn;M.viewport=new _t;const _=[A,M],S=new N_;let R=null,k=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(X){let ee=x[X];return ee===void 0&&(ee=new gd,x[X]=ee),ee.getTargetRaySpace()},this.getControllerGrip=function(X){let ee=x[X];return ee===void 0&&(ee=new gd,x[X]=ee),ee.getGripSpace()},this.getHand=function(X){let ee=x[X];return ee===void 0&&(ee=new gd,x[X]=ee),ee.getHandSpace()};function O(X){const ee=w.indexOf(X.inputSource);if(ee===-1)return;const ie=x[ee];ie!==void 0&&(ie.update(X.inputSource,X.frame,c||a),ie.dispatchEvent({type:X.type,data:X.inputSource}))}function H(){i.removeEventListener("select",O),i.removeEventListener("selectstart",O),i.removeEventListener("selectend",O),i.removeEventListener("squeeze",O),i.removeEventListener("squeezestart",O),i.removeEventListener("squeezeend",O),i.removeEventListener("end",H),i.removeEventListener("inputsourceschange",q);for(let X=0;X<x.length;X++){const ee=w[X];ee!==null&&(w[X]=null,x[X].disconnect(ee))}R=null,k=null,b.reset(),e.setRenderTarget(g),f=null,u=null,h=null,i=null,y=null,de.stop(),n.isPresenting=!1,e.setPixelRatio(T),e.setSize(P.width,P.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(X){s=X,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(X){o=X,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function(X){c=X},this.getBaseLayer=function(){return u!==null?u:f},this.getBinding=function(){return h},this.getFrame=function(){return m},this.getSession=function(){return i},this.setSession=async function(X){if(i=X,i!==null){if(g=e.getRenderTarget(),i.addEventListener("select",O),i.addEventListener("selectstart",O),i.addEventListener("selectend",O),i.addEventListener("squeeze",O),i.addEventListener("squeezestart",O),i.addEventListener("squeezeend",O),i.addEventListener("end",H),i.addEventListener("inputsourceschange",q),p.xrCompatible!==!0&&await t.makeXRCompatible(),T=e.getPixelRatio(),e.getSize(P),typeof XRWebGLBinding<"u"&&"createProjectionLayer"in XRWebGLBinding.prototype){let ie=null,Y=null,ue=null;p.depth&&(ue=p.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,ie=p.stencil?wa:ha,Y=p.stencil?_a:Zs);const oe={colorFormat:t.RGBA8,depthFormat:ue,scaleFactor:s};h=new XRWebGLBinding(i,t),u=h.createProjectionLayer(oe),i.updateRenderState({layers:[u]}),e.setPixelRatio(1),e.setSize(u.textureWidth,u.textureHeight,!1),y=new ni(u.textureWidth,u.textureHeight,{format:Dn,type:Ms,depthTexture:new Cb(u.textureWidth,u.textureHeight,Y,void 0,void 0,void 0,void 0,void 0,void 0,ie),stencilBuffer:p.stencil,colorSpace:e.outputColorSpace,samples:p.antialias?4:0,resolveDepthBuffer:u.ignoreDepthValues===!1,resolveStencilBuffer:u.ignoreDepthValues===!1})}else{const ie={antialias:p.antialias,alpha:!0,depth:p.depth,stencil:p.stencil,framebufferScaleFactor:s};f=new XRWebGLLayer(i,t,ie),i.updateRenderState({baseLayer:f}),e.setPixelRatio(1),e.setSize(f.framebufferWidth,f.framebufferHeight,!1),y=new ni(f.framebufferWidth,f.framebufferHeight,{format:Dn,type:Ms,colorSpace:e.outputColorSpace,stencilBuffer:p.stencil,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1})}y.isXRRenderTarget=!0,this.setFoveation(l),c=null,a=await i.requestReferenceSpace(o),de.setContext(i),de.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return b.getDepthTexture()};function q(X){for(let ee=0;ee<X.removed.length;ee++){const ie=X.removed[ee],Y=w.indexOf(ie);Y>=0&&(w[Y]=null,x[Y].disconnect(ie))}for(let ee=0;ee<X.added.length;ee++){const ie=X.added[ee];let Y=w.indexOf(ie);if(Y===-1){for(let oe=0;oe<x.length;oe++)if(oe>=w.length){w.push(ie),Y=oe;break}else if(w[oe]===null){w[oe]=ie,Y=oe;break}if(Y===-1)break}const ue=x[Y];ue&&ue.connect(ie)}}const G=new I,K=new I;function V(X,ee,ie){G.setFromMatrixPosition(ee.matrixWorld),K.setFromMatrixPosition(ie.matrixWorld);const Y=G.distanceTo(K),ue=ee.projectionMatrix.elements,oe=ie.projectionMatrix.elements,be=ue[14]/(ue[10]-1),Ce=ue[14]/(ue[10]+1),je=(ue[9]+1)/ue[5],Fe=(ue[9]-1)/ue[5],j=(ue[8]-1)/ue[0],Ke=(oe[8]+1)/oe[0],Ue=be*j,Te=be*Ke,Se=Y/(-j+Ke),et=Se*-j;if(ee.matrixWorld.decompose(X.position,X.quaternion,X.scale),X.translateX(et),X.translateZ(Se),X.matrixWorld.compose(X.position,X.quaternion,X.scale),X.matrixWorldInverse.copy(X.matrixWorld).invert(),ue[10]===-1)X.projectionMatrix.copy(ee.projectionMatrix),X.projectionMatrixInverse.copy(ee.projectionMatrixInverse);else{const Be=be+Se,N=Ce+Se,E=Ue-et,W=Te+(Y-et),ae=je*Ce/N*Be,ve=Fe*Ce/N*Be;X.projectionMatrix.makePerspective(E,W,ae,ve,Be,N),X.projectionMatrixInverse.copy(X.projectionMatrix).invert()}}function Z(X,ee){ee===null?X.matrixWorld.copy(X.matrix):X.matrixWorld.multiplyMatrices(ee.matrixWorld,X.matrix),X.matrixWorldInverse.copy(X.matrixWorld).invert()}this.updateCamera=function(X){if(i===null)return;let ee=X.near,ie=X.far;b.texture!==null&&(b.depthNear>0&&(ee=b.depthNear),b.depthFar>0&&(ie=b.depthFar)),S.near=M.near=A.near=ee,S.far=M.far=A.far=ie,(R!==S.near||k!==S.far)&&(i.updateRenderState({depthNear:S.near,depthFar:S.far}),R=S.near,k=S.far),A.layers.mask=X.layers.mask|2,M.layers.mask=X.layers.mask|4,S.layers.mask=A.layers.mask|M.layers.mask;const Y=X.parent,ue=S.cameras;Z(S,Y);for(let oe=0;oe<ue.length;oe++)Z(ue[oe],Y);ue.length===2?V(S,A,M):S.projectionMatrix.copy(A.projectionMatrix),le(X,S,Y)};function le(X,ee,ie){ie===null?X.matrix.copy(ee.matrixWorld):(X.matrix.copy(ie.matrixWorld),X.matrix.invert(),X.matrix.multiply(ee.matrixWorld)),X.matrix.decompose(X.position,X.quaternion,X.scale),X.updateMatrixWorld(!0),X.projectionMatrix.copy(ee.projectionMatrix),X.projectionMatrixInverse.copy(ee.projectionMatrixInverse),X.isPerspectiveCamera&&(X.fov=Sa*2*Math.atan(1/X.projectionMatrix.elements[5]),X.zoom=1)}this.getCamera=function(){return S},this.getFoveation=function(){if(!(u===null&&f===null))return l},this.setFoveation=function(X){l=X,u!==null&&(u.fixedFoveation=X),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=X)},this.hasDepthSensing=function(){return b.texture!==null},this.getDepthSensingMesh=function(){return b.getMesh(S)};let se=null;function ge(X,ee){if(d=ee.getViewerPose(c||a),m=ee,d!==null){const ie=d.views;f!==null&&(e.setRenderTargetFramebuffer(y,f.framebuffer),e.setRenderTarget(y));let Y=!1;ie.length!==S.cameras.length&&(S.cameras.length=0,Y=!0);for(let be=0;be<ie.length;be++){const Ce=ie[be];let je=null;if(f!==null)je=f.getViewport(Ce);else{const j=h.getViewSubImage(u,Ce);je=j.viewport,be===0&&(e.setRenderTargetTextures(y,j.colorTexture,u.ignoreDepthValues?void 0:j.depthStencilTexture),e.setRenderTarget(y))}let Fe=_[be];Fe===void 0&&(Fe=new gn,Fe.layers.enable(be),Fe.viewport=new _t,_[be]=Fe),Fe.matrix.fromArray(Ce.transform.matrix),Fe.matrix.decompose(Fe.position,Fe.quaternion,Fe.scale),Fe.projectionMatrix.fromArray(Ce.projectionMatrix),Fe.projectionMatrixInverse.copy(Fe.projectionMatrix).invert(),Fe.viewport.set(je.x,je.y,je.width,je.height),be===0&&(S.matrix.copy(Fe.matrix),S.matrix.decompose(S.position,S.quaternion,S.scale)),Y===!0&&S.cameras.push(Fe)}const ue=i.enabledFeatures;if(ue&&ue.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&h){const be=h.getDepthInformation(ie[0]);be&&be.isValid&&be.texture&&b.init(e,be,i.renderState)}}for(let ie=0;ie<x.length;ie++){const Y=w[ie],ue=x[ie];Y!==null&&ue!==void 0&&ue.update(Y,ee,c||a)}se&&se(X,ee),ee.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:ee}),m=null}const de=new Wb;de.setAnimationLoop(ge),this.setAnimationLoop=function(X){se=X},this.dispose=function(){}}}const or=new hn,wE=new Ie;function SE(r,e){function t(p,g){p.matrixAutoUpdate===!0&&p.updateMatrix(),g.value.copy(p.matrix)}function n(p,g){g.color.getRGB(p.fogColor.value,Sb(r)),g.isFog?(p.fogNear.value=g.near,p.fogFar.value=g.far):g.isFogExp2&&(p.fogDensity.value=g.density)}function i(p,g,y,x,w){g.isMeshBasicMaterial||g.isMeshLambertMaterial?s(p,g):g.isMeshToonMaterial?(s(p,g),h(p,g)):g.isMeshPhongMaterial?(s(p,g),d(p,g)):g.isMeshStandardMaterial?(s(p,g),u(p,g),g.isMeshPhysicalMaterial&&f(p,g,w)):g.isMeshMatcapMaterial?(s(p,g),m(p,g)):g.isMeshDepthMaterial?s(p,g):g.isMeshDistanceMaterial?(s(p,g),b(p,g)):g.isMeshNormalMaterial?s(p,g):g.isLineBasicMaterial?(a(p,g),g.isLineDashedMaterial&&o(p,g)):g.isPointsMaterial?l(p,g,y,x):g.isSpriteMaterial?c(p,g):g.isShadowMaterial?(p.color.value.copy(g.color),p.opacity.value=g.opacity):g.isShaderMaterial&&(g.uniformsNeedUpdate=!1)}function s(p,g){p.opacity.value=g.opacity,g.color&&p.diffuse.value.copy(g.color),g.emissive&&p.emissive.value.copy(g.emissive).multiplyScalar(g.emissiveIntensity),g.map&&(p.map.value=g.map,t(g.map,p.mapTransform)),g.alphaMap&&(p.alphaMap.value=g.alphaMap,t(g.alphaMap,p.alphaMapTransform)),g.bumpMap&&(p.bumpMap.value=g.bumpMap,t(g.bumpMap,p.bumpMapTransform),p.bumpScale.value=g.bumpScale,g.side===fi&&(p.bumpScale.value*=-1)),g.normalMap&&(p.normalMap.value=g.normalMap,t(g.normalMap,p.normalMapTransform),p.normalScale.value.copy(g.normalScale),g.side===fi&&p.normalScale.value.negate()),g.displacementMap&&(p.displacementMap.value=g.displacementMap,t(g.displacementMap,p.displacementMapTransform),p.displacementScale.value=g.displacementScale,p.displacementBias.value=g.displacementBias),g.emissiveMap&&(p.emissiveMap.value=g.emissiveMap,t(g.emissiveMap,p.emissiveMapTransform)),g.specularMap&&(p.specularMap.value=g.specularMap,t(g.specularMap,p.specularMapTransform)),g.alphaTest>0&&(p.alphaTest.value=g.alphaTest);const y=e.get(g),x=y.envMap,w=y.envMapRotation;x&&(p.envMap.value=x,or.copy(w),or.x*=-1,or.y*=-1,or.z*=-1,x.isCubeTexture&&x.isRenderTargetTexture===!1&&(or.y*=-1,or.z*=-1),p.envMapRotation.value.setFromMatrix4(wE.makeRotationFromEuler(or)),p.flipEnvMap.value=x.isCubeTexture&&x.isRenderTargetTexture===!1?-1:1,p.reflectivity.value=g.reflectivity,p.ior.value=g.ior,p.refractionRatio.value=g.refractionRatio),g.lightMap&&(p.lightMap.value=g.lightMap,p.lightMapIntensity.value=g.lightMapIntensity,t(g.lightMap,p.lightMapTransform)),g.aoMap&&(p.aoMap.value=g.aoMap,p.aoMapIntensity.value=g.aoMapIntensity,t(g.aoMap,p.aoMapTransform))}function a(p,g){p.diffuse.value.copy(g.color),p.opacity.value=g.opacity,g.map&&(p.map.value=g.map,t(g.map,p.mapTransform))}function o(p,g){p.dashSize.value=g.dashSize,p.totalSize.value=g.dashSize+g.gapSize,p.scale.value=g.scale}function l(p,g,y,x){p.diffuse.value.copy(g.color),p.opacity.value=g.opacity,p.size.value=g.size*y,p.scale.value=x*.5,g.map&&(p.map.value=g.map,t(g.map,p.uvTransform)),g.alphaMap&&(p.alphaMap.value=g.alphaMap,t(g.alphaMap,p.alphaMapTransform)),g.alphaTest>0&&(p.alphaTest.value=g.alphaTest)}function c(p,g){p.diffuse.value.copy(g.color),p.opacity.value=g.opacity,p.rotation.value=g.rotation,g.map&&(p.map.value=g.map,t(g.map,p.mapTransform)),g.alphaMap&&(p.alphaMap.value=g.alphaMap,t(g.alphaMap,p.alphaMapTransform)),g.alphaTest>0&&(p.alphaTest.value=g.alphaTest)}function d(p,g){p.specular.value.copy(g.specular),p.shininess.value=Math.max(g.shininess,1e-4)}function h(p,g){g.gradientMap&&(p.gradientMap.value=g.gradientMap)}function u(p,g){p.metalness.value=g.metalness,g.metalnessMap&&(p.metalnessMap.value=g.metalnessMap,t(g.metalnessMap,p.metalnessMapTransform)),p.roughness.value=g.roughness,g.roughnessMap&&(p.roughnessMap.value=g.roughnessMap,t(g.roughnessMap,p.roughnessMapTransform)),g.envMap&&(p.envMapIntensity.value=g.envMapIntensity)}function f(p,g,y){p.ior.value=g.ior,g.sheen>0&&(p.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),p.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap&&(p.sheenColorMap.value=g.sheenColorMap,t(g.sheenColorMap,p.sheenColorMapTransform)),g.sheenRoughnessMap&&(p.sheenRoughnessMap.value=g.sheenRoughnessMap,t(g.sheenRoughnessMap,p.sheenRoughnessMapTransform))),g.clearcoat>0&&(p.clearcoat.value=g.clearcoat,p.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap&&(p.clearcoatMap.value=g.clearcoatMap,t(g.clearcoatMap,p.clearcoatMapTransform)),g.clearcoatRoughnessMap&&(p.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap,t(g.clearcoatRoughnessMap,p.clearcoatRoughnessMapTransform)),g.clearcoatNormalMap&&(p.clearcoatNormalMap.value=g.clearcoatNormalMap,t(g.clearcoatNormalMap,p.clearcoatNormalMapTransform),p.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),g.side===fi&&p.clearcoatNormalScale.value.negate())),g.dispersion>0&&(p.dispersion.value=g.dispersion),g.iridescence>0&&(p.iridescence.value=g.iridescence,p.iridescenceIOR.value=g.iridescenceIOR,p.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],p.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap&&(p.iridescenceMap.value=g.iridescenceMap,t(g.iridescenceMap,p.iridescenceMapTransform)),g.iridescenceThicknessMap&&(p.iridescenceThicknessMap.value=g.iridescenceThicknessMap,t(g.iridescenceThicknessMap,p.iridescenceThicknessMapTransform))),g.transmission>0&&(p.transmission.value=g.transmission,p.transmissionSamplerMap.value=y.texture,p.transmissionSamplerSize.value.set(y.width,y.height),g.transmissionMap&&(p.transmissionMap.value=g.transmissionMap,t(g.transmissionMap,p.transmissionMapTransform)),p.thickness.value=g.thickness,g.thicknessMap&&(p.thicknessMap.value=g.thicknessMap,t(g.thicknessMap,p.thicknessMapTransform)),p.attenuationDistance.value=g.attenuationDistance,p.attenuationColor.value.copy(g.attenuationColor)),g.anisotropy>0&&(p.anisotropyVector.value.set(g.anisotropy*Math.cos(g.anisotropyRotation),g.anisotropy*Math.sin(g.anisotropyRotation)),g.anisotropyMap&&(p.anisotropyMap.value=g.anisotropyMap,t(g.anisotropyMap,p.anisotropyMapTransform))),p.specularIntensity.value=g.specularIntensity,p.specularColor.value.copy(g.specularColor),g.specularColorMap&&(p.specularColorMap.value=g.specularColorMap,t(g.specularColorMap,p.specularColorMapTransform)),g.specularIntensityMap&&(p.specularIntensityMap.value=g.specularIntensityMap,t(g.specularIntensityMap,p.specularIntensityMapTransform))}function m(p,g){g.matcap&&(p.matcap.value=g.matcap)}function b(p,g){const y=e.get(g).light;p.referencePosition.value.setFromMatrixPosition(y.matrixWorld),p.nearDistance.value=y.shadow.camera.near,p.farDistance.value=y.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:i}}function ME(r,e,t,n){let i={},s={},a=[];const o=r.getParameter(r.MAX_UNIFORM_BUFFER_BINDINGS);function l(y,x){const w=x.program;n.uniformBlockBinding(y,w)}function c(y,x){let w=i[y.id];w===void 0&&(m(y),w=d(y),i[y.id]=w,y.addEventListener("dispose",p));const P=x.program;n.updateUBOMapping(y,P);const T=e.render.frame;s[y.id]!==T&&(u(y),s[y.id]=T)}function d(y){const x=h();y.__bindingPointIndex=x;const w=r.createBuffer(),P=y.__size,T=y.usage;return r.bindBuffer(r.UNIFORM_BUFFER,w),r.bufferData(r.UNIFORM_BUFFER,P,T),r.bindBuffer(r.UNIFORM_BUFFER,null),r.bindBufferBase(r.UNIFORM_BUFFER,x,w),w}function h(){for(let y=0;y<o;y++)if(a.indexOf(y)===-1)return a.push(y),y;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function u(y){const x=i[y.id],w=y.uniforms,P=y.__cache;r.bindBuffer(r.UNIFORM_BUFFER,x);for(let T=0,A=w.length;T<A;T++){const M=Array.isArray(w[T])?w[T]:[w[T]];for(let _=0,S=M.length;_<S;_++){const R=M[_];if(f(R,T,_,P)===!0){const k=R.__offset,O=Array.isArray(R.value)?R.value:[R.value];let H=0;for(let q=0;q<O.length;q++){const G=O[q],K=b(G);typeof G=="number"||typeof G=="boolean"?(R.__data[0]=G,r.bufferSubData(r.UNIFORM_BUFFER,k+H,R.__data)):G.isMatrix3?(R.__data[0]=G.elements[0],R.__data[1]=G.elements[1],R.__data[2]=G.elements[2],R.__data[3]=0,R.__data[4]=G.elements[3],R.__data[5]=G.elements[4],R.__data[6]=G.elements[5],R.__data[7]=0,R.__data[8]=G.elements[6],R.__data[9]=G.elements[7],R.__data[10]=G.elements[8],R.__data[11]=0):(G.toArray(R.__data,H),H+=K.storage/Float32Array.BYTES_PER_ELEMENT)}r.bufferSubData(r.UNIFORM_BUFFER,k,R.__data)}}}r.bindBuffer(r.UNIFORM_BUFFER,null)}function f(y,x,w,P){const T=y.value,A=x+"_"+w;if(P[A]===void 0)return typeof T=="number"||typeof T=="boolean"?P[A]=T:P[A]=T.clone(),!0;{const M=P[A];if(typeof T=="number"||typeof T=="boolean"){if(M!==T)return P[A]=T,!0}else if(M.equals(T)===!1)return M.copy(T),!0}return!1}function m(y){const x=y.uniforms;let w=0;const P=16;for(let A=0,M=x.length;A<M;A++){const _=Array.isArray(x[A])?x[A]:[x[A]];for(let S=0,R=_.length;S<R;S++){const k=_[S],O=Array.isArray(k.value)?k.value:[k.value];for(let H=0,q=O.length;H<q;H++){const G=O[H],K=b(G),V=w%P,Z=V%K.boundary,le=V+Z;w+=Z,le!==0&&P-le<K.storage&&(w+=P-le),k.__data=new Float32Array(K.storage/Float32Array.BYTES_PER_ELEMENT),k.__offset=w,w+=K.storage}}}const T=w%P;return T>0&&(w+=P-T),y.__size=w,y.__cache={},this}function b(y){const x={boundary:0,storage:0};return typeof y=="number"||typeof y=="boolean"?(x.boundary=4,x.storage=4):y.isVector2?(x.boundary=8,x.storage=8):y.isVector3||y.isColor?(x.boundary=16,x.storage=12):y.isVector4?(x.boundary=16,x.storage=16):y.isMatrix3?(x.boundary=48,x.storage=48):y.isMatrix4?(x.boundary=64,x.storage=64):y.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",y),x}function p(y){const x=y.target;x.removeEventListener("dispose",p);const w=a.indexOf(x.__bindingPointIndex);a.splice(w,1),r.deleteBuffer(i[x.id]),delete i[x.id],delete s[x.id]}function g(){for(const y in i)r.deleteBuffer(i[y]);a=[],i={},s={}}return{bind:l,update:c,dispose:g}}class TE{constructor(e={}){const{canvas:t=Yx(),context:n=null,depth:i=!0,stencil:s=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:d="default",failIfMajorPerformanceCaveat:h=!1,reverseDepthBuffer:u=!1}=e;this.isWebGLRenderer=!0;let f;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");f=n.getContextAttributes().alpha}else f=a;const m=new Uint32Array(4),b=new Int32Array(4);let p=null,g=null;const y=[],x=[];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._outputColorSpace=gt,this.toneMapping=Xs,this.toneMappingExposure=1;const w=this;let P=!1,T=0,A=0,M=null,_=-1,S=null;const R=new _t,k=new _t;let O=null;const H=new Ne(0);let q=0,G=t.width,K=t.height,V=1,Z=null,le=null;const se=new _t(0,0,G,K),ge=new _t(0,0,G,K);let de=!1;const X=new No;let ee=!1,ie=!1;this.transmissionResolutionScale=1;const Y=new Ie,ue=new Ie,oe=new I,be=new _t,Ce={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let je=!1;function Fe(){return M===null?V:1}let j=n;function Ke(U,J){return t.getContext(U,J)}try{const U={alpha:!0,depth:i,stencil:s,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:d,failIfMajorPerformanceCaveat:h};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${yr}`),t.addEventListener("webglcontextlost",Me,!1),t.addEventListener("webglcontextrestored",Ze,!1),t.addEventListener("webglcontextcreationerror",Xe,!1),j===null){const J="webgl2";if(j=Ke(J,U),j===null)throw Ke(J)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(U){throw console.error("THREE.WebGLRenderer: "+U.message),U}let Ue,Te,Se,et,Be,N,E,W,ae,ve,ce,Oe,Pe,Ve,te,re,De,Ye,xe,Le,ct,rt,Rt,Q;function Ge(){Ue=new kM(j),Ue.init(),rt=new bE(j,Ue),Te=new CM(j,Ue,e,rt),Se=new mE(j,Ue),Te.reverseDepthBuffer&&u&&Se.buffers.depth.setReversed(!0),et=new UM(j),Be=new nE,N=new gE(j,Ue,Se,Be,Te,rt,et),E=new RM(w),W=new IM(w),ae=new W_(j),Rt=new EM(j,ae),ve=new OM(j,ae,et,Rt),ce=new zM(j,ve,ae,et),xe=new BM(j,Te,N),re=new PM(Be),Oe=new tE(w,E,W,Ue,Te,Rt,re),Pe=new SE(w,Be),Ve=new sE,te=new dE(Ue),Ye=new TM(w,E,W,Se,ce,f,l),De=new fE(w,ce,Te),Q=new ME(j,et,Te,Se),Le=new AM(j,Ue,et),ct=new FM(j,Ue,et),et.programs=Oe.programs,w.capabilities=Te,w.extensions=Ue,w.properties=Be,w.renderLists=Ve,w.shadowMap=De,w.state=Se,w.info=et}Ge();const ye=new _E(w,j);this.xr=ye,this.getContext=function(){return j},this.getContextAttributes=function(){return j.getContextAttributes()},this.forceContextLoss=function(){const U=Ue.get("WEBGL_lose_context");U&&U.loseContext()},this.forceContextRestore=function(){const U=Ue.get("WEBGL_lose_context");U&&U.restoreContext()},this.getPixelRatio=function(){return V},this.setPixelRatio=function(U){U!==void 0&&(V=U,this.setSize(G,K,!1))},this.getSize=function(U){return U.set(G,K)},this.setSize=function(U,J,he=!0){if(ye.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}G=U,K=J,t.width=Math.floor(U*V),t.height=Math.floor(J*V),he===!0&&(t.style.width=U+"px",t.style.height=J+"px"),this.setViewport(0,0,U,J)},this.getDrawingBufferSize=function(U){return U.set(G*V,K*V).floor()},this.setDrawingBufferSize=function(U,J,he){G=U,K=J,V=he,t.width=Math.floor(U*he),t.height=Math.floor(J*he),this.setViewport(0,0,U,J)},this.getCurrentViewport=function(U){return U.copy(R)},this.getViewport=function(U){return U.copy(se)},this.setViewport=function(U,J,he,fe){U.isVector4?se.set(U.x,U.y,U.z,U.w):se.set(U,J,he,fe),Se.viewport(R.copy(se).multiplyScalar(V).round())},this.getScissor=function(U){return U.copy(ge)},this.setScissor=function(U,J,he,fe){U.isVector4?ge.set(U.x,U.y,U.z,U.w):ge.set(U,J,he,fe),Se.scissor(k.copy(ge).multiplyScalar(V).round())},this.getScissorTest=function(){return de},this.setScissorTest=function(U){Se.setScissorTest(de=U)},this.setOpaqueSort=function(U){Z=U},this.setTransparentSort=function(U){le=U},this.getClearColor=function(U){return U.copy(Ye.getClearColor())},this.setClearColor=function(){Ye.setClearColor(...arguments)},this.getClearAlpha=function(){return Ye.getClearAlpha()},this.setClearAlpha=function(){Ye.setClearAlpha(...arguments)},this.clear=function(U=!0,J=!0,he=!0){let fe=0;if(U){let ne=!1;if(M!==null){const Re=M.texture.format;ne=Re===Ou||Re===ku||Re===Ic}if(ne){const Re=M.texture.type,We=Re===Ms||Re===Zs||Re===bo||Re===_a||Re===Du||Re===Lu,$e=Ye.getClearColor(),Je=Ye.getClearAlpha(),pt=$e.r,mt=$e.g,at=$e.b;We?(m[0]=pt,m[1]=mt,m[2]=at,m[3]=Je,j.clearBufferuiv(j.COLOR,0,m)):(b[0]=pt,b[1]=mt,b[2]=at,b[3]=Je,j.clearBufferiv(j.COLOR,0,b))}else fe|=j.COLOR_BUFFER_BIT}J&&(fe|=j.DEPTH_BUFFER_BIT),he&&(fe|=j.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),j.clear(fe)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",Me,!1),t.removeEventListener("webglcontextrestored",Ze,!1),t.removeEventListener("webglcontextcreationerror",Xe,!1),Ye.dispose(),Ve.dispose(),te.dispose(),Be.dispose(),E.dispose(),W.dispose(),ce.dispose(),Rt.dispose(),Q.dispose(),Oe.dispose(),ye.dispose(),ye.removeEventListener("sessionstart",zo),ye.removeEventListener("sessionend",Ho),os.stop()};function Me(U){U.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),P=!0}function Ze(){console.log("THREE.WebGLRenderer: Context Restored."),P=!1;const U=et.autoReset,J=De.enabled,he=De.autoUpdate,fe=De.needsUpdate,ne=De.type;Ge(),et.autoReset=U,De.enabled=J,De.autoUpdate=he,De.needsUpdate=fe,De.type=ne}function Xe(U){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",U.statusMessage)}function vt(U){const J=U.target;J.removeEventListener("dispose",vt),Qt(J)}function Qt(U){An(U),Be.remove(U)}function An(U){const J=Be.get(U).programs;J!==void 0&&(J.forEach(function(he){Oe.releaseProgram(he)}),U.isShaderMaterial&&Oe.releaseShaderCache(U))}this.renderBufferDirect=function(U,J,he,fe,ne,Re){J===null&&(J=Ce);const We=ne.isMesh&&ne.matrixWorld.determinant()<0,$e=Wc(U,J,he,fe,ne);Se.setMaterial(fe,We);let Je=he.index,pt=1;if(fe.wireframe===!0){if(Je=ve.getWireframeAttribute(he),Je===void 0)return;pt=2}const mt=he.drawRange,at=he.attributes.position;let St=mt.start*pt,It=(mt.start+mt.count)*pt;Re!==null&&(St=Math.max(St,Re.start*pt),It=Math.min(It,(Re.start+Re.count)*pt)),Je!==null?(St=Math.max(St,0),It=Math.min(It,Je.count)):at!=null&&(St=Math.max(St,0),It=Math.min(It,at.count));const an=It-St;if(an<0||an===1/0)return;Rt.setup(ne,fe,$e,he,Je);let nn,Nt=Le;if(Je!==null&&(nn=ae.get(Je),Nt=ct,Nt.setIndex(nn)),ne.isMesh)fe.wireframe===!0?(Se.setLineWidth(fe.wireframeLinewidth*Fe()),Nt.setMode(j.LINES)):Nt.setMode(j.TRIANGLES);else if(ne.isLine){let lt=fe.linewidth;lt===void 0&&(lt=1),Se.setLineWidth(lt*Fe()),ne.isLineSegments?Nt.setMode(j.LINES):ne.isLineLoop?Nt.setMode(j.LINE_LOOP):Nt.setMode(j.LINE_STRIP)}else ne.isPoints?Nt.setMode(j.POINTS):ne.isSprite&&Nt.setMode(j.TRIANGLES);if(ne.isBatchedMesh)if(ne._multiDrawInstances!==null)hr("THREE.WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),Nt.renderMultiDrawInstances(ne._multiDrawStarts,ne._multiDrawCounts,ne._multiDrawCount,ne._multiDrawInstances);else if(Ue.get("WEBGL_multi_draw"))Nt.renderMultiDraw(ne._multiDrawStarts,ne._multiDrawCounts,ne._multiDrawCount);else{const lt=ne._multiDrawStarts,yn=ne._multiDrawCounts,kt=ne._multiDrawCount,ri=Je?ae.get(Je).bytesPerElement:1,Kt=Be.get(fe).currentProgram.getUniforms();for(let Ln=0;Ln<kt;Ln++)Kt.setValue(j,"_gl_DrawID",Ln),Nt.render(lt[Ln]/ri,yn[Ln])}else if(ne.isInstancedMesh)Nt.renderInstances(St,an,ne.count);else if(he.isInstancedBufferGeometry){const lt=he._maxInstanceCount!==void 0?he._maxInstanceCount:1/0,yn=Math.min(he.instanceCount,lt);Nt.renderInstances(St,an,yn)}else Nt.render(St,an)};function wt(U,J,he){U.transparent===!0&&U.side===ln&&U.forceSinglePass===!1?(U.side=fi,U.needsUpdate=!0,Pr(U,J,he),U.side=Si,U.needsUpdate=!0,Pr(U,J,he),U.side=ln):Pr(U,J,he)}this.compile=function(U,J,he=null){he===null&&(he=U),g=te.get(he),g.init(J),x.push(g),he.traverseVisible(function(ne){ne.isLight&&ne.layers.test(J.layers)&&(g.pushLight(ne),ne.castShadow&&g.pushShadow(ne))}),U!==he&&U.traverseVisible(function(ne){ne.isLight&&ne.layers.test(J.layers)&&(g.pushLight(ne),ne.castShadow&&g.pushShadow(ne))}),g.setupLights();const fe=new Set;return U.traverse(function(ne){if(!(ne.isMesh||ne.isPoints||ne.isLine||ne.isSprite))return;const Re=ne.material;if(Re)if(Array.isArray(Re))for(let We=0;We<Re.length;We++){const $e=Re[We];wt($e,he,ne),fe.add($e)}else wt(Re,he,ne),fe.add(Re)}),g=x.pop(),fe},this.compileAsync=function(U,J,he=null){const fe=this.compile(U,J,he);return new Promise(ne=>{function Re(){if(fe.forEach(function(We){Be.get(We).currentProgram.isReady()&&fe.delete(We)}),fe.size===0){ne(U);return}setTimeout(Re,10)}Ue.get("KHR_parallel_shader_compile")!==null?Re():setTimeout(Re,10)})};let si=null;function Fi(U){si&&si(U)}function zo(){os.stop()}function Ho(){os.start()}const os=new Wb;os.setAnimationLoop(Fi),typeof self<"u"&&os.setContext(self),this.setAnimationLoop=function(U){si=U,ye.setAnimationLoop(U),U===null?os.stop():os.start()},ye.addEventListener("sessionstart",zo),ye.addEventListener("sessionend",Ho),this.render=function(U,J){if(J!==void 0&&J.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(P===!0)return;if(U.matrixWorldAutoUpdate===!0&&U.updateMatrixWorld(),J.parent===null&&J.matrixWorldAutoUpdate===!0&&J.updateMatrixWorld(),ye.enabled===!0&&ye.isPresenting===!0&&(ye.cameraAutoUpdate===!0&&ye.updateCamera(J),J=ye.getCamera()),U.isScene===!0&&U.onBeforeRender(w,U,J,M),g=te.get(U,x.length),g.init(J),x.push(g),ue.multiplyMatrices(J.projectionMatrix,J.matrixWorldInverse),X.setFromProjectionMatrix(ue),ie=this.localClippingEnabled,ee=re.init(this.clippingPlanes,ie),p=Ve.get(U,y.length),p.init(),y.push(p),ye.enabled===!0&&ye.isPresenting===!0){const Re=w.xr.getDepthSensingMesh();Re!==null&&ka(Re,J,-1/0,w.sortObjects)}ka(U,J,0,w.sortObjects),p.finish(),w.sortObjects===!0&&p.sort(Z,le),je=ye.enabled===!1||ye.isPresenting===!1||ye.hasDepthSensing()===!1,je&&Ye.addToRenderList(p,U),this.info.render.frame++,ee===!0&&re.beginShadows();const he=g.state.shadowsArray;De.render(he,U,J),ee===!0&&re.endShadows(),this.info.autoReset===!0&&this.info.reset();const fe=p.opaque,ne=p.transmissive;if(g.setupLights(),J.isArrayCamera){const Re=J.cameras;if(ne.length>0)for(let We=0,$e=Re.length;We<$e;We++){const Je=Re[We];Oa(fe,ne,U,Je)}je&&Ye.render(U);for(let We=0,$e=Re.length;We<$e;We++){const Je=Re[We];Go(p,U,Je,Je.viewport)}}else ne.length>0&&Oa(fe,ne,U,J),je&&Ye.render(U),Go(p,U,J);M!==null&&A===0&&(N.updateMultisampleRenderTarget(M),N.updateRenderTargetMipmap(M)),U.isScene===!0&&U.onAfterRender(w,U,J),Rt.resetDefaultState(),_=-1,S=null,x.pop(),x.length>0?(g=x[x.length-1],ee===!0&&re.setGlobalState(w.clippingPlanes,g.state.camera)):g=null,y.pop(),y.length>0?p=y[y.length-1]:p=null};function ka(U,J,he,fe){if(U.visible===!1)return;if(U.layers.test(J.layers)){if(U.isGroup)he=U.renderOrder;else if(U.isLOD)U.autoUpdate===!0&&U.update(J);else if(U.isLight)g.pushLight(U),U.castShadow&&g.pushShadow(U);else if(U.isSprite){if(!U.frustumCulled||X.intersectsSprite(U)){fe&&be.setFromMatrixPosition(U.matrixWorld).applyMatrix4(ue);const We=ce.update(U),$e=U.material;$e.visible&&p.push(U,We,$e,he,be.z,null)}}else if((U.isMesh||U.isLine||U.isPoints)&&(!U.frustumCulled||X.intersectsObject(U))){const We=ce.update(U),$e=U.material;if(fe&&(U.boundingSphere!==void 0?(U.boundingSphere===null&&U.computeBoundingSphere(),be.copy(U.boundingSphere.center)):(We.boundingSphere===null&&We.computeBoundingSphere(),be.copy(We.boundingSphere.center)),be.applyMatrix4(U.matrixWorld).applyMatrix4(ue)),Array.isArray($e)){const Je=We.groups;for(let pt=0,mt=Je.length;pt<mt;pt++){const at=Je[pt],St=$e[at.materialIndex];St&&St.visible&&p.push(U,We,St,he,be.z,at)}}else $e.visible&&p.push(U,We,$e,he,be.z,null)}}const Re=U.children;for(let We=0,$e=Re.length;We<$e;We++)ka(Re[We],J,he,fe)}function Go(U,J,he,fe){const ne=U.opaque,Re=U.transmissive,We=U.transparent;g.setupLightsView(he),ee===!0&&re.setGlobalState(w.clippingPlanes,he),fe&&Se.viewport(R.copy(fe)),ne.length>0&&Cr(ne,J,he),Re.length>0&&Cr(Re,J,he),We.length>0&&Cr(We,J,he),Se.buffers.depth.setTest(!0),Se.buffers.depth.setMask(!0),Se.buffers.color.setMask(!0),Se.setPolygonOffset(!1)}function Oa(U,J,he,fe){if((he.isScene===!0?he.overrideMaterial:null)!==null)return;g.state.transmissionRenderTarget[fe.id]===void 0&&(g.state.transmissionRenderTarget[fe.id]=new ni(1,1,{generateMipmaps:!0,type:Ue.has("EXT_color_buffer_half_float")||Ue.has("EXT_color_buffer_float")?Ri:Ms,minFilter:ji,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:ft.workingColorSpace}));const Re=g.state.transmissionRenderTarget[fe.id],We=fe.viewport||R;Re.setSize(We.z*w.transmissionResolutionScale,We.w*w.transmissionResolutionScale);const $e=w.getRenderTarget();w.setRenderTarget(Re),w.getClearColor(H),q=w.getClearAlpha(),q<1&&w.setClearColor(16777215,.5),w.clear(),je&&Ye.render(he);const Je=w.toneMapping;w.toneMapping=Xs;const pt=fe.viewport;if(fe.viewport!==void 0&&(fe.viewport=void 0),g.setupLightsView(fe),ee===!0&&re.setGlobalState(w.clippingPlanes,fe),Cr(U,he,fe),N.updateMultisampleRenderTarget(Re),N.updateRenderTargetMipmap(Re),Ue.has("WEBGL_multisampled_render_to_texture")===!1){let mt=!1;for(let at=0,St=J.length;at<St;at++){const It=J[at],an=It.object,nn=It.geometry,Nt=It.material,lt=It.group;if(Nt.side===ln&&an.layers.test(fe.layers)){const yn=Nt.side;Nt.side=fi,Nt.needsUpdate=!0,Fa(an,he,fe,nn,Nt,lt),Nt.side=yn,Nt.needsUpdate=!0,mt=!0}}mt===!0&&(N.updateMultisampleRenderTarget(Re),N.updateRenderTargetMipmap(Re))}w.setRenderTarget($e),w.setClearColor(H,q),pt!==void 0&&(fe.viewport=pt),w.toneMapping=Je}function Cr(U,J,he){const fe=J.isScene===!0?J.overrideMaterial:null;for(let ne=0,Re=U.length;ne<Re;ne++){const We=U[ne],$e=We.object,Je=We.geometry,pt=fe===null?We.material:fe,mt=We.group;$e.layers.test(he.layers)&&Fa($e,J,he,Je,pt,mt)}}function Fa(U,J,he,fe,ne,Re){U.onBeforeRender(w,J,he,fe,ne,Re),U.modelViewMatrix.multiplyMatrices(he.matrixWorldInverse,U.matrixWorld),U.normalMatrix.getNormalMatrix(U.modelViewMatrix),ne.onBeforeRender(w,J,he,fe,U,Re),ne.transparent===!0&&ne.side===ln&&ne.forceSinglePass===!1?(ne.side=fi,ne.needsUpdate=!0,w.renderBufferDirect(he,J,fe,ne,U,Re),ne.side=Si,ne.needsUpdate=!0,w.renderBufferDirect(he,J,fe,ne,U,Re),ne.side=ln):w.renderBufferDirect(he,J,fe,ne,U,Re),U.onAfterRender(w,J,he,fe,ne,Re)}function Pr(U,J,he){J.isScene!==!0&&(J=Ce);const fe=Be.get(U),ne=g.state.lights,Re=g.state.shadowsArray,We=ne.state.version,$e=Oe.getParameters(U,ne.state,Re,J,he),Je=Oe.getProgramCacheKey($e);let pt=fe.programs;fe.environment=U.isMeshStandardMaterial?J.environment:null,fe.fog=J.fog,fe.envMap=(U.isMeshStandardMaterial?W:E).get(U.envMap||fe.environment),fe.envMapRotation=fe.environment!==null&&U.envMap===null?J.environmentRotation:U.envMapRotation,pt===void 0&&(U.addEventListener("dispose",vt),pt=new Map,fe.programs=pt);let mt=pt.get(Je);if(mt!==void 0){if(fe.currentProgram===mt&&fe.lightsStateVersion===We)return Wo(U,$e),mt}else $e.uniforms=Oe.getUniforms(U),U.onBeforeCompile($e,w),mt=Oe.acquireProgram($e,Je),pt.set(Je,mt),fe.uniforms=$e.uniforms;const at=fe.uniforms;return(!U.isShaderMaterial&&!U.isRawShaderMaterial||U.clipping===!0)&&(at.clippingPlanes=re.uniform),Wo(U,$e),fe.needsLights=Xc(U),fe.lightsStateVersion=We,fe.needsLights&&(at.ambientLightColor.value=ne.state.ambient,at.lightProbe.value=ne.state.probe,at.directionalLights.value=ne.state.directional,at.directionalLightShadows.value=ne.state.directionalShadow,at.spotLights.value=ne.state.spot,at.spotLightShadows.value=ne.state.spotShadow,at.rectAreaLights.value=ne.state.rectArea,at.ltc_1.value=ne.state.rectAreaLTC1,at.ltc_2.value=ne.state.rectAreaLTC2,at.pointLights.value=ne.state.point,at.pointLightShadows.value=ne.state.pointShadow,at.hemisphereLights.value=ne.state.hemi,at.directionalShadowMap.value=ne.state.directionalShadowMap,at.directionalShadowMatrix.value=ne.state.directionalShadowMatrix,at.spotShadowMap.value=ne.state.spotShadowMap,at.spotLightMatrix.value=ne.state.spotLightMatrix,at.spotLightMap.value=ne.state.spotLightMap,at.pointShadowMap.value=ne.state.pointShadowMap,at.pointShadowMatrix.value=ne.state.pointShadowMatrix),fe.currentProgram=mt,fe.uniformsList=null,mt}function Vo(U){if(U.uniformsList===null){const J=U.currentProgram.getUniforms();U.uniformsList=fc.seqWithValue(J.seq,U.uniforms)}return U.uniformsList}function Wo(U,J){const he=Be.get(U);he.outputColorSpace=J.outputColorSpace,he.batching=J.batching,he.batchingColor=J.batchingColor,he.instancing=J.instancing,he.instancingColor=J.instancingColor,he.instancingMorph=J.instancingMorph,he.skinning=J.skinning,he.morphTargets=J.morphTargets,he.morphNormals=J.morphNormals,he.morphColors=J.morphColors,he.morphTargetsCount=J.morphTargetsCount,he.numClippingPlanes=J.numClippingPlanes,he.numIntersection=J.numClipIntersection,he.vertexAlphas=J.vertexAlphas,he.vertexTangents=J.vertexTangents,he.toneMapping=J.toneMapping}function Wc(U,J,he,fe,ne){J.isScene!==!0&&(J=Ce),N.resetTextureUnits();const Re=J.fog,We=fe.isMeshStandardMaterial?J.environment:null,$e=M===null?w.outputColorSpace:M.isXRRenderTarget===!0?M.texture.colorSpace:$n,Je=(fe.isMeshStandardMaterial?W:E).get(fe.envMap||We),pt=fe.vertexColors===!0&&!!he.attributes.color&&he.attributes.color.itemSize===4,mt=!!he.attributes.tangent&&(!!fe.normalMap||fe.anisotropy>0),at=!!he.morphAttributes.position,St=!!he.morphAttributes.normal,It=!!he.morphAttributes.color;let an=Xs;fe.toneMapped&&(M===null||M.isXRRenderTarget===!0)&&(an=w.toneMapping);const nn=he.morphAttributes.position||he.morphAttributes.normal||he.morphAttributes.color,Nt=nn!==void 0?nn.length:0,lt=Be.get(fe),yn=g.state.lights;if(ee===!0&&(ie===!0||U!==S)){const fn=U===S&&fe.id===_;re.setState(fe,U,fn)}let kt=!1;fe.version===lt.__version?(lt.needsLights&<.lightsStateVersion!==yn.state.version||lt.outputColorSpace!==$e||ne.isBatchedMesh&<.batching===!1||!ne.isBatchedMesh&<.batching===!0||ne.isBatchedMesh&<.batchingColor===!0&&ne.colorTexture===null||ne.isBatchedMesh&<.batchingColor===!1&&ne.colorTexture!==null||ne.isInstancedMesh&<.instancing===!1||!ne.isInstancedMesh&<.instancing===!0||ne.isSkinnedMesh&<.skinning===!1||!ne.isSkinnedMesh&<.skinning===!0||ne.isInstancedMesh&<.instancingColor===!0&&ne.instanceColor===null||ne.isInstancedMesh&<.instancingColor===!1&&ne.instanceColor!==null||ne.isInstancedMesh&<.instancingMorph===!0&&ne.morphTexture===null||ne.isInstancedMesh&<.instancingMorph===!1&&ne.morphTexture!==null||lt.envMap!==Je||fe.fog===!0&<.fog!==Re||lt.numClippingPlanes!==void 0&&(lt.numClippingPlanes!==re.numPlanes||lt.numIntersection!==re.numIntersection)||lt.vertexAlphas!==pt||lt.vertexTangents!==mt||lt.morphTargets!==at||lt.morphNormals!==St||lt.morphColors!==It||lt.toneMapping!==an||lt.morphTargetsCount!==Nt)&&(kt=!0):(kt=!0,lt.__version=fe.version);let ri=lt.currentProgram;kt===!0&&(ri=Pr(fe,J,ne));let Kt=!1,Ln=!1,Js=!1;const Xt=ri.getUniforms(),Qn=lt.uniforms;if(Se.useProgram(ri.program)&&(Kt=!0,Ln=!0,Js=!0),fe.id!==_&&(_=fe.id,Ln=!0),Kt||S!==U){Se.buffers.depth.getReversed()?(Y.copy(U.projectionMatrix),$x(Y),Qx(Y),Xt.setValue(j,"projectionMatrix",Y)):Xt.setValue(j,"projectionMatrix",U.projectionMatrix),Xt.setValue(j,"viewMatrix",U.matrixWorldInverse);const xn=Xt.map.cameraPosition;xn!==void 0&&xn.setValue(j,oe.setFromMatrixPosition(U.matrixWorld)),Te.logarithmicDepthBuffer&&Xt.setValue(j,"logDepthBufFC",2/(Math.log(U.far+1)/Math.LN2)),(fe.isMeshPhongMaterial||fe.isMeshToonMaterial||fe.isMeshLambertMaterial||fe.isMeshBasicMaterial||fe.isMeshStandardMaterial||fe.isShaderMaterial)&&Xt.setValue(j,"isOrthographic",U.isOrthographicCamera===!0),S!==U&&(S=U,Ln=!0,Js=!0)}if(ne.isSkinnedMesh){Xt.setOptional(j,ne,"bindMatrix"),Xt.setOptional(j,ne,"bindMatrixInverse");const fn=ne.skeleton;fn&&(fn.boneTexture===null&&fn.computeBoneTexture(),Xt.setValue(j,"boneTexture",fn.boneTexture,N))}ne.isBatchedMesh&&(Xt.setOptional(j,ne,"batchingTexture"),Xt.setValue(j,"batchingTexture",ne._matricesTexture,N),Xt.setOptional(j,ne,"batchingIdTexture"),Xt.setValue(j,"batchingIdTexture",ne._indirectTexture,N),Xt.setOptional(j,ne,"batchingColorTexture"),ne._colorsTexture!==null&&Xt.setValue(j,"batchingColorTexture",ne._colorsTexture,N));const Gn=he.morphAttributes;if((Gn.position!==void 0||Gn.normal!==void 0||Gn.color!==void 0)&&xe.update(ne,he,ri),(Ln||lt.receiveShadow!==ne.receiveShadow)&&(lt.receiveShadow=ne.receiveShadow,Xt.setValue(j,"receiveShadow",ne.receiveShadow)),fe.isMeshGouraudMaterial&&fe.envMap!==null&&(Qn.envMap.value=Je,Qn.flipEnvMap.value=Je.isCubeTexture&&Je.isRenderTargetTexture===!1?-1:1),fe.isMeshStandardMaterial&&fe.envMap===null&&J.environment!==null&&(Qn.envMapIntensity.value=J.environmentIntensity),Ln&&(Xt.setValue(j,"toneMappingExposure",w.toneMappingExposure),lt.needsLights&&jc(Qn,Js),Re&&fe.fog===!0&&Pe.refreshFogUniforms(Qn,Re),Pe.refreshMaterialUniforms(Qn,fe,V,K,g.state.transmissionRenderTarget[U.id]),fc.upload(j,Vo(lt),Qn,N)),fe.isShaderMaterial&&fe.uniformsNeedUpdate===!0&&(fc.upload(j,Vo(lt),Qn,N),fe.uniformsNeedUpdate=!1),fe.isSpriteMaterial&&Xt.setValue(j,"center",ne.center),Xt.setValue(j,"modelViewMatrix",ne.modelViewMatrix),Xt.setValue(j,"normalMatrix",ne.normalMatrix),Xt.setValue(j,"modelMatrix",ne.matrixWorld),fe.isShaderMaterial||fe.isRawShaderMaterial){const fn=fe.uniformsGroups;for(let xn=0,Rr=fn.length;xn<Rr;xn++){const ls=fn[xn];Q.update(ls,ri),Q.bind(ls,ri)}}return ri}function jc(U,J){U.ambientLightColor.needsUpdate=J,U.lightProbe.needsUpdate=J,U.directionalLights.needsUpdate=J,U.directionalLightShadows.needsUpdate=J,U.pointLights.needsUpdate=J,U.pointLightShadows.needsUpdate=J,U.spotLights.needsUpdate=J,U.spotLightShadows.needsUpdate=J,U.rectAreaLights.needsUpdate=J,U.hemisphereLights.needsUpdate=J}function Xc(U){return U.isMeshLambertMaterial||U.isMeshToonMaterial||U.isMeshPhongMaterial||U.isMeshStandardMaterial||U.isShadowMaterial||U.isShaderMaterial&&U.lights===!0}this.getActiveCubeFace=function(){return T},this.getActiveMipmapLevel=function(){return A},this.getRenderTarget=function(){return M},this.setRenderTargetTextures=function(U,J,he){Be.get(U.texture).__webglTexture=J,Be.get(U.depthTexture).__webglTexture=he;const fe=Be.get(U);fe.__hasExternalTextures=!0,fe.__autoAllocateDepthBuffer=he===void 0,fe.__autoAllocateDepthBuffer||Ue.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),fe.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(U,J){const he=Be.get(U);he.__webglFramebuffer=J,he.__useDefaultFramebuffer=J===void 0};const qc=j.createFramebuffer();this.setRenderTarget=function(U,J=0,he=0){M=U,T=J,A=he;let fe=!0,ne=null,Re=!1,We=!1;if(U){const Je=Be.get(U);if(Je.__useDefaultFramebuffer!==void 0)Se.bindFramebuffer(j.FRAMEBUFFER,null),fe=!1;else if(Je.__webglFramebuffer===void 0)N.setupRenderTarget(U);else if(Je.__hasExternalTextures)N.rebindTextures(U,Be.get(U.texture).__webglTexture,Be.get(U.depthTexture).__webglTexture);else if(U.depthBuffer){const at=U.depthTexture;if(Je.__boundDepthTexture!==at){if(at!==null&&Be.has(at)&&(U.width!==at.image.width||U.height!==at.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");N.setupDepthRenderbuffer(U)}}const pt=U.texture;(pt.isData3DTexture||pt.isDataArrayTexture||pt.isCompressedArrayTexture)&&(We=!0);const mt=Be.get(U).__webglFramebuffer;U.isWebGLCubeRenderTarget?(Array.isArray(mt[J])?ne=mt[J][he]:ne=mt[J],Re=!0):U.samples>0&&N.useMultisampledRTT(U)===!1?ne=Be.get(U).__webglMultisampledFramebuffer:Array.isArray(mt)?ne=mt[he]:ne=mt,R.copy(U.viewport),k.copy(U.scissor),O=U.scissorTest}else R.copy(se).multiplyScalar(V).floor(),k.copy(ge).multiplyScalar(V).floor(),O=de;if(he!==0&&(ne=qc),Se.bindFramebuffer(j.FRAMEBUFFER,ne)&&fe&&Se.drawBuffers(U,ne),Se.viewport(R),Se.scissor(k),Se.setScissorTest(O),Re){const Je=Be.get(U.texture);j.framebufferTexture2D(j.FRAMEBUFFER,j.COLOR_ATTACHMENT0,j.TEXTURE_CUBE_MAP_POSITIVE_X+J,Je.__webglTexture,he)}else if(We){const Je=Be.get(U.texture),pt=J;j.framebufferTextureLayer(j.FRAMEBUFFER,j.COLOR_ATTACHMENT0,Je.__webglTexture,he,pt)}else if(U!==null&&he!==0){const Je=Be.get(U.texture);j.framebufferTexture2D(j.FRAMEBUFFER,j.COLOR_ATTACHMENT0,j.TEXTURE_2D,Je.__webglTexture,he)}_=-1},this.readRenderTargetPixels=function(U,J,he,fe,ne,Re,We){if(!(U&&U.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let $e=Be.get(U).__webglFramebuffer;if(U.isWebGLCubeRenderTarget&&We!==void 0&&($e=$e[We]),$e){Se.bindFramebuffer(j.FRAMEBUFFER,$e);try{const Je=U.texture,pt=Je.format,mt=Je.type;if(!Te.textureFormatReadable(pt)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!Te.textureTypeReadable(mt)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}J>=0&&J<=U.width-fe&&he>=0&&he<=U.height-ne&&j.readPixels(J,he,fe,ne,rt.convert(pt),rt.convert(mt),Re)}finally{const Je=M!==null?Be.get(M).__webglFramebuffer:null;Se.bindFramebuffer(j.FRAMEBUFFER,Je)}}},this.readRenderTargetPixelsAsync=async function(U,J,he,fe,ne,Re,We){if(!(U&&U.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let $e=Be.get(U).__webglFramebuffer;if(U.isWebGLCubeRenderTarget&&We!==void 0&&($e=$e[We]),$e){const Je=U.texture,pt=Je.format,mt=Je.type;if(!Te.textureFormatReadable(pt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!Te.textureTypeReadable(mt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");if(J>=0&&J<=U.width-fe&&he>=0&&he<=U.height-ne){Se.bindFramebuffer(j.FRAMEBUFFER,$e);const at=j.createBuffer();j.bindBuffer(j.PIXEL_PACK_BUFFER,at),j.bufferData(j.PIXEL_PACK_BUFFER,Re.byteLength,j.STREAM_READ),j.readPixels(J,he,fe,ne,rt.convert(pt),rt.convert(mt),0);const St=M!==null?Be.get(M).__webglFramebuffer:null;Se.bindFramebuffer(j.FRAMEBUFFER,St);const It=j.fenceSync(j.SYNC_GPU_COMMANDS_COMPLETE,0);return j.flush(),await Kx(j,It,4),j.bindBuffer(j.PIXEL_PACK_BUFFER,at),j.getBufferSubData(j.PIXEL_PACK_BUFFER,0,Re),j.deleteBuffer(at),j.deleteSync(It),Re}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(U,J=null,he=0){U.isTexture!==!0&&(hr("WebGLRenderer: copyFramebufferToTexture function signature has changed."),J=arguments[0]||null,U=arguments[1]);const fe=Math.pow(2,-he),ne=Math.floor(U.image.width*fe),Re=Math.floor(U.image.height*fe),We=J!==null?J.x:0,$e=J!==null?J.y:0;N.setTexture2D(U,0),j.copyTexSubImage2D(j.TEXTURE_2D,he,0,0,We,$e,ne,Re),Se.unbindTexture()};const Zc=j.createFramebuffer(),Yc=j.createFramebuffer();this.copyTextureToTexture=function(U,J,he=null,fe=null,ne=0,Re=null){U.isTexture!==!0&&(hr("WebGLRenderer: copyTextureToTexture function signature has changed."),fe=arguments[0]||null,U=arguments[1],J=arguments[2],Re=arguments[3]||0,he=null),Re===null&&(ne!==0?(hr("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),Re=ne,ne=0):Re=0);let We,$e,Je,pt,mt,at,St,It,an;const nn=U.isCompressedTexture?U.mipmaps[Re]:U.image;if(he!==null)We=he.max.x-he.min.x,$e=he.max.y-he.min.y,Je=he.isBox3?he.max.z-he.min.z:1,pt=he.min.x,mt=he.min.y,at=he.isBox3?he.min.z:0;else{const Gn=Math.pow(2,-ne);We=Math.floor(nn.width*Gn),$e=Math.floor(nn.height*Gn),U.isDataArrayTexture?Je=nn.depth:U.isData3DTexture?Je=Math.floor(nn.depth*Gn):Je=1,pt=0,mt=0,at=0}fe!==null?(St=fe.x,It=fe.y,an=fe.z):(St=0,It=0,an=0);const Nt=rt.convert(J.format),lt=rt.convert(J.type);let yn;J.isData3DTexture?(N.setTexture3D(J,0),yn=j.TEXTURE_3D):J.isDataArrayTexture||J.isCompressedArrayTexture?(N.setTexture2DArray(J,0),yn=j.TEXTURE_2D_ARRAY):(N.setTexture2D(J,0),yn=j.TEXTURE_2D),j.pixelStorei(j.UNPACK_FLIP_Y_WEBGL,J.flipY),j.pixelStorei(j.UNPACK_PREMULTIPLY_ALPHA_WEBGL,J.premultiplyAlpha),j.pixelStorei(j.UNPACK_ALIGNMENT,J.unpackAlignment);const kt=j.getParameter(j.UNPACK_ROW_LENGTH),ri=j.getParameter(j.UNPACK_IMAGE_HEIGHT),Kt=j.getParameter(j.UNPACK_SKIP_PIXELS),Ln=j.getParameter(j.UNPACK_SKIP_ROWS),Js=j.getParameter(j.UNPACK_SKIP_IMAGES);j.pixelStorei(j.UNPACK_ROW_LENGTH,nn.width),j.pixelStorei(j.UNPACK_IMAGE_HEIGHT,nn.height),j.pixelStorei(j.UNPACK_SKIP_PIXELS,pt),j.pixelStorei(j.UNPACK_SKIP_ROWS,mt),j.pixelStorei(j.UNPACK_SKIP_IMAGES,at);const Xt=U.isDataArrayTexture||U.isData3DTexture,Qn=J.isDataArrayTexture||J.isData3DTexture;if(U.isDepthTexture){const Gn=Be.get(U),fn=Be.get(J),xn=Be.get(Gn.__renderTarget),Rr=Be.get(fn.__renderTarget);Se.bindFramebuffer(j.READ_FRAMEBUFFER,xn.__webglFramebuffer),Se.bindFramebuffer(j.DRAW_FRAMEBUFFER,Rr.__webglFramebuffer);for(let ls=0;ls<Je;ls++)Xt&&(j.framebufferTextureLayer(j.READ_FRAMEBUFFER,j.COLOR_ATTACHMENT0,Be.get(U).__webglTexture,ne,at+ls),j.framebufferTextureLayer(j.DRAW_FRAMEBUFFER,j.COLOR_ATTACHMENT0,Be.get(J).__webglTexture,Re,an+ls)),j.blitFramebuffer(pt,mt,We,$e,St,It,We,$e,j.DEPTH_BUFFER_BIT,j.NEAREST);Se.bindFramebuffer(j.READ_FRAMEBUFFER,null),Se.bindFramebuffer(j.DRAW_FRAMEBUFFER,null)}else if(ne!==0||U.isRenderTargetTexture||Be.has(U)){const Gn=Be.get(U),fn=Be.get(J);Se.bindFramebuffer(j.READ_FRAMEBUFFER,Zc),Se.bindFramebuffer(j.DRAW_FRAMEBUFFER,Yc);for(let xn=0;xn<Je;xn++)Xt?j.framebufferTextureLayer(j.READ_FRAMEBUFFER,j.COLOR_ATTACHMENT0,Gn.__webglTexture,ne,at+xn):j.framebufferTexture2D(j.READ_FRAMEBUFFER,j.COLOR_ATTACHMENT0,j.TEXTURE_2D,Gn.__webglTexture,ne),Qn?j.framebufferTextureLayer(j.DRAW_FRAMEBUFFER,j.COLOR_ATTACHMENT0,fn.__webglTexture,Re,an+xn):j.framebufferTexture2D(j.DRAW_FRAMEBUFFER,j.COLOR_ATTACHMENT0,j.TEXTURE_2D,fn.__webglTexture,Re),ne!==0?j.blitFramebuffer(pt,mt,We,$e,St,It,We,$e,j.COLOR_BUFFER_BIT,j.NEAREST):Qn?j.copyTexSubImage3D(yn,Re,St,It,an+xn,pt,mt,We,$e):j.copyTexSubImage2D(yn,Re,St,It,pt,mt,We,$e);Se.bindFramebuffer(j.READ_FRAMEBUFFER,null),Se.bindFramebuffer(j.DRAW_FRAMEBUFFER,null)}else Qn?U.isDataTexture||U.isData3DTexture?j.texSubImage3D(yn,Re,St,It,an,We,$e,Je,Nt,lt,nn.data):J.isCompressedArrayTexture?j.compressedTexSubImage3D(yn,Re,St,It,an,We,$e,Je,Nt,nn.data):j.texSubImage3D(yn,Re,St,It,an,We,$e,Je,Nt,lt,nn):U.isDataTexture?j.texSubImage2D(j.TEXTURE_2D,Re,St,It,We,$e,Nt,lt,nn.data):U.isCompressedTexture?j.compressedTexSubImage2D(j.TEXTURE_2D,Re,St,It,nn.width,nn.height,Nt,nn.data):j.texSubImage2D(j.TEXTURE_2D,Re,St,It,We,$e,Nt,lt,nn);j.pixelStorei(j.UNPACK_ROW_LENGTH,kt),j.pixelStorei(j.UNPACK_IMAGE_HEIGHT,ri),j.pixelStorei(j.UNPACK_SKIP_PIXELS,Kt),j.pixelStorei(j.UNPACK_SKIP_ROWS,Ln),j.pixelStorei(j.UNPACK_SKIP_IMAGES,Js),Re===0&&J.generateMipmaps&&j.generateMipmap(yn),Se.unbindTexture()},this.copyTextureToTexture3D=function(U,J,he=null,fe=null,ne=0){return U.isTexture!==!0&&(hr("WebGLRenderer: copyTextureToTexture3D function signature has changed."),he=arguments[0]||null,fe=arguments[1]||null,U=arguments[2],J=arguments[3],ne=arguments[4]||0),hr('WebGLRenderer: copyTextureToTexture3D function has been deprecated. Use "copyTextureToTexture" instead.'),this.copyTextureToTexture(U,J,he,fe,ne)},this.initRenderTarget=function(U){Be.get(U).__webglFramebuffer===void 0&&N.setupRenderTarget(U)},this.initTexture=function(U){U.isCubeTexture?N.setTextureCube(U,0):U.isData3DTexture?N.setTexture3D(U,0):U.isDataArrayTexture||U.isCompressedArrayTexture?N.setTexture2DArray(U,0):N.setTexture2D(U,0),Se.unbindTexture()},this.resetState=function(){T=0,A=0,M=null,Se.reset(),Rt.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return _s}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorspace=ft._getDrawingBufferColorSpace(e),t.unpackColorSpace=ft._getUnpackColorSpace()}}const XN={EDIT:"EDIT",PLAY:"PLAY"},EE="0.0.1",qN="editor-camera-position",Yb=16765952,Kb=.1,_u=.25,Ta=new gn(50,1,.01,1e3);Ta.up.set(0,0,1);Ta.name="Camera";Ta.position.set(-7.5,0,10);Ta.lookAt(new I);const gs={GOAL:"GOAL",ROUTE:"ROUTE",ALIGN:"ALIGN"},rm={NO_ENTRY:15680580,IGNORE_LIDAR_2D:15381256,IGNORE_LIDAR_3D:2278750},am=new Yt,Il=new I;class $b extends P_{constructor(){super(),this.isLineSegmentsGeometry=!0,this.type="LineSegmentsGeometry";const e=[-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],t=[-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],n=[0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5];this.setIndex(n),this.setAttribute("position",new ke(e,3)),this.setAttribute("uv",new ke(t,2))}applyMatrix4(e){const t=this.attributes.instanceStart,n=this.attributes.instanceEnd;return t!==void 0&&(t.applyMatrix4(e),n.applyMatrix4(e),t.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}setPositions(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));const n=new vu(t,6,1);return this.setAttribute("instanceStart",new Xi(n,3,0)),this.setAttribute("instanceEnd",new Xi(n,3,3)),this.instanceCount=this.attributes.instanceStart.count,this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));const n=new vu(t,6,1);return this.setAttribute("instanceColorStart",new Xi(n,3,0)),this.setAttribute("instanceColorEnd",new Xi(n,3,3)),this}fromWireframeGeometry(e){return this.setPositions(e.attributes.position.array),this}fromEdgesGeometry(e){return this.setPositions(e.attributes.position.array),this}fromMesh(e){return this.fromWireframeGeometry(new u_(e.geometry)),this}fromLineSegments(e){const t=e.geometry;return this.setPositions(t.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Yt);const e=this.attributes.instanceStart,t=this.attributes.instanceEnd;e!==void 0&&t!==void 0&&(this.boundingBox.setFromBufferAttribute(e),am.setFromBufferAttribute(t),this.boundingBox.union(am))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new vn),this.boundingBox===null&&this.computeBoundingBox();const e=this.attributes.instanceStart,t=this.attributes.instanceEnd;if(e!==void 0&&t!==void 0){const n=this.boundingSphere.center;this.boundingBox.getCenter(n);let i=0;for(let s=0,a=e.count;s<a;s++)Il.fromBufferAttribute(e,s),i=Math.max(i,n.distanceToSquared(Il)),Il.fromBufferAttribute(t,s),i=Math.max(i,n.distanceToSquared(Il));this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error("THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.",this)}}toJSON(){}applyMatrix(e){return console.warn("THREE.LineSegmentsGeometry: applyMatrix() has been renamed to applyMatrix4()."),this.applyMatrix4(e)}}He.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new me(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}};di.line={uniforms:Ca.merge([He.common,He.fog,He.line]),vertexShader:`
|
|
3856
|
+
}`;class xE{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t,n){if(this.texture===null){const i=new Ut,s=e.properties.get(i);s.__webglTexture=t.texture,(t.depthNear!==n.depthNear||t.depthFar!==n.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=i}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,n=new wn({vertexShader:vE,fragmentShader:yE,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Ee(new $s(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class _E extends Er{constructor(e,t){super();const n=this;let i=null,s=1,a=null,o="local-floor",l=1,c=null,d=null,h=null,u=null,f=null,m=null;const b=new xE,p=t.getContextAttributes();let g=null,y=null;const x=[],w=[],P=new me;let T=null;const A=new gn;A.viewport=new _t;const M=new gn;M.viewport=new _t;const _=[A,M],S=new N_;let R=null,k=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(X){let ee=x[X];return ee===void 0&&(ee=new gd,x[X]=ee),ee.getTargetRaySpace()},this.getControllerGrip=function(X){let ee=x[X];return ee===void 0&&(ee=new gd,x[X]=ee),ee.getGripSpace()},this.getHand=function(X){let ee=x[X];return ee===void 0&&(ee=new gd,x[X]=ee),ee.getHandSpace()};function O(X){const ee=w.indexOf(X.inputSource);if(ee===-1)return;const ie=x[ee];ie!==void 0&&(ie.update(X.inputSource,X.frame,c||a),ie.dispatchEvent({type:X.type,data:X.inputSource}))}function H(){i.removeEventListener("select",O),i.removeEventListener("selectstart",O),i.removeEventListener("selectend",O),i.removeEventListener("squeeze",O),i.removeEventListener("squeezestart",O),i.removeEventListener("squeezeend",O),i.removeEventListener("end",H),i.removeEventListener("inputsourceschange",q);for(let X=0;X<x.length;X++){const ee=w[X];ee!==null&&(w[X]=null,x[X].disconnect(ee))}R=null,k=null,b.reset(),e.setRenderTarget(g),f=null,u=null,h=null,i=null,y=null,de.stop(),n.isPresenting=!1,e.setPixelRatio(T),e.setSize(P.width,P.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(X){s=X,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(X){o=X,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function(X){c=X},this.getBaseLayer=function(){return u!==null?u:f},this.getBinding=function(){return h},this.getFrame=function(){return m},this.getSession=function(){return i},this.setSession=async function(X){if(i=X,i!==null){if(g=e.getRenderTarget(),i.addEventListener("select",O),i.addEventListener("selectstart",O),i.addEventListener("selectend",O),i.addEventListener("squeeze",O),i.addEventListener("squeezestart",O),i.addEventListener("squeezeend",O),i.addEventListener("end",H),i.addEventListener("inputsourceschange",q),p.xrCompatible!==!0&&await t.makeXRCompatible(),T=e.getPixelRatio(),e.getSize(P),typeof XRWebGLBinding<"u"&&"createProjectionLayer"in XRWebGLBinding.prototype){let ie=null,Z=null,ue=null;p.depth&&(ue=p.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,ie=p.stencil?wa:ha,Z=p.stencil?_a:Zs);const oe={colorFormat:t.RGBA8,depthFormat:ue,scaleFactor:s};h=new XRWebGLBinding(i,t),u=h.createProjectionLayer(oe),i.updateRenderState({layers:[u]}),e.setPixelRatio(1),e.setSize(u.textureWidth,u.textureHeight,!1),y=new ni(u.textureWidth,u.textureHeight,{format:Dn,type:Ms,depthTexture:new Cb(u.textureWidth,u.textureHeight,Z,void 0,void 0,void 0,void 0,void 0,void 0,ie),stencilBuffer:p.stencil,colorSpace:e.outputColorSpace,samples:p.antialias?4:0,resolveDepthBuffer:u.ignoreDepthValues===!1,resolveStencilBuffer:u.ignoreDepthValues===!1})}else{const ie={antialias:p.antialias,alpha:!0,depth:p.depth,stencil:p.stencil,framebufferScaleFactor:s};f=new XRWebGLLayer(i,t,ie),i.updateRenderState({baseLayer:f}),e.setPixelRatio(1),e.setSize(f.framebufferWidth,f.framebufferHeight,!1),y=new ni(f.framebufferWidth,f.framebufferHeight,{format:Dn,type:Ms,colorSpace:e.outputColorSpace,stencilBuffer:p.stencil,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1})}y.isXRRenderTarget=!0,this.setFoveation(l),c=null,a=await i.requestReferenceSpace(o),de.setContext(i),de.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return b.getDepthTexture()};function q(X){for(let ee=0;ee<X.removed.length;ee++){const ie=X.removed[ee],Z=w.indexOf(ie);Z>=0&&(w[Z]=null,x[Z].disconnect(ie))}for(let ee=0;ee<X.added.length;ee++){const ie=X.added[ee];let Z=w.indexOf(ie);if(Z===-1){for(let oe=0;oe<x.length;oe++)if(oe>=w.length){w.push(ie),Z=oe;break}else if(w[oe]===null){w[oe]=ie,Z=oe;break}if(Z===-1)break}const ue=x[Z];ue&&ue.connect(ie)}}const G=new I,K=new I;function V(X,ee,ie){G.setFromMatrixPosition(ee.matrixWorld),K.setFromMatrixPosition(ie.matrixWorld);const Z=G.distanceTo(K),ue=ee.projectionMatrix.elements,oe=ie.projectionMatrix.elements,be=ue[14]/(ue[10]-1),Ce=ue[14]/(ue[10]+1),je=(ue[9]+1)/ue[5],Fe=(ue[9]-1)/ue[5],j=(ue[8]-1)/ue[0],Ke=(oe[8]+1)/oe[0],Ue=be*j,Te=be*Ke,Se=Z/(-j+Ke),et=Se*-j;if(ee.matrixWorld.decompose(X.position,X.quaternion,X.scale),X.translateX(et),X.translateZ(Se),X.matrixWorld.compose(X.position,X.quaternion,X.scale),X.matrixWorldInverse.copy(X.matrixWorld).invert(),ue[10]===-1)X.projectionMatrix.copy(ee.projectionMatrix),X.projectionMatrixInverse.copy(ee.projectionMatrixInverse);else{const Be=be+Se,N=Ce+Se,E=Ue-et,W=Te+(Z-et),ae=je*Ce/N*Be,ve=Fe*Ce/N*Be;X.projectionMatrix.makePerspective(E,W,ae,ve,Be,N),X.projectionMatrixInverse.copy(X.projectionMatrix).invert()}}function Y(X,ee){ee===null?X.matrixWorld.copy(X.matrix):X.matrixWorld.multiplyMatrices(ee.matrixWorld,X.matrix),X.matrixWorldInverse.copy(X.matrixWorld).invert()}this.updateCamera=function(X){if(i===null)return;let ee=X.near,ie=X.far;b.texture!==null&&(b.depthNear>0&&(ee=b.depthNear),b.depthFar>0&&(ie=b.depthFar)),S.near=M.near=A.near=ee,S.far=M.far=A.far=ie,(R!==S.near||k!==S.far)&&(i.updateRenderState({depthNear:S.near,depthFar:S.far}),R=S.near,k=S.far),A.layers.mask=X.layers.mask|2,M.layers.mask=X.layers.mask|4,S.layers.mask=A.layers.mask|M.layers.mask;const Z=X.parent,ue=S.cameras;Y(S,Z);for(let oe=0;oe<ue.length;oe++)Y(ue[oe],Z);ue.length===2?V(S,A,M):S.projectionMatrix.copy(A.projectionMatrix),le(X,S,Z)};function le(X,ee,ie){ie===null?X.matrix.copy(ee.matrixWorld):(X.matrix.copy(ie.matrixWorld),X.matrix.invert(),X.matrix.multiply(ee.matrixWorld)),X.matrix.decompose(X.position,X.quaternion,X.scale),X.updateMatrixWorld(!0),X.projectionMatrix.copy(ee.projectionMatrix),X.projectionMatrixInverse.copy(ee.projectionMatrixInverse),X.isPerspectiveCamera&&(X.fov=Sa*2*Math.atan(1/X.projectionMatrix.elements[5]),X.zoom=1)}this.getCamera=function(){return S},this.getFoveation=function(){if(!(u===null&&f===null))return l},this.setFoveation=function(X){l=X,u!==null&&(u.fixedFoveation=X),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=X)},this.hasDepthSensing=function(){return b.texture!==null},this.getDepthSensingMesh=function(){return b.getMesh(S)};let se=null;function ge(X,ee){if(d=ee.getViewerPose(c||a),m=ee,d!==null){const ie=d.views;f!==null&&(e.setRenderTargetFramebuffer(y,f.framebuffer),e.setRenderTarget(y));let Z=!1;ie.length!==S.cameras.length&&(S.cameras.length=0,Z=!0);for(let be=0;be<ie.length;be++){const Ce=ie[be];let je=null;if(f!==null)je=f.getViewport(Ce);else{const j=h.getViewSubImage(u,Ce);je=j.viewport,be===0&&(e.setRenderTargetTextures(y,j.colorTexture,u.ignoreDepthValues?void 0:j.depthStencilTexture),e.setRenderTarget(y))}let Fe=_[be];Fe===void 0&&(Fe=new gn,Fe.layers.enable(be),Fe.viewport=new _t,_[be]=Fe),Fe.matrix.fromArray(Ce.transform.matrix),Fe.matrix.decompose(Fe.position,Fe.quaternion,Fe.scale),Fe.projectionMatrix.fromArray(Ce.projectionMatrix),Fe.projectionMatrixInverse.copy(Fe.projectionMatrix).invert(),Fe.viewport.set(je.x,je.y,je.width,je.height),be===0&&(S.matrix.copy(Fe.matrix),S.matrix.decompose(S.position,S.quaternion,S.scale)),Z===!0&&S.cameras.push(Fe)}const ue=i.enabledFeatures;if(ue&&ue.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&h){const be=h.getDepthInformation(ie[0]);be&&be.isValid&&be.texture&&b.init(e,be,i.renderState)}}for(let ie=0;ie<x.length;ie++){const Z=w[ie],ue=x[ie];Z!==null&&ue!==void 0&&ue.update(Z,ee,c||a)}se&&se(X,ee),ee.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:ee}),m=null}const de=new Wb;de.setAnimationLoop(ge),this.setAnimationLoop=function(X){se=X},this.dispose=function(){}}}const or=new hn,wE=new Ie;function SE(r,e){function t(p,g){p.matrixAutoUpdate===!0&&p.updateMatrix(),g.value.copy(p.matrix)}function n(p,g){g.color.getRGB(p.fogColor.value,Sb(r)),g.isFog?(p.fogNear.value=g.near,p.fogFar.value=g.far):g.isFogExp2&&(p.fogDensity.value=g.density)}function i(p,g,y,x,w){g.isMeshBasicMaterial||g.isMeshLambertMaterial?s(p,g):g.isMeshToonMaterial?(s(p,g),h(p,g)):g.isMeshPhongMaterial?(s(p,g),d(p,g)):g.isMeshStandardMaterial?(s(p,g),u(p,g),g.isMeshPhysicalMaterial&&f(p,g,w)):g.isMeshMatcapMaterial?(s(p,g),m(p,g)):g.isMeshDepthMaterial?s(p,g):g.isMeshDistanceMaterial?(s(p,g),b(p,g)):g.isMeshNormalMaterial?s(p,g):g.isLineBasicMaterial?(a(p,g),g.isLineDashedMaterial&&o(p,g)):g.isPointsMaterial?l(p,g,y,x):g.isSpriteMaterial?c(p,g):g.isShadowMaterial?(p.color.value.copy(g.color),p.opacity.value=g.opacity):g.isShaderMaterial&&(g.uniformsNeedUpdate=!1)}function s(p,g){p.opacity.value=g.opacity,g.color&&p.diffuse.value.copy(g.color),g.emissive&&p.emissive.value.copy(g.emissive).multiplyScalar(g.emissiveIntensity),g.map&&(p.map.value=g.map,t(g.map,p.mapTransform)),g.alphaMap&&(p.alphaMap.value=g.alphaMap,t(g.alphaMap,p.alphaMapTransform)),g.bumpMap&&(p.bumpMap.value=g.bumpMap,t(g.bumpMap,p.bumpMapTransform),p.bumpScale.value=g.bumpScale,g.side===fi&&(p.bumpScale.value*=-1)),g.normalMap&&(p.normalMap.value=g.normalMap,t(g.normalMap,p.normalMapTransform),p.normalScale.value.copy(g.normalScale),g.side===fi&&p.normalScale.value.negate()),g.displacementMap&&(p.displacementMap.value=g.displacementMap,t(g.displacementMap,p.displacementMapTransform),p.displacementScale.value=g.displacementScale,p.displacementBias.value=g.displacementBias),g.emissiveMap&&(p.emissiveMap.value=g.emissiveMap,t(g.emissiveMap,p.emissiveMapTransform)),g.specularMap&&(p.specularMap.value=g.specularMap,t(g.specularMap,p.specularMapTransform)),g.alphaTest>0&&(p.alphaTest.value=g.alphaTest);const y=e.get(g),x=y.envMap,w=y.envMapRotation;x&&(p.envMap.value=x,or.copy(w),or.x*=-1,or.y*=-1,or.z*=-1,x.isCubeTexture&&x.isRenderTargetTexture===!1&&(or.y*=-1,or.z*=-1),p.envMapRotation.value.setFromMatrix4(wE.makeRotationFromEuler(or)),p.flipEnvMap.value=x.isCubeTexture&&x.isRenderTargetTexture===!1?-1:1,p.reflectivity.value=g.reflectivity,p.ior.value=g.ior,p.refractionRatio.value=g.refractionRatio),g.lightMap&&(p.lightMap.value=g.lightMap,p.lightMapIntensity.value=g.lightMapIntensity,t(g.lightMap,p.lightMapTransform)),g.aoMap&&(p.aoMap.value=g.aoMap,p.aoMapIntensity.value=g.aoMapIntensity,t(g.aoMap,p.aoMapTransform))}function a(p,g){p.diffuse.value.copy(g.color),p.opacity.value=g.opacity,g.map&&(p.map.value=g.map,t(g.map,p.mapTransform))}function o(p,g){p.dashSize.value=g.dashSize,p.totalSize.value=g.dashSize+g.gapSize,p.scale.value=g.scale}function l(p,g,y,x){p.diffuse.value.copy(g.color),p.opacity.value=g.opacity,p.size.value=g.size*y,p.scale.value=x*.5,g.map&&(p.map.value=g.map,t(g.map,p.uvTransform)),g.alphaMap&&(p.alphaMap.value=g.alphaMap,t(g.alphaMap,p.alphaMapTransform)),g.alphaTest>0&&(p.alphaTest.value=g.alphaTest)}function c(p,g){p.diffuse.value.copy(g.color),p.opacity.value=g.opacity,p.rotation.value=g.rotation,g.map&&(p.map.value=g.map,t(g.map,p.mapTransform)),g.alphaMap&&(p.alphaMap.value=g.alphaMap,t(g.alphaMap,p.alphaMapTransform)),g.alphaTest>0&&(p.alphaTest.value=g.alphaTest)}function d(p,g){p.specular.value.copy(g.specular),p.shininess.value=Math.max(g.shininess,1e-4)}function h(p,g){g.gradientMap&&(p.gradientMap.value=g.gradientMap)}function u(p,g){p.metalness.value=g.metalness,g.metalnessMap&&(p.metalnessMap.value=g.metalnessMap,t(g.metalnessMap,p.metalnessMapTransform)),p.roughness.value=g.roughness,g.roughnessMap&&(p.roughnessMap.value=g.roughnessMap,t(g.roughnessMap,p.roughnessMapTransform)),g.envMap&&(p.envMapIntensity.value=g.envMapIntensity)}function f(p,g,y){p.ior.value=g.ior,g.sheen>0&&(p.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),p.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap&&(p.sheenColorMap.value=g.sheenColorMap,t(g.sheenColorMap,p.sheenColorMapTransform)),g.sheenRoughnessMap&&(p.sheenRoughnessMap.value=g.sheenRoughnessMap,t(g.sheenRoughnessMap,p.sheenRoughnessMapTransform))),g.clearcoat>0&&(p.clearcoat.value=g.clearcoat,p.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap&&(p.clearcoatMap.value=g.clearcoatMap,t(g.clearcoatMap,p.clearcoatMapTransform)),g.clearcoatRoughnessMap&&(p.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap,t(g.clearcoatRoughnessMap,p.clearcoatRoughnessMapTransform)),g.clearcoatNormalMap&&(p.clearcoatNormalMap.value=g.clearcoatNormalMap,t(g.clearcoatNormalMap,p.clearcoatNormalMapTransform),p.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),g.side===fi&&p.clearcoatNormalScale.value.negate())),g.dispersion>0&&(p.dispersion.value=g.dispersion),g.iridescence>0&&(p.iridescence.value=g.iridescence,p.iridescenceIOR.value=g.iridescenceIOR,p.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],p.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap&&(p.iridescenceMap.value=g.iridescenceMap,t(g.iridescenceMap,p.iridescenceMapTransform)),g.iridescenceThicknessMap&&(p.iridescenceThicknessMap.value=g.iridescenceThicknessMap,t(g.iridescenceThicknessMap,p.iridescenceThicknessMapTransform))),g.transmission>0&&(p.transmission.value=g.transmission,p.transmissionSamplerMap.value=y.texture,p.transmissionSamplerSize.value.set(y.width,y.height),g.transmissionMap&&(p.transmissionMap.value=g.transmissionMap,t(g.transmissionMap,p.transmissionMapTransform)),p.thickness.value=g.thickness,g.thicknessMap&&(p.thicknessMap.value=g.thicknessMap,t(g.thicknessMap,p.thicknessMapTransform)),p.attenuationDistance.value=g.attenuationDistance,p.attenuationColor.value.copy(g.attenuationColor)),g.anisotropy>0&&(p.anisotropyVector.value.set(g.anisotropy*Math.cos(g.anisotropyRotation),g.anisotropy*Math.sin(g.anisotropyRotation)),g.anisotropyMap&&(p.anisotropyMap.value=g.anisotropyMap,t(g.anisotropyMap,p.anisotropyMapTransform))),p.specularIntensity.value=g.specularIntensity,p.specularColor.value.copy(g.specularColor),g.specularColorMap&&(p.specularColorMap.value=g.specularColorMap,t(g.specularColorMap,p.specularColorMapTransform)),g.specularIntensityMap&&(p.specularIntensityMap.value=g.specularIntensityMap,t(g.specularIntensityMap,p.specularIntensityMapTransform))}function m(p,g){g.matcap&&(p.matcap.value=g.matcap)}function b(p,g){const y=e.get(g).light;p.referencePosition.value.setFromMatrixPosition(y.matrixWorld),p.nearDistance.value=y.shadow.camera.near,p.farDistance.value=y.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:i}}function ME(r,e,t,n){let i={},s={},a=[];const o=r.getParameter(r.MAX_UNIFORM_BUFFER_BINDINGS);function l(y,x){const w=x.program;n.uniformBlockBinding(y,w)}function c(y,x){let w=i[y.id];w===void 0&&(m(y),w=d(y),i[y.id]=w,y.addEventListener("dispose",p));const P=x.program;n.updateUBOMapping(y,P);const T=e.render.frame;s[y.id]!==T&&(u(y),s[y.id]=T)}function d(y){const x=h();y.__bindingPointIndex=x;const w=r.createBuffer(),P=y.__size,T=y.usage;return r.bindBuffer(r.UNIFORM_BUFFER,w),r.bufferData(r.UNIFORM_BUFFER,P,T),r.bindBuffer(r.UNIFORM_BUFFER,null),r.bindBufferBase(r.UNIFORM_BUFFER,x,w),w}function h(){for(let y=0;y<o;y++)if(a.indexOf(y)===-1)return a.push(y),y;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function u(y){const x=i[y.id],w=y.uniforms,P=y.__cache;r.bindBuffer(r.UNIFORM_BUFFER,x);for(let T=0,A=w.length;T<A;T++){const M=Array.isArray(w[T])?w[T]:[w[T]];for(let _=0,S=M.length;_<S;_++){const R=M[_];if(f(R,T,_,P)===!0){const k=R.__offset,O=Array.isArray(R.value)?R.value:[R.value];let H=0;for(let q=0;q<O.length;q++){const G=O[q],K=b(G);typeof G=="number"||typeof G=="boolean"?(R.__data[0]=G,r.bufferSubData(r.UNIFORM_BUFFER,k+H,R.__data)):G.isMatrix3?(R.__data[0]=G.elements[0],R.__data[1]=G.elements[1],R.__data[2]=G.elements[2],R.__data[3]=0,R.__data[4]=G.elements[3],R.__data[5]=G.elements[4],R.__data[6]=G.elements[5],R.__data[7]=0,R.__data[8]=G.elements[6],R.__data[9]=G.elements[7],R.__data[10]=G.elements[8],R.__data[11]=0):(G.toArray(R.__data,H),H+=K.storage/Float32Array.BYTES_PER_ELEMENT)}r.bufferSubData(r.UNIFORM_BUFFER,k,R.__data)}}}r.bindBuffer(r.UNIFORM_BUFFER,null)}function f(y,x,w,P){const T=y.value,A=x+"_"+w;if(P[A]===void 0)return typeof T=="number"||typeof T=="boolean"?P[A]=T:P[A]=T.clone(),!0;{const M=P[A];if(typeof T=="number"||typeof T=="boolean"){if(M!==T)return P[A]=T,!0}else if(M.equals(T)===!1)return M.copy(T),!0}return!1}function m(y){const x=y.uniforms;let w=0;const P=16;for(let A=0,M=x.length;A<M;A++){const _=Array.isArray(x[A])?x[A]:[x[A]];for(let S=0,R=_.length;S<R;S++){const k=_[S],O=Array.isArray(k.value)?k.value:[k.value];for(let H=0,q=O.length;H<q;H++){const G=O[H],K=b(G),V=w%P,Y=V%K.boundary,le=V+Y;w+=Y,le!==0&&P-le<K.storage&&(w+=P-le),k.__data=new Float32Array(K.storage/Float32Array.BYTES_PER_ELEMENT),k.__offset=w,w+=K.storage}}}const T=w%P;return T>0&&(w+=P-T),y.__size=w,y.__cache={},this}function b(y){const x={boundary:0,storage:0};return typeof y=="number"||typeof y=="boolean"?(x.boundary=4,x.storage=4):y.isVector2?(x.boundary=8,x.storage=8):y.isVector3||y.isColor?(x.boundary=16,x.storage=12):y.isVector4?(x.boundary=16,x.storage=16):y.isMatrix3?(x.boundary=48,x.storage=48):y.isMatrix4?(x.boundary=64,x.storage=64):y.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",y),x}function p(y){const x=y.target;x.removeEventListener("dispose",p);const w=a.indexOf(x.__bindingPointIndex);a.splice(w,1),r.deleteBuffer(i[x.id]),delete i[x.id],delete s[x.id]}function g(){for(const y in i)r.deleteBuffer(i[y]);a=[],i={},s={}}return{bind:l,update:c,dispose:g}}class TE{constructor(e={}){const{canvas:t=Yx(),context:n=null,depth:i=!0,stencil:s=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:d="default",failIfMajorPerformanceCaveat:h=!1,reverseDepthBuffer:u=!1}=e;this.isWebGLRenderer=!0;let f;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");f=n.getContextAttributes().alpha}else f=a;const m=new Uint32Array(4),b=new Int32Array(4);let p=null,g=null;const y=[],x=[];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._outputColorSpace=gt,this.toneMapping=Xs,this.toneMappingExposure=1;const w=this;let P=!1,T=0,A=0,M=null,_=-1,S=null;const R=new _t,k=new _t;let O=null;const H=new Ne(0);let q=0,G=t.width,K=t.height,V=1,Y=null,le=null;const se=new _t(0,0,G,K),ge=new _t(0,0,G,K);let de=!1;const X=new No;let ee=!1,ie=!1;this.transmissionResolutionScale=1;const Z=new Ie,ue=new Ie,oe=new I,be=new _t,Ce={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let je=!1;function Fe(){return M===null?V:1}let j=n;function Ke(U,J){return t.getContext(U,J)}try{const U={alpha:!0,depth:i,stencil:s,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:d,failIfMajorPerformanceCaveat:h};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${yr}`),t.addEventListener("webglcontextlost",Me,!1),t.addEventListener("webglcontextrestored",Ze,!1),t.addEventListener("webglcontextcreationerror",Xe,!1),j===null){const J="webgl2";if(j=Ke(J,U),j===null)throw Ke(J)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(U){throw console.error("THREE.WebGLRenderer: "+U.message),U}let Ue,Te,Se,et,Be,N,E,W,ae,ve,ce,Oe,Pe,Ve,te,re,De,Ye,xe,Le,ct,rt,Rt,Q;function Ge(){Ue=new kM(j),Ue.init(),rt=new bE(j,Ue),Te=new CM(j,Ue,e,rt),Se=new mE(j,Ue),Te.reverseDepthBuffer&&u&&Se.buffers.depth.setReversed(!0),et=new UM(j),Be=new nE,N=new gE(j,Ue,Se,Be,Te,rt,et),E=new RM(w),W=new IM(w),ae=new W_(j),Rt=new EM(j,ae),ve=new OM(j,ae,et,Rt),ce=new zM(j,ve,ae,et),xe=new BM(j,Te,N),re=new PM(Be),Oe=new tE(w,E,W,Ue,Te,Rt,re),Pe=new SE(w,Be),Ve=new sE,te=new dE(Ue),Ye=new TM(w,E,W,Se,ce,f,l),De=new fE(w,ce,Te),Q=new ME(j,et,Te,Se),Le=new AM(j,Ue,et),ct=new FM(j,Ue,et),et.programs=Oe.programs,w.capabilities=Te,w.extensions=Ue,w.properties=Be,w.renderLists=Ve,w.shadowMap=De,w.state=Se,w.info=et}Ge();const ye=new _E(w,j);this.xr=ye,this.getContext=function(){return j},this.getContextAttributes=function(){return j.getContextAttributes()},this.forceContextLoss=function(){const U=Ue.get("WEBGL_lose_context");U&&U.loseContext()},this.forceContextRestore=function(){const U=Ue.get("WEBGL_lose_context");U&&U.restoreContext()},this.getPixelRatio=function(){return V},this.setPixelRatio=function(U){U!==void 0&&(V=U,this.setSize(G,K,!1))},this.getSize=function(U){return U.set(G,K)},this.setSize=function(U,J,he=!0){if(ye.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}G=U,K=J,t.width=Math.floor(U*V),t.height=Math.floor(J*V),he===!0&&(t.style.width=U+"px",t.style.height=J+"px"),this.setViewport(0,0,U,J)},this.getDrawingBufferSize=function(U){return U.set(G*V,K*V).floor()},this.setDrawingBufferSize=function(U,J,he){G=U,K=J,V=he,t.width=Math.floor(U*he),t.height=Math.floor(J*he),this.setViewport(0,0,U,J)},this.getCurrentViewport=function(U){return U.copy(R)},this.getViewport=function(U){return U.copy(se)},this.setViewport=function(U,J,he,fe){U.isVector4?se.set(U.x,U.y,U.z,U.w):se.set(U,J,he,fe),Se.viewport(R.copy(se).multiplyScalar(V).round())},this.getScissor=function(U){return U.copy(ge)},this.setScissor=function(U,J,he,fe){U.isVector4?ge.set(U.x,U.y,U.z,U.w):ge.set(U,J,he,fe),Se.scissor(k.copy(ge).multiplyScalar(V).round())},this.getScissorTest=function(){return de},this.setScissorTest=function(U){Se.setScissorTest(de=U)},this.setOpaqueSort=function(U){Y=U},this.setTransparentSort=function(U){le=U},this.getClearColor=function(U){return U.copy(Ye.getClearColor())},this.setClearColor=function(){Ye.setClearColor(...arguments)},this.getClearAlpha=function(){return Ye.getClearAlpha()},this.setClearAlpha=function(){Ye.setClearAlpha(...arguments)},this.clear=function(U=!0,J=!0,he=!0){let fe=0;if(U){let ne=!1;if(M!==null){const Re=M.texture.format;ne=Re===Ou||Re===ku||Re===Ic}if(ne){const Re=M.texture.type,We=Re===Ms||Re===Zs||Re===bo||Re===_a||Re===Du||Re===Lu,$e=Ye.getClearColor(),Je=Ye.getClearAlpha(),pt=$e.r,mt=$e.g,at=$e.b;We?(m[0]=pt,m[1]=mt,m[2]=at,m[3]=Je,j.clearBufferuiv(j.COLOR,0,m)):(b[0]=pt,b[1]=mt,b[2]=at,b[3]=Je,j.clearBufferiv(j.COLOR,0,b))}else fe|=j.COLOR_BUFFER_BIT}J&&(fe|=j.DEPTH_BUFFER_BIT),he&&(fe|=j.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),j.clear(fe)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",Me,!1),t.removeEventListener("webglcontextrestored",Ze,!1),t.removeEventListener("webglcontextcreationerror",Xe,!1),Ye.dispose(),Ve.dispose(),te.dispose(),Be.dispose(),E.dispose(),W.dispose(),ce.dispose(),Rt.dispose(),Q.dispose(),Oe.dispose(),ye.dispose(),ye.removeEventListener("sessionstart",zo),ye.removeEventListener("sessionend",Ho),os.stop()};function Me(U){U.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),P=!0}function Ze(){console.log("THREE.WebGLRenderer: Context Restored."),P=!1;const U=et.autoReset,J=De.enabled,he=De.autoUpdate,fe=De.needsUpdate,ne=De.type;Ge(),et.autoReset=U,De.enabled=J,De.autoUpdate=he,De.needsUpdate=fe,De.type=ne}function Xe(U){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",U.statusMessage)}function vt(U){const J=U.target;J.removeEventListener("dispose",vt),Qt(J)}function Qt(U){An(U),Be.remove(U)}function An(U){const J=Be.get(U).programs;J!==void 0&&(J.forEach(function(he){Oe.releaseProgram(he)}),U.isShaderMaterial&&Oe.releaseShaderCache(U))}this.renderBufferDirect=function(U,J,he,fe,ne,Re){J===null&&(J=Ce);const We=ne.isMesh&&ne.matrixWorld.determinant()<0,$e=Wc(U,J,he,fe,ne);Se.setMaterial(fe,We);let Je=he.index,pt=1;if(fe.wireframe===!0){if(Je=ve.getWireframeAttribute(he),Je===void 0)return;pt=2}const mt=he.drawRange,at=he.attributes.position;let St=mt.start*pt,It=(mt.start+mt.count)*pt;Re!==null&&(St=Math.max(St,Re.start*pt),It=Math.min(It,(Re.start+Re.count)*pt)),Je!==null?(St=Math.max(St,0),It=Math.min(It,Je.count)):at!=null&&(St=Math.max(St,0),It=Math.min(It,at.count));const an=It-St;if(an<0||an===1/0)return;Rt.setup(ne,fe,$e,he,Je);let nn,Nt=Le;if(Je!==null&&(nn=ae.get(Je),Nt=ct,Nt.setIndex(nn)),ne.isMesh)fe.wireframe===!0?(Se.setLineWidth(fe.wireframeLinewidth*Fe()),Nt.setMode(j.LINES)):Nt.setMode(j.TRIANGLES);else if(ne.isLine){let lt=fe.linewidth;lt===void 0&&(lt=1),Se.setLineWidth(lt*Fe()),ne.isLineSegments?Nt.setMode(j.LINES):ne.isLineLoop?Nt.setMode(j.LINE_LOOP):Nt.setMode(j.LINE_STRIP)}else ne.isPoints?Nt.setMode(j.POINTS):ne.isSprite&&Nt.setMode(j.TRIANGLES);if(ne.isBatchedMesh)if(ne._multiDrawInstances!==null)hr("THREE.WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),Nt.renderMultiDrawInstances(ne._multiDrawStarts,ne._multiDrawCounts,ne._multiDrawCount,ne._multiDrawInstances);else if(Ue.get("WEBGL_multi_draw"))Nt.renderMultiDraw(ne._multiDrawStarts,ne._multiDrawCounts,ne._multiDrawCount);else{const lt=ne._multiDrawStarts,yn=ne._multiDrawCounts,kt=ne._multiDrawCount,ri=Je?ae.get(Je).bytesPerElement:1,Kt=Be.get(fe).currentProgram.getUniforms();for(let Ln=0;Ln<kt;Ln++)Kt.setValue(j,"_gl_DrawID",Ln),Nt.render(lt[Ln]/ri,yn[Ln])}else if(ne.isInstancedMesh)Nt.renderInstances(St,an,ne.count);else if(he.isInstancedBufferGeometry){const lt=he._maxInstanceCount!==void 0?he._maxInstanceCount:1/0,yn=Math.min(he.instanceCount,lt);Nt.renderInstances(St,an,yn)}else Nt.render(St,an)};function wt(U,J,he){U.transparent===!0&&U.side===ln&&U.forceSinglePass===!1?(U.side=fi,U.needsUpdate=!0,Pr(U,J,he),U.side=Si,U.needsUpdate=!0,Pr(U,J,he),U.side=ln):Pr(U,J,he)}this.compile=function(U,J,he=null){he===null&&(he=U),g=te.get(he),g.init(J),x.push(g),he.traverseVisible(function(ne){ne.isLight&&ne.layers.test(J.layers)&&(g.pushLight(ne),ne.castShadow&&g.pushShadow(ne))}),U!==he&&U.traverseVisible(function(ne){ne.isLight&&ne.layers.test(J.layers)&&(g.pushLight(ne),ne.castShadow&&g.pushShadow(ne))}),g.setupLights();const fe=new Set;return U.traverse(function(ne){if(!(ne.isMesh||ne.isPoints||ne.isLine||ne.isSprite))return;const Re=ne.material;if(Re)if(Array.isArray(Re))for(let We=0;We<Re.length;We++){const $e=Re[We];wt($e,he,ne),fe.add($e)}else wt(Re,he,ne),fe.add(Re)}),g=x.pop(),fe},this.compileAsync=function(U,J,he=null){const fe=this.compile(U,J,he);return new Promise(ne=>{function Re(){if(fe.forEach(function(We){Be.get(We).currentProgram.isReady()&&fe.delete(We)}),fe.size===0){ne(U);return}setTimeout(Re,10)}Ue.get("KHR_parallel_shader_compile")!==null?Re():setTimeout(Re,10)})};let si=null;function Fi(U){si&&si(U)}function zo(){os.stop()}function Ho(){os.start()}const os=new Wb;os.setAnimationLoop(Fi),typeof self<"u"&&os.setContext(self),this.setAnimationLoop=function(U){si=U,ye.setAnimationLoop(U),U===null?os.stop():os.start()},ye.addEventListener("sessionstart",zo),ye.addEventListener("sessionend",Ho),this.render=function(U,J){if(J!==void 0&&J.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(P===!0)return;if(U.matrixWorldAutoUpdate===!0&&U.updateMatrixWorld(),J.parent===null&&J.matrixWorldAutoUpdate===!0&&J.updateMatrixWorld(),ye.enabled===!0&&ye.isPresenting===!0&&(ye.cameraAutoUpdate===!0&&ye.updateCamera(J),J=ye.getCamera()),U.isScene===!0&&U.onBeforeRender(w,U,J,M),g=te.get(U,x.length),g.init(J),x.push(g),ue.multiplyMatrices(J.projectionMatrix,J.matrixWorldInverse),X.setFromProjectionMatrix(ue),ie=this.localClippingEnabled,ee=re.init(this.clippingPlanes,ie),p=Ve.get(U,y.length),p.init(),y.push(p),ye.enabled===!0&&ye.isPresenting===!0){const Re=w.xr.getDepthSensingMesh();Re!==null&&ka(Re,J,-1/0,w.sortObjects)}ka(U,J,0,w.sortObjects),p.finish(),w.sortObjects===!0&&p.sort(Y,le),je=ye.enabled===!1||ye.isPresenting===!1||ye.hasDepthSensing()===!1,je&&Ye.addToRenderList(p,U),this.info.render.frame++,ee===!0&&re.beginShadows();const he=g.state.shadowsArray;De.render(he,U,J),ee===!0&&re.endShadows(),this.info.autoReset===!0&&this.info.reset();const fe=p.opaque,ne=p.transmissive;if(g.setupLights(),J.isArrayCamera){const Re=J.cameras;if(ne.length>0)for(let We=0,$e=Re.length;We<$e;We++){const Je=Re[We];Oa(fe,ne,U,Je)}je&&Ye.render(U);for(let We=0,$e=Re.length;We<$e;We++){const Je=Re[We];Go(p,U,Je,Je.viewport)}}else ne.length>0&&Oa(fe,ne,U,J),je&&Ye.render(U),Go(p,U,J);M!==null&&A===0&&(N.updateMultisampleRenderTarget(M),N.updateRenderTargetMipmap(M)),U.isScene===!0&&U.onAfterRender(w,U,J),Rt.resetDefaultState(),_=-1,S=null,x.pop(),x.length>0?(g=x[x.length-1],ee===!0&&re.setGlobalState(w.clippingPlanes,g.state.camera)):g=null,y.pop(),y.length>0?p=y[y.length-1]:p=null};function ka(U,J,he,fe){if(U.visible===!1)return;if(U.layers.test(J.layers)){if(U.isGroup)he=U.renderOrder;else if(U.isLOD)U.autoUpdate===!0&&U.update(J);else if(U.isLight)g.pushLight(U),U.castShadow&&g.pushShadow(U);else if(U.isSprite){if(!U.frustumCulled||X.intersectsSprite(U)){fe&&be.setFromMatrixPosition(U.matrixWorld).applyMatrix4(ue);const We=ce.update(U),$e=U.material;$e.visible&&p.push(U,We,$e,he,be.z,null)}}else if((U.isMesh||U.isLine||U.isPoints)&&(!U.frustumCulled||X.intersectsObject(U))){const We=ce.update(U),$e=U.material;if(fe&&(U.boundingSphere!==void 0?(U.boundingSphere===null&&U.computeBoundingSphere(),be.copy(U.boundingSphere.center)):(We.boundingSphere===null&&We.computeBoundingSphere(),be.copy(We.boundingSphere.center)),be.applyMatrix4(U.matrixWorld).applyMatrix4(ue)),Array.isArray($e)){const Je=We.groups;for(let pt=0,mt=Je.length;pt<mt;pt++){const at=Je[pt],St=$e[at.materialIndex];St&&St.visible&&p.push(U,We,St,he,be.z,at)}}else $e.visible&&p.push(U,We,$e,he,be.z,null)}}const Re=U.children;for(let We=0,$e=Re.length;We<$e;We++)ka(Re[We],J,he,fe)}function Go(U,J,he,fe){const ne=U.opaque,Re=U.transmissive,We=U.transparent;g.setupLightsView(he),ee===!0&&re.setGlobalState(w.clippingPlanes,he),fe&&Se.viewport(R.copy(fe)),ne.length>0&&Cr(ne,J,he),Re.length>0&&Cr(Re,J,he),We.length>0&&Cr(We,J,he),Se.buffers.depth.setTest(!0),Se.buffers.depth.setMask(!0),Se.buffers.color.setMask(!0),Se.setPolygonOffset(!1)}function Oa(U,J,he,fe){if((he.isScene===!0?he.overrideMaterial:null)!==null)return;g.state.transmissionRenderTarget[fe.id]===void 0&&(g.state.transmissionRenderTarget[fe.id]=new ni(1,1,{generateMipmaps:!0,type:Ue.has("EXT_color_buffer_half_float")||Ue.has("EXT_color_buffer_float")?Ri:Ms,minFilter:ji,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:ft.workingColorSpace}));const Re=g.state.transmissionRenderTarget[fe.id],We=fe.viewport||R;Re.setSize(We.z*w.transmissionResolutionScale,We.w*w.transmissionResolutionScale);const $e=w.getRenderTarget();w.setRenderTarget(Re),w.getClearColor(H),q=w.getClearAlpha(),q<1&&w.setClearColor(16777215,.5),w.clear(),je&&Ye.render(he);const Je=w.toneMapping;w.toneMapping=Xs;const pt=fe.viewport;if(fe.viewport!==void 0&&(fe.viewport=void 0),g.setupLightsView(fe),ee===!0&&re.setGlobalState(w.clippingPlanes,fe),Cr(U,he,fe),N.updateMultisampleRenderTarget(Re),N.updateRenderTargetMipmap(Re),Ue.has("WEBGL_multisampled_render_to_texture")===!1){let mt=!1;for(let at=0,St=J.length;at<St;at++){const It=J[at],an=It.object,nn=It.geometry,Nt=It.material,lt=It.group;if(Nt.side===ln&&an.layers.test(fe.layers)){const yn=Nt.side;Nt.side=fi,Nt.needsUpdate=!0,Fa(an,he,fe,nn,Nt,lt),Nt.side=yn,Nt.needsUpdate=!0,mt=!0}}mt===!0&&(N.updateMultisampleRenderTarget(Re),N.updateRenderTargetMipmap(Re))}w.setRenderTarget($e),w.setClearColor(H,q),pt!==void 0&&(fe.viewport=pt),w.toneMapping=Je}function Cr(U,J,he){const fe=J.isScene===!0?J.overrideMaterial:null;for(let ne=0,Re=U.length;ne<Re;ne++){const We=U[ne],$e=We.object,Je=We.geometry,pt=fe===null?We.material:fe,mt=We.group;$e.layers.test(he.layers)&&Fa($e,J,he,Je,pt,mt)}}function Fa(U,J,he,fe,ne,Re){U.onBeforeRender(w,J,he,fe,ne,Re),U.modelViewMatrix.multiplyMatrices(he.matrixWorldInverse,U.matrixWorld),U.normalMatrix.getNormalMatrix(U.modelViewMatrix),ne.onBeforeRender(w,J,he,fe,U,Re),ne.transparent===!0&&ne.side===ln&&ne.forceSinglePass===!1?(ne.side=fi,ne.needsUpdate=!0,w.renderBufferDirect(he,J,fe,ne,U,Re),ne.side=Si,ne.needsUpdate=!0,w.renderBufferDirect(he,J,fe,ne,U,Re),ne.side=ln):w.renderBufferDirect(he,J,fe,ne,U,Re),U.onAfterRender(w,J,he,fe,ne,Re)}function Pr(U,J,he){J.isScene!==!0&&(J=Ce);const fe=Be.get(U),ne=g.state.lights,Re=g.state.shadowsArray,We=ne.state.version,$e=Oe.getParameters(U,ne.state,Re,J,he),Je=Oe.getProgramCacheKey($e);let pt=fe.programs;fe.environment=U.isMeshStandardMaterial?J.environment:null,fe.fog=J.fog,fe.envMap=(U.isMeshStandardMaterial?W:E).get(U.envMap||fe.environment),fe.envMapRotation=fe.environment!==null&&U.envMap===null?J.environmentRotation:U.envMapRotation,pt===void 0&&(U.addEventListener("dispose",vt),pt=new Map,fe.programs=pt);let mt=pt.get(Je);if(mt!==void 0){if(fe.currentProgram===mt&&fe.lightsStateVersion===We)return Wo(U,$e),mt}else $e.uniforms=Oe.getUniforms(U),U.onBeforeCompile($e,w),mt=Oe.acquireProgram($e,Je),pt.set(Je,mt),fe.uniforms=$e.uniforms;const at=fe.uniforms;return(!U.isShaderMaterial&&!U.isRawShaderMaterial||U.clipping===!0)&&(at.clippingPlanes=re.uniform),Wo(U,$e),fe.needsLights=Xc(U),fe.lightsStateVersion=We,fe.needsLights&&(at.ambientLightColor.value=ne.state.ambient,at.lightProbe.value=ne.state.probe,at.directionalLights.value=ne.state.directional,at.directionalLightShadows.value=ne.state.directionalShadow,at.spotLights.value=ne.state.spot,at.spotLightShadows.value=ne.state.spotShadow,at.rectAreaLights.value=ne.state.rectArea,at.ltc_1.value=ne.state.rectAreaLTC1,at.ltc_2.value=ne.state.rectAreaLTC2,at.pointLights.value=ne.state.point,at.pointLightShadows.value=ne.state.pointShadow,at.hemisphereLights.value=ne.state.hemi,at.directionalShadowMap.value=ne.state.directionalShadowMap,at.directionalShadowMatrix.value=ne.state.directionalShadowMatrix,at.spotShadowMap.value=ne.state.spotShadowMap,at.spotLightMatrix.value=ne.state.spotLightMatrix,at.spotLightMap.value=ne.state.spotLightMap,at.pointShadowMap.value=ne.state.pointShadowMap,at.pointShadowMatrix.value=ne.state.pointShadowMatrix),fe.currentProgram=mt,fe.uniformsList=null,mt}function Vo(U){if(U.uniformsList===null){const J=U.currentProgram.getUniforms();U.uniformsList=fc.seqWithValue(J.seq,U.uniforms)}return U.uniformsList}function Wo(U,J){const he=Be.get(U);he.outputColorSpace=J.outputColorSpace,he.batching=J.batching,he.batchingColor=J.batchingColor,he.instancing=J.instancing,he.instancingColor=J.instancingColor,he.instancingMorph=J.instancingMorph,he.skinning=J.skinning,he.morphTargets=J.morphTargets,he.morphNormals=J.morphNormals,he.morphColors=J.morphColors,he.morphTargetsCount=J.morphTargetsCount,he.numClippingPlanes=J.numClippingPlanes,he.numIntersection=J.numClipIntersection,he.vertexAlphas=J.vertexAlphas,he.vertexTangents=J.vertexTangents,he.toneMapping=J.toneMapping}function Wc(U,J,he,fe,ne){J.isScene!==!0&&(J=Ce),N.resetTextureUnits();const Re=J.fog,We=fe.isMeshStandardMaterial?J.environment:null,$e=M===null?w.outputColorSpace:M.isXRRenderTarget===!0?M.texture.colorSpace:$n,Je=(fe.isMeshStandardMaterial?W:E).get(fe.envMap||We),pt=fe.vertexColors===!0&&!!he.attributes.color&&he.attributes.color.itemSize===4,mt=!!he.attributes.tangent&&(!!fe.normalMap||fe.anisotropy>0),at=!!he.morphAttributes.position,St=!!he.morphAttributes.normal,It=!!he.morphAttributes.color;let an=Xs;fe.toneMapped&&(M===null||M.isXRRenderTarget===!0)&&(an=w.toneMapping);const nn=he.morphAttributes.position||he.morphAttributes.normal||he.morphAttributes.color,Nt=nn!==void 0?nn.length:0,lt=Be.get(fe),yn=g.state.lights;if(ee===!0&&(ie===!0||U!==S)){const fn=U===S&&fe.id===_;re.setState(fe,U,fn)}let kt=!1;fe.version===lt.__version?(lt.needsLights&<.lightsStateVersion!==yn.state.version||lt.outputColorSpace!==$e||ne.isBatchedMesh&<.batching===!1||!ne.isBatchedMesh&<.batching===!0||ne.isBatchedMesh&<.batchingColor===!0&&ne.colorTexture===null||ne.isBatchedMesh&<.batchingColor===!1&&ne.colorTexture!==null||ne.isInstancedMesh&<.instancing===!1||!ne.isInstancedMesh&<.instancing===!0||ne.isSkinnedMesh&<.skinning===!1||!ne.isSkinnedMesh&<.skinning===!0||ne.isInstancedMesh&<.instancingColor===!0&&ne.instanceColor===null||ne.isInstancedMesh&<.instancingColor===!1&&ne.instanceColor!==null||ne.isInstancedMesh&<.instancingMorph===!0&&ne.morphTexture===null||ne.isInstancedMesh&<.instancingMorph===!1&&ne.morphTexture!==null||lt.envMap!==Je||fe.fog===!0&<.fog!==Re||lt.numClippingPlanes!==void 0&&(lt.numClippingPlanes!==re.numPlanes||lt.numIntersection!==re.numIntersection)||lt.vertexAlphas!==pt||lt.vertexTangents!==mt||lt.morphTargets!==at||lt.morphNormals!==St||lt.morphColors!==It||lt.toneMapping!==an||lt.morphTargetsCount!==Nt)&&(kt=!0):(kt=!0,lt.__version=fe.version);let ri=lt.currentProgram;kt===!0&&(ri=Pr(fe,J,ne));let Kt=!1,Ln=!1,Js=!1;const Xt=ri.getUniforms(),Qn=lt.uniforms;if(Se.useProgram(ri.program)&&(Kt=!0,Ln=!0,Js=!0),fe.id!==_&&(_=fe.id,Ln=!0),Kt||S!==U){Se.buffers.depth.getReversed()?(Z.copy(U.projectionMatrix),$x(Z),Qx(Z),Xt.setValue(j,"projectionMatrix",Z)):Xt.setValue(j,"projectionMatrix",U.projectionMatrix),Xt.setValue(j,"viewMatrix",U.matrixWorldInverse);const xn=Xt.map.cameraPosition;xn!==void 0&&xn.setValue(j,oe.setFromMatrixPosition(U.matrixWorld)),Te.logarithmicDepthBuffer&&Xt.setValue(j,"logDepthBufFC",2/(Math.log(U.far+1)/Math.LN2)),(fe.isMeshPhongMaterial||fe.isMeshToonMaterial||fe.isMeshLambertMaterial||fe.isMeshBasicMaterial||fe.isMeshStandardMaterial||fe.isShaderMaterial)&&Xt.setValue(j,"isOrthographic",U.isOrthographicCamera===!0),S!==U&&(S=U,Ln=!0,Js=!0)}if(ne.isSkinnedMesh){Xt.setOptional(j,ne,"bindMatrix"),Xt.setOptional(j,ne,"bindMatrixInverse");const fn=ne.skeleton;fn&&(fn.boneTexture===null&&fn.computeBoneTexture(),Xt.setValue(j,"boneTexture",fn.boneTexture,N))}ne.isBatchedMesh&&(Xt.setOptional(j,ne,"batchingTexture"),Xt.setValue(j,"batchingTexture",ne._matricesTexture,N),Xt.setOptional(j,ne,"batchingIdTexture"),Xt.setValue(j,"batchingIdTexture",ne._indirectTexture,N),Xt.setOptional(j,ne,"batchingColorTexture"),ne._colorsTexture!==null&&Xt.setValue(j,"batchingColorTexture",ne._colorsTexture,N));const Gn=he.morphAttributes;if((Gn.position!==void 0||Gn.normal!==void 0||Gn.color!==void 0)&&xe.update(ne,he,ri),(Ln||lt.receiveShadow!==ne.receiveShadow)&&(lt.receiveShadow=ne.receiveShadow,Xt.setValue(j,"receiveShadow",ne.receiveShadow)),fe.isMeshGouraudMaterial&&fe.envMap!==null&&(Qn.envMap.value=Je,Qn.flipEnvMap.value=Je.isCubeTexture&&Je.isRenderTargetTexture===!1?-1:1),fe.isMeshStandardMaterial&&fe.envMap===null&&J.environment!==null&&(Qn.envMapIntensity.value=J.environmentIntensity),Ln&&(Xt.setValue(j,"toneMappingExposure",w.toneMappingExposure),lt.needsLights&&jc(Qn,Js),Re&&fe.fog===!0&&Pe.refreshFogUniforms(Qn,Re),Pe.refreshMaterialUniforms(Qn,fe,V,K,g.state.transmissionRenderTarget[U.id]),fc.upload(j,Vo(lt),Qn,N)),fe.isShaderMaterial&&fe.uniformsNeedUpdate===!0&&(fc.upload(j,Vo(lt),Qn,N),fe.uniformsNeedUpdate=!1),fe.isSpriteMaterial&&Xt.setValue(j,"center",ne.center),Xt.setValue(j,"modelViewMatrix",ne.modelViewMatrix),Xt.setValue(j,"normalMatrix",ne.normalMatrix),Xt.setValue(j,"modelMatrix",ne.matrixWorld),fe.isShaderMaterial||fe.isRawShaderMaterial){const fn=fe.uniformsGroups;for(let xn=0,Rr=fn.length;xn<Rr;xn++){const ls=fn[xn];Q.update(ls,ri),Q.bind(ls,ri)}}return ri}function jc(U,J){U.ambientLightColor.needsUpdate=J,U.lightProbe.needsUpdate=J,U.directionalLights.needsUpdate=J,U.directionalLightShadows.needsUpdate=J,U.pointLights.needsUpdate=J,U.pointLightShadows.needsUpdate=J,U.spotLights.needsUpdate=J,U.spotLightShadows.needsUpdate=J,U.rectAreaLights.needsUpdate=J,U.hemisphereLights.needsUpdate=J}function Xc(U){return U.isMeshLambertMaterial||U.isMeshToonMaterial||U.isMeshPhongMaterial||U.isMeshStandardMaterial||U.isShadowMaterial||U.isShaderMaterial&&U.lights===!0}this.getActiveCubeFace=function(){return T},this.getActiveMipmapLevel=function(){return A},this.getRenderTarget=function(){return M},this.setRenderTargetTextures=function(U,J,he){Be.get(U.texture).__webglTexture=J,Be.get(U.depthTexture).__webglTexture=he;const fe=Be.get(U);fe.__hasExternalTextures=!0,fe.__autoAllocateDepthBuffer=he===void 0,fe.__autoAllocateDepthBuffer||Ue.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),fe.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(U,J){const he=Be.get(U);he.__webglFramebuffer=J,he.__useDefaultFramebuffer=J===void 0};const qc=j.createFramebuffer();this.setRenderTarget=function(U,J=0,he=0){M=U,T=J,A=he;let fe=!0,ne=null,Re=!1,We=!1;if(U){const Je=Be.get(U);if(Je.__useDefaultFramebuffer!==void 0)Se.bindFramebuffer(j.FRAMEBUFFER,null),fe=!1;else if(Je.__webglFramebuffer===void 0)N.setupRenderTarget(U);else if(Je.__hasExternalTextures)N.rebindTextures(U,Be.get(U.texture).__webglTexture,Be.get(U.depthTexture).__webglTexture);else if(U.depthBuffer){const at=U.depthTexture;if(Je.__boundDepthTexture!==at){if(at!==null&&Be.has(at)&&(U.width!==at.image.width||U.height!==at.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");N.setupDepthRenderbuffer(U)}}const pt=U.texture;(pt.isData3DTexture||pt.isDataArrayTexture||pt.isCompressedArrayTexture)&&(We=!0);const mt=Be.get(U).__webglFramebuffer;U.isWebGLCubeRenderTarget?(Array.isArray(mt[J])?ne=mt[J][he]:ne=mt[J],Re=!0):U.samples>0&&N.useMultisampledRTT(U)===!1?ne=Be.get(U).__webglMultisampledFramebuffer:Array.isArray(mt)?ne=mt[he]:ne=mt,R.copy(U.viewport),k.copy(U.scissor),O=U.scissorTest}else R.copy(se).multiplyScalar(V).floor(),k.copy(ge).multiplyScalar(V).floor(),O=de;if(he!==0&&(ne=qc),Se.bindFramebuffer(j.FRAMEBUFFER,ne)&&fe&&Se.drawBuffers(U,ne),Se.viewport(R),Se.scissor(k),Se.setScissorTest(O),Re){const Je=Be.get(U.texture);j.framebufferTexture2D(j.FRAMEBUFFER,j.COLOR_ATTACHMENT0,j.TEXTURE_CUBE_MAP_POSITIVE_X+J,Je.__webglTexture,he)}else if(We){const Je=Be.get(U.texture),pt=J;j.framebufferTextureLayer(j.FRAMEBUFFER,j.COLOR_ATTACHMENT0,Je.__webglTexture,he,pt)}else if(U!==null&&he!==0){const Je=Be.get(U.texture);j.framebufferTexture2D(j.FRAMEBUFFER,j.COLOR_ATTACHMENT0,j.TEXTURE_2D,Je.__webglTexture,he)}_=-1},this.readRenderTargetPixels=function(U,J,he,fe,ne,Re,We){if(!(U&&U.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let $e=Be.get(U).__webglFramebuffer;if(U.isWebGLCubeRenderTarget&&We!==void 0&&($e=$e[We]),$e){Se.bindFramebuffer(j.FRAMEBUFFER,$e);try{const Je=U.texture,pt=Je.format,mt=Je.type;if(!Te.textureFormatReadable(pt)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!Te.textureTypeReadable(mt)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}J>=0&&J<=U.width-fe&&he>=0&&he<=U.height-ne&&j.readPixels(J,he,fe,ne,rt.convert(pt),rt.convert(mt),Re)}finally{const Je=M!==null?Be.get(M).__webglFramebuffer:null;Se.bindFramebuffer(j.FRAMEBUFFER,Je)}}},this.readRenderTargetPixelsAsync=async function(U,J,he,fe,ne,Re,We){if(!(U&&U.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let $e=Be.get(U).__webglFramebuffer;if(U.isWebGLCubeRenderTarget&&We!==void 0&&($e=$e[We]),$e){const Je=U.texture,pt=Je.format,mt=Je.type;if(!Te.textureFormatReadable(pt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!Te.textureTypeReadable(mt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");if(J>=0&&J<=U.width-fe&&he>=0&&he<=U.height-ne){Se.bindFramebuffer(j.FRAMEBUFFER,$e);const at=j.createBuffer();j.bindBuffer(j.PIXEL_PACK_BUFFER,at),j.bufferData(j.PIXEL_PACK_BUFFER,Re.byteLength,j.STREAM_READ),j.readPixels(J,he,fe,ne,rt.convert(pt),rt.convert(mt),0);const St=M!==null?Be.get(M).__webglFramebuffer:null;Se.bindFramebuffer(j.FRAMEBUFFER,St);const It=j.fenceSync(j.SYNC_GPU_COMMANDS_COMPLETE,0);return j.flush(),await Kx(j,It,4),j.bindBuffer(j.PIXEL_PACK_BUFFER,at),j.getBufferSubData(j.PIXEL_PACK_BUFFER,0,Re),j.deleteBuffer(at),j.deleteSync(It),Re}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(U,J=null,he=0){U.isTexture!==!0&&(hr("WebGLRenderer: copyFramebufferToTexture function signature has changed."),J=arguments[0]||null,U=arguments[1]);const fe=Math.pow(2,-he),ne=Math.floor(U.image.width*fe),Re=Math.floor(U.image.height*fe),We=J!==null?J.x:0,$e=J!==null?J.y:0;N.setTexture2D(U,0),j.copyTexSubImage2D(j.TEXTURE_2D,he,0,0,We,$e,ne,Re),Se.unbindTexture()};const Zc=j.createFramebuffer(),Yc=j.createFramebuffer();this.copyTextureToTexture=function(U,J,he=null,fe=null,ne=0,Re=null){U.isTexture!==!0&&(hr("WebGLRenderer: copyTextureToTexture function signature has changed."),fe=arguments[0]||null,U=arguments[1],J=arguments[2],Re=arguments[3]||0,he=null),Re===null&&(ne!==0?(hr("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),Re=ne,ne=0):Re=0);let We,$e,Je,pt,mt,at,St,It,an;const nn=U.isCompressedTexture?U.mipmaps[Re]:U.image;if(he!==null)We=he.max.x-he.min.x,$e=he.max.y-he.min.y,Je=he.isBox3?he.max.z-he.min.z:1,pt=he.min.x,mt=he.min.y,at=he.isBox3?he.min.z:0;else{const Gn=Math.pow(2,-ne);We=Math.floor(nn.width*Gn),$e=Math.floor(nn.height*Gn),U.isDataArrayTexture?Je=nn.depth:U.isData3DTexture?Je=Math.floor(nn.depth*Gn):Je=1,pt=0,mt=0,at=0}fe!==null?(St=fe.x,It=fe.y,an=fe.z):(St=0,It=0,an=0);const Nt=rt.convert(J.format),lt=rt.convert(J.type);let yn;J.isData3DTexture?(N.setTexture3D(J,0),yn=j.TEXTURE_3D):J.isDataArrayTexture||J.isCompressedArrayTexture?(N.setTexture2DArray(J,0),yn=j.TEXTURE_2D_ARRAY):(N.setTexture2D(J,0),yn=j.TEXTURE_2D),j.pixelStorei(j.UNPACK_FLIP_Y_WEBGL,J.flipY),j.pixelStorei(j.UNPACK_PREMULTIPLY_ALPHA_WEBGL,J.premultiplyAlpha),j.pixelStorei(j.UNPACK_ALIGNMENT,J.unpackAlignment);const kt=j.getParameter(j.UNPACK_ROW_LENGTH),ri=j.getParameter(j.UNPACK_IMAGE_HEIGHT),Kt=j.getParameter(j.UNPACK_SKIP_PIXELS),Ln=j.getParameter(j.UNPACK_SKIP_ROWS),Js=j.getParameter(j.UNPACK_SKIP_IMAGES);j.pixelStorei(j.UNPACK_ROW_LENGTH,nn.width),j.pixelStorei(j.UNPACK_IMAGE_HEIGHT,nn.height),j.pixelStorei(j.UNPACK_SKIP_PIXELS,pt),j.pixelStorei(j.UNPACK_SKIP_ROWS,mt),j.pixelStorei(j.UNPACK_SKIP_IMAGES,at);const Xt=U.isDataArrayTexture||U.isData3DTexture,Qn=J.isDataArrayTexture||J.isData3DTexture;if(U.isDepthTexture){const Gn=Be.get(U),fn=Be.get(J),xn=Be.get(Gn.__renderTarget),Rr=Be.get(fn.__renderTarget);Se.bindFramebuffer(j.READ_FRAMEBUFFER,xn.__webglFramebuffer),Se.bindFramebuffer(j.DRAW_FRAMEBUFFER,Rr.__webglFramebuffer);for(let ls=0;ls<Je;ls++)Xt&&(j.framebufferTextureLayer(j.READ_FRAMEBUFFER,j.COLOR_ATTACHMENT0,Be.get(U).__webglTexture,ne,at+ls),j.framebufferTextureLayer(j.DRAW_FRAMEBUFFER,j.COLOR_ATTACHMENT0,Be.get(J).__webglTexture,Re,an+ls)),j.blitFramebuffer(pt,mt,We,$e,St,It,We,$e,j.DEPTH_BUFFER_BIT,j.NEAREST);Se.bindFramebuffer(j.READ_FRAMEBUFFER,null),Se.bindFramebuffer(j.DRAW_FRAMEBUFFER,null)}else if(ne!==0||U.isRenderTargetTexture||Be.has(U)){const Gn=Be.get(U),fn=Be.get(J);Se.bindFramebuffer(j.READ_FRAMEBUFFER,Zc),Se.bindFramebuffer(j.DRAW_FRAMEBUFFER,Yc);for(let xn=0;xn<Je;xn++)Xt?j.framebufferTextureLayer(j.READ_FRAMEBUFFER,j.COLOR_ATTACHMENT0,Gn.__webglTexture,ne,at+xn):j.framebufferTexture2D(j.READ_FRAMEBUFFER,j.COLOR_ATTACHMENT0,j.TEXTURE_2D,Gn.__webglTexture,ne),Qn?j.framebufferTextureLayer(j.DRAW_FRAMEBUFFER,j.COLOR_ATTACHMENT0,fn.__webglTexture,Re,an+xn):j.framebufferTexture2D(j.DRAW_FRAMEBUFFER,j.COLOR_ATTACHMENT0,j.TEXTURE_2D,fn.__webglTexture,Re),ne!==0?j.blitFramebuffer(pt,mt,We,$e,St,It,We,$e,j.COLOR_BUFFER_BIT,j.NEAREST):Qn?j.copyTexSubImage3D(yn,Re,St,It,an+xn,pt,mt,We,$e):j.copyTexSubImage2D(yn,Re,St,It,pt,mt,We,$e);Se.bindFramebuffer(j.READ_FRAMEBUFFER,null),Se.bindFramebuffer(j.DRAW_FRAMEBUFFER,null)}else Qn?U.isDataTexture||U.isData3DTexture?j.texSubImage3D(yn,Re,St,It,an,We,$e,Je,Nt,lt,nn.data):J.isCompressedArrayTexture?j.compressedTexSubImage3D(yn,Re,St,It,an,We,$e,Je,Nt,nn.data):j.texSubImage3D(yn,Re,St,It,an,We,$e,Je,Nt,lt,nn):U.isDataTexture?j.texSubImage2D(j.TEXTURE_2D,Re,St,It,We,$e,Nt,lt,nn.data):U.isCompressedTexture?j.compressedTexSubImage2D(j.TEXTURE_2D,Re,St,It,nn.width,nn.height,Nt,nn.data):j.texSubImage2D(j.TEXTURE_2D,Re,St,It,We,$e,Nt,lt,nn);j.pixelStorei(j.UNPACK_ROW_LENGTH,kt),j.pixelStorei(j.UNPACK_IMAGE_HEIGHT,ri),j.pixelStorei(j.UNPACK_SKIP_PIXELS,Kt),j.pixelStorei(j.UNPACK_SKIP_ROWS,Ln),j.pixelStorei(j.UNPACK_SKIP_IMAGES,Js),Re===0&&J.generateMipmaps&&j.generateMipmap(yn),Se.unbindTexture()},this.copyTextureToTexture3D=function(U,J,he=null,fe=null,ne=0){return U.isTexture!==!0&&(hr("WebGLRenderer: copyTextureToTexture3D function signature has changed."),he=arguments[0]||null,fe=arguments[1]||null,U=arguments[2],J=arguments[3],ne=arguments[4]||0),hr('WebGLRenderer: copyTextureToTexture3D function has been deprecated. Use "copyTextureToTexture" instead.'),this.copyTextureToTexture(U,J,he,fe,ne)},this.initRenderTarget=function(U){Be.get(U).__webglFramebuffer===void 0&&N.setupRenderTarget(U)},this.initTexture=function(U){U.isCubeTexture?N.setTextureCube(U,0):U.isData3DTexture?N.setTexture3D(U,0):U.isDataArrayTexture||U.isCompressedArrayTexture?N.setTexture2DArray(U,0):N.setTexture2D(U,0),Se.unbindTexture()},this.resetState=function(){T=0,A=0,M=null,Se.reset(),Rt.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return _s}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorspace=ft._getDrawingBufferColorSpace(e),t.unpackColorSpace=ft._getUnpackColorSpace()}}const XN={EDIT:"EDIT",PLAY:"PLAY"},EE="0.0.1",qN="editor-camera-position",Yb=16765952,Kb=.1,_u=.25,Ta=new gn(50,1,.01,1e3);Ta.up.set(0,0,1);Ta.name="Camera";Ta.position.set(-7.5,0,10);Ta.lookAt(new I);const gs={GOAL:"GOAL",ROUTE:"ROUTE",ALIGN:"ALIGN"},rm={NO_ENTRY:15680580,IGNORE_LIDAR_2D:15381256,IGNORE_LIDAR_3D:2278750},am=new Yt,Il=new I;class $b extends P_{constructor(){super(),this.isLineSegmentsGeometry=!0,this.type="LineSegmentsGeometry";const e=[-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],t=[-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],n=[0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5];this.setIndex(n),this.setAttribute("position",new ke(e,3)),this.setAttribute("uv",new ke(t,2))}applyMatrix4(e){const t=this.attributes.instanceStart,n=this.attributes.instanceEnd;return t!==void 0&&(t.applyMatrix4(e),n.applyMatrix4(e),t.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}setPositions(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));const n=new vu(t,6,1);return this.setAttribute("instanceStart",new Xi(n,3,0)),this.setAttribute("instanceEnd",new Xi(n,3,3)),this.instanceCount=this.attributes.instanceStart.count,this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));const n=new vu(t,6,1);return this.setAttribute("instanceColorStart",new Xi(n,3,0)),this.setAttribute("instanceColorEnd",new Xi(n,3,3)),this}fromWireframeGeometry(e){return this.setPositions(e.attributes.position.array),this}fromEdgesGeometry(e){return this.setPositions(e.attributes.position.array),this}fromMesh(e){return this.fromWireframeGeometry(new u_(e.geometry)),this}fromLineSegments(e){const t=e.geometry;return this.setPositions(t.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Yt);const e=this.attributes.instanceStart,t=this.attributes.instanceEnd;e!==void 0&&t!==void 0&&(this.boundingBox.setFromBufferAttribute(e),am.setFromBufferAttribute(t),this.boundingBox.union(am))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new vn),this.boundingBox===null&&this.computeBoundingBox();const e=this.attributes.instanceStart,t=this.attributes.instanceEnd;if(e!==void 0&&t!==void 0){const n=this.boundingSphere.center;this.boundingBox.getCenter(n);let i=0;for(let s=0,a=e.count;s<a;s++)Il.fromBufferAttribute(e,s),i=Math.max(i,n.distanceToSquared(Il)),Il.fromBufferAttribute(t,s),i=Math.max(i,n.distanceToSquared(Il));this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error("THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.",this)}}toJSON(){}applyMatrix(e){return console.warn("THREE.LineSegmentsGeometry: applyMatrix() has been renamed to applyMatrix4()."),this.applyMatrix4(e)}}He.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new me(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}};di.line={uniforms:Ca.merge([He.common,He.fog,He.line]),vertexShader:`
|
|
3857
3857
|
#include <common>
|
|
3858
3858
|
#include <color_pars_vertex>
|
|
3859
3859
|
#include <fog_pars_vertex>
|
|
@@ -4223,9 +4223,9 @@ void main() {
|
|
|
4223
4223
|
#include <premultiplied_alpha_fragment>
|
|
4224
4224
|
|
|
4225
4225
|
}
|
|
4226
|
-
`};class To extends wn{constructor(e){super({type:"LineMaterial",uniforms:Ca.clone(di.line.uniforms),vertexShader:di.line.vertexShader,fragmentShader:di.line.fragmentShader,clipping:!0}),this.isLineMaterial=!0,this.setValues(e)}get color(){return this.uniforms.diffuse.value}set color(e){this.uniforms.diffuse.value=e}get worldUnits(){return"WORLD_UNITS"in this.defines}set worldUnits(e){e===!0?this.defines.WORLD_UNITS="":delete this.defines.WORLD_UNITS}get linewidth(){return this.uniforms.linewidth.value}set linewidth(e){this.uniforms.linewidth&&(this.uniforms.linewidth.value=e)}get dashed(){return"USE_DASH"in this.defines}set dashed(e){e===!0!==this.dashed&&(this.needsUpdate=!0),e===!0?this.defines.USE_DASH="":delete this.defines.USE_DASH}get dashScale(){return this.uniforms.dashScale.value}set dashScale(e){this.uniforms.dashScale.value=e}get dashSize(){return this.uniforms.dashSize.value}set dashSize(e){this.uniforms.dashSize.value=e}get dashOffset(){return this.uniforms.dashOffset.value}set dashOffset(e){this.uniforms.dashOffset.value=e}get gapSize(){return this.uniforms.gapSize.value}set gapSize(e){this.uniforms.gapSize.value=e}get opacity(){return this.uniforms.opacity.value}set opacity(e){this.uniforms&&(this.uniforms.opacity.value=e)}get resolution(){return this.uniforms.resolution.value}set resolution(e){this.uniforms.resolution.value.copy(e)}get alphaToCoverage(){return"USE_ALPHA_TO_COVERAGE"in this.defines}set alphaToCoverage(e){this.defines&&(e===!0!==this.alphaToCoverage&&(this.needsUpdate=!0),e===!0?this.defines.USE_ALPHA_TO_COVERAGE="":delete this.defines.USE_ALPHA_TO_COVERAGE)}}const Ud=new _t,om=new I,lm=new I,In=new _t,kn=new _t,Ki=new _t,Bd=new I,zd=new Ie,On=new H_,cm=new I,kl=new Yt,Ol=new vn,$i=new _t;let is,_r;function dm(r,e,t){return $i.set(0,0,-e,1).applyMatrix4(r.projectionMatrix),$i.multiplyScalar(1/$i.w),$i.x=_r/t.width,$i.y=_r/t.height,$i.applyMatrix4(r.projectionMatrixInverse),$i.multiplyScalar(1/$i.w),Math.abs(Math.max($i.x,$i.y))}function AE(r,e){const t=r.matrixWorld,n=r.geometry,i=n.attributes.instanceStart,s=n.attributes.instanceEnd,a=Math.min(n.instanceCount,i.count);for(let o=0,l=a;o<l;o++){On.start.fromBufferAttribute(i,o),On.end.fromBufferAttribute(s,o),On.applyMatrix4(t);const c=new I,d=new I;is.distanceSqToSegment(On.start,On.end,d,c),d.distanceTo(c)<_r*.5&&e.push({point:d,pointOnLine:c,distance:is.origin.distanceTo(d),object:r,face:null,faceIndex:o,uv:null,uv1:null})}}function CE(r,e,t){const n=e.projectionMatrix,s=r.material.resolution,a=r.matrixWorld,o=r.geometry,l=o.attributes.instanceStart,c=o.attributes.instanceEnd,d=Math.min(o.instanceCount,l.count),h=-e.near;is.at(1,Ki),Ki.w=1,Ki.applyMatrix4(e.matrixWorldInverse),Ki.applyMatrix4(n),Ki.multiplyScalar(1/Ki.w),Ki.x*=s.x/2,Ki.y*=s.y/2,Ki.z=0,Bd.copy(Ki),zd.multiplyMatrices(e.matrixWorldInverse,a);for(let u=0,f=d;u<f;u++){if(In.fromBufferAttribute(l,u),kn.fromBufferAttribute(c,u),In.w=1,kn.w=1,In.applyMatrix4(zd),kn.applyMatrix4(zd),In.z>h&&kn.z>h)continue;if(In.z>h){const x=In.z-kn.z,w=(In.z-h)/x;In.lerp(kn,w)}else if(kn.z>h){const x=kn.z-In.z,w=(kn.z-h)/x;kn.lerp(In,w)}In.applyMatrix4(n),kn.applyMatrix4(n),In.multiplyScalar(1/In.w),kn.multiplyScalar(1/kn.w),In.x*=s.x/2,In.y*=s.y/2,kn.x*=s.x/2,kn.y*=s.y/2,On.start.copy(In),On.start.z=0,On.end.copy(kn),On.end.z=0;const b=On.closestPointToPointParameter(Bd,!0);On.at(b,cm);const p=bt.lerp(In.z,kn.z,b),g=p>=-1&&p<=1,y=Bd.distanceTo(cm)<_r*.5;if(g&&y){On.start.fromBufferAttribute(l,u),On.end.fromBufferAttribute(c,u),On.start.applyMatrix4(a),On.end.applyMatrix4(a);const x=new I,w=new I;is.distanceSqToSegment(On.start,On.end,w,x),t.push({point:w,pointOnLine:x,distance:is.origin.distanceTo(w),object:r,face:null,faceIndex:u,uv:null,uv1:null})}}}class PE extends Ee{constructor(e=new $b,t=new To({color:Math.random()*16777215})){super(e,t),this.isLineSegments2=!0,this.type="LineSegments2"}computeLineDistances(){const e=this.geometry,t=e.attributes.instanceStart,n=e.attributes.instanceEnd,i=new Float32Array(2*t.count);for(let a=0,o=0,l=t.count;a<l;a++,o+=2)om.fromBufferAttribute(t,a),lm.fromBufferAttribute(n,a),i[o]=o===0?0:i[o-1],i[o+1]=i[o]+om.distanceTo(lm);const s=new vu(i,2,1);return e.setAttribute("instanceDistanceStart",new Xi(s,1,0)),e.setAttribute("instanceDistanceEnd",new Xi(s,1,1)),this}raycast(e,t){const n=this.material.worldUnits,i=e.camera;i===null&&!n&&console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.');const s=e.params.Line2!==void 0&&e.params.Line2.threshold||0;is=e.ray;const a=this.matrixWorld,o=this.geometry,l=this.material;_r=l.linewidth+s,o.boundingSphere===null&&o.computeBoundingSphere(),Ol.copy(o.boundingSphere).applyMatrix4(a);let c;if(n)c=_r*.5;else{const h=Math.max(i.near,Ol.distanceToPoint(is.origin));c=dm(i,h,l.resolution)}if(Ol.radius+=c,is.intersectsSphere(Ol)===!1)return;o.boundingBox===null&&o.computeBoundingBox(),kl.copy(o.boundingBox).applyMatrix4(a);let d;if(n)d=_r*.5;else{const h=Math.max(i.near,kl.distanceToPoint(is.origin));d=dm(i,h,l.resolution)}kl.expandByScalar(d),is.intersectsBox(kl)!==!1&&(n?AE(this,t):CE(this,i,t))}onBeforeRender(e){const t=this.material.uniforms;t&&t.resolution&&(e.getViewport(Ud),this.material.uniforms.resolution.value.set(Ud.z,Ud.w))}}class js extends $b{constructor(){super(),this.isLineGeometry=!0,this.type="LineGeometry"}setPositions(e){const t=e.length-3,n=new Float32Array(2*t);for(let i=0;i<t;i+=3)n[2*i]=e[i],n[2*i+1]=e[i+1],n[2*i+2]=e[i+2],n[2*i+3]=e[i+3],n[2*i+4]=e[i+4],n[2*i+5]=e[i+5];return super.setPositions(n),this}setColors(e){const t=e.length-3,n=new Float32Array(2*t);for(let i=0;i<t;i+=3)n[2*i]=e[i],n[2*i+1]=e[i+1],n[2*i+2]=e[i+2],n[2*i+3]=e[i+3],n[2*i+4]=e[i+4],n[2*i+5]=e[i+5];return super.setColors(n),this}setFromPoints(e){const t=e.length-1,n=new Float32Array(6*t);for(let i=0;i<t;i++)n[6*i]=e[i].x,n[6*i+1]=e[i].y,n[6*i+2]=e[i].z||0,n[6*i+3]=e[i+1].x,n[6*i+4]=e[i+1].y,n[6*i+5]=e[i+1].z||0;return super.setPositions(n),this}fromLine(e){const t=e.geometry;return this.setPositions(t.attributes.position.array),this}}class fo extends PE{constructor(e=new js,t=new To({color:Math.random()*16777215})){super(e,t),this.isLine2=!0,this.type="Line2"}}const lr=new tf,Xn=new I,ks=new I,sn=new Lt,hm={X:new I(1,0,0),Y:new I(0,1,0),Z:new I(0,0,1)},Hd={type:"change"},um={type:"mouseDown",mode:null},fm={type:"mouseUp",mode:null},pm={type:"objectChange"};class RE extends Vb{constructor(e,t=null){super(void 0,t);const n=new OE(this);this._root=n;const i=new FE;this._gizmo=i,n.add(i);const s=new UE;this._plane=s,n.add(s);const a=this;function o(x,w){let P=w;Object.defineProperty(a,x,{get:function(){return P!==void 0?P:w},set:function(T){P!==T&&(P=T,s[x]=T,i[x]=T,a.dispatchEvent({type:x+"-changed",value:T}),a.dispatchEvent(Hd))}}),a[x]=w,s[x]=w,i[x]=w}o("camera",e),o("object",void 0),o("enabled",!0),o("axis",null),o("mode","translate"),o("translationSnap",null),o("rotationSnap",null),o("scaleSnap",null),o("space","world"),o("size",1),o("dragging",!1),o("showX",!0),o("showY",!0),o("showZ",!0),o("minX",-1/0),o("maxX",1/0),o("minY",-1/0),o("maxY",1/0),o("minZ",-1/0),o("maxZ",1/0);const l=new I,c=new I,d=new Lt,h=new Lt,u=new I,f=new Lt,m=new I,b=new I,p=new I,g=0,y=new I;o("worldPosition",l),o("worldPositionStart",c),o("worldQuaternion",d),o("worldQuaternionStart",h),o("cameraPosition",u),o("cameraQuaternion",f),o("pointStart",m),o("pointEnd",b),o("rotationAxis",p),o("rotationAngle",g),o("eye",y),this._offset=new I,this._startNorm=new I,this._endNorm=new I,this._cameraScale=new I,this._parentPosition=new I,this._parentQuaternion=new Lt,this._parentQuaternionInv=new Lt,this._parentScale=new I,this._worldScaleStart=new I,this._worldQuaternionInv=new Lt,this._worldScale=new I,this._positionStart=new I,this._quaternionStart=new Lt,this._scaleStart=new I,this._getPointer=NE.bind(this),this._onPointerDown=LE.bind(this),this._onPointerHover=DE.bind(this),this._onPointerMove=IE.bind(this),this._onPointerUp=kE.bind(this),t!==null&&this.connect()}connect(){this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointermove",this._onPointerHover),this.domElement.addEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerHover),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="auto"}getHelper(){return this._root}pointerHover(e){if(this.object===void 0||this.dragging===!0)return;e!==null&&lr.setFromCamera(e,this.camera);const t=Gd(this._gizmo.picker[this.mode],lr);t?this.axis=t.object.name:this.axis=null}pointerDown(e){if(!(this.object===void 0||this.dragging===!0||e!=null&&e.button!==0)&&this.axis!==null){e!==null&&lr.setFromCamera(e,this.camera);const t=Gd(this._plane,lr,!0);t&&(this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),this._positionStart.copy(this.object.position),this._quaternionStart.copy(this.object.quaternion),this._scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this._worldScaleStart),this.pointStart.copy(t.point).sub(this.worldPositionStart)),this.dragging=!0,um.mode=this.mode,this.dispatchEvent(um)}}pointerMove(e){const t=this.axis,n=this.mode,i=this.object;let s=this.space;if(n==="scale"?s="local":(t==="E"||t==="XYZE"||t==="XYZ")&&(s="world"),i===void 0||t===null||this.dragging===!1||e!==null&&e.button!==-1)return;e!==null&&lr.setFromCamera(e,this.camera);const a=Gd(this._plane,lr,!0);if(a){if(this.pointEnd.copy(a.point).sub(this.worldPositionStart),n==="translate")this._offset.copy(this.pointEnd).sub(this.pointStart),s==="local"&&t!=="XYZ"&&this._offset.applyQuaternion(this._worldQuaternionInv),t.indexOf("X")===-1&&(this._offset.x=0),t.indexOf("Y")===-1&&(this._offset.y=0),t.indexOf("Z")===-1&&(this._offset.z=0),s==="local"&&t!=="XYZ"?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),i.position.copy(this._offset).add(this._positionStart),this.translationSnap&&(s==="local"&&(i.position.applyQuaternion(sn.copy(this._quaternionStart).invert()),t.search("X")!==-1&&(i.position.x=Math.round(i.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(i.position.y=Math.round(i.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(i.position.z=Math.round(i.position.z/this.translationSnap)*this.translationSnap),i.position.applyQuaternion(this._quaternionStart)),s==="world"&&(i.parent&&i.position.add(Xn.setFromMatrixPosition(i.parent.matrixWorld)),t.search("X")!==-1&&(i.position.x=Math.round(i.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(i.position.y=Math.round(i.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(i.position.z=Math.round(i.position.z/this.translationSnap)*this.translationSnap),i.parent&&i.position.sub(Xn.setFromMatrixPosition(i.parent.matrixWorld)))),i.position.x=Math.max(this.minX,Math.min(this.maxX,i.position.x)),i.position.y=Math.max(this.minY,Math.min(this.maxY,i.position.y)),i.position.z=Math.max(this.minZ,Math.min(this.maxZ,i.position.z));else if(n==="scale"){if(t.search("XYZ")!==-1){let o=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(o*=-1),ks.set(o,o,o)}else Xn.copy(this.pointStart),ks.copy(this.pointEnd),Xn.applyQuaternion(this._worldQuaternionInv),ks.applyQuaternion(this._worldQuaternionInv),ks.divide(Xn),t.search("X")===-1&&(ks.x=1),t.search("Y")===-1&&(ks.y=1),t.search("Z")===-1&&(ks.z=1);i.scale.copy(this._scaleStart).multiply(ks),this.scaleSnap&&(t.search("X")!==-1&&(i.scale.x=Math.round(i.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Y")!==-1&&(i.scale.y=Math.round(i.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Z")!==-1&&(i.scale.z=Math.round(i.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(n==="rotate"){this._offset.copy(this.pointEnd).sub(this.pointStart);const o=20/this.worldPosition.distanceTo(Xn.setFromMatrixPosition(this.camera.matrixWorld));let l=!1;t==="XYZE"?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(Xn.copy(this.rotationAxis).cross(this.eye))*o):(t==="X"||t==="Y"||t==="Z")&&(this.rotationAxis.copy(hm[t]),Xn.copy(hm[t]),s==="local"&&Xn.applyQuaternion(this.worldQuaternion),Xn.cross(this.eye),Xn.length()===0?l=!0:this.rotationAngle=this._offset.dot(Xn.normalize())*o),(t==="E"||l)&&(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),s==="local"&&t!=="E"&&t!=="XYZE"?(i.quaternion.copy(this._quaternionStart),i.quaternion.multiply(sn.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),i.quaternion.copy(sn.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),i.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(Hd),this.dispatchEvent(pm)}}pointerUp(e){e!==null&&e.button!==0||(this.dragging&&this.axis!==null&&(fm.mode=this.mode,this.dispatchEvent(fm)),this.dragging=!1,this.axis=null)}dispose(){this.disconnect(),this._root.dispose()}attach(e){return this.object=e,this._root.visible=!0,this}detach(){return this.object=void 0,this.axis=null,this._root.visible=!1,this}reset(){this.enabled&&this.dragging&&(this.object.position.copy(this._positionStart),this.object.quaternion.copy(this._quaternionStart),this.object.scale.copy(this._scaleStart),this.dispatchEvent(Hd),this.dispatchEvent(pm),this.pointStart.copy(this.pointEnd))}getRaycaster(){return lr}getMode(){return this.mode}setMode(e){this.mode=e}setTranslationSnap(e){this.translationSnap=e}setRotationSnap(e){this.rotationSnap=e}setScaleSnap(e){this.scaleSnap=e}setSize(e){this.size=e}setSpace(e){this.space=e}}function NE(r){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:r.button};{const e=this.domElement.getBoundingClientRect();return{x:(r.clientX-e.left)/e.width*2-1,y:-(r.clientY-e.top)/e.height*2+1,button:r.button}}}function DE(r){if(this.enabled)switch(r.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(r));break}}function LE(r){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(r.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(r)),this.pointerDown(this._getPointer(r)))}function IE(r){this.enabled&&this.pointerMove(this._getPointer(r))}function kE(r){this.enabled&&(this.domElement.releasePointerCapture(r.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(r)))}function Gd(r,e,t){const n=e.intersectObject(r,!0);for(let i=0;i<n.length;i++)if(n[i].object.visible||t)return n[i];return!1}const Fl=new hn,Zt=new I(0,1,0),mm=new I(0,0,0),gm=new Ie,Ul=new Lt,pc=new Lt,Qi=new I,bm=new Ie,oo=new I(1,0,0),fr=new I(0,1,0),lo=new I(0,0,1),Bl=new I,Ka=new I,$a=new I;class OE extends Pt{constructor(e){super(),this.isTransformControlsRoot=!0,this.controls=e,this.visible=!1}updateMatrixWorld(e){const t=this.controls;t.object!==void 0&&(t.object.updateMatrixWorld(),t.object.parent===null?console.error("TransformControls: The attached 3D object must be a part of the scene graph."):t.object.parent.matrixWorld.decompose(t._parentPosition,t._parentQuaternion,t._parentScale),t.object.matrixWorld.decompose(t.worldPosition,t.worldQuaternion,t._worldScale),t._parentQuaternionInv.copy(t._parentQuaternion).invert(),t._worldQuaternionInv.copy(t.worldQuaternion).invert()),t.camera.updateMatrixWorld(),t.camera.matrixWorld.decompose(t.cameraPosition,t.cameraQuaternion,t._cameraScale),t.camera.isOrthographicCamera?t.camera.getWorldDirection(t.eye).negate():t.eye.copy(t.cameraPosition).sub(t.worldPosition).normalize(),super.updateMatrixWorld(e)}dispose(){this.traverse(function(e){e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose()})}}class FE extends Pt{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const e=new jt({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),t=new zn({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),n=e.clone();n.opacity=.15;const i=t.clone();i.opacity=.5;const s=e.clone();s.color.setHex(16711680);const a=e.clone();a.color.setHex(65280);const o=e.clone();o.color.setHex(255);const l=e.clone();l.color.setHex(16711680),l.opacity=.5;const c=e.clone();c.color.setHex(65280),c.opacity=.5;const d=e.clone();d.color.setHex(255),d.opacity=.5;const h=e.clone();h.opacity=.25;const u=e.clone();u.color.setHex(16776960),u.opacity=.25,e.clone().color.setHex(16776960);const m=e.clone();m.color.setHex(7895160);const b=new Pn(0,.04,.1,12);b.translate(0,.05,0);const p=new Jt(.08,.08,.08);p.translate(0,.04,0);const g=new ht;g.setAttribute("position",new ke([0,0,0,1,0,0],3));const y=new Pn(.0075,.0075,.5,3);y.translate(0,.25,0);function x(q,G){const K=new gr(q,.0075,3,64,G*Math.PI*2);return K.rotateY(Math.PI/2),K.rotateX(Math.PI/2),K}function w(){const q=new ht;return q.setAttribute("position",new ke([0,0,0,1,1,1],3)),q}const P={X:[[new Ee(b,s),[.5,0,0],[0,0,-Math.PI/2]],[new Ee(b,s),[-.5,0,0],[0,0,Math.PI/2]],[new Ee(y,s),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new Ee(b,a),[0,.5,0]],[new Ee(b,a),[0,-.5,0],[Math.PI,0,0]],[new Ee(y,a)]],Z:[[new Ee(b,o),[0,0,.5],[Math.PI/2,0,0]],[new Ee(b,o),[0,0,-.5],[-Math.PI/2,0,0]],[new Ee(y,o),null,[Math.PI/2,0,0]]],XYZ:[[new Ee(new aa(.1,0),h.clone()),[0,0,0]]],XY:[[new Ee(new Jt(.15,.15,.01),d.clone()),[.15,.15,0]]],YZ:[[new Ee(new Jt(.15,.15,.01),l.clone()),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new Ee(new Jt(.15,.15,.01),c.clone()),[.15,0,.15],[-Math.PI/2,0,0]]]},T={X:[[new Ee(new Pn(.2,0,.6,4),n),[.3,0,0],[0,0,-Math.PI/2]],[new Ee(new Pn(.2,0,.6,4),n),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new Ee(new Pn(.2,0,.6,4),n),[0,.3,0]],[new Ee(new Pn(.2,0,.6,4),n),[0,-.3,0],[0,0,Math.PI]]],Z:[[new Ee(new Pn(.2,0,.6,4),n),[0,0,.3],[Math.PI/2,0,0]],[new Ee(new Pn(.2,0,.6,4),n),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new Ee(new aa(.2,0),n)]],XY:[[new Ee(new Jt(.2,.2,.01),n),[.15,.15,0]]],YZ:[[new Ee(new Jt(.2,.2,.01),n),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new Ee(new Jt(.2,.2,.01),n),[.15,0,.15],[-Math.PI/2,0,0]]]},A={START:[[new Ee(new aa(.01,2),i),null,null,null,"helper"]],END:[[new Ee(new aa(.01,2),i),null,null,null,"helper"]],DELTA:[[new qn(w(),i),null,null,null,"helper"]],X:[[new qn(g,i.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new qn(g,i.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new qn(g,i.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},M={XYZE:[[new Ee(x(.5,1),m),null,[0,Math.PI/2,0]]],X:[[new Ee(x(.5,.5),s)]],Y:[[new Ee(x(.5,.5),a),null,[0,0,-Math.PI/2]]],Z:[[new Ee(x(.5,.5),o),null,[0,Math.PI/2,0]]],E:[[new Ee(x(.75,1),u),null,[0,Math.PI/2,0]]]},_={AXIS:[[new qn(g,i.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},S={XYZE:[[new Ee(new Pa(.25,10,8),n)]],X:[[new Ee(new gr(.5,.1,4,24),n),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new Ee(new gr(.5,.1,4,24),n),[0,0,0],[Math.PI/2,0,0]]],Z:[[new Ee(new gr(.5,.1,4,24),n),[0,0,0],[0,0,-Math.PI/2]]],E:[[new Ee(new gr(.75,.1,2,24),n)]]},R={X:[[new Ee(p,s),[.5,0,0],[0,0,-Math.PI/2]],[new Ee(y,s),[0,0,0],[0,0,-Math.PI/2]],[new Ee(p,s),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new Ee(p,a),[0,.5,0]],[new Ee(y,a)],[new Ee(p,a),[0,-.5,0],[0,0,Math.PI]]],Z:[[new Ee(p,o),[0,0,.5],[Math.PI/2,0,0]],[new Ee(y,o),[0,0,0],[Math.PI/2,0,0]],[new Ee(p,o),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new Ee(new Jt(.15,.15,.01),d),[.15,.15,0]]],YZ:[[new Ee(new Jt(.15,.15,.01),l),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new Ee(new Jt(.15,.15,.01),c),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new Ee(new Jt(.1,.1,.1),h.clone())]]},k={X:[[new Ee(new Pn(.2,0,.6,4),n),[.3,0,0],[0,0,-Math.PI/2]],[new Ee(new Pn(.2,0,.6,4),n),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new Ee(new Pn(.2,0,.6,4),n),[0,.3,0]],[new Ee(new Pn(.2,0,.6,4),n),[0,-.3,0],[0,0,Math.PI]]],Z:[[new Ee(new Pn(.2,0,.6,4),n),[0,0,.3],[Math.PI/2,0,0]],[new Ee(new Pn(.2,0,.6,4),n),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new Ee(new Jt(.2,.2,.01),n),[.15,.15,0]]],YZ:[[new Ee(new Jt(.2,.2,.01),n),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new Ee(new Jt(.2,.2,.01),n),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new Ee(new Jt(.2,.2,.2),n),[0,0,0]]]},O={X:[[new qn(g,i.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new qn(g,i.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new qn(g,i.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function H(q){const G=new Pt;for(const K in q)for(let V=q[K].length;V--;){const Z=q[K][V][0].clone(),le=q[K][V][1],se=q[K][V][2],ge=q[K][V][3],de=q[K][V][4];Z.name=K,Z.tag=de,le&&Z.position.set(le[0],le[1],le[2]),se&&Z.rotation.set(se[0],se[1],se[2]),ge&&Z.scale.set(ge[0],ge[1],ge[2]),Z.updateMatrix();const X=Z.geometry.clone();X.applyMatrix4(Z.matrix),Z.geometry=X,Z.renderOrder=1/0,Z.position.set(0,0,0),Z.rotation.set(0,0,0),Z.scale.set(1,1,1),G.add(Z)}return G}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=H(P)),this.add(this.gizmo.rotate=H(M)),this.add(this.gizmo.scale=H(R)),this.add(this.picker.translate=H(T)),this.add(this.picker.rotate=H(S)),this.add(this.picker.scale=H(k)),this.add(this.helper.translate=H(A)),this.add(this.helper.rotate=H(_)),this.add(this.helper.scale=H(O)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(e){const n=(this.mode==="scale"?"local":this.space)==="local"?this.worldQuaternion:pc;this.gizmo.translate.visible=this.mode==="translate",this.gizmo.rotate.visible=this.mode==="rotate",this.gizmo.scale.visible=this.mode==="scale",this.helper.translate.visible=this.mode==="translate",this.helper.rotate.visible=this.mode==="rotate",this.helper.scale.visible=this.mode==="scale";let i=[];i=i.concat(this.picker[this.mode].children),i=i.concat(this.gizmo[this.mode].children),i=i.concat(this.helper[this.mode].children);for(let s=0;s<i.length;s++){const a=i[s];a.visible=!0,a.rotation.set(0,0,0),a.position.copy(this.worldPosition);let o;if(this.camera.isOrthographicCamera?o=(this.camera.top-this.camera.bottom)/this.camera.zoom:o=this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),a.scale.set(1,1,1).multiplyScalar(o*this.size/4),a.tag==="helper"){a.visible=!1,a.name==="AXIS"?(a.visible=!!this.axis,this.axis==="X"&&(sn.setFromEuler(Fl.set(0,0,0)),a.quaternion.copy(n).multiply(sn),Math.abs(Zt.copy(oo).applyQuaternion(n).dot(this.eye))>.9&&(a.visible=!1)),this.axis==="Y"&&(sn.setFromEuler(Fl.set(0,0,Math.PI/2)),a.quaternion.copy(n).multiply(sn),Math.abs(Zt.copy(fr).applyQuaternion(n).dot(this.eye))>.9&&(a.visible=!1)),this.axis==="Z"&&(sn.setFromEuler(Fl.set(0,Math.PI/2,0)),a.quaternion.copy(n).multiply(sn),Math.abs(Zt.copy(lo).applyQuaternion(n).dot(this.eye))>.9&&(a.visible=!1)),this.axis==="XYZE"&&(sn.setFromEuler(Fl.set(0,Math.PI/2,0)),Zt.copy(this.rotationAxis),a.quaternion.setFromRotationMatrix(gm.lookAt(mm,Zt,fr)),a.quaternion.multiply(sn),a.visible=this.dragging),this.axis==="E"&&(a.visible=!1)):a.name==="START"?(a.position.copy(this.worldPositionStart),a.visible=this.dragging):a.name==="END"?(a.position.copy(this.worldPosition),a.visible=this.dragging):a.name==="DELTA"?(a.position.copy(this.worldPositionStart),a.quaternion.copy(this.worldQuaternionStart),Xn.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),Xn.applyQuaternion(this.worldQuaternionStart.clone().invert()),a.scale.copy(Xn),a.visible=this.dragging):(a.quaternion.copy(n),this.dragging?a.position.copy(this.worldPositionStart):a.position.copy(this.worldPosition),this.axis&&(a.visible=this.axis.search(a.name)!==-1));continue}a.quaternion.copy(n),this.mode==="translate"||this.mode==="scale"?(a.name==="X"&&Math.abs(Zt.copy(oo).applyQuaternion(n).dot(this.eye))>.99&&(a.scale.set(1e-10,1e-10,1e-10),a.visible=!1),a.name==="Y"&&Math.abs(Zt.copy(fr).applyQuaternion(n).dot(this.eye))>.99&&(a.scale.set(1e-10,1e-10,1e-10),a.visible=!1),a.name==="Z"&&Math.abs(Zt.copy(lo).applyQuaternion(n).dot(this.eye))>.99&&(a.scale.set(1e-10,1e-10,1e-10),a.visible=!1),a.name==="XY"&&Math.abs(Zt.copy(lo).applyQuaternion(n).dot(this.eye))<.2&&(a.scale.set(1e-10,1e-10,1e-10),a.visible=!1),a.name==="YZ"&&Math.abs(Zt.copy(oo).applyQuaternion(n).dot(this.eye))<.2&&(a.scale.set(1e-10,1e-10,1e-10),a.visible=!1),a.name==="XZ"&&Math.abs(Zt.copy(fr).applyQuaternion(n).dot(this.eye))<.2&&(a.scale.set(1e-10,1e-10,1e-10),a.visible=!1)):this.mode==="rotate"&&(Ul.copy(n),Zt.copy(this.eye).applyQuaternion(sn.copy(n).invert()),a.name.search("E")!==-1&&a.quaternion.setFromRotationMatrix(gm.lookAt(this.eye,mm,fr)),a.name==="X"&&(sn.setFromAxisAngle(oo,Math.atan2(-Zt.y,Zt.z)),sn.multiplyQuaternions(Ul,sn),a.quaternion.copy(sn)),a.name==="Y"&&(sn.setFromAxisAngle(fr,Math.atan2(Zt.x,Zt.z)),sn.multiplyQuaternions(Ul,sn),a.quaternion.copy(sn)),a.name==="Z"&&(sn.setFromAxisAngle(lo,Math.atan2(Zt.y,Zt.x)),sn.multiplyQuaternions(Ul,sn),a.quaternion.copy(sn))),a.visible=a.visible&&(a.name.indexOf("X")===-1||this.showX),a.visible=a.visible&&(a.name.indexOf("Y")===-1||this.showY),a.visible=a.visible&&(a.name.indexOf("Z")===-1||this.showZ),a.visible=a.visible&&(a.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),a.material._color=a.material._color||a.material.color.clone(),a.material._opacity=a.material._opacity||a.material.opacity,a.material.color.copy(a.material._color),a.material.opacity=a.material._opacity,this.enabled&&this.axis&&(a.name===this.axis||this.axis.split("").some(function(l){return a.name===l}))&&(a.material.color.setHex(16776960),a.material.opacity=1)}super.updateMatrixWorld(e)}}class UE extends Ee{constructor(){super(new $s(1e5,1e5,2,2),new jt({visible:!1,wireframe:!0,side:ln,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(e){let t=this.space;switch(this.position.copy(this.worldPosition),this.mode==="scale"&&(t="local"),Bl.copy(oo).applyQuaternion(t==="local"?this.worldQuaternion:pc),Ka.copy(fr).applyQuaternion(t==="local"?this.worldQuaternion:pc),$a.copy(lo).applyQuaternion(t==="local"?this.worldQuaternion:pc),Zt.copy(Ka),this.mode){case"translate":case"scale":switch(this.axis){case"X":Zt.copy(this.eye).cross(Bl),Qi.copy(Bl).cross(Zt);break;case"Y":Zt.copy(this.eye).cross(Ka),Qi.copy(Ka).cross(Zt);break;case"Z":Zt.copy(this.eye).cross($a),Qi.copy($a).cross(Zt);break;case"XY":Qi.copy($a);break;case"YZ":Qi.copy(Bl);break;case"XZ":Zt.copy($a),Qi.copy(Ka);break;case"XYZ":case"E":Qi.set(0,0,0);break}break;case"rotate":default:Qi.set(0,0,0)}Qi.length()===0?this.quaternion.copy(this.cameraQuaternion):(bm.lookAt(Xn.set(0,0,0),Qi,Zt),this.quaternion.setFromRotationMatrix(bm)),super.updateMatrixWorld(e)}}class Hs extends Pt{constructor(e=document.createElement("div")){super(),this.isCSS2DObject=!0,this.element=e,this.element.style.position="absolute",this.element.style.userSelect="none",this.element.setAttribute("draggable",!1),this.center=new me(.5,.5),this.addEventListener("removed",function(){this.traverse(function(t){t.element instanceof t.element.ownerDocument.defaultView.Element&&t.element.parentNode!==null&&t.element.remove()})})}copy(e,t){return super.copy(e,t),this.element=e.element.cloneNode(!0),this.center=e.center,this}}const $r=new I,vm=new Ie,ym=new Ie,xm=new I,_m=new I;class BE{constructor(e={}){const t=this;let n,i,s,a;const o={objects:new WeakMap},l=e.element!==void 0?e.element:document.createElement("div");l.style.overflow="hidden",this.domElement=l,this.getSize=function(){return{width:n,height:i}},this.render=function(m,b){m.matrixWorldAutoUpdate===!0&&m.updateMatrixWorld(),b.parent===null&&b.matrixWorldAutoUpdate===!0&&b.updateMatrixWorld(),vm.copy(b.matrixWorldInverse),ym.multiplyMatrices(b.projectionMatrix,vm),d(m,m,b),f(m)},this.setSize=function(m,b){n=m,i=b,s=n/2,a=i/2,l.style.width=m+"px",l.style.height=b+"px"};function c(m){m.isCSS2DObject&&(m.element.style.display="none");for(let b=0,p=m.children.length;b<p;b++)c(m.children[b])}function d(m,b,p){if(m.visible===!1){c(m);return}if(m.isCSS2DObject){$r.setFromMatrixPosition(m.matrixWorld),$r.applyMatrix4(ym);const g=$r.z>=-1&&$r.z<=1&&m.layers.test(p.layers)===!0,y=m.element;y.style.display=g===!0?"":"none",g===!0&&(m.onBeforeRender(t,b,p),y.style.transform="translate("+-100*m.center.x+"%,"+-100*m.center.y+"%)translate("+($r.x*s+s)+"px,"+(-$r.y*a+a)+"px)",y.parentNode!==l&&l.appendChild(y),m.onAfterRender(t,b,p));const x={distanceToCameraSquared:h(p,m)};o.objects.set(m,x)}for(let g=0,y=m.children.length;g<y;g++)d(m.children[g],b,p)}function h(m,b){return xm.setFromMatrixPosition(m.matrixWorld),_m.setFromMatrixPosition(b.matrixWorld),xm.distanceToSquared(_m)}function u(m){const b=[];return m.traverseVisible(function(p){p.isCSS2DObject&&b.push(p)}),b}function f(m){const b=u(m).sort(function(g,y){if(g.renderOrder!==y.renderOrder)return y.renderOrder-g.renderOrder;const x=o.objects.get(g).distanceToCameraSquared,w=o.objects.get(y).distanceToCameraSquared;return x-w}),p=b.length;for(let g=0,y=b.length;g<y;g++)b[g].element.style.zIndex=p-g}}}class Qb extends pi{constructor(e){super(e)}load(e,t,n,i){const s=this,a=new Ys(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(o){try{t(s.parse(o))}catch(l){i?i(l):console.error(l),s.manager.itemError(e)}},n,i)}parse(e){function t(c){const d=new DataView(c),h=32/8*3+32/8*3*3+16/8,u=d.getUint32(80,!0);if(80+32/8+u*h===d.byteLength)return!0;const m=[115,111,108,105,100];for(let b=0;b<5;b++)if(n(m,d,b))return!1;return!0}function n(c,d,h){for(let u=0,f=c.length;u<f;u++)if(c[u]!==d.getUint8(h+u))return!1;return!0}function i(c){const d=new DataView(c),h=d.getUint32(80,!0);let u,f,m,b=!1,p,g,y,x,w;for(let R=0;R<70;R++)d.getUint32(R,!1)==1129270351&&d.getUint8(R+4)==82&&d.getUint8(R+5)==61&&(b=!0,p=new Float32Array(h*3*3),g=d.getUint8(R+6)/255,y=d.getUint8(R+7)/255,x=d.getUint8(R+8)/255,w=d.getUint8(R+9)/255);const P=84,T=50,A=new ht,M=new Float32Array(h*3*3),_=new Float32Array(h*3*3),S=new Ne;for(let R=0;R<h;R++){const k=P+R*T,O=d.getFloat32(k,!0),H=d.getFloat32(k+4,!0),q=d.getFloat32(k+8,!0);if(b){const G=d.getUint16(k+48,!0);(G&32768)===0?(u=(G&31)/31,f=(G>>5&31)/31,m=(G>>10&31)/31):(u=g,f=y,m=x)}for(let G=1;G<=3;G++){const K=k+G*12,V=R*3*3+(G-1)*3;M[V]=d.getFloat32(K,!0),M[V+1]=d.getFloat32(K+4,!0),M[V+2]=d.getFloat32(K+8,!0),_[V]=O,_[V+1]=H,_[V+2]=q,b&&(S.setRGB(u,f,m,gt),p[V]=S.r,p[V+1]=S.g,p[V+2]=S.b)}}return A.setAttribute("position",new rn(M,3)),A.setAttribute("normal",new rn(_,3)),b&&(A.setAttribute("color",new rn(p,3)),A.hasColors=!0,A.alpha=w),A}function s(c){const d=new ht,h=/solid([\s\S]*?)endsolid/g,u=/facet([\s\S]*?)endfacet/g,f=/solid\s(.+)/;let m=0;const b=/[\s]+([+-]?(?:\d*)(?:\.\d*)?(?:[eE][+-]?\d+)?)/.source,p=new RegExp("vertex"+b+b+b,"g"),g=new RegExp("normal"+b+b+b,"g"),y=[],x=[],w=[],P=new I;let T,A=0,M=0,_=0;for(;(T=h.exec(c))!==null;){M=_;const S=T[0],R=(T=f.exec(S))!==null?T[1]:"";for(w.push(R);(T=u.exec(S))!==null;){let H=0,q=0;const G=T[0];for(;(T=g.exec(G))!==null;)P.x=parseFloat(T[1]),P.y=parseFloat(T[2]),P.z=parseFloat(T[3]),q++;for(;(T=p.exec(G))!==null;)y.push(parseFloat(T[1]),parseFloat(T[2]),parseFloat(T[3])),x.push(P.x,P.y,P.z),H++,_++;q!==1&&console.error("THREE.STLLoader: Something isn't right with the normal of face number "+m),H!==3&&console.error("THREE.STLLoader: Something isn't right with the vertices of face number "+m),m++}const k=M,O=_-M;d.userData.groupNames=w,d.addGroup(k,O,A),A++}return d.setAttribute("position",new ke(y,3)),d.setAttribute("normal",new ke(x,3)),d}function a(c){return typeof c!="string"?new TextDecoder().decode(c):c}function o(c){if(typeof c=="string"){const d=new Uint8Array(c.length);for(let h=0;h<c.length;h++)d[h]=c.charCodeAt(h)&255;return d.buffer||d}else return c}const l=o(e);return t(l)?i(l):s(a(e))}}class wm extends T_{constructor(e){super(e)}parse(e){function t(G){switch(G.image_type){case u:case b:if(G.colormap_length>256||G.colormap_size!==24||G.colormap_type!==1)throw new Error("THREE.TGALoader: Invalid type colormap data for indexed type.");break;case f:case m:case p:case g:if(G.colormap_type)throw new Error("THREE.TGALoader: Invalid type colormap data for colormap type.");break;case h:throw new Error("THREE.TGALoader: No data.");default:throw new Error("THREE.TGALoader: Invalid type "+G.image_type)}if(G.width<=0||G.height<=0)throw new Error("THREE.TGALoader: Invalid image size.");if(G.pixel_size!==8&&G.pixel_size!==16&&G.pixel_size!==24&&G.pixel_size!==32)throw new Error("THREE.TGALoader: Invalid pixel size "+G.pixel_size)}function n(G,K,V,Z,le){let se,ge;const de=V.pixel_size>>3,X=V.width*V.height*de;if(K&&(ge=le.subarray(Z,Z+=V.colormap_length*(V.colormap_size>>3))),G){se=new Uint8Array(X);let ee,ie,Y,ue=0;const oe=new Uint8Array(de);for(;ue<X;)if(ee=le[Z++],ie=(ee&127)+1,ee&128){for(Y=0;Y<de;++Y)oe[Y]=le[Z++];for(Y=0;Y<ie;++Y)se.set(oe,ue+Y*de);ue+=de*ie}else{for(ie*=de,Y=0;Y<ie;++Y)se[ue+Y]=le[Z++];ue+=ie}}else se=le.subarray(Z,Z+=K?V.width*V.height:X);return{pixel_data:se,palettes:ge}}function i(G,K,V,Z,le,se,ge,de,X){const ee=X;let ie,Y=0,ue,oe;const be=S.width;for(oe=K;oe!==Z;oe+=V)for(ue=le;ue!==ge;ue+=se,Y++)ie=de[Y],G[(ue+be*oe)*4+3]=255,G[(ue+be*oe)*4+2]=ee[ie*3+0],G[(ue+be*oe)*4+1]=ee[ie*3+1],G[(ue+be*oe)*4+0]=ee[ie*3+2];return G}function s(G,K,V,Z,le,se,ge,de){let X,ee=0,ie,Y;const ue=S.width;for(Y=K;Y!==Z;Y+=V)for(ie=le;ie!==ge;ie+=se,ee+=2)X=de[ee+0]+(de[ee+1]<<8),G[(ie+ue*Y)*4+0]=(X&31744)>>7,G[(ie+ue*Y)*4+1]=(X&992)>>2,G[(ie+ue*Y)*4+2]=(X&31)<<3,G[(ie+ue*Y)*4+3]=X&32768?0:255;return G}function a(G,K,V,Z,le,se,ge,de){let X=0,ee,ie;const Y=S.width;for(ie=K;ie!==Z;ie+=V)for(ee=le;ee!==ge;ee+=se,X+=3)G[(ee+Y*ie)*4+3]=255,G[(ee+Y*ie)*4+2]=de[X+0],G[(ee+Y*ie)*4+1]=de[X+1],G[(ee+Y*ie)*4+0]=de[X+2];return G}function o(G,K,V,Z,le,se,ge,de){let X=0,ee,ie;const Y=S.width;for(ie=K;ie!==Z;ie+=V)for(ee=le;ee!==ge;ee+=se,X+=4)G[(ee+Y*ie)*4+2]=de[X+0],G[(ee+Y*ie)*4+1]=de[X+1],G[(ee+Y*ie)*4+0]=de[X+2],G[(ee+Y*ie)*4+3]=de[X+3];return G}function l(G,K,V,Z,le,se,ge,de){let X,ee=0,ie,Y;const ue=S.width;for(Y=K;Y!==Z;Y+=V)for(ie=le;ie!==ge;ie+=se,ee++)X=de[ee],G[(ie+ue*Y)*4+0]=X,G[(ie+ue*Y)*4+1]=X,G[(ie+ue*Y)*4+2]=X,G[(ie+ue*Y)*4+3]=255;return G}function c(G,K,V,Z,le,se,ge,de){let X=0,ee,ie;const Y=S.width;for(ie=K;ie!==Z;ie+=V)for(ee=le;ee!==ge;ee+=se,X+=2)G[(ee+Y*ie)*4+0]=de[X+0],G[(ee+Y*ie)*4+1]=de[X+0],G[(ee+Y*ie)*4+2]=de[X+0],G[(ee+Y*ie)*4+3]=de[X+1];return G}function d(G,K,V,Z,le){let se,ge,de,X,ee,ie;switch((S.flags&y)>>x){default:case T:se=0,de=1,ee=K,ge=0,X=1,ie=V;break;case w:se=0,de=1,ee=K,ge=V-1,X=-1,ie=-1;break;case A:se=K-1,de=-1,ee=-1,ge=0,X=1,ie=V;break;case P:se=K-1,de=-1,ee=-1,ge=V-1,X=-1,ie=-1;break}if(O)switch(S.pixel_size){case 8:l(G,ge,X,ie,se,de,ee,Z);break;case 16:c(G,ge,X,ie,se,de,ee,Z);break;default:throw new Error("THREE.TGALoader: Format not supported.")}else switch(S.pixel_size){case 8:i(G,ge,X,ie,se,de,ee,Z,le);break;case 16:s(G,ge,X,ie,se,de,ee,Z);break;case 24:a(G,ge,X,ie,se,de,ee,Z);break;case 32:o(G,ge,X,ie,se,de,ee,Z);break;default:throw new Error("THREE.TGALoader: Format not supported.")}return G}const h=0,u=1,f=2,m=3,b=9,p=10,g=11,y=48,x=4,w=0,P=1,T=2,A=3;if(e.length<19)throw new Error("THREE.TGALoader: Not enough data to contain header.");let M=0;const _=new Uint8Array(e),S={id_length:_[M++],colormap_type:_[M++],image_type:_[M++],colormap_index:_[M++]|_[M++]<<8,colormap_length:_[M++]|_[M++]<<8,colormap_size:_[M++],origin:[_[M++]|_[M++]<<8,_[M++]|_[M++]<<8],width:_[M++]|_[M++]<<8,height:_[M++]|_[M++]<<8,pixel_size:_[M++],flags:_[M++]};if(t(S),S.id_length+M>e.length)throw new Error("THREE.TGALoader: No data.");M+=S.id_length;let R=!1,k=!1,O=!1;switch(S.image_type){case b:R=!0,k=!0;break;case u:k=!0;break;case p:R=!0;break;case f:break;case g:R=!0,O=!0;break;case m:O=!0;break}const H=new Uint8Array(S.width*S.height*4),q=n(R,k,S,M,_);return d(H,S.width,S.height,q.pixel_data,q.palettes),{data:H,width:S.width,height:S.height,flipY:!0,generateMipmaps:!0,minFilter:ji}}}class Jb extends pi{load(e,t,n,i){const s=this,a=s.path===""?qs.extractUrlBase(e):s.path,o=new Ys(s.manager);o.setPath(s.path),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(e,function(l){try{t(s.parse(l,a))}catch(c){i?i(c):console.error(c),s.manager.itemError(e)}},n,i)}parse(e,t){function n(L,D){const B=[],F=L.childNodes;for(let z=0,pe=F.length;z<pe;z++){const _e=F[z];_e.nodeName===D&&B.push(_e)}return B}function i(L){if(L.length===0)return[];const D=L.trim().split(/\s+/),B=new Array(D.length);for(let F=0,z=D.length;F<z;F++)B[F]=D[F];return B}function s(L){if(L.length===0)return[];const D=L.trim().split(/\s+/),B=new Array(D.length);for(let F=0,z=D.length;F<z;F++)B[F]=parseFloat(D[F]);return B}function a(L){if(L.length===0)return[];const D=L.trim().split(/\s+/),B=new Array(D.length);for(let F=0,z=D.length;F<z;F++)B[F]=parseInt(D[F]);return B}function o(L){return L.substring(1)}function l(){return"three_default_"+ls++}function c(L){return Object.keys(L).length===0}function d(L){return{unit:h(n(L,"unit")[0]),upAxis:u(n(L,"up_axis")[0])}}function h(L){return L!==void 0&&L.hasAttribute("meter")===!0?parseFloat(L.getAttribute("meter")):1}function u(L){return L!==void 0?L.textContent:"Y_UP"}function f(L,D,B,F){const z=n(L,D)[0];if(z!==void 0){const pe=n(z,B);for(let _e=0;_e<pe.length;_e++)F(pe[_e])}}function m(L,D){for(const B in L){const F=L[B];F.build=D(L[B])}}function b(L,D){return L.build!==void 0||(L.build=D(L)),L.build}function p(L){const D={sources:{},samplers:{},channels:{}};let B=!1;for(let F=0,z=L.childNodes.length;F<z;F++){const pe=L.childNodes[F];if(pe.nodeType!==1)continue;let _e;switch(pe.nodeName){case"source":_e=pe.getAttribute("id"),D.sources[_e]=ye(pe);break;case"sampler":_e=pe.getAttribute("id"),D.samplers[_e]=g(pe);break;case"channel":_e=pe.getAttribute("target"),D.channels[_e]=y(pe);break;case"animation":p(pe),B=!0;break;default:console.log(pe)}}B===!1&&(ut.animations[L.getAttribute("id")||bt.generateUUID()]=D)}function g(L){const D={inputs:{}};for(let B=0,F=L.childNodes.length;B<F;B++){const z=L.childNodes[B];if(z.nodeType===1)switch(z.nodeName){case"input":const pe=o(z.getAttribute("source")),_e=z.getAttribute("semantic");D.inputs[_e]=pe;break}}return D}function y(L){const D={};let F=L.getAttribute("target").split("/");const z=F.shift();let pe=F.shift();const _e=pe.indexOf("(")!==-1,Qe=pe.indexOf(".")!==-1;if(Qe)F=pe.split("."),pe=F.shift(),D.member=F.shift();else if(_e){const ze=pe.split("(");pe=ze.shift();for(let qe=0;qe<ze.length;qe++)ze[qe]=parseInt(ze[qe].replace(/\)/,""));D.indices=ze}return D.id=z,D.sid=pe,D.arraySyntax=_e,D.memberSyntax=Qe,D.sampler=o(L.getAttribute("source")),D}function x(L){const D=[],B=L.channels,F=L.samplers,z=L.sources;for(const pe in B)if(B.hasOwnProperty(pe)){const _e=B[pe],Qe=F[_e.sampler],ze=Qe.inputs.INPUT,qe=Qe.inputs.OUTPUT,st=z[ze],Ae=z[qe],it=P(_e,st,Ae);S(it,D)}return D}function w(L){return b(ut.animations[L],x)}function P(L,D,B){const F=ut.nodes[L.id],z=St(F.id),pe=F.transforms[L.sid],_e=F.matrix.clone().transpose();let Qe,ze,qe,st,Ae,it;const tt={};switch(pe){case"matrix":for(qe=0,st=D.array.length;qe<st;qe++)if(Qe=D.array[qe],ze=qe*B.stride,tt[Qe]===void 0&&(tt[Qe]={}),L.arraySyntax===!0){const on=B.array[ze],Bt=L.indices[0]+4*L.indices[1];tt[Qe][Bt]=on}else for(Ae=0,it=B.stride;Ae<it;Ae++)tt[Qe][Ae]=B.array[ze+Ae];break;case"translate":console.warn('THREE.ColladaLoader: Animation transform type "%s" not yet implemented.',pe);break;case"rotate":console.warn('THREE.ColladaLoader: Animation transform type "%s" not yet implemented.',pe);break;case"scale":console.warn('THREE.ColladaLoader: Animation transform type "%s" not yet implemented.',pe);break}const dt=T(tt,_e);return{name:z.uuid,keyframes:dt}}function T(L,D){const B=[];for(const z in L)B.push({time:parseFloat(z),value:L[z]});B.sort(F);for(let z=0;z<16;z++)R(B,z,D.elements[z]);return B;function F(z,pe){return z.time-pe.time}}const A=new I,M=new I,_=new Lt;function S(L,D){const B=L.keyframes,F=L.name,z=[],pe=[],_e=[],Qe=[];for(let ze=0,qe=B.length;ze<qe;ze++){const st=B[ze],Ae=st.time,it=st.value;J.fromArray(it).transpose(),J.decompose(A,_,M),z.push(Ae),pe.push(A.x,A.y,A.z),_e.push(_.x,_.y,_.z,_.w),Qe.push(M.x,M.y,M.z)}return pe.length>0&&D.push(new Es(F+".position",z,pe)),_e.length>0&&D.push(new Ts(F+".quaternion",z,_e)),Qe.length>0&&D.push(new Es(F+".scale",z,Qe)),D}function R(L,D,B){let F,z=!0,pe,_e;for(pe=0,_e=L.length;pe<_e;pe++)F=L[pe],F.value[D]===void 0?F.value[D]=null:z=!1;if(z===!0)for(pe=0,_e=L.length;pe<_e;pe++)F=L[pe],F.value[D]=B;else k(L,D)}function k(L,D){let B,F;for(let z=0,pe=L.length;z<pe;z++){const _e=L[z];if(_e.value[D]===null){if(B=O(L,z,D),F=H(L,z,D),B===null){_e.value[D]=F.value[D];continue}if(F===null){_e.value[D]=B.value[D];continue}q(_e,B,F,D)}}}function O(L,D,B){for(;D>=0;){const F=L[D];if(F.value[B]!==null)return F;D--}return null}function H(L,D,B){for(;D<L.length;){const F=L[D];if(F.value[B]!==null)return F;D++}return null}function q(L,D,B,F){if(B.time-D.time===0){L.value[F]=D.value[F];return}L.value[F]=(L.time-D.time)*(B.value[F]-D.value[F])/(B.time-D.time)+D.value[F]}function G(L){const D={name:L.getAttribute("id")||"default",start:parseFloat(L.getAttribute("start")||0),end:parseFloat(L.getAttribute("end")||0),animations:[]};for(let B=0,F=L.childNodes.length;B<F;B++){const z=L.childNodes[B];if(z.nodeType===1)switch(z.nodeName){case"instance_animation":D.animations.push(o(z.getAttribute("url")));break}}ut.clips[L.getAttribute("id")]=D}function K(L){const D=[],B=L.name,F=L.end-L.start||-1,z=L.animations;for(let pe=0,_e=z.length;pe<_e;pe++){const Qe=w(z[pe]);for(let ze=0,qe=Qe.length;ze<qe;ze++)D.push(Qe[ze])}return new Mc(B,F,D)}function V(L){return b(ut.clips[L],K)}function Z(L){const D={};for(let B=0,F=L.childNodes.length;B<F;B++){const z=L.childNodes[B];if(z.nodeType===1)switch(z.nodeName){case"skin":D.id=o(z.getAttribute("source")),D.skin=le(z);break;case"morph":D.id=o(z.getAttribute("source")),console.warn("THREE.ColladaLoader: Morph target animation not supported yet.");break}}ut.controllers[L.getAttribute("id")]=D}function le(L){const D={sources:{}};for(let B=0,F=L.childNodes.length;B<F;B++){const z=L.childNodes[B];if(z.nodeType===1)switch(z.nodeName){case"bind_shape_matrix":D.bindShapeMatrix=s(z.textContent);break;case"source":const pe=z.getAttribute("id");D.sources[pe]=ye(z);break;case"joints":D.joints=se(z);break;case"vertex_weights":D.vertexWeights=ge(z);break}}return D}function se(L){const D={inputs:{}};for(let B=0,F=L.childNodes.length;B<F;B++){const z=L.childNodes[B];if(z.nodeType===1)switch(z.nodeName){case"input":const pe=z.getAttribute("semantic"),_e=o(z.getAttribute("source"));D.inputs[pe]=_e;break}}return D}function ge(L){const D={inputs:{}};for(let B=0,F=L.childNodes.length;B<F;B++){const z=L.childNodes[B];if(z.nodeType===1)switch(z.nodeName){case"input":const pe=z.getAttribute("semantic"),_e=o(z.getAttribute("source")),Qe=parseInt(z.getAttribute("offset"));D.inputs[pe]={id:_e,offset:Qe};break;case"vcount":D.vcount=a(z.textContent);break;case"v":D.v=a(z.textContent);break}}return D}function de(L){const D={id:L.id},B=ut.geometries[D.id];return L.skin!==void 0&&(D.skin=X(L.skin),B.sources.skinIndices=D.skin.indices,B.sources.skinWeights=D.skin.weights),D}function X(L){const B={joints:[],indices:{array:[],stride:4},weights:{array:[],stride:4}},F=L.sources,z=L.vertexWeights,pe=z.vcount,_e=z.v,Qe=z.inputs.JOINT.offset,ze=z.inputs.WEIGHT.offset,qe=L.sources[L.joints.inputs.JOINT],st=L.sources[L.joints.inputs.INV_BIND_MATRIX],Ae=F[z.inputs.WEIGHT.id].array;let it=0,tt,dt,ot;for(tt=0,ot=pe.length;tt<ot;tt++){const Bt=pe[tt],Ot=[];for(dt=0;dt<Bt;dt++){const Ft=_e[it+Qe],cs=_e[it+ze],ai=Ae[cs];Ot.push({index:Ft,weight:ai}),it+=2}for(Ot.sort(on),dt=0;dt<4;dt++){const Ft=Ot[dt];Ft!==void 0?(B.indices.array.push(Ft.index),B.weights.array.push(Ft.weight)):(B.indices.array.push(0),B.weights.array.push(0))}}for(L.bindShapeMatrix?B.bindMatrix=new Ie().fromArray(L.bindShapeMatrix).transpose():B.bindMatrix=new Ie().identity(),tt=0,ot=qe.array.length;tt<ot;tt++){const Bt=qe.array[tt],Ot=new Ie().fromArray(st.array,tt*st.stride).transpose();B.joints.push({name:Bt,boneInverse:Ot})}return B;function on(Bt,Ot){return Ot.weight-Bt.weight}}function ee(L){return b(ut.controllers[L],de)}function ie(L){const D={init_from:n(L,"init_from")[0].textContent};ut.images[L.getAttribute("id")]=D}function Y(L){return L.build!==void 0?L.build:L.init_from}function ue(L){const D=ut.images[L];return D!==void 0?b(D,Y):(console.warn("THREE.ColladaLoader: Couldn't find image with ID:",L),null)}function oe(L){const D={};for(let B=0,F=L.childNodes.length;B<F;B++){const z=L.childNodes[B];if(z.nodeType===1)switch(z.nodeName){case"profile_COMMON":D.profile=be(z);break}}ut.effects[L.getAttribute("id")]=D}function be(L){const D={surfaces:{},samplers:{}};for(let B=0,F=L.childNodes.length;B<F;B++){const z=L.childNodes[B];if(z.nodeType===1)switch(z.nodeName){case"newparam":Ce(z,D);break;case"technique":D.technique=j(z);break;case"extra":D.extra=Be(z);break}}return D}function Ce(L,D){const B=L.getAttribute("sid");for(let F=0,z=L.childNodes.length;F<z;F++){const pe=L.childNodes[F];if(pe.nodeType===1)switch(pe.nodeName){case"surface":D.surfaces[B]=je(pe);break;case"sampler2D":D.samplers[B]=Fe(pe);break}}}function je(L){const D={};for(let B=0,F=L.childNodes.length;B<F;B++){const z=L.childNodes[B];if(z.nodeType===1)switch(z.nodeName){case"init_from":D.init_from=z.textContent;break}}return D}function Fe(L){const D={};for(let B=0,F=L.childNodes.length;B<F;B++){const z=L.childNodes[B];if(z.nodeType===1)switch(z.nodeName){case"source":D.source=z.textContent;break}}return D}function j(L){const D={};for(let B=0,F=L.childNodes.length;B<F;B++){const z=L.childNodes[B];if(z.nodeType===1)switch(z.nodeName){case"constant":case"lambert":case"blinn":case"phong":D.type=z.nodeName,D.parameters=Ke(z);break;case"extra":D.extra=Be(z);break}}return D}function Ke(L){const D={};for(let B=0,F=L.childNodes.length;B<F;B++){const z=L.childNodes[B];if(z.nodeType===1)switch(z.nodeName){case"emission":case"diffuse":case"specular":case"bump":case"ambient":case"shininess":case"transparency":D[z.nodeName]=Ue(z);break;case"transparent":D[z.nodeName]={opaque:z.hasAttribute("opaque")?z.getAttribute("opaque"):"A_ONE",data:Ue(z)};break}}return D}function Ue(L){const D={};for(let B=0,F=L.childNodes.length;B<F;B++){const z=L.childNodes[B];if(z.nodeType===1)switch(z.nodeName){case"color":D[z.nodeName]=s(z.textContent);break;case"float":D[z.nodeName]=parseFloat(z.textContent);break;case"texture":D[z.nodeName]={id:z.getAttribute("texture"),extra:Te(z)};break}}return D}function Te(L){const D={technique:{}};for(let B=0,F=L.childNodes.length;B<F;B++){const z=L.childNodes[B];if(z.nodeType===1)switch(z.nodeName){case"extra":Se(z,D);break}}return D}function Se(L,D){for(let B=0,F=L.childNodes.length;B<F;B++){const z=L.childNodes[B];if(z.nodeType===1)switch(z.nodeName){case"technique":et(z,D);break}}}function et(L,D){for(let B=0,F=L.childNodes.length;B<F;B++){const z=L.childNodes[B];if(z.nodeType===1)switch(z.nodeName){case"repeatU":case"repeatV":case"offsetU":case"offsetV":D.technique[z.nodeName]=parseFloat(z.textContent);break;case"wrapU":case"wrapV":z.textContent.toUpperCase()==="TRUE"?D.technique[z.nodeName]=1:z.textContent.toUpperCase()==="FALSE"?D.technique[z.nodeName]=0:D.technique[z.nodeName]=parseInt(z.textContent);break;case"bump":D[z.nodeName]=E(z);break}}}function Be(L){const D={};for(let B=0,F=L.childNodes.length;B<F;B++){const z=L.childNodes[B];if(z.nodeType===1)switch(z.nodeName){case"technique":D.technique=N(z);break}}return D}function N(L){const D={};for(let B=0,F=L.childNodes.length;B<F;B++){const z=L.childNodes[B];if(z.nodeType===1)switch(z.nodeName){case"double_sided":D[z.nodeName]=parseInt(z.textContent);break;case"bump":D[z.nodeName]=E(z);break}}return D}function E(L){const D={};for(let B=0,F=L.childNodes.length;B<F;B++){const z=L.childNodes[B];if(z.nodeType===1)switch(z.nodeName){case"texture":D[z.nodeName]={id:z.getAttribute("texture"),texcoord:z.getAttribute("texcoord"),extra:Te(z)};break}}return D}function W(L){return L}function ae(L){return b(ut.effects[L],W)}function ve(L){const D={name:L.getAttribute("name")};for(let B=0,F=L.childNodes.length;B<F;B++){const z=L.childNodes[B];if(z.nodeType===1)switch(z.nodeName){case"instance_effect":D.url=o(z.getAttribute("url"));break}}ut.materials[L.getAttribute("id")]=D}function ce(L){let D,B=L.slice((L.lastIndexOf(".")-1>>>0)+2);switch(B=B.toLowerCase(),B){case"tga":D=Gn;break;default:D=Qn}return D}function Oe(L){const D=ae(L.url),B=D.profile.technique;let F;switch(B.type){case"phong":case"blinn":F=new Ii;break;case"lambert":F=new Fn;break;default:F=new jt;break}F.name=L.name||"";function z(ze,qe=null){const st=D.profile.samplers[ze.id];let Ae=null;if(st!==void 0){const it=D.profile.surfaces[st.source];Ae=ue(it.init_from)}else console.warn("THREE.ColladaLoader: Undefined sampler. Access image directly (see #12530)."),Ae=ue(ze.id);if(Ae!==null){const it=ce(Ae);if(it!==void 0){const tt=it.load(Ae),dt=ze.extra;if(dt!==void 0&&dt.technique!==void 0&&c(dt.technique)===!1){const ot=dt.technique;tt.wrapS=ot.wrapU?Li:ui,tt.wrapT=ot.wrapV?Li:ui,tt.offset.set(ot.offsetU||0,ot.offsetV||0),tt.repeat.set(ot.repeatU||1,ot.repeatV||1)}else tt.wrapS=Li,tt.wrapT=Li;return qe!==null&&(tt.colorSpace=qe),tt}else return console.warn("THREE.ColladaLoader: Loader for texture %s not found.",Ae),null}else return console.warn("THREE.ColladaLoader: Couldn't create texture with ID:",ze.id),null}const pe=B.parameters;for(const ze in pe){const qe=pe[ze];switch(ze){case"diffuse":qe.color&&F.color.fromArray(qe.color),qe.texture&&(F.map=z(qe.texture,gt));break;case"specular":qe.color&&F.specular&&F.specular.fromArray(qe.color),qe.texture&&(F.specularMap=z(qe.texture));break;case"bump":qe.texture&&(F.normalMap=z(qe.texture));break;case"ambient":qe.texture&&(F.lightMap=z(qe.texture,gt));break;case"shininess":qe.float&&F.shininess&&(F.shininess=qe.float);break;case"emission":qe.color&&F.emissive&&F.emissive.fromArray(qe.color),qe.texture&&(F.emissiveMap=z(qe.texture,gt));break}}ft.toWorkingColorSpace(F.color,gt),F.specular&&ft.toWorkingColorSpace(F.specular,gt),F.emissive&&ft.toWorkingColorSpace(F.emissive,gt);let _e=pe.transparent,Qe=pe.transparency;if(Qe===void 0&&_e&&(Qe={float:1}),_e===void 0&&Qe&&(_e={opaque:"A_ONE",data:{color:[1,1,1,1]}}),_e&&Qe)if(_e.data.texture)F.transparent=!0;else{const ze=_e.data.color;switch(_e.opaque){case"A_ONE":F.opacity=ze[3]*Qe.float;break;case"RGB_ZERO":F.opacity=1-ze[0]*Qe.float;break;case"A_ZERO":F.opacity=1-ze[3]*Qe.float;break;case"RGB_ONE":F.opacity=ze[0]*Qe.float;break;default:console.warn('THREE.ColladaLoader: Invalid opaque type "%s" of transparent tag.',_e.opaque)}F.opacity<1&&(F.transparent=!0)}if(B.extra!==void 0&&B.extra.technique!==void 0){const ze=B.extra.technique;for(const qe in ze){const st=ze[qe];switch(qe){case"double_sided":F.side=st===1?ln:Si;break;case"bump":F.normalMap=z(st.texture),F.normalScale=new me(1,1);break}}}return F}function Pe(L){return b(ut.materials[L],Oe)}function Ve(L){const D={name:L.getAttribute("name")};for(let B=0,F=L.childNodes.length;B<F;B++){const z=L.childNodes[B];if(z.nodeType===1)switch(z.nodeName){case"optics":D.optics=te(z);break}}ut.cameras[L.getAttribute("id")]=D}function te(L){for(let D=0;D<L.childNodes.length;D++){const B=L.childNodes[D];switch(B.nodeName){case"technique_common":return re(B)}}return{}}function re(L){const D={};for(let B=0;B<L.childNodes.length;B++){const F=L.childNodes[B];switch(F.nodeName){case"perspective":case"orthographic":D.technique=F.nodeName,D.parameters=De(F);break}}return D}function De(L){const D={};for(let B=0;B<L.childNodes.length;B++){const F=L.childNodes[B];switch(F.nodeName){case"xfov":case"yfov":case"xmag":case"ymag":case"znear":case"zfar":case"aspect_ratio":D[F.nodeName]=parseFloat(F.textContent);break}}return D}function Ye(L){let D;switch(L.optics.technique){case"perspective":D=new gn(L.optics.parameters.yfov,L.optics.parameters.aspect_ratio,L.optics.parameters.znear,L.optics.parameters.zfar);break;case"orthographic":let B=L.optics.parameters.ymag,F=L.optics.parameters.xmag;const z=L.optics.parameters.aspect_ratio;F=F===void 0?B*z:F,B=B===void 0?F/z:B,F*=.5,B*=.5,D=new ko(-F,F,B,-B,L.optics.parameters.znear,L.optics.parameters.zfar);break;default:D=new gn;break}return D.name=L.name||"",D}function xe(L){const D=ut.cameras[L];return D!==void 0?b(D,Ye):(console.warn("THREE.ColladaLoader: Couldn't find camera with ID:",L),null)}function Le(L){let D={};for(let B=0,F=L.childNodes.length;B<F;B++){const z=L.childNodes[B];if(z.nodeType===1)switch(z.nodeName){case"technique_common":D=ct(z);break}}ut.lights[L.getAttribute("id")]=D}function ct(L){const D={};for(let B=0,F=L.childNodes.length;B<F;B++){const z=L.childNodes[B];if(z.nodeType===1)switch(z.nodeName){case"directional":case"point":case"spot":case"ambient":D.technique=z.nodeName,D.parameters=rt(z)}}return D}function rt(L){const D={};for(let B=0,F=L.childNodes.length;B<F;B++){const z=L.childNodes[B];if(z.nodeType===1)switch(z.nodeName){case"color":const pe=s(z.textContent);D.color=new Ne().fromArray(pe),ft.toWorkingColorSpace(D.color,gt);break;case"falloff_angle":D.falloffAngle=parseFloat(z.textContent);break;case"quadratic_attenuation":const _e=parseFloat(z.textContent);D.distance=_e?Math.sqrt(1/_e):0;break}}return D}function Rt(L){let D;switch(L.technique){case"directional":D=new Hc;break;case"point":D=new Tc;break;case"spot":D=new $u;break;case"ambient":D=new Gb;break}return L.parameters.color&&D.color.copy(L.parameters.color),L.parameters.distance&&(D.distance=L.parameters.distance),D}function Q(L){const D=ut.lights[L];return D!==void 0?b(D,Rt):(console.warn("THREE.ColladaLoader: Couldn't find light with ID:",L),null)}function Ge(L){const D={name:L.getAttribute("name"),sources:{},vertices:{},primitives:[]},B=n(L,"mesh")[0];if(B!==void 0){for(let F=0;F<B.childNodes.length;F++){const z=B.childNodes[F];if(z.nodeType!==1)continue;const pe=z.getAttribute("id");switch(z.nodeName){case"source":D.sources[pe]=ye(z);break;case"vertices":D.vertices=Me(z);break;case"polygons":console.warn("THREE.ColladaLoader: Unsupported primitive type: ",z.nodeName);break;case"lines":case"linestrips":case"polylist":case"triangles":D.primitives.push(Ze(z));break;default:console.log(z)}}ut.geometries[L.getAttribute("id")]=D}}function ye(L){const D={array:[],stride:3};for(let B=0;B<L.childNodes.length;B++){const F=L.childNodes[B];if(F.nodeType===1)switch(F.nodeName){case"float_array":D.array=s(F.textContent);break;case"Name_array":D.array=i(F.textContent);break;case"technique_common":const z=n(F,"accessor")[0];z!==void 0&&(D.stride=parseInt(z.getAttribute("stride")));break}}return D}function Me(L){const D={};for(let B=0;B<L.childNodes.length;B++){const F=L.childNodes[B];F.nodeType===1&&(D[F.getAttribute("semantic")]=o(F.getAttribute("source")))}return D}function Ze(L){const D={type:L.nodeName,material:L.getAttribute("material"),count:parseInt(L.getAttribute("count")),inputs:{},stride:0,hasUV:!1};for(let B=0,F=L.childNodes.length;B<F;B++){const z=L.childNodes[B];if(z.nodeType===1)switch(z.nodeName){case"input":const pe=o(z.getAttribute("source")),_e=z.getAttribute("semantic"),Qe=parseInt(z.getAttribute("offset")),ze=parseInt(z.getAttribute("set")),qe=ze>0?_e+ze:_e;D.inputs[qe]={id:pe,offset:Qe},D.stride=Math.max(D.stride,Qe+1),_e==="TEXCOORD"&&(D.hasUV=!0);break;case"vcount":D.vcount=a(z.textContent);break;case"p":D.p=a(z.textContent);break}}return D}function Xe(L){const D={};for(let B=0;B<L.length;B++){const F=L[B];D[F.type]===void 0&&(D[F.type]=[]),D[F.type].push(F)}return D}function vt(L){let D=0;for(let B=0,F=L.length;B<F;B++)L[B].hasUV===!0&&D++;D>0&&D<L.length&&(L.uvsNeedsFix=!0)}function Qt(L){const D={},B=L.sources,F=L.vertices,z=L.primitives;if(z.length===0)return{};const pe=Xe(z);for(const _e in pe){const Qe=pe[_e];vt(Qe),D[_e]=An(Qe,B,F)}return D}function An(L,D,B){const F={},z={array:[],stride:0},pe={array:[],stride:0},_e={array:[],stride:0},Qe={array:[],stride:0},ze={array:[],stride:0},qe={array:[],stride:4},st={array:[],stride:4},Ae=new ht,it=[];let tt=0;for(let dt=0;dt<L.length;dt++){const ot=L[dt],on=ot.inputs;let Bt=0;switch(ot.type){case"lines":case"linestrips":Bt=ot.count*2;break;case"triangles":Bt=ot.count*3;break;case"polylist":for(let Ot=0;Ot<ot.count;Ot++){const Ft=ot.vcount[Ot];switch(Ft){case 3:Bt+=3;break;case 4:Bt+=6;break;default:Bt+=(Ft-2)*3;break}}break;default:console.warn("THREE.ColladaLoader: Unknown primitive type:",ot.type)}Ae.addGroup(tt,Bt,dt),tt+=Bt,ot.material&&it.push(ot.material);for(const Ot in on){const Ft=on[Ot];switch(Ot){case"VERTEX":for(const cs in B){const ai=B[cs];switch(cs){case"POSITION":const Nr=z.array.length;if(wt(ot,D[ai],Ft.offset,z.array),z.stride=D[ai].stride,D.skinWeights&&D.skinIndices&&(wt(ot,D.skinIndices,Ft.offset,qe.array),wt(ot,D.skinWeights,Ft.offset,st.array)),ot.hasUV===!1&&L.uvsNeedsFix===!0){const Lv=(z.array.length-Nr)/z.stride;for(let vf=0;vf<Lv;vf++)_e.array.push(0,0)}break;case"NORMAL":wt(ot,D[ai],Ft.offset,pe.array),pe.stride=D[ai].stride;break;case"COLOR":wt(ot,D[ai],Ft.offset,ze.array),ze.stride=D[ai].stride;break;case"TEXCOORD":wt(ot,D[ai],Ft.offset,_e.array),_e.stride=D[ai].stride;break;case"TEXCOORD1":wt(ot,D[ai],Ft.offset,Qe.array),_e.stride=D[ai].stride;break;default:console.warn('THREE.ColladaLoader: Semantic "%s" not handled in geometry build process.',cs)}}break;case"NORMAL":wt(ot,D[Ft.id],Ft.offset,pe.array),pe.stride=D[Ft.id].stride;break;case"COLOR":wt(ot,D[Ft.id],Ft.offset,ze.array,!0),ze.stride=D[Ft.id].stride;break;case"TEXCOORD":wt(ot,D[Ft.id],Ft.offset,_e.array),_e.stride=D[Ft.id].stride;break;case"TEXCOORD1":wt(ot,D[Ft.id],Ft.offset,Qe.array),Qe.stride=D[Ft.id].stride;break}}}return z.array.length>0&&Ae.setAttribute("position",new ke(z.array,z.stride)),pe.array.length>0&&Ae.setAttribute("normal",new ke(pe.array,pe.stride)),ze.array.length>0&&Ae.setAttribute("color",new ke(ze.array,ze.stride)),_e.array.length>0&&Ae.setAttribute("uv",new ke(_e.array,_e.stride)),Qe.array.length>0&&Ae.setAttribute("uv1",new ke(Qe.array,Qe.stride)),qe.array.length>0&&Ae.setAttribute("skinIndex",new ke(qe.array,qe.stride)),st.array.length>0&&Ae.setAttribute("skinWeight",new ke(st.array,st.stride)),F.data=Ae,F.type=L[0].type,F.materialKeys=it,F}function wt(L,D,B,F,z=!1){const pe=L.p,_e=L.stride,Qe=L.vcount;function ze(Ae){let it=pe[Ae+B]*st;const tt=it+st;for(;it<tt;it++)F.push(qe[it]);if(z){const dt=F.length-st-1;fn.setRGB(F[dt+0],F[dt+1],F[dt+2],gt),F[dt+0]=fn.r,F[dt+1]=fn.g,F[dt+2]=fn.b}}const qe=D.array,st=D.stride;if(L.vcount!==void 0){let Ae=0;for(let it=0,tt=Qe.length;it<tt;it++){const dt=Qe[it];if(dt===4){const ot=Ae+_e*0,on=Ae+_e*1,Bt=Ae+_e*2,Ot=Ae+_e*3;ze(ot),ze(on),ze(Ot),ze(on),ze(Bt),ze(Ot)}else if(dt===3){const ot=Ae+_e*0,on=Ae+_e*1,Bt=Ae+_e*2;ze(ot),ze(on),ze(Bt)}else if(dt>4)for(let ot=1,on=dt-2;ot<=on;ot++){const Bt=Ae+_e*0,Ot=Ae+_e*ot,Ft=Ae+_e*(ot+1);ze(Bt),ze(Ot),ze(Ft)}Ae+=_e*dt}}else for(let Ae=0,it=pe.length;Ae<it;Ae+=_e)ze(Ae)}function si(L){return b(ut.geometries[L],Qt)}function Fi(L){const D={name:L.getAttribute("name")||"",joints:{},links:[]};for(let B=0;B<L.childNodes.length;B++){const F=L.childNodes[B];if(F.nodeType===1)switch(F.nodeName){case"technique_common":os(F,D);break}}ut.kinematicsModels[L.getAttribute("id")]=D}function zo(L){return L.build!==void 0?L.build:L}function Ho(L){return b(ut.kinematicsModels[L],zo)}function os(L,D){for(let B=0;B<L.childNodes.length;B++){const F=L.childNodes[B];if(F.nodeType===1)switch(F.nodeName){case"joint":D.joints[F.getAttribute("sid")]=ka(F);break;case"link":D.links.push(Oa(F));break}}}function ka(L){let D;for(let B=0;B<L.childNodes.length;B++){const F=L.childNodes[B];if(F.nodeType===1)switch(F.nodeName){case"prismatic":case"revolute":D=Go(F);break}}return D}function Go(L){const D={sid:L.getAttribute("sid"),name:L.getAttribute("name")||"",axis:new I,limits:{min:0,max:0},type:L.nodeName,static:!1,zeroPosition:0,middlePosition:0};for(let B=0;B<L.childNodes.length;B++){const F=L.childNodes[B];if(F.nodeType===1)switch(F.nodeName){case"axis":const z=s(F.textContent);D.axis.fromArray(z);break;case"limits":const pe=F.getElementsByTagName("max")[0],_e=F.getElementsByTagName("min")[0];D.limits.max=parseFloat(pe.textContent),D.limits.min=parseFloat(_e.textContent);break}}return D.limits.min>=D.limits.max&&(D.static=!0),D.middlePosition=(D.limits.min+D.limits.max)/2,D}function Oa(L){const D={sid:L.getAttribute("sid"),name:L.getAttribute("name")||"",attachments:[],transforms:[]};for(let B=0;B<L.childNodes.length;B++){const F=L.childNodes[B];if(F.nodeType===1)switch(F.nodeName){case"attachment_full":D.attachments.push(Cr(F));break;case"matrix":case"translate":case"rotate":D.transforms.push(Fa(F));break}}return D}function Cr(L){const D={joint:L.getAttribute("joint").split("/").pop(),transforms:[],links:[]};for(let B=0;B<L.childNodes.length;B++){const F=L.childNodes[B];if(F.nodeType===1)switch(F.nodeName){case"link":D.links.push(Oa(F));break;case"matrix":case"translate":case"rotate":D.transforms.push(Fa(F));break}}return D}function Fa(L){const D={type:L.nodeName},B=s(L.textContent);switch(D.type){case"matrix":D.obj=new Ie,D.obj.fromArray(B).transpose();break;case"translate":D.obj=new I,D.obj.fromArray(B);break;case"rotate":D.obj=new I,D.obj.fromArray(B),D.angle=bt.degToRad(B[3]);break}return D}function Pr(L){const D={name:L.getAttribute("name")||"",rigidBodies:{}};for(let B=0;B<L.childNodes.length;B++){const F=L.childNodes[B];if(F.nodeType===1)switch(F.nodeName){case"rigid_body":D.rigidBodies[F.getAttribute("name")]={},Vo(F,D.rigidBodies[F.getAttribute("name")]);break}}ut.physicsModels[L.getAttribute("id")]=D}function Vo(L,D){for(let B=0;B<L.childNodes.length;B++){const F=L.childNodes[B];if(F.nodeType===1)switch(F.nodeName){case"technique_common":Wo(F,D);break}}}function Wo(L,D){for(let B=0;B<L.childNodes.length;B++){const F=L.childNodes[B];if(F.nodeType===1)switch(F.nodeName){case"inertia":D.inertia=s(F.textContent);break;case"mass":D.mass=s(F.textContent)[0];break}}}function Wc(L){const D={bindJointAxis:[]};for(let B=0;B<L.childNodes.length;B++){const F=L.childNodes[B];if(F.nodeType===1)switch(F.nodeName){case"bind_joint_axis":D.bindJointAxis.push(jc(F));break}}ut.kinematicsScenes[o(L.getAttribute("url"))]=D}function jc(L){const D={target:L.getAttribute("target").split("/").pop()};for(let B=0;B<L.childNodes.length;B++){const F=L.childNodes[B];if(F.nodeType===1)switch(F.nodeName){case"axis":const z=F.getElementsByTagName("param")[0];D.axis=z.textContent;const pe=D.axis.split("inst_").pop().split("axis")[0];D.jointIndex=pe.substring(0,pe.length-1);break}}return D}function Xc(L){return L.build!==void 0?L.build:L}function qc(L){return b(ut.kinematicsScenes[L],Xc)}function Zc(){const L=Object.keys(ut.kinematicsModels)[0],D=Object.keys(ut.kinematicsScenes)[0],B=Object.keys(ut.visualScenes)[0];if(L===void 0||D===void 0)return;const F=Ho(L),z=qc(D),pe=Nt(B),_e=z.bindJointAxis,Qe={};for(let st=0,Ae=_e.length;st<Ae;st++){const it=_e[st],tt=Kt.querySelector('[sid="'+it.target+'"]');if(tt){const dt=tt.parentElement;ze(it.jointIndex,dt)}}function ze(st,Ae){const it=Ae.getAttribute("name"),tt=F.joints[st];pe.traverse(function(dt){dt.name===it&&(Qe[st]={object:dt,transforms:Yc(Ae),joint:tt,position:tt.zeroPosition})})}const qe=new Ie;Rr={joints:F&&F.joints,getJointValue:function(st){const Ae=Qe[st];if(Ae)return Ae.position;console.warn("THREE.ColladaLoader: Joint "+st+" doesn't exist.")},setJointValue:function(st,Ae){const it=Qe[st];if(it){const tt=it.joint;if(Ae>tt.limits.max||Ae<tt.limits.min)console.warn("THREE.ColladaLoader: Joint "+st+" value "+Ae+" outside of limits (min: "+tt.limits.min+", max: "+tt.limits.max+").");else if(tt.static)console.warn("THREE.ColladaLoader: Joint "+st+" is static.");else{const dt=it.object,ot=tt.axis,on=it.transforms;J.identity();for(let Bt=0;Bt<on.length;Bt++){const Ot=on[Bt];if(Ot.sid&&Ot.sid.indexOf(st)!==-1)switch(tt.type){case"revolute":J.multiply(qe.makeRotationAxis(ot,bt.degToRad(Ae)));break;case"prismatic":J.multiply(qe.makeTranslation(ot.x*Ae,ot.y*Ae,ot.z*Ae));break;default:console.warn("THREE.ColladaLoader: Unknown joint type: "+tt.type);break}else switch(Ot.type){case"matrix":J.multiply(Ot.obj);break;case"translate":J.multiply(qe.makeTranslation(Ot.obj.x,Ot.obj.y,Ot.obj.z));break;case"scale":J.scale(Ot.obj);break;case"rotate":J.multiply(qe.makeRotationAxis(Ot.obj,Ot.angle));break}}dt.matrix.copy(J),dt.matrix.decompose(dt.position,dt.quaternion,dt.scale),Qe[st].position=Ae}}else console.log("THREE.ColladaLoader: "+st+" does not exist.")}}}function Yc(L){const D=[],B=Kt.querySelector('[id="'+L.id+'"]');for(let F=0;F<B.childNodes.length;F++){const z=B.childNodes[F];if(z.nodeType!==1)continue;let pe,_e;switch(z.nodeName){case"matrix":pe=s(z.textContent);const Qe=new Ie().fromArray(pe).transpose();D.push({sid:z.getAttribute("sid"),type:z.nodeName,obj:Qe});break;case"translate":case"scale":pe=s(z.textContent),_e=new I().fromArray(pe),D.push({sid:z.getAttribute("sid"),type:z.nodeName,obj:_e});break;case"rotate":pe=s(z.textContent),_e=new I().fromArray(pe);const ze=bt.degToRad(pe[3]);D.push({sid:z.getAttribute("sid"),type:z.nodeName,obj:_e,angle:ze});break}}return D}function U(L){const D=L.getElementsByTagName("node");for(let B=0;B<D.length;B++){const F=D[B];F.hasAttribute("id")===!1&&F.setAttribute("id",l())}}const J=new Ie,he=new I;function fe(L){const D={name:L.getAttribute("name")||"",type:L.getAttribute("type"),id:L.getAttribute("id"),sid:L.getAttribute("sid"),matrix:new Ie,nodes:[],instanceCameras:[],instanceControllers:[],instanceLights:[],instanceGeometries:[],instanceNodes:[],transforms:{}};for(let B=0;B<L.childNodes.length;B++){const F=L.childNodes[B];if(F.nodeType!==1)continue;let z;switch(F.nodeName){case"node":D.nodes.push(F.getAttribute("id")),fe(F);break;case"instance_camera":D.instanceCameras.push(o(F.getAttribute("url")));break;case"instance_controller":D.instanceControllers.push(ne(F));break;case"instance_light":D.instanceLights.push(o(F.getAttribute("url")));break;case"instance_geometry":D.instanceGeometries.push(ne(F));break;case"instance_node":D.instanceNodes.push(o(F.getAttribute("url")));break;case"matrix":z=s(F.textContent),D.matrix.multiply(J.fromArray(z).transpose()),D.transforms[F.getAttribute("sid")]=F.nodeName;break;case"translate":z=s(F.textContent),he.fromArray(z),D.matrix.multiply(J.makeTranslation(he.x,he.y,he.z)),D.transforms[F.getAttribute("sid")]=F.nodeName;break;case"rotate":z=s(F.textContent);const pe=bt.degToRad(z[3]);D.matrix.multiply(J.makeRotationAxis(he.fromArray(z),pe)),D.transforms[F.getAttribute("sid")]=F.nodeName;break;case"scale":z=s(F.textContent),D.matrix.scale(he.fromArray(z)),D.transforms[F.getAttribute("sid")]=F.nodeName;break;case"extra":break;default:console.log(F)}}return at(D.id)?console.warn("THREE.ColladaLoader: There is already a node with ID %s. Exclude current node from further processing.",D.id):ut.nodes[D.id]=D,D}function ne(L){const D={id:o(L.getAttribute("url")),materials:{},skeletons:[]};for(let B=0;B<L.childNodes.length;B++){const F=L.childNodes[B];switch(F.nodeName){case"bind_material":const z=F.getElementsByTagName("instance_material");for(let pe=0;pe<z.length;pe++){const _e=z[pe],Qe=_e.getAttribute("symbol"),ze=_e.getAttribute("target");D.materials[Qe]=o(ze)}break;case"skeleton":D.skeletons.push(o(F.textContent));break}}return D}function Re(L,D){const B=[],F=[];let z,pe,_e;for(z=0;z<L.length;z++){const qe=L[z];let st;if(at(qe))st=St(qe),We(st,D,B);else if(nn(qe)){const it=ut.visualScenes[qe].children;for(let tt=0;tt<it.length;tt++){const dt=it[tt];if(dt.type==="JOINT"){const ot=St(dt.id);We(ot,D,B)}}}else console.error("THREE.ColladaLoader: Unable to find root bone of skeleton with ID:",qe)}for(z=0;z<D.length;z++)for(pe=0;pe<B.length;pe++)if(_e=B[pe],_e.bone.name===D[z].name){F[z]=_e,_e.processed=!0;break}for(z=0;z<B.length;z++)_e=B[z],_e.processed===!1&&(F.push(_e),_e.processed=!0);const Qe=[],ze=[];for(z=0;z<F.length;z++)_e=F[z],Qe.push(_e.bone),ze.push(_e.boneInverse);return new Ro(Qe,ze)}function We(L,D,B){L.traverse(function(F){if(F.isBone===!0){let z;for(let pe=0;pe<D.length;pe++){const _e=D[pe];if(_e.name===F.name){z=_e.boneInverse;break}}z===void 0&&(z=new Ie),B.push({bone:F,boneInverse:z,processed:!1})}})}function $e(L){const D=[],B=L.matrix,F=L.nodes,z=L.type,pe=L.instanceCameras,_e=L.instanceControllers,Qe=L.instanceLights,ze=L.instanceGeometries,qe=L.instanceNodes;for(let Ae=0,it=F.length;Ae<it;Ae++)D.push(St(F[Ae]));for(let Ae=0,it=pe.length;Ae<it;Ae++){const tt=xe(pe[Ae]);tt!==null&&D.push(tt.clone())}for(let Ae=0,it=_e.length;Ae<it;Ae++){const tt=_e[Ae],dt=ee(tt.id),ot=si(dt.id),on=mt(ot,tt.materials),Bt=tt.skeletons,Ot=dt.skin.joints,Ft=Re(Bt,Ot);for(let cs=0,ai=on.length;cs<ai;cs++){const Nr=on[cs];Nr.isSkinnedMesh&&(Nr.bind(Ft,dt.skin.bindMatrix),Nr.normalizeSkinWeights()),D.push(Nr)}}for(let Ae=0,it=Qe.length;Ae<it;Ae++){const tt=Q(Qe[Ae]);tt!==null&&D.push(tt.clone())}for(let Ae=0,it=ze.length;Ae<it;Ae++){const tt=ze[Ae],dt=si(tt.id),ot=mt(dt,tt.materials);for(let on=0,Bt=ot.length;on<Bt;on++)D.push(ot[on])}for(let Ae=0,it=qe.length;Ae<it;Ae++)D.push(St(qe[Ae]).clone());let st;if(F.length===0&&D.length===1)st=D[0];else{st=z==="JOINT"?new _o:new Vt;for(let Ae=0;Ae<D.length;Ae++)st.add(D[Ae])}return st.name=z==="JOINT"?L.sid:L.name,st.matrix.copy(B),st.matrix.decompose(st.position,st.quaternion,st.scale),st}const Je=new jt({name:pi.DEFAULT_MATERIAL_NAME,color:16711935});function pt(L,D){const B=[];for(let F=0,z=L.length;F<z;F++){const pe=D[L[F]];pe===void 0?(console.warn("THREE.ColladaLoader: Material with key %s not found. Apply fallback material.",L[F]),B.push(Je)):B.push(Pe(pe))}return B}function mt(L,D){const B=[];for(const F in L){const z=L[F],pe=pt(z.materialKeys,D);if(pe.length===0&&(F==="lines"||F==="linestrips"?pe.push(new zn):pe.push(new Ii)),F==="lines"||F==="linestrips")for(let qe=0,st=pe.length;qe<st;qe++){const Ae=pe[qe];if(Ae.isMeshPhongMaterial===!0||Ae.isMeshLambertMaterial===!0){const it=new zn;it.color.copy(Ae.color),it.opacity=Ae.opacity,it.transparent=Ae.transparent,pe[qe]=it}}const _e=z.data.attributes.skinIndex!==void 0,Qe=pe.length===1?pe[0]:pe;let ze;switch(F){case"lines":ze=new Ks(z.data,Qe);break;case"linestrips":ze=new qn(z.data,Qe);break;case"triangles":case"polylist":_e?ze=new Vu(z.data,Qe):ze=new Ee(z.data,Qe);break}B.push(ze)}return B}function at(L){return ut.nodes[L]!==void 0}function St(L){return b(ut.nodes[L],$e)}function It(L){const D={name:L.getAttribute("name"),children:[]};U(L);const B=n(L,"node");for(let F=0;F<B.length;F++)D.children.push(fe(B[F]));ut.visualScenes[L.getAttribute("id")]=D}function an(L){const D=new Vt;D.name=L.name;const B=L.children;for(let F=0;F<B.length;F++){const z=B[F];D.add(St(z.id))}return D}function nn(L){return ut.visualScenes[L]!==void 0}function Nt(L){return b(ut.visualScenes[L],an)}function lt(L){const D=n(L,"instance_visual_scene")[0];return Nt(o(D.getAttribute("url")))}function yn(){const L=ut.clips;if(c(L)===!0){if(c(ut.animations)===!1){const D=[];for(const B in ut.animations){const F=w(B);for(let z=0,pe=F.length;z<pe;z++)D.push(F[z])}xn.push(new Mc("default",-1,D))}}else for(const D in L)xn.push(V(D))}function kt(L){let D="";const B=[L];for(;B.length;){const F=B.shift();F.nodeType===Node.TEXT_NODE?D+=F.textContent:(D+=`
|
|
4226
|
+
`};class To extends wn{constructor(e){super({type:"LineMaterial",uniforms:Ca.clone(di.line.uniforms),vertexShader:di.line.vertexShader,fragmentShader:di.line.fragmentShader,clipping:!0}),this.isLineMaterial=!0,this.setValues(e)}get color(){return this.uniforms.diffuse.value}set color(e){this.uniforms.diffuse.value=e}get worldUnits(){return"WORLD_UNITS"in this.defines}set worldUnits(e){e===!0?this.defines.WORLD_UNITS="":delete this.defines.WORLD_UNITS}get linewidth(){return this.uniforms.linewidth.value}set linewidth(e){this.uniforms.linewidth&&(this.uniforms.linewidth.value=e)}get dashed(){return"USE_DASH"in this.defines}set dashed(e){e===!0!==this.dashed&&(this.needsUpdate=!0),e===!0?this.defines.USE_DASH="":delete this.defines.USE_DASH}get dashScale(){return this.uniforms.dashScale.value}set dashScale(e){this.uniforms.dashScale.value=e}get dashSize(){return this.uniforms.dashSize.value}set dashSize(e){this.uniforms.dashSize.value=e}get dashOffset(){return this.uniforms.dashOffset.value}set dashOffset(e){this.uniforms.dashOffset.value=e}get gapSize(){return this.uniforms.gapSize.value}set gapSize(e){this.uniforms.gapSize.value=e}get opacity(){return this.uniforms.opacity.value}set opacity(e){this.uniforms&&(this.uniforms.opacity.value=e)}get resolution(){return this.uniforms.resolution.value}set resolution(e){this.uniforms.resolution.value.copy(e)}get alphaToCoverage(){return"USE_ALPHA_TO_COVERAGE"in this.defines}set alphaToCoverage(e){this.defines&&(e===!0!==this.alphaToCoverage&&(this.needsUpdate=!0),e===!0?this.defines.USE_ALPHA_TO_COVERAGE="":delete this.defines.USE_ALPHA_TO_COVERAGE)}}const Ud=new _t,om=new I,lm=new I,In=new _t,kn=new _t,Ki=new _t,Bd=new I,zd=new Ie,On=new H_,cm=new I,kl=new Yt,Ol=new vn,$i=new _t;let is,_r;function dm(r,e,t){return $i.set(0,0,-e,1).applyMatrix4(r.projectionMatrix),$i.multiplyScalar(1/$i.w),$i.x=_r/t.width,$i.y=_r/t.height,$i.applyMatrix4(r.projectionMatrixInverse),$i.multiplyScalar(1/$i.w),Math.abs(Math.max($i.x,$i.y))}function AE(r,e){const t=r.matrixWorld,n=r.geometry,i=n.attributes.instanceStart,s=n.attributes.instanceEnd,a=Math.min(n.instanceCount,i.count);for(let o=0,l=a;o<l;o++){On.start.fromBufferAttribute(i,o),On.end.fromBufferAttribute(s,o),On.applyMatrix4(t);const c=new I,d=new I;is.distanceSqToSegment(On.start,On.end,d,c),d.distanceTo(c)<_r*.5&&e.push({point:d,pointOnLine:c,distance:is.origin.distanceTo(d),object:r,face:null,faceIndex:o,uv:null,uv1:null})}}function CE(r,e,t){const n=e.projectionMatrix,s=r.material.resolution,a=r.matrixWorld,o=r.geometry,l=o.attributes.instanceStart,c=o.attributes.instanceEnd,d=Math.min(o.instanceCount,l.count),h=-e.near;is.at(1,Ki),Ki.w=1,Ki.applyMatrix4(e.matrixWorldInverse),Ki.applyMatrix4(n),Ki.multiplyScalar(1/Ki.w),Ki.x*=s.x/2,Ki.y*=s.y/2,Ki.z=0,Bd.copy(Ki),zd.multiplyMatrices(e.matrixWorldInverse,a);for(let u=0,f=d;u<f;u++){if(In.fromBufferAttribute(l,u),kn.fromBufferAttribute(c,u),In.w=1,kn.w=1,In.applyMatrix4(zd),kn.applyMatrix4(zd),In.z>h&&kn.z>h)continue;if(In.z>h){const x=In.z-kn.z,w=(In.z-h)/x;In.lerp(kn,w)}else if(kn.z>h){const x=kn.z-In.z,w=(kn.z-h)/x;kn.lerp(In,w)}In.applyMatrix4(n),kn.applyMatrix4(n),In.multiplyScalar(1/In.w),kn.multiplyScalar(1/kn.w),In.x*=s.x/2,In.y*=s.y/2,kn.x*=s.x/2,kn.y*=s.y/2,On.start.copy(In),On.start.z=0,On.end.copy(kn),On.end.z=0;const b=On.closestPointToPointParameter(Bd,!0);On.at(b,cm);const p=bt.lerp(In.z,kn.z,b),g=p>=-1&&p<=1,y=Bd.distanceTo(cm)<_r*.5;if(g&&y){On.start.fromBufferAttribute(l,u),On.end.fromBufferAttribute(c,u),On.start.applyMatrix4(a),On.end.applyMatrix4(a);const x=new I,w=new I;is.distanceSqToSegment(On.start,On.end,w,x),t.push({point:w,pointOnLine:x,distance:is.origin.distanceTo(w),object:r,face:null,faceIndex:u,uv:null,uv1:null})}}}class PE extends Ee{constructor(e=new $b,t=new To({color:Math.random()*16777215})){super(e,t),this.isLineSegments2=!0,this.type="LineSegments2"}computeLineDistances(){const e=this.geometry,t=e.attributes.instanceStart,n=e.attributes.instanceEnd,i=new Float32Array(2*t.count);for(let a=0,o=0,l=t.count;a<l;a++,o+=2)om.fromBufferAttribute(t,a),lm.fromBufferAttribute(n,a),i[o]=o===0?0:i[o-1],i[o+1]=i[o]+om.distanceTo(lm);const s=new vu(i,2,1);return e.setAttribute("instanceDistanceStart",new Xi(s,1,0)),e.setAttribute("instanceDistanceEnd",new Xi(s,1,1)),this}raycast(e,t){const n=this.material.worldUnits,i=e.camera;i===null&&!n&&console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.');const s=e.params.Line2!==void 0&&e.params.Line2.threshold||0;is=e.ray;const a=this.matrixWorld,o=this.geometry,l=this.material;_r=l.linewidth+s,o.boundingSphere===null&&o.computeBoundingSphere(),Ol.copy(o.boundingSphere).applyMatrix4(a);let c;if(n)c=_r*.5;else{const h=Math.max(i.near,Ol.distanceToPoint(is.origin));c=dm(i,h,l.resolution)}if(Ol.radius+=c,is.intersectsSphere(Ol)===!1)return;o.boundingBox===null&&o.computeBoundingBox(),kl.copy(o.boundingBox).applyMatrix4(a);let d;if(n)d=_r*.5;else{const h=Math.max(i.near,kl.distanceToPoint(is.origin));d=dm(i,h,l.resolution)}kl.expandByScalar(d),is.intersectsBox(kl)!==!1&&(n?AE(this,t):CE(this,i,t))}onBeforeRender(e){const t=this.material.uniforms;t&&t.resolution&&(e.getViewport(Ud),this.material.uniforms.resolution.value.set(Ud.z,Ud.w))}}class js extends $b{constructor(){super(),this.isLineGeometry=!0,this.type="LineGeometry"}setPositions(e){const t=e.length-3,n=new Float32Array(2*t);for(let i=0;i<t;i+=3)n[2*i]=e[i],n[2*i+1]=e[i+1],n[2*i+2]=e[i+2],n[2*i+3]=e[i+3],n[2*i+4]=e[i+4],n[2*i+5]=e[i+5];return super.setPositions(n),this}setColors(e){const t=e.length-3,n=new Float32Array(2*t);for(let i=0;i<t;i+=3)n[2*i]=e[i],n[2*i+1]=e[i+1],n[2*i+2]=e[i+2],n[2*i+3]=e[i+3],n[2*i+4]=e[i+4],n[2*i+5]=e[i+5];return super.setColors(n),this}setFromPoints(e){const t=e.length-1,n=new Float32Array(6*t);for(let i=0;i<t;i++)n[6*i]=e[i].x,n[6*i+1]=e[i].y,n[6*i+2]=e[i].z||0,n[6*i+3]=e[i+1].x,n[6*i+4]=e[i+1].y,n[6*i+5]=e[i+1].z||0;return super.setPositions(n),this}fromLine(e){const t=e.geometry;return this.setPositions(t.attributes.position.array),this}}class fo extends PE{constructor(e=new js,t=new To({color:Math.random()*16777215})){super(e,t),this.isLine2=!0,this.type="Line2"}}const lr=new tf,Xn=new I,ks=new I,sn=new Lt,hm={X:new I(1,0,0),Y:new I(0,1,0),Z:new I(0,0,1)},Hd={type:"change"},um={type:"mouseDown",mode:null},fm={type:"mouseUp",mode:null},pm={type:"objectChange"};class RE extends Vb{constructor(e,t=null){super(void 0,t);const n=new OE(this);this._root=n;const i=new FE;this._gizmo=i,n.add(i);const s=new UE;this._plane=s,n.add(s);const a=this;function o(x,w){let P=w;Object.defineProperty(a,x,{get:function(){return P!==void 0?P:w},set:function(T){P!==T&&(P=T,s[x]=T,i[x]=T,a.dispatchEvent({type:x+"-changed",value:T}),a.dispatchEvent(Hd))}}),a[x]=w,s[x]=w,i[x]=w}o("camera",e),o("object",void 0),o("enabled",!0),o("axis",null),o("mode","translate"),o("translationSnap",null),o("rotationSnap",null),o("scaleSnap",null),o("space","world"),o("size",1),o("dragging",!1),o("showX",!0),o("showY",!0),o("showZ",!0),o("minX",-1/0),o("maxX",1/0),o("minY",-1/0),o("maxY",1/0),o("minZ",-1/0),o("maxZ",1/0);const l=new I,c=new I,d=new Lt,h=new Lt,u=new I,f=new Lt,m=new I,b=new I,p=new I,g=0,y=new I;o("worldPosition",l),o("worldPositionStart",c),o("worldQuaternion",d),o("worldQuaternionStart",h),o("cameraPosition",u),o("cameraQuaternion",f),o("pointStart",m),o("pointEnd",b),o("rotationAxis",p),o("rotationAngle",g),o("eye",y),this._offset=new I,this._startNorm=new I,this._endNorm=new I,this._cameraScale=new I,this._parentPosition=new I,this._parentQuaternion=new Lt,this._parentQuaternionInv=new Lt,this._parentScale=new I,this._worldScaleStart=new I,this._worldQuaternionInv=new Lt,this._worldScale=new I,this._positionStart=new I,this._quaternionStart=new Lt,this._scaleStart=new I,this._getPointer=NE.bind(this),this._onPointerDown=LE.bind(this),this._onPointerHover=DE.bind(this),this._onPointerMove=IE.bind(this),this._onPointerUp=kE.bind(this),t!==null&&this.connect()}connect(){this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointermove",this._onPointerHover),this.domElement.addEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerHover),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="auto"}getHelper(){return this._root}pointerHover(e){if(this.object===void 0||this.dragging===!0)return;e!==null&&lr.setFromCamera(e,this.camera);const t=Gd(this._gizmo.picker[this.mode],lr);t?this.axis=t.object.name:this.axis=null}pointerDown(e){if(!(this.object===void 0||this.dragging===!0||e!=null&&e.button!==0)&&this.axis!==null){e!==null&&lr.setFromCamera(e,this.camera);const t=Gd(this._plane,lr,!0);t&&(this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),this._positionStart.copy(this.object.position),this._quaternionStart.copy(this.object.quaternion),this._scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this._worldScaleStart),this.pointStart.copy(t.point).sub(this.worldPositionStart)),this.dragging=!0,um.mode=this.mode,this.dispatchEvent(um)}}pointerMove(e){const t=this.axis,n=this.mode,i=this.object;let s=this.space;if(n==="scale"?s="local":(t==="E"||t==="XYZE"||t==="XYZ")&&(s="world"),i===void 0||t===null||this.dragging===!1||e!==null&&e.button!==-1)return;e!==null&&lr.setFromCamera(e,this.camera);const a=Gd(this._plane,lr,!0);if(a){if(this.pointEnd.copy(a.point).sub(this.worldPositionStart),n==="translate")this._offset.copy(this.pointEnd).sub(this.pointStart),s==="local"&&t!=="XYZ"&&this._offset.applyQuaternion(this._worldQuaternionInv),t.indexOf("X")===-1&&(this._offset.x=0),t.indexOf("Y")===-1&&(this._offset.y=0),t.indexOf("Z")===-1&&(this._offset.z=0),s==="local"&&t!=="XYZ"?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),i.position.copy(this._offset).add(this._positionStart),this.translationSnap&&(s==="local"&&(i.position.applyQuaternion(sn.copy(this._quaternionStart).invert()),t.search("X")!==-1&&(i.position.x=Math.round(i.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(i.position.y=Math.round(i.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(i.position.z=Math.round(i.position.z/this.translationSnap)*this.translationSnap),i.position.applyQuaternion(this._quaternionStart)),s==="world"&&(i.parent&&i.position.add(Xn.setFromMatrixPosition(i.parent.matrixWorld)),t.search("X")!==-1&&(i.position.x=Math.round(i.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(i.position.y=Math.round(i.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(i.position.z=Math.round(i.position.z/this.translationSnap)*this.translationSnap),i.parent&&i.position.sub(Xn.setFromMatrixPosition(i.parent.matrixWorld)))),i.position.x=Math.max(this.minX,Math.min(this.maxX,i.position.x)),i.position.y=Math.max(this.minY,Math.min(this.maxY,i.position.y)),i.position.z=Math.max(this.minZ,Math.min(this.maxZ,i.position.z));else if(n==="scale"){if(t.search("XYZ")!==-1){let o=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(o*=-1),ks.set(o,o,o)}else Xn.copy(this.pointStart),ks.copy(this.pointEnd),Xn.applyQuaternion(this._worldQuaternionInv),ks.applyQuaternion(this._worldQuaternionInv),ks.divide(Xn),t.search("X")===-1&&(ks.x=1),t.search("Y")===-1&&(ks.y=1),t.search("Z")===-1&&(ks.z=1);i.scale.copy(this._scaleStart).multiply(ks),this.scaleSnap&&(t.search("X")!==-1&&(i.scale.x=Math.round(i.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Y")!==-1&&(i.scale.y=Math.round(i.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Z")!==-1&&(i.scale.z=Math.round(i.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(n==="rotate"){this._offset.copy(this.pointEnd).sub(this.pointStart);const o=20/this.worldPosition.distanceTo(Xn.setFromMatrixPosition(this.camera.matrixWorld));let l=!1;t==="XYZE"?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(Xn.copy(this.rotationAxis).cross(this.eye))*o):(t==="X"||t==="Y"||t==="Z")&&(this.rotationAxis.copy(hm[t]),Xn.copy(hm[t]),s==="local"&&Xn.applyQuaternion(this.worldQuaternion),Xn.cross(this.eye),Xn.length()===0?l=!0:this.rotationAngle=this._offset.dot(Xn.normalize())*o),(t==="E"||l)&&(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),s==="local"&&t!=="E"&&t!=="XYZE"?(i.quaternion.copy(this._quaternionStart),i.quaternion.multiply(sn.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),i.quaternion.copy(sn.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),i.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(Hd),this.dispatchEvent(pm)}}pointerUp(e){e!==null&&e.button!==0||(this.dragging&&this.axis!==null&&(fm.mode=this.mode,this.dispatchEvent(fm)),this.dragging=!1,this.axis=null)}dispose(){this.disconnect(),this._root.dispose()}attach(e){return this.object=e,this._root.visible=!0,this}detach(){return this.object=void 0,this.axis=null,this._root.visible=!1,this}reset(){this.enabled&&this.dragging&&(this.object.position.copy(this._positionStart),this.object.quaternion.copy(this._quaternionStart),this.object.scale.copy(this._scaleStart),this.dispatchEvent(Hd),this.dispatchEvent(pm),this.pointStart.copy(this.pointEnd))}getRaycaster(){return lr}getMode(){return this.mode}setMode(e){this.mode=e}setTranslationSnap(e){this.translationSnap=e}setRotationSnap(e){this.rotationSnap=e}setScaleSnap(e){this.scaleSnap=e}setSize(e){this.size=e}setSpace(e){this.space=e}}function NE(r){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:r.button};{const e=this.domElement.getBoundingClientRect();return{x:(r.clientX-e.left)/e.width*2-1,y:-(r.clientY-e.top)/e.height*2+1,button:r.button}}}function DE(r){if(this.enabled)switch(r.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(r));break}}function LE(r){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(r.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(r)),this.pointerDown(this._getPointer(r)))}function IE(r){this.enabled&&this.pointerMove(this._getPointer(r))}function kE(r){this.enabled&&(this.domElement.releasePointerCapture(r.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(r)))}function Gd(r,e,t){const n=e.intersectObject(r,!0);for(let i=0;i<n.length;i++)if(n[i].object.visible||t)return n[i];return!1}const Fl=new hn,Zt=new I(0,1,0),mm=new I(0,0,0),gm=new Ie,Ul=new Lt,pc=new Lt,Qi=new I,bm=new Ie,oo=new I(1,0,0),fr=new I(0,1,0),lo=new I(0,0,1),Bl=new I,Ka=new I,$a=new I;class OE extends Pt{constructor(e){super(),this.isTransformControlsRoot=!0,this.controls=e,this.visible=!1}updateMatrixWorld(e){const t=this.controls;t.object!==void 0&&(t.object.updateMatrixWorld(),t.object.parent===null?console.error("TransformControls: The attached 3D object must be a part of the scene graph."):t.object.parent.matrixWorld.decompose(t._parentPosition,t._parentQuaternion,t._parentScale),t.object.matrixWorld.decompose(t.worldPosition,t.worldQuaternion,t._worldScale),t._parentQuaternionInv.copy(t._parentQuaternion).invert(),t._worldQuaternionInv.copy(t.worldQuaternion).invert()),t.camera.updateMatrixWorld(),t.camera.matrixWorld.decompose(t.cameraPosition,t.cameraQuaternion,t._cameraScale),t.camera.isOrthographicCamera?t.camera.getWorldDirection(t.eye).negate():t.eye.copy(t.cameraPosition).sub(t.worldPosition).normalize(),super.updateMatrixWorld(e)}dispose(){this.traverse(function(e){e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose()})}}class FE extends Pt{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const e=new jt({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),t=new zn({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),n=e.clone();n.opacity=.15;const i=t.clone();i.opacity=.5;const s=e.clone();s.color.setHex(16711680);const a=e.clone();a.color.setHex(65280);const o=e.clone();o.color.setHex(255);const l=e.clone();l.color.setHex(16711680),l.opacity=.5;const c=e.clone();c.color.setHex(65280),c.opacity=.5;const d=e.clone();d.color.setHex(255),d.opacity=.5;const h=e.clone();h.opacity=.25;const u=e.clone();u.color.setHex(16776960),u.opacity=.25,e.clone().color.setHex(16776960);const m=e.clone();m.color.setHex(7895160);const b=new Pn(0,.04,.1,12);b.translate(0,.05,0);const p=new Jt(.08,.08,.08);p.translate(0,.04,0);const g=new ht;g.setAttribute("position",new ke([0,0,0,1,0,0],3));const y=new Pn(.0075,.0075,.5,3);y.translate(0,.25,0);function x(q,G){const K=new gr(q,.0075,3,64,G*Math.PI*2);return K.rotateY(Math.PI/2),K.rotateX(Math.PI/2),K}function w(){const q=new ht;return q.setAttribute("position",new ke([0,0,0,1,1,1],3)),q}const P={X:[[new Ee(b,s),[.5,0,0],[0,0,-Math.PI/2]],[new Ee(b,s),[-.5,0,0],[0,0,Math.PI/2]],[new Ee(y,s),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new Ee(b,a),[0,.5,0]],[new Ee(b,a),[0,-.5,0],[Math.PI,0,0]],[new Ee(y,a)]],Z:[[new Ee(b,o),[0,0,.5],[Math.PI/2,0,0]],[new Ee(b,o),[0,0,-.5],[-Math.PI/2,0,0]],[new Ee(y,o),null,[Math.PI/2,0,0]]],XYZ:[[new Ee(new aa(.1,0),h.clone()),[0,0,0]]],XY:[[new Ee(new Jt(.15,.15,.01),d.clone()),[.15,.15,0]]],YZ:[[new Ee(new Jt(.15,.15,.01),l.clone()),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new Ee(new Jt(.15,.15,.01),c.clone()),[.15,0,.15],[-Math.PI/2,0,0]]]},T={X:[[new Ee(new Pn(.2,0,.6,4),n),[.3,0,0],[0,0,-Math.PI/2]],[new Ee(new Pn(.2,0,.6,4),n),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new Ee(new Pn(.2,0,.6,4),n),[0,.3,0]],[new Ee(new Pn(.2,0,.6,4),n),[0,-.3,0],[0,0,Math.PI]]],Z:[[new Ee(new Pn(.2,0,.6,4),n),[0,0,.3],[Math.PI/2,0,0]],[new Ee(new Pn(.2,0,.6,4),n),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new Ee(new aa(.2,0),n)]],XY:[[new Ee(new Jt(.2,.2,.01),n),[.15,.15,0]]],YZ:[[new Ee(new Jt(.2,.2,.01),n),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new Ee(new Jt(.2,.2,.01),n),[.15,0,.15],[-Math.PI/2,0,0]]]},A={START:[[new Ee(new aa(.01,2),i),null,null,null,"helper"]],END:[[new Ee(new aa(.01,2),i),null,null,null,"helper"]],DELTA:[[new qn(w(),i),null,null,null,"helper"]],X:[[new qn(g,i.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new qn(g,i.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new qn(g,i.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},M={XYZE:[[new Ee(x(.5,1),m),null,[0,Math.PI/2,0]]],X:[[new Ee(x(.5,.5),s)]],Y:[[new Ee(x(.5,.5),a),null,[0,0,-Math.PI/2]]],Z:[[new Ee(x(.5,.5),o),null,[0,Math.PI/2,0]]],E:[[new Ee(x(.75,1),u),null,[0,Math.PI/2,0]]]},_={AXIS:[[new qn(g,i.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},S={XYZE:[[new Ee(new Pa(.25,10,8),n)]],X:[[new Ee(new gr(.5,.1,4,24),n),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new Ee(new gr(.5,.1,4,24),n),[0,0,0],[Math.PI/2,0,0]]],Z:[[new Ee(new gr(.5,.1,4,24),n),[0,0,0],[0,0,-Math.PI/2]]],E:[[new Ee(new gr(.75,.1,2,24),n)]]},R={X:[[new Ee(p,s),[.5,0,0],[0,0,-Math.PI/2]],[new Ee(y,s),[0,0,0],[0,0,-Math.PI/2]],[new Ee(p,s),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new Ee(p,a),[0,.5,0]],[new Ee(y,a)],[new Ee(p,a),[0,-.5,0],[0,0,Math.PI]]],Z:[[new Ee(p,o),[0,0,.5],[Math.PI/2,0,0]],[new Ee(y,o),[0,0,0],[Math.PI/2,0,0]],[new Ee(p,o),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new Ee(new Jt(.15,.15,.01),d),[.15,.15,0]]],YZ:[[new Ee(new Jt(.15,.15,.01),l),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new Ee(new Jt(.15,.15,.01),c),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new Ee(new Jt(.1,.1,.1),h.clone())]]},k={X:[[new Ee(new Pn(.2,0,.6,4),n),[.3,0,0],[0,0,-Math.PI/2]],[new Ee(new Pn(.2,0,.6,4),n),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new Ee(new Pn(.2,0,.6,4),n),[0,.3,0]],[new Ee(new Pn(.2,0,.6,4),n),[0,-.3,0],[0,0,Math.PI]]],Z:[[new Ee(new Pn(.2,0,.6,4),n),[0,0,.3],[Math.PI/2,0,0]],[new Ee(new Pn(.2,0,.6,4),n),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new Ee(new Jt(.2,.2,.01),n),[.15,.15,0]]],YZ:[[new Ee(new Jt(.2,.2,.01),n),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new Ee(new Jt(.2,.2,.01),n),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new Ee(new Jt(.2,.2,.2),n),[0,0,0]]]},O={X:[[new qn(g,i.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new qn(g,i.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new qn(g,i.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function H(q){const G=new Pt;for(const K in q)for(let V=q[K].length;V--;){const Y=q[K][V][0].clone(),le=q[K][V][1],se=q[K][V][2],ge=q[K][V][3],de=q[K][V][4];Y.name=K,Y.tag=de,le&&Y.position.set(le[0],le[1],le[2]),se&&Y.rotation.set(se[0],se[1],se[2]),ge&&Y.scale.set(ge[0],ge[1],ge[2]),Y.updateMatrix();const X=Y.geometry.clone();X.applyMatrix4(Y.matrix),Y.geometry=X,Y.renderOrder=1/0,Y.position.set(0,0,0),Y.rotation.set(0,0,0),Y.scale.set(1,1,1),G.add(Y)}return G}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=H(P)),this.add(this.gizmo.rotate=H(M)),this.add(this.gizmo.scale=H(R)),this.add(this.picker.translate=H(T)),this.add(this.picker.rotate=H(S)),this.add(this.picker.scale=H(k)),this.add(this.helper.translate=H(A)),this.add(this.helper.rotate=H(_)),this.add(this.helper.scale=H(O)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(e){const n=(this.mode==="scale"?"local":this.space)==="local"?this.worldQuaternion:pc;this.gizmo.translate.visible=this.mode==="translate",this.gizmo.rotate.visible=this.mode==="rotate",this.gizmo.scale.visible=this.mode==="scale",this.helper.translate.visible=this.mode==="translate",this.helper.rotate.visible=this.mode==="rotate",this.helper.scale.visible=this.mode==="scale";let i=[];i=i.concat(this.picker[this.mode].children),i=i.concat(this.gizmo[this.mode].children),i=i.concat(this.helper[this.mode].children);for(let s=0;s<i.length;s++){const a=i[s];a.visible=!0,a.rotation.set(0,0,0),a.position.copy(this.worldPosition);let o;if(this.camera.isOrthographicCamera?o=(this.camera.top-this.camera.bottom)/this.camera.zoom:o=this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),a.scale.set(1,1,1).multiplyScalar(o*this.size/4),a.tag==="helper"){a.visible=!1,a.name==="AXIS"?(a.visible=!!this.axis,this.axis==="X"&&(sn.setFromEuler(Fl.set(0,0,0)),a.quaternion.copy(n).multiply(sn),Math.abs(Zt.copy(oo).applyQuaternion(n).dot(this.eye))>.9&&(a.visible=!1)),this.axis==="Y"&&(sn.setFromEuler(Fl.set(0,0,Math.PI/2)),a.quaternion.copy(n).multiply(sn),Math.abs(Zt.copy(fr).applyQuaternion(n).dot(this.eye))>.9&&(a.visible=!1)),this.axis==="Z"&&(sn.setFromEuler(Fl.set(0,Math.PI/2,0)),a.quaternion.copy(n).multiply(sn),Math.abs(Zt.copy(lo).applyQuaternion(n).dot(this.eye))>.9&&(a.visible=!1)),this.axis==="XYZE"&&(sn.setFromEuler(Fl.set(0,Math.PI/2,0)),Zt.copy(this.rotationAxis),a.quaternion.setFromRotationMatrix(gm.lookAt(mm,Zt,fr)),a.quaternion.multiply(sn),a.visible=this.dragging),this.axis==="E"&&(a.visible=!1)):a.name==="START"?(a.position.copy(this.worldPositionStart),a.visible=this.dragging):a.name==="END"?(a.position.copy(this.worldPosition),a.visible=this.dragging):a.name==="DELTA"?(a.position.copy(this.worldPositionStart),a.quaternion.copy(this.worldQuaternionStart),Xn.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),Xn.applyQuaternion(this.worldQuaternionStart.clone().invert()),a.scale.copy(Xn),a.visible=this.dragging):(a.quaternion.copy(n),this.dragging?a.position.copy(this.worldPositionStart):a.position.copy(this.worldPosition),this.axis&&(a.visible=this.axis.search(a.name)!==-1));continue}a.quaternion.copy(n),this.mode==="translate"||this.mode==="scale"?(a.name==="X"&&Math.abs(Zt.copy(oo).applyQuaternion(n).dot(this.eye))>.99&&(a.scale.set(1e-10,1e-10,1e-10),a.visible=!1),a.name==="Y"&&Math.abs(Zt.copy(fr).applyQuaternion(n).dot(this.eye))>.99&&(a.scale.set(1e-10,1e-10,1e-10),a.visible=!1),a.name==="Z"&&Math.abs(Zt.copy(lo).applyQuaternion(n).dot(this.eye))>.99&&(a.scale.set(1e-10,1e-10,1e-10),a.visible=!1),a.name==="XY"&&Math.abs(Zt.copy(lo).applyQuaternion(n).dot(this.eye))<.2&&(a.scale.set(1e-10,1e-10,1e-10),a.visible=!1),a.name==="YZ"&&Math.abs(Zt.copy(oo).applyQuaternion(n).dot(this.eye))<.2&&(a.scale.set(1e-10,1e-10,1e-10),a.visible=!1),a.name==="XZ"&&Math.abs(Zt.copy(fr).applyQuaternion(n).dot(this.eye))<.2&&(a.scale.set(1e-10,1e-10,1e-10),a.visible=!1)):this.mode==="rotate"&&(Ul.copy(n),Zt.copy(this.eye).applyQuaternion(sn.copy(n).invert()),a.name.search("E")!==-1&&a.quaternion.setFromRotationMatrix(gm.lookAt(this.eye,mm,fr)),a.name==="X"&&(sn.setFromAxisAngle(oo,Math.atan2(-Zt.y,Zt.z)),sn.multiplyQuaternions(Ul,sn),a.quaternion.copy(sn)),a.name==="Y"&&(sn.setFromAxisAngle(fr,Math.atan2(Zt.x,Zt.z)),sn.multiplyQuaternions(Ul,sn),a.quaternion.copy(sn)),a.name==="Z"&&(sn.setFromAxisAngle(lo,Math.atan2(Zt.y,Zt.x)),sn.multiplyQuaternions(Ul,sn),a.quaternion.copy(sn))),a.visible=a.visible&&(a.name.indexOf("X")===-1||this.showX),a.visible=a.visible&&(a.name.indexOf("Y")===-1||this.showY),a.visible=a.visible&&(a.name.indexOf("Z")===-1||this.showZ),a.visible=a.visible&&(a.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),a.material._color=a.material._color||a.material.color.clone(),a.material._opacity=a.material._opacity||a.material.opacity,a.material.color.copy(a.material._color),a.material.opacity=a.material._opacity,this.enabled&&this.axis&&(a.name===this.axis||this.axis.split("").some(function(l){return a.name===l}))&&(a.material.color.setHex(16776960),a.material.opacity=1)}super.updateMatrixWorld(e)}}class UE extends Ee{constructor(){super(new $s(1e5,1e5,2,2),new jt({visible:!1,wireframe:!0,side:ln,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(e){let t=this.space;switch(this.position.copy(this.worldPosition),this.mode==="scale"&&(t="local"),Bl.copy(oo).applyQuaternion(t==="local"?this.worldQuaternion:pc),Ka.copy(fr).applyQuaternion(t==="local"?this.worldQuaternion:pc),$a.copy(lo).applyQuaternion(t==="local"?this.worldQuaternion:pc),Zt.copy(Ka),this.mode){case"translate":case"scale":switch(this.axis){case"X":Zt.copy(this.eye).cross(Bl),Qi.copy(Bl).cross(Zt);break;case"Y":Zt.copy(this.eye).cross(Ka),Qi.copy(Ka).cross(Zt);break;case"Z":Zt.copy(this.eye).cross($a),Qi.copy($a).cross(Zt);break;case"XY":Qi.copy($a);break;case"YZ":Qi.copy(Bl);break;case"XZ":Zt.copy($a),Qi.copy(Ka);break;case"XYZ":case"E":Qi.set(0,0,0);break}break;case"rotate":default:Qi.set(0,0,0)}Qi.length()===0?this.quaternion.copy(this.cameraQuaternion):(bm.lookAt(Xn.set(0,0,0),Qi,Zt),this.quaternion.setFromRotationMatrix(bm)),super.updateMatrixWorld(e)}}class Hs extends Pt{constructor(e=document.createElement("div")){super(),this.isCSS2DObject=!0,this.element=e,this.element.style.position="absolute",this.element.style.userSelect="none",this.element.setAttribute("draggable",!1),this.center=new me(.5,.5),this.addEventListener("removed",function(){this.traverse(function(t){t.element instanceof t.element.ownerDocument.defaultView.Element&&t.element.parentNode!==null&&t.element.remove()})})}copy(e,t){return super.copy(e,t),this.element=e.element.cloneNode(!0),this.center=e.center,this}}const $r=new I,vm=new Ie,ym=new Ie,xm=new I,_m=new I;class BE{constructor(e={}){const t=this;let n,i,s,a;const o={objects:new WeakMap},l=e.element!==void 0?e.element:document.createElement("div");l.style.overflow="hidden",this.domElement=l,this.getSize=function(){return{width:n,height:i}},this.render=function(m,b){m.matrixWorldAutoUpdate===!0&&m.updateMatrixWorld(),b.parent===null&&b.matrixWorldAutoUpdate===!0&&b.updateMatrixWorld(),vm.copy(b.matrixWorldInverse),ym.multiplyMatrices(b.projectionMatrix,vm),d(m,m,b),f(m)},this.setSize=function(m,b){n=m,i=b,s=n/2,a=i/2,l.style.width=m+"px",l.style.height=b+"px"};function c(m){m.isCSS2DObject&&(m.element.style.display="none");for(let b=0,p=m.children.length;b<p;b++)c(m.children[b])}function d(m,b,p){if(m.visible===!1){c(m);return}if(m.isCSS2DObject){$r.setFromMatrixPosition(m.matrixWorld),$r.applyMatrix4(ym);const g=$r.z>=-1&&$r.z<=1&&m.layers.test(p.layers)===!0,y=m.element;y.style.display=g===!0?"":"none",g===!0&&(m.onBeforeRender(t,b,p),y.style.transform="translate("+-100*m.center.x+"%,"+-100*m.center.y+"%)translate("+($r.x*s+s)+"px,"+(-$r.y*a+a)+"px)",y.parentNode!==l&&l.appendChild(y),m.onAfterRender(t,b,p));const x={distanceToCameraSquared:h(p,m)};o.objects.set(m,x)}for(let g=0,y=m.children.length;g<y;g++)d(m.children[g],b,p)}function h(m,b){return xm.setFromMatrixPosition(m.matrixWorld),_m.setFromMatrixPosition(b.matrixWorld),xm.distanceToSquared(_m)}function u(m){const b=[];return m.traverseVisible(function(p){p.isCSS2DObject&&b.push(p)}),b}function f(m){const b=u(m).sort(function(g,y){if(g.renderOrder!==y.renderOrder)return y.renderOrder-g.renderOrder;const x=o.objects.get(g).distanceToCameraSquared,w=o.objects.get(y).distanceToCameraSquared;return x-w}),p=b.length;for(let g=0,y=b.length;g<y;g++)b[g].element.style.zIndex=p-g}}}class Qb extends pi{constructor(e){super(e)}load(e,t,n,i){const s=this,a=new Ys(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(o){try{t(s.parse(o))}catch(l){i?i(l):console.error(l),s.manager.itemError(e)}},n,i)}parse(e){function t(c){const d=new DataView(c),h=32/8*3+32/8*3*3+16/8,u=d.getUint32(80,!0);if(80+32/8+u*h===d.byteLength)return!0;const m=[115,111,108,105,100];for(let b=0;b<5;b++)if(n(m,d,b))return!1;return!0}function n(c,d,h){for(let u=0,f=c.length;u<f;u++)if(c[u]!==d.getUint8(h+u))return!1;return!0}function i(c){const d=new DataView(c),h=d.getUint32(80,!0);let u,f,m,b=!1,p,g,y,x,w;for(let R=0;R<70;R++)d.getUint32(R,!1)==1129270351&&d.getUint8(R+4)==82&&d.getUint8(R+5)==61&&(b=!0,p=new Float32Array(h*3*3),g=d.getUint8(R+6)/255,y=d.getUint8(R+7)/255,x=d.getUint8(R+8)/255,w=d.getUint8(R+9)/255);const P=84,T=50,A=new ht,M=new Float32Array(h*3*3),_=new Float32Array(h*3*3),S=new Ne;for(let R=0;R<h;R++){const k=P+R*T,O=d.getFloat32(k,!0),H=d.getFloat32(k+4,!0),q=d.getFloat32(k+8,!0);if(b){const G=d.getUint16(k+48,!0);(G&32768)===0?(u=(G&31)/31,f=(G>>5&31)/31,m=(G>>10&31)/31):(u=g,f=y,m=x)}for(let G=1;G<=3;G++){const K=k+G*12,V=R*3*3+(G-1)*3;M[V]=d.getFloat32(K,!0),M[V+1]=d.getFloat32(K+4,!0),M[V+2]=d.getFloat32(K+8,!0),_[V]=O,_[V+1]=H,_[V+2]=q,b&&(S.setRGB(u,f,m,gt),p[V]=S.r,p[V+1]=S.g,p[V+2]=S.b)}}return A.setAttribute("position",new rn(M,3)),A.setAttribute("normal",new rn(_,3)),b&&(A.setAttribute("color",new rn(p,3)),A.hasColors=!0,A.alpha=w),A}function s(c){const d=new ht,h=/solid([\s\S]*?)endsolid/g,u=/facet([\s\S]*?)endfacet/g,f=/solid\s(.+)/;let m=0;const b=/[\s]+([+-]?(?:\d*)(?:\.\d*)?(?:[eE][+-]?\d+)?)/.source,p=new RegExp("vertex"+b+b+b,"g"),g=new RegExp("normal"+b+b+b,"g"),y=[],x=[],w=[],P=new I;let T,A=0,M=0,_=0;for(;(T=h.exec(c))!==null;){M=_;const S=T[0],R=(T=f.exec(S))!==null?T[1]:"";for(w.push(R);(T=u.exec(S))!==null;){let H=0,q=0;const G=T[0];for(;(T=g.exec(G))!==null;)P.x=parseFloat(T[1]),P.y=parseFloat(T[2]),P.z=parseFloat(T[3]),q++;for(;(T=p.exec(G))!==null;)y.push(parseFloat(T[1]),parseFloat(T[2]),parseFloat(T[3])),x.push(P.x,P.y,P.z),H++,_++;q!==1&&console.error("THREE.STLLoader: Something isn't right with the normal of face number "+m),H!==3&&console.error("THREE.STLLoader: Something isn't right with the vertices of face number "+m),m++}const k=M,O=_-M;d.userData.groupNames=w,d.addGroup(k,O,A),A++}return d.setAttribute("position",new ke(y,3)),d.setAttribute("normal",new ke(x,3)),d}function a(c){return typeof c!="string"?new TextDecoder().decode(c):c}function o(c){if(typeof c=="string"){const d=new Uint8Array(c.length);for(let h=0;h<c.length;h++)d[h]=c.charCodeAt(h)&255;return d.buffer||d}else return c}const l=o(e);return t(l)?i(l):s(a(e))}}class wm extends T_{constructor(e){super(e)}parse(e){function t(G){switch(G.image_type){case u:case b:if(G.colormap_length>256||G.colormap_size!==24||G.colormap_type!==1)throw new Error("THREE.TGALoader: Invalid type colormap data for indexed type.");break;case f:case m:case p:case g:if(G.colormap_type)throw new Error("THREE.TGALoader: Invalid type colormap data for colormap type.");break;case h:throw new Error("THREE.TGALoader: No data.");default:throw new Error("THREE.TGALoader: Invalid type "+G.image_type)}if(G.width<=0||G.height<=0)throw new Error("THREE.TGALoader: Invalid image size.");if(G.pixel_size!==8&&G.pixel_size!==16&&G.pixel_size!==24&&G.pixel_size!==32)throw new Error("THREE.TGALoader: Invalid pixel size "+G.pixel_size)}function n(G,K,V,Y,le){let se,ge;const de=V.pixel_size>>3,X=V.width*V.height*de;if(K&&(ge=le.subarray(Y,Y+=V.colormap_length*(V.colormap_size>>3))),G){se=new Uint8Array(X);let ee,ie,Z,ue=0;const oe=new Uint8Array(de);for(;ue<X;)if(ee=le[Y++],ie=(ee&127)+1,ee&128){for(Z=0;Z<de;++Z)oe[Z]=le[Y++];for(Z=0;Z<ie;++Z)se.set(oe,ue+Z*de);ue+=de*ie}else{for(ie*=de,Z=0;Z<ie;++Z)se[ue+Z]=le[Y++];ue+=ie}}else se=le.subarray(Y,Y+=K?V.width*V.height:X);return{pixel_data:se,palettes:ge}}function i(G,K,V,Y,le,se,ge,de,X){const ee=X;let ie,Z=0,ue,oe;const be=S.width;for(oe=K;oe!==Y;oe+=V)for(ue=le;ue!==ge;ue+=se,Z++)ie=de[Z],G[(ue+be*oe)*4+3]=255,G[(ue+be*oe)*4+2]=ee[ie*3+0],G[(ue+be*oe)*4+1]=ee[ie*3+1],G[(ue+be*oe)*4+0]=ee[ie*3+2];return G}function s(G,K,V,Y,le,se,ge,de){let X,ee=0,ie,Z;const ue=S.width;for(Z=K;Z!==Y;Z+=V)for(ie=le;ie!==ge;ie+=se,ee+=2)X=de[ee+0]+(de[ee+1]<<8),G[(ie+ue*Z)*4+0]=(X&31744)>>7,G[(ie+ue*Z)*4+1]=(X&992)>>2,G[(ie+ue*Z)*4+2]=(X&31)<<3,G[(ie+ue*Z)*4+3]=X&32768?0:255;return G}function a(G,K,V,Y,le,se,ge,de){let X=0,ee,ie;const Z=S.width;for(ie=K;ie!==Y;ie+=V)for(ee=le;ee!==ge;ee+=se,X+=3)G[(ee+Z*ie)*4+3]=255,G[(ee+Z*ie)*4+2]=de[X+0],G[(ee+Z*ie)*4+1]=de[X+1],G[(ee+Z*ie)*4+0]=de[X+2];return G}function o(G,K,V,Y,le,se,ge,de){let X=0,ee,ie;const Z=S.width;for(ie=K;ie!==Y;ie+=V)for(ee=le;ee!==ge;ee+=se,X+=4)G[(ee+Z*ie)*4+2]=de[X+0],G[(ee+Z*ie)*4+1]=de[X+1],G[(ee+Z*ie)*4+0]=de[X+2],G[(ee+Z*ie)*4+3]=de[X+3];return G}function l(G,K,V,Y,le,se,ge,de){let X,ee=0,ie,Z;const ue=S.width;for(Z=K;Z!==Y;Z+=V)for(ie=le;ie!==ge;ie+=se,ee++)X=de[ee],G[(ie+ue*Z)*4+0]=X,G[(ie+ue*Z)*4+1]=X,G[(ie+ue*Z)*4+2]=X,G[(ie+ue*Z)*4+3]=255;return G}function c(G,K,V,Y,le,se,ge,de){let X=0,ee,ie;const Z=S.width;for(ie=K;ie!==Y;ie+=V)for(ee=le;ee!==ge;ee+=se,X+=2)G[(ee+Z*ie)*4+0]=de[X+0],G[(ee+Z*ie)*4+1]=de[X+0],G[(ee+Z*ie)*4+2]=de[X+0],G[(ee+Z*ie)*4+3]=de[X+1];return G}function d(G,K,V,Y,le){let se,ge,de,X,ee,ie;switch((S.flags&y)>>x){default:case T:se=0,de=1,ee=K,ge=0,X=1,ie=V;break;case w:se=0,de=1,ee=K,ge=V-1,X=-1,ie=-1;break;case A:se=K-1,de=-1,ee=-1,ge=0,X=1,ie=V;break;case P:se=K-1,de=-1,ee=-1,ge=V-1,X=-1,ie=-1;break}if(O)switch(S.pixel_size){case 8:l(G,ge,X,ie,se,de,ee,Y);break;case 16:c(G,ge,X,ie,se,de,ee,Y);break;default:throw new Error("THREE.TGALoader: Format not supported.")}else switch(S.pixel_size){case 8:i(G,ge,X,ie,se,de,ee,Y,le);break;case 16:s(G,ge,X,ie,se,de,ee,Y);break;case 24:a(G,ge,X,ie,se,de,ee,Y);break;case 32:o(G,ge,X,ie,se,de,ee,Y);break;default:throw new Error("THREE.TGALoader: Format not supported.")}return G}const h=0,u=1,f=2,m=3,b=9,p=10,g=11,y=48,x=4,w=0,P=1,T=2,A=3;if(e.length<19)throw new Error("THREE.TGALoader: Not enough data to contain header.");let M=0;const _=new Uint8Array(e),S={id_length:_[M++],colormap_type:_[M++],image_type:_[M++],colormap_index:_[M++]|_[M++]<<8,colormap_length:_[M++]|_[M++]<<8,colormap_size:_[M++],origin:[_[M++]|_[M++]<<8,_[M++]|_[M++]<<8],width:_[M++]|_[M++]<<8,height:_[M++]|_[M++]<<8,pixel_size:_[M++],flags:_[M++]};if(t(S),S.id_length+M>e.length)throw new Error("THREE.TGALoader: No data.");M+=S.id_length;let R=!1,k=!1,O=!1;switch(S.image_type){case b:R=!0,k=!0;break;case u:k=!0;break;case p:R=!0;break;case f:break;case g:R=!0,O=!0;break;case m:O=!0;break}const H=new Uint8Array(S.width*S.height*4),q=n(R,k,S,M,_);return d(H,S.width,S.height,q.pixel_data,q.palettes),{data:H,width:S.width,height:S.height,flipY:!0,generateMipmaps:!0,minFilter:ji}}}class Jb extends pi{load(e,t,n,i){const s=this,a=s.path===""?qs.extractUrlBase(e):s.path,o=new Ys(s.manager);o.setPath(s.path),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(e,function(l){try{t(s.parse(l,a))}catch(c){i?i(c):console.error(c),s.manager.itemError(e)}},n,i)}parse(e,t){function n(L,D){const B=[],F=L.childNodes;for(let z=0,pe=F.length;z<pe;z++){const _e=F[z];_e.nodeName===D&&B.push(_e)}return B}function i(L){if(L.length===0)return[];const D=L.trim().split(/\s+/),B=new Array(D.length);for(let F=0,z=D.length;F<z;F++)B[F]=D[F];return B}function s(L){if(L.length===0)return[];const D=L.trim().split(/\s+/),B=new Array(D.length);for(let F=0,z=D.length;F<z;F++)B[F]=parseFloat(D[F]);return B}function a(L){if(L.length===0)return[];const D=L.trim().split(/\s+/),B=new Array(D.length);for(let F=0,z=D.length;F<z;F++)B[F]=parseInt(D[F]);return B}function o(L){return L.substring(1)}function l(){return"three_default_"+ls++}function c(L){return Object.keys(L).length===0}function d(L){return{unit:h(n(L,"unit")[0]),upAxis:u(n(L,"up_axis")[0])}}function h(L){return L!==void 0&&L.hasAttribute("meter")===!0?parseFloat(L.getAttribute("meter")):1}function u(L){return L!==void 0?L.textContent:"Y_UP"}function f(L,D,B,F){const z=n(L,D)[0];if(z!==void 0){const pe=n(z,B);for(let _e=0;_e<pe.length;_e++)F(pe[_e])}}function m(L,D){for(const B in L){const F=L[B];F.build=D(L[B])}}function b(L,D){return L.build!==void 0||(L.build=D(L)),L.build}function p(L){const D={sources:{},samplers:{},channels:{}};let B=!1;for(let F=0,z=L.childNodes.length;F<z;F++){const pe=L.childNodes[F];if(pe.nodeType!==1)continue;let _e;switch(pe.nodeName){case"source":_e=pe.getAttribute("id"),D.sources[_e]=ye(pe);break;case"sampler":_e=pe.getAttribute("id"),D.samplers[_e]=g(pe);break;case"channel":_e=pe.getAttribute("target"),D.channels[_e]=y(pe);break;case"animation":p(pe),B=!0;break;default:console.log(pe)}}B===!1&&(ut.animations[L.getAttribute("id")||bt.generateUUID()]=D)}function g(L){const D={inputs:{}};for(let B=0,F=L.childNodes.length;B<F;B++){const z=L.childNodes[B];if(z.nodeType===1)switch(z.nodeName){case"input":const pe=o(z.getAttribute("source")),_e=z.getAttribute("semantic");D.inputs[_e]=pe;break}}return D}function y(L){const D={};let F=L.getAttribute("target").split("/");const z=F.shift();let pe=F.shift();const _e=pe.indexOf("(")!==-1,Qe=pe.indexOf(".")!==-1;if(Qe)F=pe.split("."),pe=F.shift(),D.member=F.shift();else if(_e){const ze=pe.split("(");pe=ze.shift();for(let qe=0;qe<ze.length;qe++)ze[qe]=parseInt(ze[qe].replace(/\)/,""));D.indices=ze}return D.id=z,D.sid=pe,D.arraySyntax=_e,D.memberSyntax=Qe,D.sampler=o(L.getAttribute("source")),D}function x(L){const D=[],B=L.channels,F=L.samplers,z=L.sources;for(const pe in B)if(B.hasOwnProperty(pe)){const _e=B[pe],Qe=F[_e.sampler],ze=Qe.inputs.INPUT,qe=Qe.inputs.OUTPUT,st=z[ze],Ae=z[qe],it=P(_e,st,Ae);S(it,D)}return D}function w(L){return b(ut.animations[L],x)}function P(L,D,B){const F=ut.nodes[L.id],z=St(F.id),pe=F.transforms[L.sid],_e=F.matrix.clone().transpose();let Qe,ze,qe,st,Ae,it;const tt={};switch(pe){case"matrix":for(qe=0,st=D.array.length;qe<st;qe++)if(Qe=D.array[qe],ze=qe*B.stride,tt[Qe]===void 0&&(tt[Qe]={}),L.arraySyntax===!0){const on=B.array[ze],Bt=L.indices[0]+4*L.indices[1];tt[Qe][Bt]=on}else for(Ae=0,it=B.stride;Ae<it;Ae++)tt[Qe][Ae]=B.array[ze+Ae];break;case"translate":console.warn('THREE.ColladaLoader: Animation transform type "%s" not yet implemented.',pe);break;case"rotate":console.warn('THREE.ColladaLoader: Animation transform type "%s" not yet implemented.',pe);break;case"scale":console.warn('THREE.ColladaLoader: Animation transform type "%s" not yet implemented.',pe);break}const dt=T(tt,_e);return{name:z.uuid,keyframes:dt}}function T(L,D){const B=[];for(const z in L)B.push({time:parseFloat(z),value:L[z]});B.sort(F);for(let z=0;z<16;z++)R(B,z,D.elements[z]);return B;function F(z,pe){return z.time-pe.time}}const A=new I,M=new I,_=new Lt;function S(L,D){const B=L.keyframes,F=L.name,z=[],pe=[],_e=[],Qe=[];for(let ze=0,qe=B.length;ze<qe;ze++){const st=B[ze],Ae=st.time,it=st.value;J.fromArray(it).transpose(),J.decompose(A,_,M),z.push(Ae),pe.push(A.x,A.y,A.z),_e.push(_.x,_.y,_.z,_.w),Qe.push(M.x,M.y,M.z)}return pe.length>0&&D.push(new Es(F+".position",z,pe)),_e.length>0&&D.push(new Ts(F+".quaternion",z,_e)),Qe.length>0&&D.push(new Es(F+".scale",z,Qe)),D}function R(L,D,B){let F,z=!0,pe,_e;for(pe=0,_e=L.length;pe<_e;pe++)F=L[pe],F.value[D]===void 0?F.value[D]=null:z=!1;if(z===!0)for(pe=0,_e=L.length;pe<_e;pe++)F=L[pe],F.value[D]=B;else k(L,D)}function k(L,D){let B,F;for(let z=0,pe=L.length;z<pe;z++){const _e=L[z];if(_e.value[D]===null){if(B=O(L,z,D),F=H(L,z,D),B===null){_e.value[D]=F.value[D];continue}if(F===null){_e.value[D]=B.value[D];continue}q(_e,B,F,D)}}}function O(L,D,B){for(;D>=0;){const F=L[D];if(F.value[B]!==null)return F;D--}return null}function H(L,D,B){for(;D<L.length;){const F=L[D];if(F.value[B]!==null)return F;D++}return null}function q(L,D,B,F){if(B.time-D.time===0){L.value[F]=D.value[F];return}L.value[F]=(L.time-D.time)*(B.value[F]-D.value[F])/(B.time-D.time)+D.value[F]}function G(L){const D={name:L.getAttribute("id")||"default",start:parseFloat(L.getAttribute("start")||0),end:parseFloat(L.getAttribute("end")||0),animations:[]};for(let B=0,F=L.childNodes.length;B<F;B++){const z=L.childNodes[B];if(z.nodeType===1)switch(z.nodeName){case"instance_animation":D.animations.push(o(z.getAttribute("url")));break}}ut.clips[L.getAttribute("id")]=D}function K(L){const D=[],B=L.name,F=L.end-L.start||-1,z=L.animations;for(let pe=0,_e=z.length;pe<_e;pe++){const Qe=w(z[pe]);for(let ze=0,qe=Qe.length;ze<qe;ze++)D.push(Qe[ze])}return new Mc(B,F,D)}function V(L){return b(ut.clips[L],K)}function Y(L){const D={};for(let B=0,F=L.childNodes.length;B<F;B++){const z=L.childNodes[B];if(z.nodeType===1)switch(z.nodeName){case"skin":D.id=o(z.getAttribute("source")),D.skin=le(z);break;case"morph":D.id=o(z.getAttribute("source")),console.warn("THREE.ColladaLoader: Morph target animation not supported yet.");break}}ut.controllers[L.getAttribute("id")]=D}function le(L){const D={sources:{}};for(let B=0,F=L.childNodes.length;B<F;B++){const z=L.childNodes[B];if(z.nodeType===1)switch(z.nodeName){case"bind_shape_matrix":D.bindShapeMatrix=s(z.textContent);break;case"source":const pe=z.getAttribute("id");D.sources[pe]=ye(z);break;case"joints":D.joints=se(z);break;case"vertex_weights":D.vertexWeights=ge(z);break}}return D}function se(L){const D={inputs:{}};for(let B=0,F=L.childNodes.length;B<F;B++){const z=L.childNodes[B];if(z.nodeType===1)switch(z.nodeName){case"input":const pe=z.getAttribute("semantic"),_e=o(z.getAttribute("source"));D.inputs[pe]=_e;break}}return D}function ge(L){const D={inputs:{}};for(let B=0,F=L.childNodes.length;B<F;B++){const z=L.childNodes[B];if(z.nodeType===1)switch(z.nodeName){case"input":const pe=z.getAttribute("semantic"),_e=o(z.getAttribute("source")),Qe=parseInt(z.getAttribute("offset"));D.inputs[pe]={id:_e,offset:Qe};break;case"vcount":D.vcount=a(z.textContent);break;case"v":D.v=a(z.textContent);break}}return D}function de(L){const D={id:L.id},B=ut.geometries[D.id];return L.skin!==void 0&&(D.skin=X(L.skin),B.sources.skinIndices=D.skin.indices,B.sources.skinWeights=D.skin.weights),D}function X(L){const B={joints:[],indices:{array:[],stride:4},weights:{array:[],stride:4}},F=L.sources,z=L.vertexWeights,pe=z.vcount,_e=z.v,Qe=z.inputs.JOINT.offset,ze=z.inputs.WEIGHT.offset,qe=L.sources[L.joints.inputs.JOINT],st=L.sources[L.joints.inputs.INV_BIND_MATRIX],Ae=F[z.inputs.WEIGHT.id].array;let it=0,tt,dt,ot;for(tt=0,ot=pe.length;tt<ot;tt++){const Bt=pe[tt],Ot=[];for(dt=0;dt<Bt;dt++){const Ft=_e[it+Qe],cs=_e[it+ze],ai=Ae[cs];Ot.push({index:Ft,weight:ai}),it+=2}for(Ot.sort(on),dt=0;dt<4;dt++){const Ft=Ot[dt];Ft!==void 0?(B.indices.array.push(Ft.index),B.weights.array.push(Ft.weight)):(B.indices.array.push(0),B.weights.array.push(0))}}for(L.bindShapeMatrix?B.bindMatrix=new Ie().fromArray(L.bindShapeMatrix).transpose():B.bindMatrix=new Ie().identity(),tt=0,ot=qe.array.length;tt<ot;tt++){const Bt=qe.array[tt],Ot=new Ie().fromArray(st.array,tt*st.stride).transpose();B.joints.push({name:Bt,boneInverse:Ot})}return B;function on(Bt,Ot){return Ot.weight-Bt.weight}}function ee(L){return b(ut.controllers[L],de)}function ie(L){const D={init_from:n(L,"init_from")[0].textContent};ut.images[L.getAttribute("id")]=D}function Z(L){return L.build!==void 0?L.build:L.init_from}function ue(L){const D=ut.images[L];return D!==void 0?b(D,Z):(console.warn("THREE.ColladaLoader: Couldn't find image with ID:",L),null)}function oe(L){const D={};for(let B=0,F=L.childNodes.length;B<F;B++){const z=L.childNodes[B];if(z.nodeType===1)switch(z.nodeName){case"profile_COMMON":D.profile=be(z);break}}ut.effects[L.getAttribute("id")]=D}function be(L){const D={surfaces:{},samplers:{}};for(let B=0,F=L.childNodes.length;B<F;B++){const z=L.childNodes[B];if(z.nodeType===1)switch(z.nodeName){case"newparam":Ce(z,D);break;case"technique":D.technique=j(z);break;case"extra":D.extra=Be(z);break}}return D}function Ce(L,D){const B=L.getAttribute("sid");for(let F=0,z=L.childNodes.length;F<z;F++){const pe=L.childNodes[F];if(pe.nodeType===1)switch(pe.nodeName){case"surface":D.surfaces[B]=je(pe);break;case"sampler2D":D.samplers[B]=Fe(pe);break}}}function je(L){const D={};for(let B=0,F=L.childNodes.length;B<F;B++){const z=L.childNodes[B];if(z.nodeType===1)switch(z.nodeName){case"init_from":D.init_from=z.textContent;break}}return D}function Fe(L){const D={};for(let B=0,F=L.childNodes.length;B<F;B++){const z=L.childNodes[B];if(z.nodeType===1)switch(z.nodeName){case"source":D.source=z.textContent;break}}return D}function j(L){const D={};for(let B=0,F=L.childNodes.length;B<F;B++){const z=L.childNodes[B];if(z.nodeType===1)switch(z.nodeName){case"constant":case"lambert":case"blinn":case"phong":D.type=z.nodeName,D.parameters=Ke(z);break;case"extra":D.extra=Be(z);break}}return D}function Ke(L){const D={};for(let B=0,F=L.childNodes.length;B<F;B++){const z=L.childNodes[B];if(z.nodeType===1)switch(z.nodeName){case"emission":case"diffuse":case"specular":case"bump":case"ambient":case"shininess":case"transparency":D[z.nodeName]=Ue(z);break;case"transparent":D[z.nodeName]={opaque:z.hasAttribute("opaque")?z.getAttribute("opaque"):"A_ONE",data:Ue(z)};break}}return D}function Ue(L){const D={};for(let B=0,F=L.childNodes.length;B<F;B++){const z=L.childNodes[B];if(z.nodeType===1)switch(z.nodeName){case"color":D[z.nodeName]=s(z.textContent);break;case"float":D[z.nodeName]=parseFloat(z.textContent);break;case"texture":D[z.nodeName]={id:z.getAttribute("texture"),extra:Te(z)};break}}return D}function Te(L){const D={technique:{}};for(let B=0,F=L.childNodes.length;B<F;B++){const z=L.childNodes[B];if(z.nodeType===1)switch(z.nodeName){case"extra":Se(z,D);break}}return D}function Se(L,D){for(let B=0,F=L.childNodes.length;B<F;B++){const z=L.childNodes[B];if(z.nodeType===1)switch(z.nodeName){case"technique":et(z,D);break}}}function et(L,D){for(let B=0,F=L.childNodes.length;B<F;B++){const z=L.childNodes[B];if(z.nodeType===1)switch(z.nodeName){case"repeatU":case"repeatV":case"offsetU":case"offsetV":D.technique[z.nodeName]=parseFloat(z.textContent);break;case"wrapU":case"wrapV":z.textContent.toUpperCase()==="TRUE"?D.technique[z.nodeName]=1:z.textContent.toUpperCase()==="FALSE"?D.technique[z.nodeName]=0:D.technique[z.nodeName]=parseInt(z.textContent);break;case"bump":D[z.nodeName]=E(z);break}}}function Be(L){const D={};for(let B=0,F=L.childNodes.length;B<F;B++){const z=L.childNodes[B];if(z.nodeType===1)switch(z.nodeName){case"technique":D.technique=N(z);break}}return D}function N(L){const D={};for(let B=0,F=L.childNodes.length;B<F;B++){const z=L.childNodes[B];if(z.nodeType===1)switch(z.nodeName){case"double_sided":D[z.nodeName]=parseInt(z.textContent);break;case"bump":D[z.nodeName]=E(z);break}}return D}function E(L){const D={};for(let B=0,F=L.childNodes.length;B<F;B++){const z=L.childNodes[B];if(z.nodeType===1)switch(z.nodeName){case"texture":D[z.nodeName]={id:z.getAttribute("texture"),texcoord:z.getAttribute("texcoord"),extra:Te(z)};break}}return D}function W(L){return L}function ae(L){return b(ut.effects[L],W)}function ve(L){const D={name:L.getAttribute("name")};for(let B=0,F=L.childNodes.length;B<F;B++){const z=L.childNodes[B];if(z.nodeType===1)switch(z.nodeName){case"instance_effect":D.url=o(z.getAttribute("url"));break}}ut.materials[L.getAttribute("id")]=D}function ce(L){let D,B=L.slice((L.lastIndexOf(".")-1>>>0)+2);switch(B=B.toLowerCase(),B){case"tga":D=Gn;break;default:D=Qn}return D}function Oe(L){const D=ae(L.url),B=D.profile.technique;let F;switch(B.type){case"phong":case"blinn":F=new Ii;break;case"lambert":F=new Fn;break;default:F=new jt;break}F.name=L.name||"";function z(ze,qe=null){const st=D.profile.samplers[ze.id];let Ae=null;if(st!==void 0){const it=D.profile.surfaces[st.source];Ae=ue(it.init_from)}else console.warn("THREE.ColladaLoader: Undefined sampler. Access image directly (see #12530)."),Ae=ue(ze.id);if(Ae!==null){const it=ce(Ae);if(it!==void 0){const tt=it.load(Ae),dt=ze.extra;if(dt!==void 0&&dt.technique!==void 0&&c(dt.technique)===!1){const ot=dt.technique;tt.wrapS=ot.wrapU?Li:ui,tt.wrapT=ot.wrapV?Li:ui,tt.offset.set(ot.offsetU||0,ot.offsetV||0),tt.repeat.set(ot.repeatU||1,ot.repeatV||1)}else tt.wrapS=Li,tt.wrapT=Li;return qe!==null&&(tt.colorSpace=qe),tt}else return console.warn("THREE.ColladaLoader: Loader for texture %s not found.",Ae),null}else return console.warn("THREE.ColladaLoader: Couldn't create texture with ID:",ze.id),null}const pe=B.parameters;for(const ze in pe){const qe=pe[ze];switch(ze){case"diffuse":qe.color&&F.color.fromArray(qe.color),qe.texture&&(F.map=z(qe.texture,gt));break;case"specular":qe.color&&F.specular&&F.specular.fromArray(qe.color),qe.texture&&(F.specularMap=z(qe.texture));break;case"bump":qe.texture&&(F.normalMap=z(qe.texture));break;case"ambient":qe.texture&&(F.lightMap=z(qe.texture,gt));break;case"shininess":qe.float&&F.shininess&&(F.shininess=qe.float);break;case"emission":qe.color&&F.emissive&&F.emissive.fromArray(qe.color),qe.texture&&(F.emissiveMap=z(qe.texture,gt));break}}ft.toWorkingColorSpace(F.color,gt),F.specular&&ft.toWorkingColorSpace(F.specular,gt),F.emissive&&ft.toWorkingColorSpace(F.emissive,gt);let _e=pe.transparent,Qe=pe.transparency;if(Qe===void 0&&_e&&(Qe={float:1}),_e===void 0&&Qe&&(_e={opaque:"A_ONE",data:{color:[1,1,1,1]}}),_e&&Qe)if(_e.data.texture)F.transparent=!0;else{const ze=_e.data.color;switch(_e.opaque){case"A_ONE":F.opacity=ze[3]*Qe.float;break;case"RGB_ZERO":F.opacity=1-ze[0]*Qe.float;break;case"A_ZERO":F.opacity=1-ze[3]*Qe.float;break;case"RGB_ONE":F.opacity=ze[0]*Qe.float;break;default:console.warn('THREE.ColladaLoader: Invalid opaque type "%s" of transparent tag.',_e.opaque)}F.opacity<1&&(F.transparent=!0)}if(B.extra!==void 0&&B.extra.technique!==void 0){const ze=B.extra.technique;for(const qe in ze){const st=ze[qe];switch(qe){case"double_sided":F.side=st===1?ln:Si;break;case"bump":F.normalMap=z(st.texture),F.normalScale=new me(1,1);break}}}return F}function Pe(L){return b(ut.materials[L],Oe)}function Ve(L){const D={name:L.getAttribute("name")};for(let B=0,F=L.childNodes.length;B<F;B++){const z=L.childNodes[B];if(z.nodeType===1)switch(z.nodeName){case"optics":D.optics=te(z);break}}ut.cameras[L.getAttribute("id")]=D}function te(L){for(let D=0;D<L.childNodes.length;D++){const B=L.childNodes[D];switch(B.nodeName){case"technique_common":return re(B)}}return{}}function re(L){const D={};for(let B=0;B<L.childNodes.length;B++){const F=L.childNodes[B];switch(F.nodeName){case"perspective":case"orthographic":D.technique=F.nodeName,D.parameters=De(F);break}}return D}function De(L){const D={};for(let B=0;B<L.childNodes.length;B++){const F=L.childNodes[B];switch(F.nodeName){case"xfov":case"yfov":case"xmag":case"ymag":case"znear":case"zfar":case"aspect_ratio":D[F.nodeName]=parseFloat(F.textContent);break}}return D}function Ye(L){let D;switch(L.optics.technique){case"perspective":D=new gn(L.optics.parameters.yfov,L.optics.parameters.aspect_ratio,L.optics.parameters.znear,L.optics.parameters.zfar);break;case"orthographic":let B=L.optics.parameters.ymag,F=L.optics.parameters.xmag;const z=L.optics.parameters.aspect_ratio;F=F===void 0?B*z:F,B=B===void 0?F/z:B,F*=.5,B*=.5,D=new ko(-F,F,B,-B,L.optics.parameters.znear,L.optics.parameters.zfar);break;default:D=new gn;break}return D.name=L.name||"",D}function xe(L){const D=ut.cameras[L];return D!==void 0?b(D,Ye):(console.warn("THREE.ColladaLoader: Couldn't find camera with ID:",L),null)}function Le(L){let D={};for(let B=0,F=L.childNodes.length;B<F;B++){const z=L.childNodes[B];if(z.nodeType===1)switch(z.nodeName){case"technique_common":D=ct(z);break}}ut.lights[L.getAttribute("id")]=D}function ct(L){const D={};for(let B=0,F=L.childNodes.length;B<F;B++){const z=L.childNodes[B];if(z.nodeType===1)switch(z.nodeName){case"directional":case"point":case"spot":case"ambient":D.technique=z.nodeName,D.parameters=rt(z)}}return D}function rt(L){const D={};for(let B=0,F=L.childNodes.length;B<F;B++){const z=L.childNodes[B];if(z.nodeType===1)switch(z.nodeName){case"color":const pe=s(z.textContent);D.color=new Ne().fromArray(pe),ft.toWorkingColorSpace(D.color,gt);break;case"falloff_angle":D.falloffAngle=parseFloat(z.textContent);break;case"quadratic_attenuation":const _e=parseFloat(z.textContent);D.distance=_e?Math.sqrt(1/_e):0;break}}return D}function Rt(L){let D;switch(L.technique){case"directional":D=new Hc;break;case"point":D=new Tc;break;case"spot":D=new $u;break;case"ambient":D=new Gb;break}return L.parameters.color&&D.color.copy(L.parameters.color),L.parameters.distance&&(D.distance=L.parameters.distance),D}function Q(L){const D=ut.lights[L];return D!==void 0?b(D,Rt):(console.warn("THREE.ColladaLoader: Couldn't find light with ID:",L),null)}function Ge(L){const D={name:L.getAttribute("name"),sources:{},vertices:{},primitives:[]},B=n(L,"mesh")[0];if(B!==void 0){for(let F=0;F<B.childNodes.length;F++){const z=B.childNodes[F];if(z.nodeType!==1)continue;const pe=z.getAttribute("id");switch(z.nodeName){case"source":D.sources[pe]=ye(z);break;case"vertices":D.vertices=Me(z);break;case"polygons":console.warn("THREE.ColladaLoader: Unsupported primitive type: ",z.nodeName);break;case"lines":case"linestrips":case"polylist":case"triangles":D.primitives.push(Ze(z));break;default:console.log(z)}}ut.geometries[L.getAttribute("id")]=D}}function ye(L){const D={array:[],stride:3};for(let B=0;B<L.childNodes.length;B++){const F=L.childNodes[B];if(F.nodeType===1)switch(F.nodeName){case"float_array":D.array=s(F.textContent);break;case"Name_array":D.array=i(F.textContent);break;case"technique_common":const z=n(F,"accessor")[0];z!==void 0&&(D.stride=parseInt(z.getAttribute("stride")));break}}return D}function Me(L){const D={};for(let B=0;B<L.childNodes.length;B++){const F=L.childNodes[B];F.nodeType===1&&(D[F.getAttribute("semantic")]=o(F.getAttribute("source")))}return D}function Ze(L){const D={type:L.nodeName,material:L.getAttribute("material"),count:parseInt(L.getAttribute("count")),inputs:{},stride:0,hasUV:!1};for(let B=0,F=L.childNodes.length;B<F;B++){const z=L.childNodes[B];if(z.nodeType===1)switch(z.nodeName){case"input":const pe=o(z.getAttribute("source")),_e=z.getAttribute("semantic"),Qe=parseInt(z.getAttribute("offset")),ze=parseInt(z.getAttribute("set")),qe=ze>0?_e+ze:_e;D.inputs[qe]={id:pe,offset:Qe},D.stride=Math.max(D.stride,Qe+1),_e==="TEXCOORD"&&(D.hasUV=!0);break;case"vcount":D.vcount=a(z.textContent);break;case"p":D.p=a(z.textContent);break}}return D}function Xe(L){const D={};for(let B=0;B<L.length;B++){const F=L[B];D[F.type]===void 0&&(D[F.type]=[]),D[F.type].push(F)}return D}function vt(L){let D=0;for(let B=0,F=L.length;B<F;B++)L[B].hasUV===!0&&D++;D>0&&D<L.length&&(L.uvsNeedsFix=!0)}function Qt(L){const D={},B=L.sources,F=L.vertices,z=L.primitives;if(z.length===0)return{};const pe=Xe(z);for(const _e in pe){const Qe=pe[_e];vt(Qe),D[_e]=An(Qe,B,F)}return D}function An(L,D,B){const F={},z={array:[],stride:0},pe={array:[],stride:0},_e={array:[],stride:0},Qe={array:[],stride:0},ze={array:[],stride:0},qe={array:[],stride:4},st={array:[],stride:4},Ae=new ht,it=[];let tt=0;for(let dt=0;dt<L.length;dt++){const ot=L[dt],on=ot.inputs;let Bt=0;switch(ot.type){case"lines":case"linestrips":Bt=ot.count*2;break;case"triangles":Bt=ot.count*3;break;case"polylist":for(let Ot=0;Ot<ot.count;Ot++){const Ft=ot.vcount[Ot];switch(Ft){case 3:Bt+=3;break;case 4:Bt+=6;break;default:Bt+=(Ft-2)*3;break}}break;default:console.warn("THREE.ColladaLoader: Unknown primitive type:",ot.type)}Ae.addGroup(tt,Bt,dt),tt+=Bt,ot.material&&it.push(ot.material);for(const Ot in on){const Ft=on[Ot];switch(Ot){case"VERTEX":for(const cs in B){const ai=B[cs];switch(cs){case"POSITION":const Nr=z.array.length;if(wt(ot,D[ai],Ft.offset,z.array),z.stride=D[ai].stride,D.skinWeights&&D.skinIndices&&(wt(ot,D.skinIndices,Ft.offset,qe.array),wt(ot,D.skinWeights,Ft.offset,st.array)),ot.hasUV===!1&&L.uvsNeedsFix===!0){const Lv=(z.array.length-Nr)/z.stride;for(let vf=0;vf<Lv;vf++)_e.array.push(0,0)}break;case"NORMAL":wt(ot,D[ai],Ft.offset,pe.array),pe.stride=D[ai].stride;break;case"COLOR":wt(ot,D[ai],Ft.offset,ze.array),ze.stride=D[ai].stride;break;case"TEXCOORD":wt(ot,D[ai],Ft.offset,_e.array),_e.stride=D[ai].stride;break;case"TEXCOORD1":wt(ot,D[ai],Ft.offset,Qe.array),_e.stride=D[ai].stride;break;default:console.warn('THREE.ColladaLoader: Semantic "%s" not handled in geometry build process.',cs)}}break;case"NORMAL":wt(ot,D[Ft.id],Ft.offset,pe.array),pe.stride=D[Ft.id].stride;break;case"COLOR":wt(ot,D[Ft.id],Ft.offset,ze.array,!0),ze.stride=D[Ft.id].stride;break;case"TEXCOORD":wt(ot,D[Ft.id],Ft.offset,_e.array),_e.stride=D[Ft.id].stride;break;case"TEXCOORD1":wt(ot,D[Ft.id],Ft.offset,Qe.array),Qe.stride=D[Ft.id].stride;break}}}return z.array.length>0&&Ae.setAttribute("position",new ke(z.array,z.stride)),pe.array.length>0&&Ae.setAttribute("normal",new ke(pe.array,pe.stride)),ze.array.length>0&&Ae.setAttribute("color",new ke(ze.array,ze.stride)),_e.array.length>0&&Ae.setAttribute("uv",new ke(_e.array,_e.stride)),Qe.array.length>0&&Ae.setAttribute("uv1",new ke(Qe.array,Qe.stride)),qe.array.length>0&&Ae.setAttribute("skinIndex",new ke(qe.array,qe.stride)),st.array.length>0&&Ae.setAttribute("skinWeight",new ke(st.array,st.stride)),F.data=Ae,F.type=L[0].type,F.materialKeys=it,F}function wt(L,D,B,F,z=!1){const pe=L.p,_e=L.stride,Qe=L.vcount;function ze(Ae){let it=pe[Ae+B]*st;const tt=it+st;for(;it<tt;it++)F.push(qe[it]);if(z){const dt=F.length-st-1;fn.setRGB(F[dt+0],F[dt+1],F[dt+2],gt),F[dt+0]=fn.r,F[dt+1]=fn.g,F[dt+2]=fn.b}}const qe=D.array,st=D.stride;if(L.vcount!==void 0){let Ae=0;for(let it=0,tt=Qe.length;it<tt;it++){const dt=Qe[it];if(dt===4){const ot=Ae+_e*0,on=Ae+_e*1,Bt=Ae+_e*2,Ot=Ae+_e*3;ze(ot),ze(on),ze(Ot),ze(on),ze(Bt),ze(Ot)}else if(dt===3){const ot=Ae+_e*0,on=Ae+_e*1,Bt=Ae+_e*2;ze(ot),ze(on),ze(Bt)}else if(dt>4)for(let ot=1,on=dt-2;ot<=on;ot++){const Bt=Ae+_e*0,Ot=Ae+_e*ot,Ft=Ae+_e*(ot+1);ze(Bt),ze(Ot),ze(Ft)}Ae+=_e*dt}}else for(let Ae=0,it=pe.length;Ae<it;Ae+=_e)ze(Ae)}function si(L){return b(ut.geometries[L],Qt)}function Fi(L){const D={name:L.getAttribute("name")||"",joints:{},links:[]};for(let B=0;B<L.childNodes.length;B++){const F=L.childNodes[B];if(F.nodeType===1)switch(F.nodeName){case"technique_common":os(F,D);break}}ut.kinematicsModels[L.getAttribute("id")]=D}function zo(L){return L.build!==void 0?L.build:L}function Ho(L){return b(ut.kinematicsModels[L],zo)}function os(L,D){for(let B=0;B<L.childNodes.length;B++){const F=L.childNodes[B];if(F.nodeType===1)switch(F.nodeName){case"joint":D.joints[F.getAttribute("sid")]=ka(F);break;case"link":D.links.push(Oa(F));break}}}function ka(L){let D;for(let B=0;B<L.childNodes.length;B++){const F=L.childNodes[B];if(F.nodeType===1)switch(F.nodeName){case"prismatic":case"revolute":D=Go(F);break}}return D}function Go(L){const D={sid:L.getAttribute("sid"),name:L.getAttribute("name")||"",axis:new I,limits:{min:0,max:0},type:L.nodeName,static:!1,zeroPosition:0,middlePosition:0};for(let B=0;B<L.childNodes.length;B++){const F=L.childNodes[B];if(F.nodeType===1)switch(F.nodeName){case"axis":const z=s(F.textContent);D.axis.fromArray(z);break;case"limits":const pe=F.getElementsByTagName("max")[0],_e=F.getElementsByTagName("min")[0];D.limits.max=parseFloat(pe.textContent),D.limits.min=parseFloat(_e.textContent);break}}return D.limits.min>=D.limits.max&&(D.static=!0),D.middlePosition=(D.limits.min+D.limits.max)/2,D}function Oa(L){const D={sid:L.getAttribute("sid"),name:L.getAttribute("name")||"",attachments:[],transforms:[]};for(let B=0;B<L.childNodes.length;B++){const F=L.childNodes[B];if(F.nodeType===1)switch(F.nodeName){case"attachment_full":D.attachments.push(Cr(F));break;case"matrix":case"translate":case"rotate":D.transforms.push(Fa(F));break}}return D}function Cr(L){const D={joint:L.getAttribute("joint").split("/").pop(),transforms:[],links:[]};for(let B=0;B<L.childNodes.length;B++){const F=L.childNodes[B];if(F.nodeType===1)switch(F.nodeName){case"link":D.links.push(Oa(F));break;case"matrix":case"translate":case"rotate":D.transforms.push(Fa(F));break}}return D}function Fa(L){const D={type:L.nodeName},B=s(L.textContent);switch(D.type){case"matrix":D.obj=new Ie,D.obj.fromArray(B).transpose();break;case"translate":D.obj=new I,D.obj.fromArray(B);break;case"rotate":D.obj=new I,D.obj.fromArray(B),D.angle=bt.degToRad(B[3]);break}return D}function Pr(L){const D={name:L.getAttribute("name")||"",rigidBodies:{}};for(let B=0;B<L.childNodes.length;B++){const F=L.childNodes[B];if(F.nodeType===1)switch(F.nodeName){case"rigid_body":D.rigidBodies[F.getAttribute("name")]={},Vo(F,D.rigidBodies[F.getAttribute("name")]);break}}ut.physicsModels[L.getAttribute("id")]=D}function Vo(L,D){for(let B=0;B<L.childNodes.length;B++){const F=L.childNodes[B];if(F.nodeType===1)switch(F.nodeName){case"technique_common":Wo(F,D);break}}}function Wo(L,D){for(let B=0;B<L.childNodes.length;B++){const F=L.childNodes[B];if(F.nodeType===1)switch(F.nodeName){case"inertia":D.inertia=s(F.textContent);break;case"mass":D.mass=s(F.textContent)[0];break}}}function Wc(L){const D={bindJointAxis:[]};for(let B=0;B<L.childNodes.length;B++){const F=L.childNodes[B];if(F.nodeType===1)switch(F.nodeName){case"bind_joint_axis":D.bindJointAxis.push(jc(F));break}}ut.kinematicsScenes[o(L.getAttribute("url"))]=D}function jc(L){const D={target:L.getAttribute("target").split("/").pop()};for(let B=0;B<L.childNodes.length;B++){const F=L.childNodes[B];if(F.nodeType===1)switch(F.nodeName){case"axis":const z=F.getElementsByTagName("param")[0];D.axis=z.textContent;const pe=D.axis.split("inst_").pop().split("axis")[0];D.jointIndex=pe.substring(0,pe.length-1);break}}return D}function Xc(L){return L.build!==void 0?L.build:L}function qc(L){return b(ut.kinematicsScenes[L],Xc)}function Zc(){const L=Object.keys(ut.kinematicsModels)[0],D=Object.keys(ut.kinematicsScenes)[0],B=Object.keys(ut.visualScenes)[0];if(L===void 0||D===void 0)return;const F=Ho(L),z=qc(D),pe=Nt(B),_e=z.bindJointAxis,Qe={};for(let st=0,Ae=_e.length;st<Ae;st++){const it=_e[st],tt=Kt.querySelector('[sid="'+it.target+'"]');if(tt){const dt=tt.parentElement;ze(it.jointIndex,dt)}}function ze(st,Ae){const it=Ae.getAttribute("name"),tt=F.joints[st];pe.traverse(function(dt){dt.name===it&&(Qe[st]={object:dt,transforms:Yc(Ae),joint:tt,position:tt.zeroPosition})})}const qe=new Ie;Rr={joints:F&&F.joints,getJointValue:function(st){const Ae=Qe[st];if(Ae)return Ae.position;console.warn("THREE.ColladaLoader: Joint "+st+" doesn't exist.")},setJointValue:function(st,Ae){const it=Qe[st];if(it){const tt=it.joint;if(Ae>tt.limits.max||Ae<tt.limits.min)console.warn("THREE.ColladaLoader: Joint "+st+" value "+Ae+" outside of limits (min: "+tt.limits.min+", max: "+tt.limits.max+").");else if(tt.static)console.warn("THREE.ColladaLoader: Joint "+st+" is static.");else{const dt=it.object,ot=tt.axis,on=it.transforms;J.identity();for(let Bt=0;Bt<on.length;Bt++){const Ot=on[Bt];if(Ot.sid&&Ot.sid.indexOf(st)!==-1)switch(tt.type){case"revolute":J.multiply(qe.makeRotationAxis(ot,bt.degToRad(Ae)));break;case"prismatic":J.multiply(qe.makeTranslation(ot.x*Ae,ot.y*Ae,ot.z*Ae));break;default:console.warn("THREE.ColladaLoader: Unknown joint type: "+tt.type);break}else switch(Ot.type){case"matrix":J.multiply(Ot.obj);break;case"translate":J.multiply(qe.makeTranslation(Ot.obj.x,Ot.obj.y,Ot.obj.z));break;case"scale":J.scale(Ot.obj);break;case"rotate":J.multiply(qe.makeRotationAxis(Ot.obj,Ot.angle));break}}dt.matrix.copy(J),dt.matrix.decompose(dt.position,dt.quaternion,dt.scale),Qe[st].position=Ae}}else console.log("THREE.ColladaLoader: "+st+" does not exist.")}}}function Yc(L){const D=[],B=Kt.querySelector('[id="'+L.id+'"]');for(let F=0;F<B.childNodes.length;F++){const z=B.childNodes[F];if(z.nodeType!==1)continue;let pe,_e;switch(z.nodeName){case"matrix":pe=s(z.textContent);const Qe=new Ie().fromArray(pe).transpose();D.push({sid:z.getAttribute("sid"),type:z.nodeName,obj:Qe});break;case"translate":case"scale":pe=s(z.textContent),_e=new I().fromArray(pe),D.push({sid:z.getAttribute("sid"),type:z.nodeName,obj:_e});break;case"rotate":pe=s(z.textContent),_e=new I().fromArray(pe);const ze=bt.degToRad(pe[3]);D.push({sid:z.getAttribute("sid"),type:z.nodeName,obj:_e,angle:ze});break}}return D}function U(L){const D=L.getElementsByTagName("node");for(let B=0;B<D.length;B++){const F=D[B];F.hasAttribute("id")===!1&&F.setAttribute("id",l())}}const J=new Ie,he=new I;function fe(L){const D={name:L.getAttribute("name")||"",type:L.getAttribute("type"),id:L.getAttribute("id"),sid:L.getAttribute("sid"),matrix:new Ie,nodes:[],instanceCameras:[],instanceControllers:[],instanceLights:[],instanceGeometries:[],instanceNodes:[],transforms:{}};for(let B=0;B<L.childNodes.length;B++){const F=L.childNodes[B];if(F.nodeType!==1)continue;let z;switch(F.nodeName){case"node":D.nodes.push(F.getAttribute("id")),fe(F);break;case"instance_camera":D.instanceCameras.push(o(F.getAttribute("url")));break;case"instance_controller":D.instanceControllers.push(ne(F));break;case"instance_light":D.instanceLights.push(o(F.getAttribute("url")));break;case"instance_geometry":D.instanceGeometries.push(ne(F));break;case"instance_node":D.instanceNodes.push(o(F.getAttribute("url")));break;case"matrix":z=s(F.textContent),D.matrix.multiply(J.fromArray(z).transpose()),D.transforms[F.getAttribute("sid")]=F.nodeName;break;case"translate":z=s(F.textContent),he.fromArray(z),D.matrix.multiply(J.makeTranslation(he.x,he.y,he.z)),D.transforms[F.getAttribute("sid")]=F.nodeName;break;case"rotate":z=s(F.textContent);const pe=bt.degToRad(z[3]);D.matrix.multiply(J.makeRotationAxis(he.fromArray(z),pe)),D.transforms[F.getAttribute("sid")]=F.nodeName;break;case"scale":z=s(F.textContent),D.matrix.scale(he.fromArray(z)),D.transforms[F.getAttribute("sid")]=F.nodeName;break;case"extra":break;default:console.log(F)}}return at(D.id)?console.warn("THREE.ColladaLoader: There is already a node with ID %s. Exclude current node from further processing.",D.id):ut.nodes[D.id]=D,D}function ne(L){const D={id:o(L.getAttribute("url")),materials:{},skeletons:[]};for(let B=0;B<L.childNodes.length;B++){const F=L.childNodes[B];switch(F.nodeName){case"bind_material":const z=F.getElementsByTagName("instance_material");for(let pe=0;pe<z.length;pe++){const _e=z[pe],Qe=_e.getAttribute("symbol"),ze=_e.getAttribute("target");D.materials[Qe]=o(ze)}break;case"skeleton":D.skeletons.push(o(F.textContent));break}}return D}function Re(L,D){const B=[],F=[];let z,pe,_e;for(z=0;z<L.length;z++){const qe=L[z];let st;if(at(qe))st=St(qe),We(st,D,B);else if(nn(qe)){const it=ut.visualScenes[qe].children;for(let tt=0;tt<it.length;tt++){const dt=it[tt];if(dt.type==="JOINT"){const ot=St(dt.id);We(ot,D,B)}}}else console.error("THREE.ColladaLoader: Unable to find root bone of skeleton with ID:",qe)}for(z=0;z<D.length;z++)for(pe=0;pe<B.length;pe++)if(_e=B[pe],_e.bone.name===D[z].name){F[z]=_e,_e.processed=!0;break}for(z=0;z<B.length;z++)_e=B[z],_e.processed===!1&&(F.push(_e),_e.processed=!0);const Qe=[],ze=[];for(z=0;z<F.length;z++)_e=F[z],Qe.push(_e.bone),ze.push(_e.boneInverse);return new Ro(Qe,ze)}function We(L,D,B){L.traverse(function(F){if(F.isBone===!0){let z;for(let pe=0;pe<D.length;pe++){const _e=D[pe];if(_e.name===F.name){z=_e.boneInverse;break}}z===void 0&&(z=new Ie),B.push({bone:F,boneInverse:z,processed:!1})}})}function $e(L){const D=[],B=L.matrix,F=L.nodes,z=L.type,pe=L.instanceCameras,_e=L.instanceControllers,Qe=L.instanceLights,ze=L.instanceGeometries,qe=L.instanceNodes;for(let Ae=0,it=F.length;Ae<it;Ae++)D.push(St(F[Ae]));for(let Ae=0,it=pe.length;Ae<it;Ae++){const tt=xe(pe[Ae]);tt!==null&&D.push(tt.clone())}for(let Ae=0,it=_e.length;Ae<it;Ae++){const tt=_e[Ae],dt=ee(tt.id),ot=si(dt.id),on=mt(ot,tt.materials),Bt=tt.skeletons,Ot=dt.skin.joints,Ft=Re(Bt,Ot);for(let cs=0,ai=on.length;cs<ai;cs++){const Nr=on[cs];Nr.isSkinnedMesh&&(Nr.bind(Ft,dt.skin.bindMatrix),Nr.normalizeSkinWeights()),D.push(Nr)}}for(let Ae=0,it=Qe.length;Ae<it;Ae++){const tt=Q(Qe[Ae]);tt!==null&&D.push(tt.clone())}for(let Ae=0,it=ze.length;Ae<it;Ae++){const tt=ze[Ae],dt=si(tt.id),ot=mt(dt,tt.materials);for(let on=0,Bt=ot.length;on<Bt;on++)D.push(ot[on])}for(let Ae=0,it=qe.length;Ae<it;Ae++)D.push(St(qe[Ae]).clone());let st;if(F.length===0&&D.length===1)st=D[0];else{st=z==="JOINT"?new _o:new Vt;for(let Ae=0;Ae<D.length;Ae++)st.add(D[Ae])}return st.name=z==="JOINT"?L.sid:L.name,st.matrix.copy(B),st.matrix.decompose(st.position,st.quaternion,st.scale),st}const Je=new jt({name:pi.DEFAULT_MATERIAL_NAME,color:16711935});function pt(L,D){const B=[];for(let F=0,z=L.length;F<z;F++){const pe=D[L[F]];pe===void 0?(console.warn("THREE.ColladaLoader: Material with key %s not found. Apply fallback material.",L[F]),B.push(Je)):B.push(Pe(pe))}return B}function mt(L,D){const B=[];for(const F in L){const z=L[F],pe=pt(z.materialKeys,D);if(pe.length===0&&(F==="lines"||F==="linestrips"?pe.push(new zn):pe.push(new Ii)),F==="lines"||F==="linestrips")for(let qe=0,st=pe.length;qe<st;qe++){const Ae=pe[qe];if(Ae.isMeshPhongMaterial===!0||Ae.isMeshLambertMaterial===!0){const it=new zn;it.color.copy(Ae.color),it.opacity=Ae.opacity,it.transparent=Ae.transparent,pe[qe]=it}}const _e=z.data.attributes.skinIndex!==void 0,Qe=pe.length===1?pe[0]:pe;let ze;switch(F){case"lines":ze=new Ks(z.data,Qe);break;case"linestrips":ze=new qn(z.data,Qe);break;case"triangles":case"polylist":_e?ze=new Vu(z.data,Qe):ze=new Ee(z.data,Qe);break}B.push(ze)}return B}function at(L){return ut.nodes[L]!==void 0}function St(L){return b(ut.nodes[L],$e)}function It(L){const D={name:L.getAttribute("name"),children:[]};U(L);const B=n(L,"node");for(let F=0;F<B.length;F++)D.children.push(fe(B[F]));ut.visualScenes[L.getAttribute("id")]=D}function an(L){const D=new Vt;D.name=L.name;const B=L.children;for(let F=0;F<B.length;F++){const z=B[F];D.add(St(z.id))}return D}function nn(L){return ut.visualScenes[L]!==void 0}function Nt(L){return b(ut.visualScenes[L],an)}function lt(L){const D=n(L,"instance_visual_scene")[0];return Nt(o(D.getAttribute("url")))}function yn(){const L=ut.clips;if(c(L)===!0){if(c(ut.animations)===!1){const D=[];for(const B in ut.animations){const F=w(B);for(let z=0,pe=F.length;z<pe;z++)D.push(F[z])}xn.push(new Mc("default",-1,D))}}else for(const D in L)xn.push(V(D))}function kt(L){let D="";const B=[L];for(;B.length;){const F=B.shift();F.nodeType===Node.TEXT_NODE?D+=F.textContent:(D+=`
|
|
4227
4227
|
`,B.push(...F.childNodes))}return D.trim()}if(e.length===0)return{scene:new uu};const ri=new DOMParser().parseFromString(e,"application/xml"),Kt=n(ri,"COLLADA")[0],Ln=ri.getElementsByTagName("parsererror")[0];if(Ln!==void 0){const L=n(Ln,"div")[0];let D;return L?D=L.textContent:D=kt(Ln),console.error(`THREE.ColladaLoader: Failed to parse collada file.
|
|
4228
|
-
`,D),null}const Js=Kt.getAttribute("version");console.debug("THREE.ColladaLoader: File version",Js);const Xt=d(n(Kt,"asset")[0]),Qn=new Lo(this.manager);Qn.setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin);let Gn;wm&&(Gn=new wm(this.manager),Gn.setPath(this.resourcePath||t));const fn=new Ne,xn=[];let Rr={},ls=0;const ut={animations:{},clips:{},controllers:{},images:{},effects:{},materials:{},cameras:{},lights:{},geometries:{},nodes:{},visualScenes:{},kinematicsModels:{},physicsModels:{},kinematicsScenes:{}};f(Kt,"library_animations","animation",p),f(Kt,"library_animation_clips","animation_clip",G),f(Kt,"library_controllers","controller",Z),f(Kt,"library_images","image",ie),f(Kt,"library_effects","effect",oe),f(Kt,"library_materials","material",ve),f(Kt,"library_cameras","camera",Ve),f(Kt,"library_lights","light",Le),f(Kt,"library_geometries","geometry",Ge),f(Kt,"library_nodes","node",fe),f(Kt,"library_visual_scenes","visual_scene",It),f(Kt,"library_kinematics_models","kinematics_model",Fi),f(Kt,"library_physics_models","physics_model",Pr),f(Kt,"scene","instance_kinematics_scene",Wc),m(ut.animations,x),m(ut.clips,K),m(ut.controllers,de),m(ut.images,Y),m(ut.effects,W),m(ut.materials,Oe),m(ut.cameras,Ye),m(ut.lights,Rt),m(ut.geometries,Qt),m(ut.visualScenes,an),yn(),Zc();const jo=lt(n(Kt,"scene")[0]);return jo.animations=xn,Xt.upAxis==="Z_UP"&&(console.warn("THREE.ColladaLoader: You are loading an asset with a Z-UP coordinate system. The loader just rotates the asset to transform it into Y-UP. The vertex data are not converted, see #24289."),jo.rotation.set(-Math.PI/2,0,0)),jo.scale.multiplyScalar(Xt.unit),{get animations(){return console.warn("THREE.ColladaLoader: Please access animations over scene.animations now."),xn},kinematics:Rr,library:ut,scene:jo}}}const Sm=new I,zE=new hn,zl=new Ie,Os=new Ie,Hl=new Lt,Gl=new I(1,1,1),Vl=new I;class Vc extends Pt{constructor(...e){super(...e),this.urdfNode=null,this.urdfName=""}copy(e,t){return super.copy(e,t),this.urdfNode=e.urdfNode,this.urdfName=e.urdfName,this}}class HE extends Vc{constructor(...e){super(...e),this.isURDFCollider=!0,this.type="URDFCollider"}}class GE extends Vc{constructor(...e){super(...e),this.isURDFVisual=!0,this.type="URDFVisual"}}class ev extends Vc{constructor(...e){super(...e),this.isURDFLink=!0,this.type="URDFLink"}}class tv extends Vc{get jointType(){return this._jointType}set jointType(e){if(this.jointType!==e)switch(this._jointType=e,this.matrixWorldNeedsUpdate=!0,e){case"fixed":this.jointValue=[];break;case"continuous":case"revolute":case"prismatic":this.jointValue=new Array(1).fill(0);break;case"planar":this.jointValue=new Array(3).fill(0),this.axis=new I(0,0,1);break;case"floating":this.jointValue=new Array(6).fill(0);break}}get angle(){return this.jointValue[0]}constructor(...e){super(...e),this.isURDFJoint=!0,this.type="URDFJoint",this.jointValue=null,this.jointType="fixed",this.axis=new I(1,0,0),this.limit={lower:0,upper:0},this.ignoreLimits=!1,this.origPosition=null,this.origQuaternion=null,this.mimicJoints=[]}copy(e,t){return super.copy(e,t),this.jointType=e.jointType,this.axis=e.axis.clone(),this.limit.lower=e.limit.lower,this.limit.upper=e.limit.upper,this.ignoreLimits=!1,this.jointValue=[...e.jointValue],this.origPosition=e.origPosition?e.origPosition.clone():null,this.origQuaternion=e.origQuaternion?e.origQuaternion.clone():null,this.mimicJoints=[...e.mimicJoints],this}setJointValue(...e){e=e.map(n=>n===null?null:parseFloat(n)),(!this.origPosition||!this.origQuaternion)&&(this.origPosition=this.position.clone(),this.origQuaternion=this.quaternion.clone());let t=!1;switch(this.mimicJoints.forEach(n=>{t=n.updateFromMimickedJoint(...e)||t}),this.jointType){case"fixed":return t;case"continuous":case"revolute":{let n=e[0];return n==null||n===this.jointValue[0]?t:(!this.ignoreLimits&&this.jointType==="revolute"&&(n=Math.min(this.limit.upper,n),n=Math.max(this.limit.lower,n)),this.quaternion.setFromAxisAngle(this.axis,n).premultiply(this.origQuaternion),this.jointValue[0]!==n?(this.jointValue[0]=n,this.matrixWorldNeedsUpdate=!0,!0):t)}case"prismatic":{let n=e[0];return n==null||n===this.jointValue[0]?t:(this.ignoreLimits||(n=Math.min(this.limit.upper,n),n=Math.max(this.limit.lower,n)),this.position.copy(this.origPosition),Sm.copy(this.axis).applyEuler(this.rotation),this.position.addScaledVector(Sm,n),this.jointValue[0]!==n?(this.jointValue[0]=n,this.matrixWorldNeedsUpdate=!0,!0):t)}case"floating":return this.jointValue.every((n,i)=>e[i]===n||e[i]===null)?t:(this.jointValue[0]=e[0]!==null?e[0]:this.jointValue[0],this.jointValue[1]=e[1]!==null?e[1]:this.jointValue[1],this.jointValue[2]=e[2]!==null?e[2]:this.jointValue[2],this.jointValue[3]=e[3]!==null?e[3]:this.jointValue[3],this.jointValue[4]=e[4]!==null?e[4]:this.jointValue[4],this.jointValue[5]=e[5]!==null?e[5]:this.jointValue[5],Os.compose(this.origPosition,this.origQuaternion,Gl),Hl.setFromEuler(zE.set(this.jointValue[3],this.jointValue[4],this.jointValue[5],"XYZ")),Vl.set(this.jointValue[0],this.jointValue[1],this.jointValue[2]),zl.compose(Vl,Hl,Gl),Os.premultiply(zl),this.position.setFromMatrixPosition(Os),this.rotation.setFromRotationMatrix(Os),this.matrixWorldNeedsUpdate=!0,!0);case"planar":return this.jointValue.every((n,i)=>e[i]===n||e[i]===null)?t:(this.jointValue[0]=e[0]!==null?e[0]:this.jointValue[0],this.jointValue[1]=e[1]!==null?e[1]:this.jointValue[1],this.jointValue[2]=e[2]!==null?e[2]:this.jointValue[2],Os.compose(this.origPosition,this.origQuaternion,Gl),Hl.setFromAxisAngle(this.axis,this.jointValue[2]),Vl.set(this.jointValue[0],this.jointValue[1],0),zl.compose(Vl,Hl,Gl),Os.premultiply(zl),this.position.setFromMatrixPosition(Os),this.rotation.setFromRotationMatrix(Os),this.matrixWorldNeedsUpdate=!0,!0)}return t}}class Mm extends tv{constructor(...e){super(...e),this.type="URDFMimicJoint",this.mimicJoint=null,this.offset=0,this.multiplier=1}updateFromMimickedJoint(...e){const t=e.map(n=>n*this.multiplier+this.offset);return super.setJointValue(...t)}copy(e,t){return super.copy(e,t),this.mimicJoint=e.mimicJoint,this.offset=e.offset,this.multiplier=e.multiplier,this}}class VE extends ev{constructor(...e){super(...e),this.isURDFRobot=!0,this.urdfNode=null,this.urdfRobotNode=null,this.robotName=null,this.links=null,this.joints=null,this.colliders=null,this.visual=null,this.frames=null}copy(e,t){super.copy(e,t),this.urdfRobotNode=e.urdfRobotNode,this.robotName=e.robotName,this.links={},this.joints={},this.colliders={},this.visual={},this.traverse(n=>{n.isURDFJoint&&n.urdfName in e.joints&&(this.joints[n.urdfName]=n),n.isURDFLink&&n.urdfName in e.links&&(this.links[n.urdfName]=n),n.isURDFCollider&&n.urdfName in e.colliders&&(this.colliders[n.urdfName]=n),n.isURDFVisual&&n.urdfName in e.visual&&(this.visual[n.urdfName]=n)});for(const n in this.joints)this.joints[n].mimicJoints=this.joints[n].mimicJoints.map(i=>this.joints[i.name]);return this.frames={...this.colliders,...this.visual,...this.links,...this.joints},this}getFrame(e){return this.frames[e]}setJointValue(e,...t){const n=this.joints[e];return n?n.setJointValue(...t):!1}setJointValues(e){let t=!1;for(const n in e){const i=e[n];Array.isArray(i)?t=this.setJointValue(n,...i)||t:t=this.setJointValue(n,i)||t}return t}}const Vd=new Lt,Tm=new hn;function Qr(r){return r?r.trim().split(/\s+/g).map(e=>parseFloat(e)):[0,0,0]}function Em(r,e,t=!1){t||r.rotation.set(0,0,0),Tm.set(e[0],e[1],e[2],"ZYX"),Vd.setFromEuler(Tm),Vd.multiply(r.quaternion),r.quaternion.copy(Vd)}class sf{constructor(e){this.manager=e||Hb,this.loadMeshCb=this.defaultMeshLoader.bind(this),this.parseVisual=!0,this.parseCollision=!1,this.packages="",this.workingPath="",this.fetchOptions={}}loadAsync(e){return new Promise((t,n)=>{this.load(e,t,null,n)})}load(e,t,n,i){const s=this.manager,a=qs.extractUrlBase(e),o=this.manager.resolveURL(e);s.itemStart(o),fetch(o,this.fetchOptions).then(l=>{if(l.ok)return n&&n(null),l.text();throw new Error(`URDFLoader: Failed to load url '${o}' with error code ${l.status} : ${l.statusText}.`)}).then(l=>{const c=this.parse(l,this.workingPath||a);t(c),s.itemEnd(o)}).catch(l=>{i?i(l):console.error("URDFLoader: Error loading file.",l),s.itemError(o),s.itemEnd(o)})}parse(e,t=this.workingPath){const n=this.packages,i=this.loadMeshCb,s=this.parseVisual,a=this.parseCollision,o=this.manager,l={},c={},d={};function h(y){if(!/^package:\/\//.test(y))return t?t+y:y;const[x,w]=y.replace(/^package:\/\//,"").split(/\/(.+)/);if(typeof n=="string")return n.endsWith(x)?n+"/"+w:n+"/"+x+"/"+w;if(n instanceof Function)return n(x)+"/"+w;if(typeof n=="object")return x in n?n[x]+"/"+w:(console.error(`URDFLoader : ${x} not found in provided package list.`),null)}function u(y){let x;y instanceof Document?x=[...y.children]:y instanceof Element?x=[y]:x=[...new DOMParser().parseFromString(y,"text/xml").children];const w=x.filter(P=>P.nodeName==="robot").pop();return f(w)}function f(y){const x=[...y.children],w=x.filter(R=>R.nodeName.toLowerCase()==="link"),P=x.filter(R=>R.nodeName.toLowerCase()==="joint"),T=x.filter(R=>R.nodeName.toLowerCase()==="material"),A=new VE;A.robotName=y.getAttribute("name"),A.urdfRobotNode=y,T.forEach(R=>{const k=R.getAttribute("name");d[k]=p(R)});const M={},_={};w.forEach(R=>{const k=R.getAttribute("name"),O=y.querySelector(`child[link="${k}"]`)===null;l[k]=b(R,M,_,O?A:null)}),P.forEach(R=>{const k=R.getAttribute("name");c[k]=m(R)}),A.joints=c,A.links=l,A.colliders=_,A.visual=M;const S=Object.values(c);return S.forEach(R=>{R instanceof Mm&&c[R.mimicJoint].mimicJoints.push(R)}),S.forEach(R=>{const k=new Set,O=H=>{if(k.has(H))throw new Error("URDFLoader: Detected an infinite loop of mimic joints.");k.add(H),H.mimicJoints.forEach(q=>{O(q)})};O(R)}),A.frames={..._,...M,...l,...c},A}function m(y){const x=[...y.children],w=y.getAttribute("type");let P;const T=x.find(k=>k.nodeName.toLowerCase()==="mimic");T?(P=new Mm,P.mimicJoint=T.getAttribute("joint"),P.multiplier=parseFloat(T.getAttribute("multiplier")||1),P.offset=parseFloat(T.getAttribute("offset")||0)):P=new tv,P.urdfNode=y,P.name=y.getAttribute("name"),P.urdfName=P.name,P.jointType=w;let A=null,M=null,_=[0,0,0],S=[0,0,0];x.forEach(k=>{const O=k.nodeName.toLowerCase();O==="origin"?(_=Qr(k.getAttribute("xyz")),S=Qr(k.getAttribute("rpy"))):O==="child"?M=l[k.getAttribute("link")]:O==="parent"?A=l[k.getAttribute("link")]:O==="limit"&&(P.limit.lower=parseFloat(k.getAttribute("lower")||P.limit.lower),P.limit.upper=parseFloat(k.getAttribute("upper")||P.limit.upper))}),A.add(P),P.add(M),Em(P,S),P.position.set(_[0],_[1],_[2]);const R=x.filter(k=>k.nodeName.toLowerCase()==="axis")[0];if(R){const k=R.getAttribute("xyz").split(/\s+/g).map(O=>parseFloat(O));P.axis=new I(k[0],k[1],k[2]),P.axis.normalize()}return P}function b(y,x,w,P=null){P===null&&(P=new ev);const T=[...y.children];return P.name=y.getAttribute("name"),P.urdfName=P.name,P.urdfNode=y,s&&T.filter(M=>M.nodeName.toLowerCase()==="visual").forEach(M=>{const _=g(M,d);if(P.add(_),M.hasAttribute("name")){const S=M.getAttribute("name");_.name=S,_.urdfName=S,x[S]=_}}),a&&T.filter(M=>M.nodeName.toLowerCase()==="collision").forEach(M=>{const _=g(M);if(P.add(_),M.hasAttribute("name")){const S=M.getAttribute("name");_.name=S,_.urdfName=S,w[S]=_}}),P}function p(y){const x=[...y.children],w=new Ii;return w.name=y.getAttribute("name")||"",x.forEach(P=>{const T=P.nodeName.toLowerCase();if(T==="color"){const A=P.getAttribute("rgba").split(/\s/g).map(M=>parseFloat(M));w.color.setRGB(A[0],A[1],A[2]),w.opacity=A[3],w.transparent=A[3]<1,w.depthWrite=!w.transparent}else if(T==="texture"){const A=P.getAttribute("filename");if(A){const M=new Lo(o),_=h(A);w.map=M.load(_),w.map.colorSpace=gt}}}),w}function g(y,x={}){const w=y.nodeName.toLowerCase()==="collision",P=[...y.children];let T=null;const A=P.filter(_=>_.nodeName.toLowerCase()==="material")[0];if(A){const _=A.getAttribute("name");_&&_ in x?T=x[_]:T=p(A)}else T=new Ii;const M=w?new HE:new GE;return M.urdfNode=y,P.forEach(_=>{const S=_.nodeName.toLowerCase();if(S==="geometry"){const R=_.children[0].nodeName.toLowerCase();if(R==="mesh"){const k=_.children[0].getAttribute("filename"),O=h(k);if(O!==null){const H=_.children[0].getAttribute("scale");if(H){const q=Qr(H);M.scale.set(q[0],q[1],q[2])}i(O,o,(q,G)=>{G?console.error("URDFLoader: Error loading mesh.",G):q&&(q instanceof Ee&&(q.material=T),q.position.set(0,0,0),q.quaternion.identity(),M.add(q))})}}else if(R==="box"){const k=new Ee;k.geometry=new Jt(1,1,1),k.material=T;const O=Qr(_.children[0].getAttribute("size"));k.scale.set(O[0],O[1],O[2]),M.add(k)}else if(R==="sphere"){const k=new Ee;k.geometry=new Pa(1,30,30),k.material=T;const O=parseFloat(_.children[0].getAttribute("radius"))||0;k.scale.set(O,O,O),M.add(k)}else if(R==="cylinder"){const k=new Ee;k.geometry=new Pn(1,1,1,30),k.material=T;const O=parseFloat(_.children[0].getAttribute("radius"))||0,H=parseFloat(_.children[0].getAttribute("length"))||0;k.scale.set(O,H,O),k.rotation.set(Math.PI/2,0,0),M.add(k)}}else if(S==="origin"){const R=Qr(_.getAttribute("xyz")),k=Qr(_.getAttribute("rpy"));M.position.set(R[0],R[1],R[2]),M.rotation.set(0,0,0),Em(M,k)}}),M}return u(e)}defaultMeshLoader(e,t,n){/\.stl$/i.test(e)?new Qb(t).load(e,s=>{const a=new Ee(s,new Ii);n(a)}):/\.dae$/i.test(e)?new Jb(t).load(e,s=>n(s.scene)):console.warn(`URDFLoader: Could not load model at ${e}.
|
|
4228
|
+
`,D),null}const Js=Kt.getAttribute("version");console.debug("THREE.ColladaLoader: File version",Js);const Xt=d(n(Kt,"asset")[0]),Qn=new Lo(this.manager);Qn.setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin);let Gn;wm&&(Gn=new wm(this.manager),Gn.setPath(this.resourcePath||t));const fn=new Ne,xn=[];let Rr={},ls=0;const ut={animations:{},clips:{},controllers:{},images:{},effects:{},materials:{},cameras:{},lights:{},geometries:{},nodes:{},visualScenes:{},kinematicsModels:{},physicsModels:{},kinematicsScenes:{}};f(Kt,"library_animations","animation",p),f(Kt,"library_animation_clips","animation_clip",G),f(Kt,"library_controllers","controller",Y),f(Kt,"library_images","image",ie),f(Kt,"library_effects","effect",oe),f(Kt,"library_materials","material",ve),f(Kt,"library_cameras","camera",Ve),f(Kt,"library_lights","light",Le),f(Kt,"library_geometries","geometry",Ge),f(Kt,"library_nodes","node",fe),f(Kt,"library_visual_scenes","visual_scene",It),f(Kt,"library_kinematics_models","kinematics_model",Fi),f(Kt,"library_physics_models","physics_model",Pr),f(Kt,"scene","instance_kinematics_scene",Wc),m(ut.animations,x),m(ut.clips,K),m(ut.controllers,de),m(ut.images,Z),m(ut.effects,W),m(ut.materials,Oe),m(ut.cameras,Ye),m(ut.lights,Rt),m(ut.geometries,Qt),m(ut.visualScenes,an),yn(),Zc();const jo=lt(n(Kt,"scene")[0]);return jo.animations=xn,Xt.upAxis==="Z_UP"&&(console.warn("THREE.ColladaLoader: You are loading an asset with a Z-UP coordinate system. The loader just rotates the asset to transform it into Y-UP. The vertex data are not converted, see #24289."),jo.rotation.set(-Math.PI/2,0,0)),jo.scale.multiplyScalar(Xt.unit),{get animations(){return console.warn("THREE.ColladaLoader: Please access animations over scene.animations now."),xn},kinematics:Rr,library:ut,scene:jo}}}const Sm=new I,zE=new hn,zl=new Ie,Os=new Ie,Hl=new Lt,Gl=new I(1,1,1),Vl=new I;class Vc extends Pt{constructor(...e){super(...e),this.urdfNode=null,this.urdfName=""}copy(e,t){return super.copy(e,t),this.urdfNode=e.urdfNode,this.urdfName=e.urdfName,this}}class HE extends Vc{constructor(...e){super(...e),this.isURDFCollider=!0,this.type="URDFCollider"}}class GE extends Vc{constructor(...e){super(...e),this.isURDFVisual=!0,this.type="URDFVisual"}}class ev extends Vc{constructor(...e){super(...e),this.isURDFLink=!0,this.type="URDFLink"}}class tv extends Vc{get jointType(){return this._jointType}set jointType(e){if(this.jointType!==e)switch(this._jointType=e,this.matrixWorldNeedsUpdate=!0,e){case"fixed":this.jointValue=[];break;case"continuous":case"revolute":case"prismatic":this.jointValue=new Array(1).fill(0);break;case"planar":this.jointValue=new Array(3).fill(0),this.axis=new I(0,0,1);break;case"floating":this.jointValue=new Array(6).fill(0);break}}get angle(){return this.jointValue[0]}constructor(...e){super(...e),this.isURDFJoint=!0,this.type="URDFJoint",this.jointValue=null,this.jointType="fixed",this.axis=new I(1,0,0),this.limit={lower:0,upper:0},this.ignoreLimits=!1,this.origPosition=null,this.origQuaternion=null,this.mimicJoints=[]}copy(e,t){return super.copy(e,t),this.jointType=e.jointType,this.axis=e.axis.clone(),this.limit.lower=e.limit.lower,this.limit.upper=e.limit.upper,this.ignoreLimits=!1,this.jointValue=[...e.jointValue],this.origPosition=e.origPosition?e.origPosition.clone():null,this.origQuaternion=e.origQuaternion?e.origQuaternion.clone():null,this.mimicJoints=[...e.mimicJoints],this}setJointValue(...e){e=e.map(n=>n===null?null:parseFloat(n)),(!this.origPosition||!this.origQuaternion)&&(this.origPosition=this.position.clone(),this.origQuaternion=this.quaternion.clone());let t=!1;switch(this.mimicJoints.forEach(n=>{t=n.updateFromMimickedJoint(...e)||t}),this.jointType){case"fixed":return t;case"continuous":case"revolute":{let n=e[0];return n==null||n===this.jointValue[0]?t:(!this.ignoreLimits&&this.jointType==="revolute"&&(n=Math.min(this.limit.upper,n),n=Math.max(this.limit.lower,n)),this.quaternion.setFromAxisAngle(this.axis,n).premultiply(this.origQuaternion),this.jointValue[0]!==n?(this.jointValue[0]=n,this.matrixWorldNeedsUpdate=!0,!0):t)}case"prismatic":{let n=e[0];return n==null||n===this.jointValue[0]?t:(this.ignoreLimits||(n=Math.min(this.limit.upper,n),n=Math.max(this.limit.lower,n)),this.position.copy(this.origPosition),Sm.copy(this.axis).applyEuler(this.rotation),this.position.addScaledVector(Sm,n),this.jointValue[0]!==n?(this.jointValue[0]=n,this.matrixWorldNeedsUpdate=!0,!0):t)}case"floating":return this.jointValue.every((n,i)=>e[i]===n||e[i]===null)?t:(this.jointValue[0]=e[0]!==null?e[0]:this.jointValue[0],this.jointValue[1]=e[1]!==null?e[1]:this.jointValue[1],this.jointValue[2]=e[2]!==null?e[2]:this.jointValue[2],this.jointValue[3]=e[3]!==null?e[3]:this.jointValue[3],this.jointValue[4]=e[4]!==null?e[4]:this.jointValue[4],this.jointValue[5]=e[5]!==null?e[5]:this.jointValue[5],Os.compose(this.origPosition,this.origQuaternion,Gl),Hl.setFromEuler(zE.set(this.jointValue[3],this.jointValue[4],this.jointValue[5],"XYZ")),Vl.set(this.jointValue[0],this.jointValue[1],this.jointValue[2]),zl.compose(Vl,Hl,Gl),Os.premultiply(zl),this.position.setFromMatrixPosition(Os),this.rotation.setFromRotationMatrix(Os),this.matrixWorldNeedsUpdate=!0,!0);case"planar":return this.jointValue.every((n,i)=>e[i]===n||e[i]===null)?t:(this.jointValue[0]=e[0]!==null?e[0]:this.jointValue[0],this.jointValue[1]=e[1]!==null?e[1]:this.jointValue[1],this.jointValue[2]=e[2]!==null?e[2]:this.jointValue[2],Os.compose(this.origPosition,this.origQuaternion,Gl),Hl.setFromAxisAngle(this.axis,this.jointValue[2]),Vl.set(this.jointValue[0],this.jointValue[1],0),zl.compose(Vl,Hl,Gl),Os.premultiply(zl),this.position.setFromMatrixPosition(Os),this.rotation.setFromRotationMatrix(Os),this.matrixWorldNeedsUpdate=!0,!0)}return t}}class Mm extends tv{constructor(...e){super(...e),this.type="URDFMimicJoint",this.mimicJoint=null,this.offset=0,this.multiplier=1}updateFromMimickedJoint(...e){const t=e.map(n=>n*this.multiplier+this.offset);return super.setJointValue(...t)}copy(e,t){return super.copy(e,t),this.mimicJoint=e.mimicJoint,this.offset=e.offset,this.multiplier=e.multiplier,this}}class VE extends ev{constructor(...e){super(...e),this.isURDFRobot=!0,this.urdfNode=null,this.urdfRobotNode=null,this.robotName=null,this.links=null,this.joints=null,this.colliders=null,this.visual=null,this.frames=null}copy(e,t){super.copy(e,t),this.urdfRobotNode=e.urdfRobotNode,this.robotName=e.robotName,this.links={},this.joints={},this.colliders={},this.visual={},this.traverse(n=>{n.isURDFJoint&&n.urdfName in e.joints&&(this.joints[n.urdfName]=n),n.isURDFLink&&n.urdfName in e.links&&(this.links[n.urdfName]=n),n.isURDFCollider&&n.urdfName in e.colliders&&(this.colliders[n.urdfName]=n),n.isURDFVisual&&n.urdfName in e.visual&&(this.visual[n.urdfName]=n)});for(const n in this.joints)this.joints[n].mimicJoints=this.joints[n].mimicJoints.map(i=>this.joints[i.name]);return this.frames={...this.colliders,...this.visual,...this.links,...this.joints},this}getFrame(e){return this.frames[e]}setJointValue(e,...t){const n=this.joints[e];return n?n.setJointValue(...t):!1}setJointValues(e){let t=!1;for(const n in e){const i=e[n];Array.isArray(i)?t=this.setJointValue(n,...i)||t:t=this.setJointValue(n,i)||t}return t}}const Vd=new Lt,Tm=new hn;function Qr(r){return r?r.trim().split(/\s+/g).map(e=>parseFloat(e)):[0,0,0]}function Em(r,e,t=!1){t||r.rotation.set(0,0,0),Tm.set(e[0],e[1],e[2],"ZYX"),Vd.setFromEuler(Tm),Vd.multiply(r.quaternion),r.quaternion.copy(Vd)}class sf{constructor(e){this.manager=e||Hb,this.loadMeshCb=this.defaultMeshLoader.bind(this),this.parseVisual=!0,this.parseCollision=!1,this.packages="",this.workingPath="",this.fetchOptions={}}loadAsync(e){return new Promise((t,n)=>{this.load(e,t,null,n)})}load(e,t,n,i){const s=this.manager,a=qs.extractUrlBase(e),o=this.manager.resolveURL(e);s.itemStart(o),fetch(o,this.fetchOptions).then(l=>{if(l.ok)return n&&n(null),l.text();throw new Error(`URDFLoader: Failed to load url '${o}' with error code ${l.status} : ${l.statusText}.`)}).then(l=>{const c=this.parse(l,this.workingPath||a);t(c),s.itemEnd(o)}).catch(l=>{i?i(l):console.error("URDFLoader: Error loading file.",l),s.itemError(o),s.itemEnd(o)})}parse(e,t=this.workingPath){const n=this.packages,i=this.loadMeshCb,s=this.parseVisual,a=this.parseCollision,o=this.manager,l={},c={},d={};function h(y){if(!/^package:\/\//.test(y))return t?t+y:y;const[x,w]=y.replace(/^package:\/\//,"").split(/\/(.+)/);if(typeof n=="string")return n.endsWith(x)?n+"/"+w:n+"/"+x+"/"+w;if(n instanceof Function)return n(x)+"/"+w;if(typeof n=="object")return x in n?n[x]+"/"+w:(console.error(`URDFLoader : ${x} not found in provided package list.`),null)}function u(y){let x;y instanceof Document?x=[...y.children]:y instanceof Element?x=[y]:x=[...new DOMParser().parseFromString(y,"text/xml").children];const w=x.filter(P=>P.nodeName==="robot").pop();return f(w)}function f(y){const x=[...y.children],w=x.filter(R=>R.nodeName.toLowerCase()==="link"),P=x.filter(R=>R.nodeName.toLowerCase()==="joint"),T=x.filter(R=>R.nodeName.toLowerCase()==="material"),A=new VE;A.robotName=y.getAttribute("name"),A.urdfRobotNode=y,T.forEach(R=>{const k=R.getAttribute("name");d[k]=p(R)});const M={},_={};w.forEach(R=>{const k=R.getAttribute("name"),O=y.querySelector(`child[link="${k}"]`)===null;l[k]=b(R,M,_,O?A:null)}),P.forEach(R=>{const k=R.getAttribute("name");c[k]=m(R)}),A.joints=c,A.links=l,A.colliders=_,A.visual=M;const S=Object.values(c);return S.forEach(R=>{R instanceof Mm&&c[R.mimicJoint].mimicJoints.push(R)}),S.forEach(R=>{const k=new Set,O=H=>{if(k.has(H))throw new Error("URDFLoader: Detected an infinite loop of mimic joints.");k.add(H),H.mimicJoints.forEach(q=>{O(q)})};O(R)}),A.frames={..._,...M,...l,...c},A}function m(y){const x=[...y.children],w=y.getAttribute("type");let P;const T=x.find(k=>k.nodeName.toLowerCase()==="mimic");T?(P=new Mm,P.mimicJoint=T.getAttribute("joint"),P.multiplier=parseFloat(T.getAttribute("multiplier")||1),P.offset=parseFloat(T.getAttribute("offset")||0)):P=new tv,P.urdfNode=y,P.name=y.getAttribute("name"),P.urdfName=P.name,P.jointType=w;let A=null,M=null,_=[0,0,0],S=[0,0,0];x.forEach(k=>{const O=k.nodeName.toLowerCase();O==="origin"?(_=Qr(k.getAttribute("xyz")),S=Qr(k.getAttribute("rpy"))):O==="child"?M=l[k.getAttribute("link")]:O==="parent"?A=l[k.getAttribute("link")]:O==="limit"&&(P.limit.lower=parseFloat(k.getAttribute("lower")||P.limit.lower),P.limit.upper=parseFloat(k.getAttribute("upper")||P.limit.upper))}),A.add(P),P.add(M),Em(P,S),P.position.set(_[0],_[1],_[2]);const R=x.filter(k=>k.nodeName.toLowerCase()==="axis")[0];if(R){const k=R.getAttribute("xyz").split(/\s+/g).map(O=>parseFloat(O));P.axis=new I(k[0],k[1],k[2]),P.axis.normalize()}return P}function b(y,x,w,P=null){P===null&&(P=new ev);const T=[...y.children];return P.name=y.getAttribute("name"),P.urdfName=P.name,P.urdfNode=y,s&&T.filter(M=>M.nodeName.toLowerCase()==="visual").forEach(M=>{const _=g(M,d);if(P.add(_),M.hasAttribute("name")){const S=M.getAttribute("name");_.name=S,_.urdfName=S,x[S]=_}}),a&&T.filter(M=>M.nodeName.toLowerCase()==="collision").forEach(M=>{const _=g(M);if(P.add(_),M.hasAttribute("name")){const S=M.getAttribute("name");_.name=S,_.urdfName=S,w[S]=_}}),P}function p(y){const x=[...y.children],w=new Ii;return w.name=y.getAttribute("name")||"",x.forEach(P=>{const T=P.nodeName.toLowerCase();if(T==="color"){const A=P.getAttribute("rgba").split(/\s/g).map(M=>parseFloat(M));w.color.setRGB(A[0],A[1],A[2]),w.opacity=A[3],w.transparent=A[3]<1,w.depthWrite=!w.transparent}else if(T==="texture"){const A=P.getAttribute("filename");if(A){const M=new Lo(o),_=h(A);w.map=M.load(_),w.map.colorSpace=gt}}}),w}function g(y,x={}){const w=y.nodeName.toLowerCase()==="collision",P=[...y.children];let T=null;const A=P.filter(_=>_.nodeName.toLowerCase()==="material")[0];if(A){const _=A.getAttribute("name");_&&_ in x?T=x[_]:T=p(A)}else T=new Ii;const M=w?new HE:new GE;return M.urdfNode=y,P.forEach(_=>{const S=_.nodeName.toLowerCase();if(S==="geometry"){const R=_.children[0].nodeName.toLowerCase();if(R==="mesh"){const k=_.children[0].getAttribute("filename"),O=h(k);if(O!==null){const H=_.children[0].getAttribute("scale");if(H){const q=Qr(H);M.scale.set(q[0],q[1],q[2])}i(O,o,(q,G)=>{G?console.error("URDFLoader: Error loading mesh.",G):q&&(q instanceof Ee&&(q.material=T),q.position.set(0,0,0),q.quaternion.identity(),M.add(q))})}}else if(R==="box"){const k=new Ee;k.geometry=new Jt(1,1,1),k.material=T;const O=Qr(_.children[0].getAttribute("size"));k.scale.set(O[0],O[1],O[2]),M.add(k)}else if(R==="sphere"){const k=new Ee;k.geometry=new Pa(1,30,30),k.material=T;const O=parseFloat(_.children[0].getAttribute("radius"))||0;k.scale.set(O,O,O),M.add(k)}else if(R==="cylinder"){const k=new Ee;k.geometry=new Pn(1,1,1,30),k.material=T;const O=parseFloat(_.children[0].getAttribute("radius"))||0,H=parseFloat(_.children[0].getAttribute("length"))||0;k.scale.set(O,H,O),k.rotation.set(Math.PI/2,0,0),M.add(k)}}else if(S==="origin"){const R=Qr(_.getAttribute("xyz")),k=Qr(_.getAttribute("rpy"));M.position.set(R[0],R[1],R[2]),M.rotation.set(0,0,0),Em(M,k)}}),M}return u(e)}defaultMeshLoader(e,t,n){/\.stl$/i.test(e)?new Qb(t).load(e,s=>{const a=new Ee(s,new Ii);n(a)}):/\.dae$/i.test(e)?new Jb(t).load(e,s=>n(s.scene)):console.warn(`URDFLoader: Could not load model at ${e}.
|
|
4229
4229
|
No loader available`)}}const Wd=new WeakMap;class Oo extends pi{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,n,i){const s=new Ys(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,i)},n,i)}parse(e,t,n=()=>{}){this.decodeDracoFile(e,t,null,null,gt,n).catch(n)}decodeDracoFile(e,t,n,i,s=$n,a=()=>{}){const o={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:i||this.defaultAttributeTypes,useUniqueIDs:!!n,vertexColorSpace:s};return this.decodeGeometry(e,o).then(t).catch(a)}decodeGeometry(e,t){const n=JSON.stringify(t);if(Wd.has(e)){const l=Wd.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 i;const s=this.workerNextTaskID++,a=e.byteLength,o=this._getWorker(s,a).then(l=>(i=l,new Promise((c,d)=>{i._callbacks[s]={resolve:c,reject:d},i.postMessage({type:"decode",id:s,taskConfig:t,buffer:e},[e])}))).then(l=>this._createGeometry(l.geometry));return o.catch(()=>!0).then(()=>{i&&s&&this._releaseTask(i,s)}),Wd.set(e,{key:n,promise:o}),o}_createGeometry(e){const t=new ht;e.index&&t.setIndex(new rn(e.index.array,1));for(let n=0;n<e.attributes.length;n++){const i=e.attributes[n],s=i.name,a=i.array,o=i.itemSize,l=new rn(a,o);s==="color"&&(this._assignVertexColorSpace(l,i.vertexColorSpace),l.normalized=!(a instanceof Float32Array)),t.setAttribute(s,l)}return t}_assignVertexColorSpace(e,t){if(t!==gt)return;const n=new Ne;for(let i=0,s=e.count;i<s;i++)n.fromBufferAttribute(e,i),ft.toWorkingColorSpace(n,gt),e.setXYZ(i,n.r,n.g,n.b)}_loadLibrary(e,t){const n=new Ys(this.manager);return n.setPath(this.decoderPath),n.setResponseType(t),n.setWithCredentials(this.withCredentials),new Promise((i,s)=>{n.load(e,i,void 0,s)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(n=>{const i=n[0];e||(this.decoderConfig.wasmBinary=n[1]);const s=WE.toString(),a=["/* draco decoder */",i,"","/* worker */",s.substring(s.indexOf("{")+1,s.lastIndexOf("}"))].join(`
|
|
4230
4230
|
`);this.workerSourceURL=URL.createObjectURL(new Blob([a]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const i=new Worker(this.workerSourceURL);i._callbacks={},i._taskCosts={},i._taskLoad=0,i.postMessage({type:"init",decoderConfig:this.decoderConfig}),i.onmessage=function(s){const a=s.data;switch(a.type){case"decode":i._callbacks[a.id].resolve(a);break;case"error":i._callbacks[a.id].reject(a);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+a.type+'"')}},this.workerPool.push(i)}else this.workerPool.sort(function(i,s){return i._taskLoad>s._taskLoad?-1:1});const n=this.workerPool[this.workerPool.length-1];return n._taskCosts[e]=t,n._taskLoad+=t,n})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}}function WE(){let r,e;onmessage=function(a){const o=a.data;switch(o.type){case"init":r=o.decoderConfig,e=new Promise(function(d){r.onModuleLoaded=function(h){d({draco:h})},DracoDecoderModule(r)});break;case"decode":const l=o.buffer,c=o.taskConfig;e.then(d=>{const h=d.draco,u=new h.Decoder;try{const f=t(h,u,new Int8Array(l),c),m=f.attributes.map(b=>b.array.buffer);f.index&&m.push(f.index.array.buffer),self.postMessage({type:"decode",id:o.id,geometry:f},m)}catch(f){console.error(f),self.postMessage({type:"error",id:o.id,error:f.message})}finally{h.destroy(u)}});break}};function t(a,o,l,c){const d=c.attributeIDs,h=c.attributeTypes;let u,f;const m=o.GetEncodedGeometryType(l);if(m===a.TRIANGULAR_MESH)u=new a.Mesh,f=o.DecodeArrayToMesh(l,l.byteLength,u);else if(m===a.POINT_CLOUD)u=new a.PointCloud,f=o.DecodeArrayToPointCloud(l,l.byteLength,u);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!f.ok()||u.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+f.error_msg());const b={index:null,attributes:[]};for(const p in d){const g=self[h[p]];let y,x;if(c.useUniqueIDs)x=d[p],y=o.GetAttributeByUniqueId(u,x);else{if(x=o.GetAttributeId(u,a[d[p]]),x===-1)continue;y=o.GetAttribute(u,x)}const w=i(a,o,u,p,g,y);p==="color"&&(w.vertexColorSpace=c.vertexColorSpace),b.attributes.push(w)}return m===a.TRIANGULAR_MESH&&(b.index=n(a,o,u)),a.destroy(u),b}function n(a,o,l){const d=l.num_faces()*3,h=d*4,u=a._malloc(h);o.GetTrianglesUInt32Array(l,h,u);const f=new Uint32Array(a.HEAPF32.buffer,u,d).slice();return a._free(u),{array:f,itemSize:1}}function i(a,o,l,c,d,h){const u=h.num_components(),m=l.num_points()*u,b=m*d.BYTES_PER_ELEMENT,p=s(a,d),g=a._malloc(b);o.GetAttributeDataArrayForAllPoints(l,h,p,b,g);const y=new d(a.HEAPF32.buffer,g,m).slice();return a._free(g),{name:c,array:y,itemSize:u}}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}}}function ZN(r,e=!1){const t=r[0].index!==null,n=new Set(Object.keys(r[0].attributes)),i=new Set(Object.keys(r[0].morphAttributes)),s={},a={},o=r[0].morphTargetsRelative,l=new ht;let c=0;for(let d=0;d<r.length;++d){const h=r[d];let u=0;if(t!==(h.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const f in h.attributes){if(!n.has(f))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+'. All geometries must have compatible attributes; make sure "'+f+'" attribute exists among all geometries, or in none of them.'),null;s[f]===void 0&&(s[f]=[]),s[f].push(h.attributes[f]),u++}if(u!==n.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". Make sure all geometries have the same number of attributes."),null;if(o!==h.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const f in h.morphAttributes){if(!i.has(f))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". .morphAttributes must be consistent throughout all geometries."),null;a[f]===void 0&&(a[f]=[]),a[f].push(h.morphAttributes[f])}if(e){let f;if(t)f=h.index.count;else if(h.attributes.position!==void 0)f=h.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". The geometry must have either an index or a position attribute"),null;l.addGroup(c,f,d),c+=f}}if(t){let d=0;const h=[];for(let u=0;u<r.length;++u){const f=r[u].index;for(let m=0;m<f.count;++m)h.push(f.getX(m)+d);d+=r[u].attributes.position.count}l.setIndex(h)}for(const d in s){const h=Am(s[d]);if(!h)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+d+" attribute."),null;l.setAttribute(d,h)}for(const d in a){const h=a[d][0].length;if(h===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[d]=[];for(let u=0;u<h;++u){const f=[];for(let b=0;b<a[d].length;++b)f.push(a[d][b][u]);const m=Am(f);if(!m)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+d+" morphAttribute."),null;l.morphAttributes[d].push(m)}}return l}function Am(r){let e,t,n,i=-1,s=0;for(let c=0;c<r.length;++c){const d=r[c];if(e===void 0&&(e=d.array.constructor),e!==d.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(t===void 0&&(t=d.itemSize),t!==d.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(n===void 0&&(n=d.normalized),n!==d.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(i===-1&&(i=d.gpuType),i!==d.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;s+=d.count*t}const a=new e(s),o=new rn(a,t,n);let l=0;for(let c=0;c<r.length;++c){const d=r[c];if(d.isInterleavedBufferAttribute){const h=l/t;for(let u=0,f=d.count;u<f;u++)for(let m=0;m<t;m++){const b=d.getComponent(u,m);o.setComponent(u+h,m,b)}}else a.set(d.array,l);l+=d.count*t}return i!==void 0&&(o.gpuType=i),o}function Cm(r,e){if(e===Sx)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),r;if(e===du||e===bb){let t=r.getIndex();if(t===null){const a=[],o=r.getAttribute("position");if(o!==void 0){for(let l=0;l<o.count;l++)a.push(l);r.setIndex(a),t=r.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),r}const n=t.count-2,i=[];if(e===du)for(let a=1;a<=n;a++)i.push(t.getX(0)),i.push(t.getX(a)),i.push(t.getX(a+1));else for(let a=0;a<n;a++)a%2===0?(i.push(t.getX(a)),i.push(t.getX(a+1)),i.push(t.getX(a+2))):(i.push(t.getX(a+2)),i.push(t.getX(a+1)),i.push(t.getX(a)));i.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const s=r.clone();return s.setIndex(i),s.clearGroups(),s}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),r}class Ar extends pi{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new YE(t)}),this.register(function(t){return new KE(t)}),this.register(function(t){return new rA(t)}),this.register(function(t){return new aA(t)}),this.register(function(t){return new oA(t)}),this.register(function(t){return new QE(t)}),this.register(function(t){return new JE(t)}),this.register(function(t){return new eA(t)}),this.register(function(t){return new tA(t)}),this.register(function(t){return new ZE(t)}),this.register(function(t){return new nA(t)}),this.register(function(t){return new $E(t)}),this.register(function(t){return new sA(t)}),this.register(function(t){return new iA(t)}),this.register(function(t){return new XE(t)}),this.register(function(t){return new lA(t)}),this.register(function(t){return new cA(t)})}load(e,t,n,i){const s=this;let a;if(this.resourcePath!=="")a=this.resourcePath;else if(this.path!==""){const c=qs.extractUrlBase(e);a=qs.resolveURL(c,this.path)}else a=qs.extractUrlBase(e);this.manager.itemStart(e);const o=function(c){i?i(c):console.error(c),s.manager.itemError(e),s.manager.itemEnd(e)},l=new Ys(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(d){t(d),s.manager.itemEnd(e)},o)}catch(d){o(d)}},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,i){let s;const 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))===nv){try{a[Ct.KHR_BINARY_GLTF]=new dA(e)}catch(h){i&&i(h);return}s=JSON.parse(a[Ct.KHR_BINARY_GLTF].content)}else s=JSON.parse(l.decode(e));else s=e;if(s.asset===void 0||s.asset.version[0]<2){i&&i(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const c=new SA(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 d=0;d<this.pluginCallbacks.length;d++){const h=this.pluginCallbacks[d](c);h.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),o[h.name]=h,a[h.name]=!0}if(s.extensionsUsed)for(let d=0;d<s.extensionsUsed.length;++d){const h=s.extensionsUsed[d],u=s.extensionsRequired||[];switch(h){case Ct.KHR_MATERIALS_UNLIT:a[h]=new qE;break;case Ct.KHR_DRACO_MESH_COMPRESSION:a[h]=new hA(s,this.dracoLoader);break;case Ct.KHR_TEXTURE_TRANSFORM:a[h]=new uA;break;case Ct.KHR_MESH_QUANTIZATION:a[h]=new fA;break;default:u.indexOf(h)>=0&&o[h]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+h+'".')}}c.setExtensions(a),c.setPlugins(o),c.parse(n,i)}parseAsync(e,t){const n=this;return new Promise(function(i,s){n.parse(e,t,i,s)})}}function jE(){let r={};return{get:function(e){return r[e]},add:function(e,t){r[e]=t},remove:function(e){delete r[e]},removeAll:function(){r={}}}}const Ct={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class XE{constructor(e){this.parser=e,this.name=Ct.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n<i;n++){const 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){const t=this.parser,n="light:"+e;let i=t.cache.get(n);if(i)return i;const s=t.json,l=((s.extensions&&s.extensions[this.name]||{}).lights||[])[e];let c;const d=new Ne(16777215);l.color!==void 0&&d.setRGB(l.color[0],l.color[1],l.color[2],$n);const h=l.range!==void 0?l.range:0;switch(l.type){case"directional":c=new Hc(d),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new Tc(d),c.distance=h;break;case"spot":c=new $u(d),c.distance=h,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),ys(c,l),l.intensity!==void 0&&(c.intensity=l.intensity),c.name=t.createUniqueName(l.name||"light_"+e),i=Promise.resolve(c),t.cache.add(n,i),i}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const 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)})}}class qE{constructor(){this.name=Ct.KHR_MATERIALS_UNLIT}getMaterialType(){return jt}extendParams(e,t,n){const i=[];e.color=new Ne(1,1,1),e.opacity=1;const s=t.pbrMetallicRoughness;if(s){if(Array.isArray(s.baseColorFactor)){const a=s.baseColorFactor;e.color.setRGB(a[0],a[1],a[2],$n),e.opacity=a[3]}s.baseColorTexture!==void 0&&i.push(n.assignTexture(e,"map",s.baseColorTexture,gt))}return Promise.all(i)}}class ZE{constructor(e){this.parser=e,this.name=Ct.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=i.extensions[this.name].emissiveStrength;return s!==void 0&&(t.emissiveIntensity=s),Promise.resolve()}}class YE{constructor(e){this.parser=e,this.name=Ct.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:rs}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],a=i.extensions[this.name];if(a.clearcoatFactor!==void 0&&(t.clearcoat=a.clearcoatFactor),a.clearcoatTexture!==void 0&&s.push(n.assignTexture(t,"clearcoatMap",a.clearcoatTexture)),a.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=a.clearcoatRoughnessFactor),a.clearcoatRoughnessTexture!==void 0&&s.push(n.assignTexture(t,"clearcoatRoughnessMap",a.clearcoatRoughnessTexture)),a.clearcoatNormalTexture!==void 0&&(s.push(n.assignTexture(t,"clearcoatNormalMap",a.clearcoatNormalTexture)),a.clearcoatNormalTexture.scale!==void 0)){const o=a.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new me(o,o)}return Promise.all(s)}}class KE{constructor(e){this.parser=e,this.name=Ct.KHR_MATERIALS_DISPERSION}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:rs}extendMaterialParams(e,t){const i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=i.extensions[this.name];return t.dispersion=s.dispersion!==void 0?s.dispersion:0,Promise.resolve()}}class $E{constructor(e){this.parser=e,this.name=Ct.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:rs}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],a=i.extensions[this.name];return a.iridescenceFactor!==void 0&&(t.iridescence=a.iridescenceFactor),a.iridescenceTexture!==void 0&&s.push(n.assignTexture(t,"iridescenceMap",a.iridescenceTexture)),a.iridescenceIor!==void 0&&(t.iridescenceIOR=a.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),a.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=a.iridescenceThicknessMinimum),a.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=a.iridescenceThicknessMaximum),a.iridescenceThicknessTexture!==void 0&&s.push(n.assignTexture(t,"iridescenceThicknessMap",a.iridescenceThicknessTexture)),Promise.all(s)}}class QE{constructor(e){this.parser=e,this.name=Ct.KHR_MATERIALS_SHEEN}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:rs}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[];t.sheenColor=new Ne(0,0,0),t.sheenRoughness=0,t.sheen=1;const a=i.extensions[this.name];if(a.sheenColorFactor!==void 0){const o=a.sheenColorFactor;t.sheenColor.setRGB(o[0],o[1],o[2],$n)}return a.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=a.sheenRoughnessFactor),a.sheenColorTexture!==void 0&&s.push(n.assignTexture(t,"sheenColorMap",a.sheenColorTexture,gt)),a.sheenRoughnessTexture!==void 0&&s.push(n.assignTexture(t,"sheenRoughnessMap",a.sheenRoughnessTexture)),Promise.all(s)}}class JE{constructor(e){this.parser=e,this.name=Ct.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:rs}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],a=i.extensions[this.name];return a.transmissionFactor!==void 0&&(t.transmission=a.transmissionFactor),a.transmissionTexture!==void 0&&s.push(n.assignTexture(t,"transmissionMap",a.transmissionTexture)),Promise.all(s)}}class eA{constructor(e){this.parser=e,this.name=Ct.KHR_MATERIALS_VOLUME}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:rs}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],a=i.extensions[this.name];t.thickness=a.thicknessFactor!==void 0?a.thicknessFactor:0,a.thicknessTexture!==void 0&&s.push(n.assignTexture(t,"thicknessMap",a.thicknessTexture)),t.attenuationDistance=a.attenuationDistance||1/0;const o=a.attenuationColor||[1,1,1];return t.attenuationColor=new Ne().setRGB(o[0],o[1],o[2],$n),Promise.all(s)}}class tA{constructor(e){this.parser=e,this.name=Ct.KHR_MATERIALS_IOR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:rs}extendMaterialParams(e,t){const i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=i.extensions[this.name];return t.ior=s.ior!==void 0?s.ior:1.5,Promise.resolve()}}class nA{constructor(e){this.parser=e,this.name=Ct.KHR_MATERIALS_SPECULAR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:rs}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],a=i.extensions[this.name];t.specularIntensity=a.specularFactor!==void 0?a.specularFactor:1,a.specularTexture!==void 0&&s.push(n.assignTexture(t,"specularIntensityMap",a.specularTexture));const o=a.specularColorFactor||[1,1,1];return t.specularColor=new Ne().setRGB(o[0],o[1],o[2],$n),a.specularColorTexture!==void 0&&s.push(n.assignTexture(t,"specularColorMap",a.specularColorTexture,gt)),Promise.all(s)}}class iA{constructor(e){this.parser=e,this.name=Ct.EXT_MATERIALS_BUMP}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:rs}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],a=i.extensions[this.name];return t.bumpScale=a.bumpFactor!==void 0?a.bumpFactor:1,a.bumpTexture!==void 0&&s.push(n.assignTexture(t,"bumpMap",a.bumpTexture)),Promise.all(s)}}class sA{constructor(e){this.parser=e,this.name=Ct.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:rs}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],a=i.extensions[this.name];return a.anisotropyStrength!==void 0&&(t.anisotropy=a.anisotropyStrength),a.anisotropyRotation!==void 0&&(t.anisotropyRotation=a.anisotropyRotation),a.anisotropyTexture!==void 0&&s.push(n.assignTexture(t,"anisotropyMap",a.anisotropyTexture)),Promise.all(s)}}class rA{constructor(e){this.parser=e,this.name=Ct.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,i=n.textures[e];if(!i.extensions||!i.extensions[this.name])return null;const s=i.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)}}class aA{constructor(e){this.parser=e,this.name=Ct.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,i=n.json,s=i.textures[e];if(!s.extensions||!s.extensions[t])return null;const a=s.extensions[t],o=i.images[a.source];let l=n.textureLoader;if(o.uri){const c=n.options.manager.getHandler(o.uri);c!==null&&(l=c)}return this.detectSupport().then(function(c){if(c)return n.loadTextureImage(e,a.source,l);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class oA{constructor(e){this.parser=e,this.name=Ct.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,i=n.json,s=i.textures[e];if(!s.extensions||!s.extensions[t])return null;const a=s.extensions[t],o=i.images[a.source];let l=n.textureLoader;if(o.uri){const c=n.options.manager.getHandler(o.uri);c!==null&&(l=c)}return this.detectSupport().then(function(c){if(c)return n.loadTextureImage(e,a.source,l);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class lA{constructor(e){this.name=Ct.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const i=n.extensions[this.name],s=this.parser.getDependency("buffer",i.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){const l=i.byteOffset||0,c=i.byteLength||0,d=i.count,h=i.byteStride,u=new Uint8Array(o,l,c);return a.decodeGltfBufferAsync?a.decodeGltfBufferAsync(d,h,u,i.mode,i.filter).then(function(f){return f.buffer}):a.ready.then(function(){const f=new ArrayBuffer(d*h);return a.decodeGltfBuffer(new Uint8Array(f),d,h,u,i.mode,i.filter),f})})}else return null}}class cA{constructor(e){this.name=Ct.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;const i=t.meshes[n.mesh];for(const c of i.primitives)if(c.mode!==Ci.TRIANGLES&&c.mode!==Ci.TRIANGLE_STRIP&&c.mode!==Ci.TRIANGLE_FAN&&c.mode!==void 0)return null;const a=n.extensions[this.name].attributes,o=[],l={};for(const c in a)o.push(this.parser.getDependency("accessor",a[c]).then(d=>(l[c]=d,l[c])));return o.length<1?null:(o.push(this.parser.createNodeMesh(e)),Promise.all(o).then(c=>{const d=c.pop(),h=d.isGroup?d.children:[d],u=c[0].count,f=[];for(const m of h){const b=new Ie,p=new I,g=new Lt,y=new I(1,1,1),x=new E0(m.geometry,m.material,u);for(let w=0;w<u;w++)l.TRANSLATION&&p.fromBufferAttribute(l.TRANSLATION,w),l.ROTATION&&g.fromBufferAttribute(l.ROTATION,w),l.SCALE&&y.fromBufferAttribute(l.SCALE,w),x.setMatrixAt(w,b.compose(p,g,y));for(const w in l)if(w==="_COLOR_0"){const P=l[w];x.instanceColor=new fu(P.array,P.itemSize,P.normalized)}else w!=="TRANSLATION"&&w!=="ROTATION"&&w!=="SCALE"&&m.geometry.setAttribute(w,l[w]);Pt.prototype.copy.call(x,m),this.parser.assignFinalMaterial(x),f.push(x)}return d.isGroup?(d.clear(),d.add(...f),d):f[0]}))}}const nv="glTF",Qa=12,Pm={JSON:1313821514,BIN:5130562};class dA{constructor(e){this.name=Ct.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,Qa),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!==nv)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const i=this.header.length-Qa,s=new DataView(e,Qa);let a=0;for(;a<i;){const o=s.getUint32(a,!0);a+=4;const l=s.getUint32(a,!0);if(a+=4,l===Pm.JSON){const c=new Uint8Array(e,Qa+a,o);this.content=n.decode(c)}else if(l===Pm.BIN){const c=Qa+a;this.body=e.slice(c,c+o)}a+=o}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class hA{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=Ct.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,i=this.dracoLoader,s=e.extensions[this.name].bufferView,a=e.extensions[this.name].attributes,o={},l={},c={};for(const d in a){const h=wu[d]||d.toLowerCase();o[h]=a[d]}for(const d in e.attributes){const h=wu[d]||d.toLowerCase();if(a[d]!==void 0){const u=n.accessors[e.attributes[d]],f=ga[u.componentType];c[h]=f.name,l[h]=u.normalized===!0}}return t.getDependency("bufferView",s).then(function(d){return new Promise(function(h,u){i.decodeDracoFile(d,function(f){for(const m in f.attributes){const b=f.attributes[m],p=l[m];p!==void 0&&(b.normalized=p)}h(f)},o,c,$n,u)})})}}class uA{constructor(){this.name=Ct.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0||(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class fA{constructor(){this.name=Ct.KHR_MESH_QUANTIZATION}}class iv extends Do{constructor(e,t,n,i){super(e,t,n,i)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,s=e*i*3+i;for(let a=0;a!==i;a++)t[a]=n[s+a];return t}interpolate_(e,t,n,i){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=o*2,c=o*3,d=i-t,h=(n-t)/d,u=h*h,f=u*h,m=e*c,b=m-c,p=-2*f+3*u,g=f-u,y=1-p,x=g-u+h;for(let w=0;w!==o;w++){const P=a[b+w+o],T=a[b+w+l]*d,A=a[m+w+o],M=a[m+w]*d;s[w]=y*P+x*T+p*A+g*M}return s}}const pA=new Lt;class mA extends iv{interpolate_(e,t,n,i){const s=super.interpolate_(e,t,n,i);return pA.fromArray(s).normalize().toArray(s),s}}const Ci={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},ga={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Rm={9728:Sn,9729:bn,9984:ob,9985:oc,9986:ro,9987:ji},Nm={33071:ui,33648:yc,10497:Li},jd={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},wu={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"},Fs={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},gA={CUBICSPLINE:void 0,LINEAR:yo,STEP:vo},Xd={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function bA(r){return r.DefaultMaterial===void 0&&(r.DefaultMaterial=new Bc({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:Si})),r.DefaultMaterial}function cr(r,e,t){for(const n in t.extensions)r[n]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=t.extensions[n])}function ys(r,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(r.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function vA(r,e,t){let n=!1,i=!1,s=!1;for(let c=0,d=e.length;c<d;c++){const h=e[c];if(h.POSITION!==void 0&&(n=!0),h.NORMAL!==void 0&&(i=!0),h.COLOR_0!==void 0&&(s=!0),n&&i&&s)break}if(!n&&!i&&!s)return Promise.resolve(r);const a=[],o=[],l=[];for(let c=0,d=e.length;c<d;c++){const h=e[c];if(n){const u=h.POSITION!==void 0?t.getDependency("accessor",h.POSITION):r.attributes.position;a.push(u)}if(i){const u=h.NORMAL!==void 0?t.getDependency("accessor",h.NORMAL):r.attributes.normal;o.push(u)}if(s){const u=h.COLOR_0!==void 0?t.getDependency("accessor",h.COLOR_0):r.attributes.color;l.push(u)}}return Promise.all([Promise.all(a),Promise.all(o),Promise.all(l)]).then(function(c){const d=c[0],h=c[1],u=c[2];return n&&(r.morphAttributes.position=d),i&&(r.morphAttributes.normal=h),s&&(r.morphAttributes.color=u),r.morphTargetsRelative=!0,r})}function yA(r,e){if(r.updateMorphTargets(),e.weights!==void 0)for(let t=0,n=e.weights.length;t<n;t++)r.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(r.morphTargetInfluences.length===t.length){r.morphTargetDictionary={};for(let n=0,i=t.length;n<i;n++)r.morphTargetDictionary[t[n]]=n}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function xA(r){let e;const t=r.extensions&&r.extensions[Ct.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+qd(t.attributes):e=r.indices+":"+qd(r.attributes)+":"+r.mode,r.targets!==void 0)for(let n=0,i=r.targets.length;n<i;n++)e+=":"+qd(r.targets[n]);return e}function qd(r){let e="";const t=Object.keys(r).sort();for(let n=0,i=t.length;n<i;n++)e+=t[n]+":"+r[t[n]]+";";return e}function Su(r){switch(r){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 _A(r){return r.search(/\.jpe?g($|\?)/i)>0||r.search(/^data\:image\/jpeg/)===0?"image/jpeg":r.search(/\.webp($|\?)/i)>0||r.search(/^data\:image\/webp/)===0?"image/webp":r.search(/\.ktx2($|\?)/i)>0||r.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const wA=new Ie;class SA{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new jE,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,i=-1,s=!1,a=-1;if(typeof navigator<"u"){const o=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(o)===!0;const l=o.match(/Version\/(\d+)/);i=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&&i<17||s&&a<98?this.textureLoader=new Lo(this.options.manager):this.textureLoader=new R_(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Ys(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const n=this,i=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){const o={scene:a[0][i.scene||0],scenes:a[0],animations:a[1],cameras:a[2],asset:i.asset,parser:n,userData:{}};return cr(s,o,i),ys(o,i),Promise.all(n._invokeAll(function(l){return l.afterRoot&&l.afterRoot(o)})).then(function(){for(const l of o.scenes)l.updateMatrixWorld();e(o)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let i=0,s=t.length;i<s;i++){const a=t[i].joints;for(let o=0,l=a.length;o<l;o++)e[a[o]].isBone=!0}for(let i=0,s=e.length;i<s;i++){const a=e[i];a.mesh!==void 0&&(this._addNodeRef(this.meshCache,a.mesh),a.skin!==void 0&&(n[a.mesh].isSkinnedMesh=!0)),a.camera!==void 0&&this._addNodeRef(this.cameraCache,a.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;const i=n.clone(),s=(a,o)=>{const l=this.associations.get(a);l!=null&&this.associations.set(o,l);for(const[c,d]of a.children.entries())s(d,o.children[c])};return s(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const i=e(t[n]);if(i)return i}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let i=0;i<t.length;i++){const s=e(t[i]);s&&n.push(s)}return n}getDependency(e,t){const n=e+":"+t;let i=this.cache.get(n);if(!i){switch(e){case"scene":i=this.loadScene(t);break;case"node":i=this._invokeOne(function(s){return s.loadNode&&s.loadNode(t)});break;case"mesh":i=this._invokeOne(function(s){return s.loadMesh&&s.loadMesh(t)});break;case"accessor":i=this.loadAccessor(t);break;case"bufferView":i=this._invokeOne(function(s){return s.loadBufferView&&s.loadBufferView(t)});break;case"buffer":i=this.loadBuffer(t);break;case"material":i=this._invokeOne(function(s){return s.loadMaterial&&s.loadMaterial(t)});break;case"texture":i=this._invokeOne(function(s){return s.loadTexture&&s.loadTexture(t)});break;case"skin":i=this.loadSkin(t);break;case"animation":i=this._invokeOne(function(s){return s.loadAnimation&&s.loadAnimation(t)});break;case"camera":i=this.loadCamera(t);break;default:if(i=this._invokeOne(function(s){return s!=this&&s.getDependency&&s.getDependency(e,t)}),!i)throw new Error("Unknown type: "+e);break}this.cache.add(n,i)}return i}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,i=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(i.map(function(s,a){return n.getDependency(e,a)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[Ct.KHR_BINARY_GLTF].body);const i=this.options;return new Promise(function(s,a){n.load(qs.resolveURL(t.uri,i.path),s,void 0,function(){a(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(n){const i=t.byteLength||0,s=t.byteOffset||0;return n.slice(s,s+i)})}loadAccessor(e){const t=this,n=this.json,i=this.json.accessors[e];if(i.bufferView===void 0&&i.sparse===void 0){const a=jd[i.type],o=ga[i.componentType],l=i.normalized===!0,c=new o(i.count*a);return Promise.resolve(new rn(c,a,l))}const s=[];return i.bufferView!==void 0?s.push(this.getDependency("bufferView",i.bufferView)):s.push(null),i.sparse!==void 0&&(s.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),s.push(this.getDependency("bufferView",i.sparse.values.bufferView))),Promise.all(s).then(function(a){const o=a[0],l=jd[i.type],c=ga[i.componentType],d=c.BYTES_PER_ELEMENT,h=d*l,u=i.byteOffset||0,f=i.bufferView!==void 0?n.bufferViews[i.bufferView].byteStride:void 0,m=i.normalized===!0;let b,p;if(f&&f!==h){const g=Math.floor(u/f),y="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+g+":"+i.count;let x=t.cache.get(y);x||(b=new c(o,g*f,i.count*f/d),x=new Gu(b,f/d),t.cache.add(y,x)),p=new Xi(x,l,u%f/d,m)}else o===null?b=new c(i.count*l):b=new c(o,u,i.count*l),p=new rn(b,l,m);if(i.sparse!==void 0){const g=jd.SCALAR,y=ga[i.sparse.indices.componentType],x=i.sparse.indices.byteOffset||0,w=i.sparse.values.byteOffset||0,P=new y(a[1],x,i.sparse.count*g),T=new c(a[2],w,i.sparse.count*l);o!==null&&(p=new rn(p.array.slice(),p.itemSize,p.normalized)),p.normalized=!1;for(let A=0,M=P.length;A<M;A++){const _=P[A];if(p.setX(_,T[A*l]),l>=2&&p.setY(_,T[A*l+1]),l>=3&&p.setZ(_,T[A*l+2]),l>=4&&p.setW(_,T[A*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}p.normalized=m}return p})}loadTexture(e){const t=this.json,n=this.options,s=t.textures[e].source,a=t.images[s];let o=this.textureLoader;if(a.uri){const l=n.manager.getHandler(a.uri);l!==null&&(o=l)}return this.loadTextureImage(e,s,o)}loadTextureImage(e,t,n){const i=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];const c=this.loadImageSource(t,n).then(function(d){d.flipY=!1,d.name=a.name||o.name||"",d.name===""&&typeof o.uri=="string"&&o.uri.startsWith("data:image/")===!1&&(d.name=o.uri);const u=(s.samplers||{})[a.sampler]||{};return d.magFilter=Rm[u.magFilter]||bn,d.minFilter=Rm[u.minFilter]||ji,d.wrapS=Nm[u.wrapS]||Li,d.wrapT=Nm[u.wrapT]||Li,d.generateMipmaps=!d.isCompressedTexture&&d.minFilter!==Sn&&d.minFilter!==bn,i.associations.set(d,{textures:e}),d}).catch(function(){return null});return this.textureCache[l]=c,c}loadImageSource(e,t){const n=this,i=this.json,s=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(h=>h.clone());const a=i.images[e],o=self.URL||self.webkitURL;let l=a.uri||"",c=!1;if(a.bufferView!==void 0)l=n.getDependency("bufferView",a.bufferView).then(function(h){c=!0;const u=new Blob([h],{type:a.mimeType});return l=o.createObjectURL(u),l});else if(a.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const d=Promise.resolve(l).then(function(h){return new Promise(function(u,f){let m=u;t.isImageBitmapLoader===!0&&(m=function(b){const p=new Ut(b);p.needsUpdate=!0,u(p)}),t.load(qs.resolveURL(h,s.path),m,void 0,f)})}).then(function(h){return c===!0&&o.revokeObjectURL(l),ys(h,a),h.userData.mimeType=a.mimeType||_A(a.uri),h}).catch(function(h){throw console.error("THREE.GLTFLoader: Couldn't load texture",l),h});return this.sourceCache[e]=d,d}assignTexture(e,t,n,i){const 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[Ct.KHR_TEXTURE_TRANSFORM]){const o=n.extensions!==void 0?n.extensions[Ct.KHR_TEXTURE_TRANSFORM]:void 0;if(o){const l=s.associations.get(a);a=s.extensions[Ct.KHR_TEXTURE_TRANSFORM].extendTexture(a,o),s.associations.set(a,l)}}return i!==void 0&&(a.colorSpace=i),e[t]=a,a})}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const i=t.attributes.tangent===void 0,s=t.attributes.color!==void 0,a=t.attributes.normal===void 0;if(e.isPoints){const o="PointsMaterial:"+n.uuid;let l=this.cache.get(o);l||(l=new mr,wi.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){const o="LineBasicMaterial:"+n.uuid;let l=this.cache.get(o);l||(l=new zn,wi.prototype.copy.call(l,n),l.color.copy(n.color),l.map=n.map,this.cache.add(o,l)),n=l}if(i||s||a){let o="ClonedMaterial:"+n.uuid+":";i&&(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),i&&(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 Bc}loadMaterial(e){const t=this,n=this.json,i=this.extensions,s=n.materials[e];let a;const o={},l=s.extensions||{},c=[];if(l[Ct.KHR_MATERIALS_UNLIT]){const h=i[Ct.KHR_MATERIALS_UNLIT];a=h.getMaterialType(),c.push(h.extendParams(o,s,t))}else{const h=s.pbrMetallicRoughness||{};if(o.color=new Ne(1,1,1),o.opacity=1,Array.isArray(h.baseColorFactor)){const u=h.baseColorFactor;o.color.setRGB(u[0],u[1],u[2],$n),o.opacity=u[3]}h.baseColorTexture!==void 0&&c.push(t.assignTexture(o,"map",h.baseColorTexture,gt)),o.metalness=h.metallicFactor!==void 0?h.metallicFactor:1,o.roughness=h.roughnessFactor!==void 0?h.roughnessFactor:1,h.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(o,"metalnessMap",h.metallicRoughnessTexture)),c.push(t.assignTexture(o,"roughnessMap",h.metallicRoughnessTexture))),a=this._invokeOne(function(u){return u.getMaterialType&&u.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(u){return u.extendMaterialParams&&u.extendMaterialParams(e,o)})))}s.doubleSided===!0&&(o.side=ln);const d=s.alphaMode||Xd.OPAQUE;if(d===Xd.BLEND?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,d===Xd.MASK&&(o.alphaTest=s.alphaCutoff!==void 0?s.alphaCutoff:.5)),s.normalTexture!==void 0&&a!==jt&&(c.push(t.assignTexture(o,"normalMap",s.normalTexture)),o.normalScale=new me(1,1),s.normalTexture.scale!==void 0)){const h=s.normalTexture.scale;o.normalScale.set(h,h)}if(s.occlusionTexture!==void 0&&a!==jt&&(c.push(t.assignTexture(o,"aoMap",s.occlusionTexture)),s.occlusionTexture.strength!==void 0&&(o.aoMapIntensity=s.occlusionTexture.strength)),s.emissiveFactor!==void 0&&a!==jt){const h=s.emissiveFactor;o.emissive=new Ne().setRGB(h[0],h[1],h[2],$n)}return s.emissiveTexture!==void 0&&a!==jt&&c.push(t.assignTexture(o,"emissiveMap",s.emissiveTexture,gt)),Promise.all(c).then(function(){const h=new a(o);return s.name&&(h.name=s.name),ys(h,s),t.associations.set(h,{materials:e}),s.extensions&&cr(i,h,s),h})}createUniqueName(e){const t=Dt.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,n=this.extensions,i=this.primitiveCache;function s(o){return n[Ct.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(o,t).then(function(l){return Dm(l,o,t)})}const a=[];for(let o=0,l=e.length;o<l;o++){const c=e[o],d=xA(c),h=i[d];if(h)a.push(h.promise);else{let u;c.extensions&&c.extensions[Ct.KHR_DRACO_MESH_COMPRESSION]?u=s(c):u=Dm(new ht,c,t),i[d]={primitive:c,promise:u},a.push(u)}}return Promise.all(a)}loadMesh(e){const t=this,n=this.json,i=this.extensions,s=n.meshes[e],a=s.primitives,o=[];for(let l=0,c=a.length;l<c;l++){const d=a[l].material===void 0?bA(this.cache):this.getDependency("material",a[l].material);o.push(d)}return o.push(t.loadGeometries(a)),Promise.all(o).then(function(l){const c=l.slice(0,l.length-1),d=l[l.length-1],h=[];for(let f=0,m=d.length;f<m;f++){const b=d[f],p=a[f];let g;const y=c[f];if(p.mode===Ci.TRIANGLES||p.mode===Ci.TRIANGLE_STRIP||p.mode===Ci.TRIANGLE_FAN||p.mode===void 0)g=s.isSkinnedMesh===!0?new Vu(b,y):new Ee(b,y),g.isSkinnedMesh===!0&&g.normalizeSkinWeights(),p.mode===Ci.TRIANGLE_STRIP?g.geometry=Cm(g.geometry,bb):p.mode===Ci.TRIANGLE_FAN&&(g.geometry=Cm(g.geometry,du));else if(p.mode===Ci.LINES)g=new Ks(b,y);else if(p.mode===Ci.LINE_STRIP)g=new qn(b,y);else if(p.mode===Ci.LINE_LOOP)g=new Ab(b,y);else if(p.mode===Ci.POINTS)g=new sa(b,y);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+p.mode);Object.keys(g.geometry.morphAttributes).length>0&&yA(g,s),g.name=t.createUniqueName(s.name||"mesh_"+e),ys(g,s),p.extensions&&cr(i,g,p),t.assignFinalMaterial(g),h.push(g)}for(let f=0,m=h.length;f<m;f++)t.associations.set(h[f],{meshes:e,primitives:f});if(h.length===1)return s.extensions&&cr(i,h[0],s),h[0];const u=new Vt;s.extensions&&cr(i,u,s),t.associations.set(u,{meshes:e});for(let f=0,m=h.length;f<m;f++)u.add(h[f]);return u})}loadCamera(e){let t;const n=this.json.cameras[e],i=n[n.type];if(!i){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return n.type==="perspective"?t=new gn(bt.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):n.type==="orthographic"&&(t=new ko(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),ys(t,n),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],n=[];for(let i=0,s=t.joints.length;i<s;i++)n.push(this._loadNodeShallow(t.joints[i]));return t.inverseBindMatrices!==void 0?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then(function(i){const s=i.pop(),a=i,o=[],l=[];for(let c=0,d=a.length;c<d;c++){const h=a[c];if(h){o.push(h);const u=new Ie;s!==null&&u.fromArray(s.array,c*16),l.push(u)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[c])}return new Ro(o,l)})}loadAnimation(e){const t=this.json,n=this,i=t.animations[e],s=i.name?i.name:"animation_"+e,a=[],o=[],l=[],c=[],d=[];for(let h=0,u=i.channels.length;h<u;h++){const f=i.channels[h],m=i.samplers[f.sampler],b=f.target,p=b.node,g=i.parameters!==void 0?i.parameters[m.input]:m.input,y=i.parameters!==void 0?i.parameters[m.output]:m.output;b.node!==void 0&&(a.push(this.getDependency("node",p)),o.push(this.getDependency("accessor",g)),l.push(this.getDependency("accessor",y)),c.push(m),d.push(b))}return Promise.all([Promise.all(a),Promise.all(o),Promise.all(l),Promise.all(c),Promise.all(d)]).then(function(h){const u=h[0],f=h[1],m=h[2],b=h[3],p=h[4],g=[];for(let y=0,x=u.length;y<x;y++){const w=u[y],P=f[y],T=m[y],A=b[y],M=p[y];if(w===void 0)continue;w.updateMatrix&&w.updateMatrix();const _=n._createAnimationTracks(w,P,T,A,M);if(_)for(let S=0;S<_.length;S++)g.push(_[S])}return new Mc(s,void 0,g)})}createNodeMesh(e){const t=this.json,n=this,i=t.nodes[e];return i.mesh===void 0?null:n.getDependency("mesh",i.mesh).then(function(s){const a=n._getNodeRef(n.meshCache,i.mesh,s);return i.weights!==void 0&&a.traverse(function(o){if(o.isMesh)for(let l=0,c=i.weights.length;l<c;l++)o.morphTargetInfluences[l]=i.weights[l]}),a})}loadNode(e){const t=this.json,n=this,i=t.nodes[e],s=n._loadNodeShallow(e),a=[],o=i.children||[];for(let c=0,d=o.length;c<d;c++)a.push(n.getDependency("node",o[c]));const l=i.skin===void 0?Promise.resolve(null):n.getDependency("skin",i.skin);return Promise.all([s,Promise.all(a),l]).then(function(c){const d=c[0],h=c[1],u=c[2];u!==null&&d.traverse(function(f){f.isSkinnedMesh&&f.bind(u,wA)});for(let f=0,m=h.length;f<m;f++)d.add(h[f]);return d})}_loadNodeShallow(e){const t=this.json,n=this.extensions,i=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const s=t.nodes[e],a=s.name?i.createUniqueName(s.name):"",o=[],l=i._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});return l&&o.push(l),s.camera!==void 0&&o.push(i.getDependency("camera",s.camera).then(function(c){return i._getNodeRef(i.cameraCache,s.camera,c)})),i._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 d;if(s.isBone===!0?d=new _o:c.length>1?d=new Vt:c.length===1?d=c[0]:d=new Pt,d!==c[0])for(let h=0,u=c.length;h<u;h++)d.add(c[h]);if(s.name&&(d.userData.name=s.name,d.name=a),ys(d,s),s.extensions&&cr(n,d,s),s.matrix!==void 0){const h=new Ie;h.fromArray(s.matrix),d.applyMatrix4(h)}else s.translation!==void 0&&d.position.fromArray(s.translation),s.rotation!==void 0&&d.quaternion.fromArray(s.rotation),s.scale!==void 0&&d.scale.fromArray(s.scale);return i.associations.has(d)||i.associations.set(d,{}),i.associations.get(d).nodes=e,d}),this.nodeCache[e]}loadScene(e){const t=this.extensions,n=this.json.scenes[e],i=this,s=new Vt;n.name&&(s.name=i.createUniqueName(n.name)),ys(s,n),n.extensions&&cr(t,s,n);const a=n.nodes||[],o=[];for(let l=0,c=a.length;l<c;l++)o.push(i.getDependency("node",a[l]));return Promise.all(o).then(function(l){for(let d=0,h=l.length;d<h;d++)s.add(l[d]);const c=d=>{const h=new Map;for(const[u,f]of i.associations)(u instanceof wi||u instanceof Ut)&&h.set(u,f);return d.traverse(u=>{const f=i.associations.get(u);f!=null&&h.set(u,f)}),h};return i.associations=c(s),s})}_createAnimationTracks(e,t,n,i,s){const a=[],o=e.name?e.name:e.uuid,l=[];Fs[s.path]===Fs.weights?e.traverse(function(u){u.morphTargetInfluences&&l.push(u.name?u.name:u.uuid)}):l.push(o);let c;switch(Fs[s.path]){case Fs.weights:c=Mr;break;case Fs.rotation:c=Ts;break;case Fs.position:case Fs.scale:c=Es;break;default:switch(n.itemSize){case 1:c=Mr;break;case 2:case 3:default:c=Es;break}break}const d=i.interpolation!==void 0?gA[i.interpolation]:yo,h=this._getArrayFromAccessor(n);for(let u=0,f=l.length;u<f;u++){const m=new c(l[u]+"."+Fs[s.path],t.array,h,d);i.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(m),a.push(m)}return a}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const n=Su(t.constructor),i=new Float32Array(t.length);for(let s=0,a=t.length;s<a;s++)i[s]=t[s]*n;t=i}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){const i=this instanceof Ts?mA:iv;return new i(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function MA(r,e,t){const n=e.attributes,i=new Yt;if(n.POSITION!==void 0){const o=t.json.accessors[n.POSITION],l=o.min,c=o.max;if(l!==void 0&&c!==void 0){if(i.set(new I(l[0],l[1],l[2]),new I(c[0],c[1],c[2])),o.normalized){const d=Su(ga[o.componentType]);i.min.multiplyScalar(d),i.max.multiplyScalar(d)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const s=e.targets;if(s!==void 0){const o=new I,l=new I;for(let c=0,d=s.length;c<d;c++){const h=s[c];if(h.POSITION!==void 0){const u=t.json.accessors[h.POSITION],f=u.min,m=u.max;if(f!==void 0&&m!==void 0){if(l.setX(Math.max(Math.abs(f[0]),Math.abs(m[0]))),l.setY(Math.max(Math.abs(f[1]),Math.abs(m[1]))),l.setZ(Math.max(Math.abs(f[2]),Math.abs(m[2]))),u.normalized){const b=Su(ga[u.componentType]);l.multiplyScalar(b)}o.max(l)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}i.expandByVector(o)}r.boundingBox=i;const a=new vn;i.getCenter(a.center),a.radius=i.min.distanceTo(i.max)/2,r.boundingSphere=a}function Dm(r,e,t){const n=e.attributes,i=[];function s(a,o){return t.getDependency("accessor",a).then(function(l){r.setAttribute(o,l)})}for(const a in n){const o=wu[a]||a.toLowerCase();o in r.attributes||i.push(s(n[a],o))}if(e.indices!==void 0&&!r.index){const a=t.getDependency("accessor",e.indices).then(function(o){r.setIndex(o)});i.push(a)}return ft.workingColorSpace!==$n&&"COLOR_0"in n&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${ft.workingColorSpace}" not supported.`),ys(r,e),MA(r,e,t),Promise.all(i).then(function(){return e.targets!==void 0?vA(r,e.targets,t):r})}var TA=(function(){var r="b9H79Tebbbe8Fv9Gbb9Gvuuuuueu9Giuuub9Geueu9Giuuueuikqbeeedddillviebeoweuec:q;iekr;leDo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbeY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVbdE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbiL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtblK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949Wbol79IV9Rbrq:P8Yqdbk;3sezu8Jjjjjbcj;eb9Rgv8Kjjjjbc9:hodnadcefal0mbcuhoaiRbbc:Ge9hmbavaialfgrad9Radz1jjjbhwcj;abad9UhoaicefhldnadTmbaoc;WFbGgocjdaocjd6EhDcbhqinaqae9pmeaDaeaq9RaqaDfae6Egkcsfgocl4cifcd4hxdndndndnaoc9WGgmTmbcbhPcehsawcjdfhzalhHinaraH9Rax6midnaraHaxfgl9RcK6mbczhoinawcj;cbfaogifgoc9WfhOdndndndndnaHaic9WfgAco4fRbbaAci4coG4ciGPlbedibkaO9cb83ibaOcwf9cb83ibxikaOalRblalRbbgAco4gCaCciSgCE86bbaocGfalclfaCfgORbbaAcl4ciGgCaCciSgCE86bbaocVfaOaCfgORbbaAcd4ciGgCaCciSgCE86bbaoc7faOaCfgORbbaAciGgAaAciSgAE86bbaoctfaOaAfgARbbalRbegOco4gCaCciSgCE86bbaoc91faAaCfgARbbaOcl4ciGgCaCciSgCE86bbaoc4faAaCfgARbbaOcd4ciGgCaCciSgCE86bbaoc93faAaCfgARbbaOciGgOaOciSgOE86bbaoc94faAaOfgARbbalRbdgOco4gCaCciSgCE86bbaoc95faAaCfgARbbaOcl4ciGgCaCciSgCE86bbaoc96faAaCfgARbbaOcd4ciGgCaCciSgCE86bbaoc97faAaCfgARbbaOciGgOaOciSgOE86bbaoc98faAaOfgORbbalRbiglco4gAaAciSgAE86bbaoc99faOaAfgORbbalcl4ciGgAaAciSgAE86bbaoc9:faOaAfgORbbalcd4ciGgAaAciSgAE86bbaocufaOaAfgoRbbalciGglalciSglE86bbaoalfhlxdkaOalRbwalRbbgAcl4gCaCcsSgCE86bbaocGfalcwfaCfgORbbaAcsGgAaAcsSgAE86bbaocVfaOaAfgORbbalRbegAcl4gCaCcsSgCE86bbaoc7faOaCfgORbbaAcsGgAaAcsSgAE86bbaoctfaOaAfgORbbalRbdgAcl4gCaCcsSgCE86bbaoc91faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc4faOaAfgORbbalRbigAcl4gCaCcsSgCE86bbaoc93faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc94faOaAfgORbbalRblgAcl4gCaCcsSgCE86bbaoc95faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc96faOaAfgORbbalRbvgAcl4gCaCcsSgCE86bbaoc97faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc98faOaAfgORbbalRbogAcl4gCaCcsSgCE86bbaoc99faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc9:faOaAfgORbbalRbrglcl4gAaAcsSgAE86bbaocufaOaAfgoRbbalcsGglalcsSglE86bbaoalfhlxekaOal8Pbb83bbaOcwfalcwf8Pbb83bbalczfhlkdnaiam9pmbaiczfhoaral9RcL0mekkaiam6mialTmidnakTmbawaPfRbbhOcbhoazhiinaiawcj;cbfaofRbbgAce4cbaAceG9R7aOfgO86bbaiadfhiaocefgoak9hmbkkazcefhzaPcefgPad6hsalhHaPad9hmexvkkcbhlasceGmdxikalaxad2fhCdnakTmbcbhHcehsawcjdfhminaral9Rax6mialTmdalaxfhlawaHfRbbhOcbhoamhiinaiawcj;cbfaofRbbgAce4cbaAceG9R7aOfgO86bbaiadfhiaocefgoak9hmbkamcefhmaHcefgHad6hsaHad9hmbkaChlxikcbhocehsinaral9Rax6mdalTmealaxfhlaocefgoad6hsadao9hmbkaChlxdkcbhlasceGTmekc9:hoxikabaqad2fawcjdfakad2z1jjjb8Aawawcjdfakcufad2fadz1jjjb8Aakaqfhqalmbkc9:hoxekcbc99aral9Radcaadca0ESEhokavcj;ebf8Kjjjjbaok;yzeHu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnaeci9UgrcHfal0mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecjez:jjjjb8AavcUf9cu83ibavc8Wf9cu83ibavcyf9cu83ibavcaf9cu83ibavcKf9cu83ibavczf9cu83ibav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhodnaeTmbcmcsaDceSEhkcbhxcbhmcbhDcbhicbhlindnaoaq9nmbc9:hoxikdndnawRbbgrc;Ve0mbavc;abfalarcl4cu7fcsGcitfgPydlhsaPydbhzdnarcsGgPak9pmbavaiarcu7fcsGcdtfydbaxaPEhraPThPdndnadcd9hmbabaDcetfgHaz87ebaHcdfas87ebaHclfar87ebxekabaDcdtfgHazBdbaHclfasBdbaHcwfarBdbkaxaPfhxavc;abfalcitfgHarBdbaHasBdlavaicdtfarBdbavc;abfalcefcsGglcitfgHazBdbaHarBdlaiaPfhialcefhlxdkdndnaPcsSmbamaPfaPc987fcefhmxekaocefhrao8SbbgPcFeGhHdndnaPcu9mmbarhoxekaocvfhoaHcFbGhHcrhPdninar8SbbgOcFbGaPtaHVhHaOcu9kmearcefhraPcrfgPc8J9hmbxdkkarcefhokaHce4cbaHceG9R7amfhmkdndnadcd9hmbabaDcetfgraz87ebarcdfas87ebarclfam87ebxekabaDcdtfgrazBdbarclfasBdbarcwfamBdbkavc;abfalcitfgramBdbarasBdlavaicdtfamBdbavc;abfalcefcsGglcitfgrazBdbaramBdlaicefhialcefhlxekdnarcpe0mbaxcefgOavaiaqarcsGfRbbgPcl49RcsGcdtfydbaPcz6gHEhravaiaP9RcsGcdtfydbaOaHfgsaPcsGgOEhPaOThOdndnadcd9hmbabaDcetfgzax87ebazcdfar87ebazclfaP87ebxekabaDcdtfgzaxBdbazclfarBdbazcwfaPBdbkavaicdtfaxBdbavc;abfalcitfgzarBdbazaxBdlavaicefgicsGcdtfarBdbavc;abfalcefcsGcitfgzaPBdbazarBdlavaiaHfcsGgicdtfaPBdbavc;abfalcdfcsGglcitfgraxBdbaraPBdlalcefhlaiaOfhiasaOfhxxekaxcbaoRbbgzEgAarc;:eSgrfhsazcsGhCazcl4hXdndnazcs0mbascefhOxekashOavaiaX9RcsGcdtfydbhskdndnaCmbaOcefhxxekaOhxavaiaz9RcsGcdtfydbhOkdndnarTmbaocefhrxekaocdfhrao8SbegHcFeGhPdnaHcu9kmbaocofhAaPcFbGhPcrhodninar8SbbgHcFbGaotaPVhPaHcu9kmearcefhraocrfgoc8J9hmbkaAhrxekarcefhrkaPce4cbaPceG9R7amfgmhAkdndnaXcsSmbarhPxekarcefhPar8SbbgocFeGhHdnaocu9kmbarcvfhsaHcFbGhHcrhodninaP8SbbgrcFbGaotaHVhHarcu9kmeaPcefhPaocrfgoc8J9hmbkashPxekaPcefhPkaHce4cbaHceG9R7amfgmhskdndnaCcsSmbaPhoxekaPcefhoaP8SbbgrcFeGhHdnarcu9kmbaPcvfhOaHcFbGhHcrhrdninao8SbbgPcFbGartaHVhHaPcu9kmeaocefhoarcrfgrc8J9hmbkaOhoxekaocefhokaHce4cbaHceG9R7amfgmhOkdndnadcd9hmbabaDcetfgraA87ebarcdfas87ebarclfaO87ebxekabaDcdtfgraABdbarclfasBdbarcwfaOBdbkavc;abfalcitfgrasBdbaraABdlavaicdtfaABdbavc;abfalcefcsGcitfgraOBdbarasBdlavaicefgicsGcdtfasBdbavc;abfalcdfcsGcitfgraABdbaraOBdlavaiazcz6aXcsSVfgicsGcdtfaOBdbaiaCTaCcsSVfhialcifhlkawcefhwalcsGhlaicsGhiaDcifgDae6mbkkcbc99aoaqSEhokavc;aef8Kjjjjbaok:llevu8Jjjjjbcz9Rhvc9:hodnaecvfal0mbcuhoaiRbbc;:eGc;qe9hmbav9cb83iwaicefhraialfc98fhwdnaeTmbdnadcdSmbcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcdtfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfglBdbaoalBdbaDcefgDae9hmbxdkkcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcetfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfgl87ebaoalBdbaDcefgDae9hmbkkcbc99arawSEhokaok:Lvoeue99dud99eud99dndnadcl9hmbaeTmeindndnabcdfgd8Sbb:Yab8Sbbgi:Ygl:l:tabcefgv8Sbbgo:Ygr:l:tgwJbb;:9cawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai86bbdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad86bbdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad86bbabclfhbaecufgembxdkkaeTmbindndnabclfgd8Ueb:Yab8Uebgi:Ygl:l:tabcdfgv8Uebgo:Ygr:l:tgwJb;:FSawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai87ebdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad87ebdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad87ebabcwfhbaecufgembkkk;siliui99iue99dnaeTmbcbhiabhlindndnJ;Zl81Zalcof8UebgvciV:Y:vgoal8Ueb:YNgrJb;:FSNJbbbZJbbb:;arJbbbb9GEMgw:lJbbb9p9DTmbaw:OhDxekcjjjj94hDkalclf8Uebhqalcdf8UebhkabavcefciGaiVcetfaD87ebdndnaoak:YNgwJb;:FSNJbbbZJbbb:;awJbbbb9GEMgx:lJbbb9p9DTmbax:Ohkxekcjjjj94hkkabavcdfciGaiVcetfak87ebdndnaoaq:YNgoJb;:FSNJbbbZJbbb:;aoJbbbb9GEMgx:lJbbb9p9DTmbax:Ohqxekcjjjj94hqkabavcufciGaiVcetfaq87ebdndnJbbjZararN:tawawN:taoaoN:tgrJbbbbarJbbbb9GE:rJb;:FSNJbbbZMgr:lJbbb9p9DTmbar:Ohqxekcjjjj94hqkabavciGaiVcetfaq87ebalcwfhlaiclfhiaecufgembkkk9mbdnadcd4ae2geTmbinababydbgdcwtcw91:Yadce91cjjj;8ifcjjj98G::NUdbabclfhbaecufgembkkk9teiucbcbydj1jjbgeabcifc98GfgbBdj1jjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaik;LeeeudndnaeabVciGTmbabhixekdndnadcz9pmbabhixekabhiinaiaeydbBdbaiclfaeclfydbBdbaicwfaecwfydbBdbaicxfaecxfydbBdbaiczfhiaeczfheadc9Wfgdcs0mbkkadcl6mbinaiaeydbBdbaeclfheaiclfhiadc98fgdci0mbkkdnadTmbinaiaeRbb86bbaicefhiaecefheadcufgdmbkkabk;aeedudndnabciGTmbabhixekaecFeGc:b:c:ew2hldndnadcz9pmbabhixekabhiinaialBdbaicxfalBdbaicwfalBdbaiclfalBdbaiczfhiadc9Wfgdcs0mbkkadcl6mbinaialBdbaiclfhiadc98fgdci0mbkkdnadTmbinaiae86bbaicefhiadcufgdmbkkabkkkebcjwklz9Kbb",e="b9H79TebbbeKl9Gbb9Gvuuuuueu9Giuuub9Geueuikqbbebeedddilve9Weeeviebeoweuec:q;Aekr;leDo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbdY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVblE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtboK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbrL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949Wbwl79IV9RbDq;t9tqlbzik9:evu8Jjjjjbcz9Rhbcbheincbhdcbhiinabcwfadfaicjuaead4ceGglE86bbaialfhiadcefgdcw9hmbkaec:q:yjjbfai86bbaecitc:q1jjbfab8Piw83ibaecefgecjd9hmbkk;h8JlHud97euo978Jjjjjbcj;kb9Rgv8Kjjjjbc9:hodnadcefal0mbcuhoaiRbbc:Ge9hmbavaialfgrad9Rad;8qbbcj;abad9UhoaicefhldnadTmbaoc;WFbGgocjdaocjd6EhwcbhDinaDae9pmeawaeaD9RaDawfae6Egqcsfgoc9WGgkci2hxakcethmaocl4cifcd4hPabaDad2fhscbhzdnincehHalhOcbhAdninaraO9RaP6miavcj;cbfaAak2fhCaOaPfhlcbhidnakc;ab6mbaral9Rc;Gb6mbcbhoinaCaofhidndndndndnaOaoco4fRbbgXciGPlbedibkaipxbbbbbbbbbbbbbbbbpklbxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklbalczfhlkdndndndndnaXcd4ciGPlbedibkaipxbbbbbbbbbbbbbbbbpklzxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklzalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklzalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklzalczfhlkdndndndndnaXcl4ciGPlbedibkaipxbbbbbbbbbbbbbbbbpklaxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklaalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklaalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklaalczfhlkdndndndndnaXco4Plbedibkaipxbbbbbbbbbbbbbbbbpkl8WxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibaXc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spkl8WalclfaYpQbfaXc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibaXc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spkl8WalcwfaYpQbfaXc:q:yjjbfRbbfhlxekaialpbbbpkl8Walczfhlkaoc;abfhiaocjefak0meaihoaral9Rc;Fb0mbkkdndnaiak9pmbaici4hoinaral9RcK6mdaCaifhXdndndndndnaOaico4fRbbaocoG4ciGPlbedibkaXpxbbbbbbbbbbbbbbbbpklbxikaXalpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaXalpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaXalpbbbpklbalczfhlkaocdfhoaiczfgiak6mbkkalTmbaAci6hHalhOaAcefgohAaoclSmdxekkcbhlaHceGmdkdnakTmbavcjdfazfhiavazfpbdbhYcbhXinaiavcj;cbfaXfgopblbgLcep9TaLpxeeeeeeeeeeeeeeeegQp9op9Hp9rgLaoakfpblbg8Acep9Ta8AaQp9op9Hp9rg8ApmbzeHdOiAlCvXoQrLgEaoamfpblbg3cep9Ta3aQp9op9Hp9rg3aoaxfpblbg5cep9Ta5aQp9op9Hp9rg5pmbzeHdOiAlCvXoQrLg8EpmbezHdiOAlvCXorQLgQaQpmbedibedibedibediaYp9UgYp9AdbbaiadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfgoaYaEa8EpmwDKYqk8AExm35Ps8E8FgQaQpmbedibedibedibedip9UgYp9AdbbaoadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfgoaYaLa8ApmwKDYq8AkEx3m5P8Es8FgLa3a5pmwKDYq8AkEx3m5P8Es8Fg8ApmbezHdiOAlvCXorQLgQaQpmbedibedibedibedip9UgYp9AdbbaoadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfgoaYaLa8ApmwDKYqk8AExm35Ps8E8FgQaQpmbedibedibedibedip9UgYp9AdbbaoadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfhiaXczfgXak6mbkkazclfgzad6mbkasavcjdfaqad2;8qbbavavcjdfaqcufad2fad;8qbbaqaDfhDc9:hoalmexikkc9:hoxekcbc99aral9Radcaadca0ESEhokavcj;kbf8Kjjjjbaokwbz:bjjjbk;uzeHu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnaeci9UgrcHfal0mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecje;8kbavcUf9cu83ibavc8Wf9cu83ibavcyf9cu83ibavcaf9cu83ibavcKf9cu83ibavczf9cu83ibav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhodnaeTmbcmcsaDceSEhkcbhxcbhmcbhDcbhicbhlindnaoaq9nmbc9:hoxikdndnawRbbgrc;Ve0mbavc;abfalarcl4cu7fcsGcitfgPydlhsaPydbhzdnarcsGgPak9pmbavaiarcu7fcsGcdtfydbaxaPEhraPThPdndnadcd9hmbabaDcetfgHaz87ebaHcdfas87ebaHclfar87ebxekabaDcdtfgHazBdbaHclfasBdbaHcwfarBdbkaxaPfhxavc;abfalcitfgHarBdbaHasBdlavaicdtfarBdbavc;abfalcefcsGglcitfgHazBdbaHarBdlaiaPfhialcefhlxdkdndnaPcsSmbamaPfaPc987fcefhmxekaocefhrao8SbbgPcFeGhHdndnaPcu9mmbarhoxekaocvfhoaHcFbGhHcrhPdninar8SbbgOcFbGaPtaHVhHaOcu9kmearcefhraPcrfgPc8J9hmbxdkkarcefhokaHce4cbaHceG9R7amfhmkdndnadcd9hmbabaDcetfgraz87ebarcdfas87ebarclfam87ebxekabaDcdtfgrazBdbarclfasBdbarcwfamBdbkavc;abfalcitfgramBdbarasBdlavaicdtfamBdbavc;abfalcefcsGglcitfgrazBdbaramBdlaicefhialcefhlxekdnarcpe0mbaxcefgOavaiaqarcsGfRbbgPcl49RcsGcdtfydbaPcz6gHEhravaiaP9RcsGcdtfydbaOaHfgsaPcsGgOEhPaOThOdndnadcd9hmbabaDcetfgzax87ebazcdfar87ebazclfaP87ebxekabaDcdtfgzaxBdbazclfarBdbazcwfaPBdbkavaicdtfaxBdbavc;abfalcitfgzarBdbazaxBdlavaicefgicsGcdtfarBdbavc;abfalcefcsGcitfgzaPBdbazarBdlavaiaHfcsGgicdtfaPBdbavc;abfalcdfcsGglcitfgraxBdbaraPBdlalcefhlaiaOfhiasaOfhxxekaxcbaoRbbgzEgAarc;:eSgrfhsazcsGhCazcl4hXdndnazcs0mbascefhOxekashOavaiaX9RcsGcdtfydbhskdndnaCmbaOcefhxxekaOhxavaiaz9RcsGcdtfydbhOkdndnarTmbaocefhrxekaocdfhrao8SbegHcFeGhPdnaHcu9kmbaocofhAaPcFbGhPcrhodninar8SbbgHcFbGaotaPVhPaHcu9kmearcefhraocrfgoc8J9hmbkaAhrxekarcefhrkaPce4cbaPceG9R7amfgmhAkdndnaXcsSmbarhPxekarcefhPar8SbbgocFeGhHdnaocu9kmbarcvfhsaHcFbGhHcrhodninaP8SbbgrcFbGaotaHVhHarcu9kmeaPcefhPaocrfgoc8J9hmbkashPxekaPcefhPkaHce4cbaHceG9R7amfgmhskdndnaCcsSmbaPhoxekaPcefhoaP8SbbgrcFeGhHdnarcu9kmbaPcvfhOaHcFbGhHcrhrdninao8SbbgPcFbGartaHVhHaPcu9kmeaocefhoarcrfgrc8J9hmbkaOhoxekaocefhokaHce4cbaHceG9R7amfgmhOkdndnadcd9hmbabaDcetfgraA87ebarcdfas87ebarclfaO87ebxekabaDcdtfgraABdbarclfasBdbarcwfaOBdbkavc;abfalcitfgrasBdbaraABdlavaicdtfaABdbavc;abfalcefcsGcitfgraOBdbarasBdlavaicefgicsGcdtfasBdbavc;abfalcdfcsGcitfgraABdbaraOBdlavaiazcz6aXcsSVfgicsGcdtfaOBdbaiaCTaCcsSVfhialcifhlkawcefhwalcsGhlaicsGhiaDcifgDae6mbkkcbc99aoaqSEhokavc;aef8Kjjjjbaok:llevu8Jjjjjbcz9Rhvc9:hodnaecvfal0mbcuhoaiRbbc;:eGc;qe9hmbav9cb83iwaicefhraialfc98fhwdnaeTmbdnadcdSmbcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcdtfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfglBdbaoalBdbaDcefgDae9hmbxdkkcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcetfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfgl87ebaoalBdbaDcefgDae9hmbkkcbc99arawSEhokaok:EPliuo97eue978Jjjjjbca9Rhidndnadcl9hmbdnaec98GglTmbcbhvabhdinadadpbbbgocKp:RecKp:Sep;6egraocwp:RecKp:Sep;6earp;Geaoczp:RecKp:Sep;6egwp;Gep;Kep;LegDpxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgkp9op9rp;Kegrpxbb;:9cbb;:9cbb;:9cbb;:9cararp;MeaDaDp;Meawaqawakp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFbbbFbbbFbbbFbbbp9oaopxbbbFbbbFbbbFbbbFp9op9qarawp;Meaqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaDawp;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpkbbadczfhdavclfgval6mbkkalae9pmeaiaeciGgvcdtgdVcbczad9R;8kbaiabalcdtfglad;8qbbdnavTmbaiaipblbgocKp:RecKp:Sep;6egraocwp:RecKp:Sep;6earp;Geaoczp:RecKp:Sep;6egwp;Gep;Kep;LegDpxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgkp9op9rp;Kegrpxbb;:9cbb;:9cbb;:9cbb;:9cararp;MeaDaDp;Meawaqawakp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFbbbFbbbFbbbFbbbp9oaopxbbbFbbbFbbbFbbbFp9op9qarawp;Meaqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaDawp;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpklbkalaiad;8qbbskdnaec98GgxTmbcbhvabhdinadczfglalpbbbgopxbbbbbbFFbbbbbbFFgkp9oadpbbbgDaopmlvorxmPsCXQL358E8FpxFubbFubbFubbFubbp9op;6eaDaopmbediwDqkzHOAKY8AEgoczp:Sep;6egrp;Geaoczp:Reczp:Sep;6egwp;Gep;Kep;Legopxb;:FSb;:FSb;:FSb;:FSawaopxbbbbbbbbbbbbbbbbp:2egqawpxbbbjbbbjbbbjbbbjgmp9op9rp;Kegwawp;Meaoaop;Mearaqaramp9op9rp;Kegoaop;Mep;Kep;Kep;Jep;Negrp;Mepxbbn0bbn0bbn0bbn0gqp;Keczp:Reawarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9op9qgwaoarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9ogopmwDKYqk8AExm35Ps8E8Fp9qpkbbadaDakp9oawaopmbezHdiOAlvCXorQLp9qpkbbadcafhdavclfgvax6mbkkaxae9pmbaiaeciGgvcitgdfcbcaad9R;8kbaiabaxcitfglad;8qbbdnavTmbaiaipblzgopxbbbbbbFFbbbbbbFFgkp9oaipblbgDaopmlvorxmPsCXQL358E8FpxFubbFubbFubbFubbp9op;6eaDaopmbediwDqkzHOAKY8AEgoczp:Sep;6egrp;Geaoczp:Reczp:Sep;6egwp;Gep;Kep;Legopxb;:FSb;:FSb;:FSb;:FSawaopxbbbbbbbbbbbbbbbbp:2egqawpxbbbjbbbjbbbjbbbjgmp9op9rp;Kegwawp;Meaoaop;Mearaqaramp9op9rp;Kegoaop;Mep;Kep;Kep;Jep;Negrp;Mepxbbn0bbn0bbn0bbn0gqp;Keczp:Reawarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9op9qgwaoarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9ogopmwDKYqk8AExm35Ps8E8Fp9qpklzaiaDakp9oawaopmbezHdiOAlvCXorQLp9qpklbkalaiad;8qbbkk;4wllue97euv978Jjjjjbc8W9Rhidnaec98GglTmbcbhvabhoinaiaopbbbgraoczfgwpbbbgDpmlvorxmPsCXQL358E8Fgqczp:Segkclp:RepklbaopxbbjZbbjZbbjZbbjZpx;Zl81Z;Zl81Z;Zl81Z;Zl81Zakpxibbbibbbibbbibbbp9qp;6ep;NegkaraDpmbediwDqkzHOAKY8AEgrczp:Reczp:Sep;6ep;MegDaDp;Meakarczp:Sep;6ep;Megxaxp;Meakaqczp:Reczp:Sep;6ep;Megqaqp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jepxb;:FSb;:FSb;:FSb;:FSgkp;Mepxbbn0bbn0bbn0bbn0grp;KepxFFbbFFbbFFbbFFbbgmp9oaxakp;Mearp;Keczp:Rep9qgxaqakp;Mearp;Keczp:ReaDakp;Mearp;Keamp9op9qgkpmbezHdiOAlvCXorQLgrp5baipblbpEb:T:j83ibaocwfarp5eaipblbpEe:T:j83ibawaxakpmwDKYqk8AExm35Ps8E8Fgkp5baipblbpEd:T:j83ibaocKfakp5eaipblbpEi:T:j83ibaocafhoavclfgval6mbkkdnalae9pmbaiaeciGgvcitgofcbcaao9R;8kbaiabalcitfgwao;8qbbdnavTmbaiaipblbgraipblzgDpmlvorxmPsCXQL358E8Fgqczp:Segkclp:RepklaaipxbbjZbbjZbbjZbbjZpx;Zl81Z;Zl81Z;Zl81Z;Zl81Zakpxibbbibbbibbbibbbp9qp;6ep;NegkaraDpmbediwDqkzHOAKY8AEgrczp:Reczp:Sep;6ep;MegDaDp;Meakarczp:Sep;6ep;Megxaxp;Meakaqczp:Reczp:Sep;6ep;Megqaqp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jepxb;:FSb;:FSb;:FSb;:FSgkp;Mepxbbn0bbn0bbn0bbn0grp;KepxFFbbFFbbFFbbFFbbgmp9oaxakp;Mearp;Keczp:Rep9qgxaqakp;Mearp;Keczp:ReaDakp;Mearp;Keamp9op9qgkpmbezHdiOAlvCXorQLgrp5baipblapEb:T:j83ibaiarp5eaipblapEe:T:j83iwaiaxakpmwDKYqk8AExm35Ps8E8Fgkp5baipblapEd:T:j83izaiakp5eaipblapEi:T:j83iKkawaiao;8qbbkk:Pddiue978Jjjjjbc;ab9Rhidnadcd4ae2glc98GgvTmbcbhdabheinaeaepbbbgocwp:Recwp:Sep;6eaocep:SepxbbjZbbjZbbjZbbjZp:UepxbbjFbbjFbbjFbbjFp9op;Mepkbbaeczfheadclfgdav6mbkkdnaval9pmbaialciGgdcdtgeVcbc;abae9R;8kbaiabavcdtfgvae;8qbbdnadTmbaiaipblbgocwp:Recwp:Sep;6eaocep:SepxbbjZbbjZbbjZbbjZp:UepxbbjFbbjFbbjFbbjFp9op;Mepklbkavaiae;8qbbkk9teiucbcbydj1jjbgeabcifc98GfgbBdj1jjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaikkkebcjwklz9Tbb",t=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]),n=new Uint8Array([32,0,65,2,1,106,34,33,3,128,11,4,13,64,6,253,10,7,15,116,127,5,8,12,40,16,19,54,20,9,27,255,113,17,42,67,24,23,146,148,18,14,22,45,70,69,56,114,101,21,25,63,75,136,108,28,118,29,73,115]);if(typeof WebAssembly!="object")return{supported:!1};var i=WebAssembly.validate(t)?e:r,s,a=WebAssembly.instantiate(o(i),{}).then(function(g){s=g.instance,s.exports.__wasm_call_ctors()});function o(g){for(var y=new Uint8Array(g.length),x=0;x<g.length;++x){var w=g.charCodeAt(x);y[x]=w>96?w-97:w>64?w-39:w+4}for(var P=0,x=0;x<g.length;++x)y[P++]=y[x]<60?n[y[x]]:(y[x]-60)*64+y[++x];return y.buffer.slice(0,P)}function l(g,y,x,w,P,T){var A=s.exports.sbrk,M=x+3&-4,_=A(M*w),S=A(P.length),R=new Uint8Array(s.exports.memory.buffer);R.set(P,S);var k=g(_,x,w,S,P.length);if(k==0&&T&&T(_,M,w),y.set(R.subarray(_,_+x*w)),A(_-A(0)),k!=0)throw new Error("Malformed buffer data: "+k)}var c={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},d={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"},h=[],u=0;function f(g){var y={object:new Worker(g),pending:0,requests:{}};return y.object.onmessage=function(x){var w=x.data;y.pending-=w.count,y.requests[w.id][w.action](w.value),delete y.requests[w.id]},y}function m(g){for(var y="var instance; var ready = WebAssembly.instantiate(new Uint8Array(["+new Uint8Array(o(i))+"]), {}).then(function(result) { instance = result.instance; instance.exports.__wasm_call_ctors(); });self.onmessage = workerProcess;"+l.toString()+p.toString(),x=new Blob([y],{type:"text/javascript"}),w=URL.createObjectURL(x),P=0;P<g;++P)h[P]=f(w);URL.revokeObjectURL(w)}function b(g,y,x,w,P){for(var T=h[0],A=1;A<h.length;++A)h[A].pending<T.pending&&(T=h[A]);return new Promise(function(M,_){var S=new Uint8Array(x),R=u++;T.pending+=g,T.requests[R]={resolve:M,reject:_},T.object.postMessage({id:R,count:g,size:y,source:S,mode:w,filter:P},[S.buffer])})}function p(g){a.then(function(){var y=g.data;try{var x=new Uint8Array(y.count*y.size);l(s.exports[y.mode],x,y.count,y.size,y.source,s.exports[y.filter]),self.postMessage({id:y.id,count:y.count,action:"resolve",value:x},[x.buffer])}catch(w){self.postMessage({id:y.id,count:y.count,action:"reject",value:w})}})}return{ready:a,supported:!0,useWorkers:function(g){m(g)},decodeVertexBuffer:function(g,y,x,w,P){l(s.exports.meshopt_decodeVertexBuffer,g,y,x,w,s.exports[c[P]])},decodeIndexBuffer:function(g,y,x,w){l(s.exports.meshopt_decodeIndexBuffer,g,y,x,w)},decodeIndexSequence:function(g,y,x,w){l(s.exports.meshopt_decodeIndexSequence,g,y,x,w)},decodeGltfBuffer:function(g,y,x,w,P,T){l(s.exports[d[P]],g,y,x,w,s.exports[c[T]])},decodeGltfBufferAsync:function(g,y,x,w,P){return h.length>0?b(g,y,x,d[w],c[P]):a.then(function(){var T=new Uint8Array(g*y);return l(s.exports[d[w]],T,g,y,x,s.exports[c[P]]),T})}}})();let Wl=null;const EA=()=>(Wl||(Wl=new Oo,Wl.setDecoderPath(Hn("/draco/"))),Wl);function AA(r){const e=new Ar(r);return e.setDRACOLoader(EA()),e.setMeshoptDecoder(TA),e}const CA=["/gaia/"],Lm=r=>{const e=new Fn;return"color"in r&&r.color instanceof Ne&&e.color.copy(r.color),"map"in r&&r.map instanceof Ut&&(e.map=r.map),"transparent"in r&&(e.transparent=r.transparent),"opacity"in r&&(e.opacity=r.opacity),"side"in r&&(e.side=r.side),e},PA=r=>{r.traverse(e=>{e instanceof Ee&&(Array.isArray(e.material)?e.material=e.material.map(Lm):e.material=Lm(e.material))})},RA=r=>{const e=r.toLowerCase();return CA.some(t=>e.includes(t))},sv=(r,e,t)=>{if(/\.(gltf|glb)(\?|#|$)/i.test(r)){AA(e).load(r,i=>{const s=i.scene??new Vt;RA(r)&&PA(s),t(s)},void 0,i=>{console.warn("GLTF load error:",r,i),t(new Vt)});return}if(/\.stl(\?|#|$)/i.test(r)){new Qb(e).load(r,i=>{const s=new Ee(i,new Bc({color:8421504}));t(s)},void 0,i=>{console.warn("STL load error:",r,i),t(new Vt)});return}if(/\.dae(\?|#|$)/i.test(r)){new Jb(e).load(r,i=>{const s=i.scene??i;s.rotation.set(0,0,0),s.traverse(a=>{a.isMesh}),t(s)},void 0,i=>{console.warn("DAE load error:",r,i),t(new Vt)});return}console.warn(`URDFLoader: no loader for ${r}`),t(new Vt)},Im={type:"change"},rf={type:"start"},rv={type:"end"},jl=new Aa,km=new ns,NA=Math.cos(70*bt.DEG2RAD),_n=new I,li=2*Math.PI,Wt={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Zd=1e-6;class DA extends Vb{constructor(e,t=null){super(e,t),this.state=Wt.NONE,this.enabled=!0,this.target=new I,this.cursor=new I,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:xr.ROTATE,MIDDLE:xr.DOLLY,RIGHT:xr.PAN},this.touches={ONE:Gs.ROTATE,TWO:Gs.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new I,this._lastQuaternion=new Lt,this._lastTargetPosition=new I,this._quat=new Lt().setFromUnitVectors(e.up,new I(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new Rp,this._sphericalDelta=new Rp,this._scale=1,this._panOffset=new I,this._rotateStart=new me,this._rotateEnd=new me,this._rotateDelta=new me,this._panStart=new me,this._panEnd=new me,this._panDelta=new me,this._dollyStart=new me,this._dollyEnd=new me,this._dollyDelta=new me,this._dollyDirection=new I,this._mouse=new me,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=IA.bind(this),this._onPointerDown=LA.bind(this),this._onPointerUp=kA.bind(this),this._onContextMenu=GA.bind(this),this._onMouseWheel=UA.bind(this),this._onKeyDown=BA.bind(this),this._onTouchStart=zA.bind(this),this._onTouchMove=HA.bind(this),this._onMouseDown=OA.bind(this),this._onMouseMove=FA.bind(this),this._interceptControlDown=VA.bind(this),this._interceptControlUp=WA.bind(this),this.domElement!==null&&this.connect(),this.update()}connect(){this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(Im),this.update(),this.state=Wt.NONE}update(e=null){const t=this.object.position;_n.copy(t).sub(this.target),_n.applyQuaternion(this._quat),this._spherical.setFromVector3(_n),this.autoRotate&&this.state===Wt.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let n=this.minAzimuthAngle,i=this.maxAzimuthAngle;isFinite(n)&&isFinite(i)&&(n<-Math.PI?n+=li:n>Math.PI&&(n-=li),i<-Math.PI?i+=li:i>Math.PI&&(i-=li),n<=i?this._spherical.theta=Math.max(n,Math.min(i,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+i)/2?Math.max(n,this._spherical.theta):Math.min(i,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let s=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const a=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),s=a!=this._spherical.radius}if(_n.setFromSpherical(this._spherical),_n.applyQuaternion(this._quatInverse),t.copy(this.target).add(_n),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let a=null;if(this.object.isPerspectiveCamera){const o=_n.length();a=this._clampDistance(o*this._scale);const l=o-a;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),s=!!l}else if(this.object.isOrthographicCamera){const o=new I(this._mouse.x,this._mouse.y,0);o.unproject(this.object);const l=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),s=l!==this.object.zoom;const c=new I(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(o),this.object.updateMatrixWorld(),a=_n.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;a!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(a).add(this.object.position):(jl.origin.copy(this.object.position),jl.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(jl.direction))<NA?this.object.lookAt(this.target):(km.setFromNormalAndCoplanarPoint(this.object.up,this.target),jl.intersectPlane(km,this.target))))}else if(this.object.isOrthographicCamera){const a=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),a!==this.object.zoom&&(this.object.updateProjectionMatrix(),s=!0)}return this._scale=1,this._performCursorZoom=!1,s||this._lastPosition.distanceToSquared(this.object.position)>Zd||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Zd||this._lastTargetPosition.distanceToSquared(this.target)>Zd?(this.dispatchEvent(Im),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?li/60*this.autoRotateSpeed*e:li/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){_n.setFromMatrixColumn(t,0),_n.multiplyScalar(-e),this._panOffset.add(_n)}_panUp(e,t){this.screenSpacePanning===!0?_n.setFromMatrixColumn(t,1):(_n.setFromMatrixColumn(t,0),_n.crossVectors(this.object.up,_n)),_n.multiplyScalar(e),this._panOffset.add(_n)}_pan(e,t){const n=this.domElement;if(this.object.isPerspectiveCamera){const i=this.object.position;_n.copy(i).sub(this.target);let s=_n.length();s*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*s/n.clientHeight,this.object.matrix),this._panUp(2*t*s/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const n=this.domElement.getBoundingClientRect(),i=e-n.left,s=t-n.top,a=n.width,o=n.height;this._mouse.x=i/a*2-1,this._mouse.y=-(s/o)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(li*this._rotateDelta.x/t.clientHeight),this._rotateUp(li*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(li*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-li*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(li*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-li*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);this._rotateStart.set(n,i)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);this._panStart.set(n,i)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,i=e.pageY-t.y,s=Math.sqrt(n*n+i*i);this._dollyStart.set(0,s)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),i=.5*(e.pageX+n.x),s=.5*(e.pageY+n.y);this._rotateEnd.set(i,s)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(li*this._rotateDelta.x/t.clientHeight),this._rotateUp(li*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);this._panEnd.set(n,i)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,i=e.pageY-t.y,s=Math.sqrt(n*n+i*i);this._dollyEnd.set(0,s),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const a=(e.pageX+t.x)*.5,o=(e.pageY+t.y)*.5;this._updateZoomParameters(a,o)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new me,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){const t=e.deltaMode,n={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(n.deltaY*=10),n}}function LA(r){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(r.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(r)&&(this._addPointer(r),r.pointerType==="touch"?this._onTouchStart(r):this._onMouseDown(r)))}function IA(r){this.enabled!==!1&&(r.pointerType==="touch"?this._onTouchMove(r):this._onMouseMove(r))}function kA(r){switch(this._removePointer(r),this._pointers.length){case 0:this.domElement.releasePointerCapture(r.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(rv),this.state=Wt.NONE;break;case 1:const e=this._pointers[0],t=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:t.x,pageY:t.y});break}}function OA(r){let e;switch(r.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case xr.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(r),this.state=Wt.DOLLY;break;case xr.ROTATE:if(r.ctrlKey||r.metaKey||r.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(r),this.state=Wt.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(r),this.state=Wt.ROTATE}break;case xr.PAN:if(r.ctrlKey||r.metaKey||r.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(r),this.state=Wt.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(r),this.state=Wt.PAN}break;default:this.state=Wt.NONE}this.state!==Wt.NONE&&this.dispatchEvent(rf)}function FA(r){switch(this.state){case Wt.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(r);break;case Wt.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(r);break;case Wt.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(r);break}}function UA(r){this.enabled===!1||this.enableZoom===!1||this.state!==Wt.NONE||(r.preventDefault(),this.dispatchEvent(rf),this._handleMouseWheel(this._customWheelEvent(r)),this.dispatchEvent(rv))}function BA(r){this.enabled!==!1&&this._handleKeyDown(r)}function zA(r){switch(this._trackPointer(r),this._pointers.length){case 1:switch(this.touches.ONE){case Gs.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(r),this.state=Wt.TOUCH_ROTATE;break;case Gs.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(r),this.state=Wt.TOUCH_PAN;break;default:this.state=Wt.NONE}break;case 2:switch(this.touches.TWO){case Gs.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(r),this.state=Wt.TOUCH_DOLLY_PAN;break;case Gs.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(r),this.state=Wt.TOUCH_DOLLY_ROTATE;break;default:this.state=Wt.NONE}break;default:this.state=Wt.NONE}this.state!==Wt.NONE&&this.dispatchEvent(rf)}function HA(r){switch(this._trackPointer(r),this.state){case Wt.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(r),this.update();break;case Wt.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(r),this.update();break;case Wt.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(r),this.update();break;case Wt.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(r),this.update();break;default:this.state=Wt.NONE}}function GA(r){this.enabled!==!1&&r.preventDefault()}function VA(r){r.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function WA(r){r.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}const jA=`
|
|
4231
4231
|
varying vec3 worldPosition;
|
|
@@ -4386,24 +4386,24 @@ fflate - fast JavaScript compression/decompression
|
|
|
4386
4386
|
<https://101arrowz.github.io/fflate>
|
|
4387
4387
|
Licensed under MIT. https://github.com/101arrowz/fflate/blob/master/LICENSE
|
|
4388
4388
|
version 0.8.2
|
|
4389
|
-
*/var Di=Uint8Array,la=Uint16Array,w1=Int32Array,ov=new Di([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]),lv=new Di([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]),S1=new Di([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),cv=function(r,e){for(var t=new la(31),n=0;n<31;++n)t[n]=e+=1<<r[n-1];for(var i=new w1(t[30]),n=1;n<30;++n)for(var s=t[n];s<t[n+1];++s)i[s]=s-t[n]<<5|n;return{b:t,r:i}},dv=cv(ov,2),hv=dv.b,M1=dv.r;hv[28]=258,M1[258]=28;var T1=cv(lv,0),E1=T1.b,Mu=new la(32768);for(var en=0;en<32768;++en){var Us=(en&43690)>>1|(en&21845)<<1;Us=(Us&52428)>>2|(Us&13107)<<2,Us=(Us&61680)>>4|(Us&3855)<<4,Mu[en]=((Us&65280)>>8|(Us&255)<<8)>>1}var po=(function(r,e,t){for(var n=r.length,i=0,s=new la(e);i<n;++i)r[i]&&++s[r[i]-1];var a=new la(e);for(i=1;i<e;++i)a[i]=a[i-1]+s[i-1]<<1;var o;if(t){o=new la(1<<e);var l=15-e;for(i=0;i<n;++i)if(r[i])for(var c=i<<4|r[i],d=e-r[i],h=a[r[i]-1]++<<d,u=h|(1<<d)-1;h<=u;++h)o[Mu[h]>>l]=c}else for(o=new la(n),i=0;i<n;++i)r[i]&&(o[i]=Mu[a[r[i]-1]++]>>15-r[i]);return o}),Fo=new Di(288);for(var en=0;en<144;++en)Fo[en]=8;for(var en=144;en<256;++en)Fo[en]=9;for(var en=256;en<280;++en)Fo[en]=7;for(var en=280;en<288;++en)Fo[en]=8;var uv=new Di(32);for(var en=0;en<32;++en)uv[en]=5;var A1=po(Fo,9,1),C1=po(uv,5,1),Qd=function(r){for(var e=r[0],t=1;t<r.length;++t)r[t]>e&&(e=r[t]);return e},Hi=function(r,e,t){var n=e/8|0;return(r[n]|r[n+1]<<8)>>(e&7)&t},Jd=function(r,e){var t=e/8|0;return(r[t]|r[t+1]<<8|r[t+2]<<16)>>(e&7)},P1=function(r){return(r+7)/8|0},R1=function(r,e,t){return(t==null||t>r.length)&&(t=r.length),new Di(r.subarray(e,t))},N1=["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"],Vi=function(r,e,t){var n=new Error(e||N1[r]);if(n.code=r,Error.captureStackTrace&&Error.captureStackTrace(n,Vi),!t)throw n;return n},D1=function(r,e,t,n){var i=r.length,s=0;if(!i||e.f&&!e.l)return t||new Di(0);var a=!t,o=a||e.i!=2,l=e.i;a&&(t=new Di(i*3));var c=function(Ce){var je=t.length;if(Ce>je){var Fe=new Di(Math.max(je*2,Ce));Fe.set(t),t=Fe}},d=e.f||0,h=e.p||0,u=e.b||0,f=e.l,m=e.d,b=e.m,p=e.n,g=i*8;do{if(!f){d=Hi(r,h,1);var y=Hi(r,h+1,3);if(h+=3,y)if(y==1)f=A1,m=C1,b=9,p=5;else if(y==2){var T=Hi(r,h,31)+257,A=Hi(r,h+10,15)+4,M=T+Hi(r,h+5,31)+1;h+=14;for(var _=new Di(M),S=new Di(19),R=0;R<A;++R)S[S1[R]]=Hi(r,h+R*3,7);h+=A*3;for(var k=Qd(S),O=(1<<k)-1,H=po(S,k,1),R=0;R<M;){var q=H[Hi(r,h,O)];h+=q&15;var x=q>>4;if(x<16)_[R++]=x;else{var G=0,K=0;for(x==16?(K=3+Hi(r,h,3),h+=2,G=_[R-1]):x==17?(K=3+Hi(r,h,7),h+=3):x==18&&(K=11+Hi(r,h,127),h+=7);K--;)_[R++]=G}}var V=_.subarray(0,T),Z=_.subarray(T);b=Qd(V),p=Qd(Z),f=po(V,b,1),m=po(Z,p,1)}else Vi(1);else{var x=P1(h)+4,w=r[x-4]|r[x-3]<<8,P=x+w;if(P>i){l&&Vi(0);break}o&&c(u+w),t.set(r.subarray(x,P),u),e.b=u+=w,e.p=h=P*8,e.f=d;continue}if(h>g){l&&Vi(0);break}}o&&c(u+131072);for(var le=(1<<b)-1,se=(1<<p)-1,ge=h;;ge=h){var G=f[Jd(r,h)&le],de=G>>4;if(h+=G&15,h>g){l&&Vi(0);break}if(G||Vi(2),de<256)t[u++]=de;else if(de==256){ge=h,f=null;break}else{var X=de-254;if(de>264){var R=de-257,ee=ov[R];X=Hi(r,h,(1<<ee)-1)+hv[R],h+=ee}var ie=m[Jd(r,h)&se],Y=ie>>4;ie||Vi(3),h+=ie&15;var Z=E1[Y];if(Y>3){var ee=lv[Y];Z+=Jd(r,h)&(1<<ee)-1,h+=ee}if(h>g){l&&Vi(0);break}o&&c(u+131072);var ue=u+X;if(u<Z){var oe=s-Z,be=Math.min(Z,ue);for(oe+u<0&&Vi(3);u<be;++u)t[u]=n[oe+u]}for(;u<ue;++u)t[u]=t[u-Z]}}e.l=f,e.p=ge,e.b=u,e.f=d,f&&(d=1,e.m=b,e.d=m,e.n=p)}while(!d);return u!=t.length&&a?R1(t,0,u):t.subarray(0,u)},L1=new Di(0),I1=function(r,e){return((r[0]&15)!=8||r[0]>>4>7||(r[0]<<8|r[1])%31)&&Vi(6,"invalid zlib data"),(r[1]>>5&1)==1&&Vi(6,"invalid zlib data: "+(r[1]&32?"need":"unexpected")+" dictionary"),(r[1]>>3&4)+2};function k1(r,e){return D1(r.subarray(I1(r),-4),{i:2},e,e)}var O1=typeof TextDecoder<"u"&&new TextDecoder,F1=0;try{O1.decode(L1,{stream:!0}),F1=1}catch{}function fv(r,e,t){const n=t.length-r-1;if(e>=t[n])return n-1;if(e<=t[r])return r;let i=r,s=n,a=Math.floor((i+s)/2);for(;e<t[a]||e>=t[a+1];)e<t[a]?s=a:i=a,a=Math.floor((i+s)/2);return a}function U1(r,e,t,n){const i=[],s=[],a=[];i[0]=1;for(let o=1;o<=t;++o){s[o]=e-n[r+1-o],a[o]=n[r+o]-e;let l=0;for(let c=0;c<o;++c){const d=a[c+1],h=s[o-c],u=i[c]/(d+h);i[c]=l+d*u,l=h*u}i[o]=l}return i}function B1(r,e,t,n){const i=fv(r,n,e),s=U1(i,n,r,e),a=new _t(0,0,0,0);for(let o=0;o<=r;++o){const l=t[i-r+o],c=s[o],d=l.w*c;a.x+=l.x*d,a.y+=l.y*d,a.z+=l.z*d,a.w+=l.w*c}return a}function z1(r,e,t,n,i){const s=[];for(let h=0;h<=t;++h)s[h]=0;const a=[];for(let h=0;h<=n;++h)a[h]=s.slice(0);const o=[];for(let h=0;h<=t;++h)o[h]=s.slice(0);o[0][0]=1;const l=s.slice(0),c=s.slice(0);for(let h=1;h<=t;++h){l[h]=e-i[r+1-h],c[h]=i[r+h]-e;let u=0;for(let f=0;f<h;++f){const m=c[f+1],b=l[h-f];o[h][f]=m+b;const p=o[f][h-1]/o[h][f];o[f][h]=u+m*p,u=b*p}o[h][h]=u}for(let h=0;h<=t;++h)a[0][h]=o[h][t];for(let h=0;h<=t;++h){let u=0,f=1;const m=[];for(let b=0;b<=t;++b)m[b]=s.slice(0);m[0][0]=1;for(let b=1;b<=n;++b){let p=0;const g=h-b,y=t-b;h>=b&&(m[f][0]=m[u][0]/o[y+1][g],p=m[f][0]*o[g][y]);const x=g>=-1?1:-g,w=h-1<=y?b-1:t-h;for(let T=x;T<=w;++T)m[f][T]=(m[u][T]-m[u][T-1])/o[y+1][g+T],p+=m[f][T]*o[g+T][y];h<=y&&(m[f][b]=-m[u][b-1]/o[y+1][h],p+=m[f][b]*o[h][y]),a[b][h]=p;const P=u;u=f,f=P}}let d=t;for(let h=1;h<=n;++h){for(let u=0;u<=t;++u)a[h][u]*=d;d*=t-h}return a}function H1(r,e,t,n,i){const s=i<r?i:r,a=[],o=fv(r,n,e),l=z1(o,n,r,s,e),c=[];for(let d=0;d<t.length;++d){const h=t[d].clone(),u=h.w;h.x*=u,h.y*=u,h.z*=u,c[d]=h}for(let d=0;d<=s;++d){const h=c[o-r].clone().multiplyScalar(l[d][0]);for(let u=1;u<=r;++u)h.add(c[o-r+u].clone().multiplyScalar(l[d][u]));a[d]=h}for(let d=s+1;d<=i+1;++d)a[d]=new _t(0,0,0);return a}function G1(r,e){let t=1;for(let i=2;i<=r;++i)t*=i;let n=1;for(let i=2;i<=e;++i)n*=i;for(let i=2;i<=r-e;++i)n*=i;return t/n}function V1(r){const e=r.length,t=[],n=[];for(let s=0;s<e;++s){const a=r[s];t[s]=new I(a.x,a.y,a.z),n[s]=a.w}const i=[];for(let s=0;s<e;++s){const a=t[s].clone();for(let o=1;o<=s;++o)a.sub(i[s-o].clone().multiplyScalar(G1(s,o)*n[o]));i[s]=a.divideScalar(n[0])}return i}function W1(r,e,t,n,i){const s=H1(r,e,t,n,i);return V1(s)}class j1 extends Yi{constructor(e,t,n,i,s){super();const a=t?t.length-1:0,o=n?n.length:0;this.degree=e,this.knots=t,this.controlPoints=[],this.startKnot=i||0,this.endKnot=s||a;for(let l=0;l<o;++l){const c=n[l];this.controlPoints[l]=new _t(c.x,c.y,c.z,c.w)}}getPoint(e,t=new I){const n=t,i=this.knots[this.startKnot]+e*(this.knots[this.endKnot]-this.knots[this.startKnot]),s=B1(this.degree,this.knots,this.controlPoints,i);return s.w!==1&&s.divideScalar(s.w),n.set(s.x,s.y,s.z)}getTangent(e,t=new I){const n=t,i=this.knots[0]+e*(this.knots[this.knots.length-1]-this.knots[0]),s=W1(this.degree,this.knots,this.controlPoints,i,1);return n.copy(s[1]).normalize(),n}toJSON(){const e=super.toJSON();return e.degree=this.degree,e.knots=[...this.knots],e.controlPoints=this.controlPoints.map(t=>t.toArray()),e.startKnot=this.startKnot,e.endKnot=this.endKnot,e}fromJSON(e){return super.fromJSON(e),this.degree=e.degree,this.knots=[...e.knots],this.controlPoints=e.controlPoints.map(t=>new _t(t[0],t[1],t[2],t[3])),this.startKnot=e.startKnot,this.endKnot=e.endKnot,this}}let Tt,un,ti;class X1 extends pi{constructor(e){super(e)}load(e,t,n,i){const s=this,a=s.path===""?qs.extractUrlBase(e):s.path,o=new Ys(this.manager);o.setPath(s.path),o.setResponseType("arraybuffer"),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(e,function(l){try{t(s.parse(l,a))}catch(c){i?i(c):console.error(c),s.manager.itemError(e)}},n,i)}parse(e,t){if(Q1(e))Tt=new $1().parse(e);else{const i=gv(e);if(!J1(i))throw new Error("THREE.FBXLoader: Unknown format.");if(Bm(i)<7e3)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+Bm(i));Tt=new K1().parse(i)}const n=new Lo(this.manager).setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin);return new q1(n,this.manager).parse(Tt)}}class q1{constructor(e,t){this.textureLoader=e,this.manager=t}parse(){un=this.parseConnections();const e=this.parseImages(),t=this.parseTextures(e),n=this.parseMaterials(t),i=this.parseDeformers(),s=new Z1().parse(i);return this.parseScene(i,s,n),ti}parseConnections(){const e=new Map;return"Connections"in Tt&&Tt.Connections.connections.forEach(function(n){const i=n[0],s=n[1],a=n[2];e.has(i)||e.set(i,{parents:[],children:[]});const o={ID:s,relationship:a};e.get(i).parents.push(o),e.has(s)||e.set(s,{parents:[],children:[]});const l={ID:i,relationship:a};e.get(s).children.push(l)}),e}parseImages(){const e={},t={};if("Video"in Tt.Objects){const n=Tt.Objects.Video;for(const i in n){const s=n[i],a=parseInt(i);if(e[a]=s.RelativeFilename||s.Filename,"Content"in s){const o=s.Content instanceof ArrayBuffer&&s.Content.byteLength>0,l=typeof s.Content=="string"&&s.Content!=="";if(o||l){const c=this.parseImage(n[i]);t[s.RelativeFilename||s.Filename]=c}}}}for(const n in e){const i=e[n];t[i]!==void 0?e[n]=t[i]:e[n]=e[n].split("\\").pop()}return e}parseImage(e){const t=e.Content,n=e.RelativeFilename||e.Filename,i=n.slice(n.lastIndexOf(".")+1).toLowerCase();let s;switch(i){case"bmp":s="image/bmp";break;case"jpg":case"jpeg":s="image/jpeg";break;case"png":s="image/png";break;case"tif":s="image/tiff";break;case"tga":this.manager.getHandler(".tga")===null&&console.warn("FBXLoader: TGA loader not found, skipping ",n),s="image/tga";break;default:console.warn('FBXLoader: Image type "'+i+'" is not supported.');return}if(typeof t=="string")return"data:"+s+";base64,"+t;{const a=new Uint8Array(t);return window.URL.createObjectURL(new Blob([a],{type:s}))}}parseTextures(e){const t=new Map;if("Texture"in Tt.Objects){const n=Tt.Objects.Texture;for(const i in n){const s=this.parseTexture(n[i],e);t.set(parseInt(i),s)}}return t}parseTexture(e,t){const n=this.loadTexture(e,t);n.ID=e.id,n.name=e.attrName;const i=e.WrapModeU,s=e.WrapModeV,a=i!==void 0?i.value:0,o=s!==void 0?s.value:0;if(n.wrapS=a===0?Li:ui,n.wrapT=o===0?Li:ui,"Scaling"in e){const l=e.Scaling.value;n.repeat.x=l[0],n.repeat.y=l[1]}if("Translation"in e){const l=e.Translation.value;n.offset.x=l[0],n.offset.y=l[1]}return n}loadTexture(e,t){const n=new Set(["tga","tif","tiff","exr","dds","hdr","ktx2"]),i=e.FileName.split(".").pop().toLowerCase(),s=n.has(i)?this.manager.getHandler(`.${i}`):this.textureLoader;if(!s)return console.warn(`FBXLoader: ${i.toUpperCase()} loader not found, creating placeholder texture for`,e.RelativeFilename),new Ut;const a=s.path;a||s.setPath(this.textureLoader.path);const o=un.get(e.id).children;let l;o!==void 0&&o.length>0&&t[o[0].ID]!==void 0&&(l=t[o[0].ID],(l.indexOf("blob:")===0||l.indexOf("data:")===0)&&s.setPath(void 0));const c=s.load(l);return s.setPath(a),c}parseMaterials(e){const t=new Map;if("Material"in Tt.Objects){const n=Tt.Objects.Material;for(const i in n){const s=this.parseMaterial(n[i],e);s!==null&&t.set(parseInt(i),s)}}return t}parseMaterial(e,t){const n=e.id,i=e.attrName;let s=e.ShadingModel;if(typeof s=="object"&&(s=s.value),!un.has(n))return null;const a=this.parseParameters(e,t,n);let o;switch(s.toLowerCase()){case"phong":o=new Ii;break;case"lambert":o=new Fn;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.',s),o=new Ii;break}return o.setValues(a),o.name=i,o}parseParameters(e,t,n){const i={};e.BumpFactor&&(i.bumpScale=e.BumpFactor.value),e.Diffuse?i.color=ft.toWorkingColorSpace(new Ne().fromArray(e.Diffuse.value),gt):e.DiffuseColor&&(e.DiffuseColor.type==="Color"||e.DiffuseColor.type==="ColorRGB")&&(i.color=ft.toWorkingColorSpace(new Ne().fromArray(e.DiffuseColor.value),gt)),e.DisplacementFactor&&(i.displacementScale=e.DisplacementFactor.value),e.Emissive?i.emissive=ft.toWorkingColorSpace(new Ne().fromArray(e.Emissive.value),gt):e.EmissiveColor&&(e.EmissiveColor.type==="Color"||e.EmissiveColor.type==="ColorRGB")&&(i.emissive=ft.toWorkingColorSpace(new Ne().fromArray(e.EmissiveColor.value),gt)),e.EmissiveFactor&&(i.emissiveIntensity=parseFloat(e.EmissiveFactor.value)),i.opacity=1-(e.TransparencyFactor?parseFloat(e.TransparencyFactor.value):0),(i.opacity===1||i.opacity===0)&&(i.opacity=e.Opacity?parseFloat(e.Opacity.value):null,i.opacity===null&&(i.opacity=1-(e.TransparentColor?parseFloat(e.TransparentColor.value[0]):0))),i.opacity<1&&(i.transparent=!0),e.ReflectionFactor&&(i.reflectivity=e.ReflectionFactor.value),e.Shininess&&(i.shininess=e.Shininess.value),e.Specular?i.specular=ft.toWorkingColorSpace(new Ne().fromArray(e.Specular.value),gt):e.SpecularColor&&e.SpecularColor.type==="Color"&&(i.specular=ft.toWorkingColorSpace(new Ne().fromArray(e.SpecularColor.value),gt));const s=this;return un.get(n).children.forEach(function(a){const o=a.relationship;switch(o){case"Bump":i.bumpMap=s.getTexture(t,a.ID);break;case"Maya|TEX_ao_map":i.aoMap=s.getTexture(t,a.ID);break;case"DiffuseColor":case"Maya|TEX_color_map":i.map=s.getTexture(t,a.ID),i.map!==void 0&&(i.map.colorSpace=gt);break;case"DisplacementColor":i.displacementMap=s.getTexture(t,a.ID);break;case"EmissiveColor":i.emissiveMap=s.getTexture(t,a.ID),i.emissiveMap!==void 0&&(i.emissiveMap.colorSpace=gt);break;case"NormalMap":case"Maya|TEX_normal_map":i.normalMap=s.getTexture(t,a.ID);break;case"ReflectionColor":i.envMap=s.getTexture(t,a.ID),i.envMap!==void 0&&(i.envMap.mapping=vc,i.envMap.colorSpace=gt);break;case"SpecularColor":i.specularMap=s.getTexture(t,a.ID),i.specularMap!==void 0&&(i.specularMap.colorSpace=gt);break;case"TransparentColor":case"TransparencyFactor":i.alphaMap=s.getTexture(t,a.ID),i.transparent=!0;break;case"AmbientColor":case"ShininessExponent":case"SpecularFactor":case"VectorDisplacementColor":default:console.warn("THREE.FBXLoader: %s map is not supported in three.js, skipping texture.",o);break}}),i}getTexture(e,t){return"LayeredTexture"in Tt.Objects&&t in Tt.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),t=un.get(t).children[0].ID),e.get(t)}parseDeformers(){const e={},t={};if("Deformer"in Tt.Objects){const n=Tt.Objects.Deformer;for(const i in n){const s=n[i],a=un.get(parseInt(i));if(s.attrType==="Skin"){const o=this.parseSkeleton(a,n);o.ID=i,a.parents.length>1&&console.warn("THREE.FBXLoader: skeleton attached to more than one geometry is not supported."),o.geometryID=a.parents[0].ID,e[i]=o}else if(s.attrType==="BlendShape"){const o={id:i};o.rawTargets=this.parseMorphTargets(a,n),o.id=i,a.parents.length>1&&console.warn("THREE.FBXLoader: morph target attached to more than one geometry is not supported."),t[i]=o}}}return{skeletons:e,morphTargets:t}}parseSkeleton(e,t){const n=[];return e.children.forEach(function(i){const s=t[i.ID];if(s.attrType!=="Cluster")return;const a={ID:i.ID,indices:[],weights:[],transformLink:new Ie().fromArray(s.TransformLink.a)};"Indexes"in s&&(a.indices=s.Indexes.a,a.weights=s.Weights.a),n.push(a)}),{rawBones:n,bones:[]}}parseMorphTargets(e,t){const n=[];for(let i=0;i<e.children.length;i++){const s=e.children[i],a=t[s.ID],o={name:a.attrName,initialWeight:a.DeformPercent,id:a.id,fullWeights:a.FullWeights.a};if(a.attrType!=="BlendShapeChannel")return;o.geoID=un.get(parseInt(s.ID)).children.filter(function(l){return l.relationship===void 0})[0].ID,n.push(o)}return n}parseScene(e,t,n){ti=new Vt;const i=this.parseModels(e.skeletons,t,n),s=Tt.Objects.Model,a=this;i.forEach(function(l){const c=s[l.ID];a.setLookAtProperties(l,c),un.get(l.ID).parents.forEach(function(h){const u=i.get(h.ID);u!==void 0&&u.add(l)}),l.parent===null&&ti.add(l)}),this.bindSkeleton(e.skeletons,t,i),this.addGlobalSceneSettings(),ti.traverse(function(l){if(l.userData.transformData){l.parent&&(l.userData.transformData.parentMatrix=l.parent.matrix,l.userData.transformData.parentMatrixWorld=l.parent.matrixWorld);const c=mv(l.userData.transformData);l.applyMatrix4(c),l.updateWorldMatrix()}});const o=new Y1().parse();ti.children.length===1&&ti.children[0].isGroup&&(ti.children[0].animations=o,ti=ti.children[0]),ti.animations=o}parseModels(e,t,n){const i=new Map,s=Tt.Objects.Model;for(const a in s){const o=parseInt(a),l=s[a],c=un.get(o);let d=this.buildSkeleton(c,e,o,l.attrName);if(!d){switch(l.attrType){case"Camera":d=this.createCamera(c);break;case"Light":d=this.createLight(c);break;case"Mesh":d=this.createMesh(c,t,n);break;case"NurbsCurve":d=this.createCurve(c,t);break;case"LimbNode":case"Root":d=new _o;break;case"Null":default:d=new Vt;break}d.name=l.attrName?Dt.sanitizeNodeName(l.attrName):"",d.userData.originalName=l.attrName,d.ID=o}this.getTransformData(d,l),i.set(o,d)}return i}buildSkeleton(e,t,n,i){let s=null;return e.parents.forEach(function(a){for(const o in t){const l=t[o];l.rawBones.forEach(function(c,d){if(c.ID===a.ID){const h=s;s=new _o,s.matrixWorld.copy(c.transformLink),s.name=i?Dt.sanitizeNodeName(i):"",s.userData.originalName=i,s.ID=n,l.bones[d]=s,h!==null&&s.add(h)}})}}),s}createCamera(e){let t,n;if(e.children.forEach(function(i){const s=Tt.Objects.NodeAttribute[i.ID];s!==void 0&&(n=s)}),n===void 0)t=new Pt;else{let i=0;n.CameraProjectionType!==void 0&&n.CameraProjectionType.value===1&&(i=1);let s=1;n.NearPlane!==void 0&&(s=n.NearPlane.value/1e3);let a=1e3;n.FarPlane!==void 0&&(a=n.FarPlane.value/1e3);let o=window.innerWidth,l=window.innerHeight;n.AspectWidth!==void 0&&n.AspectHeight!==void 0&&(o=n.AspectWidth.value,l=n.AspectHeight.value);const c=o/l;let d=45;n.FieldOfView!==void 0&&(d=n.FieldOfView.value);const h=n.FocalLength?n.FocalLength.value:null;switch(i){case 0:t=new gn(d,c,s,a),h!==null&&t.setFocalLength(h);break;case 1:console.warn("THREE.FBXLoader: Orthographic cameras not supported yet."),t=new Pt;break;default:console.warn("THREE.FBXLoader: Unknown camera type "+i+"."),t=new Pt;break}}return t}createLight(e){let t,n;if(e.children.forEach(function(i){const s=Tt.Objects.NodeAttribute[i.ID];s!==void 0&&(n=s)}),n===void 0)t=new Pt;else{let i;n.LightType===void 0?i=0:i=n.LightType.value;let s=16777215;n.Color!==void 0&&(s=ft.toWorkingColorSpace(new Ne().fromArray(n.Color.value),gt));let a=n.Intensity===void 0?1:n.Intensity.value/100;n.CastLightOnObject!==void 0&&n.CastLightOnObject.value===0&&(a=0);let o=0;n.FarAttenuationEnd!==void 0&&(n.EnableFarAttenuation!==void 0&&n.EnableFarAttenuation.value===0?o=0:o=n.FarAttenuationEnd.value);const l=1;switch(i){case 0:t=new Tc(s,a,o,l);break;case 1:t=new Hc(s,a);break;case 2:let c=Math.PI/3;n.InnerAngle!==void 0&&(c=bt.degToRad(n.InnerAngle.value));let d=0;n.OuterAngle!==void 0&&(d=bt.degToRad(n.OuterAngle.value),d=Math.max(d,1)),t=new $u(s,a,o,c,d,l);break;default:console.warn("THREE.FBXLoader: Unknown light type "+n.LightType.value+", defaulting to a PointLight."),t=new Tc(s,a);break}n.CastShadows!==void 0&&n.CastShadows.value===1&&(t.castShadow=!0)}return t}createMesh(e,t,n){let i,s=null,a=null;const o=[];if(e.children.forEach(function(l){t.has(l.ID)&&(s=t.get(l.ID)),n.has(l.ID)&&o.push(n.get(l.ID))}),o.length>1?a=o:o.length>0?a=o[0]:(a=new Ii({name:pi.DEFAULT_MATERIAL_NAME,color:13421772}),o.push(a)),"color"in s.attributes&&o.forEach(function(l){l.vertexColors=!0}),s.groups.length>0){let l=!1;for(let c=0,d=s.groups.length;c<d;c++){const h=s.groups[c];(h.materialIndex<0||h.materialIndex>=o.length)&&(h.materialIndex=o.length,l=!0)}if(l){const c=new Ii;o.push(c)}}return s.FBX_Deformer?(i=new Vu(s,a),i.normalizeSkinWeights()):i=new Ee(s,a),i}createCurve(e,t){const n=e.children.reduce(function(s,a){return t.has(a.ID)&&(s=t.get(a.ID)),s},null),i=new zn({name:pi.DEFAULT_MATERIAL_NAME,color:3342591,linewidth:1});return new qn(n,i)}getTransformData(e,t){const n={};"InheritType"in t&&(n.inheritType=parseInt(t.InheritType.value)),"RotationOrder"in t?n.eulerOrder=Eo(t.RotationOrder.value):n.eulerOrder=Eo(0),"Lcl_Translation"in t&&(n.translation=t.Lcl_Translation.value),"PreRotation"in t&&(n.preRotation=t.PreRotation.value),"Lcl_Rotation"in t&&(n.rotation=t.Lcl_Rotation.value),"PostRotation"in t&&(n.postRotation=t.PostRotation.value),"Lcl_Scaling"in t&&(n.scale=t.Lcl_Scaling.value),"ScalingOffset"in t&&(n.scalingOffset=t.ScalingOffset.value),"ScalingPivot"in t&&(n.scalingPivot=t.ScalingPivot.value),"RotationOffset"in t&&(n.rotationOffset=t.RotationOffset.value),"RotationPivot"in t&&(n.rotationPivot=t.RotationPivot.value),e.userData.transformData=n}setLookAtProperties(e,t){"LookAtProperty"in t&&un.get(e.ID).children.forEach(function(i){if(i.relationship==="LookAtProperty"){const s=Tt.Objects.Model[i.ID];if("Lcl_Translation"in s){const a=s.Lcl_Translation.value;e.target!==void 0?(e.target.position.fromArray(a),ti.add(e.target)):e.lookAt(new I().fromArray(a))}}})}bindSkeleton(e,t,n){const i=this.parsePoseNodes();for(const s in e){const a=e[s];un.get(parseInt(a.ID)).parents.forEach(function(l){if(t.has(l.ID)){const c=l.ID;un.get(c).parents.forEach(function(h){n.has(h.ID)&&n.get(h.ID).bind(new Ro(a.bones),i[h.ID])})}})}}parsePoseNodes(){const e={};if("Pose"in Tt.Objects){const t=Tt.Objects.Pose;for(const n in t)if(t[n].attrType==="BindPose"&&t[n].NbPoseNodes>0){const i=t[n].PoseNode;Array.isArray(i)?i.forEach(function(s){e[s.Node]=new Ie().fromArray(s.Matrix.a)}):e[i.Node]=new Ie().fromArray(i.Matrix.a)}}return e}addGlobalSceneSettings(){if("GlobalSettings"in Tt){if("AmbientColor"in Tt.GlobalSettings){const e=Tt.GlobalSettings.AmbientColor.value,t=e[0],n=e[1],i=e[2];if(t!==0||n!==0||i!==0){const s=new Ne().setRGB(t,n,i,gt);ti.add(new Gb(s,1))}}"UnitScaleFactor"in Tt.GlobalSettings&&(ti.userData.unitScaleFactor=Tt.GlobalSettings.UnitScaleFactor.value)}}}class Z1{constructor(){this.negativeMaterialIndices=!1}parse(e){const t=new Map;if("Geometry"in Tt.Objects){const n=Tt.Objects.Geometry;for(const i in n){const s=un.get(parseInt(i)),a=this.parseGeometry(s,n[i],e);t.set(parseInt(i),a)}}return this.negativeMaterialIndices===!0&&console.warn("THREE.FBXLoader: The FBX file contains invalid (negative) material indices. The asset might not render as expected."),t}parseGeometry(e,t,n){switch(t.attrType){case"Mesh":return this.parseMeshGeometry(e,t,n);case"NurbsCurve":return this.parseNurbsGeometry(t)}}parseMeshGeometry(e,t,n){const i=n.skeletons,s=[],a=e.parents.map(function(h){return Tt.Objects.Model[h.ID]});if(a.length===0)return;const o=e.children.reduce(function(h,u){return i[u.ID]!==void 0&&(h=i[u.ID]),h},null);e.children.forEach(function(h){n.morphTargets[h.ID]!==void 0&&s.push(n.morphTargets[h.ID])});const l=a[0],c={};"RotationOrder"in l&&(c.eulerOrder=Eo(l.RotationOrder.value)),"InheritType"in l&&(c.inheritType=parseInt(l.InheritType.value)),"GeometricTranslation"in l&&(c.translation=l.GeometricTranslation.value),"GeometricRotation"in l&&(c.rotation=l.GeometricRotation.value),"GeometricScaling"in l&&(c.scale=l.GeometricScaling.value);const d=mv(c);return this.genGeometry(t,o,s,d)}genGeometry(e,t,n,i){const s=new ht;e.attrName&&(s.name=e.attrName);const a=this.parseGeoNode(e,t),o=this.genBuffers(a),l=new ke(o.vertex,3);if(l.applyMatrix4(i),s.setAttribute("position",l),o.colors.length>0&&s.setAttribute("color",new ke(o.colors,3)),t&&(s.setAttribute("skinIndex",new zu(o.weightsIndices,4)),s.setAttribute("skinWeight",new ke(o.vertexWeights,4)),s.FBX_Deformer=t),o.normal.length>0){const c=new xt().getNormalMatrix(i),d=new ke(o.normal,3);d.applyNormalMatrix(c),s.setAttribute("normal",d)}if(o.uvs.forEach(function(c,d){const h=d===0?"uv":`uv${d}`;s.setAttribute(h,new ke(o.uvs[d],2))}),a.material&&a.material.mappingType!=="AllSame"){let c=o.materialIndex[0],d=0;if(o.materialIndex.forEach(function(h,u){h!==c&&(s.addGroup(d,u-d,c),c=h,d=u)}),s.groups.length>0){const h=s.groups[s.groups.length-1],u=h.start+h.count;u!==o.materialIndex.length&&s.addGroup(u,o.materialIndex.length-u,c)}s.groups.length===0&&s.addGroup(0,o.materialIndex.length,o.materialIndex[0])}return this.addMorphTargets(s,e,n,i),s}parseGeoNode(e,t){const n={};if(n.vertexPositions=e.Vertices!==void 0?e.Vertices.a:[],n.vertexIndices=e.PolygonVertexIndex!==void 0?e.PolygonVertexIndex.a:[],e.LayerElementColor&&(n.color=this.parseVertexColors(e.LayerElementColor[0])),e.LayerElementMaterial&&(n.material=this.parseMaterialIndices(e.LayerElementMaterial[0])),e.LayerElementNormal&&(n.normal=this.parseNormals(e.LayerElementNormal[0])),e.LayerElementUV){n.uv=[];let i=0;for(;e.LayerElementUV[i];)e.LayerElementUV[i].UV&&n.uv.push(this.parseUVs(e.LayerElementUV[i])),i++}return n.weightTable={},t!==null&&(n.skeleton=t,t.rawBones.forEach(function(i,s){i.indices.forEach(function(a,o){n.weightTable[a]===void 0&&(n.weightTable[a]=[]),n.weightTable[a].push({id:s,weight:i.weights[o]})})})),n}genBuffers(e){const t={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]};let n=0,i=0,s=!1,a=[],o=[],l=[],c=[],d=[],h=[];const u=this;return e.vertexIndices.forEach(function(f,m){let b,p=!1;f<0&&(f=f^-1,p=!0);let g=[],y=[];if(a.push(f*3,f*3+1,f*3+2),e.color){const x=ql(m,n,f,e.color);l.push(x[0],x[1],x[2])}if(e.skeleton){if(e.weightTable[f]!==void 0&&e.weightTable[f].forEach(function(x){y.push(x.weight),g.push(x.id)}),y.length>4){s||(console.warn("THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."),s=!0);const x=[0,0,0,0],w=[0,0,0,0];y.forEach(function(P,T){let A=P,M=g[T];w.forEach(function(_,S,R){if(A>_){R[S]=A,A=_;const k=x[S];x[S]=M,M=k}})}),g=x,y=w}for(;y.length<4;)y.push(0),g.push(0);for(let x=0;x<4;++x)d.push(y[x]),h.push(g[x])}if(e.normal){const x=ql(m,n,f,e.normal);o.push(x[0],x[1],x[2])}e.material&&e.material.mappingType!=="AllSame"&&(b=ql(m,n,f,e.material)[0],b<0&&(u.negativeMaterialIndices=!0,b=0)),e.uv&&e.uv.forEach(function(x,w){const P=ql(m,n,f,x);c[w]===void 0&&(c[w]=[]),c[w].push(P[0]),c[w].push(P[1])}),i++,p&&(u.genFace(t,e,a,b,o,l,c,d,h,i),n++,i=0,a=[],o=[],l=[],c=[],d=[],h=[])}),t}getNormalNewell(e){const t=new I(0,0,0);for(let n=0;n<e.length;n++){const i=e[n],s=e[(n+1)%e.length];t.x+=(i.y-s.y)*(i.z+s.z),t.y+=(i.z-s.z)*(i.x+s.x),t.z+=(i.x-s.x)*(i.y+s.y)}return t.normalize(),t}getNormalTangentAndBitangent(e){const t=this.getNormalNewell(e),i=(Math.abs(t.z)>.5?new I(0,1,0):new I(0,0,1)).cross(t).normalize(),s=t.clone().cross(i).normalize();return{normal:t,tangent:i,bitangent:s}}flattenVertex(e,t,n){return new me(e.dot(t),e.dot(n))}genFace(e,t,n,i,s,a,o,l,c,d){let h;if(d>3){const u=[],f=t.baseVertexPositions||t.vertexPositions;for(let g=0;g<n.length;g+=3)u.push(new I(f[n[g]],f[n[g+1]],f[n[g+2]]));const{tangent:m,bitangent:b}=this.getNormalTangentAndBitangent(u),p=[];for(const g of u)p.push(this.flattenVertex(g,m,b));h=ma.triangulateShape(p,[])}else h=[[0,1,2]];for(const[u,f,m]of h)e.vertex.push(t.vertexPositions[n[u*3]]),e.vertex.push(t.vertexPositions[n[u*3+1]]),e.vertex.push(t.vertexPositions[n[u*3+2]]),e.vertex.push(t.vertexPositions[n[f*3]]),e.vertex.push(t.vertexPositions[n[f*3+1]]),e.vertex.push(t.vertexPositions[n[f*3+2]]),e.vertex.push(t.vertexPositions[n[m*3]]),e.vertex.push(t.vertexPositions[n[m*3+1]]),e.vertex.push(t.vertexPositions[n[m*3+2]]),t.skeleton&&(e.vertexWeights.push(l[u*4]),e.vertexWeights.push(l[u*4+1]),e.vertexWeights.push(l[u*4+2]),e.vertexWeights.push(l[u*4+3]),e.vertexWeights.push(l[f*4]),e.vertexWeights.push(l[f*4+1]),e.vertexWeights.push(l[f*4+2]),e.vertexWeights.push(l[f*4+3]),e.vertexWeights.push(l[m*4]),e.vertexWeights.push(l[m*4+1]),e.vertexWeights.push(l[m*4+2]),e.vertexWeights.push(l[m*4+3]),e.weightsIndices.push(c[u*4]),e.weightsIndices.push(c[u*4+1]),e.weightsIndices.push(c[u*4+2]),e.weightsIndices.push(c[u*4+3]),e.weightsIndices.push(c[f*4]),e.weightsIndices.push(c[f*4+1]),e.weightsIndices.push(c[f*4+2]),e.weightsIndices.push(c[f*4+3]),e.weightsIndices.push(c[m*4]),e.weightsIndices.push(c[m*4+1]),e.weightsIndices.push(c[m*4+2]),e.weightsIndices.push(c[m*4+3])),t.color&&(e.colors.push(a[u*3]),e.colors.push(a[u*3+1]),e.colors.push(a[u*3+2]),e.colors.push(a[f*3]),e.colors.push(a[f*3+1]),e.colors.push(a[f*3+2]),e.colors.push(a[m*3]),e.colors.push(a[m*3+1]),e.colors.push(a[m*3+2])),t.material&&t.material.mappingType!=="AllSame"&&(e.materialIndex.push(i),e.materialIndex.push(i),e.materialIndex.push(i)),t.normal&&(e.normal.push(s[u*3]),e.normal.push(s[u*3+1]),e.normal.push(s[u*3+2]),e.normal.push(s[f*3]),e.normal.push(s[f*3+1]),e.normal.push(s[f*3+2]),e.normal.push(s[m*3]),e.normal.push(s[m*3+1]),e.normal.push(s[m*3+2])),t.uv&&t.uv.forEach(function(b,p){e.uvs[p]===void 0&&(e.uvs[p]=[]),e.uvs[p].push(o[p][u*2]),e.uvs[p].push(o[p][u*2+1]),e.uvs[p].push(o[p][f*2]),e.uvs[p].push(o[p][f*2+1]),e.uvs[p].push(o[p][m*2]),e.uvs[p].push(o[p][m*2+1])})}addMorphTargets(e,t,n,i){if(n.length===0)return;e.morphTargetsRelative=!0,e.morphAttributes.position=[];const s=this;n.forEach(function(a){a.rawTargets.forEach(function(o){const l=Tt.Objects.Geometry[o.geoID];l!==void 0&&s.genMorphGeometry(e,t,l,i,o.name)})})}genMorphGeometry(e,t,n,i,s){const a=t.Vertices!==void 0?t.Vertices.a:[],o=t.PolygonVertexIndex!==void 0?t.PolygonVertexIndex.a:[],l=n.Vertices!==void 0?n.Vertices.a:[],c=n.Indexes!==void 0?n.Indexes.a:[],d=e.attributes.position.count*3,h=new Float32Array(d);for(let b=0;b<c.length;b++){const p=c[b]*3;h[p]=l[b*3],h[p+1]=l[b*3+1],h[p+2]=l[b*3+2]}const u={vertexIndices:o,vertexPositions:h,baseVertexPositions:a},f=this.genBuffers(u),m=new ke(f.vertex,3);m.name=s||n.attrName,m.applyMatrix4(i),e.morphAttributes.position.push(m)}parseNormals(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,i=e.Normals.a;let s=[];return n==="IndexToDirect"&&("NormalIndex"in e?s=e.NormalIndex.a:"NormalsIndex"in e&&(s=e.NormalsIndex.a)),{dataSize:3,buffer:i,indices:s,mappingType:t,referenceType:n}}parseUVs(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,i=e.UV.a;let s=[];return n==="IndexToDirect"&&(s=e.UVIndex.a),{dataSize:2,buffer:i,indices:s,mappingType:t,referenceType:n}}parseVertexColors(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,i=e.Colors.a;let s=[];n==="IndexToDirect"&&(s=e.ColorIndex.a);for(let a=0,o=new Ne;a<i.length;a+=4)o.fromArray(i,a),ft.toWorkingColorSpace(o,gt),o.toArray(i,a);return{dataSize:4,buffer:i,indices:s,mappingType:t,referenceType:n}}parseMaterialIndices(e){const t=e.MappingInformationType,n=e.ReferenceInformationType;if(t==="NoMappingInformation")return{dataSize:1,buffer:[0],indices:[0],mappingType:"AllSame",referenceType:n};const i=e.Materials.a,s=[];for(let a=0;a<i.length;++a)s.push(a);return{dataSize:1,buffer:i,indices:s,mappingType:t,referenceType:n}}parseNurbsGeometry(e){const t=parseInt(e.Order);if(isNaN(t))return console.error("THREE.FBXLoader: Invalid Order %s given for geometry ID: %s",e.Order,e.id),new ht;const n=t-1,i=e.KnotVector.a,s=[],a=e.Points.a;for(let h=0,u=a.length;h<u;h+=4)s.push(new _t().fromArray(a,h));let o,l;if(e.Form==="Closed")s.push(s[0]);else if(e.Form==="Periodic"){o=n,l=i.length-1-o;for(let h=0;h<n;++h)s.push(s[h])}const d=new j1(n,i,s,o,l).getPoints(s.length*12);return new ht().setFromPoints(d)}}class Y1{parse(){const e=[],t=this.parseClips();if(t!==void 0)for(const n in t){const i=t[n],s=this.addClip(i);e.push(s)}return e}parseClips(){if(Tt.Objects.AnimationCurve===void 0)return;const e=this.parseAnimationCurveNodes();this.parseAnimationCurves(e);const t=this.parseAnimationLayers(e);return this.parseAnimStacks(t)}parseAnimationCurveNodes(){const e=Tt.Objects.AnimationCurveNode,t=new Map;for(const n in e){const i=e[n];if(i.attrName.match(/S|R|T|DeformPercent/)!==null){const s={id:i.id,attr:i.attrName,curves:{}};t.set(s.id,s)}}return t}parseAnimationCurves(e){const t=Tt.Objects.AnimationCurve;for(const n in t){const i={id:t[n].id,times:t[n].KeyTime.a.map(eC),values:t[n].KeyValueFloat.a},s=un.get(i.id);if(s!==void 0){const a=s.parents[0].ID,o=s.parents[0].relationship;o.match(/X/)?e.get(a).curves.x=i:o.match(/Y/)?e.get(a).curves.y=i:o.match(/Z/)?e.get(a).curves.z=i:o.match(/DeformPercent/)&&e.has(a)&&(e.get(a).curves.morph=i)}}}parseAnimationLayers(e){const t=Tt.Objects.AnimationLayer,n=new Map;for(const i in t){const s=[],a=un.get(parseInt(i));a!==void 0&&(a.children.forEach(function(l,c){if(e.has(l.ID)){const d=e.get(l.ID);if(d.curves.x!==void 0||d.curves.y!==void 0||d.curves.z!==void 0){if(s[c]===void 0){const h=un.get(l.ID).parents.filter(function(u){return u.relationship!==void 0})[0].ID;if(h!==void 0){const u=Tt.Objects.Model[h.toString()];if(u===void 0){console.warn("THREE.FBXLoader: Encountered a unused curve.",l);return}const f={modelName:u.attrName?Dt.sanitizeNodeName(u.attrName):"",ID:u.id,initialPosition:[0,0,0],initialRotation:[0,0,0],initialScale:[1,1,1]};ti.traverse(function(m){m.ID===u.id&&(f.transform=m.matrix,m.userData.transformData&&(f.eulerOrder=m.userData.transformData.eulerOrder))}),f.transform||(f.transform=new Ie),"PreRotation"in u&&(f.preRotation=u.PreRotation.value),"PostRotation"in u&&(f.postRotation=u.PostRotation.value),s[c]=f}}s[c]&&(s[c][d.attr]=d)}else if(d.curves.morph!==void 0){if(s[c]===void 0){const h=un.get(l.ID).parents.filter(function(g){return g.relationship!==void 0})[0].ID,u=un.get(h).parents[0].ID,f=un.get(u).parents[0].ID,m=un.get(f).parents[0].ID,b=Tt.Objects.Model[m],p={modelName:b.attrName?Dt.sanitizeNodeName(b.attrName):"",morphName:Tt.Objects.Deformer[h].attrName};s[c]=p}s[c][d.attr]=d}}}),n.set(parseInt(i),s))}return n}parseAnimStacks(e){const t=Tt.Objects.AnimationStack,n={};for(const i in t){const s=un.get(parseInt(i)).children;s.length>1&&console.warn("THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers.");const a=e.get(s[0].ID);n[i]={name:t[i].attrName,layer:a}}return n}addClip(e){let t=[];const n=this;return e.layer.forEach(function(i){t=t.concat(n.generateTracks(i))}),new Mc(e.name,-1,t)}generateTracks(e){const t=[];let n=new I,i=new I;if(e.transform&&e.transform.decompose(n,new Lt,i),n=n.toArray(),i=i.toArray(),e.T!==void 0&&Object.keys(e.T.curves).length>0){const s=this.generateVectorTrack(e.modelName,e.T.curves,n,"position");s!==void 0&&t.push(s)}if(e.R!==void 0&&Object.keys(e.R.curves).length>0){const s=this.generateRotationTrack(e.modelName,e.R.curves,e.preRotation,e.postRotation,e.eulerOrder);s!==void 0&&t.push(s)}if(e.S!==void 0&&Object.keys(e.S.curves).length>0){const s=this.generateVectorTrack(e.modelName,e.S.curves,i,"scale");s!==void 0&&t.push(s)}if(e.DeformPercent!==void 0){const s=this.generateMorphTrack(e);s!==void 0&&t.push(s)}return t}generateVectorTrack(e,t,n,i){const s=this.getTimesForAllAxes(t),a=this.getKeyframeTrackValues(s,t,n);return new Es(e+"."+i,s,a)}generateRotationTrack(e,t,n,i,s){let a,o;if(t.x!==void 0&&t.y!==void 0&&t.z!==void 0){const u=this.interpolateRotations(t.x,t.y,t.z,s);a=u[0],o=u[1]}const l=Eo(0);n!==void 0&&(n=n.map(bt.degToRad),n.push(l),n=new hn().fromArray(n),n=new Lt().setFromEuler(n)),i!==void 0&&(i=i.map(bt.degToRad),i.push(l),i=new hn().fromArray(i),i=new Lt().setFromEuler(i).invert());const c=new Lt,d=new hn,h=[];if(!o||!a)return new Ts(e+".quaternion",[0],[0]);for(let u=0;u<o.length;u+=3)d.set(o[u],o[u+1],o[u+2],s),c.setFromEuler(d),n!==void 0&&c.premultiply(n),i!==void 0&&c.multiply(i),u>2&&new Lt().fromArray(h,(u-3)/3*4).dot(c)<0&&c.set(-c.x,-c.y,-c.z,-c.w),c.toArray(h,u/3*4);return new Ts(e+".quaternion",a,h)}generateMorphTrack(e){const t=e.DeformPercent.curves.morph,n=t.values.map(function(s){return s/100}),i=ti.getObjectByName(e.modelName).morphTargetDictionary[e.morphName];return new Mr(e.modelName+".morphTargetInfluences["+i+"]",t.times,n)}getTimesForAllAxes(e){let t=[];if(e.x!==void 0&&(t=t.concat(e.x.times)),e.y!==void 0&&(t=t.concat(e.y.times)),e.z!==void 0&&(t=t.concat(e.z.times)),t=t.sort(function(n,i){return n-i}),t.length>1){let n=1,i=t[0];for(let s=1;s<t.length;s++){const a=t[s];a!==i&&(t[n]=a,i=a,n++)}t=t.slice(0,n)}return t}getKeyframeTrackValues(e,t,n){const i=n,s=[];let a=-1,o=-1,l=-1;return e.forEach(function(c){if(t.x&&(a=t.x.times.indexOf(c)),t.y&&(o=t.y.times.indexOf(c)),t.z&&(l=t.z.times.indexOf(c)),a!==-1){const d=t.x.values[a];s.push(d),i[0]=d}else s.push(i[0]);if(o!==-1){const d=t.y.values[o];s.push(d),i[1]=d}else s.push(i[1]);if(l!==-1){const d=t.z.values[l];s.push(d),i[2]=d}else s.push(i[2])}),s}interpolateRotations(e,t,n,i){const s=[],a=[];s.push(e.times[0]),a.push(bt.degToRad(e.values[0])),a.push(bt.degToRad(t.values[0])),a.push(bt.degToRad(n.values[0]));for(let o=1;o<e.values.length;o++){const l=[e.values[o-1],t.values[o-1],n.values[o-1]];if(isNaN(l[0])||isNaN(l[1])||isNaN(l[2]))continue;const c=l.map(bt.degToRad),d=[e.values[o],t.values[o],n.values[o]];if(isNaN(d[0])||isNaN(d[1])||isNaN(d[2]))continue;const h=d.map(bt.degToRad),u=[d[0]-l[0],d[1]-l[1],d[2]-l[2]],f=[Math.abs(u[0]),Math.abs(u[1]),Math.abs(u[2])];if(f[0]>=180||f[1]>=180||f[2]>=180){const b=Math.max(...f)/180,p=new hn(...c,i),g=new hn(...h,i),y=new Lt().setFromEuler(p),x=new Lt().setFromEuler(g);y.dot(x)&&x.set(-x.x,-x.y,-x.z,-x.w);const w=e.times[o-1],P=e.times[o]-w,T=new Lt,A=new hn;for(let M=0;M<1;M+=1/b)T.copy(y.clone().slerp(x.clone(),M)),s.push(w+M*P),A.setFromQuaternion(T,i),a.push(A.x),a.push(A.y),a.push(A.z)}else s.push(e.times[o]),a.push(bt.degToRad(e.values[o])),a.push(bt.degToRad(t.values[o])),a.push(bt.degToRad(n.values[o]))}return[s,a]}}class K1{getPrevNode(){return this.nodeStack[this.currentIndent-2]}getCurrentNode(){return this.nodeStack[this.currentIndent-1]}getCurrentProp(){return this.currentProp}pushStack(e){this.nodeStack.push(e),this.currentIndent+=1}popStack(){this.nodeStack.pop(),this.currentIndent-=1}setCurrentProp(e,t){this.currentProp=e,this.currentPropName=t}parse(e){this.currentIndent=0,this.allNodes=new pv,this.nodeStack=[],this.currentProp=[],this.currentPropName="";const t=this,n=e.split(/[\r\n]+/);return n.forEach(function(i,s){const a=i.match(/^[\s\t]*;/),o=i.match(/^[\s\t]*$/);if(a||o)return;const l=i.match("^\\t{"+t.currentIndent+"}(\\w+):(.*){",""),c=i.match("^\\t{"+t.currentIndent+"}(\\w+):[\\s\\t\\r\\n](.*)"),d=i.match("^\\t{"+(t.currentIndent-1)+"}}");l?t.parseNodeBegin(i,l):c?t.parseNodeProperty(i,c,n[++s]):d?t.popStack():i.match(/^[^\s\t}]/)&&t.parseNodePropertyContinued(i)}),this.allNodes}parseNodeBegin(e,t){const n=t[1].trim().replace(/^"/,"").replace(/"$/,""),i=t[2].split(",").map(function(l){return l.trim().replace(/^"/,"").replace(/"$/,"")}),s={name:n},a=this.parseNodeAttr(i),o=this.getCurrentNode();this.currentIndent===0?this.allNodes.add(n,s):n in o?(n==="PoseNode"?o.PoseNode.push(s):o[n].id!==void 0&&(o[n]={},o[n][o[n].id]=o[n]),a.id!==""&&(o[n][a.id]=s)):typeof a.id=="number"?(o[n]={},o[n][a.id]=s):n!=="Properties70"&&(n==="PoseNode"?o[n]=[s]:o[n]=s),typeof a.id=="number"&&(s.id=a.id),a.name!==""&&(s.attrName=a.name),a.type!==""&&(s.attrType=a.type),this.pushStack(s)}parseNodeAttr(e){let t=e[0];e[0]!==""&&(t=parseInt(e[0]),isNaN(t)&&(t=e[0]));let n="",i="";return e.length>1&&(n=e[1].replace(/^(\w+)::/,""),i=e[2]),{id:t,name:n,type:i}}parseNodeProperty(e,t,n){let i=t[1].replace(/^"/,"").replace(/"$/,"").trim(),s=t[2].replace(/^"/,"").replace(/"$/,"").trim();i==="Content"&&s===","&&(s=n.replace(/"/g,"").replace(/,$/,"").trim());const a=this.getCurrentNode();if(a.name==="Properties70"){this.parseNodeSpecialProperty(e,i,s);return}if(i==="C"){const l=s.split(",").slice(1),c=parseInt(l[0]),d=parseInt(l[1]);let h=s.split(",").slice(3);h=h.map(function(u){return u.trim().replace(/^"/,"")}),i="connections",s=[c,d],nC(s,h),a[i]===void 0&&(a[i]=[])}i==="Node"&&(a.id=s),i in a&&Array.isArray(a[i])?a[i].push(s):i!=="a"?a[i]=s:a.a=s,this.setCurrentProp(a,i),i==="a"&&s.slice(-1)!==","&&(a.a=th(s))}parseNodePropertyContinued(e){const t=this.getCurrentNode();t.a+=e,e.slice(-1)!==","&&(t.a=th(t.a))}parseNodeSpecialProperty(e,t,n){const i=n.split('",').map(function(d){return d.trim().replace(/^\"/,"").replace(/\s/,"_")}),s=i[0],a=i[1],o=i[2],l=i[3];let c=i[4];switch(a){case"int":case"enum":case"bool":case"ULongLong":case"double":case"Number":case"FieldOfView":c=parseFloat(c);break;case"Color":case"ColorRGB":case"Vector3D":case"Lcl_Translation":case"Lcl_Rotation":case"Lcl_Scaling":c=th(c);break}this.getPrevNode()[s]={type:a,type2:o,flag:l,value:c},this.setCurrentProp(this.getPrevNode(),s)}}class $1{parse(e){const t=new Um(e);t.skip(23);const n=t.getUint32();if(n<6400)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+n);const i=new pv;for(;!this.endOfContent(t);){const s=this.parseNode(t,n);s!==null&&i.add(s.name,s)}return i}endOfContent(e){return e.size()%16===0?(e.getOffset()+160+16&-16)>=e.size():e.getOffset()+160+16>=e.size()}parseNode(e,t){const n={},i=t>=7500?e.getUint64():e.getUint32(),s=t>=7500?e.getUint64():e.getUint32();t>=7500?e.getUint64():e.getUint32();const a=e.getUint8(),o=e.getString(a);if(i===0)return null;const l=[];for(let u=0;u<s;u++)l.push(this.parseProperty(e));const c=l.length>0?l[0]:"",d=l.length>1?l[1]:"",h=l.length>2?l[2]:"";for(n.singleProperty=s===1&&e.getOffset()===i;i>e.getOffset();){const u=this.parseNode(e,t);u!==null&&this.parseSubNode(o,n,u)}return n.propertyList=l,typeof c=="number"&&(n.id=c),d!==""&&(n.attrName=d),h!==""&&(n.attrType=h),o!==""&&(n.name=o),n}parseSubNode(e,t,n){if(n.singleProperty===!0){const i=n.propertyList[0];Array.isArray(i)?(t[n.name]=n,n.a=i):t[n.name]=i}else if(e==="Connections"&&n.name==="C"){const i=[];n.propertyList.forEach(function(s,a){a!==0&&i.push(s)}),t.connections===void 0&&(t.connections=[]),t.connections.push(i)}else if(n.name==="Properties70")Object.keys(n).forEach(function(s){t[s]=n[s]});else if(e==="Properties70"&&n.name==="P"){let i=n.propertyList[0],s=n.propertyList[1];const a=n.propertyList[2],o=n.propertyList[3];let l;i.indexOf("Lcl ")===0&&(i=i.replace("Lcl ","Lcl_")),s.indexOf("Lcl ")===0&&(s=s.replace("Lcl ","Lcl_")),s==="Color"||s==="ColorRGB"||s==="Vector"||s==="Vector3D"||s.indexOf("Lcl_")===0?l=[n.propertyList[4],n.propertyList[5],n.propertyList[6]]:l=n.propertyList[4],t[i]={type:s,type2:a,flag:o,value:l}}else t[n.name]===void 0?typeof n.id=="number"?(t[n.name]={},t[n.name][n.id]=n):t[n.name]=n:n.name==="PoseNode"?(Array.isArray(t[n.name])||(t[n.name]=[t[n.name]]),t[n.name].push(n)):t[n.name][n.id]===void 0&&(t[n.name][n.id]=n)}parseProperty(e){const t=e.getString(1);let n;switch(t){case"C":return e.getBoolean();case"D":return e.getFloat64();case"F":return e.getFloat32();case"I":return e.getInt32();case"L":return e.getInt64();case"R":return n=e.getUint32(),e.getArrayBuffer(n);case"S":return n=e.getUint32(),e.getString(n);case"Y":return e.getInt16();case"b":case"c":case"d":case"f":case"i":case"l":const i=e.getUint32(),s=e.getUint32(),a=e.getUint32();if(s===0)switch(t){case"b":case"c":return e.getBooleanArray(i);case"d":return e.getFloat64Array(i);case"f":return e.getFloat32Array(i);case"i":return e.getInt32Array(i);case"l":return e.getInt64Array(i)}const o=k1(new Uint8Array(e.getArrayBuffer(a))),l=new Um(o.buffer);switch(t){case"b":case"c":return l.getBooleanArray(i);case"d":return l.getFloat64Array(i);case"f":return l.getFloat32Array(i);case"i":return l.getInt32Array(i);case"l":return l.getInt64Array(i)}break;default:throw new Error("THREE.FBXLoader: Unknown property type "+t)}}}class Um{constructor(e,t){this.dv=new DataView(e),this.offset=0,this.littleEndian=t!==void 0?t:!0,this._textDecoder=new TextDecoder}getOffset(){return this.offset}size(){return this.dv.buffer.byteLength}skip(e){this.offset+=e}getBoolean(){return(this.getUint8()&1)===1}getBooleanArray(e){const t=[];for(let n=0;n<e;n++)t.push(this.getBoolean());return t}getUint8(){const e=this.dv.getUint8(this.offset);return this.offset+=1,e}getInt16(){const e=this.dv.getInt16(this.offset,this.littleEndian);return this.offset+=2,e}getInt32(){const e=this.dv.getInt32(this.offset,this.littleEndian);return this.offset+=4,e}getInt32Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getInt32());return t}getUint32(){const e=this.dv.getUint32(this.offset,this.littleEndian);return this.offset+=4,e}getInt64(){let e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),t&2147483648?(t=~t&4294967295,e=~e&4294967295,e===4294967295&&(t=t+1&4294967295),e=e+1&4294967295,-(t*4294967296+e)):t*4294967296+e}getInt64Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getInt64());return t}getUint64(){let e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),t*4294967296+e}getFloat32(){const e=this.dv.getFloat32(this.offset,this.littleEndian);return this.offset+=4,e}getFloat32Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getFloat32());return t}getFloat64(){const e=this.dv.getFloat64(this.offset,this.littleEndian);return this.offset+=8,e}getFloat64Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getFloat64());return t}getArrayBuffer(e){const t=this.dv.buffer.slice(this.offset,this.offset+e);return this.offset+=e,t}getString(e){const t=this.offset;let n=new Uint8Array(this.dv.buffer,t,e);this.skip(e);const i=n.indexOf(0);return i>=0&&(n=new Uint8Array(this.dv.buffer,t,i)),this._textDecoder.decode(n)}}class pv{add(e,t){this[e]=t}}function Q1(r){const e="Kaydara FBX Binary \0";return r.byteLength>=e.length&&e===gv(r,0,e.length)}function J1(r){const e=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"];let t=0;function n(i){const s=r[i-1];return r=r.slice(t+i),t++,s}for(let i=0;i<e.length;++i)if(n(1)===e[i])return!1;return!0}function Bm(r){const e=/FBXVersion: (\d+)/,t=r.match(e);if(t)return parseInt(t[1]);throw new Error("THREE.FBXLoader: Cannot find the version number for the file given.")}function eC(r){return r/46186158e3}const tC=[];function ql(r,e,t,n){let i;switch(n.mappingType){case"ByPolygonVertex":i=r;break;case"ByPolygon":i=e;break;case"ByVertice":i=t;break;case"AllSame":i=n.indices[0];break;default:console.warn("THREE.FBXLoader: unknown attribute mapping type "+n.mappingType)}n.referenceType==="IndexToDirect"&&(i=n.indices[i]);const s=i*n.dataSize,a=s+n.dataSize;return iC(tC,n.buffer,s,a)}const eh=new hn,Jr=new I;function mv(r){const e=new Ie,t=new Ie,n=new Ie,i=new Ie,s=new Ie,a=new Ie,o=new Ie,l=new Ie,c=new Ie,d=new Ie,h=new Ie,u=new Ie,f=r.inheritType?r.inheritType:0;r.translation&&e.setPosition(Jr.fromArray(r.translation));const m=Eo(0);if(r.preRotation){const R=r.preRotation.map(bt.degToRad);R.push(m),t.makeRotationFromEuler(eh.fromArray(R))}if(r.rotation){const R=r.rotation.map(bt.degToRad);R.push(r.eulerOrder||m),n.makeRotationFromEuler(eh.fromArray(R))}if(r.postRotation){const R=r.postRotation.map(bt.degToRad);R.push(m),i.makeRotationFromEuler(eh.fromArray(R)),i.invert()}r.scale&&s.scale(Jr.fromArray(r.scale)),r.scalingOffset&&o.setPosition(Jr.fromArray(r.scalingOffset)),r.scalingPivot&&a.setPosition(Jr.fromArray(r.scalingPivot)),r.rotationOffset&&l.setPosition(Jr.fromArray(r.rotationOffset)),r.rotationPivot&&c.setPosition(Jr.fromArray(r.rotationPivot)),r.parentMatrixWorld&&(h.copy(r.parentMatrix),d.copy(r.parentMatrixWorld));const b=t.clone().multiply(n).multiply(i),p=new Ie;p.extractRotation(d);const g=new Ie;g.copyPosition(d);const y=g.clone().invert().multiply(d),x=p.clone().invert().multiply(y),w=s,P=new Ie;if(f===0)P.copy(p).multiply(b).multiply(x).multiply(w);else if(f===1)P.copy(p).multiply(x).multiply(b).multiply(w);else{const k=new Ie().scale(new I().setFromMatrixScale(h)).clone().invert(),O=x.clone().multiply(k);P.copy(p).multiply(b).multiply(O).multiply(w)}const T=c.clone().invert(),A=a.clone().invert();let M=e.clone().multiply(l).multiply(c).multiply(t).multiply(n).multiply(i).multiply(T).multiply(o).multiply(a).multiply(s).multiply(A);const _=new Ie().copyPosition(M),S=d.clone().multiply(_);return u.copyPosition(S),M=u.clone().multiply(P),M.premultiply(d.invert()),M}function Eo(r){r=r||0;const e=["ZYX","YZX","XZY","ZXY","YXZ","XYZ"];return r===6?(console.warn("THREE.FBXLoader: unsupported Euler Order: Spherical XYZ. Animations and rotations may be incorrect."),e[0]):e[r]}function th(r){return r.split(",").map(function(t){return parseFloat(t)})}function gv(r,e,t){return e===void 0&&(e=0),t===void 0&&(t=r.byteLength),new TextDecoder().decode(new Uint8Array(r,e,t))}function nC(r,e){for(let t=0,n=r.length,i=e.length;t<i;t++,n++)r[n]=e[t]}function iC(r,e,t,n){for(let i=t,s=0;i<n;i++,s++)r[s]=e[i];return r}class zm{link(e,t,n,i){for(let s=0;s<t.length-1;s++)bv(e,t[s],t[s+1],n,i)}}class sC{link(e,t,n,i){for(let s=0;s<t.length-1;s++)for(let a=s+1;a<t.length;a++)bv(e,t[s],t[a],n,i)}}class rC{constructor(e,t,n){this.nodeManager=e,this.eventBus=t,this.getSelectedObjects=n}strategy=new zm;registerEventListeners(){this.eventBus.on("ui:link-nodes-requested",this.handleLinkNodes),this.eventBus.on("ui:unlink-nodes-requested",this.handleUnlinkNodes)}deregisterEventListeners(){this.eventBus.off("ui:link-nodes-requested",this.handleLinkNodes),this.eventBus.off("ui:unlink-nodes-requested",this.handleUnlinkNodes)}dispose(){this.deregisterEventListeners()}setStrategy(e){this.strategy=e}execute(e,t,n){if(e.length>1){this.strategy.link(this.nodeManager,e,t,n);return}Tf.openToast({type:"fail",title:"링크 연결",content:"2개 이상의 노드를 선택해 주세요.",position:"top-right",duration:5e3})}handleLinkNodes=({nodes:e,strategy:t,bidirectional:n,properties:i})=>{this.setStrategy(t==="sequential"?new zm:new sC),this.execute(e,n,i)};handleUnlinkNodes=()=>{const e=this.getSelectedObjects();if(e.length<2){Tf.openToast({type:"fail",title:"링크 삭제",content:"2개 이상의 노드를 선택해 주세요.",position:"top-right",duration:5e3});return}for(let t=0;t<e.length-1;t++)for(let n=t+1;n<e.length;n++)this.nodeManager.unlinkNodes(e[t],e[n])}}function bv(r,e,t,n,i){r.linkNodes(e,t,i),n&&r.linkNodes(t,e,i)}const Hm={name:"",type:"NO_ENTRY"},aC=.2,Gm=.05,oC=.35,lC=1,cC=.85,dC=1,nh=.95,ih=.75,hC=.16,Vm=1,Wm=1.2,jm=1.45,uC=.2,fC=.35,sh=new Ne(16777215),pC=10,mC=30,gC=40;class bC{constructor(e,t,n,i){this.nodeManager=e,this.eventBus=t,this.getScene=n,this.zoneSelectableBridge=i}draftState="idle";draftEditingZoneId=null;draftSelectedVertexIndex=null;draftHoveredVertexIndex=null;draftMeta={...Hm};draftPoints=[];draftGroup=null;cursorPreviewMesh=null;draftVertexMeshes=[];draftOutlineLine=null;previewLine=null;closingLine=null;committedZoneObjects=new Map;hiddenCommittedZoneIds=new Set;selectedZoneIds=new Set;focusedZoneId=null;registerEventListeners(){this.eventBus.on("ui:mapping-start-requested",this.handleMappingStarted),this.eventBus.on("ui:mapping-stop-requested",this.handleMappingStopped),this.eventBus.on("ui:zone-draft-start-requested",this.handleDraftStart),this.eventBus.on("ui:zone-draft-cancel-requested",this.handleDraftCancel),this.eventBus.on("ui:zone-draft-clear-requested",this.handleDraftClear),this.eventBus.on("ui:zone-draft-undo-requested",this.handleDraftUndo),this.eventBus.on("ui:zone-draft-close-requested",this.handleDraftClose),this.eventBus.on("ui:zone-draft-reopen-requested",this.handleDraftReopen),this.eventBus.on("ui:zone-draft-commit-requested",this.handleDraftCommit),this.eventBus.on("ui:zone-edit-start-requested",this.handleEditStart),this.eventBus.on("ui:zone-focus-requested",this.handleZoneFocusRequested),this.eventBus.on("ui:zone-draft-meta-updated",this.handleDraftMetaUpdated),this.eventBus.on("viewport:zone-point-preview-updated",this.handlePreviewUpdated),this.eventBus.on("viewport:pointer-leave",this.handleViewportPointerLeave),this.eventBus.on("viewport:zone-point-place-requested",this.handlePointPlaced),this.eventBus.on("selector:zone-draft-vertex-selected",this.handleDraftVertexSelected),this.eventBus.on("viewport:zone-draft-vertex-moved",this.handleDraftVertexMoved),this.eventBus.on("viewport:zone-draft-vertex-hovered",this.handleDraftVertexHovered)}deregisterEventListeners(){this.eventBus.off("ui:mapping-start-requested",this.handleMappingStarted),this.eventBus.off("ui:mapping-stop-requested",this.handleMappingStopped),this.eventBus.off("ui:zone-draft-start-requested",this.handleDraftStart),this.eventBus.off("ui:zone-draft-cancel-requested",this.handleDraftCancel),this.eventBus.off("ui:zone-draft-clear-requested",this.handleDraftClear),this.eventBus.off("ui:zone-draft-undo-requested",this.handleDraftUndo),this.eventBus.off("ui:zone-draft-close-requested",this.handleDraftClose),this.eventBus.off("ui:zone-draft-reopen-requested",this.handleDraftReopen),this.eventBus.off("ui:zone-draft-commit-requested",this.handleDraftCommit),this.eventBus.off("ui:zone-edit-start-requested",this.handleEditStart),this.eventBus.off("ui:zone-focus-requested",this.handleZoneFocusRequested),this.eventBus.off("ui:zone-draft-meta-updated",this.handleDraftMetaUpdated),this.eventBus.off("viewport:zone-point-preview-updated",this.handlePreviewUpdated),this.eventBus.off("viewport:pointer-leave",this.handleViewportPointerLeave),this.eventBus.off("viewport:zone-point-place-requested",this.handlePointPlaced),this.eventBus.off("selector:zone-draft-vertex-selected",this.handleDraftVertexSelected),this.eventBus.off("viewport:zone-draft-vertex-moved",this.handleDraftVertexMoved),this.eventBus.off("viewport:zone-draft-vertex-hovered",this.handleDraftVertexHovered)}dispose(){this.deregisterEventListeners(),this.resetDraft(),this.clearCommittedZones()}resetDraft(){this.disposeDraftObjects(),this.draftState="idle",this.draftEditingZoneId=null,this.draftSelectedVertexIndex=null,this.draftHoveredVertexIndex=null,this.draftMeta={...Hm},this.draftPoints=[],this.emitDraftUpdated()}clearDraftVertexSelection(){this.draftSelectedVertexIndex=null,this.draftHoveredVertexIndex=null,this.eventBus.emit("selector:zone-draft-vertex-selected",{vertex:null,vertexIndex:null})}restoreEditingZoneVisibility(){this.draftEditingZoneId&&this.setCommittedZoneHidden(this.draftEditingZoneId,!1)}resetDraftSession(){this.clearDraftVertexSelection(),this.resetDraft()}ensureDraftObjects(){if(this.draftGroup)return;this.draftGroup=new Vt,this.draftGroup.name="topology-zone-draft",this.draftGroup.userData.keep=!0;const e=this.getZoneColor(this.draftMeta.type);this.cursorPreviewMesh=this.createPointMesh({color:e,transparent:!0,opacity:.35,radius:aC}),this.cursorPreviewMesh.visible=!1,this.draftGroup.add(this.cursorPreviewMesh),this.previewLine=this.createLine({color:e,transparent:!0,opacity:.5}),this.previewLine.visible=!1,this.draftGroup.add(this.previewLine),this.draftOutlineLine=this.createLine({color:e,transparent:!1,opacity:1}),this.draftOutlineLine.visible=!1,this.draftGroup.add(this.draftOutlineLine),this.closingLine=this.createLine({color:e,transparent:!1,opacity:1}),this.closingLine.visible=!1,this.draftGroup.add(this.closingLine),this.getScene().add(this.draftGroup)}disposeDraftObjects(){this.draftVertexMeshes.forEach(e=>{this.zoneSelectableBridge.unregisterSelectableZoneVertex(e),this.disposeObject(e)}),this.previewLine&&this.disposeObject(this.previewLine),this.draftOutlineLine&&this.disposeObject(this.draftOutlineLine),this.closingLine&&this.disposeObject(this.closingLine),this.cursorPreviewMesh&&this.disposeObject(this.cursorPreviewMesh),this.draftGroup?.parent&&this.draftGroup.parent.remove(this.draftGroup),this.draftVertexMeshes=[],this.draftOutlineLine=null,this.previewLine=null,this.closingLine=null,this.cursorPreviewMesh=null,this.draftGroup=null}createPointMesh({color:e,transparent:t,opacity:n,radius:i}){const s=new Pa(i),a=new jt({color:e,transparent:t,opacity:n,depthWrite:!t});return new Ee(s,a)}createLine({color:e,transparent:t,opacity:n}){const i=new ht,s=new zn({color:e,transparent:t,opacity:n});return new qn(i,s)}createLineLoop({color:e,transparent:t,opacity:n}){const i=new ht,s=new zn({color:e,transparent:t,opacity:n});return new Ab(i,s)}disposeObject(e){if(e.removeFromParent(),e instanceof Ee){e.geometry.dispose(),Array.isArray(e.material)?e.material.forEach(t=>t.dispose()):e.material.dispose();return}e instanceof qn&&(e.geometry.dispose(),Array.isArray(e.material)?e.material.forEach(t=>t.dispose()):e.material.dispose())}updateLinePositions(e,t,n){e&&this.replaceLineGeometry(e,[t,n])}replaceLineGeometry(e,t){e&&(e.geometry.dispose(),e.geometry=new ht().setFromPoints(t))}hideDraftPreview(){this.cursorPreviewMesh&&(this.cursorPreviewMesh.visible=!1),this.previewLine&&(this.previewLine.visible=!1)}updateDraftOutlineGeometry(){if(this.draftOutlineLine){if(this.draftPoints.length>=2){this.replaceLineGeometry(this.draftOutlineLine,this.draftPoints),this.draftOutlineLine.visible=!0;return}this.replaceLineGeometry(this.draftOutlineLine,[]),this.draftOutlineLine.visible=!1}}updateDraftClosingGeometry(){if(!this.closingLine)return;if(this.draftState!=="closed"||this.draftPoints.length<3){this.closingLine.visible=!1,this.replaceLineGeometry(this.closingLine,[]);return}const e=this.draftPoints[0],t=this.draftPoints[this.draftPoints.length-1];this.updateLinePositions(this.closingLine,t,e),this.closingLine.visible=!0}syncDraftVertexSelectableRegistration(){this.draftVertexMeshes.forEach(e=>{this.zoneSelectableBridge.unregisterSelectableZoneVertex(e)}),this.draftState==="closed"&&this.draftVertexMeshes.forEach(e=>{this.zoneSelectableBridge.registerSelectableZoneVertex(e)})}updateDraftVertexMeshes(){const e=this.getZoneColor(this.draftMeta.type),t=new Ne(e),n=t.clone().lerp(sh,uC),i=t.clone().lerp(sh,fC);for(let s=0;s<this.draftVertexMeshes.length;s++){const a=this.draftVertexMeshes[s],o=this.draftPoints[s];if(!o)continue;a.position.copy(o);const l=this.draftSelectedVertexIndex===s?jm:this.draftHoveredVertexIndex===s?Wm:Vm;if(a.scale.setScalar(l),a.material instanceof jt){const c=this.draftSelectedVertexIndex===s,d=this.draftHoveredVertexIndex===s;a.material.color.copy(c?i:d?n:t),a.material.opacity=this.draftState==="closed"?d||c?1:nh:ih}}this.syncDraftVertexSelectableRegistration()}rebuildDraftVertexMeshes(){const e=this.getZoneColor(this.draftMeta.type);this.draftVertexMeshes.forEach(t=>{this.zoneSelectableBridge.unregisterSelectableZoneVertex(t),this.disposeObject(t)}),this.draftVertexMeshes=[];for(let t=0;t<this.draftPoints.length;t++){const n=this.draftPoints[t],i=this.createPointMesh({color:e,transparent:!0,opacity:this.draftState==="closed"?nh:ih,radius:hC});i.name=`topology-zone-draft-vertex-${t}`,i.position.copy(n),i.userData={...i.userData,objectType:"topology-zone-draft-vertex",vertexIndex:t,keep:!0},i.scale.setScalar(this.draftSelectedVertexIndex===t?jm:this.draftHoveredVertexIndex===t?Wm:Vm),this.draftVertexMeshes.push(i),this.draftGroup?.add(i)}this.updateDraftVertexMeshes()}syncDraftGeometry(){if(this.ensureDraftObjects(),this.updateDraftOutlineGeometry(),this.updateDraftClosingGeometry(),this.draftVertexMeshes.length!==this.draftPoints.length){this.rebuildDraftVertexMeshes();return}this.updateDraftVertexMeshes()}emitDraftUpdated(){this.eventBus.emit("zone:draft-updated",{state:this.draftState,editingZoneId:this.draftEditingZoneId,selectedVertexIndex:this.draftSelectedVertexIndex,name:this.draftMeta.name,type:this.draftMeta.type,pointCount:this.draftPoints.length,points:this.draftPoints.map(e=>({x:e.x,y:e.y,z:e.z}))})}getZoneColor(e){return rm[e]??rm.NO_ENTRY}updateDraftColors(){const e=this.getZoneColor(this.draftMeta.type);this.cursorPreviewMesh?.material instanceof jt&&this.cursorPreviewMesh.material.color.setHex(e),this.draftVertexMeshes.forEach(t=>{t.material instanceof jt&&(t.material.color.setHex(e),t.material.opacity=this.draftState==="closed"?nh:ih)}),[this.previewLine,this.closingLine,this.draftOutlineLine].forEach(t=>{t?.material instanceof zn&&t.material.color.setHex(e)})}renderCommittedZones(e){e.forEach(t=>{this.renderCommittedZone(t)})}focusCommittedZones(e){this.selectedZoneIds=new Set(e),(!this.focusedZoneId||!this.selectedZoneIds.has(this.focusedZoneId))&&(this.focusedZoneId=e[0]??null),this.refreshCommittedZoneHighlights()}focusActiveCommittedZone(e){this.focusedZoneId=e,this.refreshCommittedZoneHighlights()}clearCommittedZones(){this.committedZoneObjects.forEach(e=>{this.disposeCommittedZone(e)}),this.committedZoneObjects.clear(),this.hiddenCommittedZoneIds.clear(),this.focusedZoneId=null}removeCommittedZone(e){const t=this.committedZoneObjects.get(e);t&&(this.selectedZoneIds.delete(e),this.focusedZoneId===e&&(this.focusedZoneId=null),this.hiddenCommittedZoneIds.delete(e),this.disposeCommittedZone(t),this.committedZoneObjects.delete(e))}refreshCommittedZoneHighlights(){this.committedZoneObjects.forEach((e,t)=>{this.applyCommittedZoneHighlight(e,this.selectedZoneIds.has(t),this.focusedZoneId===t)})}setCommittedZonesVisibility(e){this.committedZoneObjects.forEach(t=>{t.group.visible=e&&!this.hiddenCommittedZoneIds.has(String(t.group.userData.zoneId))})}setCommittedZoneHidden(e,t){t?this.hiddenCommittedZoneIds.add(e):this.hiddenCommittedZoneIds.delete(e);const n=this.committedZoneObjects.get(e);n&&(n.group.visible=!t)}getPolygonBoundsCenter(e){if(!e.length)return new me;let t=e[0].x,n=e[0].x,i=e[0].y,s=e[0].y;for(let a=1;a<e.length;a++){const o=e[a];t=Math.min(t,o.x),n=Math.max(n,o.x),i=Math.min(i,o.y),s=Math.max(s,o.y)}return new me((t+n)/2,(i+s)/2)}createCommittedZoneHitMesh(e,t){const n=new Ib(e.polygon.map(o=>new me(o.x-t.x,o.y-t.y))),i=new Yu(n),s=new jt({color:this.getZoneColor(e.type),transparent:!0,opacity:Gm,side:ln,depthWrite:!1}),a=new Ee(i,s);return a.name=`topology-zone-hit-${e.id}`,a.position.z=-.001,a.userData={...a.userData,zoneId:e.id,topologyObjectType:"zone",objectType:"topology-zone-hit-area"},a}createCommittedZoneBoundingBoxLine(e,t){const n=e.polygon.map(a=>new me(a.x-t.x,a.y-t.y)),i=new Ws().setFromPoints(n),s=this.createLineLoop({color:Yb,transparent:!1,opacity:1});return s.name=`topology-zone-bounds-${e.id}`,s.renderOrder=gC,s.position.z=.01,s.visible=!1,s.geometry.setFromPoints([new I(i.min.x,i.min.y,0),new I(i.max.x,i.min.y,0),new I(i.max.x,i.max.y,0),new I(i.min.x,i.max.y,0)]),s}getHighlightedZoneColor(e){return new Ne(this.getZoneColor(e)).lerp(sh,.35)}applyCommittedZoneHighlight(e,t,n){const i=e.group.userData.zoneType,s=this.getZoneColor(i??"NO_ENTRY"),a=t?this.getHighlightedZoneColor(i??"NO_ENTRY"):new Ne(s);e.lineLoop.material instanceof zn&&(e.lineLoop.material.color.copy(a),e.lineLoop.material.transparent=!0,e.lineLoop.material.opacity=n?dC:t?lC:cC),e.hitMesh.material instanceof jt&&(e.hitMesh.material.color.setHex(s),e.hitMesh.material.opacity=n?oC:t?0:Gm),e.boundingBoxLine.visible=n}disposeCommittedZone(e){this.zoneSelectableBridge.unregisterSelectableZone(e.hitMesh),this.disposeObject(e.hitMesh),this.disposeObject(e.lineLoop),this.disposeObject(e.boundingBoxLine),e.group.parent&&e.group.parent.remove(e.group),e.group.clear()}renderCommittedZone(e){if(e.polygon.length<3)return;const t=this.committedZoneObjects.get(e.id);t&&(this.disposeCommittedZone(t),this.committedZoneObjects.delete(e.id));const n=new Vt,i=this.getPolygonBoundsCenter(e.polygon);n.position.set(i.x,i.y,0),n.name=`topology-zone-${e.id}`,n.userData={...n.userData,zoneId:e.id,zoneType:e.type,topologyObjectType:"zone",keep:!0};const s=this.createLineLoop({color:this.getZoneColor(e.type),transparent:!1,opacity:1});s.renderOrder=mC,s.name=`topology-zone-outline-${e.id}`,s.userData={...s.userData,zoneId:e.id,topologyObjectType:"zone"},s.geometry.setFromPoints(e.polygon.map(c=>new I(c.x-i.x,c.y-i.y,0)));const a=this.createCommittedZoneHitMesh(e,i),o=this.createCommittedZoneBoundingBoxLine(e,i);a.renderOrder=pC,a.userData={...a.userData,zoneOwner:n},n.add(a),n.add(s),n.add(o),this.getScene().add(n),this.zoneSelectableBridge.registerSelectableZone(a);const l={group:n,lineLoop:s,boundingBoxLine:o,hitMesh:a};this.hiddenCommittedZoneIds.has(e.id)&&(n.visible=!1),this.applyCommittedZoneHighlight(l,this.selectedZoneIds.has(e.id),this.focusedZoneId===e.id),this.committedZoneObjects.set(e.id,l)}handleMappingStarted=()=>{this.setCommittedZonesVisibility(!1)};handleMappingStopped=()=>{this.setCommittedZonesVisibility(!0)};handleDraftStart=({name:e,type:t})=>{this.restoreEditingZoneVisibility(),this.clearDraftVertexSelection(),this.disposeDraftObjects(),this.draftEditingZoneId=null,this.draftPoints=[],this.ensureDraftObjects(),this.draftMeta={name:e,type:t},this.draftState="drawing",this.syncDraftGeometry(),this.updateDraftColors(),this.emitDraftUpdated()};handleDraftCancel=()=>{this.restoreEditingZoneVisibility(),this.resetDraftSession()};handleDraftClear=()=>{this.resetDraft()};handleDraftUndo=()=>{this.draftState==="idle"||this.draftState==="closed"||this.draftPoints.length===0||(this.draftPoints=this.draftPoints.slice(0,-1),this.syncDraftGeometry(),this.hideDraftPreview(),this.emitDraftUpdated())};handleDraftClose=()=>{this.draftPoints.length<3||this.draftState==="closed"||(this.draftState="closed",this.clearDraftVertexSelection(),this.syncDraftGeometry(),this.cursorPreviewMesh&&(this.cursorPreviewMesh.visible=!1),this.previewLine&&(this.previewLine.visible=!1),this.emitDraftUpdated())};handleDraftReopen=()=>{this.draftState==="closed"&&(this.draftState="drawing",this.clearDraftVertexSelection(),this.hideDraftPreview(),this.syncDraftGeometry(),this.emitDraftUpdated())};handleDraftCommit=()=>{if(this.draftState!=="closed"||this.draftPoints.length<3)return;const e=this.draftEditingZoneId,t={id:e??bt.generateUUID(),name:this.draftMeta.name,type:this.draftMeta.type,polygon:this.draftPoints.map(i=>({x:i.x,y:i.y}))},n=e!==null;if(n){if(!this.nodeManager.updateTopologyZone(t))return;this.setCommittedZoneHidden(t.id,!1)}else this.nodeManager.addTopologyZone(t);this.renderCommittedZone(t),this.nodeManager.emitTopologyChanged(n?"zone-updated":"zone-created"),this.resetDraftSession()};handleEditStart=({zoneId:e})=>{const t=this.nodeManager.getTopologyZone(e);t&&(this.restoreEditingZoneVisibility(),this.clearDraftVertexSelection(),this.disposeDraftObjects(),this.draftEditingZoneId=t.id,this.draftMeta={name:t.name,type:t.type},this.focusActiveCommittedZone(t.id),this.draftPoints=t.polygon.map(n=>new I(n.x,n.y,0)),this.draftState="closed",this.setCommittedZoneHidden(t.id,!0),this.syncDraftGeometry(),this.updateDraftColors(),this.emitDraftUpdated())};handleZoneFocusRequested=({zoneId:e})=>{this.focusActiveCommittedZone(e)};handleDraftMetaUpdated=({name:e,type:t})=>{typeof e=="string"&&(this.draftMeta.name=e),typeof t=="string"&&(this.draftMeta.type=t,this.updateDraftColors()),this.emitDraftUpdated()};handlePreviewUpdated=({point:e})=>{if(this.draftState!=="drawing")return;this.ensureDraftObjects(),this.cursorPreviewMesh&&(this.cursorPreviewMesh.position.copy(e),this.cursorPreviewMesh.position.z=0,this.cursorPreviewMesh.visible=!0);const t=this.draftPoints[this.draftPoints.length-1];if(!t||!this.previewLine){this.previewLine&&(this.previewLine.visible=!1);return}this.updateLinePositions(this.previewLine,t,e),this.previewLine.visible=!0};handleViewportPointerLeave=()=>{this.draftHoveredVertexIndex!==null&&(this.draftHoveredVertexIndex=null,this.draftVertexMeshes.length>0&&this.updateDraftVertexMeshes()),this.hideDraftPreview()};handlePointPlaced=({point:e})=>{if(this.draftState!=="drawing")return;this.ensureDraftObjects();const t=e.clone();t.z=0,this.draftPoints=[...this.draftPoints,t],this.syncDraftGeometry(),this.emitDraftUpdated()};handleDraftVertexSelected=({vertexIndex:e})=>{this.draftSelectedVertexIndex=e,this.draftVertexMeshes.length>0&&(this.updateDraftVertexMeshes(),this.updateDraftColors()),this.emitDraftUpdated()};handleDraftVertexMoved=({vertexIndex:e,point:t})=>{if(this.draftState!=="closed"||e<0||e>=this.draftPoints.length)return;const n=t.clone();n.z=0,this.draftPoints=this.draftPoints.map((i,s)=>s===e?n:i),this.syncDraftGeometry(),this.updateDraftColors(),this.emitDraftUpdated()};handleDraftVertexHovered=({vertexIndex:e})=>{const t=this.draftState==="closed"?e:null;this.draftHoveredVertexIndex!==t&&(this.draftHoveredVertexIndex=t,this.draftVertexMeshes.length>0&&this.updateDraftVertexMeshes())}}const vv=.012,vC=.012,yC=.35,yv=new Oc(vv,24);yv.translate(0,0,vC);class xC{constructor(e){this.editor=e,this.linkModule=new rC(this,this.editor.eventHandler.eventBus,()=>this.editor.selectionManager.getSelectedObjects()),this.zoneModule=new bC(this,this.editor.eventHandler.eventBus,()=>this.editor.scene,{registerSelectableZone:t=>this.editor.selectionManager.registerSelectableZone(t),unregisterSelectableZone:t=>this.editor.selectionManager.unregisterSelectableZone(t),registerSelectableZoneVertex:t=>this.editor.selectionManager.registerSelectableZoneVertex(t),unregisterSelectableZoneVertex:t=>this.editor.selectionManager.unregisterSelectableZoneVertex(t)})}goalMesh;routeMesh;alignMesh;markerMesh;arrowMap=new Map;materialMap={GOAL:null,ROUTE:null,ALIGN:null,MARKER:null};NODE_TYPE_MAP={[gs.GOAL]:"GOAL",[gs.ROUTE]:"ROUTE",[gs.ALIGN]:"ALIGN"};nodeRadiusMap={GOAL:0,ROUTE:0,ALIGN:0,MARKER:0};topologyLinks=[];topologyZones=[];isArrowLayerVisible=!0;linkVisibilityFilter={dir:"all",method:"all"};linkModule;zoneModule;MAX_ID=9999;nodeRenderMode="default";simpleMaterialMap={GOAL:new Fn({color:12186288,side:ln}),ROUTE:new Fn({color:1573017,side:ln}),ALIGN:new Fn({color:16727988,side:ln}),MARKER:new Fn({color:16727988,side:ln})};usedIds=new Set;lastIssued=-1;normalizeLinkDirection(e){return String(e??"").toUpperCase()==="REVERSE"?"REVERSE":"FORWARD"}normalizeLinkMethod(e){const t=String(e??"").toUpperCase();return t==="HPP"||t==="TNG"||t==="SIDE"?t:"PP"}clampNumber(e,t,n,i){return typeof e!="number"||Number.isNaN(e)?i:Math.min(n,Math.max(t,e))}registerEventListeners(){const e=this.editor.eventHandler.eventBus;e.on("editor:initialized",this.handleEditorInitialized),e.on("ui:mapping-start-requested",this.handleMappingStarted),e.on("ui:mapping-stop-requested",this.handleMappingStopped),e.on("ui:topo-update-requested",this.handleUpdateTopology),e.on("ui:add-node-by-preview-requested",this.handleAddNodeByPreview),e.on("ui:quick-add-node-requested",this.handleQuickAnnotation),e.on("ui:node-updated",this.handleNodeUpdated),e.on("ui:node-type-change-requested",this.handleNodeTypeChange),e.on("ui:node-render-mode-set-requested",this.handleNodeRenderModeRequested),e.on("ui:nodes-transform-delta-requested",this.handleNodesTransformDeltaRequested),e.on("ui:nodes-transform-absolute-requested",this.handleNodesTransformAbsoluteRequested),e.on("ui:nodes-delete-requested",this.handleDeleteNodes),e.on("ui:link-updated",this.handleLinkUpdated),e.on("ui:link-delete-requested",this.handleLinkDeleted),e.on("ui:link-focus-requested",this.handleLinkFocused),e.on("selector:link-selected",this.handleLinkSelected),e.on("selector:zone-selected",this.handleZoneSelected),e.on("node-manager:selection-transform-changed",this.handleSelectionTransformChanged),e.on("viewport:zone-translation-committed",this.handleZoneTranslationCommitted),e.on("ui:link-visibility-filter-requested",this.handleLinkVisibilityFilterRequested),this.linkModule.registerEventListeners(),this.zoneModule.registerEventListeners()}deRegisterEventListeners(){const e=this.editor.eventHandler.eventBus;e.off("editor:initialized",this.handleEditorInitialized),e.off("ui:mapping-start-requested",this.handleMappingStarted),e.off("ui:mapping-stop-requested",this.handleMappingStopped),e.off("ui:topo-update-requested",this.handleUpdateTopology),e.off("ui:add-node-by-preview-requested",this.handleAddNodeByPreview),e.off("ui:quick-add-node-requested",this.handleQuickAnnotation),e.off("ui:node-updated",this.handleNodeUpdated),e.off("ui:node-type-change-requested",this.handleNodeTypeChange),e.off("ui:node-render-mode-set-requested",this.handleNodeRenderModeRequested),e.off("ui:nodes-transform-delta-requested",this.handleNodesTransformDeltaRequested),e.off("ui:nodes-transform-absolute-requested",this.handleNodesTransformAbsoluteRequested),e.off("ui:nodes-delete-requested",this.handleDeleteNodes),e.off("ui:link-updated",this.handleLinkUpdated),e.off("ui:link-delete-requested",this.handleLinkDeleted),e.off("ui:link-focus-requested",this.handleLinkFocused),e.off("selector:link-selected",this.handleLinkSelected),e.off("selector:zone-selected",this.handleZoneSelected),e.off("node-manager:selection-transform-changed",this.handleSelectionTransformChanged),e.off("viewport:zone-translation-committed",this.handleZoneTranslationCommitted),e.off("ui:link-visibility-filter-requested",this.handleLinkVisibilityFilterRequested),this.linkModule.deregisterEventListeners(),this.zoneModule.deregisterEventListeners()}clearTopo(){this.clearArrows(),this.zoneModule.resetDraft(),this.zoneModule.clearCommittedZones();const e=[];this.editor.scene.traverse(t=>{t instanceof Hs&&t.userData.labelType==="node"?(t.element&&t.element.parentNode&&t.element.parentNode.removeChild(t.element),e.push(t)):t.userData.keep||e.push(t)});for(let t=0,n=e.length;t<n;t++){const i=e[t];this.editor.removeObject(i)}this.editor.selectionManager.reset(),this.topologyLinks=[],this.topologyZones=[],this.editor.eventHandler.eventBus.emit("node-manager:topo-updated")}async drawTopo(e){const t=e?.nodes??[];if(this.topologyLinks=(e?.links??[]).map(i=>({...i,dir:this.normalizeLinkDirection(i.dir),method:this.normalizeLinkMethod(i.method),slowMarginX:this.clampNumber(i.slowMarginX,-1,1,0),slowMarginY:this.clampNumber(i.slowMarginY,-1,1,0),stopMarginX:this.clampNumber(i.stopMarginX,-1,1,0),stopMarginY:this.clampNumber(i.stopMarginY,-1,1,0)})),this.topologyZones=[...e?.zones??[]],this.zoneModule.clearCommittedZones(),!t.length){this.zoneModule.renderCommittedZones(this.topologyZones),this.editor.eventHandler.eventBus.emit("node-manager:topo-updated");return}const n=t.map((i,s)=>{const a=h=>h===void 0||Number.isNaN(h)?0:h,o=i.pose,l={x:a(o.x),y:a(o.y),z:a(o.z),rx:Yd(a(o.rx)),ry:Yd(a(o.ry)),rz:Yd(a(o.rz)),idx:s},c={name:i.name,id:i.id,context:i.context,features:Array.isArray(i.features)?i.features.filter(h=>typeof h=="string"):[],safetyField:typeof i.safetyField=="number"?i.safetyField:0},d=this.NODE_TYPE_MAP[i.type];if(!d){console.warn(`[DRAW TOPO] This type of node is not supported: ${i.type}`);return}return this.addNode(d,l,c)});await Promise.all(n);for(let i=0,s=this.topologyLinks.length;i<s;i++)this.renderTopologyLink(this.topologyLinks[i]);this.applyArrowVisibilityFilter(),this.zoneModule.renderCommittedZones(this.topologyZones),this.editor.eventHandler.eventBus.emit("node-manager:topo-updated")}findObjectByUserDataId(e,t){if(e.userData?.id===t)return e;for(const n of e.children){const i=this.findObjectByUserDataId(n,t);if(i)return i}return null}dispose(){this.clearArrows(),this.deRegisterEventListeners()}addLabel(e){const t=document.createElement("div");t.className="nodeLabel italic text-base p-1 font-semibold rounded-sm",t.textContent=e.name,t.style.cssText=`
|
|
4389
|
+
*/var Di=Uint8Array,la=Uint16Array,w1=Int32Array,ov=new Di([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]),lv=new Di([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]),S1=new Di([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),cv=function(r,e){for(var t=new la(31),n=0;n<31;++n)t[n]=e+=1<<r[n-1];for(var i=new w1(t[30]),n=1;n<30;++n)for(var s=t[n];s<t[n+1];++s)i[s]=s-t[n]<<5|n;return{b:t,r:i}},dv=cv(ov,2),hv=dv.b,M1=dv.r;hv[28]=258,M1[258]=28;var T1=cv(lv,0),E1=T1.b,Mu=new la(32768);for(var en=0;en<32768;++en){var Us=(en&43690)>>1|(en&21845)<<1;Us=(Us&52428)>>2|(Us&13107)<<2,Us=(Us&61680)>>4|(Us&3855)<<4,Mu[en]=((Us&65280)>>8|(Us&255)<<8)>>1}var po=(function(r,e,t){for(var n=r.length,i=0,s=new la(e);i<n;++i)r[i]&&++s[r[i]-1];var a=new la(e);for(i=1;i<e;++i)a[i]=a[i-1]+s[i-1]<<1;var o;if(t){o=new la(1<<e);var l=15-e;for(i=0;i<n;++i)if(r[i])for(var c=i<<4|r[i],d=e-r[i],h=a[r[i]-1]++<<d,u=h|(1<<d)-1;h<=u;++h)o[Mu[h]>>l]=c}else for(o=new la(n),i=0;i<n;++i)r[i]&&(o[i]=Mu[a[r[i]-1]++]>>15-r[i]);return o}),Fo=new Di(288);for(var en=0;en<144;++en)Fo[en]=8;for(var en=144;en<256;++en)Fo[en]=9;for(var en=256;en<280;++en)Fo[en]=7;for(var en=280;en<288;++en)Fo[en]=8;var uv=new Di(32);for(var en=0;en<32;++en)uv[en]=5;var A1=po(Fo,9,1),C1=po(uv,5,1),Qd=function(r){for(var e=r[0],t=1;t<r.length;++t)r[t]>e&&(e=r[t]);return e},Hi=function(r,e,t){var n=e/8|0;return(r[n]|r[n+1]<<8)>>(e&7)&t},Jd=function(r,e){var t=e/8|0;return(r[t]|r[t+1]<<8|r[t+2]<<16)>>(e&7)},P1=function(r){return(r+7)/8|0},R1=function(r,e,t){return(t==null||t>r.length)&&(t=r.length),new Di(r.subarray(e,t))},N1=["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"],Vi=function(r,e,t){var n=new Error(e||N1[r]);if(n.code=r,Error.captureStackTrace&&Error.captureStackTrace(n,Vi),!t)throw n;return n},D1=function(r,e,t,n){var i=r.length,s=0;if(!i||e.f&&!e.l)return t||new Di(0);var a=!t,o=a||e.i!=2,l=e.i;a&&(t=new Di(i*3));var c=function(Ce){var je=t.length;if(Ce>je){var Fe=new Di(Math.max(je*2,Ce));Fe.set(t),t=Fe}},d=e.f||0,h=e.p||0,u=e.b||0,f=e.l,m=e.d,b=e.m,p=e.n,g=i*8;do{if(!f){d=Hi(r,h,1);var y=Hi(r,h+1,3);if(h+=3,y)if(y==1)f=A1,m=C1,b=9,p=5;else if(y==2){var T=Hi(r,h,31)+257,A=Hi(r,h+10,15)+4,M=T+Hi(r,h+5,31)+1;h+=14;for(var _=new Di(M),S=new Di(19),R=0;R<A;++R)S[S1[R]]=Hi(r,h+R*3,7);h+=A*3;for(var k=Qd(S),O=(1<<k)-1,H=po(S,k,1),R=0;R<M;){var q=H[Hi(r,h,O)];h+=q&15;var x=q>>4;if(x<16)_[R++]=x;else{var G=0,K=0;for(x==16?(K=3+Hi(r,h,3),h+=2,G=_[R-1]):x==17?(K=3+Hi(r,h,7),h+=3):x==18&&(K=11+Hi(r,h,127),h+=7);K--;)_[R++]=G}}var V=_.subarray(0,T),Y=_.subarray(T);b=Qd(V),p=Qd(Y),f=po(V,b,1),m=po(Y,p,1)}else Vi(1);else{var x=P1(h)+4,w=r[x-4]|r[x-3]<<8,P=x+w;if(P>i){l&&Vi(0);break}o&&c(u+w),t.set(r.subarray(x,P),u),e.b=u+=w,e.p=h=P*8,e.f=d;continue}if(h>g){l&&Vi(0);break}}o&&c(u+131072);for(var le=(1<<b)-1,se=(1<<p)-1,ge=h;;ge=h){var G=f[Jd(r,h)&le],de=G>>4;if(h+=G&15,h>g){l&&Vi(0);break}if(G||Vi(2),de<256)t[u++]=de;else if(de==256){ge=h,f=null;break}else{var X=de-254;if(de>264){var R=de-257,ee=ov[R];X=Hi(r,h,(1<<ee)-1)+hv[R],h+=ee}var ie=m[Jd(r,h)&se],Z=ie>>4;ie||Vi(3),h+=ie&15;var Y=E1[Z];if(Z>3){var ee=lv[Z];Y+=Jd(r,h)&(1<<ee)-1,h+=ee}if(h>g){l&&Vi(0);break}o&&c(u+131072);var ue=u+X;if(u<Y){var oe=s-Y,be=Math.min(Y,ue);for(oe+u<0&&Vi(3);u<be;++u)t[u]=n[oe+u]}for(;u<ue;++u)t[u]=t[u-Y]}}e.l=f,e.p=ge,e.b=u,e.f=d,f&&(d=1,e.m=b,e.d=m,e.n=p)}while(!d);return u!=t.length&&a?R1(t,0,u):t.subarray(0,u)},L1=new Di(0),I1=function(r,e){return((r[0]&15)!=8||r[0]>>4>7||(r[0]<<8|r[1])%31)&&Vi(6,"invalid zlib data"),(r[1]>>5&1)==1&&Vi(6,"invalid zlib data: "+(r[1]&32?"need":"unexpected")+" dictionary"),(r[1]>>3&4)+2};function k1(r,e){return D1(r.subarray(I1(r),-4),{i:2},e,e)}var O1=typeof TextDecoder<"u"&&new TextDecoder,F1=0;try{O1.decode(L1,{stream:!0}),F1=1}catch{}function fv(r,e,t){const n=t.length-r-1;if(e>=t[n])return n-1;if(e<=t[r])return r;let i=r,s=n,a=Math.floor((i+s)/2);for(;e<t[a]||e>=t[a+1];)e<t[a]?s=a:i=a,a=Math.floor((i+s)/2);return a}function U1(r,e,t,n){const i=[],s=[],a=[];i[0]=1;for(let o=1;o<=t;++o){s[o]=e-n[r+1-o],a[o]=n[r+o]-e;let l=0;for(let c=0;c<o;++c){const d=a[c+1],h=s[o-c],u=i[c]/(d+h);i[c]=l+d*u,l=h*u}i[o]=l}return i}function B1(r,e,t,n){const i=fv(r,n,e),s=U1(i,n,r,e),a=new _t(0,0,0,0);for(let o=0;o<=r;++o){const l=t[i-r+o],c=s[o],d=l.w*c;a.x+=l.x*d,a.y+=l.y*d,a.z+=l.z*d,a.w+=l.w*c}return a}function z1(r,e,t,n,i){const s=[];for(let h=0;h<=t;++h)s[h]=0;const a=[];for(let h=0;h<=n;++h)a[h]=s.slice(0);const o=[];for(let h=0;h<=t;++h)o[h]=s.slice(0);o[0][0]=1;const l=s.slice(0),c=s.slice(0);for(let h=1;h<=t;++h){l[h]=e-i[r+1-h],c[h]=i[r+h]-e;let u=0;for(let f=0;f<h;++f){const m=c[f+1],b=l[h-f];o[h][f]=m+b;const p=o[f][h-1]/o[h][f];o[f][h]=u+m*p,u=b*p}o[h][h]=u}for(let h=0;h<=t;++h)a[0][h]=o[h][t];for(let h=0;h<=t;++h){let u=0,f=1;const m=[];for(let b=0;b<=t;++b)m[b]=s.slice(0);m[0][0]=1;for(let b=1;b<=n;++b){let p=0;const g=h-b,y=t-b;h>=b&&(m[f][0]=m[u][0]/o[y+1][g],p=m[f][0]*o[g][y]);const x=g>=-1?1:-g,w=h-1<=y?b-1:t-h;for(let T=x;T<=w;++T)m[f][T]=(m[u][T]-m[u][T-1])/o[y+1][g+T],p+=m[f][T]*o[g+T][y];h<=y&&(m[f][b]=-m[u][b-1]/o[y+1][h],p+=m[f][b]*o[h][y]),a[b][h]=p;const P=u;u=f,f=P}}let d=t;for(let h=1;h<=n;++h){for(let u=0;u<=t;++u)a[h][u]*=d;d*=t-h}return a}function H1(r,e,t,n,i){const s=i<r?i:r,a=[],o=fv(r,n,e),l=z1(o,n,r,s,e),c=[];for(let d=0;d<t.length;++d){const h=t[d].clone(),u=h.w;h.x*=u,h.y*=u,h.z*=u,c[d]=h}for(let d=0;d<=s;++d){const h=c[o-r].clone().multiplyScalar(l[d][0]);for(let u=1;u<=r;++u)h.add(c[o-r+u].clone().multiplyScalar(l[d][u]));a[d]=h}for(let d=s+1;d<=i+1;++d)a[d]=new _t(0,0,0);return a}function G1(r,e){let t=1;for(let i=2;i<=r;++i)t*=i;let n=1;for(let i=2;i<=e;++i)n*=i;for(let i=2;i<=r-e;++i)n*=i;return t/n}function V1(r){const e=r.length,t=[],n=[];for(let s=0;s<e;++s){const a=r[s];t[s]=new I(a.x,a.y,a.z),n[s]=a.w}const i=[];for(let s=0;s<e;++s){const a=t[s].clone();for(let o=1;o<=s;++o)a.sub(i[s-o].clone().multiplyScalar(G1(s,o)*n[o]));i[s]=a.divideScalar(n[0])}return i}function W1(r,e,t,n,i){const s=H1(r,e,t,n,i);return V1(s)}class j1 extends Yi{constructor(e,t,n,i,s){super();const a=t?t.length-1:0,o=n?n.length:0;this.degree=e,this.knots=t,this.controlPoints=[],this.startKnot=i||0,this.endKnot=s||a;for(let l=0;l<o;++l){const c=n[l];this.controlPoints[l]=new _t(c.x,c.y,c.z,c.w)}}getPoint(e,t=new I){const n=t,i=this.knots[this.startKnot]+e*(this.knots[this.endKnot]-this.knots[this.startKnot]),s=B1(this.degree,this.knots,this.controlPoints,i);return s.w!==1&&s.divideScalar(s.w),n.set(s.x,s.y,s.z)}getTangent(e,t=new I){const n=t,i=this.knots[0]+e*(this.knots[this.knots.length-1]-this.knots[0]),s=W1(this.degree,this.knots,this.controlPoints,i,1);return n.copy(s[1]).normalize(),n}toJSON(){const e=super.toJSON();return e.degree=this.degree,e.knots=[...this.knots],e.controlPoints=this.controlPoints.map(t=>t.toArray()),e.startKnot=this.startKnot,e.endKnot=this.endKnot,e}fromJSON(e){return super.fromJSON(e),this.degree=e.degree,this.knots=[...e.knots],this.controlPoints=e.controlPoints.map(t=>new _t(t[0],t[1],t[2],t[3])),this.startKnot=e.startKnot,this.endKnot=e.endKnot,this}}let Tt,un,ti;class X1 extends pi{constructor(e){super(e)}load(e,t,n,i){const s=this,a=s.path===""?qs.extractUrlBase(e):s.path,o=new Ys(this.manager);o.setPath(s.path),o.setResponseType("arraybuffer"),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(e,function(l){try{t(s.parse(l,a))}catch(c){i?i(c):console.error(c),s.manager.itemError(e)}},n,i)}parse(e,t){if(Q1(e))Tt=new $1().parse(e);else{const i=gv(e);if(!J1(i))throw new Error("THREE.FBXLoader: Unknown format.");if(Bm(i)<7e3)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+Bm(i));Tt=new K1().parse(i)}const n=new Lo(this.manager).setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin);return new q1(n,this.manager).parse(Tt)}}class q1{constructor(e,t){this.textureLoader=e,this.manager=t}parse(){un=this.parseConnections();const e=this.parseImages(),t=this.parseTextures(e),n=this.parseMaterials(t),i=this.parseDeformers(),s=new Z1().parse(i);return this.parseScene(i,s,n),ti}parseConnections(){const e=new Map;return"Connections"in Tt&&Tt.Connections.connections.forEach(function(n){const i=n[0],s=n[1],a=n[2];e.has(i)||e.set(i,{parents:[],children:[]});const o={ID:s,relationship:a};e.get(i).parents.push(o),e.has(s)||e.set(s,{parents:[],children:[]});const l={ID:i,relationship:a};e.get(s).children.push(l)}),e}parseImages(){const e={},t={};if("Video"in Tt.Objects){const n=Tt.Objects.Video;for(const i in n){const s=n[i],a=parseInt(i);if(e[a]=s.RelativeFilename||s.Filename,"Content"in s){const o=s.Content instanceof ArrayBuffer&&s.Content.byteLength>0,l=typeof s.Content=="string"&&s.Content!=="";if(o||l){const c=this.parseImage(n[i]);t[s.RelativeFilename||s.Filename]=c}}}}for(const n in e){const i=e[n];t[i]!==void 0?e[n]=t[i]:e[n]=e[n].split("\\").pop()}return e}parseImage(e){const t=e.Content,n=e.RelativeFilename||e.Filename,i=n.slice(n.lastIndexOf(".")+1).toLowerCase();let s;switch(i){case"bmp":s="image/bmp";break;case"jpg":case"jpeg":s="image/jpeg";break;case"png":s="image/png";break;case"tif":s="image/tiff";break;case"tga":this.manager.getHandler(".tga")===null&&console.warn("FBXLoader: TGA loader not found, skipping ",n),s="image/tga";break;default:console.warn('FBXLoader: Image type "'+i+'" is not supported.');return}if(typeof t=="string")return"data:"+s+";base64,"+t;{const a=new Uint8Array(t);return window.URL.createObjectURL(new Blob([a],{type:s}))}}parseTextures(e){const t=new Map;if("Texture"in Tt.Objects){const n=Tt.Objects.Texture;for(const i in n){const s=this.parseTexture(n[i],e);t.set(parseInt(i),s)}}return t}parseTexture(e,t){const n=this.loadTexture(e,t);n.ID=e.id,n.name=e.attrName;const i=e.WrapModeU,s=e.WrapModeV,a=i!==void 0?i.value:0,o=s!==void 0?s.value:0;if(n.wrapS=a===0?Li:ui,n.wrapT=o===0?Li:ui,"Scaling"in e){const l=e.Scaling.value;n.repeat.x=l[0],n.repeat.y=l[1]}if("Translation"in e){const l=e.Translation.value;n.offset.x=l[0],n.offset.y=l[1]}return n}loadTexture(e,t){const n=new Set(["tga","tif","tiff","exr","dds","hdr","ktx2"]),i=e.FileName.split(".").pop().toLowerCase(),s=n.has(i)?this.manager.getHandler(`.${i}`):this.textureLoader;if(!s)return console.warn(`FBXLoader: ${i.toUpperCase()} loader not found, creating placeholder texture for`,e.RelativeFilename),new Ut;const a=s.path;a||s.setPath(this.textureLoader.path);const o=un.get(e.id).children;let l;o!==void 0&&o.length>0&&t[o[0].ID]!==void 0&&(l=t[o[0].ID],(l.indexOf("blob:")===0||l.indexOf("data:")===0)&&s.setPath(void 0));const c=s.load(l);return s.setPath(a),c}parseMaterials(e){const t=new Map;if("Material"in Tt.Objects){const n=Tt.Objects.Material;for(const i in n){const s=this.parseMaterial(n[i],e);s!==null&&t.set(parseInt(i),s)}}return t}parseMaterial(e,t){const n=e.id,i=e.attrName;let s=e.ShadingModel;if(typeof s=="object"&&(s=s.value),!un.has(n))return null;const a=this.parseParameters(e,t,n);let o;switch(s.toLowerCase()){case"phong":o=new Ii;break;case"lambert":o=new Fn;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.',s),o=new Ii;break}return o.setValues(a),o.name=i,o}parseParameters(e,t,n){const i={};e.BumpFactor&&(i.bumpScale=e.BumpFactor.value),e.Diffuse?i.color=ft.toWorkingColorSpace(new Ne().fromArray(e.Diffuse.value),gt):e.DiffuseColor&&(e.DiffuseColor.type==="Color"||e.DiffuseColor.type==="ColorRGB")&&(i.color=ft.toWorkingColorSpace(new Ne().fromArray(e.DiffuseColor.value),gt)),e.DisplacementFactor&&(i.displacementScale=e.DisplacementFactor.value),e.Emissive?i.emissive=ft.toWorkingColorSpace(new Ne().fromArray(e.Emissive.value),gt):e.EmissiveColor&&(e.EmissiveColor.type==="Color"||e.EmissiveColor.type==="ColorRGB")&&(i.emissive=ft.toWorkingColorSpace(new Ne().fromArray(e.EmissiveColor.value),gt)),e.EmissiveFactor&&(i.emissiveIntensity=parseFloat(e.EmissiveFactor.value)),i.opacity=1-(e.TransparencyFactor?parseFloat(e.TransparencyFactor.value):0),(i.opacity===1||i.opacity===0)&&(i.opacity=e.Opacity?parseFloat(e.Opacity.value):null,i.opacity===null&&(i.opacity=1-(e.TransparentColor?parseFloat(e.TransparentColor.value[0]):0))),i.opacity<1&&(i.transparent=!0),e.ReflectionFactor&&(i.reflectivity=e.ReflectionFactor.value),e.Shininess&&(i.shininess=e.Shininess.value),e.Specular?i.specular=ft.toWorkingColorSpace(new Ne().fromArray(e.Specular.value),gt):e.SpecularColor&&e.SpecularColor.type==="Color"&&(i.specular=ft.toWorkingColorSpace(new Ne().fromArray(e.SpecularColor.value),gt));const s=this;return un.get(n).children.forEach(function(a){const o=a.relationship;switch(o){case"Bump":i.bumpMap=s.getTexture(t,a.ID);break;case"Maya|TEX_ao_map":i.aoMap=s.getTexture(t,a.ID);break;case"DiffuseColor":case"Maya|TEX_color_map":i.map=s.getTexture(t,a.ID),i.map!==void 0&&(i.map.colorSpace=gt);break;case"DisplacementColor":i.displacementMap=s.getTexture(t,a.ID);break;case"EmissiveColor":i.emissiveMap=s.getTexture(t,a.ID),i.emissiveMap!==void 0&&(i.emissiveMap.colorSpace=gt);break;case"NormalMap":case"Maya|TEX_normal_map":i.normalMap=s.getTexture(t,a.ID);break;case"ReflectionColor":i.envMap=s.getTexture(t,a.ID),i.envMap!==void 0&&(i.envMap.mapping=vc,i.envMap.colorSpace=gt);break;case"SpecularColor":i.specularMap=s.getTexture(t,a.ID),i.specularMap!==void 0&&(i.specularMap.colorSpace=gt);break;case"TransparentColor":case"TransparencyFactor":i.alphaMap=s.getTexture(t,a.ID),i.transparent=!0;break;case"AmbientColor":case"ShininessExponent":case"SpecularFactor":case"VectorDisplacementColor":default:console.warn("THREE.FBXLoader: %s map is not supported in three.js, skipping texture.",o);break}}),i}getTexture(e,t){return"LayeredTexture"in Tt.Objects&&t in Tt.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),t=un.get(t).children[0].ID),e.get(t)}parseDeformers(){const e={},t={};if("Deformer"in Tt.Objects){const n=Tt.Objects.Deformer;for(const i in n){const s=n[i],a=un.get(parseInt(i));if(s.attrType==="Skin"){const o=this.parseSkeleton(a,n);o.ID=i,a.parents.length>1&&console.warn("THREE.FBXLoader: skeleton attached to more than one geometry is not supported."),o.geometryID=a.parents[0].ID,e[i]=o}else if(s.attrType==="BlendShape"){const o={id:i};o.rawTargets=this.parseMorphTargets(a,n),o.id=i,a.parents.length>1&&console.warn("THREE.FBXLoader: morph target attached to more than one geometry is not supported."),t[i]=o}}}return{skeletons:e,morphTargets:t}}parseSkeleton(e,t){const n=[];return e.children.forEach(function(i){const s=t[i.ID];if(s.attrType!=="Cluster")return;const a={ID:i.ID,indices:[],weights:[],transformLink:new Ie().fromArray(s.TransformLink.a)};"Indexes"in s&&(a.indices=s.Indexes.a,a.weights=s.Weights.a),n.push(a)}),{rawBones:n,bones:[]}}parseMorphTargets(e,t){const n=[];for(let i=0;i<e.children.length;i++){const s=e.children[i],a=t[s.ID],o={name:a.attrName,initialWeight:a.DeformPercent,id:a.id,fullWeights:a.FullWeights.a};if(a.attrType!=="BlendShapeChannel")return;o.geoID=un.get(parseInt(s.ID)).children.filter(function(l){return l.relationship===void 0})[0].ID,n.push(o)}return n}parseScene(e,t,n){ti=new Vt;const i=this.parseModels(e.skeletons,t,n),s=Tt.Objects.Model,a=this;i.forEach(function(l){const c=s[l.ID];a.setLookAtProperties(l,c),un.get(l.ID).parents.forEach(function(h){const u=i.get(h.ID);u!==void 0&&u.add(l)}),l.parent===null&&ti.add(l)}),this.bindSkeleton(e.skeletons,t,i),this.addGlobalSceneSettings(),ti.traverse(function(l){if(l.userData.transformData){l.parent&&(l.userData.transformData.parentMatrix=l.parent.matrix,l.userData.transformData.parentMatrixWorld=l.parent.matrixWorld);const c=mv(l.userData.transformData);l.applyMatrix4(c),l.updateWorldMatrix()}});const o=new Y1().parse();ti.children.length===1&&ti.children[0].isGroup&&(ti.children[0].animations=o,ti=ti.children[0]),ti.animations=o}parseModels(e,t,n){const i=new Map,s=Tt.Objects.Model;for(const a in s){const o=parseInt(a),l=s[a],c=un.get(o);let d=this.buildSkeleton(c,e,o,l.attrName);if(!d){switch(l.attrType){case"Camera":d=this.createCamera(c);break;case"Light":d=this.createLight(c);break;case"Mesh":d=this.createMesh(c,t,n);break;case"NurbsCurve":d=this.createCurve(c,t);break;case"LimbNode":case"Root":d=new _o;break;case"Null":default:d=new Vt;break}d.name=l.attrName?Dt.sanitizeNodeName(l.attrName):"",d.userData.originalName=l.attrName,d.ID=o}this.getTransformData(d,l),i.set(o,d)}return i}buildSkeleton(e,t,n,i){let s=null;return e.parents.forEach(function(a){for(const o in t){const l=t[o];l.rawBones.forEach(function(c,d){if(c.ID===a.ID){const h=s;s=new _o,s.matrixWorld.copy(c.transformLink),s.name=i?Dt.sanitizeNodeName(i):"",s.userData.originalName=i,s.ID=n,l.bones[d]=s,h!==null&&s.add(h)}})}}),s}createCamera(e){let t,n;if(e.children.forEach(function(i){const s=Tt.Objects.NodeAttribute[i.ID];s!==void 0&&(n=s)}),n===void 0)t=new Pt;else{let i=0;n.CameraProjectionType!==void 0&&n.CameraProjectionType.value===1&&(i=1);let s=1;n.NearPlane!==void 0&&(s=n.NearPlane.value/1e3);let a=1e3;n.FarPlane!==void 0&&(a=n.FarPlane.value/1e3);let o=window.innerWidth,l=window.innerHeight;n.AspectWidth!==void 0&&n.AspectHeight!==void 0&&(o=n.AspectWidth.value,l=n.AspectHeight.value);const c=o/l;let d=45;n.FieldOfView!==void 0&&(d=n.FieldOfView.value);const h=n.FocalLength?n.FocalLength.value:null;switch(i){case 0:t=new gn(d,c,s,a),h!==null&&t.setFocalLength(h);break;case 1:console.warn("THREE.FBXLoader: Orthographic cameras not supported yet."),t=new Pt;break;default:console.warn("THREE.FBXLoader: Unknown camera type "+i+"."),t=new Pt;break}}return t}createLight(e){let t,n;if(e.children.forEach(function(i){const s=Tt.Objects.NodeAttribute[i.ID];s!==void 0&&(n=s)}),n===void 0)t=new Pt;else{let i;n.LightType===void 0?i=0:i=n.LightType.value;let s=16777215;n.Color!==void 0&&(s=ft.toWorkingColorSpace(new Ne().fromArray(n.Color.value),gt));let a=n.Intensity===void 0?1:n.Intensity.value/100;n.CastLightOnObject!==void 0&&n.CastLightOnObject.value===0&&(a=0);let o=0;n.FarAttenuationEnd!==void 0&&(n.EnableFarAttenuation!==void 0&&n.EnableFarAttenuation.value===0?o=0:o=n.FarAttenuationEnd.value);const l=1;switch(i){case 0:t=new Tc(s,a,o,l);break;case 1:t=new Hc(s,a);break;case 2:let c=Math.PI/3;n.InnerAngle!==void 0&&(c=bt.degToRad(n.InnerAngle.value));let d=0;n.OuterAngle!==void 0&&(d=bt.degToRad(n.OuterAngle.value),d=Math.max(d,1)),t=new $u(s,a,o,c,d,l);break;default:console.warn("THREE.FBXLoader: Unknown light type "+n.LightType.value+", defaulting to a PointLight."),t=new Tc(s,a);break}n.CastShadows!==void 0&&n.CastShadows.value===1&&(t.castShadow=!0)}return t}createMesh(e,t,n){let i,s=null,a=null;const o=[];if(e.children.forEach(function(l){t.has(l.ID)&&(s=t.get(l.ID)),n.has(l.ID)&&o.push(n.get(l.ID))}),o.length>1?a=o:o.length>0?a=o[0]:(a=new Ii({name:pi.DEFAULT_MATERIAL_NAME,color:13421772}),o.push(a)),"color"in s.attributes&&o.forEach(function(l){l.vertexColors=!0}),s.groups.length>0){let l=!1;for(let c=0,d=s.groups.length;c<d;c++){const h=s.groups[c];(h.materialIndex<0||h.materialIndex>=o.length)&&(h.materialIndex=o.length,l=!0)}if(l){const c=new Ii;o.push(c)}}return s.FBX_Deformer?(i=new Vu(s,a),i.normalizeSkinWeights()):i=new Ee(s,a),i}createCurve(e,t){const n=e.children.reduce(function(s,a){return t.has(a.ID)&&(s=t.get(a.ID)),s},null),i=new zn({name:pi.DEFAULT_MATERIAL_NAME,color:3342591,linewidth:1});return new qn(n,i)}getTransformData(e,t){const n={};"InheritType"in t&&(n.inheritType=parseInt(t.InheritType.value)),"RotationOrder"in t?n.eulerOrder=Eo(t.RotationOrder.value):n.eulerOrder=Eo(0),"Lcl_Translation"in t&&(n.translation=t.Lcl_Translation.value),"PreRotation"in t&&(n.preRotation=t.PreRotation.value),"Lcl_Rotation"in t&&(n.rotation=t.Lcl_Rotation.value),"PostRotation"in t&&(n.postRotation=t.PostRotation.value),"Lcl_Scaling"in t&&(n.scale=t.Lcl_Scaling.value),"ScalingOffset"in t&&(n.scalingOffset=t.ScalingOffset.value),"ScalingPivot"in t&&(n.scalingPivot=t.ScalingPivot.value),"RotationOffset"in t&&(n.rotationOffset=t.RotationOffset.value),"RotationPivot"in t&&(n.rotationPivot=t.RotationPivot.value),e.userData.transformData=n}setLookAtProperties(e,t){"LookAtProperty"in t&&un.get(e.ID).children.forEach(function(i){if(i.relationship==="LookAtProperty"){const s=Tt.Objects.Model[i.ID];if("Lcl_Translation"in s){const a=s.Lcl_Translation.value;e.target!==void 0?(e.target.position.fromArray(a),ti.add(e.target)):e.lookAt(new I().fromArray(a))}}})}bindSkeleton(e,t,n){const i=this.parsePoseNodes();for(const s in e){const a=e[s];un.get(parseInt(a.ID)).parents.forEach(function(l){if(t.has(l.ID)){const c=l.ID;un.get(c).parents.forEach(function(h){n.has(h.ID)&&n.get(h.ID).bind(new Ro(a.bones),i[h.ID])})}})}}parsePoseNodes(){const e={};if("Pose"in Tt.Objects){const t=Tt.Objects.Pose;for(const n in t)if(t[n].attrType==="BindPose"&&t[n].NbPoseNodes>0){const i=t[n].PoseNode;Array.isArray(i)?i.forEach(function(s){e[s.Node]=new Ie().fromArray(s.Matrix.a)}):e[i.Node]=new Ie().fromArray(i.Matrix.a)}}return e}addGlobalSceneSettings(){if("GlobalSettings"in Tt){if("AmbientColor"in Tt.GlobalSettings){const e=Tt.GlobalSettings.AmbientColor.value,t=e[0],n=e[1],i=e[2];if(t!==0||n!==0||i!==0){const s=new Ne().setRGB(t,n,i,gt);ti.add(new Gb(s,1))}}"UnitScaleFactor"in Tt.GlobalSettings&&(ti.userData.unitScaleFactor=Tt.GlobalSettings.UnitScaleFactor.value)}}}class Z1{constructor(){this.negativeMaterialIndices=!1}parse(e){const t=new Map;if("Geometry"in Tt.Objects){const n=Tt.Objects.Geometry;for(const i in n){const s=un.get(parseInt(i)),a=this.parseGeometry(s,n[i],e);t.set(parseInt(i),a)}}return this.negativeMaterialIndices===!0&&console.warn("THREE.FBXLoader: The FBX file contains invalid (negative) material indices. The asset might not render as expected."),t}parseGeometry(e,t,n){switch(t.attrType){case"Mesh":return this.parseMeshGeometry(e,t,n);case"NurbsCurve":return this.parseNurbsGeometry(t)}}parseMeshGeometry(e,t,n){const i=n.skeletons,s=[],a=e.parents.map(function(h){return Tt.Objects.Model[h.ID]});if(a.length===0)return;const o=e.children.reduce(function(h,u){return i[u.ID]!==void 0&&(h=i[u.ID]),h},null);e.children.forEach(function(h){n.morphTargets[h.ID]!==void 0&&s.push(n.morphTargets[h.ID])});const l=a[0],c={};"RotationOrder"in l&&(c.eulerOrder=Eo(l.RotationOrder.value)),"InheritType"in l&&(c.inheritType=parseInt(l.InheritType.value)),"GeometricTranslation"in l&&(c.translation=l.GeometricTranslation.value),"GeometricRotation"in l&&(c.rotation=l.GeometricRotation.value),"GeometricScaling"in l&&(c.scale=l.GeometricScaling.value);const d=mv(c);return this.genGeometry(t,o,s,d)}genGeometry(e,t,n,i){const s=new ht;e.attrName&&(s.name=e.attrName);const a=this.parseGeoNode(e,t),o=this.genBuffers(a),l=new ke(o.vertex,3);if(l.applyMatrix4(i),s.setAttribute("position",l),o.colors.length>0&&s.setAttribute("color",new ke(o.colors,3)),t&&(s.setAttribute("skinIndex",new zu(o.weightsIndices,4)),s.setAttribute("skinWeight",new ke(o.vertexWeights,4)),s.FBX_Deformer=t),o.normal.length>0){const c=new xt().getNormalMatrix(i),d=new ke(o.normal,3);d.applyNormalMatrix(c),s.setAttribute("normal",d)}if(o.uvs.forEach(function(c,d){const h=d===0?"uv":`uv${d}`;s.setAttribute(h,new ke(o.uvs[d],2))}),a.material&&a.material.mappingType!=="AllSame"){let c=o.materialIndex[0],d=0;if(o.materialIndex.forEach(function(h,u){h!==c&&(s.addGroup(d,u-d,c),c=h,d=u)}),s.groups.length>0){const h=s.groups[s.groups.length-1],u=h.start+h.count;u!==o.materialIndex.length&&s.addGroup(u,o.materialIndex.length-u,c)}s.groups.length===0&&s.addGroup(0,o.materialIndex.length,o.materialIndex[0])}return this.addMorphTargets(s,e,n,i),s}parseGeoNode(e,t){const n={};if(n.vertexPositions=e.Vertices!==void 0?e.Vertices.a:[],n.vertexIndices=e.PolygonVertexIndex!==void 0?e.PolygonVertexIndex.a:[],e.LayerElementColor&&(n.color=this.parseVertexColors(e.LayerElementColor[0])),e.LayerElementMaterial&&(n.material=this.parseMaterialIndices(e.LayerElementMaterial[0])),e.LayerElementNormal&&(n.normal=this.parseNormals(e.LayerElementNormal[0])),e.LayerElementUV){n.uv=[];let i=0;for(;e.LayerElementUV[i];)e.LayerElementUV[i].UV&&n.uv.push(this.parseUVs(e.LayerElementUV[i])),i++}return n.weightTable={},t!==null&&(n.skeleton=t,t.rawBones.forEach(function(i,s){i.indices.forEach(function(a,o){n.weightTable[a]===void 0&&(n.weightTable[a]=[]),n.weightTable[a].push({id:s,weight:i.weights[o]})})})),n}genBuffers(e){const t={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]};let n=0,i=0,s=!1,a=[],o=[],l=[],c=[],d=[],h=[];const u=this;return e.vertexIndices.forEach(function(f,m){let b,p=!1;f<0&&(f=f^-1,p=!0);let g=[],y=[];if(a.push(f*3,f*3+1,f*3+2),e.color){const x=ql(m,n,f,e.color);l.push(x[0],x[1],x[2])}if(e.skeleton){if(e.weightTable[f]!==void 0&&e.weightTable[f].forEach(function(x){y.push(x.weight),g.push(x.id)}),y.length>4){s||(console.warn("THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."),s=!0);const x=[0,0,0,0],w=[0,0,0,0];y.forEach(function(P,T){let A=P,M=g[T];w.forEach(function(_,S,R){if(A>_){R[S]=A,A=_;const k=x[S];x[S]=M,M=k}})}),g=x,y=w}for(;y.length<4;)y.push(0),g.push(0);for(let x=0;x<4;++x)d.push(y[x]),h.push(g[x])}if(e.normal){const x=ql(m,n,f,e.normal);o.push(x[0],x[1],x[2])}e.material&&e.material.mappingType!=="AllSame"&&(b=ql(m,n,f,e.material)[0],b<0&&(u.negativeMaterialIndices=!0,b=0)),e.uv&&e.uv.forEach(function(x,w){const P=ql(m,n,f,x);c[w]===void 0&&(c[w]=[]),c[w].push(P[0]),c[w].push(P[1])}),i++,p&&(u.genFace(t,e,a,b,o,l,c,d,h,i),n++,i=0,a=[],o=[],l=[],c=[],d=[],h=[])}),t}getNormalNewell(e){const t=new I(0,0,0);for(let n=0;n<e.length;n++){const i=e[n],s=e[(n+1)%e.length];t.x+=(i.y-s.y)*(i.z+s.z),t.y+=(i.z-s.z)*(i.x+s.x),t.z+=(i.x-s.x)*(i.y+s.y)}return t.normalize(),t}getNormalTangentAndBitangent(e){const t=this.getNormalNewell(e),i=(Math.abs(t.z)>.5?new I(0,1,0):new I(0,0,1)).cross(t).normalize(),s=t.clone().cross(i).normalize();return{normal:t,tangent:i,bitangent:s}}flattenVertex(e,t,n){return new me(e.dot(t),e.dot(n))}genFace(e,t,n,i,s,a,o,l,c,d){let h;if(d>3){const u=[],f=t.baseVertexPositions||t.vertexPositions;for(let g=0;g<n.length;g+=3)u.push(new I(f[n[g]],f[n[g+1]],f[n[g+2]]));const{tangent:m,bitangent:b}=this.getNormalTangentAndBitangent(u),p=[];for(const g of u)p.push(this.flattenVertex(g,m,b));h=ma.triangulateShape(p,[])}else h=[[0,1,2]];for(const[u,f,m]of h)e.vertex.push(t.vertexPositions[n[u*3]]),e.vertex.push(t.vertexPositions[n[u*3+1]]),e.vertex.push(t.vertexPositions[n[u*3+2]]),e.vertex.push(t.vertexPositions[n[f*3]]),e.vertex.push(t.vertexPositions[n[f*3+1]]),e.vertex.push(t.vertexPositions[n[f*3+2]]),e.vertex.push(t.vertexPositions[n[m*3]]),e.vertex.push(t.vertexPositions[n[m*3+1]]),e.vertex.push(t.vertexPositions[n[m*3+2]]),t.skeleton&&(e.vertexWeights.push(l[u*4]),e.vertexWeights.push(l[u*4+1]),e.vertexWeights.push(l[u*4+2]),e.vertexWeights.push(l[u*4+3]),e.vertexWeights.push(l[f*4]),e.vertexWeights.push(l[f*4+1]),e.vertexWeights.push(l[f*4+2]),e.vertexWeights.push(l[f*4+3]),e.vertexWeights.push(l[m*4]),e.vertexWeights.push(l[m*4+1]),e.vertexWeights.push(l[m*4+2]),e.vertexWeights.push(l[m*4+3]),e.weightsIndices.push(c[u*4]),e.weightsIndices.push(c[u*4+1]),e.weightsIndices.push(c[u*4+2]),e.weightsIndices.push(c[u*4+3]),e.weightsIndices.push(c[f*4]),e.weightsIndices.push(c[f*4+1]),e.weightsIndices.push(c[f*4+2]),e.weightsIndices.push(c[f*4+3]),e.weightsIndices.push(c[m*4]),e.weightsIndices.push(c[m*4+1]),e.weightsIndices.push(c[m*4+2]),e.weightsIndices.push(c[m*4+3])),t.color&&(e.colors.push(a[u*3]),e.colors.push(a[u*3+1]),e.colors.push(a[u*3+2]),e.colors.push(a[f*3]),e.colors.push(a[f*3+1]),e.colors.push(a[f*3+2]),e.colors.push(a[m*3]),e.colors.push(a[m*3+1]),e.colors.push(a[m*3+2])),t.material&&t.material.mappingType!=="AllSame"&&(e.materialIndex.push(i),e.materialIndex.push(i),e.materialIndex.push(i)),t.normal&&(e.normal.push(s[u*3]),e.normal.push(s[u*3+1]),e.normal.push(s[u*3+2]),e.normal.push(s[f*3]),e.normal.push(s[f*3+1]),e.normal.push(s[f*3+2]),e.normal.push(s[m*3]),e.normal.push(s[m*3+1]),e.normal.push(s[m*3+2])),t.uv&&t.uv.forEach(function(b,p){e.uvs[p]===void 0&&(e.uvs[p]=[]),e.uvs[p].push(o[p][u*2]),e.uvs[p].push(o[p][u*2+1]),e.uvs[p].push(o[p][f*2]),e.uvs[p].push(o[p][f*2+1]),e.uvs[p].push(o[p][m*2]),e.uvs[p].push(o[p][m*2+1])})}addMorphTargets(e,t,n,i){if(n.length===0)return;e.morphTargetsRelative=!0,e.morphAttributes.position=[];const s=this;n.forEach(function(a){a.rawTargets.forEach(function(o){const l=Tt.Objects.Geometry[o.geoID];l!==void 0&&s.genMorphGeometry(e,t,l,i,o.name)})})}genMorphGeometry(e,t,n,i,s){const a=t.Vertices!==void 0?t.Vertices.a:[],o=t.PolygonVertexIndex!==void 0?t.PolygonVertexIndex.a:[],l=n.Vertices!==void 0?n.Vertices.a:[],c=n.Indexes!==void 0?n.Indexes.a:[],d=e.attributes.position.count*3,h=new Float32Array(d);for(let b=0;b<c.length;b++){const p=c[b]*3;h[p]=l[b*3],h[p+1]=l[b*3+1],h[p+2]=l[b*3+2]}const u={vertexIndices:o,vertexPositions:h,baseVertexPositions:a},f=this.genBuffers(u),m=new ke(f.vertex,3);m.name=s||n.attrName,m.applyMatrix4(i),e.morphAttributes.position.push(m)}parseNormals(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,i=e.Normals.a;let s=[];return n==="IndexToDirect"&&("NormalIndex"in e?s=e.NormalIndex.a:"NormalsIndex"in e&&(s=e.NormalsIndex.a)),{dataSize:3,buffer:i,indices:s,mappingType:t,referenceType:n}}parseUVs(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,i=e.UV.a;let s=[];return n==="IndexToDirect"&&(s=e.UVIndex.a),{dataSize:2,buffer:i,indices:s,mappingType:t,referenceType:n}}parseVertexColors(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,i=e.Colors.a;let s=[];n==="IndexToDirect"&&(s=e.ColorIndex.a);for(let a=0,o=new Ne;a<i.length;a+=4)o.fromArray(i,a),ft.toWorkingColorSpace(o,gt),o.toArray(i,a);return{dataSize:4,buffer:i,indices:s,mappingType:t,referenceType:n}}parseMaterialIndices(e){const t=e.MappingInformationType,n=e.ReferenceInformationType;if(t==="NoMappingInformation")return{dataSize:1,buffer:[0],indices:[0],mappingType:"AllSame",referenceType:n};const i=e.Materials.a,s=[];for(let a=0;a<i.length;++a)s.push(a);return{dataSize:1,buffer:i,indices:s,mappingType:t,referenceType:n}}parseNurbsGeometry(e){const t=parseInt(e.Order);if(isNaN(t))return console.error("THREE.FBXLoader: Invalid Order %s given for geometry ID: %s",e.Order,e.id),new ht;const n=t-1,i=e.KnotVector.a,s=[],a=e.Points.a;for(let h=0,u=a.length;h<u;h+=4)s.push(new _t().fromArray(a,h));let o,l;if(e.Form==="Closed")s.push(s[0]);else if(e.Form==="Periodic"){o=n,l=i.length-1-o;for(let h=0;h<n;++h)s.push(s[h])}const d=new j1(n,i,s,o,l).getPoints(s.length*12);return new ht().setFromPoints(d)}}class Y1{parse(){const e=[],t=this.parseClips();if(t!==void 0)for(const n in t){const i=t[n],s=this.addClip(i);e.push(s)}return e}parseClips(){if(Tt.Objects.AnimationCurve===void 0)return;const e=this.parseAnimationCurveNodes();this.parseAnimationCurves(e);const t=this.parseAnimationLayers(e);return this.parseAnimStacks(t)}parseAnimationCurveNodes(){const e=Tt.Objects.AnimationCurveNode,t=new Map;for(const n in e){const i=e[n];if(i.attrName.match(/S|R|T|DeformPercent/)!==null){const s={id:i.id,attr:i.attrName,curves:{}};t.set(s.id,s)}}return t}parseAnimationCurves(e){const t=Tt.Objects.AnimationCurve;for(const n in t){const i={id:t[n].id,times:t[n].KeyTime.a.map(eC),values:t[n].KeyValueFloat.a},s=un.get(i.id);if(s!==void 0){const a=s.parents[0].ID,o=s.parents[0].relationship;o.match(/X/)?e.get(a).curves.x=i:o.match(/Y/)?e.get(a).curves.y=i:o.match(/Z/)?e.get(a).curves.z=i:o.match(/DeformPercent/)&&e.has(a)&&(e.get(a).curves.morph=i)}}}parseAnimationLayers(e){const t=Tt.Objects.AnimationLayer,n=new Map;for(const i in t){const s=[],a=un.get(parseInt(i));a!==void 0&&(a.children.forEach(function(l,c){if(e.has(l.ID)){const d=e.get(l.ID);if(d.curves.x!==void 0||d.curves.y!==void 0||d.curves.z!==void 0){if(s[c]===void 0){const h=un.get(l.ID).parents.filter(function(u){return u.relationship!==void 0})[0].ID;if(h!==void 0){const u=Tt.Objects.Model[h.toString()];if(u===void 0){console.warn("THREE.FBXLoader: Encountered a unused curve.",l);return}const f={modelName:u.attrName?Dt.sanitizeNodeName(u.attrName):"",ID:u.id,initialPosition:[0,0,0],initialRotation:[0,0,0],initialScale:[1,1,1]};ti.traverse(function(m){m.ID===u.id&&(f.transform=m.matrix,m.userData.transformData&&(f.eulerOrder=m.userData.transformData.eulerOrder))}),f.transform||(f.transform=new Ie),"PreRotation"in u&&(f.preRotation=u.PreRotation.value),"PostRotation"in u&&(f.postRotation=u.PostRotation.value),s[c]=f}}s[c]&&(s[c][d.attr]=d)}else if(d.curves.morph!==void 0){if(s[c]===void 0){const h=un.get(l.ID).parents.filter(function(g){return g.relationship!==void 0})[0].ID,u=un.get(h).parents[0].ID,f=un.get(u).parents[0].ID,m=un.get(f).parents[0].ID,b=Tt.Objects.Model[m],p={modelName:b.attrName?Dt.sanitizeNodeName(b.attrName):"",morphName:Tt.Objects.Deformer[h].attrName};s[c]=p}s[c][d.attr]=d}}}),n.set(parseInt(i),s))}return n}parseAnimStacks(e){const t=Tt.Objects.AnimationStack,n={};for(const i in t){const s=un.get(parseInt(i)).children;s.length>1&&console.warn("THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers.");const a=e.get(s[0].ID);n[i]={name:t[i].attrName,layer:a}}return n}addClip(e){let t=[];const n=this;return e.layer.forEach(function(i){t=t.concat(n.generateTracks(i))}),new Mc(e.name,-1,t)}generateTracks(e){const t=[];let n=new I,i=new I;if(e.transform&&e.transform.decompose(n,new Lt,i),n=n.toArray(),i=i.toArray(),e.T!==void 0&&Object.keys(e.T.curves).length>0){const s=this.generateVectorTrack(e.modelName,e.T.curves,n,"position");s!==void 0&&t.push(s)}if(e.R!==void 0&&Object.keys(e.R.curves).length>0){const s=this.generateRotationTrack(e.modelName,e.R.curves,e.preRotation,e.postRotation,e.eulerOrder);s!==void 0&&t.push(s)}if(e.S!==void 0&&Object.keys(e.S.curves).length>0){const s=this.generateVectorTrack(e.modelName,e.S.curves,i,"scale");s!==void 0&&t.push(s)}if(e.DeformPercent!==void 0){const s=this.generateMorphTrack(e);s!==void 0&&t.push(s)}return t}generateVectorTrack(e,t,n,i){const s=this.getTimesForAllAxes(t),a=this.getKeyframeTrackValues(s,t,n);return new Es(e+"."+i,s,a)}generateRotationTrack(e,t,n,i,s){let a,o;if(t.x!==void 0&&t.y!==void 0&&t.z!==void 0){const u=this.interpolateRotations(t.x,t.y,t.z,s);a=u[0],o=u[1]}const l=Eo(0);n!==void 0&&(n=n.map(bt.degToRad),n.push(l),n=new hn().fromArray(n),n=new Lt().setFromEuler(n)),i!==void 0&&(i=i.map(bt.degToRad),i.push(l),i=new hn().fromArray(i),i=new Lt().setFromEuler(i).invert());const c=new Lt,d=new hn,h=[];if(!o||!a)return new Ts(e+".quaternion",[0],[0]);for(let u=0;u<o.length;u+=3)d.set(o[u],o[u+1],o[u+2],s),c.setFromEuler(d),n!==void 0&&c.premultiply(n),i!==void 0&&c.multiply(i),u>2&&new Lt().fromArray(h,(u-3)/3*4).dot(c)<0&&c.set(-c.x,-c.y,-c.z,-c.w),c.toArray(h,u/3*4);return new Ts(e+".quaternion",a,h)}generateMorphTrack(e){const t=e.DeformPercent.curves.morph,n=t.values.map(function(s){return s/100}),i=ti.getObjectByName(e.modelName).morphTargetDictionary[e.morphName];return new Mr(e.modelName+".morphTargetInfluences["+i+"]",t.times,n)}getTimesForAllAxes(e){let t=[];if(e.x!==void 0&&(t=t.concat(e.x.times)),e.y!==void 0&&(t=t.concat(e.y.times)),e.z!==void 0&&(t=t.concat(e.z.times)),t=t.sort(function(n,i){return n-i}),t.length>1){let n=1,i=t[0];for(let s=1;s<t.length;s++){const a=t[s];a!==i&&(t[n]=a,i=a,n++)}t=t.slice(0,n)}return t}getKeyframeTrackValues(e,t,n){const i=n,s=[];let a=-1,o=-1,l=-1;return e.forEach(function(c){if(t.x&&(a=t.x.times.indexOf(c)),t.y&&(o=t.y.times.indexOf(c)),t.z&&(l=t.z.times.indexOf(c)),a!==-1){const d=t.x.values[a];s.push(d),i[0]=d}else s.push(i[0]);if(o!==-1){const d=t.y.values[o];s.push(d),i[1]=d}else s.push(i[1]);if(l!==-1){const d=t.z.values[l];s.push(d),i[2]=d}else s.push(i[2])}),s}interpolateRotations(e,t,n,i){const s=[],a=[];s.push(e.times[0]),a.push(bt.degToRad(e.values[0])),a.push(bt.degToRad(t.values[0])),a.push(bt.degToRad(n.values[0]));for(let o=1;o<e.values.length;o++){const l=[e.values[o-1],t.values[o-1],n.values[o-1]];if(isNaN(l[0])||isNaN(l[1])||isNaN(l[2]))continue;const c=l.map(bt.degToRad),d=[e.values[o],t.values[o],n.values[o]];if(isNaN(d[0])||isNaN(d[1])||isNaN(d[2]))continue;const h=d.map(bt.degToRad),u=[d[0]-l[0],d[1]-l[1],d[2]-l[2]],f=[Math.abs(u[0]),Math.abs(u[1]),Math.abs(u[2])];if(f[0]>=180||f[1]>=180||f[2]>=180){const b=Math.max(...f)/180,p=new hn(...c,i),g=new hn(...h,i),y=new Lt().setFromEuler(p),x=new Lt().setFromEuler(g);y.dot(x)&&x.set(-x.x,-x.y,-x.z,-x.w);const w=e.times[o-1],P=e.times[o]-w,T=new Lt,A=new hn;for(let M=0;M<1;M+=1/b)T.copy(y.clone().slerp(x.clone(),M)),s.push(w+M*P),A.setFromQuaternion(T,i),a.push(A.x),a.push(A.y),a.push(A.z)}else s.push(e.times[o]),a.push(bt.degToRad(e.values[o])),a.push(bt.degToRad(t.values[o])),a.push(bt.degToRad(n.values[o]))}return[s,a]}}class K1{getPrevNode(){return this.nodeStack[this.currentIndent-2]}getCurrentNode(){return this.nodeStack[this.currentIndent-1]}getCurrentProp(){return this.currentProp}pushStack(e){this.nodeStack.push(e),this.currentIndent+=1}popStack(){this.nodeStack.pop(),this.currentIndent-=1}setCurrentProp(e,t){this.currentProp=e,this.currentPropName=t}parse(e){this.currentIndent=0,this.allNodes=new pv,this.nodeStack=[],this.currentProp=[],this.currentPropName="";const t=this,n=e.split(/[\r\n]+/);return n.forEach(function(i,s){const a=i.match(/^[\s\t]*;/),o=i.match(/^[\s\t]*$/);if(a||o)return;const l=i.match("^\\t{"+t.currentIndent+"}(\\w+):(.*){",""),c=i.match("^\\t{"+t.currentIndent+"}(\\w+):[\\s\\t\\r\\n](.*)"),d=i.match("^\\t{"+(t.currentIndent-1)+"}}");l?t.parseNodeBegin(i,l):c?t.parseNodeProperty(i,c,n[++s]):d?t.popStack():i.match(/^[^\s\t}]/)&&t.parseNodePropertyContinued(i)}),this.allNodes}parseNodeBegin(e,t){const n=t[1].trim().replace(/^"/,"").replace(/"$/,""),i=t[2].split(",").map(function(l){return l.trim().replace(/^"/,"").replace(/"$/,"")}),s={name:n},a=this.parseNodeAttr(i),o=this.getCurrentNode();this.currentIndent===0?this.allNodes.add(n,s):n in o?(n==="PoseNode"?o.PoseNode.push(s):o[n].id!==void 0&&(o[n]={},o[n][o[n].id]=o[n]),a.id!==""&&(o[n][a.id]=s)):typeof a.id=="number"?(o[n]={},o[n][a.id]=s):n!=="Properties70"&&(n==="PoseNode"?o[n]=[s]:o[n]=s),typeof a.id=="number"&&(s.id=a.id),a.name!==""&&(s.attrName=a.name),a.type!==""&&(s.attrType=a.type),this.pushStack(s)}parseNodeAttr(e){let t=e[0];e[0]!==""&&(t=parseInt(e[0]),isNaN(t)&&(t=e[0]));let n="",i="";return e.length>1&&(n=e[1].replace(/^(\w+)::/,""),i=e[2]),{id:t,name:n,type:i}}parseNodeProperty(e,t,n){let i=t[1].replace(/^"/,"").replace(/"$/,"").trim(),s=t[2].replace(/^"/,"").replace(/"$/,"").trim();i==="Content"&&s===","&&(s=n.replace(/"/g,"").replace(/,$/,"").trim());const a=this.getCurrentNode();if(a.name==="Properties70"){this.parseNodeSpecialProperty(e,i,s);return}if(i==="C"){const l=s.split(",").slice(1),c=parseInt(l[0]),d=parseInt(l[1]);let h=s.split(",").slice(3);h=h.map(function(u){return u.trim().replace(/^"/,"")}),i="connections",s=[c,d],nC(s,h),a[i]===void 0&&(a[i]=[])}i==="Node"&&(a.id=s),i in a&&Array.isArray(a[i])?a[i].push(s):i!=="a"?a[i]=s:a.a=s,this.setCurrentProp(a,i),i==="a"&&s.slice(-1)!==","&&(a.a=th(s))}parseNodePropertyContinued(e){const t=this.getCurrentNode();t.a+=e,e.slice(-1)!==","&&(t.a=th(t.a))}parseNodeSpecialProperty(e,t,n){const i=n.split('",').map(function(d){return d.trim().replace(/^\"/,"").replace(/\s/,"_")}),s=i[0],a=i[1],o=i[2],l=i[3];let c=i[4];switch(a){case"int":case"enum":case"bool":case"ULongLong":case"double":case"Number":case"FieldOfView":c=parseFloat(c);break;case"Color":case"ColorRGB":case"Vector3D":case"Lcl_Translation":case"Lcl_Rotation":case"Lcl_Scaling":c=th(c);break}this.getPrevNode()[s]={type:a,type2:o,flag:l,value:c},this.setCurrentProp(this.getPrevNode(),s)}}class $1{parse(e){const t=new Um(e);t.skip(23);const n=t.getUint32();if(n<6400)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+n);const i=new pv;for(;!this.endOfContent(t);){const s=this.parseNode(t,n);s!==null&&i.add(s.name,s)}return i}endOfContent(e){return e.size()%16===0?(e.getOffset()+160+16&-16)>=e.size():e.getOffset()+160+16>=e.size()}parseNode(e,t){const n={},i=t>=7500?e.getUint64():e.getUint32(),s=t>=7500?e.getUint64():e.getUint32();t>=7500?e.getUint64():e.getUint32();const a=e.getUint8(),o=e.getString(a);if(i===0)return null;const l=[];for(let u=0;u<s;u++)l.push(this.parseProperty(e));const c=l.length>0?l[0]:"",d=l.length>1?l[1]:"",h=l.length>2?l[2]:"";for(n.singleProperty=s===1&&e.getOffset()===i;i>e.getOffset();){const u=this.parseNode(e,t);u!==null&&this.parseSubNode(o,n,u)}return n.propertyList=l,typeof c=="number"&&(n.id=c),d!==""&&(n.attrName=d),h!==""&&(n.attrType=h),o!==""&&(n.name=o),n}parseSubNode(e,t,n){if(n.singleProperty===!0){const i=n.propertyList[0];Array.isArray(i)?(t[n.name]=n,n.a=i):t[n.name]=i}else if(e==="Connections"&&n.name==="C"){const i=[];n.propertyList.forEach(function(s,a){a!==0&&i.push(s)}),t.connections===void 0&&(t.connections=[]),t.connections.push(i)}else if(n.name==="Properties70")Object.keys(n).forEach(function(s){t[s]=n[s]});else if(e==="Properties70"&&n.name==="P"){let i=n.propertyList[0],s=n.propertyList[1];const a=n.propertyList[2],o=n.propertyList[3];let l;i.indexOf("Lcl ")===0&&(i=i.replace("Lcl ","Lcl_")),s.indexOf("Lcl ")===0&&(s=s.replace("Lcl ","Lcl_")),s==="Color"||s==="ColorRGB"||s==="Vector"||s==="Vector3D"||s.indexOf("Lcl_")===0?l=[n.propertyList[4],n.propertyList[5],n.propertyList[6]]:l=n.propertyList[4],t[i]={type:s,type2:a,flag:o,value:l}}else t[n.name]===void 0?typeof n.id=="number"?(t[n.name]={},t[n.name][n.id]=n):t[n.name]=n:n.name==="PoseNode"?(Array.isArray(t[n.name])||(t[n.name]=[t[n.name]]),t[n.name].push(n)):t[n.name][n.id]===void 0&&(t[n.name][n.id]=n)}parseProperty(e){const t=e.getString(1);let n;switch(t){case"C":return e.getBoolean();case"D":return e.getFloat64();case"F":return e.getFloat32();case"I":return e.getInt32();case"L":return e.getInt64();case"R":return n=e.getUint32(),e.getArrayBuffer(n);case"S":return n=e.getUint32(),e.getString(n);case"Y":return e.getInt16();case"b":case"c":case"d":case"f":case"i":case"l":const i=e.getUint32(),s=e.getUint32(),a=e.getUint32();if(s===0)switch(t){case"b":case"c":return e.getBooleanArray(i);case"d":return e.getFloat64Array(i);case"f":return e.getFloat32Array(i);case"i":return e.getInt32Array(i);case"l":return e.getInt64Array(i)}const o=k1(new Uint8Array(e.getArrayBuffer(a))),l=new Um(o.buffer);switch(t){case"b":case"c":return l.getBooleanArray(i);case"d":return l.getFloat64Array(i);case"f":return l.getFloat32Array(i);case"i":return l.getInt32Array(i);case"l":return l.getInt64Array(i)}break;default:throw new Error("THREE.FBXLoader: Unknown property type "+t)}}}class Um{constructor(e,t){this.dv=new DataView(e),this.offset=0,this.littleEndian=t!==void 0?t:!0,this._textDecoder=new TextDecoder}getOffset(){return this.offset}size(){return this.dv.buffer.byteLength}skip(e){this.offset+=e}getBoolean(){return(this.getUint8()&1)===1}getBooleanArray(e){const t=[];for(let n=0;n<e;n++)t.push(this.getBoolean());return t}getUint8(){const e=this.dv.getUint8(this.offset);return this.offset+=1,e}getInt16(){const e=this.dv.getInt16(this.offset,this.littleEndian);return this.offset+=2,e}getInt32(){const e=this.dv.getInt32(this.offset,this.littleEndian);return this.offset+=4,e}getInt32Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getInt32());return t}getUint32(){const e=this.dv.getUint32(this.offset,this.littleEndian);return this.offset+=4,e}getInt64(){let e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),t&2147483648?(t=~t&4294967295,e=~e&4294967295,e===4294967295&&(t=t+1&4294967295),e=e+1&4294967295,-(t*4294967296+e)):t*4294967296+e}getInt64Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getInt64());return t}getUint64(){let e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),t*4294967296+e}getFloat32(){const e=this.dv.getFloat32(this.offset,this.littleEndian);return this.offset+=4,e}getFloat32Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getFloat32());return t}getFloat64(){const e=this.dv.getFloat64(this.offset,this.littleEndian);return this.offset+=8,e}getFloat64Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getFloat64());return t}getArrayBuffer(e){const t=this.dv.buffer.slice(this.offset,this.offset+e);return this.offset+=e,t}getString(e){const t=this.offset;let n=new Uint8Array(this.dv.buffer,t,e);this.skip(e);const i=n.indexOf(0);return i>=0&&(n=new Uint8Array(this.dv.buffer,t,i)),this._textDecoder.decode(n)}}class pv{add(e,t){this[e]=t}}function Q1(r){const e="Kaydara FBX Binary \0";return r.byteLength>=e.length&&e===gv(r,0,e.length)}function J1(r){const e=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"];let t=0;function n(i){const s=r[i-1];return r=r.slice(t+i),t++,s}for(let i=0;i<e.length;++i)if(n(1)===e[i])return!1;return!0}function Bm(r){const e=/FBXVersion: (\d+)/,t=r.match(e);if(t)return parseInt(t[1]);throw new Error("THREE.FBXLoader: Cannot find the version number for the file given.")}function eC(r){return r/46186158e3}const tC=[];function ql(r,e,t,n){let i;switch(n.mappingType){case"ByPolygonVertex":i=r;break;case"ByPolygon":i=e;break;case"ByVertice":i=t;break;case"AllSame":i=n.indices[0];break;default:console.warn("THREE.FBXLoader: unknown attribute mapping type "+n.mappingType)}n.referenceType==="IndexToDirect"&&(i=n.indices[i]);const s=i*n.dataSize,a=s+n.dataSize;return iC(tC,n.buffer,s,a)}const eh=new hn,Jr=new I;function mv(r){const e=new Ie,t=new Ie,n=new Ie,i=new Ie,s=new Ie,a=new Ie,o=new Ie,l=new Ie,c=new Ie,d=new Ie,h=new Ie,u=new Ie,f=r.inheritType?r.inheritType:0;r.translation&&e.setPosition(Jr.fromArray(r.translation));const m=Eo(0);if(r.preRotation){const R=r.preRotation.map(bt.degToRad);R.push(m),t.makeRotationFromEuler(eh.fromArray(R))}if(r.rotation){const R=r.rotation.map(bt.degToRad);R.push(r.eulerOrder||m),n.makeRotationFromEuler(eh.fromArray(R))}if(r.postRotation){const R=r.postRotation.map(bt.degToRad);R.push(m),i.makeRotationFromEuler(eh.fromArray(R)),i.invert()}r.scale&&s.scale(Jr.fromArray(r.scale)),r.scalingOffset&&o.setPosition(Jr.fromArray(r.scalingOffset)),r.scalingPivot&&a.setPosition(Jr.fromArray(r.scalingPivot)),r.rotationOffset&&l.setPosition(Jr.fromArray(r.rotationOffset)),r.rotationPivot&&c.setPosition(Jr.fromArray(r.rotationPivot)),r.parentMatrixWorld&&(h.copy(r.parentMatrix),d.copy(r.parentMatrixWorld));const b=t.clone().multiply(n).multiply(i),p=new Ie;p.extractRotation(d);const g=new Ie;g.copyPosition(d);const y=g.clone().invert().multiply(d),x=p.clone().invert().multiply(y),w=s,P=new Ie;if(f===0)P.copy(p).multiply(b).multiply(x).multiply(w);else if(f===1)P.copy(p).multiply(x).multiply(b).multiply(w);else{const k=new Ie().scale(new I().setFromMatrixScale(h)).clone().invert(),O=x.clone().multiply(k);P.copy(p).multiply(b).multiply(O).multiply(w)}const T=c.clone().invert(),A=a.clone().invert();let M=e.clone().multiply(l).multiply(c).multiply(t).multiply(n).multiply(i).multiply(T).multiply(o).multiply(a).multiply(s).multiply(A);const _=new Ie().copyPosition(M),S=d.clone().multiply(_);return u.copyPosition(S),M=u.clone().multiply(P),M.premultiply(d.invert()),M}function Eo(r){r=r||0;const e=["ZYX","YZX","XZY","ZXY","YXZ","XYZ"];return r===6?(console.warn("THREE.FBXLoader: unsupported Euler Order: Spherical XYZ. Animations and rotations may be incorrect."),e[0]):e[r]}function th(r){return r.split(",").map(function(t){return parseFloat(t)})}function gv(r,e,t){return e===void 0&&(e=0),t===void 0&&(t=r.byteLength),new TextDecoder().decode(new Uint8Array(r,e,t))}function nC(r,e){for(let t=0,n=r.length,i=e.length;t<i;t++,n++)r[n]=e[t]}function iC(r,e,t,n){for(let i=t,s=0;i<n;i++,s++)r[s]=e[i];return r}class zm{link(e,t,n,i){for(let s=0;s<t.length-1;s++)bv(e,t[s],t[s+1],n,i)}}class sC{link(e,t,n,i){for(let s=0;s<t.length-1;s++)for(let a=s+1;a<t.length;a++)bv(e,t[s],t[a],n,i)}}class rC{constructor(e,t,n){this.nodeManager=e,this.eventBus=t,this.getSelectedObjects=n}strategy=new zm;registerEventListeners(){this.eventBus.on("ui:link-nodes-requested",this.handleLinkNodes),this.eventBus.on("ui:unlink-nodes-requested",this.handleUnlinkNodes)}deregisterEventListeners(){this.eventBus.off("ui:link-nodes-requested",this.handleLinkNodes),this.eventBus.off("ui:unlink-nodes-requested",this.handleUnlinkNodes)}dispose(){this.deregisterEventListeners()}setStrategy(e){this.strategy=e}execute(e,t,n){if(e.length>1){this.strategy.link(this.nodeManager,e,t,n);return}Tf.openToast({type:"fail",title:"링크 연결",content:"2개 이상의 노드를 선택해 주세요.",position:"top-right",duration:5e3})}handleLinkNodes=({nodes:e,strategy:t,bidirectional:n,properties:i})=>{this.setStrategy(t==="sequential"?new zm:new sC),this.execute(e,n,i)};handleUnlinkNodes=()=>{const e=this.getSelectedObjects();if(e.length<2){Tf.openToast({type:"fail",title:"링크 삭제",content:"2개 이상의 노드를 선택해 주세요.",position:"top-right",duration:5e3});return}for(let t=0;t<e.length-1;t++)for(let n=t+1;n<e.length;n++)this.nodeManager.unlinkNodes(e[t],e[n])}}function bv(r,e,t,n,i){r.linkNodes(e,t,i),n&&r.linkNodes(t,e,i)}const Hm={name:"",type:"NO_ENTRY"},aC=.2,Gm=.05,oC=.35,lC=1,cC=.85,dC=1,nh=.95,ih=.75,hC=.16,Vm=1,Wm=1.2,jm=1.45,uC=.2,fC=.35,sh=new Ne(16777215),pC=10,mC=30,gC=40;class bC{constructor(e,t,n,i){this.nodeManager=e,this.eventBus=t,this.getScene=n,this.zoneSelectableBridge=i}draftState="idle";draftEditingZoneId=null;draftSelectedVertexIndex=null;draftHoveredVertexIndex=null;draftMeta={...Hm};draftPoints=[];draftGroup=null;cursorPreviewMesh=null;draftVertexMeshes=[];draftOutlineLine=null;previewLine=null;closingLine=null;committedZoneObjects=new Map;hiddenCommittedZoneIds=new Set;selectedZoneIds=new Set;focusedZoneId=null;registerEventListeners(){this.eventBus.on("ui:mapping-start-requested",this.handleMappingStarted),this.eventBus.on("ui:mapping-stop-requested",this.handleMappingStopped),this.eventBus.on("ui:zone-draft-start-requested",this.handleDraftStart),this.eventBus.on("ui:zone-draft-cancel-requested",this.handleDraftCancel),this.eventBus.on("ui:zone-draft-clear-requested",this.handleDraftClear),this.eventBus.on("ui:zone-draft-undo-requested",this.handleDraftUndo),this.eventBus.on("ui:zone-draft-close-requested",this.handleDraftClose),this.eventBus.on("ui:zone-draft-reopen-requested",this.handleDraftReopen),this.eventBus.on("ui:zone-draft-commit-requested",this.handleDraftCommit),this.eventBus.on("ui:zone-edit-start-requested",this.handleEditStart),this.eventBus.on("ui:zone-focus-requested",this.handleZoneFocusRequested),this.eventBus.on("ui:zone-draft-meta-updated",this.handleDraftMetaUpdated),this.eventBus.on("viewport:zone-point-preview-updated",this.handlePreviewUpdated),this.eventBus.on("viewport:pointer-leave",this.handleViewportPointerLeave),this.eventBus.on("viewport:zone-point-place-requested",this.handlePointPlaced),this.eventBus.on("selector:zone-draft-vertex-selected",this.handleDraftVertexSelected),this.eventBus.on("viewport:zone-draft-vertex-moved",this.handleDraftVertexMoved),this.eventBus.on("viewport:zone-draft-vertex-hovered",this.handleDraftVertexHovered)}deregisterEventListeners(){this.eventBus.off("ui:mapping-start-requested",this.handleMappingStarted),this.eventBus.off("ui:mapping-stop-requested",this.handleMappingStopped),this.eventBus.off("ui:zone-draft-start-requested",this.handleDraftStart),this.eventBus.off("ui:zone-draft-cancel-requested",this.handleDraftCancel),this.eventBus.off("ui:zone-draft-clear-requested",this.handleDraftClear),this.eventBus.off("ui:zone-draft-undo-requested",this.handleDraftUndo),this.eventBus.off("ui:zone-draft-close-requested",this.handleDraftClose),this.eventBus.off("ui:zone-draft-reopen-requested",this.handleDraftReopen),this.eventBus.off("ui:zone-draft-commit-requested",this.handleDraftCommit),this.eventBus.off("ui:zone-edit-start-requested",this.handleEditStart),this.eventBus.off("ui:zone-focus-requested",this.handleZoneFocusRequested),this.eventBus.off("ui:zone-draft-meta-updated",this.handleDraftMetaUpdated),this.eventBus.off("viewport:zone-point-preview-updated",this.handlePreviewUpdated),this.eventBus.off("viewport:pointer-leave",this.handleViewportPointerLeave),this.eventBus.off("viewport:zone-point-place-requested",this.handlePointPlaced),this.eventBus.off("selector:zone-draft-vertex-selected",this.handleDraftVertexSelected),this.eventBus.off("viewport:zone-draft-vertex-moved",this.handleDraftVertexMoved),this.eventBus.off("viewport:zone-draft-vertex-hovered",this.handleDraftVertexHovered)}dispose(){this.deregisterEventListeners(),this.resetDraft(),this.clearCommittedZones()}resetDraft(){this.disposeDraftObjects(),this.draftState="idle",this.draftEditingZoneId=null,this.draftSelectedVertexIndex=null,this.draftHoveredVertexIndex=null,this.draftMeta={...Hm},this.draftPoints=[],this.emitDraftUpdated()}clearDraftVertexSelection(){this.draftSelectedVertexIndex=null,this.draftHoveredVertexIndex=null,this.eventBus.emit("selector:zone-draft-vertex-selected",{vertex:null,vertexIndex:null})}restoreEditingZoneVisibility(){this.draftEditingZoneId&&this.setCommittedZoneHidden(this.draftEditingZoneId,!1)}resetDraftSession(){this.clearDraftVertexSelection(),this.resetDraft()}ensureDraftObjects(){if(this.draftGroup)return;this.draftGroup=new Vt,this.draftGroup.name="topology-zone-draft",this.draftGroup.userData.keep=!0;const e=this.getZoneColor(this.draftMeta.type);this.cursorPreviewMesh=this.createPointMesh({color:e,transparent:!0,opacity:.35,radius:aC}),this.cursorPreviewMesh.visible=!1,this.draftGroup.add(this.cursorPreviewMesh),this.previewLine=this.createLine({color:e,transparent:!0,opacity:.5}),this.previewLine.visible=!1,this.draftGroup.add(this.previewLine),this.draftOutlineLine=this.createLine({color:e,transparent:!1,opacity:1}),this.draftOutlineLine.visible=!1,this.draftGroup.add(this.draftOutlineLine),this.closingLine=this.createLine({color:e,transparent:!1,opacity:1}),this.closingLine.visible=!1,this.draftGroup.add(this.closingLine),this.getScene().add(this.draftGroup)}disposeDraftObjects(){this.draftVertexMeshes.forEach(e=>{this.zoneSelectableBridge.unregisterSelectableZoneVertex(e),this.disposeObject(e)}),this.previewLine&&this.disposeObject(this.previewLine),this.draftOutlineLine&&this.disposeObject(this.draftOutlineLine),this.closingLine&&this.disposeObject(this.closingLine),this.cursorPreviewMesh&&this.disposeObject(this.cursorPreviewMesh),this.draftGroup?.parent&&this.draftGroup.parent.remove(this.draftGroup),this.draftVertexMeshes=[],this.draftOutlineLine=null,this.previewLine=null,this.closingLine=null,this.cursorPreviewMesh=null,this.draftGroup=null}createPointMesh({color:e,transparent:t,opacity:n,radius:i}){const s=new Pa(i),a=new jt({color:e,transparent:t,opacity:n,depthWrite:!t});return new Ee(s,a)}createLine({color:e,transparent:t,opacity:n}){const i=new ht,s=new zn({color:e,transparent:t,opacity:n});return new qn(i,s)}createLineLoop({color:e,transparent:t,opacity:n}){const i=new ht,s=new zn({color:e,transparent:t,opacity:n});return new Ab(i,s)}disposeObject(e){if(e.removeFromParent(),e instanceof Ee){e.geometry.dispose(),Array.isArray(e.material)?e.material.forEach(t=>t.dispose()):e.material.dispose();return}e instanceof qn&&(e.geometry.dispose(),Array.isArray(e.material)?e.material.forEach(t=>t.dispose()):e.material.dispose())}updateLinePositions(e,t,n){e&&this.replaceLineGeometry(e,[t,n])}replaceLineGeometry(e,t){e&&(e.geometry.dispose(),e.geometry=new ht().setFromPoints(t))}hideDraftPreview(){this.cursorPreviewMesh&&(this.cursorPreviewMesh.visible=!1),this.previewLine&&(this.previewLine.visible=!1)}updateDraftOutlineGeometry(){if(this.draftOutlineLine){if(this.draftPoints.length>=2){this.replaceLineGeometry(this.draftOutlineLine,this.draftPoints),this.draftOutlineLine.visible=!0;return}this.replaceLineGeometry(this.draftOutlineLine,[]),this.draftOutlineLine.visible=!1}}updateDraftClosingGeometry(){if(!this.closingLine)return;if(this.draftState!=="closed"||this.draftPoints.length<3){this.closingLine.visible=!1,this.replaceLineGeometry(this.closingLine,[]);return}const e=this.draftPoints[0],t=this.draftPoints[this.draftPoints.length-1];this.updateLinePositions(this.closingLine,t,e),this.closingLine.visible=!0}syncDraftVertexSelectableRegistration(){this.draftVertexMeshes.forEach(e=>{this.zoneSelectableBridge.unregisterSelectableZoneVertex(e)}),this.draftState==="closed"&&this.draftVertexMeshes.forEach(e=>{this.zoneSelectableBridge.registerSelectableZoneVertex(e)})}updateDraftVertexMeshes(){const e=this.getZoneColor(this.draftMeta.type),t=new Ne(e),n=t.clone().lerp(sh,uC),i=t.clone().lerp(sh,fC);for(let s=0;s<this.draftVertexMeshes.length;s++){const a=this.draftVertexMeshes[s],o=this.draftPoints[s];if(!o)continue;a.position.copy(o);const l=this.draftSelectedVertexIndex===s?jm:this.draftHoveredVertexIndex===s?Wm:Vm;if(a.scale.setScalar(l),a.material instanceof jt){const c=this.draftSelectedVertexIndex===s,d=this.draftHoveredVertexIndex===s;a.material.color.copy(c?i:d?n:t),a.material.opacity=this.draftState==="closed"?d||c?1:nh:ih}}this.syncDraftVertexSelectableRegistration()}rebuildDraftVertexMeshes(){const e=this.getZoneColor(this.draftMeta.type);this.draftVertexMeshes.forEach(t=>{this.zoneSelectableBridge.unregisterSelectableZoneVertex(t),this.disposeObject(t)}),this.draftVertexMeshes=[];for(let t=0;t<this.draftPoints.length;t++){const n=this.draftPoints[t],i=this.createPointMesh({color:e,transparent:!0,opacity:this.draftState==="closed"?nh:ih,radius:hC});i.name=`topology-zone-draft-vertex-${t}`,i.position.copy(n),i.userData={...i.userData,objectType:"topology-zone-draft-vertex",vertexIndex:t,keep:!0},i.scale.setScalar(this.draftSelectedVertexIndex===t?jm:this.draftHoveredVertexIndex===t?Wm:Vm),this.draftVertexMeshes.push(i),this.draftGroup?.add(i)}this.updateDraftVertexMeshes()}syncDraftGeometry(){if(this.ensureDraftObjects(),this.updateDraftOutlineGeometry(),this.updateDraftClosingGeometry(),this.draftVertexMeshes.length!==this.draftPoints.length){this.rebuildDraftVertexMeshes();return}this.updateDraftVertexMeshes()}emitDraftUpdated(){this.eventBus.emit("zone:draft-updated",{state:this.draftState,editingZoneId:this.draftEditingZoneId,selectedVertexIndex:this.draftSelectedVertexIndex,name:this.draftMeta.name,type:this.draftMeta.type,pointCount:this.draftPoints.length,points:this.draftPoints.map(e=>({x:e.x,y:e.y,z:e.z}))})}getZoneColor(e){return rm[e]??rm.NO_ENTRY}updateDraftColors(){const e=this.getZoneColor(this.draftMeta.type);this.cursorPreviewMesh?.material instanceof jt&&this.cursorPreviewMesh.material.color.setHex(e),this.draftVertexMeshes.forEach(t=>{t.material instanceof jt&&(t.material.color.setHex(e),t.material.opacity=this.draftState==="closed"?nh:ih)}),[this.previewLine,this.closingLine,this.draftOutlineLine].forEach(t=>{t?.material instanceof zn&&t.material.color.setHex(e)})}renderCommittedZones(e){e.forEach(t=>{this.renderCommittedZone(t)})}focusCommittedZones(e){this.selectedZoneIds=new Set(e),(!this.focusedZoneId||!this.selectedZoneIds.has(this.focusedZoneId))&&(this.focusedZoneId=e[0]??null),this.refreshCommittedZoneHighlights()}focusActiveCommittedZone(e){this.focusedZoneId=e,this.refreshCommittedZoneHighlights()}clearCommittedZones(){this.committedZoneObjects.forEach(e=>{this.disposeCommittedZone(e)}),this.committedZoneObjects.clear(),this.hiddenCommittedZoneIds.clear(),this.focusedZoneId=null}removeCommittedZone(e){const t=this.committedZoneObjects.get(e);t&&(this.selectedZoneIds.delete(e),this.focusedZoneId===e&&(this.focusedZoneId=null),this.hiddenCommittedZoneIds.delete(e),this.disposeCommittedZone(t),this.committedZoneObjects.delete(e))}refreshCommittedZoneHighlights(){this.committedZoneObjects.forEach((e,t)=>{this.applyCommittedZoneHighlight(e,this.selectedZoneIds.has(t),this.focusedZoneId===t)})}setCommittedZonesVisibility(e){this.committedZoneObjects.forEach(t=>{t.group.visible=e&&!this.hiddenCommittedZoneIds.has(String(t.group.userData.zoneId))})}setCommittedZoneHidden(e,t){t?this.hiddenCommittedZoneIds.add(e):this.hiddenCommittedZoneIds.delete(e);const n=this.committedZoneObjects.get(e);n&&(n.group.visible=!t)}getPolygonBoundsCenter(e){if(!e.length)return new me;let t=e[0].x,n=e[0].x,i=e[0].y,s=e[0].y;for(let a=1;a<e.length;a++){const o=e[a];t=Math.min(t,o.x),n=Math.max(n,o.x),i=Math.min(i,o.y),s=Math.max(s,o.y)}return new me((t+n)/2,(i+s)/2)}createCommittedZoneHitMesh(e,t){const n=new Ib(e.polygon.map(o=>new me(o.x-t.x,o.y-t.y))),i=new Yu(n),s=new jt({color:this.getZoneColor(e.type),transparent:!0,opacity:Gm,side:ln,depthWrite:!1}),a=new Ee(i,s);return a.name=`topology-zone-hit-${e.id}`,a.position.z=-.001,a.userData={...a.userData,zoneId:e.id,topologyObjectType:"zone",objectType:"topology-zone-hit-area"},a}createCommittedZoneBoundingBoxLine(e,t){const n=e.polygon.map(a=>new me(a.x-t.x,a.y-t.y)),i=new Ws().setFromPoints(n),s=this.createLineLoop({color:Yb,transparent:!1,opacity:1});return s.name=`topology-zone-bounds-${e.id}`,s.renderOrder=gC,s.position.z=.01,s.visible=!1,s.geometry.setFromPoints([new I(i.min.x,i.min.y,0),new I(i.max.x,i.min.y,0),new I(i.max.x,i.max.y,0),new I(i.min.x,i.max.y,0)]),s}getHighlightedZoneColor(e){return new Ne(this.getZoneColor(e)).lerp(sh,.35)}applyCommittedZoneHighlight(e,t,n){const i=e.group.userData.zoneType,s=this.getZoneColor(i??"NO_ENTRY"),a=t?this.getHighlightedZoneColor(i??"NO_ENTRY"):new Ne(s);e.lineLoop.material instanceof zn&&(e.lineLoop.material.color.copy(a),e.lineLoop.material.transparent=!0,e.lineLoop.material.opacity=n?dC:t?lC:cC),e.hitMesh.material instanceof jt&&(e.hitMesh.material.color.setHex(s),e.hitMesh.material.opacity=n?oC:t?0:Gm),e.boundingBoxLine.visible=n}disposeCommittedZone(e){this.zoneSelectableBridge.unregisterSelectableZone(e.hitMesh),this.disposeObject(e.hitMesh),this.disposeObject(e.lineLoop),this.disposeObject(e.boundingBoxLine),e.group.parent&&e.group.parent.remove(e.group),e.group.clear()}renderCommittedZone(e){if(e.polygon.length<3)return;const t=this.committedZoneObjects.get(e.id);t&&(this.disposeCommittedZone(t),this.committedZoneObjects.delete(e.id));const n=new Vt,i=this.getPolygonBoundsCenter(e.polygon);n.position.set(i.x,i.y,0),n.name=`topology-zone-${e.id}`,n.userData={...n.userData,zoneId:e.id,zoneType:e.type,topologyObjectType:"zone",keep:!0};const s=this.createLineLoop({color:this.getZoneColor(e.type),transparent:!1,opacity:1});s.renderOrder=mC,s.name=`topology-zone-outline-${e.id}`,s.userData={...s.userData,zoneId:e.id,topologyObjectType:"zone"},s.geometry.setFromPoints(e.polygon.map(c=>new I(c.x-i.x,c.y-i.y,0)));const a=this.createCommittedZoneHitMesh(e,i),o=this.createCommittedZoneBoundingBoxLine(e,i);a.renderOrder=pC,a.userData={...a.userData,zoneOwner:n},n.add(a),n.add(s),n.add(o),this.getScene().add(n),this.zoneSelectableBridge.registerSelectableZone(a);const l={group:n,lineLoop:s,boundingBoxLine:o,hitMesh:a};this.hiddenCommittedZoneIds.has(e.id)&&(n.visible=!1),this.applyCommittedZoneHighlight(l,this.selectedZoneIds.has(e.id),this.focusedZoneId===e.id),this.committedZoneObjects.set(e.id,l)}handleMappingStarted=()=>{this.setCommittedZonesVisibility(!1)};handleMappingStopped=()=>{this.setCommittedZonesVisibility(!0)};handleDraftStart=({name:e,type:t})=>{this.restoreEditingZoneVisibility(),this.clearDraftVertexSelection(),this.disposeDraftObjects(),this.draftEditingZoneId=null,this.draftPoints=[],this.ensureDraftObjects(),this.draftMeta={name:e,type:t},this.draftState="drawing",this.syncDraftGeometry(),this.updateDraftColors(),this.emitDraftUpdated()};handleDraftCancel=()=>{this.restoreEditingZoneVisibility(),this.resetDraftSession()};handleDraftClear=()=>{this.resetDraft()};handleDraftUndo=()=>{this.draftState==="idle"||this.draftState==="closed"||this.draftPoints.length===0||(this.draftPoints=this.draftPoints.slice(0,-1),this.syncDraftGeometry(),this.hideDraftPreview(),this.emitDraftUpdated())};handleDraftClose=()=>{this.draftPoints.length<3||this.draftState==="closed"||(this.draftState="closed",this.clearDraftVertexSelection(),this.syncDraftGeometry(),this.cursorPreviewMesh&&(this.cursorPreviewMesh.visible=!1),this.previewLine&&(this.previewLine.visible=!1),this.emitDraftUpdated())};handleDraftReopen=()=>{this.draftState==="closed"&&(this.draftState="drawing",this.clearDraftVertexSelection(),this.hideDraftPreview(),this.syncDraftGeometry(),this.emitDraftUpdated())};handleDraftCommit=()=>{if(this.draftState!=="closed"||this.draftPoints.length<3)return;const e=this.draftEditingZoneId,t={id:e??bt.generateUUID(),name:this.draftMeta.name,type:this.draftMeta.type,polygon:this.draftPoints.map(i=>({x:i.x,y:i.y}))},n=e!==null;if(n){if(!this.nodeManager.updateTopologyZone(t))return;this.setCommittedZoneHidden(t.id,!1)}else this.nodeManager.addTopologyZone(t);this.renderCommittedZone(t),this.nodeManager.emitTopologyChanged(n?"zone-updated":"zone-created"),this.resetDraftSession()};handleEditStart=({zoneId:e})=>{const t=this.nodeManager.getTopologyZone(e);t&&(this.restoreEditingZoneVisibility(),this.clearDraftVertexSelection(),this.disposeDraftObjects(),this.draftEditingZoneId=t.id,this.draftMeta={name:t.name,type:t.type},this.focusActiveCommittedZone(t.id),this.draftPoints=t.polygon.map(n=>new I(n.x,n.y,0)),this.draftState="closed",this.setCommittedZoneHidden(t.id,!0),this.syncDraftGeometry(),this.updateDraftColors(),this.emitDraftUpdated())};handleZoneFocusRequested=({zoneId:e})=>{this.focusActiveCommittedZone(e)};handleDraftMetaUpdated=({name:e,type:t})=>{typeof e=="string"&&(this.draftMeta.name=e),typeof t=="string"&&(this.draftMeta.type=t,this.updateDraftColors()),this.emitDraftUpdated()};handlePreviewUpdated=({point:e})=>{if(this.draftState!=="drawing")return;this.ensureDraftObjects(),this.cursorPreviewMesh&&(this.cursorPreviewMesh.position.copy(e),this.cursorPreviewMesh.position.z=0,this.cursorPreviewMesh.visible=!0);const t=this.draftPoints[this.draftPoints.length-1];if(!t||!this.previewLine){this.previewLine&&(this.previewLine.visible=!1);return}this.updateLinePositions(this.previewLine,t,e),this.previewLine.visible=!0};handleViewportPointerLeave=()=>{this.draftHoveredVertexIndex!==null&&(this.draftHoveredVertexIndex=null,this.draftVertexMeshes.length>0&&this.updateDraftVertexMeshes()),this.hideDraftPreview()};handlePointPlaced=({point:e})=>{if(this.draftState!=="drawing")return;this.ensureDraftObjects();const t=e.clone();t.z=0,this.draftPoints=[...this.draftPoints,t],this.syncDraftGeometry(),this.emitDraftUpdated()};handleDraftVertexSelected=({vertexIndex:e})=>{this.draftSelectedVertexIndex=e,this.draftVertexMeshes.length>0&&(this.updateDraftVertexMeshes(),this.updateDraftColors()),this.emitDraftUpdated()};handleDraftVertexMoved=({vertexIndex:e,point:t})=>{if(this.draftState!=="closed"||e<0||e>=this.draftPoints.length)return;const n=t.clone();n.z=0,this.draftPoints=this.draftPoints.map((i,s)=>s===e?n:i),this.syncDraftGeometry(),this.updateDraftColors(),this.emitDraftUpdated()};handleDraftVertexHovered=({vertexIndex:e})=>{const t=this.draftState==="closed"?e:null;this.draftHoveredVertexIndex!==t&&(this.draftHoveredVertexIndex=t,this.draftVertexMeshes.length>0&&this.updateDraftVertexMeshes())}}const vv=.012,vC=.012,yC=.35,yv=new Oc(vv,24);yv.translate(0,0,vC);class xC{constructor(e){this.editor=e,this.linkModule=new rC(this,this.editor.eventHandler.eventBus,()=>this.editor.selectionManager.getSelectedObjects()),this.zoneModule=new bC(this,this.editor.eventHandler.eventBus,()=>this.editor.scene,{registerSelectableZone:t=>this.editor.selectionManager.registerSelectableZone(t),unregisterSelectableZone:t=>this.editor.selectionManager.unregisterSelectableZone(t),registerSelectableZoneVertex:t=>this.editor.selectionManager.registerSelectableZoneVertex(t),unregisterSelectableZoneVertex:t=>this.editor.selectionManager.unregisterSelectableZoneVertex(t)})}goalMesh;routeMesh;alignMesh;markerMesh;arrowMap=new Map;materialMap={GOAL:null,ROUTE:null,ALIGN:null,MARKER:null};NODE_TYPE_MAP={[gs.GOAL]:"GOAL",[gs.ROUTE]:"ROUTE",[gs.ALIGN]:"ALIGN"};nodeRadiusMap={GOAL:0,ROUTE:0,ALIGN:0,MARKER:0};topologyLinks=[];topologyZones=[];isArrowLayerVisible=!0;linkVisibilityFilter={dir:"all",method:"all"};linkModule;zoneModule;MAX_ID=9999;nodeRenderMode="default";simpleMaterialMap={GOAL:new Fn({color:12186288,side:ln}),ROUTE:new Fn({color:1573017,side:ln}),ALIGN:new Fn({color:16727988,side:ln}),MARKER:new Fn({color:16727988,side:ln})};usedIds=new Set;lastIssued=-1;normalizeLinkDirection(e){return String(e??"").toUpperCase()==="REVERSE"?"REVERSE":"FORWARD"}normalizeLinkMethod(e){const t=String(e??"").toUpperCase();return t==="HPP"||t==="TNG"||t==="SIDE"?t:"PP"}clampNumber(e,t,n,i){return typeof e!="number"||Number.isNaN(e)?i:Math.min(n,Math.max(t,e))}registerEventListeners(){const e=this.editor.eventHandler.eventBus;e.on("editor:initialized",this.handleEditorInitialized),e.on("ui:mapping-start-requested",this.handleMappingStarted),e.on("ui:mapping-stop-requested",this.handleMappingStopped),e.on("ui:topo-update-requested",this.handleUpdateTopology),e.on("ui:add-node-by-preview-requested",this.handleAddNodeByPreview),e.on("ui:quick-add-node-requested",this.handleQuickAnnotation),e.on("ui:node-updated",this.handleNodeUpdated),e.on("ui:node-type-change-requested",this.handleNodeTypeChange),e.on("ui:node-render-mode-set-requested",this.handleNodeRenderModeRequested),e.on("ui:nodes-transform-delta-requested",this.handleNodesTransformDeltaRequested),e.on("ui:nodes-transform-absolute-requested",this.handleNodesTransformAbsoluteRequested),e.on("ui:nodes-delete-requested",this.handleDeleteNodes),e.on("ui:link-updated",this.handleLinkUpdated),e.on("ui:link-delete-requested",this.handleLinkDeleted),e.on("ui:link-focus-requested",this.handleLinkFocused),e.on("selector:link-selected",this.handleLinkSelected),e.on("selector:zone-selected",this.handleZoneSelected),e.on("node-manager:selection-transform-changed",this.handleSelectionTransformChanged),e.on("viewport:zone-translation-committed",this.handleZoneTranslationCommitted),e.on("ui:link-visibility-filter-requested",this.handleLinkVisibilityFilterRequested),this.linkModule.registerEventListeners(),this.zoneModule.registerEventListeners()}deRegisterEventListeners(){const e=this.editor.eventHandler.eventBus;e.off("editor:initialized",this.handleEditorInitialized),e.off("ui:mapping-start-requested",this.handleMappingStarted),e.off("ui:mapping-stop-requested",this.handleMappingStopped),e.off("ui:topo-update-requested",this.handleUpdateTopology),e.off("ui:add-node-by-preview-requested",this.handleAddNodeByPreview),e.off("ui:quick-add-node-requested",this.handleQuickAnnotation),e.off("ui:node-updated",this.handleNodeUpdated),e.off("ui:node-type-change-requested",this.handleNodeTypeChange),e.off("ui:node-render-mode-set-requested",this.handleNodeRenderModeRequested),e.off("ui:nodes-transform-delta-requested",this.handleNodesTransformDeltaRequested),e.off("ui:nodes-transform-absolute-requested",this.handleNodesTransformAbsoluteRequested),e.off("ui:nodes-delete-requested",this.handleDeleteNodes),e.off("ui:link-updated",this.handleLinkUpdated),e.off("ui:link-delete-requested",this.handleLinkDeleted),e.off("ui:link-focus-requested",this.handleLinkFocused),e.off("selector:link-selected",this.handleLinkSelected),e.off("selector:zone-selected",this.handleZoneSelected),e.off("node-manager:selection-transform-changed",this.handleSelectionTransformChanged),e.off("viewport:zone-translation-committed",this.handleZoneTranslationCommitted),e.off("ui:link-visibility-filter-requested",this.handleLinkVisibilityFilterRequested),this.linkModule.deregisterEventListeners(),this.zoneModule.deregisterEventListeners()}clearTopo(){this.clearArrows(),this.zoneModule.resetDraft(),this.zoneModule.clearCommittedZones();const e=[];this.editor.scene.traverse(t=>{t instanceof Hs&&t.userData.labelType==="node"?(t.element&&t.element.parentNode&&t.element.parentNode.removeChild(t.element),e.push(t)):t.userData.keep||e.push(t)});for(let t=0,n=e.length;t<n;t++){const i=e[t];this.editor.removeObject(i)}this.editor.selectionManager.reset(),this.topologyLinks=[],this.topologyZones=[],this.editor.eventHandler.eventBus.emit("node-manager:topo-updated")}async drawTopo(e){const t=e?.nodes??[];if(this.topologyLinks=(e?.links??[]).map(i=>({...i,dir:this.normalizeLinkDirection(i.dir),method:this.normalizeLinkMethod(i.method),slowMarginX:this.clampNumber(i.slowMarginX,-1,1,0),slowMarginY:this.clampNumber(i.slowMarginY,-1,1,0),stopMarginX:this.clampNumber(i.stopMarginX,-1,1,0),stopMarginY:this.clampNumber(i.stopMarginY,-1,1,0)})),this.topologyZones=[...e?.zones??[]],this.zoneModule.clearCommittedZones(),!t.length){this.zoneModule.renderCommittedZones(this.topologyZones),this.editor.eventHandler.eventBus.emit("node-manager:topo-updated");return}const n=t.map((i,s)=>{const a=h=>h===void 0||Number.isNaN(h)?0:h,o=i.pose,l={x:a(o.x),y:a(o.y),z:a(o.z),rx:Yd(a(o.rx)),ry:Yd(a(o.ry)),rz:Yd(a(o.rz)),idx:s},c={name:i.name,id:i.id,context:i.context,features:Array.isArray(i.features)?i.features.filter(h=>typeof h=="string"):[],safetyField:typeof i.safetyField=="number"?i.safetyField:0},d=this.NODE_TYPE_MAP[i.type];if(!d){console.warn(`[DRAW TOPO] This type of node is not supported: ${i.type}`);return}return this.addNode(d,l,c)});await Promise.all(n);for(let i=0,s=this.topologyLinks.length;i<s;i++)this.renderTopologyLink(this.topologyLinks[i]);this.applyArrowVisibilityFilter(),this.zoneModule.renderCommittedZones(this.topologyZones),this.editor.eventHandler.eventBus.emit("node-manager:topo-updated")}findObjectByUserDataId(e,t){if(e.userData?.id===t)return e;for(const n of e.children){const i=this.findObjectByUserDataId(n,t);if(i)return i}return null}dispose(){this.clearArrows(),this.deRegisterEventListeners()}addLabel(e){const t=document.createElement("div");t.className="nodeLabel italic text-base p-1 font-semibold rounded-sm",t.textContent=e.name,t.style.cssText=`
|
|
4390
4390
|
background: #1e2337;
|
|
4391
4391
|
color: #c0caf5;
|
|
4392
|
-
`;const n=new Hs(t);n.visible=!0,n.userData.keep=!0,n.userData.labelType="node",n.name="label",n.center.set(0,-.5),e.add(n);const i={obj:n,bucket:null,worldPosition:null};this.editor.eventHandler.eventBus.emit("node-manager:label-added",i)}formatId(e){return e.toString().padStart(4,"0")}parseIssuedNumber(e){if(!e)return null;const t=/^[GRA]_(\d{4})$/.exec(e);return t?Number(t[1]):null}allocateId(){for(let e=0;e<=this.MAX_ID;e++){const t=(this.lastIssued+1+e)%(this.MAX_ID+1),n=this.formatId(t);if(!this.usedIds.has(n))return this.usedIds.add(n),this.lastIssued=t,n}throw new Error("사용 가능한 Node ID(0000~9999)가 없습니다.")}addNode(e,t,n=null){let i=this.goalMesh;if(!i)return;if(e===gs.ROUTE)i=this.routeMesh;else if(e===gs.ALIGN){const f=n?.features??[];i=(f.includes("APRIL")||f.includes("ARUCO"))&&this.markerMesh?this.markerMesh:this.alignMesh}const s=i.clone(),{x:a,y:o,z:l,rx:c,ry:d,rz:h}=t;s.position.set(a,o,l),s.rotation.set(c,d,h);const u=e===gs.GOAL?"G":e===gs.ROUTE?"R":"A";if(s.userData.type=e,s.userData.features=[],s.userData.safetyField=0,n){s.name=n.name,s.userData.id=n.id,s.userData.context=n.context??"",Array.isArray(n.features)&&(s.userData.features=n.features.filter(m=>typeof m=="string")),typeof n.safetyField=="number"&&(s.userData.safetyField=n.safetyField);const f=this.parseIssuedNumber(n.name);f!==null&&(this.usedIds.add(this.formatId(f)),f>this.lastIssued&&(this.lastIssued=f))}else{const f=this.allocateId();s.name=`${u}_${f}`,s.userData.id=s.uuid}return this.addLabel(s),this.cacheDefaultNodeAppearance(s),this.applyNodeRenderMode(s),this.editor.scene.add(s),this.editor.selectionManager.registerSelectable(s),this.editor.eventHandler.eventBus.emit("topology:nodes-updated",this.editor.selectionManager.getSelectableObjects()),s}alignNodesByAxis(e,t){const n=this.editor.selectionManager.getSelectedObjects();if(!n.length)return;const i=t==="min",s=i?Math.min:Math.max,a=i?1/0:-1/0,o=n.reduce((l,c)=>s(l,c.position[e]),a);for(let l=0,c=n.length;l<c;l++){const d=n[l];d.position[e]=o}this.updateArrows(),this.emitSelectionTransformChanged(n[n.length-1]),this.emitTopologyChanged("node-updated")}alignNodesWithSpacing(e,t){const n=this.editor.selectionManager.getSelectedObjects();if(!n.length)return;const i=n.map(o=>o.position[e]),s=e==="x"?Math.min(...i):Math.max(...i),a=e==="x"?1:-1;for(let o=0,l=n.length;o<l;o++){const c=n[o];c.position[e]=s+a*t*o}this.updateArrows(),this.emitSelectionTransformChanged(n[n.length-1]),this.emitTopologyChanged("node-updated")}alignNodesTheta(){const e=this.editor.selectionManager.getSelectedObjects();if(!e.length)return;let t=0,n=0;for(let s=0,a=e.length;s<a;s++){const l=e[s].rotation.z;t+=Math.sin(l),n+=Math.cos(l)}const i=Math.atan2(t,n);for(let s=0,a=e.length;s<a;s++){const o=e[s];o.rotation.z=i}}changeNodeName(e,t){e.name=t,this.editor.eventHandler.eventBus.emit("node-manager:node-name-changed",{name:t})}getCircumradius(e){if(this.nodeRenderMode==="simple")return vv;const t=this.getNodeRadiusKey(e);return this.nodeRadiusMap[t]*yC}getNodeRadiusKey(e){const t=Array.isArray(e.userData.features)?e.userData.features:[];if(e.userData.type===gs.ALIGN&&(t.includes("APRIL")||t.includes("ARUCO")))return"MARKER";switch(e.userData.type){case"GOAL":return"GOAL";case"ROUTE":return"ROUTE";case"ALIGN":return"ALIGN"}return"GOAL"}measureNodeModelRadius(e){return new Yt().setFromObject(e).getBoundingSphere(new vn).radius}async cacheNodeAssets(e){const t=new X1,n=Hn("/nodes/goal2.fbx");try{const c=(await t.loadAsync(n)).children[0],d=c.material,h=new Fn;h.copy(d),h.color.set(12186288),c.material=h,this.goalMesh=c,this.materialMap.GOAL=h,this.nodeRadiusMap.GOAL=this.measureNodeModelRadius(c),console.log("[NodeManager] goal mesh loaded from",n)}catch(l){console.error(l)}const i=Hn("/nodes/route.fbx");try{const c=(await t.loadAsync(i)).children[0],d=c.material,h=new Fn;h.copy(d),c.material=h,this.routeMesh=c,this.materialMap.ROUTE=h,this.nodeRadiusMap.ROUTE=this.measureNodeModelRadius(c),console.log("[NodeManager] route mesh loaded from",i)}catch(l){console.error(l)}const s=this.goalMesh.clone(),a=this.goalMesh.material.clone();a.color.set(16727988),s.material=a,this.alignMesh=s,this.materialMap.ALIGN=a,this.nodeRadiusMap.ALIGN=this.measureNodeModelRadius(s);const o=Hn("/nodes/marker.fbx");try{const c=(await t.loadAsync(o)).children[0],d=c.material,h=new Fn;h.copy(d),c.material=h,this.markerMesh=c,this.materialMap.MARKER=h,this.nodeRadiusMap.MARKER=this.measureNodeModelRadius(c)}catch(l){console.error(l),this.markerMesh=s.clone(),this.materialMap.MARKER=a,this.nodeRadiusMap.MARKER=this.measureNodeModelRadius(this.markerMesh)}this.editor.eventHandler.eventBus.emit("node-manager:ready")}getTopologyLinks(){return[...this.topologyLinks]}getTopologyZones(){return[...this.topologyZones]}getTopologyZone(e){return this.topologyZones.find(t=>t.id===e)??null}focusTopologyLinks(e){const t=e.length?this.editor.selectionManager.getSelectableLinks().filter(n=>e.includes(String(n.userData.linkId))):[];this.editor.selectionManager.setSelectedLinks(t),this.editor.eventHandler.eventBus.emit("selector:link-focused",{linkId:this.editor.selectionManager.getFocusedLinkId()}),this.updateArrowVisualStates(e)}focusActiveTopologyLink(e){this.editor.selectionManager.setFocusedLinkId(e),this.editor.eventHandler.eventBus.emit("selector:link-focused",{linkId:this.editor.selectionManager.getFocusedLinkId()}),this.updateArrowVisualStates(this.getSelectedLinkIds())}matchesLinkVisibilityFilter(e){const t=this.linkVisibilityFilter.dir==="all"||this.linkVisibilityFilter.dir==="forward"&&e.dir==="FORWARD"||this.linkVisibilityFilter.dir==="reverse"&&e.dir==="REVERSE",n=this.linkVisibilityFilter.method==="all"||e.method===this.linkVisibilityFilter.method;return t&&n}applyArrowVisibilityFilter(){for(let e=0;e<this.topologyLinks.length;e++){const t=this.topologyLinks[e],n=this.getArrowKey(t.from,t.to),i=this.arrowMap.get(n);i&&(i.visible=this.getArrowVisibility(t))}}getArrowVisibility(e){return this.isArrowLayerVisible&&this.matchesLinkVisibilityFilter(e)}cacheDefaultNodeAppearance(e){const t=e;t.userData.defaultAppearance||(t.userData.defaultAppearance={geometry:e.geometry,material:e.material,childMeshVisibility:e.children.filter(n=>!(n instanceof Hs)).map(n=>({object:n,visible:n.visible}))})}getSimpleMaterial(e){const t=Array.isArray(e.userData.features)?e.userData.features:[];return e.userData.type===gs.ALIGN&&(t.includes("APRIL")||t.includes("ARUCO"))?this.simpleMaterialMap.MARKER:this.simpleMaterialMap[e.userData.type]}applyDefaultNodeAppearance(e){const n=e.userData.defaultAppearance;if(n){e.geometry=n.geometry,e.material=n.material;for(let i=0;i<n.childMeshVisibility.length;i++){const s=n.childMeshVisibility[i];s.object.visible=s.visible}}}applySimpleNodeAppearance(e){e.geometry=yv,e.material=this.getSimpleMaterial(e);const n=e.userData.defaultAppearance;if(n)for(let i=0;i<n.childMeshVisibility.length;i++)n.childMeshVisibility[i].object.visible=!1}applyNodeRenderMode(e){if(this.cacheDefaultNodeAppearance(e),this.nodeRenderMode==="simple"){this.applySimpleNodeAppearance(e);return}this.applyDefaultNodeAppearance(e)}applyNodeRenderModeToAllNodes(){const e=this.editor.selectionManager.getSelectableObjects();for(let t=0;t<e.length;t++)this.applyNodeRenderMode(e[t]);this.refreshAllArrows()}refreshAllArrows(){for(let e=0;e<this.topologyLinks.length;e++){const t=this.topologyLinks[e],n=this.getArrowNodes(t);if(!n){this.removeArrow(t);continue}const i=this.buildArrowSpec(t,n.from,n.to);if(!i){this.removeArrow(t);continue}this.upsertArrow(t,i,n.from,n.to)}this.applyArrowVisibilityFilter()}focusTopologyZones(e){const t=e.length?this.editor.selectionManager.getSelectableZones().filter(n=>e.includes(String(n.userData.zoneId))):[];this.editor.selectionManager.setSelectedZones(t),this.editor.eventHandler.eventBus.emit("selector:zone-focused",{zoneId:this.editor.selectionManager.getFocusedZoneId()}),this.zoneModule.focusCommittedZones(e)}focusActiveTopologyZone(e){this.editor.selectionManager.setFocusedZoneId(e),this.editor.eventHandler.eventBus.emit("selector:zone-focused",{zoneId:this.editor.selectionManager.getFocusedZoneId()}),this.zoneModule.focusActiveCommittedZone(e)}addTopologyZone(e){this.topologyZones=[...this.topologyZones,e],this.editor.eventHandler.eventBus.emit("node-manager:topo-updated")}updateTopologyZone(e){return this.topologyZones.findIndex(n=>n.id===e.id)<0?!1:(this.topologyZones=this.topologyZones.map(n=>n.id===e.id?e:n),this.editor.eventHandler.eventBus.emit("node-manager:topo-updated"),!0)}moveTopologyZone(e,t){const n=this.getTopologyZone(e);if(!n)return!1;const i={...n,polygon:n.polygon.map(s=>({x:s.x+t.x,y:s.y+t.y}))};return this.updateTopologyZone(i)?(this.emitTopologyChanged("zone-updated"),!0):!1}deleteTopologyZone(e){this.topologyZones.some(n=>n.id===e)&&(this.topologyZones=this.topologyZones.filter(n=>n.id!==e),this.zoneModule.removeCommittedZone(e),this.editor.eventHandler.eventBus.emit("node-manager:topo-updated"),this.emitTopologyChanged("zone-deleted"))}emitTopologyChanged(e){this.editor.eventHandler.eventBus.emit("topology:changed",{source:e})}linkNodes(e,t,n={dir:"FORWARD",method:"PP",speed:0,avoidRange:0,safetyField:0,slowMarginX:0,slowMarginY:0,stopMarginX:0,stopMarginY:0}){if(!e||!t)return;const i=this.getTopologyNodeId(e),s=this.getTopologyNodeId(t);if(!i||!s)return;const a=this.findTopologyLink(i,s),o={id:a?.id??bt.generateUUID(),from:i,to:s,...n},l=!a;this.upsertTopologyLink(o),this.emitTopologyChanged(l?"link-created":"link-updated");const c=this.buildArrowSpec(o,e,t);c&&this.upsertArrow(o,c,e,t)}renderTopologyLink(e){const t=this.findObjectByUserDataId(this.editor.scene,e.from),n=this.findObjectByUserDataId(this.editor.scene,e.to);if(!t||!n){console.warn(`[DRAW TOPO] Invalid link: ${e.id}`,e);return}const i=this.buildArrowSpec(e,t,n);i&&this.upsertArrow(e,i,t,n)}upsertTopologyLink(e){const t=this.topologyLinks.findIndex(n=>n.from===e.from&&n.to===e.to);if(t<0){this.topologyLinks=[...this.topologyLinks,e],this.editor.eventHandler.eventBus.emit("node-manager:topo-updated");return}this.topologyLinks=this.topologyLinks.map((n,i)=>i===t?e:n),this.editor.eventHandler.eventBus.emit("node-manager:topo-updated")}removeTopologyLink(e,t){const n=this.getTopologyNodeId(e),i=this.getTopologyNodeId(t);if(!n||!i||!this.topologyLinks.some(l=>l.from===n&&l.to===i))return!1;const a=this.getArrowKey(n,i),o=this.arrowMap.get(a);return o&&(o.removeFromParent(),o.dispose(),this.arrowMap.delete(a)),this.topologyLinks=this.topologyLinks.filter(l=>!(l.from===n&&l.to===i)),this.editor.eventHandler.eventBus.emit("node-manager:topo-updated"),this.emitTopologyChanged("link-deleted"),!0}findTopologyLink(e,t){return this.topologyLinks.find(n=>n.from===e&&n.to===t)}getArrowKey(e,t){return`${e}->${t}`}getArrowNodes(e){const t=this.findObjectByUserDataId(this.editor.scene,e.from),n=this.findObjectByUserDataId(this.editor.scene,e.to);return!t||!n?null:{from:t,to:n}}getRelatedTopologyLinks(e){return this.topologyLinks.filter(t=>t.from===e||t.to===e)}getTopologyNodeId(e){return typeof e.userData.id=="string"?e.userData.id:""}toggleAllNodes=e=>{this.editor.selectionManager.getSelectableObjects().forEach(t=>{t.visible=e})};toggleAllArrows=e=>{this.isArrowLayerVisible=e,this.applyArrowVisibilityFilter()};unlinkNodes(e,t){this.removeTopologyLink(e,t),this.removeTopologyLink(t,e)}updateArrows=()=>{const e=this.editor.selectionManager.getSelectedObjects();for(let t=0,n=e.length;t<n;t++){const i=e[t],s=this.getTopologyNodeId(i);if(!s)continue;const a=this.getRelatedTopologyLinks(s);for(let o=0;o<a.length;o++){const l=a[o],c=this.getArrowNodes(l);if(!c){this.removeArrow(l);continue}const d=this.buildArrowSpec(l,c.from,c.to);if(!d){this.removeArrow(l);continue}this.upsertArrow(l,d,c.from,c.to)}}};updateNodeName(e){const t=this.editor.selectionManager.getSelected();t!==null&&(this.removeLabel(t),t.name=e,this.addLabel(t))}removeAllArrowsRelatedTo=e=>{const t=this.getTopologyNodeId(e);if(!t)return;const n=this.getRelatedTopologyLinks(t);for(let i=0;i<n.length;i++)this.removeArrow(n[i])};removeAllLinksRelatedTo(e){if(!e)return;const t=this.getTopologyNodeId(e);if(!t)return;const n=this.getRelatedTopologyLinks(t);for(let i=0;i<n.length;i++)this.removeArrow(n[i]);this.topologyLinks=this.topologyLinks.filter(i=>i.from!==t&&i.to!==t),this.editor.eventHandler.eventBus.emit("node-manager:topo-updated")}removeLabel(e){e.traverse(t=>{t.name==="label"&&e.remove(t)})}transformNodes(e,t){const n=this.editor.selectionManager.getSelectedObjects();if(!n.length)return;for(let s=0,a=n.length;s<a;s++){const o=n[s];switch(e){case"x":o.position.x+=t;break;case"y":o.position.y+=t;break;case"z":o.position.z+=t;break;case"rz":{const l=t*Math.PI/180;o.rotation.z+=l;break}}}const i=n[n.length-1];this.updateArrows(),this.emitSelectionTransformChanged(i),this.emitTopologyChanged("node-updated")}transformNodesByInput(e,t){const n=this.editor.selectionManager.getSelectedObjects();if(n.length===0)return;const i=Number(t);if(Number.isNaN(i))return;let s=0;e==="rz"&&(s=i*Math.PI/180);for(let o=0,l=n.length;o<l;o++){const c=n[o];switch(e){case"x":c.position.x=i;break;case"y":c.position.y=i;break;case"z":c.position.z=i;break;case"rz":c.rotation.z=s;break}}const a=n[n.length-1];this.updateArrows(),this.emitSelectionTransformChanged(a),this.emitTopologyChanged("node-updated")}clearArrows(){this.arrowMap.forEach(e=>{this.editor.selectionManager.unregisterSelectableLink(e),e.removeFromParent(),e.dispose()}),this.arrowMap.clear()}updateArrowVisualStates(e){const t=new Set(e),n=this.editor.selectionManager.getFocusedLinkId();for(let i=0;i<this.topologyLinks.length;i++){const s=this.topologyLinks[i],a=this.getArrowKey(s.from,s.to),o=this.arrowMap.get(a);if(o){if(n===s.id){o.setVisualState("focused");continue}if(t.has(s.id)){o.setVisualState("selected");continue}o.setVisualState("default")}}}getSelectedLinkIds(){return this.editor.selectionManager.getSelectedLinks().map(e=>String(e.userData.linkId))}removeArrow(e){const t=this.getArrowKey(e.from,e.to),n=this.arrowMap.get(t);n&&(this.editor.selectionManager.unregisterSelectableLink(n),n.removeFromParent(),n.dispose(),this.arrowMap.delete(t))}upsertArrow(e,t,n,i){const s=this.getArrowKey(e.from,e.to),a=this.arrowMap.get(s);if(a){a.applySpec(t),this.applyArrowVisualState(a,e.id),a.visible=this.getArrowVisibility(e);return}const o=new b1;o.applySpec(t),this.applyArrowVisualState(o,e.id),o.name=`${n.id}-${i.id}`,o.userData={...o.userData,from:n.id,to:i.id,linkId:e.id,linkKey:s},o.hitArea.userData={...o.hitArea.userData,from:n.id,to:i.id,linkId:e.id,linkKey:s},this.editor.scene.add(o),this.editor.selectionManager.registerSelectableLink(o),this.arrowMap.set(s,o),o.visible=this.getArrowVisibility(e)}applyArrowVisualState(e,t){if(this.editor.selectionManager.getFocusedLinkId()===t){e.setVisualState("focused");return}if(this.getSelectedLinkIds().includes(t)){e.setVisualState("selected");return}e.setVisualState("default")}buildArrowSpec(e,t,n){const i=t.position,s=n.position,a=i.distanceTo(s);if(a<=0)return null;const o=new I().subVectors(s,i).normalize(),l=this.getCircumradius(n),c=n.userData.type==="ROUTE"?.8:1.5,d=a-l;return{dir:o,origin:i.clone().addScaledVector(Pt.DEFAULT_UP,.1),length:Math.max(d,0),showHead:a-l>=c,showReverseBar:e.dir==="REVERSE"}}handleEditorInitialized=e=>{this.cacheNodeAssets(e.robotType)};handleMappingStarted=()=>{this.toggleAllNodes(!1),this.toggleAllArrows(!1)};handleMappingStopped=()=>{this.toggleAllNodes(!0),this.toggleAllArrows(!0)};handleUpdateTopology=e=>{this.usedIds.clear(),this.lastIssued=-1,this.editor.clear({clearMap:!1,clearTopo:!0}),this.drawTopo(e.topoData)};handleAddNodeByPreview=e=>{if(!this.editor.previewHelper.visible)return;const t=this.editor.previewHelper.position,n={x:t.x,y:t.y,z:t.z,rx:this.editor.previewHelper.rotation.x,ry:this.editor.previewHelper.rotation.y,rz:this.editor.previewHelper.rotation.z};this.addNode(e,n)&&this.emitTopologyChanged("node-added")};handleQuickAnnotation=e=>{const t=this.editor.robotManager.mainRobot,n={x:t.position.x,y:t.position.y,z:t.position.z,rx:t.rotation.x,ry:t.rotation.y,rz:t.rotation.z};this.addNode(e,n)&&this.emitTopologyChanged("node-added")};handleNodeUpdated=({nodeId:e,updates:t})=>{const n=this.editor.selectionManager.getSelectedObjects().find(i=>i.uuid===e);n&&(typeof t.name=="string"&&(n.name=t.name),Array.isArray(t.features)&&(n.userData.features=t.features.filter(i=>typeof i=="string"),this.nodeRenderMode==="simple"&&this.applySimpleNodeAppearance(n)),typeof t.safetyField=="number"&&(n.userData.safetyField=t.safetyField),typeof t.x=="number"&&(n.position.x=t.x),typeof t.y=="number"&&(n.position.y=t.y),typeof t.z=="number"&&(n.position.z=t.z),typeof t.rx=="number"&&(n.rotation.x=t.rx*Math.PI/180),typeof t.ry=="number"&&(n.rotation.y=t.ry*Math.PI/180),typeof t.rz=="number"&&(n.rotation.z=t.rz*Math.PI/180),this.emitSelectionTransformChanged(n),this.emitTopologyChanged("node-updated"))};handleNodeTypeChange=({nodeId:e,type:t})=>{const n=this.editor.selectionManager.getSelectedObjects().find(h=>h.uuid===e);if(!n||n.userData.type===t)return;const i=this.getTopologyNodeId(n);if(!i)return;const s=[...this.editor.selectionManager.getSelectedObjects()],a=this.getSelectedLinkIds(),o=this.editor.selectionManager.getFocusedLinkId(),l=this.getRelatedTopologyLinks(i),c=this.createReplacementNode(n,i,t);if(!c)return;this.replaceNodeMesh(n,c),this.refreshRelatedArrows(l),this.restoreLinkSelection(a,o);const d=s.map(h=>h===n?c:h);this.emitNodeTypeChanged(s,d)};createReplacementNode(e,t,n){const i=Array.isArray(e.userData.features)?e.userData.features.filter(s=>typeof s=="string"&&(n==="ALIGN"||s!=="APRIL"&&s!=="ARUCO")):[];return this.addNode(n,{x:e.position.x,y:e.position.y,z:e.position.z,rx:e.rotation.x,ry:e.rotation.y,rz:e.rotation.z},{name:e.name,id:t,context:typeof e.userData.context=="string"?e.userData.context:"",features:i,safetyField:typeof e.userData.safetyField=="number"?e.userData.safetyField:0})}replaceNodeMesh(e,t){this.editor.selectionManager.unregisterSelectable(t),this.editor.selectionManager.replaceSelectable(e,t),this.editor.selectionManager.replaceSelected(e,t);const n=e.children.find(i=>i instanceof Hs);e.removeFromParent(),e.traverse(i=>{i instanceof Hs&&i.element.parentNode&&i.element.parentNode.removeChild(i.element)}),e.clear(),n&&this.editor.eventHandler.eventBus.emit("node-manager:label-removed",n)}refreshRelatedArrows(e){for(const t of e)this.removeArrow(t),this.renderTopologyLink(t)}restoreLinkSelection(e,t){const n=e.map(i=>this.topologyLinks.find(s=>s.id===i)).filter(i=>!!i).map(i=>this.arrowMap.get(this.getArrowKey(i.from,i.to))).filter(i=>!!i);this.editor.selectionManager.setSelectedLinks(n),this.editor.selectionManager.setFocusedLinkId(t)}emitNodeTypeChanged(e,t){this.editor.eventHandler.eventBus.emit("selector:object-selected",{object:t[t.length-1]??null,prevSelected:e,selectedObjects:t,action:"select"}),this.editor.eventHandler.eventBus.emit("topology:nodes-updated",this.editor.selectionManager.getSelectableObjects()),this.editor.eventHandler.eventBus.emit("node-manager:topo-updated"),this.emitTopologyChanged("node-type-changed")}emitSelectionTransformChanged(e){const t=bt.radToDeg(e.rotation.z);this.editor.eventHandler.eventBus.emit("node-manager:selection-transform-changed",{x:e.position.x.toString().slice(0,6),y:e.position.y.toString().slice(0,6),z:e.position.z.toString().slice(0,6),rz:t.toString().slice(0,6)})}handleNodesTransformDeltaRequested=({target:e,value:t})=>{this.transformNodes(e,t)};handleNodesTransformAbsoluteRequested=({target:e,value:t})=>{this.transformNodesByInput(e,String(t))};handleDeleteNodes=()=>{const e=[...this.editor.selectionManager.getSelectedObjects()];e.length!==0&&(e.forEach(t=>{this.editor.removeObject(t)}),this.emitTopologyChanged("node-deleted"))};handleLinkUpdated=({linkId:e,updates:t})=>{const n=this.topologyLinks.find(a=>a.id===e);if(!n)return;const i={...n,...t};this.topologyLinks=this.topologyLinks.map(a=>a.id===e?i:a);const s=this.getArrowNodes(i);if(s){const a=this.buildArrowSpec(i,s.from,s.to);a?this.upsertArrow(i,a,s.from,s.to):this.removeArrow(i)}this.editor.eventHandler.eventBus.emit("node-manager:topo-updated"),this.emitTopologyChanged("link-updated")};handleLinkDeleted=({linkId:e})=>{const t=this.topologyLinks.find(n=>n.id===e);t&&(this.removeArrow(t),this.topologyLinks=this.topologyLinks.filter(n=>n.id!==e),this.editor.eventHandler.eventBus.emit("node-manager:topo-updated"),this.emitTopologyChanged("link-deleted"))};handleLinkFocused=({linkId:e})=>{this.focusActiveTopologyLink(e)};handleLinkVisibilityFilterRequested=({filter:e})=>{this.linkVisibilityFilter=e,this.applyArrowVisibilityFilter()};handleNodeRenderModeRequested=e=>{this.nodeRenderMode!==e&&(this.nodeRenderMode=e,this.applyNodeRenderModeToAllNodes())};handleLinkSelected=({linkIds:e})=>{this.focusTopologyLinks(e)};handleZoneSelected=({zoneIds:e})=>{this.focusTopologyZones(e)};handleSelectionTransformChanged=()=>{this.updateArrows()};handleZoneTranslationCommitted=({zoneId:e,delta:t})=>{this.moveTopologyZone(e,new I(t.x,t.y,0))}}const _C=.07,wC=.03,SC=2,MC=24;class TC{editor;globalPath;globalPathMap;localPath;constructor(e){this.editor=e,this.globalPathMap=new Map;const t=new js,n=new To({color:16711680,linewidth:_C,vertexColors:!1,worldUnits:!0,dashed:!1});this.globalPath=new fo(t,n),this.globalPath.position.set(0,0,.15),this.globalPath.renderOrder=mn.PATH,this.globalPath.visible=!1;const i=new js,s=new To({color:16766282,linewidth:wC,vertexColors:!1,worldUnits:!0,dashed:!0,dashSize:SC,dashScale:MC});this.localPath=new fo(i,s),this.localPath.position.set(0,0,.2),this.localPath.renderOrder=mn.PATH,this.localPath.visible=!1}dispose(){this.editor.eventHandler.eventBus.off("node-manager:topo-updated",this.handleTopoUpdated)}registerEventBusHandler(){this.editor.eventHandler.eventBus.on("node-manager:topo-updated",this.handleTopoUpdated)}updateGlobalPath(e){if(this.ensurePathsAddedToScene(),e.length){const t=this.convertDataToPositions(e),n=this.globalPath.geometry,i=new js;i.setPositions(t),i.instanceCount=Math.max(0,t.length/3-1),this.globalPath.geometry=i,n.dispose(),this.globalPath.visible=!0}else this.globalPath.visible=!1}updateLocalPath(e){if(this.ensurePathsAddedToScene(),e.length){const t=this.convertDataToPositions(e),n=this.localPath.geometry,i=new js;i.setPositions(t),i.instanceCount=Math.max(0,t.length/3-1),this.localPath.geometry=i,n.dispose(),this.localPath.computeLineDistances(),this.localPath.visible=!0}else this.localPath.visible=!1}convertDataToPositions(e){const t=new Float32Array(e.length*3);for(let n=0;n<e.length;n++){const[i,s]=e[n],a=n*3;t[a]=i,t[a+1]=s,t[a+2]=0}return t}ensurePathsAddedToScene(){this.editor.scene&&(this.globalPath.parent||(this.globalPath.userData.keep=!0,this.editor.scene.add(this.globalPath)),this.localPath.parent||(this.localPath.userData.keep=!0,this.editor.scene.add(this.localPath)))}handleTopoUpdated=()=>{this.globalPathMap.clear()}}class af{boundary;capacity;points;divided;children;constructor(e,t=20){this.boundary=e,this.capacity=t,this.points=[],this.divided=!1,this.children=[]}dispose(){if(this.divided)for(const e of this.children)e.dispose();this.points=[],this.children=[],this.boundary=null,this.divided=!1}insert(e,t){if(!this.boundary.containsPoint(e))return!1;if(this.points.length<this.capacity)return this.points.push({position:e.clone(),index:t}),!0;this.divided||this.subdivide();for(const n of this.children)if(n.insert(e,t))return!0;return!1}subdivide(){const{min:e,max:t}=this.boundary,n=new I().addVectors(e,t).multiplyScalar(.5);for(let i=0;i<2;i++)for(let s=0;s<2;s++)for(let a=0;a<2;a++){const o=new I(i===0?e.x:n.x,s===0?e.y:n.y,a===0?e.z:n.z),l=new I(i===0?n.x:t.x,s===0?n.y:t.y,a===0?n.z:t.z),c=new Yt(o,l);this.children.push(new af(c,this.capacity))}for(const{position:i,index:s}of this.points)for(const a of this.children)if(a.insert(i,s))break;this.points=[],this.divided=!0}}class of{boundary;capacity;points;divided;children;depth;maxDepth;minSize;constructor(e,t=8,n=0,i=16,s=.001){this.boundary=e.clone(),this.capacity=t,this.points=[],this.divided=!1,this.children=[],this.depth=n,this.maxDepth=i,this.minSize=s}dispose(){for(const e of this.children)e.dispose();this.points.length=0,this.children.length=0,this.divided=!1}insert(e,t){return this.boundary.containsPoint(new me(e.x,e.y))?!this.divided&&(this.points.length<this.capacity||this.shouldStopSubdivide())?(this.points.push({position:e.clone(),index:t}),!0):(this.divided||(this.subdivide(),this.redistributePointsToChildren()),this.insertIntoChild(e,t)):!1}shouldStopSubdivide(){const e=this.boundary.max.x-this.boundary.min.x,t=this.boundary.max.y-this.boundary.min.y;return this.depth>=this.maxDepth||e<=this.minSize||t<=this.minSize}subdivide(){if(this.divided)throw new Error("PointsQuadTree: subdivide called on divided node");const{min:e,max:t}=this.boundary,n=new me((e.x+t.x)/2,(e.y+t.y)/2),i=[new Ws(new me(e.x,e.y),new me(n.x,n.y)),new Ws(new me(n.x,e.y),new me(t.x,n.y)),new Ws(new me(e.x,n.y),new me(n.x,t.y)),new Ws(new me(n.x,n.y),new me(t.x,t.y))];if(this.children=i.map(s=>new of(s,this.capacity,this.depth+1,this.maxDepth,this.minSize)),this.children.length!==4)throw new Error("PointsQuadTree: failed to create 4 child quadrants");this.divided=!0}redistributePointsToChildren(){if(!this.divided||this.children.length!==4)throw new Error("PointsQuadTree: redistribute requires a divided node with 4 children");const e=this.points;this.points=[];for(const{position:t,index:n}of e)this.insertIntoChild(t,n)}insertIntoChild(e,t){if(!this.divided||this.children.length!==4)throw new Error("PointsQuadTree: insertIntoChild called before subdivision");const n=this.getChildIndex(e);if(!this.children[n].insert(e,t))throw new Error(`PointsQuadTree: failed to insert into child(${n}) at (${e.x}, ${e.y})`);return!0}getChildIndex(e){const{min:t,max:n}=this.boundary,i=(t.x+n.x)/2,s=(t.y+n.y)/2,a=e.x>=i,o=e.y>=s;return!a&&!o?0:a&&!o?1:!a&&o?2:3}clear(){this.points=[];for(const e of this.children)e.clear();this.children=[],this.divided=!1}}const Ji=[{r:44/255,g:123/255,b:182/255},{r:171/255,g:217/255,b:233/255},{r:1,g:1,b:191/255},{r:253/255,g:174/255,b:97/255},{r:215/255,g:25/255,b:28/255}],Xm=1024*3,EC=12294903;class AC{editor;pointsOctree=null;pointsQuadTree=null;mappingPoints=null;mappingPointsGeo=null;mappingPointsMat=null;mappingKeyFrame=null;mappingKeyFrameGeo=null;mappingKeyFrameMat=null;mapPoints;mapPointsGeo;mapPointsMat;mapPointsData;mapBoundary=null;showMapBoundary=!1;mapPointHeightClip=null;lidarPoints;lidarPointsGeo;lidarPointsMat;lidarFloat32Array=new Float32Array;lidarPositionAttr;lidar3DPoints;lidar3DPointsGeo;lidar3DPointsMat;lidar3DFloat32Array=new Float32Array;lidar3DPositionAttr;lastLidarSphereUpdateTime={lidar2D:0,lidar3D:0};sphereUpdateInterval=5e3;pendingMappingKeyFrameChunkNum=null;pendingMappingKeyFrameChunks=new Map;constructor(e){this.editor=e}registerEventListeners(){const e=this.editor.eventHandler.eventBus;e.on("lidar:updated",this.handleLidarUpdated),e.on("lidar3d:updated",this.handleLidar3DUpdated),e.on("ui:map-points-update-requested",this.handleMapPointsLoaded),e.on("ui:map-points-height-clip-set-requested",this.handleMapPointHeightClipSetRequested),e.on("ui:typed-map-points-update-requested",this.handleTypedMapPointsLoaded),e.on("ui:mapping-start-requested",this.handleMappingStarted),e.on("ui:mapping-stop-requested",this.handleMappingStopped),e.on("ui:mapping-data-received",this.handleMappingDataReceived),e.on("ui:mapping-keyframe-received",this.handleMappingKeyFrameReceived),e.on("robot-manager:main-robot-loaded",this.handleMainrobotLoaded),e.on("editor:initialized",this.handleEditorInitialized),e.on("ui:lidar-toggled",this.handleLidarToggled),e.on("ui:lidar3d-toggled",this.handleLidar3DToggled),e.on("ui:map-boundary-visibility-set-requested",this.handleMapBoundaryVisibilitySetRequested),e.on("ui:lidar-point-size-set-requested",this.handleLidarPointSizeSetRequested),e.on("ui:map-point-size-set-requested",this.handleMapPointSizeSetRequested)}deregisterEventListeners(){const e=this.editor.eventHandler.eventBus;e.off("lidar:updated",this.handleLidarUpdated),e.off("lidar3d:updated",this.handleLidar3DUpdated),e.off("ui:map-points-update-requested",this.handleMapPointsLoaded),e.off("ui:map-points-height-clip-set-requested",this.handleMapPointHeightClipSetRequested),e.off("ui:typed-map-points-update-requested",this.handleTypedMapPointsLoaded),e.off("ui:mapping-start-requested",this.handleMappingStarted),e.off("ui:mapping-stop-requested",this.handleMappingStopped),e.off("ui:mapping-data-received",this.handleMappingDataReceived),e.off("ui:mapping-keyframe-received",this.handleMappingKeyFrameReceived),e.off("robot-manager:main-robot-loaded",this.handleMainrobotLoaded),e.off("editor:initialized",this.handleEditorInitialized),e.off("ui:lidar-toggled",this.handleLidarToggled),e.off("ui:lidar3d-toggled",this.handleLidar3DToggled),e.off("ui:map-boundary-visibility-set-requested",this.handleMapBoundaryVisibilitySetRequested),e.off("ui:lidar-point-size-set-requested",this.handleLidarPointSizeSetRequested),e.off("ui:map-point-size-set-requested",this.handleMapPointSizeSetRequested)}changeMapPointsOpacity(e){this.mapPointsMat.opacity=e*.01}clearMapPoints(){this.mapPointsGeo.deleteAttribute("position"),this.mapPointsGeo.setAttribute("position",new ke([],3)),this.mapPointsGeo.boundingSphere=null,this.mapPointsGeo.attributes.position.needsUpdate=!0,this.pointsOctree&&(this.pointsOctree.dispose(),this.pointsOctree=null),this.pointsQuadTree&&(this.pointsQuadTree.dispose(),this.pointsQuadTree=null),this.clearMapBoundary(),this.mapPointsData=[],this.editor.eventHandler.eventBus.emit("points-manager:mappoints-updated",{mapBounds:null})}dispose(){this.pointsOctree&&(this.pointsOctree.dispose(),this.pointsOctree=null),this.pointsQuadTree&&(this.pointsQuadTree.dispose(),this.pointsQuadTree=null),this.mapPointsGeo?.dispose(),this.mapPointsMat?.dispose(),this.mapPointsData=null,this.lidarPointsGeo?.dispose(),this.lidar3DPointsGeo?.dispose(),this.lidarPointsMat?.dispose(),this.lidar3DPointsMat?.dispose(),this.mappingPoints&&this.editor.scene.remove(this.mappingPoints),this.mappingKeyFrame&&this.editor.scene.remove(this.mappingKeyFrame),this.lidarPoints&&this.editor.scene.remove(this.lidarPoints),this.lidar3DPoints&&this.editor.scene.remove(this.lidar3DPoints),this.clearMapBoundary(),this.mappingPointsGeo?.dispose(),this.mappingPointsMat?.dispose(),this.mappingKeyFrameGeo?.dispose(),this.mappingKeyFrameMat?.dispose(),this.mappingPointsGeo=null,this.mappingPointsMat=null,this.mappingKeyFrameGeo=null,this.mappingKeyFrameMat=null,this.resetMappingKeyFrameChunks(),this.deregisterEventListeners()}updateMapPoints(e){if(!this.mapPointsGeo)return;const{position:t,numPoints:n}=this.updatePosition(this.mapPointsGeo,e,"reset"),{boundaries:i,mapBounds:s}=this.calculateMapBoundsAndColorBoundaries(t,n);this.updateColors(i),this.finalizeUpdate(),this.createCloudQuadTree(),this.mapPointsData=e,this.updateMapBoundary(s),this.editor.eventHandler.eventBus.emit("points-manager:mappoints-updated",{mapBounds:s})}updateTypedMapPoints(e){if(!this.mapPointsGeo)return;const t=Math.min(Math.max(0,Math.floor(e.pointCount)),Math.floor(e.positions.length/3)),n=t*3,i=e.positions.length===n?e.positions:e.positions.subarray(0,n);this.mapPointsGeo.setAttribute("position",new ke(i,3));const s=t*3,a=e.intensityColors,o=a&&a.length>=s?a:e.colors;if(o&&o.length>=s){const l=o.length===s?o:o.subarray(0,s);this.mapPointsGeo.setAttribute("color",new ke(l,3)),this.mapPointsMat.vertexColors=!0}else this.mapPointsGeo.deleteAttribute("color"),this.mapPointsMat.vertexColors=!1,this.mapPointsMat.color.set(3800852);this.mapPointsMat.needsUpdate=!0,this.finalizeUpdate(e.bounds),this.mapPointsData=[],this.updateMapBoundary(e.bounds),this.editor.eventHandler.eventBus.emit("points-manager:mappoints-updated",{mapBounds:e.bounds})}updateMappingPoints(e){const t=this.mappingPointsGeo;!t||!this.mappingPointsMat||(this.updatePosition(t,e,"append"),t.computeBoundingSphere(),t.attributes.position.needsUpdate=!0)}updateMappingKeyFrame(e){const t=this.mappingKeyFrameGeo;!t||!this.mappingKeyFrameMat||(this.updatePosition(t,e,"append"),t.computeBoundingSphere(),t.attributes.position.needsUpdate=!0)}flattenMapPoints(){if(!this.mapPointsGeo)return;const e=this.mapPointsGeo.getAttribute("position");if(!e||!e.array.length){console.warn("[Flatten Map Points] No position attribute found in geometry.");return}for(let t=0;t<e.count;t++)e.setZ(t,0);this.finalizeUpdate()}restoreMapPointsDepth(){if(!this.mapPointsGeo)return;if(!this.mapPointsData){console.warn("Original map points data is missing.");return}const e=this.mapPointsGeo.getAttribute("position");if(!e||!e.array.length){console.warn("[Restore Map Points] Position attribute not found in geometry.");return}for(let t=0;t<this.mapPointsData.length;t++){const n=this.mapPointsData[t];e.setZ(t,n[2])}this.finalizeUpdate()}setMapPointHeightClip(e){e?this.mapPointHeightClip={minZ:Math.min(e.minZ,e.maxZ),maxZ:Math.max(e.minZ,e.maxZ)}:this.mapPointHeightClip=null,this.applyMapPointHeightClip()}calculateMapBoundsAndColorBoundaries(e,t){if(t===0)return{mapBounds:null,boundaries:null};let n=1/0,i=1/0,s=1/0,a=-1/0,o=-1/0,l=-1/0;for(let u=0;u<t;u++){const f=e[u*3],m=e[u*3+1],b=e[u*3+2];f<n&&(n=f),f>a&&(a=f),m<i&&(i=m),m>o&&(o=m),b<s&&(s=b),b>l&&(l=b)}const c={minX:n,minY:i,minZ:s,maxX:a,maxY:o,maxZ:l};if(s===l)return{mapBounds:c,boundaries:null};const d=l-s,h=[s,s+d*.2,s+d*.4,s+d*.6,s+d*.8,l];return{mapBounds:c,boundaries:h}}applyMapPointHeightClip(){if(!this.mapPointsMat)return;const{mapPointHeightClip:e}=this;this.mapPointsMat.clippingPlanes=e?[new ns(new I(0,0,1),-e.minZ),new ns(new I(0,0,-1),e.maxZ)]:[],this.mapPointsMat.needsUpdate=!0}createCloudOctree(){const e=this.mapPointsGeo.getAttribute("position"),t=new Yt().setFromBufferAttribute(e);t.expandByScalar(1);const n=new af(t,20);for(let i=0;i<e.count;i++){const s=new I().fromBufferAttribute(e,i);n.insert(s,i)}this.pointsOctree=n}createCloudQuadTree(){const e=this.mapPointsGeo.getAttribute("position"),t=new Yt().setFromBufferAttribute(e),n=new Ws(new me(t.min.x,t.min.y),new me(t.max.x,t.max.y));n.expandByScalar(1);const i=new of(n,20);try{for(let s=0;s<e.count;s++){const a=new I().fromBufferAttribute(e,s);i.insert(a,s)}}catch(s){console.error("PointsQuadTree: Insert error:",s)}this.pointsQuadTree=i}ensureCapacity(e){const t=this.lidarPositionAttr.array;if(e>t.length){const n=Math.max(e,t.length*2),i=new Float32Array(n);i.set(t);const s=new ke(i,3);s.setUsage(qo),this.lidarPositionAttr=s,this.lidarPointsGeo.setAttribute("position",s)}}ensureLidar3DCapacity(e){const t=this.lidar3DPositionAttr.array;if(e>t.length){const n=Math.max(e,t.length*2),i=new ke(new Float32Array(n),3);i.setUsage(qo),this.lidar3DPositionAttr=i,this.lidar3DPointsGeo.setAttribute("position",i)}}finalizeUpdate(e){if(this.mapPointsGeo.attributes.position.needsUpdate=!0,!e){this.mapPointsGeo.computeBoundingSphere();return}const t=new I((e.minX+e.maxX)/2,(e.minY+e.maxY)/2,(e.minZ+e.maxZ)/2),n=Math.hypot(e.maxX-e.minX,e.maxY-e.minY,e.maxZ-e.minZ)/2;this.mapPointsGeo.boundingSphere=new vn(t,n)}clearPointsGeometry(e){e.deleteAttribute("position"),e.setAttribute("position",new ke([],3)),e.boundingSphere=null,e.attributes.position.needsUpdate=!0}clearMapBoundary(){this.mapBoundary&&(this.editor.scene.remove(this.mapBoundary),this.mapBoundary.geometry.dispose(),Array.isArray(this.mapBoundary.material)?this.mapBoundary.material.forEach(e=>e.dispose()):this.mapBoundary.material.dispose(),this.mapBoundary=null)}updateMapBoundary(e){if(this.clearMapBoundary(),!e)return;const t=Math.max(e.maxZ,0)+.02,n=new Float32Array([e.minX,e.minY,t,e.maxX,e.minY,t,e.maxX,e.minY,t,e.maxX,e.maxY,t,e.maxX,e.maxY,t,e.minX,e.maxY,t,e.minX,e.maxY,t,e.minX,e.minY,t]),i=new ht;i.setAttribute("position",new rn(n,3));const s=new zn({color:Yb,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.95});this.mapBoundary=new Ks(i,s),this.mapBoundary.renderOrder=mn.PATH,this.mapBoundary.visible=this.showMapBoundary,this.mapBoundary.userData.keep=!0,this.editor.scene.add(this.mapBoundary)}handleLidarUpdated=e=>{const t=this.lidarPointsToFloatArray(e.lidarPoints);this.ensureCapacity(t.length),this.lidarPositionAttr.array.set(t),this.lidarPointsGeo.setAttribute("position",this.lidarPositionAttr);const n=t.length/3;this.lidarPointsGeo.setDrawRange(0,n),this.lidarPointsGeo.attributes.position.needsUpdate=!0,this.shouldUpdateSphere("lidar2D")&&this.lidarPointsGeo.computeBoundingSphere()};handleLidar3DUpdated=e=>{const t=this.lidar3DPointsToFloatArray(e.lidarPoints);this.ensureLidar3DCapacity(t.length),this.lidar3DPositionAttr.array.set(t),this.lidar3DPointsGeo.setDrawRange(0,t.length/3),this.lidar3DPositionAttr.needsUpdate=!0,this.shouldUpdateSphere("lidar3D")&&this.lidar3DPointsGeo.computeBoundingSphere()};handleLidarToggled=e=>{this.lidarPoints.visible=e};handleLidar3DToggled=e=>{this.lidar3DPoints.visible=e};handleMapBoundaryVisibilitySetRequested=e=>{this.showMapBoundary=e,this.mapBoundary&&(this.mapBoundary.visible=e)};handleLidarPointSizeSetRequested=e=>{this.lidarPointsMat.size=e,this.lidarPointsMat.needsUpdate=!0,this.lidar3DPointsMat.size=e,this.lidar3DPointsMat.needsUpdate=!0};handleMapPointSizeSetRequested=e=>{this.mapPointsMat.size=e,this.mapPointsMat.needsUpdate=!0};shouldUpdateSphere(e){const t=performance.now(),n=this.lastLidarSphereUpdateTime[e];return t-n>this.sphereUpdateInterval||n===0?(this.lastLidarSphereUpdateTime[e]=t,!0):!1}handleMappingKeyFrameReceived=e=>{const t=this.mappingKeyFrameGeo,n=this.mappingPointsGeo;if(!e||!t||!n)return;const{data:i,chunkNum:s,chunkId:a}=e;if(s<=0||a<0||a>=s||((a===0||this.pendingMappingKeyFrameChunkNum!==s)&&(this.resetMappingKeyFrameChunks(),this.pendingMappingKeyFrameChunkNum=s),this.pendingMappingKeyFrameChunks.set(a,i),this.pendingMappingKeyFrameChunks.size!==s))return;const o=[];for(let l=0;l<s;l++){const c=this.pendingMappingKeyFrameChunks.get(l);if(!c)return;for(const d of c)o.push(d)}this.updateMappingKeyFrame(o),this.clearPointsGeometry(n),this.resetMappingKeyFrameChunks()};updateColors(e){const t=this.mapPointsGeo,n=t.getAttribute("position"),i=n.count,s=n.array;let a=t.getAttribute("color");if((!a||a.count!==i)&&(a=new ke(new Float32Array(i*3),3),t.setAttribute("color",a)),!e){const o=.2235294117647059,l=255/255,c=20/255;for(let d=0;d<i;d++)a.setXYZ(d,o,l,c);a.needsUpdate=!0;return}for(let o=0;o<i;o++){const l=s[o*3+2];let c,d,h,u;l<e[1]?(c=Ji[0],d=Ji[1],h=e[0],u=e[1]):l<e[2]?(c=Ji[1],d=Ji[2],h=e[1],u=e[2]):l<e[3]?(c=Ji[2],d=Ji[3],h=e[2],u=e[3]):l<e[4]?(c=Ji[3],d=Ji[4],h=e[3],u=e[4]):(c=Ji[4],d=Ji[4],h=e[4],u=e[5]);const f=u-h||1;let m=(l-h)/f;m=Math.max(0,Math.min(1,m));const b=c.r*(1-m)+d.r*m,p=c.g*(1-m)+d.g*m,g=c.b*(1-m)+d.b*m;a.setXYZ(o,b,p,g)}a.needsUpdate=!0}updatePosition(e,t,n="reset"){const i=new Float32Array(t.length*3);for(let o=0,l=0;o<t.length;o++,l+=3){const[c,d,h]=t[o];i[l]=c,i[l+1]=d,i[l+2]=h}let s;if(n==="reset")s=i;else{const l=e.getAttribute("position")?.array,c=l?.length??0;s=new Float32Array(c+i.length),l&&s.set(l,0),s.set(i,c)}const a=new ke(s,3);return e.setAttribute("position",a),{position:s,numPoints:s.length/3}}handleMapPointsLoaded=e=>{this.updateMapPoints(e)};handleMapPointHeightClipSetRequested=e=>{this.setMapPointHeightClip(e)};handleTypedMapPointsLoaded=e=>{this.updateTypedMapPoints(e)};handleMappingStarted=()=>{this.handleMappingStopped(),this.resetMappingKeyFrameChunks(),this.mapPoints.visible=!1,this.mappingPointsGeo=new ht,this.mappingPointsGeo.setAttribute("position",new ke([],3)),this.mappingPointsMat=new mr({size:.2,color:8245247}),this.mappingPoints=new sa(this.mappingPointsGeo,this.mappingPointsMat),this.mappingPoints.renderOrder=mn.MAPPING_POINTS,this.mappingPoints.userData.keep=!0,this.editor.scene.add(this.mappingPoints),this.mappingKeyFrameGeo=new ht,this.mappingKeyFrameGeo.setAttribute("position",new ke([],3)),this.mappingKeyFrameMat=new mr({size:.2,color:2450411}),this.mappingKeyFrame=new sa(this.mappingKeyFrameGeo,this.mappingKeyFrameMat),this.mappingKeyFrame.renderOrder=mn.MAP_POINTS,this.mappingKeyFrame.userData.keep=!0,this.editor.scene.add(this.mappingKeyFrame)};handleMappingStopped=()=>{this.mapPoints.visible=!0,this.resetMappingKeyFrameChunks(),this.mappingPoints&&this.editor.scene.remove(this.mappingPoints),this.mappingKeyFrame&&this.editor.scene.remove(this.mappingKeyFrame),this.mappingPointsGeo?.dispose(),this.mappingPointsMat?.dispose(),this.mappingKeyFrameGeo?.dispose(),this.mappingKeyFrameMat?.dispose(),this.mappingPoints=null,this.mappingKeyFrame=null,this.mappingPointsGeo=null,this.mappingPointsMat=null,this.mappingKeyFrameGeo=null,this.mappingKeyFrameMat=null};handleMappingDataReceived=e=>{this.updateMappingPoints(e)};handleMainrobotLoaded=()=>{this.editor.robotManager.mainRobot&&this.editor.scene.add(this.lidarPoints)};lidarPointsToFloatArray=e=>{const t=e.length*3;this.lidarFloat32Array.length<t&&(this.lidarFloat32Array=new Float32Array(t*2));for(let n=0,i=0;n<e.length;n++,i+=3){const[s,a,o]=e[n];this.lidarFloat32Array[i]=+s,this.lidarFloat32Array[i+1]=+a,this.lidarFloat32Array[i+2]=+o}return this.lidarFloat32Array.subarray(0,t)};lidar3DPointsToFloatArray=e=>{const t=e.length*3;this.lidar3DFloat32Array.length<t&&(this.lidar3DFloat32Array=new Float32Array(t*2));for(let n=0,i=0;n<e.length;n++,i+=3){const[s,a,o]=e[n];this.lidar3DFloat32Array[i]=+s,this.lidar3DFloat32Array[i+1]=+a,this.lidar3DFloat32Array[i+2]=+o}return this.lidar3DFloat32Array.subarray(0,t)};handleEditorInitialized=()=>{this.mapPointsGeo=new ht,this.mapPointsGeo.setAttribute("position",new ke([],3)),this.mapPointsMat=new mr({size:Kb,vertexColors:!0,transparent:!0,opacity:1,depthWrite:!1}),this.mapPoints=new sa(this.mapPointsGeo,this.mapPointsMat),this.mapPoints.renderOrder=mn.MAP_POINTS,this.mapPoints.userData.keep=!0,this.editor.scene.add(this.mapPoints),this.applyMapPointHeightClip(),this.mapPointsData=[],this.lidarPointsGeo=new ht,this.lidarPointsMat=new mr({size:_u,color:16725342,transparent:!0,depthWrite:!1}),this.lidarPoints=new sa(this.lidarPointsGeo,this.lidarPointsMat),this.lidarPoints.renderOrder=mn.LIDAR_POINTS,this.lidarPoints.userData.keep=!0,this.lidarPositionAttr=new ke(new Float32Array(Xm),3),this.lidarPositionAttr.setUsage(qo),this.lidarPointsGeo.setAttribute("position",this.lidarPositionAttr),this.lidarPointsGeo.setDrawRange(0,0),this.lidar3DPointsGeo=new ht,this.lidar3DPointsMat=new mr({size:_u,color:EC,transparent:!0,depthTest:!0,depthWrite:!1}),this.lidar3DPoints=new sa(this.lidar3DPointsGeo,this.lidar3DPointsMat),this.lidar3DPoints.renderOrder=mn.LIDAR_3D_POINTS,this.lidar3DPoints.userData.keep=!0,this.editor.scene.add(this.lidar3DPoints),this.lidar3DPositionAttr=new ke(new Float32Array(Xm),3),this.lidar3DPositionAttr.setUsage(qo),this.lidar3DPointsGeo.setAttribute("position",this.lidar3DPositionAttr),this.lidar3DPointsGeo.setDrawRange(0,0)};resetMappingKeyFrameChunks=()=>{this.pendingMappingKeyFrameChunkNum=null,this.pendingMappingKeyFrameChunks.clear()}}class lf{constructor(e=120){this.cap=e}buf=[];push(e){this.buf.push(e),this.buf.length>this.cap&&this.buf.shift()}bracket(e){let t,n;for(let i=this.buf.length-1;i>=0;--i)if(this.buf[i].t<=e){t=this.buf[i],n=this.buf[i+1];break}return[t,n]}sampleTransform(e){const[t,n]=this.bracket(e),i=t,s=n;if(!i)return null;if(!s)return{...i,t:e};const a=(e-t.t)/(n.t-t.t||1e-6);return{t:e,x:this.lerpNum(i.x,s.x,a),y:this.lerpNum(i.y,s.y,a),rz:this.lerpAngleDeg(i.rz,s.rz,a)}}sampleJoint(e){const[t,n]=this.bracket(e),i=t,s=n;if(!i)return null;if(!s)return{...i,t:e};const a=(e-i.t)/(s.t-i.t||1e-6);return{t:e,map:this.lerpMap(i.map,s.map,a)}}lerpNum(e,t,n){return e+(t-e)*n}lerpAngleDeg(e,t,n){const i=(t-e+540)%360-180;return e+i*n}lerpMap(e,t,n){const i={};for(const s in t){const a=e?e[s]??t[s]:t[s];i[s]=this.lerpNum(a,t[s],n)}return i}}class Qs extends Vt{transformBuf=new lf;tmpTransform=new I;clock=new Qu;ROT_DAMP_RATE=5;jointBuf;constructor(){super()}pushTransformSnapshot(e){this.transformBuf.push(e)}pushJointsSnapshot(e,t=performance.now()/1e3){this.jointBuf&&this.jointBuf.push({t,map:e})}tick(e){const t=this.transformBuf.sampleTransform(e);if(t){this.tmpTransform.set(t.x,t.y,0),this.position.lerp(this.tmpTransform,.15);const n=this.clock.getDelta(),i=bt.degToRad(t.rz),s=bt.euclideanModulo(i-this.rotation.z+Math.PI,2*Math.PI)-Math.PI;this.rotation.z+=s*bt.damp(0,1,this.ROT_DAMP_RATE,n)}if(this.jointBuf){const n=this.jointBuf.sampleJoint(e);n&&this.applyJointValues?.(n.map)}}alignToGroundZUp(e,t){const{centerXY:n=!1}=t||{};e.updateMatrixWorld(!0);const i=new Yt().setFromObject(e),s=-i.min.z;if(e.position.z+=s,n){const a=new I;i.getCenter(a),e.position.x-=a.x,e.position.y-=a.y}e.updateMatrixWorld(!0)}}class cf extends Qs{static async create(){const e=new cf;return await e._initAsync(),e}constructor(){super(),this.name="RB-S100",this.userData.keep=!0}async _initAsync(){const e=new Ar,t=Hn(As.S100.modelUrl);try{const i=(await e.loadAsync(t)).scene;i.traverse(s=>{s.userData.keep=!0}),i.renderOrder=mn.ROBOT,i.updateMatrixWorld(!0),this.add(i)}catch(n){n instanceof Error?console.error("RB-S100 Load Failed:",n.message):console.error("RB-S100 Load Failed:",n)}}update(e){this.position.set(Number(e.x),Number(e.y),0),this.rotation.z=bt.degToRad(Number(e.rz))}applyPose(e){if(!e)return;const t={t:performance.now()*.001,x:e.x,y:e.y,rz:e.rz};this.pushTransformSnapshot(t)}}var mc={exports:{}};/* @license
|
|
4392
|
+
`;const n=new Hs(t);n.visible=!0,n.userData.keep=!0,n.userData.labelType="node",n.name="label",n.center.set(0,-.5),e.add(n);const i={obj:n,bucket:null,worldPosition:null};this.editor.eventHandler.eventBus.emit("node-manager:label-added",i)}formatId(e){return e.toString().padStart(4,"0")}parseIssuedNumber(e){if(!e)return null;const t=/^[GRA]_(\d{4})$/.exec(e);return t?Number(t[1]):null}allocateId(){for(let e=0;e<=this.MAX_ID;e++){const t=(this.lastIssued+1+e)%(this.MAX_ID+1),n=this.formatId(t);if(!this.usedIds.has(n))return this.usedIds.add(n),this.lastIssued=t,n}throw new Error("사용 가능한 Node ID(0000~9999)가 없습니다.")}addNode(e,t,n=null){let i=this.goalMesh;if(!i)return;if(e===gs.ROUTE)i=this.routeMesh;else if(e===gs.ALIGN){const f=n?.features??[];i=(f.includes("APRIL")||f.includes("ARUCO"))&&this.markerMesh?this.markerMesh:this.alignMesh}const s=i.clone(),{x:a,y:o,z:l,rx:c,ry:d,rz:h}=t;s.position.set(a,o,l),s.rotation.set(c,d,h);const u=e===gs.GOAL?"G":e===gs.ROUTE?"R":"A";if(s.userData.type=e,s.userData.features=[],s.userData.safetyField=0,n){s.name=n.name,s.userData.id=n.id,s.userData.context=n.context??"",Array.isArray(n.features)&&(s.userData.features=n.features.filter(m=>typeof m=="string")),typeof n.safetyField=="number"&&(s.userData.safetyField=n.safetyField);const f=this.parseIssuedNumber(n.name);f!==null&&(this.usedIds.add(this.formatId(f)),f>this.lastIssued&&(this.lastIssued=f))}else{const f=this.allocateId();s.name=`${u}_${f}`,s.userData.id=s.uuid}return this.addLabel(s),this.cacheDefaultNodeAppearance(s),this.applyNodeRenderMode(s),this.editor.scene.add(s),this.editor.selectionManager.registerSelectable(s),this.editor.eventHandler.eventBus.emit("topology:nodes-updated",this.editor.selectionManager.getSelectableObjects()),s}alignNodesByAxis(e,t){const n=this.editor.selectionManager.getSelectedObjects();if(!n.length)return;const i=t==="min",s=i?Math.min:Math.max,a=i?1/0:-1/0,o=n.reduce((l,c)=>s(l,c.position[e]),a);for(let l=0,c=n.length;l<c;l++){const d=n[l];d.position[e]=o}this.updateArrows(),this.emitSelectionTransformChanged(n[n.length-1]),this.emitTopologyChanged("node-updated")}alignNodesWithSpacing(e,t){const n=this.editor.selectionManager.getSelectedObjects();if(!n.length)return;const i=n.map(o=>o.position[e]),s=e==="x"?Math.min(...i):Math.max(...i),a=e==="x"?1:-1;for(let o=0,l=n.length;o<l;o++){const c=n[o];c.position[e]=s+a*t*o}this.updateArrows(),this.emitSelectionTransformChanged(n[n.length-1]),this.emitTopologyChanged("node-updated")}alignNodesTheta(){const e=this.editor.selectionManager.getSelectedObjects();if(!e.length)return;let t=0,n=0;for(let s=0,a=e.length;s<a;s++){const l=e[s].rotation.z;t+=Math.sin(l),n+=Math.cos(l)}const i=Math.atan2(t,n);for(let s=0,a=e.length;s<a;s++){const o=e[s];o.rotation.z=i}}changeNodeName(e,t){e.name=t,this.editor.eventHandler.eventBus.emit("node-manager:node-name-changed",{name:t})}getCircumradius(e){if(this.nodeRenderMode==="simple")return vv;const t=this.getNodeRadiusKey(e);return this.nodeRadiusMap[t]*yC}getNodeRadiusKey(e){const t=Array.isArray(e.userData.features)?e.userData.features:[];if(e.userData.type===gs.ALIGN&&(t.includes("APRIL")||t.includes("ARUCO")))return"MARKER";switch(e.userData.type){case"GOAL":return"GOAL";case"ROUTE":return"ROUTE";case"ALIGN":return"ALIGN"}return"GOAL"}measureNodeModelRadius(e){return new Yt().setFromObject(e).getBoundingSphere(new vn).radius}async cacheNodeAssets(e){const t=new X1,n=Hn("/nodes/goal2.fbx");try{const c=(await t.loadAsync(n)).children[0],d=c.material,h=new Fn;h.copy(d),h.color.set(12186288),c.material=h,this.goalMesh=c,this.materialMap.GOAL=h,this.nodeRadiusMap.GOAL=this.measureNodeModelRadius(c),console.log("[NodeManager] goal mesh loaded from",n)}catch(l){console.error(l)}const i=Hn("/nodes/route.fbx");try{const c=(await t.loadAsync(i)).children[0],d=c.material,h=new Fn;h.copy(d),c.material=h,this.routeMesh=c,this.materialMap.ROUTE=h,this.nodeRadiusMap.ROUTE=this.measureNodeModelRadius(c),console.log("[NodeManager] route mesh loaded from",i)}catch(l){console.error(l)}const s=this.goalMesh.clone(),a=this.goalMesh.material.clone();a.color.set(16727988),s.material=a,this.alignMesh=s,this.materialMap.ALIGN=a,this.nodeRadiusMap.ALIGN=this.measureNodeModelRadius(s);const o=Hn("/nodes/marker.fbx");try{const c=(await t.loadAsync(o)).children[0],d=c.material,h=new Fn;h.copy(d),c.material=h,this.markerMesh=c,this.materialMap.MARKER=h,this.nodeRadiusMap.MARKER=this.measureNodeModelRadius(c)}catch(l){console.error(l),this.markerMesh=s.clone(),this.materialMap.MARKER=a,this.nodeRadiusMap.MARKER=this.measureNodeModelRadius(this.markerMesh)}this.editor.eventHandler.eventBus.emit("node-manager:ready")}getTopologyLinks(){return[...this.topologyLinks]}getTopologyZones(){return[...this.topologyZones]}getTopologyZone(e){return this.topologyZones.find(t=>t.id===e)??null}focusTopologyLinks(e){const t=e.length?this.editor.selectionManager.getSelectableLinks().filter(n=>e.includes(String(n.userData.linkId))):[];this.editor.selectionManager.setSelectedLinks(t),this.editor.eventHandler.eventBus.emit("selector:link-focused",{linkId:this.editor.selectionManager.getFocusedLinkId()}),this.updateArrowVisualStates(e)}focusActiveTopologyLink(e){this.editor.selectionManager.setFocusedLinkId(e),this.editor.eventHandler.eventBus.emit("selector:link-focused",{linkId:this.editor.selectionManager.getFocusedLinkId()}),this.updateArrowVisualStates(this.getSelectedLinkIds())}matchesLinkVisibilityFilter(e){const t=this.linkVisibilityFilter.dir==="all"||this.linkVisibilityFilter.dir==="forward"&&e.dir==="FORWARD"||this.linkVisibilityFilter.dir==="reverse"&&e.dir==="REVERSE",n=this.linkVisibilityFilter.method==="all"||e.method===this.linkVisibilityFilter.method;return t&&n}applyArrowVisibilityFilter(){for(let e=0;e<this.topologyLinks.length;e++){const t=this.topologyLinks[e],n=this.getArrowKey(t.from,t.to),i=this.arrowMap.get(n);i&&(i.visible=this.getArrowVisibility(t))}}getArrowVisibility(e){return this.isArrowLayerVisible&&this.matchesLinkVisibilityFilter(e)}cacheDefaultNodeAppearance(e){const t=e;t.userData.defaultAppearance||(t.userData.defaultAppearance={geometry:e.geometry,material:e.material,childMeshVisibility:e.children.filter(n=>!(n instanceof Hs)).map(n=>({object:n,visible:n.visible}))})}getSimpleMaterial(e){const t=Array.isArray(e.userData.features)?e.userData.features:[];return e.userData.type===gs.ALIGN&&(t.includes("APRIL")||t.includes("ARUCO"))?this.simpleMaterialMap.MARKER:this.simpleMaterialMap[e.userData.type]}applyDefaultNodeAppearance(e){const n=e.userData.defaultAppearance;if(n){e.geometry=n.geometry,e.material=n.material;for(let i=0;i<n.childMeshVisibility.length;i++){const s=n.childMeshVisibility[i];s.object.visible=s.visible}}}applySimpleNodeAppearance(e){e.geometry=yv,e.material=this.getSimpleMaterial(e);const n=e.userData.defaultAppearance;if(n)for(let i=0;i<n.childMeshVisibility.length;i++)n.childMeshVisibility[i].object.visible=!1}applyNodeRenderMode(e){if(this.cacheDefaultNodeAppearance(e),this.nodeRenderMode==="simple"){this.applySimpleNodeAppearance(e);return}this.applyDefaultNodeAppearance(e)}applyNodeRenderModeToAllNodes(){const e=this.editor.selectionManager.getSelectableObjects();for(let t=0;t<e.length;t++)this.applyNodeRenderMode(e[t]);this.refreshAllArrows()}refreshAllArrows(){for(let e=0;e<this.topologyLinks.length;e++){const t=this.topologyLinks[e],n=this.getArrowNodes(t);if(!n){this.removeArrow(t);continue}const i=this.buildArrowSpec(t,n.from,n.to);if(!i){this.removeArrow(t);continue}this.upsertArrow(t,i,n.from,n.to)}this.applyArrowVisibilityFilter()}focusTopologyZones(e){const t=e.length?this.editor.selectionManager.getSelectableZones().filter(n=>e.includes(String(n.userData.zoneId))):[];this.editor.selectionManager.setSelectedZones(t),this.editor.eventHandler.eventBus.emit("selector:zone-focused",{zoneId:this.editor.selectionManager.getFocusedZoneId()}),this.zoneModule.focusCommittedZones(e)}focusActiveTopologyZone(e){this.editor.selectionManager.setFocusedZoneId(e),this.editor.eventHandler.eventBus.emit("selector:zone-focused",{zoneId:this.editor.selectionManager.getFocusedZoneId()}),this.zoneModule.focusActiveCommittedZone(e)}addTopologyZone(e){this.topologyZones=[...this.topologyZones,e],this.editor.eventHandler.eventBus.emit("node-manager:topo-updated")}updateTopologyZone(e){return this.topologyZones.findIndex(n=>n.id===e.id)<0?!1:(this.topologyZones=this.topologyZones.map(n=>n.id===e.id?e:n),this.editor.eventHandler.eventBus.emit("node-manager:topo-updated"),!0)}moveTopologyZone(e,t){const n=this.getTopologyZone(e);if(!n)return!1;const i={...n,polygon:n.polygon.map(s=>({x:s.x+t.x,y:s.y+t.y}))};return this.updateTopologyZone(i)?(this.emitTopologyChanged("zone-updated"),!0):!1}deleteTopologyZone(e){this.topologyZones.some(n=>n.id===e)&&(this.topologyZones=this.topologyZones.filter(n=>n.id!==e),this.zoneModule.removeCommittedZone(e),this.editor.eventHandler.eventBus.emit("node-manager:topo-updated"),this.emitTopologyChanged("zone-deleted"))}emitTopologyChanged(e){this.editor.eventHandler.eventBus.emit("topology:changed",{source:e})}linkNodes(e,t,n={dir:"FORWARD",method:"PP",speed:0,avoidRange:0,safetyField:0,slowMarginX:0,slowMarginY:0,stopMarginX:0,stopMarginY:0}){if(!e||!t)return;const i=this.getTopologyNodeId(e),s=this.getTopologyNodeId(t);if(!i||!s)return;const a=this.findTopologyLink(i,s),o={id:a?.id??bt.generateUUID(),from:i,to:s,...n},l=!a;this.upsertTopologyLink(o),this.emitTopologyChanged(l?"link-created":"link-updated");const c=this.buildArrowSpec(o,e,t);c&&this.upsertArrow(o,c,e,t)}renderTopologyLink(e){const t=this.findObjectByUserDataId(this.editor.scene,e.from),n=this.findObjectByUserDataId(this.editor.scene,e.to);if(!t||!n){console.warn(`[DRAW TOPO] Invalid link: ${e.id}`,e);return}const i=this.buildArrowSpec(e,t,n);i&&this.upsertArrow(e,i,t,n)}upsertTopologyLink(e){const t=this.topologyLinks.findIndex(n=>n.from===e.from&&n.to===e.to);if(t<0){this.topologyLinks=[...this.topologyLinks,e],this.editor.eventHandler.eventBus.emit("node-manager:topo-updated");return}this.topologyLinks=this.topologyLinks.map((n,i)=>i===t?e:n),this.editor.eventHandler.eventBus.emit("node-manager:topo-updated")}removeTopologyLink(e,t){const n=this.getTopologyNodeId(e),i=this.getTopologyNodeId(t);if(!n||!i||!this.topologyLinks.some(l=>l.from===n&&l.to===i))return!1;const a=this.getArrowKey(n,i),o=this.arrowMap.get(a);return o&&(o.removeFromParent(),o.dispose(),this.arrowMap.delete(a)),this.topologyLinks=this.topologyLinks.filter(l=>!(l.from===n&&l.to===i)),this.editor.eventHandler.eventBus.emit("node-manager:topo-updated"),this.emitTopologyChanged("link-deleted"),!0}findTopologyLink(e,t){return this.topologyLinks.find(n=>n.from===e&&n.to===t)}getArrowKey(e,t){return`${e}->${t}`}getArrowNodes(e){const t=this.findObjectByUserDataId(this.editor.scene,e.from),n=this.findObjectByUserDataId(this.editor.scene,e.to);return!t||!n?null:{from:t,to:n}}getRelatedTopologyLinks(e){return this.topologyLinks.filter(t=>t.from===e||t.to===e)}getTopologyNodeId(e){return typeof e.userData.id=="string"?e.userData.id:""}toggleAllNodes=e=>{this.editor.selectionManager.getSelectableObjects().forEach(t=>{t.visible=e})};toggleAllArrows=e=>{this.isArrowLayerVisible=e,this.applyArrowVisibilityFilter()};unlinkNodes(e,t){this.removeTopologyLink(e,t),this.removeTopologyLink(t,e)}updateArrows=()=>{const e=this.editor.selectionManager.getSelectedObjects();for(let t=0,n=e.length;t<n;t++){const i=e[t],s=this.getTopologyNodeId(i);if(!s)continue;const a=this.getRelatedTopologyLinks(s);for(let o=0;o<a.length;o++){const l=a[o],c=this.getArrowNodes(l);if(!c){this.removeArrow(l);continue}const d=this.buildArrowSpec(l,c.from,c.to);if(!d){this.removeArrow(l);continue}this.upsertArrow(l,d,c.from,c.to)}}};updateNodeName(e){const t=this.editor.selectionManager.getSelected();t!==null&&(this.removeLabel(t),t.name=e,this.addLabel(t))}removeAllArrowsRelatedTo=e=>{const t=this.getTopologyNodeId(e);if(!t)return;const n=this.getRelatedTopologyLinks(t);for(let i=0;i<n.length;i++)this.removeArrow(n[i])};removeAllLinksRelatedTo(e){if(!e)return;const t=this.getTopologyNodeId(e);if(!t)return;const n=this.getRelatedTopologyLinks(t);for(let i=0;i<n.length;i++)this.removeArrow(n[i]);this.topologyLinks=this.topologyLinks.filter(i=>i.from!==t&&i.to!==t),this.editor.eventHandler.eventBus.emit("node-manager:topo-updated")}removeLabel(e){e.traverse(t=>{t.name==="label"&&e.remove(t)})}transformNodes(e,t){const n=this.editor.selectionManager.getSelectedObjects();if(!n.length)return;for(let s=0,a=n.length;s<a;s++){const o=n[s];switch(e){case"x":o.position.x+=t;break;case"y":o.position.y+=t;break;case"z":o.position.z+=t;break;case"rz":{const l=t*Math.PI/180;o.rotation.z+=l;break}}}const i=n[n.length-1];this.updateArrows(),this.emitSelectionTransformChanged(i),this.emitTopologyChanged("node-updated")}transformNodesByInput(e,t){const n=this.editor.selectionManager.getSelectedObjects();if(n.length===0)return;const i=Number(t);if(Number.isNaN(i))return;let s=0;e==="rz"&&(s=i*Math.PI/180);for(let o=0,l=n.length;o<l;o++){const c=n[o];switch(e){case"x":c.position.x=i;break;case"y":c.position.y=i;break;case"z":c.position.z=i;break;case"rz":c.rotation.z=s;break}}const a=n[n.length-1];this.updateArrows(),this.emitSelectionTransformChanged(a),this.emitTopologyChanged("node-updated")}clearArrows(){this.arrowMap.forEach(e=>{this.editor.selectionManager.unregisterSelectableLink(e),e.removeFromParent(),e.dispose()}),this.arrowMap.clear()}updateArrowVisualStates(e){const t=new Set(e),n=this.editor.selectionManager.getFocusedLinkId();for(let i=0;i<this.topologyLinks.length;i++){const s=this.topologyLinks[i],a=this.getArrowKey(s.from,s.to),o=this.arrowMap.get(a);if(o){if(n===s.id){o.setVisualState("focused");continue}if(t.has(s.id)){o.setVisualState("selected");continue}o.setVisualState("default")}}}getSelectedLinkIds(){return this.editor.selectionManager.getSelectedLinks().map(e=>String(e.userData.linkId))}removeArrow(e){const t=this.getArrowKey(e.from,e.to),n=this.arrowMap.get(t);n&&(this.editor.selectionManager.unregisterSelectableLink(n),n.removeFromParent(),n.dispose(),this.arrowMap.delete(t))}upsertArrow(e,t,n,i){const s=this.getArrowKey(e.from,e.to),a=this.arrowMap.get(s);if(a){a.applySpec(t),this.applyArrowVisualState(a,e.id),a.visible=this.getArrowVisibility(e);return}const o=new b1;o.applySpec(t),this.applyArrowVisualState(o,e.id),o.name=`${n.id}-${i.id}`,o.userData={...o.userData,from:n.id,to:i.id,linkId:e.id,linkKey:s},o.hitArea.userData={...o.hitArea.userData,from:n.id,to:i.id,linkId:e.id,linkKey:s},this.editor.scene.add(o),this.editor.selectionManager.registerSelectableLink(o),this.arrowMap.set(s,o),o.visible=this.getArrowVisibility(e)}applyArrowVisualState(e,t){if(this.editor.selectionManager.getFocusedLinkId()===t){e.setVisualState("focused");return}if(this.getSelectedLinkIds().includes(t)){e.setVisualState("selected");return}e.setVisualState("default")}buildArrowSpec(e,t,n){const i=t.position,s=n.position,a=i.distanceTo(s);if(a<=0)return null;const o=new I().subVectors(s,i).normalize(),l=this.getCircumradius(n),c=n.userData.type==="ROUTE"?.8:1.5,d=a-l;return{dir:o,origin:i.clone().addScaledVector(Pt.DEFAULT_UP,.1),length:Math.max(d,0),showHead:a-l>=c,showReverseBar:e.dir==="REVERSE"}}handleEditorInitialized=e=>{this.cacheNodeAssets(e.robotType)};handleMappingStarted=()=>{this.toggleAllNodes(!1),this.toggleAllArrows(!1)};handleMappingStopped=()=>{this.toggleAllNodes(!0),this.toggleAllArrows(!0)};handleUpdateTopology=e=>{this.usedIds.clear(),this.lastIssued=-1,this.editor.clear({clearMap:!1,clearTopo:!0}),this.drawTopo(e.topoData)};handleAddNodeByPreview=e=>{if(!this.editor.previewHelper.visible)return;const t=this.editor.previewHelper.position,n={x:t.x,y:t.y,z:t.z,rx:this.editor.previewHelper.rotation.x,ry:this.editor.previewHelper.rotation.y,rz:this.editor.previewHelper.rotation.z};this.addNode(e,n)&&this.emitTopologyChanged("node-added")};handleQuickAnnotation=e=>{const t=this.editor.robotManager.mainRobot,n={x:t.position.x,y:t.position.y,z:t.position.z,rx:t.rotation.x,ry:t.rotation.y,rz:t.rotation.z};this.addNode(e,n)&&this.emitTopologyChanged("node-added")};handleNodeUpdated=({nodeId:e,updates:t})=>{const n=this.editor.selectionManager.getSelectedObjects().find(i=>i.uuid===e);n&&(typeof t.name=="string"&&(n.name=t.name),Array.isArray(t.features)&&(n.userData.features=t.features.filter(i=>typeof i=="string"),this.nodeRenderMode==="simple"&&this.applySimpleNodeAppearance(n)),typeof t.safetyField=="number"&&(n.userData.safetyField=t.safetyField),typeof t.x=="number"&&(n.position.x=t.x),typeof t.y=="number"&&(n.position.y=t.y),typeof t.z=="number"&&(n.position.z=t.z),typeof t.rx=="number"&&(n.rotation.x=t.rx*Math.PI/180),typeof t.ry=="number"&&(n.rotation.y=t.ry*Math.PI/180),typeof t.rz=="number"&&(n.rotation.z=t.rz*Math.PI/180),this.emitSelectionTransformChanged(n),this.emitTopologyChanged("node-updated"))};handleNodeTypeChange=({nodeId:e,type:t})=>{const n=this.editor.selectionManager.getSelectedObjects().find(h=>h.uuid===e);if(!n||n.userData.type===t)return;const i=this.getTopologyNodeId(n);if(!i)return;const s=[...this.editor.selectionManager.getSelectedObjects()],a=this.getSelectedLinkIds(),o=this.editor.selectionManager.getFocusedLinkId(),l=this.getRelatedTopologyLinks(i),c=this.createReplacementNode(n,i,t);if(!c)return;this.replaceNodeMesh(n,c),this.refreshRelatedArrows(l),this.restoreLinkSelection(a,o);const d=s.map(h=>h===n?c:h);this.emitNodeTypeChanged(s,d)};createReplacementNode(e,t,n){const i=Array.isArray(e.userData.features)?e.userData.features.filter(s=>typeof s=="string"&&(n==="ALIGN"||s!=="APRIL"&&s!=="ARUCO")):[];return this.addNode(n,{x:e.position.x,y:e.position.y,z:e.position.z,rx:e.rotation.x,ry:e.rotation.y,rz:e.rotation.z},{name:e.name,id:t,context:typeof e.userData.context=="string"?e.userData.context:"",features:i,safetyField:typeof e.userData.safetyField=="number"?e.userData.safetyField:0})}replaceNodeMesh(e,t){this.editor.selectionManager.unregisterSelectable(t),this.editor.selectionManager.replaceSelectable(e,t),this.editor.selectionManager.replaceSelected(e,t);const n=e.children.find(i=>i instanceof Hs);e.removeFromParent(),e.traverse(i=>{i instanceof Hs&&i.element.parentNode&&i.element.parentNode.removeChild(i.element)}),e.clear(),n&&this.editor.eventHandler.eventBus.emit("node-manager:label-removed",n)}refreshRelatedArrows(e){for(const t of e)this.removeArrow(t),this.renderTopologyLink(t)}restoreLinkSelection(e,t){const n=e.map(i=>this.topologyLinks.find(s=>s.id===i)).filter(i=>!!i).map(i=>this.arrowMap.get(this.getArrowKey(i.from,i.to))).filter(i=>!!i);this.editor.selectionManager.setSelectedLinks(n),this.editor.selectionManager.setFocusedLinkId(t)}emitNodeTypeChanged(e,t){this.editor.eventHandler.eventBus.emit("selector:object-selected",{object:t[t.length-1]??null,prevSelected:e,selectedObjects:t,action:"select"}),this.editor.eventHandler.eventBus.emit("topology:nodes-updated",this.editor.selectionManager.getSelectableObjects()),this.editor.eventHandler.eventBus.emit("node-manager:topo-updated"),this.emitTopologyChanged("node-type-changed")}emitSelectionTransformChanged(e){const t=bt.radToDeg(e.rotation.z);this.editor.eventHandler.eventBus.emit("node-manager:selection-transform-changed",{x:e.position.x.toString().slice(0,6),y:e.position.y.toString().slice(0,6),z:e.position.z.toString().slice(0,6),rz:t.toString().slice(0,6)})}handleNodesTransformDeltaRequested=({target:e,value:t})=>{this.transformNodes(e,t)};handleNodesTransformAbsoluteRequested=({target:e,value:t})=>{this.transformNodesByInput(e,String(t))};handleDeleteNodes=()=>{const e=[...this.editor.selectionManager.getSelectedObjects()];e.length!==0&&(e.forEach(t=>{this.editor.removeObject(t)}),this.emitTopologyChanged("node-deleted"))};handleLinkUpdated=({linkId:e,updates:t})=>{const n=this.topologyLinks.find(a=>a.id===e);if(!n)return;const i={...n,...t};this.topologyLinks=this.topologyLinks.map(a=>a.id===e?i:a);const s=this.getArrowNodes(i);if(s){const a=this.buildArrowSpec(i,s.from,s.to);a?this.upsertArrow(i,a,s.from,s.to):this.removeArrow(i)}this.editor.eventHandler.eventBus.emit("node-manager:topo-updated"),this.emitTopologyChanged("link-updated")};handleLinkDeleted=({linkId:e})=>{const t=this.topologyLinks.find(n=>n.id===e);t&&(this.removeArrow(t),this.topologyLinks=this.topologyLinks.filter(n=>n.id!==e),this.editor.eventHandler.eventBus.emit("node-manager:topo-updated"),this.emitTopologyChanged("link-deleted"))};handleLinkFocused=({linkId:e})=>{this.focusActiveTopologyLink(e)};handleLinkVisibilityFilterRequested=({filter:e})=>{this.linkVisibilityFilter=e,this.applyArrowVisibilityFilter()};handleNodeRenderModeRequested=e=>{this.nodeRenderMode!==e&&(this.nodeRenderMode=e,this.applyNodeRenderModeToAllNodes())};handleLinkSelected=({linkIds:e})=>{this.focusTopologyLinks(e)};handleZoneSelected=({zoneIds:e})=>{this.focusTopologyZones(e)};handleSelectionTransformChanged=()=>{this.updateArrows()};handleZoneTranslationCommitted=({zoneId:e,delta:t})=>{this.moveTopologyZone(e,new I(t.x,t.y,0))}}const _C=.07,wC=.03,SC=2,MC=24;class TC{editor;globalPath;globalPathMap;localPath;constructor(e){this.editor=e,this.globalPathMap=new Map;const t=new js,n=new To({color:16711680,linewidth:_C,vertexColors:!1,worldUnits:!0,dashed:!1});this.globalPath=new fo(t,n),this.globalPath.position.set(0,0,.15),this.globalPath.renderOrder=mn.PATH,this.globalPath.visible=!1;const i=new js,s=new To({color:16766282,linewidth:wC,vertexColors:!1,worldUnits:!0,dashed:!0,dashSize:SC,dashScale:MC});this.localPath=new fo(i,s),this.localPath.position.set(0,0,.2),this.localPath.renderOrder=mn.PATH,this.localPath.visible=!1}dispose(){this.editor.eventHandler.eventBus.off("node-manager:topo-updated",this.handleTopoUpdated)}registerEventBusHandler(){this.editor.eventHandler.eventBus.on("node-manager:topo-updated",this.handleTopoUpdated)}updateGlobalPath(e){if(this.ensurePathsAddedToScene(),e.length){const t=this.convertDataToPositions(e),n=this.globalPath.geometry,i=new js;i.setPositions(t),i.instanceCount=Math.max(0,t.length/3-1),this.globalPath.geometry=i,n.dispose(),this.globalPath.visible=!0}else this.globalPath.visible=!1}updateLocalPath(e){if(this.ensurePathsAddedToScene(),e.length){const t=this.convertDataToPositions(e),n=this.localPath.geometry,i=new js;i.setPositions(t),i.instanceCount=Math.max(0,t.length/3-1),this.localPath.geometry=i,n.dispose(),this.localPath.computeLineDistances(),this.localPath.visible=!0}else this.localPath.visible=!1}convertDataToPositions(e){const t=new Float32Array(e.length*3);for(let n=0;n<e.length;n++){const[i,s]=e[n],a=n*3;t[a]=i,t[a+1]=s,t[a+2]=0}return t}ensurePathsAddedToScene(){this.editor.scene&&(this.globalPath.parent||(this.globalPath.userData.keep=!0,this.editor.scene.add(this.globalPath)),this.localPath.parent||(this.localPath.userData.keep=!0,this.editor.scene.add(this.localPath)))}handleTopoUpdated=()=>{this.globalPathMap.clear()}}class af{boundary;capacity;points;divided;children;constructor(e,t=20){this.boundary=e,this.capacity=t,this.points=[],this.divided=!1,this.children=[]}dispose(){if(this.divided)for(const e of this.children)e.dispose();this.points=[],this.children=[],this.boundary=null,this.divided=!1}insert(e,t){if(!this.boundary.containsPoint(e))return!1;if(this.points.length<this.capacity)return this.points.push({position:e.clone(),index:t}),!0;this.divided||this.subdivide();for(const n of this.children)if(n.insert(e,t))return!0;return!1}subdivide(){const{min:e,max:t}=this.boundary,n=new I().addVectors(e,t).multiplyScalar(.5);for(let i=0;i<2;i++)for(let s=0;s<2;s++)for(let a=0;a<2;a++){const o=new I(i===0?e.x:n.x,s===0?e.y:n.y,a===0?e.z:n.z),l=new I(i===0?n.x:t.x,s===0?n.y:t.y,a===0?n.z:t.z),c=new Yt(o,l);this.children.push(new af(c,this.capacity))}for(const{position:i,index:s}of this.points)for(const a of this.children)if(a.insert(i,s))break;this.points=[],this.divided=!0}}class of{boundary;capacity;points;divided;children;depth;maxDepth;minSize;constructor(e,t=8,n=0,i=16,s=.001){this.boundary=e.clone(),this.capacity=t,this.points=[],this.divided=!1,this.children=[],this.depth=n,this.maxDepth=i,this.minSize=s}dispose(){for(const e of this.children)e.dispose();this.points.length=0,this.children.length=0,this.divided=!1}insert(e,t){return this.boundary.containsPoint(new me(e.x,e.y))?!this.divided&&(this.points.length<this.capacity||this.shouldStopSubdivide())?(this.points.push({position:e.clone(),index:t}),!0):(this.divided||(this.subdivide(),this.redistributePointsToChildren()),this.insertIntoChild(e,t)):!1}shouldStopSubdivide(){const e=this.boundary.max.x-this.boundary.min.x,t=this.boundary.max.y-this.boundary.min.y;return this.depth>=this.maxDepth||e<=this.minSize||t<=this.minSize}subdivide(){if(this.divided)throw new Error("PointsQuadTree: subdivide called on divided node");const{min:e,max:t}=this.boundary,n=new me((e.x+t.x)/2,(e.y+t.y)/2),i=[new Ws(new me(e.x,e.y),new me(n.x,n.y)),new Ws(new me(n.x,e.y),new me(t.x,n.y)),new Ws(new me(e.x,n.y),new me(n.x,t.y)),new Ws(new me(n.x,n.y),new me(t.x,t.y))];if(this.children=i.map(s=>new of(s,this.capacity,this.depth+1,this.maxDepth,this.minSize)),this.children.length!==4)throw new Error("PointsQuadTree: failed to create 4 child quadrants");this.divided=!0}redistributePointsToChildren(){if(!this.divided||this.children.length!==4)throw new Error("PointsQuadTree: redistribute requires a divided node with 4 children");const e=this.points;this.points=[];for(const{position:t,index:n}of e)this.insertIntoChild(t,n)}insertIntoChild(e,t){if(!this.divided||this.children.length!==4)throw new Error("PointsQuadTree: insertIntoChild called before subdivision");const n=this.getChildIndex(e);if(!this.children[n].insert(e,t))throw new Error(`PointsQuadTree: failed to insert into child(${n}) at (${e.x}, ${e.y})`);return!0}getChildIndex(e){const{min:t,max:n}=this.boundary,i=(t.x+n.x)/2,s=(t.y+n.y)/2,a=e.x>=i,o=e.y>=s;return!a&&!o?0:a&&!o?1:!a&&o?2:3}clear(){this.points=[];for(const e of this.children)e.clear();this.children=[],this.divided=!1}}const Ji=[{r:44/255,g:123/255,b:182/255},{r:171/255,g:217/255,b:233/255},{r:1,g:1,b:191/255},{r:253/255,g:174/255,b:97/255},{r:215/255,g:25/255,b:28/255}],Xm=1024*3,EC=12294903;class AC{editor;pointsOctree=null;pointsQuadTree=null;mappingPoints=null;mappingPointsGeo=null;mappingPointsMat=null;mappingKeyFrame=null;mappingKeyFrameGeo=null;mappingKeyFrameMat=null;mapPoints;mapPointsGeo;mapPointsMat;mapPointsData;mapBoundary=null;showMapBoundary=!1;mapPointHeightClip=null;lidarPoints;lidarPointsGeo;lidarPointsMat;lidarFloat32Array=new Float32Array;lidarPositionAttr;lidar3DPoints;lidar3DPointsGeo;lidar3DPointsMat;lidar3DFloat32Array=new Float32Array;lidar3DPositionAttr;lastLidarSphereUpdateTime={lidar2D:0,lidar3D:0};sphereUpdateInterval=5e3;pendingMappingKeyFrameChunkNum=null;pendingMappingKeyFrameChunks=new Map;constructor(e){this.editor=e}registerEventListeners(){const e=this.editor.eventHandler.eventBus;e.on("lidar:updated",this.handleLidarUpdated),e.on("lidar3d:updated",this.handleLidar3DUpdated),e.on("ui:map-points-update-requested",this.handleMapPointsLoaded),e.on("ui:map-points-height-clip-set-requested",this.handleMapPointHeightClipSetRequested),e.on("ui:typed-map-points-update-requested",this.handleTypedMapPointsLoaded),e.on("ui:mapping-start-requested",this.handleMappingStarted),e.on("ui:mapping-stop-requested",this.handleMappingStopped),e.on("ui:mapping-data-received",this.handleMappingDataReceived),e.on("ui:mapping-keyframe-received",this.handleMappingKeyFrameReceived),e.on("robot-manager:main-robot-loaded",this.handleMainrobotLoaded),e.on("editor:initialized",this.handleEditorInitialized),e.on("ui:lidar-toggled",this.handleLidarToggled),e.on("ui:lidar3d-toggled",this.handleLidar3DToggled),e.on("ui:map-boundary-visibility-set-requested",this.handleMapBoundaryVisibilitySetRequested),e.on("ui:lidar-point-size-set-requested",this.handleLidarPointSizeSetRequested),e.on("ui:map-point-size-set-requested",this.handleMapPointSizeSetRequested)}deregisterEventListeners(){const e=this.editor.eventHandler.eventBus;e.off("lidar:updated",this.handleLidarUpdated),e.off("lidar3d:updated",this.handleLidar3DUpdated),e.off("ui:map-points-update-requested",this.handleMapPointsLoaded),e.off("ui:map-points-height-clip-set-requested",this.handleMapPointHeightClipSetRequested),e.off("ui:typed-map-points-update-requested",this.handleTypedMapPointsLoaded),e.off("ui:mapping-start-requested",this.handleMappingStarted),e.off("ui:mapping-stop-requested",this.handleMappingStopped),e.off("ui:mapping-data-received",this.handleMappingDataReceived),e.off("ui:mapping-keyframe-received",this.handleMappingKeyFrameReceived),e.off("robot-manager:main-robot-loaded",this.handleMainrobotLoaded),e.off("editor:initialized",this.handleEditorInitialized),e.off("ui:lidar-toggled",this.handleLidarToggled),e.off("ui:lidar3d-toggled",this.handleLidar3DToggled),e.off("ui:map-boundary-visibility-set-requested",this.handleMapBoundaryVisibilitySetRequested),e.off("ui:lidar-point-size-set-requested",this.handleLidarPointSizeSetRequested),e.off("ui:map-point-size-set-requested",this.handleMapPointSizeSetRequested)}changeMapPointsOpacity(e){this.mapPointsMat.opacity=e*.01}clearMapPoints(){this.mapPointsGeo.deleteAttribute("position"),this.mapPointsGeo.setAttribute("position",new ke([],3)),this.mapPointsGeo.boundingSphere=null,this.mapPointsGeo.attributes.position.needsUpdate=!0,this.pointsOctree&&(this.pointsOctree.dispose(),this.pointsOctree=null),this.pointsQuadTree&&(this.pointsQuadTree.dispose(),this.pointsQuadTree=null),this.clearMapBoundary(),this.mapPointsData=[],this.editor.eventHandler.eventBus.emit("points-manager:mappoints-updated",{mapBounds:null})}dispose(){this.pointsOctree&&(this.pointsOctree.dispose(),this.pointsOctree=null),this.pointsQuadTree&&(this.pointsQuadTree.dispose(),this.pointsQuadTree=null),this.mapPointsGeo?.dispose(),this.mapPointsMat?.dispose(),this.mapPointsData=null,this.lidarPointsGeo?.dispose(),this.lidar3DPointsGeo?.dispose(),this.lidarPointsMat?.dispose(),this.lidar3DPointsMat?.dispose(),this.mappingPoints&&this.editor.scene.remove(this.mappingPoints),this.mappingKeyFrame&&this.editor.scene.remove(this.mappingKeyFrame),this.lidarPoints&&this.editor.scene.remove(this.lidarPoints),this.lidar3DPoints&&this.editor.scene.remove(this.lidar3DPoints),this.clearMapBoundary(),this.mappingPointsGeo?.dispose(),this.mappingPointsMat?.dispose(),this.mappingKeyFrameGeo?.dispose(),this.mappingKeyFrameMat?.dispose(),this.mappingPointsGeo=null,this.mappingPointsMat=null,this.mappingKeyFrameGeo=null,this.mappingKeyFrameMat=null,this.resetMappingKeyFrameChunks(),this.deregisterEventListeners()}updateMapPoints(e){if(!this.mapPointsGeo)return;const{position:t,numPoints:n}=this.updatePosition(this.mapPointsGeo,e,"reset"),{boundaries:i,mapBounds:s}=this.calculateMapBoundsAndColorBoundaries(t,n);this.updateColors(i),this.finalizeUpdate(),this.createCloudQuadTree(),this.mapPointsData=e,this.updateMapBoundary(s),this.editor.eventHandler.eventBus.emit("points-manager:mappoints-updated",{mapBounds:s})}updateTypedMapPoints(e){if(!this.mapPointsGeo)return;const t=Math.min(Math.max(0,Math.floor(e.pointCount)),Math.floor(e.positions.length/3)),n=t*3,i=e.positions.length===n?e.positions:e.positions.subarray(0,n);this.mapPointsGeo.setAttribute("position",new ke(i,3));const s=t*3,a=e.intensityColors,o=a&&a.length>=s?a:e.colors;if(o&&o.length>=s){const l=o.length===s?o:o.subarray(0,s);this.mapPointsGeo.setAttribute("color",new ke(l,3)),this.mapPointsMat.vertexColors=!0}else this.mapPointsGeo.deleteAttribute("color"),this.mapPointsMat.vertexColors=!1,this.mapPointsMat.color.set(3800852);this.mapPointsMat.needsUpdate=!0,this.finalizeUpdate(e.bounds),this.mapPointsData=[],this.updateMapBoundary(e.bounds),this.editor.eventHandler.eventBus.emit("points-manager:mappoints-updated",{mapBounds:e.bounds})}updateMappingPoints(e){const t=this.mappingPointsGeo;!t||!this.mappingPointsMat||(this.updatePosition(t,e,"append"),t.computeBoundingSphere(),t.attributes.position.needsUpdate=!0)}updateMappingKeyFrame(e){const t=this.mappingKeyFrameGeo;!t||!this.mappingKeyFrameMat||(this.updatePosition(t,e,"append"),t.computeBoundingSphere(),t.attributes.position.needsUpdate=!0)}flattenMapPoints(){if(!this.mapPointsGeo)return;const e=this.mapPointsGeo.getAttribute("position");if(!e||!e.array.length){console.warn("[Flatten Map Points] No position attribute found in geometry.");return}for(let t=0;t<e.count;t++)e.setZ(t,0);this.finalizeUpdate()}restoreMapPointsDepth(){if(!this.mapPointsGeo)return;if(!this.mapPointsData){console.warn("Original map points data is missing.");return}const e=this.mapPointsGeo.getAttribute("position");if(!e||!e.array.length){console.warn("[Restore Map Points] Position attribute not found in geometry.");return}for(let t=0;t<this.mapPointsData.length;t++){const n=this.mapPointsData[t];e.setZ(t,n[2])}this.finalizeUpdate()}setMapPointHeightClip(e){e?this.mapPointHeightClip={minZ:Math.min(e.minZ,e.maxZ),maxZ:Math.max(e.minZ,e.maxZ)}:this.mapPointHeightClip=null,this.applyMapPointHeightClip()}calculateMapBoundsAndColorBoundaries(e,t){if(t===0)return{mapBounds:null,boundaries:null};let n=1/0,i=1/0,s=1/0,a=-1/0,o=-1/0,l=-1/0;for(let u=0;u<t;u++){const f=e[u*3],m=e[u*3+1],b=e[u*3+2];f<n&&(n=f),f>a&&(a=f),m<i&&(i=m),m>o&&(o=m),b<s&&(s=b),b>l&&(l=b)}const c={minX:n,minY:i,minZ:s,maxX:a,maxY:o,maxZ:l};if(s===l)return{mapBounds:c,boundaries:null};const d=l-s,h=[s,s+d*.2,s+d*.4,s+d*.6,s+d*.8,l];return{mapBounds:c,boundaries:h}}applyMapPointHeightClip(){if(!this.mapPointsMat)return;const{mapPointHeightClip:e}=this;this.mapPointsMat.clippingPlanes=e?[new ns(new I(0,0,1),-e.minZ),new ns(new I(0,0,-1),e.maxZ)]:[],this.mapPointsMat.needsUpdate=!0}createCloudOctree(){const e=this.mapPointsGeo.getAttribute("position"),t=new Yt().setFromBufferAttribute(e);t.expandByScalar(1);const n=new af(t,20);for(let i=0;i<e.count;i++){const s=new I().fromBufferAttribute(e,i);n.insert(s,i)}this.pointsOctree=n}createCloudQuadTree(){const e=this.mapPointsGeo.getAttribute("position"),t=new Yt().setFromBufferAttribute(e),n=new Ws(new me(t.min.x,t.min.y),new me(t.max.x,t.max.y));n.expandByScalar(1);const i=new of(n,20);try{for(let s=0;s<e.count;s++){const a=new I().fromBufferAttribute(e,s);i.insert(a,s)}}catch(s){console.error("PointsQuadTree: Insert error:",s)}this.pointsQuadTree=i}ensureCapacity(e){const t=this.lidarPositionAttr.array;if(e>t.length){const n=Math.max(e,t.length*2),i=new Float32Array(n);i.set(t);const s=new ke(i,3);s.setUsage(qo),this.lidarPositionAttr=s,this.lidarPointsGeo.setAttribute("position",s)}}ensureLidar3DCapacity(e){const t=this.lidar3DPositionAttr.array;if(e>t.length){const n=Math.max(e,t.length*2),i=new ke(new Float32Array(n),3);i.setUsage(qo),this.lidar3DPositionAttr=i,this.lidar3DPointsGeo.setAttribute("position",i)}}finalizeUpdate(e){if(this.mapPointsGeo.attributes.position.needsUpdate=!0,!e){this.mapPointsGeo.computeBoundingSphere();return}const t=new I((e.minX+e.maxX)/2,(e.minY+e.maxY)/2,(e.minZ+e.maxZ)/2),n=Math.hypot(e.maxX-e.minX,e.maxY-e.minY,e.maxZ-e.minZ)/2;this.mapPointsGeo.boundingSphere=new vn(t,n)}clearPointsGeometry(e){e.deleteAttribute("position"),e.setAttribute("position",new ke([],3)),e.boundingSphere=null,e.attributes.position.needsUpdate=!0}clearMapBoundary(){this.mapBoundary&&(this.editor.scene.remove(this.mapBoundary),this.mapBoundary.geometry.dispose(),Array.isArray(this.mapBoundary.material)?this.mapBoundary.material.forEach(e=>e.dispose()):this.mapBoundary.material.dispose(),this.mapBoundary=null)}updateMapBoundary(e){if(this.clearMapBoundary(),!e)return;const t=Math.max(e.maxZ,0)+.02,n=new Float32Array([e.minX,e.minY,t,e.maxX,e.minY,t,e.maxX,e.minY,t,e.maxX,e.maxY,t,e.maxX,e.maxY,t,e.minX,e.maxY,t,e.minX,e.maxY,t,e.minX,e.minY,t]),i=new ht;i.setAttribute("position",new rn(n,3));const s=new zn({color:Yb,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.95});this.mapBoundary=new Ks(i,s),this.mapBoundary.renderOrder=mn.PATH,this.mapBoundary.visible=this.showMapBoundary,this.mapBoundary.userData.keep=!0,this.editor.scene.add(this.mapBoundary)}handleLidarUpdated=e=>{const t=this.lidarPointsToFloatArray(e.lidarPoints);this.ensureCapacity(t.length),this.lidarPositionAttr.array.set(t),this.lidarPointsGeo.setAttribute("position",this.lidarPositionAttr);const n=t.length/3;this.lidarPointsGeo.setDrawRange(0,n),this.lidarPointsGeo.attributes.position.needsUpdate=!0,this.shouldUpdateSphere("lidar2D")&&this.lidarPointsGeo.computeBoundingSphere()};handleLidar3DUpdated=e=>{const t=this.lidar3DPointsToFloatArray(e.lidarPoints);this.ensureLidar3DCapacity(t.length),this.lidar3DPositionAttr.array.set(t),this.lidar3DPointsGeo.setDrawRange(0,t.length/3),this.lidar3DPositionAttr.needsUpdate=!0,this.shouldUpdateSphere("lidar3D")&&this.lidar3DPointsGeo.computeBoundingSphere()};handleLidarToggled=e=>{this.lidarPoints.visible=e};handleLidar3DToggled=e=>{this.lidar3DPoints.visible=e};handleMapBoundaryVisibilitySetRequested=e=>{this.showMapBoundary=e,this.mapBoundary&&(this.mapBoundary.visible=e)};handleLidarPointSizeSetRequested=e=>{this.lidarPointsMat.size=e,this.lidarPointsMat.needsUpdate=!0,this.lidar3DPointsMat.size=e,this.lidar3DPointsMat.needsUpdate=!0};handleMapPointSizeSetRequested=e=>{this.mapPointsMat.size=e,this.mapPointsMat.needsUpdate=!0};shouldUpdateSphere(e){const t=performance.now(),n=this.lastLidarSphereUpdateTime[e];return t-n>this.sphereUpdateInterval||n===0?(this.lastLidarSphereUpdateTime[e]=t,!0):!1}handleMappingKeyFrameReceived=e=>{const t=this.mappingKeyFrameGeo,n=this.mappingPointsGeo;if(!e||!t||!n)return;const{data:i,chunkNum:s,chunkId:a}=e;if(s<=0||a<0||a>=s||((a===0||this.pendingMappingKeyFrameChunkNum!==s)&&(this.resetMappingKeyFrameChunks(),this.pendingMappingKeyFrameChunkNum=s),this.pendingMappingKeyFrameChunks.set(a,i),this.pendingMappingKeyFrameChunks.size!==s))return;const o=[];for(let l=0;l<s;l++){const c=this.pendingMappingKeyFrameChunks.get(l);if(!c)return;for(const d of c)o.push(d)}this.updateMappingKeyFrame(o),this.clearPointsGeometry(n),this.resetMappingKeyFrameChunks()};updateColors(e){const t=this.mapPointsGeo,n=t.getAttribute("position"),i=n.count,s=n.array;let a=t.getAttribute("color");if((!a||a.count!==i)&&(a=new ke(new Float32Array(i*3),3),t.setAttribute("color",a)),!e){const o=.2235294117647059,l=255/255,c=20/255;for(let d=0;d<i;d++)a.setXYZ(d,o,l,c);a.needsUpdate=!0;return}for(let o=0;o<i;o++){const l=s[o*3+2];let c,d,h,u;l<e[1]?(c=Ji[0],d=Ji[1],h=e[0],u=e[1]):l<e[2]?(c=Ji[1],d=Ji[2],h=e[1],u=e[2]):l<e[3]?(c=Ji[2],d=Ji[3],h=e[2],u=e[3]):l<e[4]?(c=Ji[3],d=Ji[4],h=e[3],u=e[4]):(c=Ji[4],d=Ji[4],h=e[4],u=e[5]);const f=u-h||1;let m=(l-h)/f;m=Math.max(0,Math.min(1,m));const b=c.r*(1-m)+d.r*m,p=c.g*(1-m)+d.g*m,g=c.b*(1-m)+d.b*m;a.setXYZ(o,b,p,g)}a.needsUpdate=!0}updatePosition(e,t,n="reset"){const i=new Float32Array(t.length*3);for(let o=0,l=0;o<t.length;o++,l+=3){const[c,d,h]=t[o];i[l]=c,i[l+1]=d,i[l+2]=h}let s;if(n==="reset")s=i;else{const l=e.getAttribute("position")?.array,c=l?.length??0;s=new Float32Array(c+i.length),l&&s.set(l,0),s.set(i,c)}const a=new ke(s,3);return e.setAttribute("position",a),{position:s,numPoints:s.length/3}}handleMapPointsLoaded=e=>{this.updateMapPoints(e)};handleMapPointHeightClipSetRequested=e=>{this.setMapPointHeightClip(e)};handleTypedMapPointsLoaded=e=>{this.updateTypedMapPoints(e)};handleMappingStarted=()=>{this.handleMappingStopped(),this.resetMappingKeyFrameChunks(),this.mapPoints.visible=!1,this.mappingPointsGeo=new ht,this.mappingPointsGeo.setAttribute("position",new ke([],3)),this.mappingPointsMat=new mr({size:.2,color:8245247}),this.mappingPoints=new sa(this.mappingPointsGeo,this.mappingPointsMat),this.mappingPoints.renderOrder=mn.MAPPING_POINTS,this.mappingPoints.userData.keep=!0,this.editor.scene.add(this.mappingPoints),this.mappingKeyFrameGeo=new ht,this.mappingKeyFrameGeo.setAttribute("position",new ke([],3)),this.mappingKeyFrameMat=new mr({size:.2,color:2450411}),this.mappingKeyFrame=new sa(this.mappingKeyFrameGeo,this.mappingKeyFrameMat),this.mappingKeyFrame.renderOrder=mn.MAP_POINTS,this.mappingKeyFrame.userData.keep=!0,this.editor.scene.add(this.mappingKeyFrame)};handleMappingStopped=()=>{this.mapPoints.visible=!0,this.resetMappingKeyFrameChunks(),this.mappingPoints&&this.editor.scene.remove(this.mappingPoints),this.mappingKeyFrame&&this.editor.scene.remove(this.mappingKeyFrame),this.mappingPointsGeo?.dispose(),this.mappingPointsMat?.dispose(),this.mappingKeyFrameGeo?.dispose(),this.mappingKeyFrameMat?.dispose(),this.mappingPoints=null,this.mappingKeyFrame=null,this.mappingPointsGeo=null,this.mappingPointsMat=null,this.mappingKeyFrameGeo=null,this.mappingKeyFrameMat=null};resetMappingRecovery=()=>{this.resetMappingKeyFrameChunks(),this.mappingPointsGeo&&this.clearPointsGeometry(this.mappingPointsGeo),this.mappingKeyFrameGeo&&this.clearPointsGeometry(this.mappingKeyFrameGeo)};handleMappingDataReceived=e=>{this.updateMappingPoints(e)};handleMainrobotLoaded=()=>{this.editor.robotManager.mainRobot&&this.editor.scene.add(this.lidarPoints)};lidarPointsToFloatArray=e=>{const t=e.length*3;this.lidarFloat32Array.length<t&&(this.lidarFloat32Array=new Float32Array(t*2));for(let n=0,i=0;n<e.length;n++,i+=3){const[s,a,o]=e[n];this.lidarFloat32Array[i]=+s,this.lidarFloat32Array[i+1]=+a,this.lidarFloat32Array[i+2]=+o}return this.lidarFloat32Array.subarray(0,t)};lidar3DPointsToFloatArray=e=>{const t=e.length*3;this.lidar3DFloat32Array.length<t&&(this.lidar3DFloat32Array=new Float32Array(t*2));for(let n=0,i=0;n<e.length;n++,i+=3){const[s,a,o]=e[n];this.lidar3DFloat32Array[i]=+s,this.lidar3DFloat32Array[i+1]=+a,this.lidar3DFloat32Array[i+2]=+o}return this.lidar3DFloat32Array.subarray(0,t)};handleEditorInitialized=()=>{this.mapPointsGeo=new ht,this.mapPointsGeo.setAttribute("position",new ke([],3)),this.mapPointsMat=new mr({size:Kb,vertexColors:!0,transparent:!0,opacity:1,depthWrite:!1}),this.mapPoints=new sa(this.mapPointsGeo,this.mapPointsMat),this.mapPoints.renderOrder=mn.MAP_POINTS,this.mapPoints.userData.keep=!0,this.editor.scene.add(this.mapPoints),this.applyMapPointHeightClip(),this.mapPointsData=[],this.lidarPointsGeo=new ht,this.lidarPointsMat=new mr({size:_u,color:16725342,transparent:!0,depthWrite:!1}),this.lidarPoints=new sa(this.lidarPointsGeo,this.lidarPointsMat),this.lidarPoints.renderOrder=mn.LIDAR_POINTS,this.lidarPoints.userData.keep=!0,this.lidarPositionAttr=new ke(new Float32Array(Xm),3),this.lidarPositionAttr.setUsage(qo),this.lidarPointsGeo.setAttribute("position",this.lidarPositionAttr),this.lidarPointsGeo.setDrawRange(0,0),this.lidar3DPointsGeo=new ht,this.lidar3DPointsMat=new mr({size:_u,color:EC,transparent:!0,depthTest:!0,depthWrite:!1}),this.lidar3DPoints=new sa(this.lidar3DPointsGeo,this.lidar3DPointsMat),this.lidar3DPoints.renderOrder=mn.LIDAR_3D_POINTS,this.lidar3DPoints.userData.keep=!0,this.editor.scene.add(this.lidar3DPoints),this.lidar3DPositionAttr=new ke(new Float32Array(Xm),3),this.lidar3DPositionAttr.setUsage(qo),this.lidar3DPointsGeo.setAttribute("position",this.lidar3DPositionAttr),this.lidar3DPointsGeo.setDrawRange(0,0)};resetMappingKeyFrameChunks=()=>{this.pendingMappingKeyFrameChunkNum=null,this.pendingMappingKeyFrameChunks.clear()}}class lf{constructor(e=120){this.cap=e}buf=[];push(e){this.buf.push(e),this.buf.length>this.cap&&this.buf.shift()}bracket(e){let t,n;for(let i=this.buf.length-1;i>=0;--i)if(this.buf[i].t<=e){t=this.buf[i],n=this.buf[i+1];break}return[t,n]}sampleTransform(e){const[t,n]=this.bracket(e),i=t,s=n;if(!i)return null;if(!s)return{...i,t:e};const a=(e-t.t)/(n.t-t.t||1e-6);return{t:e,x:this.lerpNum(i.x,s.x,a),y:this.lerpNum(i.y,s.y,a),rz:this.lerpAngleDeg(i.rz,s.rz,a)}}sampleJoint(e){const[t,n]=this.bracket(e),i=t,s=n;if(!i)return null;if(!s)return{...i,t:e};const a=(e-i.t)/(s.t-i.t||1e-6);return{t:e,map:this.lerpMap(i.map,s.map,a)}}lerpNum(e,t,n){return e+(t-e)*n}lerpAngleDeg(e,t,n){const i=(t-e+540)%360-180;return e+i*n}lerpMap(e,t,n){const i={};for(const s in t){const a=e?e[s]??t[s]:t[s];i[s]=this.lerpNum(a,t[s],n)}return i}}class Qs extends Vt{transformBuf=new lf;tmpTransform=new I;clock=new Qu;ROT_DAMP_RATE=5;jointBuf;constructor(){super()}pushTransformSnapshot(e){this.transformBuf.push(e)}pushJointsSnapshot(e,t=performance.now()/1e3){this.jointBuf&&this.jointBuf.push({t,map:e})}tick(e){const t=this.transformBuf.sampleTransform(e);if(t){this.tmpTransform.set(t.x,t.y,0),this.position.lerp(this.tmpTransform,.15);const n=this.clock.getDelta(),i=bt.degToRad(t.rz),s=bt.euclideanModulo(i-this.rotation.z+Math.PI,2*Math.PI)-Math.PI;this.rotation.z+=s*bt.damp(0,1,this.ROT_DAMP_RATE,n)}if(this.jointBuf){const n=this.jointBuf.sampleJoint(e);n&&this.applyJointValues?.(n.map)}}alignToGroundZUp(e,t){const{centerXY:n=!1}=t||{};e.updateMatrixWorld(!0);const i=new Yt().setFromObject(e),s=-i.min.z;if(e.position.z+=s,n){const a=new I;i.getCenter(a),e.position.x-=a.x,e.position.y-=a.y}e.updateMatrixWorld(!0)}}class cf extends Qs{static async create(){const e=new cf;return await e._initAsync(),e}constructor(){super(),this.name="RB-S100",this.userData.keep=!0}async _initAsync(){const e=new Ar,t=Hn(As.S100.modelUrl);try{const i=(await e.loadAsync(t)).scene;i.traverse(s=>{s.userData.keep=!0}),i.renderOrder=mn.ROBOT,i.updateMatrixWorld(!0),this.add(i)}catch(n){n instanceof Error?console.error("RB-S100 Load Failed:",n.message):console.error("RB-S100 Load Failed:",n)}}update(e){this.position.set(Number(e.x),Number(e.y),0),this.rotation.z=bt.degToRad(Number(e.rz))}applyPose(e){if(!e)return;const t={t:performance.now()*.001,x:e.x,y:e.y,rz:e.rz};this.pushTransformSnapshot(t)}}var mc={exports:{}};/* @license
|
|
4393
4393
|
Papa Parse
|
|
4394
4394
|
v5.5.3
|
|
4395
4395
|
https://github.com/mholt/PapaParse
|
|
4396
4396
|
License: MIT
|
|
4397
|
-
*/var CC=mc.exports,qm;function PC(){return qm||(qm=1,(function(r,e){((t,n)=>{r.exports=n()})(CC,function t(){var n=typeof self<"u"?self:typeof window<"u"?window:n!==void 0?n:{},i,s=!n.document&&!!n.postMessage,a=n.IS_PAPA_WORKER||!1,o={},l=0,c={};function d(M){this._handle=null,this._finished=!1,this._completed=!1,this._halted=!1,this._input=null,this._baseIndex=0,this._partialLine="",this._rowCount=0,this._start=0,this._nextChunk=null,this.isFirstChunk=!0,this._completeResults={data:[],errors:[],meta:{}},function(_){var S=P(_);S.chunkSize=parseInt(S.chunkSize),_.step||_.chunk||(S.chunkSize=null),this._handle=new b(S),(this._handle.streamer=this)._config=S}.call(this,M),this.parseChunk=function(_,S){var R=parseInt(this._config.skipFirstNLines)||0;if(this.isFirstChunk&&0<R){let O=this._config.newline;O||(k=this._config.quoteChar||'"',O=this._handle.guessLineEndings(_,k)),_=[..._.split(O).slice(R)].join(O)}this.isFirstChunk&&A(this._config.beforeFirstChunk)&&(k=this._config.beforeFirstChunk(_))!==void 0&&(_=k),this.isFirstChunk=!1,this._halted=!1;var R=this._partialLine+_,k=(this._partialLine="",this._handle.parse(R,this._baseIndex,!this._finished));if(!this._handle.paused()&&!this._handle.aborted()){if(_=k.meta.cursor,R=(this._finished||(this._partialLine=R.substring(_-this._baseIndex),this._baseIndex=_),k&&k.data&&(this._rowCount+=k.data.length),this._finished||this._config.preview&&this._rowCount>=this._config.preview),a)n.postMessage({results:k,workerId:c.WORKER_ID,finished:R});else if(A(this._config.chunk)&&!S){if(this._config.chunk(k,this._handle),this._handle.paused()||this._handle.aborted())return void(this._halted=!0);this._completeResults=k=void 0}return this._config.step||this._config.chunk||(this._completeResults.data=this._completeResults.data.concat(k.data),this._completeResults.errors=this._completeResults.errors.concat(k.errors),this._completeResults.meta=k.meta),this._completed||!R||!A(this._config.complete)||k&&k.meta.aborted||(this._config.complete(this._completeResults,this._input),this._completed=!0),R||k&&k.meta.paused||this._nextChunk(),k}this._halted=!0},this._sendError=function(_){A(this._config.error)?this._config.error(_):a&&this._config.error&&n.postMessage({workerId:c.WORKER_ID,error:_,finished:!1})}}function h(M){var _;(M=M||{}).chunkSize||(M.chunkSize=c.RemoteChunkSize),d.call(this,M),this._nextChunk=s?function(){this._readChunk(),this._chunkLoaded()}:function(){this._readChunk()},this.stream=function(S){this._input=S,this._nextChunk()},this._readChunk=function(){if(this._finished)this._chunkLoaded();else{if(_=new XMLHttpRequest,this._config.withCredentials&&(_.withCredentials=this._config.withCredentials),s||(_.onload=T(this._chunkLoaded,this),_.onerror=T(this._chunkError,this)),_.open(this._config.downloadRequestBody?"POST":"GET",this._input,!s),this._config.downloadRequestHeaders){var S,R=this._config.downloadRequestHeaders;for(S in R)_.setRequestHeader(S,R[S])}var k;this._config.chunkSize&&(k=this._start+this._config.chunkSize-1,_.setRequestHeader("Range","bytes="+this._start+"-"+k));try{_.send(this._config.downloadRequestBody)}catch(O){this._chunkError(O.message)}s&&_.status===0&&this._chunkError()}},this._chunkLoaded=function(){_.readyState===4&&(_.status<200||400<=_.status?this._chunkError():(this._start+=this._config.chunkSize||_.responseText.length,this._finished=!this._config.chunkSize||this._start>=(S=>(S=S.getResponseHeader("Content-Range"))!==null?parseInt(S.substring(S.lastIndexOf("/")+1)):-1)(_),this.parseChunk(_.responseText)))},this._chunkError=function(S){S=_.statusText||S,this._sendError(new Error(S))}}function u(M){(M=M||{}).chunkSize||(M.chunkSize=c.LocalChunkSize),d.call(this,M);var _,S,R=typeof FileReader<"u";this.stream=function(k){this._input=k,S=k.slice||k.webkitSlice||k.mozSlice,R?((_=new FileReader).onload=T(this._chunkLoaded,this),_.onerror=T(this._chunkError,this)):_=new FileReaderSync,this._nextChunk()},this._nextChunk=function(){this._finished||this._config.preview&&!(this._rowCount<this._config.preview)||this._readChunk()},this._readChunk=function(){var k=this._input,O=(this._config.chunkSize&&(O=Math.min(this._start+this._config.chunkSize,this._input.size),k=S.call(k,this._start,O)),_.readAsText(k,this._config.encoding));R||this._chunkLoaded({target:{result:O}})},this._chunkLoaded=function(k){this._start+=this._config.chunkSize,this._finished=!this._config.chunkSize||this._start>=this._input.size,this.parseChunk(k.target.result)},this._chunkError=function(){this._sendError(_.error)}}function f(M){var _;d.call(this,M=M||{}),this.stream=function(S){return _=S,this._nextChunk()},this._nextChunk=function(){var S,R;if(!this._finished)return S=this._config.chunkSize,_=S?(R=_.substring(0,S),_.substring(S)):(R=_,""),this._finished=!_,this.parseChunk(R)}}function m(M){d.call(this,M=M||{});var _=[],S=!0,R=!1;this.pause=function(){d.prototype.pause.apply(this,arguments),this._input.pause()},this.resume=function(){d.prototype.resume.apply(this,arguments),this._input.resume()},this.stream=function(k){this._input=k,this._input.on("data",this._streamData),this._input.on("end",this._streamEnd),this._input.on("error",this._streamError)},this._checkIsFinished=function(){R&&_.length===1&&(this._finished=!0)},this._nextChunk=function(){this._checkIsFinished(),_.length?this.parseChunk(_.shift()):S=!0},this._streamData=T(function(k){try{_.push(typeof k=="string"?k:k.toString(this._config.encoding)),S&&(S=!1,this._checkIsFinished(),this.parseChunk(_.shift()))}catch(O){this._streamError(O)}},this),this._streamError=T(function(k){this._streamCleanUp(),this._sendError(k)},this),this._streamEnd=T(function(){this._streamCleanUp(),R=!0,this._streamData("")},this),this._streamCleanUp=T(function(){this._input.removeListener("data",this._streamData),this._input.removeListener("end",this._streamEnd),this._input.removeListener("error",this._streamError)},this)}function b(M){var _,S,R,k,O=Math.pow(2,53),H=-O,q=/^\s*-?(\d+\.?|\.\d+|\d+\.\d+)([eE][-+]?\d+)?\s*$/,G=/^((\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z)))$/,K=this,V=0,
|
|
4397
|
+
*/var CC=mc.exports,qm;function PC(){return qm||(qm=1,(function(r,e){((t,n)=>{r.exports=n()})(CC,function t(){var n=typeof self<"u"?self:typeof window<"u"?window:n!==void 0?n:{},i,s=!n.document&&!!n.postMessage,a=n.IS_PAPA_WORKER||!1,o={},l=0,c={};function d(M){this._handle=null,this._finished=!1,this._completed=!1,this._halted=!1,this._input=null,this._baseIndex=0,this._partialLine="",this._rowCount=0,this._start=0,this._nextChunk=null,this.isFirstChunk=!0,this._completeResults={data:[],errors:[],meta:{}},function(_){var S=P(_);S.chunkSize=parseInt(S.chunkSize),_.step||_.chunk||(S.chunkSize=null),this._handle=new b(S),(this._handle.streamer=this)._config=S}.call(this,M),this.parseChunk=function(_,S){var R=parseInt(this._config.skipFirstNLines)||0;if(this.isFirstChunk&&0<R){let O=this._config.newline;O||(k=this._config.quoteChar||'"',O=this._handle.guessLineEndings(_,k)),_=[..._.split(O).slice(R)].join(O)}this.isFirstChunk&&A(this._config.beforeFirstChunk)&&(k=this._config.beforeFirstChunk(_))!==void 0&&(_=k),this.isFirstChunk=!1,this._halted=!1;var R=this._partialLine+_,k=(this._partialLine="",this._handle.parse(R,this._baseIndex,!this._finished));if(!this._handle.paused()&&!this._handle.aborted()){if(_=k.meta.cursor,R=(this._finished||(this._partialLine=R.substring(_-this._baseIndex),this._baseIndex=_),k&&k.data&&(this._rowCount+=k.data.length),this._finished||this._config.preview&&this._rowCount>=this._config.preview),a)n.postMessage({results:k,workerId:c.WORKER_ID,finished:R});else if(A(this._config.chunk)&&!S){if(this._config.chunk(k,this._handle),this._handle.paused()||this._handle.aborted())return void(this._halted=!0);this._completeResults=k=void 0}return this._config.step||this._config.chunk||(this._completeResults.data=this._completeResults.data.concat(k.data),this._completeResults.errors=this._completeResults.errors.concat(k.errors),this._completeResults.meta=k.meta),this._completed||!R||!A(this._config.complete)||k&&k.meta.aborted||(this._config.complete(this._completeResults,this._input),this._completed=!0),R||k&&k.meta.paused||this._nextChunk(),k}this._halted=!0},this._sendError=function(_){A(this._config.error)?this._config.error(_):a&&this._config.error&&n.postMessage({workerId:c.WORKER_ID,error:_,finished:!1})}}function h(M){var _;(M=M||{}).chunkSize||(M.chunkSize=c.RemoteChunkSize),d.call(this,M),this._nextChunk=s?function(){this._readChunk(),this._chunkLoaded()}:function(){this._readChunk()},this.stream=function(S){this._input=S,this._nextChunk()},this._readChunk=function(){if(this._finished)this._chunkLoaded();else{if(_=new XMLHttpRequest,this._config.withCredentials&&(_.withCredentials=this._config.withCredentials),s||(_.onload=T(this._chunkLoaded,this),_.onerror=T(this._chunkError,this)),_.open(this._config.downloadRequestBody?"POST":"GET",this._input,!s),this._config.downloadRequestHeaders){var S,R=this._config.downloadRequestHeaders;for(S in R)_.setRequestHeader(S,R[S])}var k;this._config.chunkSize&&(k=this._start+this._config.chunkSize-1,_.setRequestHeader("Range","bytes="+this._start+"-"+k));try{_.send(this._config.downloadRequestBody)}catch(O){this._chunkError(O.message)}s&&_.status===0&&this._chunkError()}},this._chunkLoaded=function(){_.readyState===4&&(_.status<200||400<=_.status?this._chunkError():(this._start+=this._config.chunkSize||_.responseText.length,this._finished=!this._config.chunkSize||this._start>=(S=>(S=S.getResponseHeader("Content-Range"))!==null?parseInt(S.substring(S.lastIndexOf("/")+1)):-1)(_),this.parseChunk(_.responseText)))},this._chunkError=function(S){S=_.statusText||S,this._sendError(new Error(S))}}function u(M){(M=M||{}).chunkSize||(M.chunkSize=c.LocalChunkSize),d.call(this,M);var _,S,R=typeof FileReader<"u";this.stream=function(k){this._input=k,S=k.slice||k.webkitSlice||k.mozSlice,R?((_=new FileReader).onload=T(this._chunkLoaded,this),_.onerror=T(this._chunkError,this)):_=new FileReaderSync,this._nextChunk()},this._nextChunk=function(){this._finished||this._config.preview&&!(this._rowCount<this._config.preview)||this._readChunk()},this._readChunk=function(){var k=this._input,O=(this._config.chunkSize&&(O=Math.min(this._start+this._config.chunkSize,this._input.size),k=S.call(k,this._start,O)),_.readAsText(k,this._config.encoding));R||this._chunkLoaded({target:{result:O}})},this._chunkLoaded=function(k){this._start+=this._config.chunkSize,this._finished=!this._config.chunkSize||this._start>=this._input.size,this.parseChunk(k.target.result)},this._chunkError=function(){this._sendError(_.error)}}function f(M){var _;d.call(this,M=M||{}),this.stream=function(S){return _=S,this._nextChunk()},this._nextChunk=function(){var S,R;if(!this._finished)return S=this._config.chunkSize,_=S?(R=_.substring(0,S),_.substring(S)):(R=_,""),this._finished=!_,this.parseChunk(R)}}function m(M){d.call(this,M=M||{});var _=[],S=!0,R=!1;this.pause=function(){d.prototype.pause.apply(this,arguments),this._input.pause()},this.resume=function(){d.prototype.resume.apply(this,arguments),this._input.resume()},this.stream=function(k){this._input=k,this._input.on("data",this._streamData),this._input.on("end",this._streamEnd),this._input.on("error",this._streamError)},this._checkIsFinished=function(){R&&_.length===1&&(this._finished=!0)},this._nextChunk=function(){this._checkIsFinished(),_.length?this.parseChunk(_.shift()):S=!0},this._streamData=T(function(k){try{_.push(typeof k=="string"?k:k.toString(this._config.encoding)),S&&(S=!1,this._checkIsFinished(),this.parseChunk(_.shift()))}catch(O){this._streamError(O)}},this),this._streamError=T(function(k){this._streamCleanUp(),this._sendError(k)},this),this._streamEnd=T(function(){this._streamCleanUp(),R=!0,this._streamData("")},this),this._streamCleanUp=T(function(){this._input.removeListener("data",this._streamData),this._input.removeListener("end",this._streamEnd),this._input.removeListener("error",this._streamError)},this)}function b(M){var _,S,R,k,O=Math.pow(2,53),H=-O,q=/^\s*-?(\d+\.?|\.\d+|\d+\.\d+)([eE][-+]?\d+)?\s*$/,G=/^((\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z)))$/,K=this,V=0,Y=0,le=!1,se=!1,ge=[],de={data:[],errors:[],meta:{}};function X(ue){return M.skipEmptyLines==="greedy"?ue.join("").trim()==="":ue.length===1&&ue[0].length===0}function ee(){if(de&&R&&(Z("Delimiter","UndetectableDelimiter","Unable to auto-detect delimiting character; defaulted to '"+c.DefaultDelimiter+"'"),R=!1),M.skipEmptyLines&&(de.data=de.data.filter(function(Ce){return!X(Ce)})),ie()){let Ce=function(je,Fe){A(M.transformHeader)&&(je=M.transformHeader(je,Fe)),ge.push(je)};if(de)if(Array.isArray(de.data[0])){for(var ue=0;ie()&&ue<de.data.length;ue++)de.data[ue].forEach(Ce);de.data.splice(0,1)}else de.data.forEach(Ce)}function oe(Ce,je){for(var Fe=M.header?{}:[],j=0;j<Ce.length;j++){var Ke=j,Ue=Ce[j],Ue=((Te,Se)=>(et=>(M.dynamicTypingFunction&&M.dynamicTyping[et]===void 0&&(M.dynamicTyping[et]=M.dynamicTypingFunction(et)),(M.dynamicTyping[et]||M.dynamicTyping)===!0))(Te)?Se==="true"||Se==="TRUE"||Se!=="false"&&Se!=="FALSE"&&((et=>{if(q.test(et)&&(et=parseFloat(et),H<et&&et<O))return 1})(Se)?parseFloat(Se):G.test(Se)?new Date(Se):Se===""?null:Se):Se)(Ke=M.header?j>=ge.length?"__parsed_extra":ge[j]:Ke,Ue=M.transform?M.transform(Ue,Ke):Ue);Ke==="__parsed_extra"?(Fe[Ke]=Fe[Ke]||[],Fe[Ke].push(Ue)):Fe[Ke]=Ue}return M.header&&(j>ge.length?Z("FieldMismatch","TooManyFields","Too many fields: expected "+ge.length+" fields but parsed "+j,Y+je):j<ge.length&&Z("FieldMismatch","TooFewFields","Too few fields: expected "+ge.length+" fields but parsed "+j,Y+je)),Fe}var be;de&&(M.header||M.dynamicTyping||M.transform)&&(be=1,!de.data.length||Array.isArray(de.data[0])?(de.data=de.data.map(oe),be=de.data.length):de.data=oe(de.data,0),M.header&&de.meta&&(de.meta.fields=ge),Y+=be)}function ie(){return M.header&&ge.length===0}function Z(ue,oe,be,Ce){ue={type:ue,code:oe,message:be},Ce!==void 0&&(ue.row=Ce),de.errors.push(ue)}A(M.step)&&(k=M.step,M.step=function(ue){de=ue,ie()?ee():(ee(),de.data.length!==0&&(V+=ue.data.length,M.preview&&V>M.preview?S.abort():(de.data=de.data[0],k(de,K))))}),this.parse=function(ue,oe,be){var Ce=M.quoteChar||'"',Ce=(M.newline||(M.newline=this.guessLineEndings(ue,Ce)),R=!1,M.delimiter?A(M.delimiter)&&(M.delimiter=M.delimiter(ue),de.meta.delimiter=M.delimiter):((Ce=((je,Fe,j,Ke,Ue)=>{var Te,Se,et,Be;Ue=Ue||[","," ","|",";",c.RECORD_SEP,c.UNIT_SEP];for(var N=0;N<Ue.length;N++){for(var E,W=Ue[N],ae=0,ve=0,ce=0,Oe=(et=void 0,new g({comments:Ke,delimiter:W,newline:Fe,preview:10}).parse(je)),Pe=0;Pe<Oe.data.length;Pe++)j&&X(Oe.data[Pe])?ce++:(E=Oe.data[Pe].length,ve+=E,et===void 0?et=E:0<E&&(ae+=Math.abs(E-et),et=E));0<Oe.data.length&&(ve/=Oe.data.length-ce),(Se===void 0||ae<=Se)&&(Be===void 0||Be<ve)&&1.99<ve&&(Se=ae,Te=W,Be=ve)}return{successful:!!(M.delimiter=Te),bestDelimiter:Te}})(ue,M.newline,M.skipEmptyLines,M.comments,M.delimitersToGuess)).successful?M.delimiter=Ce.bestDelimiter:(R=!0,M.delimiter=c.DefaultDelimiter),de.meta.delimiter=M.delimiter),P(M));return M.preview&&M.header&&Ce.preview++,_=ue,S=new g(Ce),de=S.parse(_,oe,be),ee(),le?{meta:{paused:!0}}:de||{meta:{paused:!1}}},this.paused=function(){return le},this.pause=function(){le=!0,S.abort(),_=A(M.chunk)?"":_.substring(S.getCharIndex())},this.resume=function(){K.streamer._halted?(le=!1,K.streamer.parseChunk(_,!0)):setTimeout(K.resume,3)},this.aborted=function(){return se},this.abort=function(){se=!0,S.abort(),de.meta.aborted=!0,A(M.complete)&&M.complete(de),_=""},this.guessLineEndings=function(je,Ce){je=je.substring(0,1048576);var Ce=new RegExp(p(Ce)+"([^]*?)"+p(Ce),"gm"),be=(je=je.replace(Ce,"")).split("\r"),Ce=je.split(`
|
|
4398
4398
|
`),je=1<Ce.length&&Ce[0].length<be[0].length;if(be.length===1||je)return`
|
|
4399
4399
|
`;for(var Fe=0,j=0;j<be.length;j++)be[j][0]===`
|
|
4400
4400
|
`&&Fe++;return Fe>=be.length/2?`\r
|
|
4401
4401
|
`:"\r"}}function p(M){return M.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function g(M){var _=(M=M||{}).delimiter,S=M.newline,R=M.comments,k=M.step,O=M.preview,H=M.fastMode,q=null,G=!1,K=M.quoteChar==null?'"':M.quoteChar,V=K;if(M.escapeChar!==void 0&&(V=M.escapeChar),(typeof _!="string"||-1<c.BAD_DELIMITERS.indexOf(_))&&(_=","),R===_)throw new Error("Comment character same as delimiter");R===!0?R="#":(typeof R!="string"||-1<c.BAD_DELIMITERS.indexOf(R))&&(R=!1),S!==`
|
|
4402
4402
|
`&&S!=="\r"&&S!==`\r
|
|
4403
4403
|
`&&(S=`
|
|
4404
|
-
`);var
|
|
4405
|
-
`,H='"',q=H+H,G=!1,K=null,V=!1,
|
|
4406
|
-
`,'"',c.BYTE_ORDER_MARK],c.WORKERS_SUPPORTED=!s&&!!n.Worker,c.NODE_STREAM_INPUT=1,c.LocalChunkSize=10485760,c.RemoteChunkSize=5242880,c.DefaultDelimiter=",",c.Parser=g,c.ParserHandle=b,c.NetworkStreamer=h,c.FileStreamer=u,c.StringStreamer=f,c.ReadableStreamStreamer=m,n.jQuery&&((i=n.jQuery).fn.parse=function(M){var _=M.config||{},S=[];return this.each(function(O){if(!(i(this).prop("tagName").toUpperCase()==="INPUT"&&i(this).attr("type").toLowerCase()==="file"&&n.FileReader)||!this.files||this.files.length===0)return!0;for(var H=0;H<this.files.length;H++)S.push({file:this.files[H],inputElem:this,instanceConfig:i.extend({},_)})}),R(),this;function R(){if(S.length===0)A(M.complete)&&M.complete();else{var O,H,q,G,K=S[0];if(A(M.before)){var V=M.before(K.file,K.inputElem);if(typeof V=="object"){if(V.action==="abort")return O="AbortError",H=K.file,q=K.inputElem,G=V.reason,void(A(M.error)&&M.error({name:O},H,q,G));if(V.action==="skip")return void k();typeof V.config=="object"&&(K.instanceConfig=i.extend(K.instanceConfig,V.config))}else if(V==="skip")return void k()}var Z=K.instanceConfig.complete;K.instanceConfig.complete=function(le){A(Z)&&Z(le,K.file,K.inputElem),k()},c.parse(K.file,K.instanceConfig)}}function k(){S.splice(0,1),R()}}),a&&(n.onmessage=function(M){M=M.data,c.WORKER_ID===void 0&&M&&(c.WORKER_ID=M.workerId),typeof M.input=="string"?n.postMessage({workerId:c.WORKER_ID,results:c.parse(M.input,M.config),finished:!0}):(n.File&&M.input instanceof File||M.input instanceof Object)&&(M=c.parse(M.input,M.config))&&n.postMessage({workerId:c.WORKER_ID,results:M,finished:!0})}),(h.prototype=Object.create(d.prototype)).constructor=h,(u.prototype=Object.create(d.prototype)).constructor=u,(f.prototype=Object.create(f.prototype)).constructor=f,(m.prototype=Object.create(d.prototype)).constructor=m,c})})(mc)),mc.exports}var RC=PC();const NC=My(RC);class df extends Qs{robot;static async create(){const e=new df;return await e._initAsync(),e}constructor(){super(),this.jointBuf=new lf,this.name="RBQ",this.userData.keep=!0}async _initAsync(){const e=new zc,t=new sf(e),n=Hn(As.RBQ.modelUrl);try{const i=await t.loadAsync(n);i.userData.keep=!0,i.traverse(s=>{s.userData.keep=!0}),this.robot=i,this.add(i)}catch(i){console.error(i)}}update(e){this.position.set(+e.x,+e.y,0),this.rotation.z=bt.degToRad(+e.rz)}applyPose(e){this.pushTransformSnapshot({t:performance.now()*.001,x:e.x,y:e.y,rz:e.rz})}async loadJointData(e,t=!0,n=1){const i=zv(e),s=await fetch(i).then(c=>c.text()),{data:a}=NC.parse(s,{header:!0,dynamicTyping:!0,skipEmptyLines:!0}),o=a.sort((c,d)=>c.time-d.time),l=performance.now()/1e3;for(const c of o){const{time:d,...h}=c,u=h,f=l+d/n;t?setTimeout(()=>this.pushJointsSnapshot(u,f),d/n*1e3):this.pushJointsSnapshot(u,f)}}applyJointValues(e){this.robot?.setJointValues(e)}}class hf extends Qs{static async create(){const e=new hf;return await e._initAsync(),e}constructor(){super(),this.name="SEM",this.userData.keep=!0}update(e){}applyPose(e){if(!e)return;const t={t:performance.now()*.001,x:e.x,y:e.y,rz:e.rz};this.pushTransformSnapshot(t)}async _initAsync(){const i=new Jt(1.1044,.7484,.537,10,1,1),s=new Ne(65535),a=new Ne(16711680),o=[],l=-1.1044/2,c=1.1044/2,d=l+(c-l)*(2/3);for(let b=0;b<i.attributes.position.count;b++){const p=new I;p.fromBufferAttribute(i.attributes.position,b);const g=p.x>=d?a:s;o.push(g.r,g.g,g.b)}i.setAttribute("color",new ke(o,3));const h=new jt({vertexColors:!0,transparent:!0,opacity:.65,depthWrite:!1,side:Si}),u=new Ee(i,h);u.position.set(0,0,.2685),u.userData.keep=!0,u.renderOrder=1;const f=new Fc(i),m=new Ks(f,new zn({color:16777215}));m.renderOrder=2,m.userData.keep=!0,u.add(m),this.add(u)}}class uf extends Qs{static async create(){const e=new uf;return await e._initAsync(),e}constructor(){super(),this.name="SEC",this.userData.keep=!0}update(e){}applyPose(e){if(!e)return;const t={t:performance.now()*.001,x:e.x,y:e.y,rz:e.rz};this.pushTransformSnapshot(t)}async _initAsync(){const i=new Jt(1.1044,.7484,.537,10,1,1),s=new Ne(65535),a=new Ne(16711680),o=[],l=-1.1044/2,c=1.1044/2,d=l+(c-l)*(2/3);for(let b=0;b<i.attributes.position.count;b++){const p=new I;p.fromBufferAttribute(i.attributes.position,b);const g=p.x>=d?a:s;o.push(g.r,g.g,g.b)}i.setAttribute("color",new ke(o,3));const h=new jt({vertexColors:!0,transparent:!0,opacity:.65,depthWrite:!1,side:Si}),u=new Ee(i,h);u.position.set(0,0,.2685),u.userData.keep=!0,u.renderOrder=1;const f=new Fc(i),m=new Ks(f,new zn({color:16777215}));m.renderOrder=2,m.userData.keep=!0,u.add(m),this.add(u)}}class Ec extends Qs{static async create(){const e=new Ec;return await e._initAsync(),e}constructor(){super(),this.name="FallbackRobot",this.userData.keep=!0}update(e){}applyPose(e){if(!e)return;const t={t:performance.now()*.001,x:e.x,y:e.y,rz:e.rz};this.pushTransformSnapshot(t)}async _initAsync(){const i=new Jt(1.1044,.7484,.537,10,1,1),s=new Ne(65535),a=new Ne(16711680),o=[],l=-1.1044/2,c=1.1044/2,d=l+(c-l)*(2/3);for(let b=0;b<i.attributes.position.count;b++){const p=new I;p.fromBufferAttribute(i.attributes.position,b);const g=p.x>=d?a:s;o.push(g.r,g.g,g.b)}i.setAttribute("color",new ke(o,3));const h=new jt({vertexColors:!0,transparent:!0,opacity:.65,depthWrite:!1,side:Si}),u=new Ee(i,h);u.position.set(0,0,.2685),u.userData.keep=!0,u.renderOrder=1;const f=new Fc(i),m=new Ks(f,new zn({color:16777215}));m.renderOrder=2,m.userData.keep=!0,u.add(m),this.add(u)}}class ff extends Qs{static async create(){const e=new ff;return await e._initAsync(),e}constructor(){super(),this.name="GAIA",this.userData.keep=!0}async _initAsync(){const e=new Ar,t=new Oo,n=Hn(As.GAIA.modelUrl);t.setDecoderPath(Hn("/draco/")),e.setDRACOLoader(t);try{const s=(await e.loadAsync(n)).scene;s.renderOrder=mn.ROBOT;const a=new Vt;a.add(s),a.traverse(o=>{if(o.userData.keep=!0,!(o instanceof Ee))return;const l=c=>{const d=new Fn;return"color"in c&&c.color instanceof Ne&&d.color.copy(c.color),"map"in c&&c.map instanceof Ut&&(d.map=c.map),"transparent"in c&&(d.transparent=c.transparent),"opacity"in c&&(d.opacity=c.opacity),"side"in c&&(d.side=c.side),d};Array.isArray(o.material)?o.material=o.material.map(l):o.material=l(o.material)}),this.alignToGroundZUp(s),a.rotation.z=Math.PI,this.add(a)}catch(i){i instanceof Error?console.error("GAIA Load Failed:",i.message):console.error("GAIA Load Failed:",i)}finally{t.dispose()}}update(e){this.position.set(Number(e.x),Number(e.y),0),this.rotation.z=bt.degToRad(Number(e.rz))}applyPose(e){if(!e)return;const t={t:performance.now()*.001,x:e.x,y:e.y,rz:e.rz};this.pushTransformSnapshot(t)}}class pf extends Qs{static async create(){const e=new pf;return await e._initAsync(),e}constructor(){super(),this.name="QD",this.userData.keep=!0}async _initAsync(){const e=new Ar,t=new Oo,n=Hn(As.QD.modelUrl);t.setDecoderPath(Hn("/draco/")),e.setDRACOLoader(t);try{const s=(await e.loadAsync(n)).scene;s.renderOrder=mn.ROBOT;const a=new Vt;a.add(s),a.traverse(o=>{o.userData.keep=!0}),this.alignToGroundZUp(s),this.add(a)}catch(i){i instanceof Error?console.error("QD Load Failed:",i.message):console.error("QD Load Failed:",i)}finally{t.dispose()}}update(e){this.position.set(Number(e.x),Number(e.y),0),this.rotation.z=bt.degToRad(Number(e.rz))}applyPose(e){if(!e)return;const t={t:performance.now()*.001,x:e.x,y:e.y,rz:e.rz};this.pushTransformSnapshot(t)}}const Zm={rby1a:{name:"RBY1-A",urdfPath:"/rby1a/rby1a.urdf"},rby1m:{name:"RBY1-M",urdfPath:"/rby1m/rby1m.urdf"},rby1ub:{name:"RBY1-UB",urdfPath:"/rby1ub/rby1ub.urdf"},rby2c:{name:"RBY2-C",urdfPath:"/rby2c/rby2c.urdf"}};class mf extends Qs{robot;variant;static async create(e="rby1m"){const t=new mf(e);return await t._initAsync(),t}constructor(e){super(),this.variant=e,this.jointBuf=new lf,this.name=Zm[e].name,this.userData.keep=!0}async _initAsync(){const e=Zm[this.variant],t=Hn(e.urdfPath);await new Promise(n=>{const i=new zc,s=new sf(i);let a=null,o=!1;const l=()=>{o||(o=!0,n())};s.loadMeshCb=sv,i.onLoad=()=>{if(!o){if(!a){l();return}a.userData.keep=!0,a.traverse(c=>{c.userData.keep=!0}),this.robot=a,this.alignToGroundZUp(a),this.add(a),l()}},i.onError=c=>{o||(console.warn(`[RBY] Load failed: ${c}`),l())},s.load(t,c=>{o||(a=c)},void 0,c=>{o||(c instanceof Error?console.error(`RBY Load Failed (${this.variant}):`,c.message):console.error(`RBY Load Failed (${this.variant}):`,c),l())})})}update(e){this.position.set(Number(e.x),Number(e.y),0),this.rotation.z=bt.degToRad(Number(e.rz))}applyPose(e){if(!e)return;const t={t:performance.now()*.001,x:e.x,y:e.y,rz:e.rz};this.pushTransformSnapshot(t)}applyJointValues(e){this.robot?.setJointValues(e)}}const Ym=["#0087fc","#f77468","#f37a32","#dc8932","#ca9232","#bb9832","#ae9d31","#9fa131","#8ea631","#77ab31","#50b131","#32b25c","#33b07a","#34af8c","#35ae99","#36ada4","#36acae","#37aab9","#38a9c5","#39a7d5","#3ba3ec","#6e9bf4","#9591f4","#b287f4","#cc7af4","#e866f4","#f560e4","#f565cc","#f66ab7","#f66da2"];class DC{editor;mainRobot=null;rbq;s100;robotMap;previousUpdateTime;availableColors;constructor(e){this.editor=e,this.s100=null,this.rbq=null,this.robotMap=new Map,this.previousUpdateTime=Date.now(),this.availableColors=[...Ym]}registerEventListeners(){this.editor.eventHandler.eventBus.on("ui:initial-view-set-up",this.handleSetUpInitialView)}deregisterEventListeners(){this.editor.eventHandler.eventBus.off("ui:initial-view-set-up",this.handleSetUpInitialView)}addLabel(e){const t=document.createElement("div");t.className="nodeLabel",t.textContent=e.name,t.style.color="white",t.style.backgroundColor="transparent",t.style.position="absolute",t.style.fontSize="6.5px",t.style.zIndex="-999";const n=new Hs(t);n.userData.keep=!0,n.userData.labelType="robot",n.name="label",n.center.set(0,-.5),e.add(n)}count(){return this.robotMap.size}dispose(){this.rbq=null,this.s100=null,this.mainRobot=null}async loadMainRobot(e){if(this.mainRobot||!this.editor.scene)return;let t=null;switch(e){case"S100":case"S100-A":case"S100-A-3D":case"S100-B":case"S100-B-3D":t=await cf.create(),this.s100=t;break;case"RBQ":t=await df.create(),this.rbq=t;break;case"SEM":t=await hf.create();break;case"SEC":t=await uf.create();break;case"D400":case"D400_NEW":case"DD-SEC_EE":t=await Ec.create();break;case"QD":t=await ff.create();break;case"rby1a":case"rby1m":case"rby1ub":case"rby2c":t=await mf.create(e);break;case"QD-RBY":t=await pf.create();break;default:t=await Ec.create();break}t&&(this.mainRobot=t,this.editor.scene.add(this.mainRobot),this.robotMap.set("mainRobot",this.mainRobot),this.editor.eventHandler.eventBus.emit("robot-manager:main-robot-loaded"))}update=(e,t)=>{e.visible?(e.position.set(t.x,t.y,e.position.z),e.rotation.z=t.rz*Math.PI/180):(e.position.set(t.x,t.y,0),e.rotation.z=t.rz,e.visible=!0)};updateAll(e){this.mainRobot?.tick(e)}addAxesHelper(e){const t=new Da(1e3);t.userData.keep=!0,e.add(t)}cloneEdgeLine(e,t){const n=e.getObjectByName("edgeLine"),i=t.getObjectByName("edgeLine");n&&i&&(i.material=n.material.clone())}cloneRobot(e){const t=e.clone();t.name="robot";const n=e.material.clone();return n.color=new Ne(this.getUniqueColor()),t.material=n,t}getUniqueColor(){return this.availableColors.length===0&&(this.availableColors=[...Ym]),this.availableColors.splice(0,1)[0]}handleSetUpInitialView=e=>{if(!this.mainRobot)return;const t={x:Number(e.x),y:Number(e.y),z:0},n=Number(e.rz)*Math.PI/180;this.mainRobot.position.copy(t),this.mainRobot.rotation.z=n}}class LC{_selected=null;_selectableObjects=[];_selectableLinks=[];_selectableZones=[];_selectableZoneVertices=[];_selectedObjects=[];_selectedLinks=[];_focusedLinkId=null;_selectedZones=[];_focusedZoneId=null;_selectedZoneVertex=null;getSelected(){return this._selected}setSelected(e){this._selected=e}getSelectableObjects(){return this._selectableObjects}setSelectableObjects(e){this._selectableObjects=e}registerSelectable(e){this._selectableObjects.push(e)}getSelectableLinks(){return this._selectableLinks}registerSelectableLink(e){this._selectableLinks.push(e)}getSelectableZones(){return this._selectableZones}registerSelectableZone(e){this._selectableZones.push(e)}getSelectableZoneVertices(){return this._selectableZoneVertices}registerSelectableZoneVertex(e){this._selectableZoneVertices.push(e)}unregisterSelectableZoneVertex(e){const t=this._selectableZoneVertices.indexOf(e);t>-1&&this._selectableZoneVertices.splice(t,1),this._selectedZoneVertex===e&&(this._selectedZoneVertex=null)}unregisterSelectableZone(e){const t=this._selectableZones.indexOf(e);t>-1&&this._selectableZones.splice(t,1),this._selectedZones=this._selectedZones.filter(n=>n!==e),this.syncFocusedZoneId()}unregisterSelectableLink(e){const t=this._selectableLinks.indexOf(e);t>-1&&this._selectableLinks.splice(t,1),this._selectedLinks=this._selectedLinks.filter(n=>n!==e),this.syncFocusedLinkId()}unregisterSelectable(e){const t=this._selectableObjects.indexOf(e);t>-1&&this._selectableObjects.splice(t,1);const n=this._selectedObjects.indexOf(e);n>-1&&this._selectedObjects.splice(n,1)}replaceSelectable(e,t){const n=this._selectableObjects.indexOf(e);n>-1&&(this._selectableObjects[n]=t)}replaceSelected(e,t){this._selectedObjects=this._selectedObjects.map(n=>n===e?t:n),this._selected===e&&(this._selected=t)}isSelectable(e){return this._selectableObjects.includes(e)}getSelectedObjects(){return this._selectedObjects}setSelectedObjects(e){this._selectedObjects=e}getSelectedLinks(){return this._selectedLinks}setSelectedLinks(e){this._selectedLinks=e,this.syncFocusedLinkId()}getFocusedLinkId(){return this._focusedLinkId}setFocusedLinkId(e){if(e===null){this._focusedLinkId=null;return}this._focusedLinkId=this._selectedLinks.some(t=>String(t.userData.linkId)===e)?e:this._selectedLinks[0]?String(this._selectedLinks[0].userData.linkId):null}getSelectedZones(){return this._selectedZones}setSelectedZones(e){this._selectedZones=e,this.syncFocusedZoneId()}getFocusedZoneId(){return this._focusedZoneId}setFocusedZoneId(e){if(e===null){this._focusedZoneId=null;return}this._focusedZoneId=this._selectedZones.some(t=>String(t.userData.zoneId)===e)?e:this._selectedZones[0]?String(this._selectedZones[0].userData.zoneId):null}getSelectedZoneVertex(){return this._selectedZoneVertex}setSelectedZoneVertex(e){this._selectedZoneVertex=e}clearLinkSelection(){this._selectedLinks=[],this._focusedLinkId=null}clearZoneSelection(){this._selectedZones=[],this._focusedZoneId=null}clearZoneVertexSelection(){this._selectedZoneVertex=null}clearSelection(){this._selected=null,this._selectedObjects=[],this._selectedLinks=[],this._focusedLinkId=null,this._selectedZones=[],this._focusedZoneId=null,this._selectedZoneVertex=null}reset(){this.clearSelection(),this._selectableObjects=[],this._selectableLinks=[],this._selectableZones=[],this._selectableZoneVertices=[]}syncFocusedLinkId(){if(this._selectedLinks.length===0){this._focusedLinkId=null;return}this._focusedLinkId&&this._selectedLinks.some(e=>String(e.userData.linkId)===this._focusedLinkId)||(this._focusedLinkId=String(this._selectedLinks[0].userData.linkId))}syncFocusedZoneId(){if(this._selectedZones.length===0){this._focusedZoneId=null;return}this._focusedZoneId&&this._selectedZones.some(e=>String(e.userData.zoneId)===this._focusedZoneId)||(this._focusedZoneId=String(this._selectedZones[0].userData.zoneId))}}class IC{editor;_raycaster;_invMat=new Ie;mouse=new me;selectionRect=new Ws;constructor(e){this.editor=e,this._raycaster=new tf,this._raycaster.params.Points.threshold=.5}get pointsThreshold(){return this._raycaster.params.Points.threshold}set pointsThreshold(e){e<=0||(this._raycaster.params.Points.threshold=e)}dispose(){this.deregisterEvents()}deregisterEvents(){const e=this.editor.eventHandler.eventBus;e.off("viewport:intersections-detected",this.handleIntersectionsDetected),e.off("selector:box-intersections-detected",this.handleBoxIntersectionsDetected),e.off("editor:object-removed",this.handleObjectRemoved),e.off("ui:selection-reset-requested",this.handleSelectionReset),e.off("ui:node-selected",this.handleNodeSelectedFromUI),e.off("eraser:radius-changed",this.handleEraserRadiusChanged)}getSelectionBoxIntersects(e,t,n){this.selectionRect.min=new me(Math.min(t.x,n.x),Math.min(t.y,n.y)),this.selectionRect.max=new me(Math.max(t.x,n.x),Math.max(t.y,n.y));const i=[],s=this.editor.selectionManager.getSelectableObjects(),a=s.length;for(let l=0;l<a;l++){const c=s[l],d=this.toScreenPosition(e,c),h=new me(d.x,d.y);this.selectionRect.containsPoint(h)&&i.push(c)}return this.getSortedIntersects(i)}getPointerPlaneIntersection(e,t){return this.mouse.set(e.x*2-1,-(e.y*2)+1),this._raycaster.setFromCamera(this.mouse,t),this.computeGlobalPlaneIntersection(this._raycaster)}getPointerObjectIntersections(e,t){return this.mouse.set(e.x*2-1,-(e.y*2)+1),this._raycaster.setFromCamera(this.mouse,t),this.computeObjectIntersects(this._raycaster)}getPointerZoneDraftVertexIntersection(e,t){this.mouse.set(e.x*2-1,-(e.y*2)+1),this._raycaster.setFromCamera(this.mouse,t);const n=this._raycaster.intersectObjects(this.editor.selectionManager.getSelectableZoneVertices(),!0);return this.resolveZoneDraftVertexHit(n)}getPointerOctreeIntersections(e,t){return this.mouse.set(e.x*2-1,-(e.y*2)+1),this._raycaster.setFromCamera(this.mouse,t),this.computeOctreePointIntersections(this._raycaster,t)}getPointerQuadTreeIntersections(e,t){return this.mouse.set(e.x*2-1,-(e.y*2)+1),this._raycaster.setFromCamera(this.mouse,t),this.computeQuadtreePointIntersections(this._raycaster,t)}getPointerMapBrushIntersections(e,t){this.mouse.set(e.x*2-1,-(e.y*2)+1),this._raycaster.setFromCamera(this.mouse,t);const n=this.computeGlobalPlaneIntersection(this._raycaster);return n.length?this.computeQuadtreeXYBrushIntersections(n[0].point,this._raycaster.params.Points.threshold??1,t):[]}getPointerNearestPointIntersection(e,t){return this.mouse.set(e.x*2-1,-(e.y*2)+1),this._raycaster.setFromCamera(this.mouse,t),this.computeNearestPointIntersect(this._raycaster,t)}registerEventListeners(){const e=this.editor.eventHandler.eventBus;e.on("viewport:intersections-detected",this.handleIntersectionsDetected),e.on("selector:box-intersections-detected",this.handleBoxIntersectionsDetected),e.on("editor:object-removed",this.handleObjectRemoved),e.on("ui:selection-reset-requested",this.handleSelectionReset),e.on("ui:node-selected",this.handleNodeSelectedFromUI),e.on("eraser:radius-changed",this.handleEraserRadiusChanged)}accumulateOctreeIntersections(e,t,n,i,s){if(e.intersectsBox(t.boundary))if(t.divided)for(const a of t.children)this.accumulateOctreeIntersections(e,a,n,i,s);else for(const{position:a,index:o}of t.points){const l=e.distanceToPoint(a);if(l<=n){const c=i.position.distanceTo(a);s.push({point:a.clone(),index:o,distance:l,cameraDist:c})}}}computeGlobalPlaneIntersection(e){return e.intersectObject(this.editor.globalPlane)}computeNearestPointIntersect(e,t){const n=e.ray,i=this.editor.pointsManager.pointsOctree;return this.findNearestOctreeIntersection(n,i,e.params.Points.threshold,t)}computeObjectIntersects(e){const t=[...this.editor.selectionManager.getSelectableZoneVertices(),...this.editor.selectionManager.getSelectableObjects(),...this.editor.selectionManager.getSelectableLinks().filter(n=>n.visible),...this.editor.selectionManager.getSelectableZones()];return e.intersectObjects(t,!0)}computeOctreePointIntersections(e,t){const n=e.ray,i=[],s=this.editor.pointsManager.pointsOctree;return this.accumulateOctreeIntersections(n,s,e.params.Points.threshold,t,i),i}findNearestOctreeIntersection(e,t,n,i){if(!e.intersectsBox(t.boundary))return null;let s=null;if(t.divided)for(const a of t.children){const o=this.findNearestOctreeIntersection(e,a,n,i);o!==null&&(s===null||o.cameraDist<s.cameraDist)&&(s=o)}else for(const{position:a,index:o}of t.points){const l=e.distanceToPoint(a);if(l<=n){const c=i.position.distanceTo(a);(s===null||c<s.cameraDist)&&(s={point:a.clone(),index:o,distance:l,cameraDist:c})}}return s}getSortedIntersects(e){return e.sort((t,n)=>{const i=t.position.x-n.position.x;return i!==0?i:n.position.y-t.position.y}),e}handleBoxIntersectionsDetected=e=>{const{intersections:t,action:n}=e;this.clearLinkSelection(),this.clearZoneSelection(),this.select(null),this.multiSelect(t,n)};handleIntersectionsDetected=e=>{const{action:t,intent:n,intersections:i}=e,s=this.resolveSelectionHit(i);if(!s){if(n==="add"||n==="remove")return;this.clearZoneVertexSelection(),this.clearLinkSelection(),this.clearZoneSelection(),this.select(null);return}if(s.kind==="zone-draft-vertex"){this.clearLinkSelection(),this.clearZoneSelection(),this.select(null),this.selectZoneDraftVertex(s.vertex,s.vertexIndex);return}if(s.kind==="links"){this.clearZoneVertexSelection(),this.clearZoneSelection(),this.editor.selectionManager.setSelectedLinks(s.arrows),this.editor.eventHandler.eventBus.emit("selector:link-selected",{linkIds:s.linkIds}),this.select(null);return}if(s.kind==="zones"){this.clearZoneVertexSelection(),this.clearLinkSelection(),this.editor.selectionManager.setSelectedZones(s.zones),this.select(null),this.editor.eventHandler.eventBus.emit("selector:zone-selected",{zoneIds:s.zoneIds});return}this.clearZoneVertexSelection(),this.clearLinkSelection(),this.clearZoneSelection(),this.select(s.object,t,n)};handleNodesCopied=e=>{this.select(null),this.multiSelect(e,"inspect")};handleObjectRemoved=()=>{this.clearZoneVertexSelection(),this.clearLinkSelection(),this.clearZoneSelection(),this.select(null)};multiSelect=(e,t)=>{const n=this.editor.selectionManager,i=[...n.getSelectedObjects()],s=e[e.length-1]??null;n.setSelected(s),n.setSelectedObjects(e),this.editor.eventHandler.eventBus.emit("selector:object-selected",{object:s,prevSelected:i,selectedObjects:[...e],action:t})};select=(e,t,n="replace")=>{const i=this.editor.selectionManager,s=i.getSelectedObjects();if(n==="replace"&&e!==null&&s.length===1&&s[0]===e)return;const o=e?n==="add"?[...s.filter(d=>d!==e),e]:n==="remove"?s.filter(d=>d!==e):[e]:[];if(n==="remove"&&e!==null&&s.length===o.length){const d=i.getSelected();this.editor.eventHandler.eventBus.emit("selector:object-selected",{object:d,prevSelected:[...s],selectedObjects:[...s],action:t});return}const l=o[o.length-1]??null;i.setSelected(l);const c={object:l,prevSelected:[...s],selectedObjects:[...o],action:t};this.editor.eventHandler.eventBus.emit("selector:object-selected",c),i.setSelectedObjects(o)};toScreenPosition(e,t){const n=e.getBoundingClientRect(),i=new I;return t.updateMatrixWorld(),i.setFromMatrixPosition(t.matrixWorld),i.project(this.editor.camera),{x:(i.x+1)/2*n.width+n.left,y:(-i.y+1)/2*n.height+n.top}}computeQuadtreePointIntersections(e,t){const n=[],i=this.editor.pointsManager.pointsQuadTree;if(!i)return n;const s=e.params.Points.threshold??1;return this.accumulateQuadtreeIntersections(e.ray,i,s,t,n),n}computeQuadtreeXYBrushIntersections(e,t,n){const i=[],s=this.editor.pointsManager.pointsQuadTree;if(!s)return i;const a=new Ws(new me(e.x-t,e.y-t),new me(e.x+t,e.y+t));return this.accumulateQuadtreeXYBrushIntersections(e,t,a,s,n,i),i}_visualizeRay(e,t,n,i=30,s=65535){const a=new G_(t,e,i,s,.3,.3);n.add(a)}accumulateQuadtreeIntersections(e,t,n,i,s){const a=t.boundary.clone().expandByScalar(n),o=new Yt(new I(a.min.x,a.min.y,-n),new I(a.max.x,a.max.y,n));if(e.intersectsBox(o))if(t.divided)for(const l of t.children)this.accumulateQuadtreeIntersections(e,l,n,i,s);else for(const{position:l,index:c}of t.points){const d=e.distanceToPoint(l);if(d<=n){const h=i.position.distanceTo(l);s.push({point:l.clone(),index:c,distance:d,cameraDist:h})}}}accumulateQuadtreeXYBrushIntersections(e,t,n,i,s,a){if(!i.boundary.intersectsBox(n))return;const o=t*t;if(i.divided)for(const l of i.children)this.accumulateQuadtreeXYBrushIntersections(e,t,n,l,s,a);else for(const{position:l,index:c}of i.points){const d=l.x-e.x,h=l.y-e.y,u=d*d+h*h;if(u<=o){const f=Math.sqrt(u),m=s.position.distanceTo(l);a.push({point:l.clone(),index:c,distance:f,cameraDist:m})}}}handleSelectionReset=()=>{this.clearZoneVertexSelection(),this.clearLinkSelection(),this.clearZoneSelection(),this.select(null)};handleNodeSelectedFromUI=({nodeId:e,intent:t})=>{const n=this.editor.scene.getObjectByProperty("uuid",e);if(!n)return;const i=n;this.clearZoneVertexSelection(),this.clearLinkSelection(),this.clearZoneSelection(),this.select(i,"select",t)};handleEraserRadiusChanged=e=>{this._raycaster.params.Points.threshold=e};clearLinkSelection(){this.editor.selectionManager.clearLinkSelection(),this.editor.eventHandler.eventBus.emit("selector:link-selected",{linkIds:[]})}clearZoneSelection(){this.editor.selectionManager.clearZoneSelection(),this.editor.eventHandler.eventBus.emit("selector:zone-selected",{zoneIds:[]})}clearZoneVertexSelection(){this.editor.selectionManager.clearZoneVertexSelection(),this.editor.eventHandler.eventBus.emit("selector:zone-draft-vertex-selected",{vertex:null,vertexIndex:null})}selectZoneDraftVertex(e,t){this.editor.selectionManager.setSelectedZoneVertex(e),this.editor.eventHandler.eventBus.emit("selector:zone-draft-vertex-selected",{vertex:e,vertexIndex:t})}resolveSelectionHit(e){const t=this.resolveZoneDraftVertexHit(e);if(t)return{kind:"zone-draft-vertex",vertex:t.mesh,vertexIndex:t.vertexIndex};for(let s=0;s<e.length;s++){const a=e[s].object;if(this.editor.selectionManager.isSelectable(a))return{kind:"node",object:a}}const n=this.resolveLinkHits(e);if(n.length>0)return{kind:"links",arrows:n,linkIds:n.map(s=>String(s.userData.linkId))};const i=this.resolveZoneHits(e);return i.length>0?{kind:"zones",zones:i,zoneIds:i.map(s=>String(s.userData.zoneId))}:null}resolveLinkHits(e){const t=new Map;for(let n=0;n<e.length;n++){const i=this.resolveLinkHit(e[n].object);if(!i)continue;const s=String(i.userData.linkId);t.has(s)||t.set(s,i)}return[...t.values()]}resolveLinkHit(e){const t=e.userData.objectType,n=e.userData.arrowOwner,i=e.userData.linkId??n?.userData.linkId;return(t==="topology-link-hit-area"||t==="topology-link-part")&&n&&n.visible&&i?n:null}resolveZoneHits(e){const t=new Map;for(let n=0;n<e.length;n++){const i=this.resolveZoneHit(e[n].object);if(!i)continue;const s=String(i.userData.zoneId);t.has(s)||t.set(s,i)}return[...t.values()]}resolveZoneHit(e){const t=e.userData.objectType,n=e.userData.zoneId;return t==="topology-zone-hit-area"&&n?e:null}resolveZoneDraftVertexHit(e){for(let t=0;t<e.length;t++){const n=e[t].object;if(!this.editor.selectionManager.getSelectableZoneVertices().includes(n))continue;const i=n.userData.vertexIndex;if(typeof i=="number")return{mesh:n,vertexIndex:i}}return null}}/*! *****************************************************************************
|
|
4404
|
+
`);var Y=0,le=!1;this.parse=function(se,ge,de){if(typeof se!="string")throw new Error("Input must be a string");var X=se.length,ee=_.length,ie=S.length,Z=R.length,ue=A(k),oe=[],be=[],Ce=[],je=Y=0;if(!se)return ae();if(H||H!==!1&&se.indexOf(K)===-1){for(var Fe=se.split(S),j=0;j<Fe.length;j++){if(Ce=Fe[j],Y+=Ce.length,j!==Fe.length-1)Y+=S.length;else if(de)return ae();if(!R||Ce.substring(0,Z)!==R){if(ue){if(oe=[],Be(Ce.split(_)),ve(),le)return ae()}else Be(Ce.split(_));if(O&&O<=j)return oe=oe.slice(0,O),ae(!0)}}return ae()}for(var Ke=se.indexOf(_,Y),Ue=se.indexOf(S,Y),Te=new RegExp(p(V)+p(K),"g"),Se=se.indexOf(K,Y);;)if(se[Y]===K)for(Se=Y,Y++;;){if((Se=se.indexOf(K,Se+1))===-1)return de||be.push({type:"Quotes",code:"MissingQuotes",message:"Quoted field unterminated",row:oe.length,index:Y}),E();if(Se===X-1)return E(se.substring(Y,Se).replace(Te,K));if(K===V&&se[Se+1]===V)Se++;else if(K===V||Se===0||se[Se-1]!==V){Ke!==-1&&Ke<Se+1&&(Ke=se.indexOf(_,Se+1));var et=N((Ue=Ue!==-1&&Ue<Se+1?se.indexOf(S,Se+1):Ue)===-1?Ke:Math.min(Ke,Ue));if(se.substr(Se+1+et,ee)===_){Ce.push(se.substring(Y,Se).replace(Te,K)),se[Y=Se+1+et+ee]!==K&&(Se=se.indexOf(K,Y)),Ke=se.indexOf(_,Y),Ue=se.indexOf(S,Y);break}if(et=N(Ue),se.substring(Se+1+et,Se+1+et+ie)===S){if(Ce.push(se.substring(Y,Se).replace(Te,K)),W(Se+1+et+ie),Ke=se.indexOf(_,Y),Se=se.indexOf(K,Y),ue&&(ve(),le))return ae();if(O&&oe.length>=O)return ae(!0);break}be.push({type:"Quotes",code:"InvalidQuotes",message:"Trailing quote on quoted field is malformed",row:oe.length,index:Y}),Se++}}else if(R&&Ce.length===0&&se.substring(Y,Y+Z)===R){if(Ue===-1)return ae();Y=Ue+ie,Ue=se.indexOf(S,Y),Ke=se.indexOf(_,Y)}else if(Ke!==-1&&(Ke<Ue||Ue===-1))Ce.push(se.substring(Y,Ke)),Y=Ke+ee,Ke=se.indexOf(_,Y);else{if(Ue===-1)break;if(Ce.push(se.substring(Y,Ue)),W(Ue+ie),ue&&(ve(),le))return ae();if(O&&oe.length>=O)return ae(!0)}return E();function Be(ce){oe.push(ce),je=Y}function N(ce){var Oe=0;return Oe=ce!==-1&&(ce=se.substring(Se+1,ce))&&ce.trim()===""?ce.length:Oe}function E(ce){return de||(ce===void 0&&(ce=se.substring(Y)),Ce.push(ce),Y=X,Be(Ce),ue&&ve()),ae()}function W(ce){Y=ce,Be(Ce),Ce=[],Ue=se.indexOf(S,Y)}function ae(ce){if(M.header&&!ge&&oe.length&&!G){var Oe=oe[0],Pe=Object.create(null),Ve=new Set(Oe);let te=!1;for(let re=0;re<Oe.length;re++){let De=Oe[re];if(Pe[De=A(M.transformHeader)?M.transformHeader(De,re):De]){let Ye,xe=Pe[De];for(;Ye=De+"_"+xe,xe++,Ve.has(Ye););Ve.add(Ye),Oe[re]=Ye,Pe[De]++,te=!0,(q=q===null?{}:q)[Ye]=De}else Pe[De]=1,Oe[re]=De;Ve.add(De)}te&&console.warn("Duplicate headers found and renamed."),G=!0}return{data:oe,errors:be,meta:{delimiter:_,linebreak:S,aborted:le,truncated:!!ce,cursor:je+(ge||0),renamedHeaders:q}}}function ve(){k(ae()),oe=[],be=[]}},this.abort=function(){le=!0},this.getCharIndex=function(){return Y}}function y(M){var _=M.data,S=o[_.workerId],R=!1;if(_.error)S.userError(_.error,_.file);else if(_.results&&_.results.data){var k={abort:function(){R=!0,x(_.workerId,{data:[],errors:[],meta:{aborted:!0}})},pause:w,resume:w};if(A(S.userStep)){for(var O=0;O<_.results.data.length&&(S.userStep({data:_.results.data[O],errors:_.results.errors,meta:_.results.meta},k),!R);O++);delete _.results}else A(S.userChunk)&&(S.userChunk(_.results,k,_.file),delete _.results)}_.finished&&!R&&x(_.workerId,_.results)}function x(M,_){var S=o[M];A(S.userComplete)&&S.userComplete(_),S.terminate(),delete o[M]}function w(){throw new Error("Not implemented.")}function P(M){if(typeof M!="object"||M===null)return M;var _,S=Array.isArray(M)?[]:{};for(_ in M)S[_]=P(M[_]);return S}function T(M,_){return function(){M.apply(_,arguments)}}function A(M){return typeof M=="function"}return c.parse=function(M,_){var S=(_=_||{}).dynamicTyping||!1;if(A(S)&&(_.dynamicTypingFunction=S,S={}),_.dynamicTyping=S,_.transform=!!A(_.transform)&&_.transform,!_.worker||!c.WORKERS_SUPPORTED)return S=null,c.NODE_STREAM_INPUT,typeof M=="string"?(M=(R=>R.charCodeAt(0)!==65279?R:R.slice(1))(M),S=new(_.download?h:f)(_)):M.readable===!0&&A(M.read)&&A(M.on)?S=new m(_):(n.File&&M instanceof File||M instanceof Object)&&(S=new u(_)),S.stream(M);(S=(()=>{var R;return!!c.WORKERS_SUPPORTED&&(R=(()=>{var k=n.URL||n.webkitURL||null,O=t.toString();return c.BLOB_URL||(c.BLOB_URL=k.createObjectURL(new Blob(["var global = (function() { if (typeof self !== 'undefined') { return self; } if (typeof window !== 'undefined') { return window; } if (typeof global !== 'undefined') { return global; } return {}; })(); global.IS_PAPA_WORKER=true; ","(",O,")();"],{type:"text/javascript"})))})(),(R=new n.Worker(R)).onmessage=y,R.id=l++,o[R.id]=R)})()).userStep=_.step,S.userChunk=_.chunk,S.userComplete=_.complete,S.userError=_.error,_.step=A(_.step),_.chunk=A(_.chunk),_.complete=A(_.complete),_.error=A(_.error),delete _.worker,S.postMessage({input:M,config:_,workerId:S.id})},c.unparse=function(M,_){var S=!1,R=!0,k=",",O=`\r
|
|
4405
|
+
`,H='"',q=H+H,G=!1,K=null,V=!1,Y=((()=>{if(typeof _=="object"){if(typeof _.delimiter!="string"||c.BAD_DELIMITERS.filter(function(ge){return _.delimiter.indexOf(ge)!==-1}).length||(k=_.delimiter),typeof _.quotes!="boolean"&&typeof _.quotes!="function"&&!Array.isArray(_.quotes)||(S=_.quotes),typeof _.skipEmptyLines!="boolean"&&typeof _.skipEmptyLines!="string"||(G=_.skipEmptyLines),typeof _.newline=="string"&&(O=_.newline),typeof _.quoteChar=="string"&&(H=_.quoteChar),typeof _.header=="boolean"&&(R=_.header),Array.isArray(_.columns)){if(_.columns.length===0)throw new Error("Option columns is empty");K=_.columns}_.escapeChar!==void 0&&(q=_.escapeChar+H),_.escapeFormulae instanceof RegExp?V=_.escapeFormulae:typeof _.escapeFormulae=="boolean"&&_.escapeFormulae&&(V=/^[=+\-@\t\r].*$/)}})(),new RegExp(p(H),"g"));if(typeof M=="string"&&(M=JSON.parse(M)),Array.isArray(M)){if(!M.length||Array.isArray(M[0]))return le(null,M,G);if(typeof M[0]=="object")return le(K||Object.keys(M[0]),M,G)}else if(typeof M=="object")return typeof M.data=="string"&&(M.data=JSON.parse(M.data)),Array.isArray(M.data)&&(M.fields||(M.fields=M.meta&&M.meta.fields||K),M.fields||(M.fields=Array.isArray(M.data[0])?M.fields:typeof M.data[0]=="object"?Object.keys(M.data[0]):[]),Array.isArray(M.data[0])||typeof M.data[0]=="object"||(M.data=[M.data])),le(M.fields||[],M.data||[],G);throw new Error("Unable to serialize unrecognized input");function le(ge,de,X){var ee="",ie=(typeof ge=="string"&&(ge=JSON.parse(ge)),typeof de=="string"&&(de=JSON.parse(de)),Array.isArray(ge)&&0<ge.length),Z=!Array.isArray(de[0]);if(ie&&R){for(var ue=0;ue<ge.length;ue++)0<ue&&(ee+=k),ee+=se(ge[ue],ue);0<de.length&&(ee+=O)}for(var oe=0;oe<de.length;oe++){var be=(ie?ge:de[oe]).length,Ce=!1,je=ie?Object.keys(de[oe]).length===0:de[oe].length===0;if(X&&!ie&&(Ce=X==="greedy"?de[oe].join("").trim()==="":de[oe].length===1&&de[oe][0].length===0),X==="greedy"&&ie){for(var Fe=[],j=0;j<be;j++){var Ke=Z?ge[j]:j;Fe.push(de[oe][Ke])}Ce=Fe.join("").trim()===""}if(!Ce){for(var Ue=0;Ue<be;Ue++){0<Ue&&!je&&(ee+=k);var Te=ie&&Z?ge[Ue]:Ue;ee+=se(de[oe][Te],Ue)}oe<de.length-1&&(!X||0<be&&!je)&&(ee+=O)}}return ee}function se(ge,de){var X,ee;return ge==null?"":ge.constructor===Date?JSON.stringify(ge).slice(1,25):(ee=!1,V&&typeof ge=="string"&&V.test(ge)&&(ge="'"+ge,ee=!0),X=ge.toString().replace(Y,q),(ee=ee||S===!0||typeof S=="function"&&S(ge,de)||Array.isArray(S)&&S[de]||((ie,Z)=>{for(var ue=0;ue<Z.length;ue++)if(-1<ie.indexOf(Z[ue]))return!0;return!1})(X,c.BAD_DELIMITERS)||-1<X.indexOf(k)||X.charAt(0)===" "||X.charAt(X.length-1)===" ")?H+X+H:X)}},c.RECORD_SEP="",c.UNIT_SEP="",c.BYTE_ORDER_MARK="\uFEFF",c.BAD_DELIMITERS=["\r",`
|
|
4406
|
+
`,'"',c.BYTE_ORDER_MARK],c.WORKERS_SUPPORTED=!s&&!!n.Worker,c.NODE_STREAM_INPUT=1,c.LocalChunkSize=10485760,c.RemoteChunkSize=5242880,c.DefaultDelimiter=",",c.Parser=g,c.ParserHandle=b,c.NetworkStreamer=h,c.FileStreamer=u,c.StringStreamer=f,c.ReadableStreamStreamer=m,n.jQuery&&((i=n.jQuery).fn.parse=function(M){var _=M.config||{},S=[];return this.each(function(O){if(!(i(this).prop("tagName").toUpperCase()==="INPUT"&&i(this).attr("type").toLowerCase()==="file"&&n.FileReader)||!this.files||this.files.length===0)return!0;for(var H=0;H<this.files.length;H++)S.push({file:this.files[H],inputElem:this,instanceConfig:i.extend({},_)})}),R(),this;function R(){if(S.length===0)A(M.complete)&&M.complete();else{var O,H,q,G,K=S[0];if(A(M.before)){var V=M.before(K.file,K.inputElem);if(typeof V=="object"){if(V.action==="abort")return O="AbortError",H=K.file,q=K.inputElem,G=V.reason,void(A(M.error)&&M.error({name:O},H,q,G));if(V.action==="skip")return void k();typeof V.config=="object"&&(K.instanceConfig=i.extend(K.instanceConfig,V.config))}else if(V==="skip")return void k()}var Y=K.instanceConfig.complete;K.instanceConfig.complete=function(le){A(Y)&&Y(le,K.file,K.inputElem),k()},c.parse(K.file,K.instanceConfig)}}function k(){S.splice(0,1),R()}}),a&&(n.onmessage=function(M){M=M.data,c.WORKER_ID===void 0&&M&&(c.WORKER_ID=M.workerId),typeof M.input=="string"?n.postMessage({workerId:c.WORKER_ID,results:c.parse(M.input,M.config),finished:!0}):(n.File&&M.input instanceof File||M.input instanceof Object)&&(M=c.parse(M.input,M.config))&&n.postMessage({workerId:c.WORKER_ID,results:M,finished:!0})}),(h.prototype=Object.create(d.prototype)).constructor=h,(u.prototype=Object.create(d.prototype)).constructor=u,(f.prototype=Object.create(f.prototype)).constructor=f,(m.prototype=Object.create(d.prototype)).constructor=m,c})})(mc)),mc.exports}var RC=PC();const NC=My(RC);class df extends Qs{robot;static async create(){const e=new df;return await e._initAsync(),e}constructor(){super(),this.jointBuf=new lf,this.name="RBQ",this.userData.keep=!0}async _initAsync(){const e=new zc,t=new sf(e),n=Hn(As.RBQ.modelUrl);try{const i=await t.loadAsync(n);i.userData.keep=!0,i.traverse(s=>{s.userData.keep=!0}),this.robot=i,this.add(i)}catch(i){console.error(i)}}update(e){this.position.set(+e.x,+e.y,0),this.rotation.z=bt.degToRad(+e.rz)}applyPose(e){this.pushTransformSnapshot({t:performance.now()*.001,x:e.x,y:e.y,rz:e.rz})}async loadJointData(e,t=!0,n=1){const i=zv(e),s=await fetch(i).then(c=>c.text()),{data:a}=NC.parse(s,{header:!0,dynamicTyping:!0,skipEmptyLines:!0}),o=a.sort((c,d)=>c.time-d.time),l=performance.now()/1e3;for(const c of o){const{time:d,...h}=c,u=h,f=l+d/n;t?setTimeout(()=>this.pushJointsSnapshot(u,f),d/n*1e3):this.pushJointsSnapshot(u,f)}}applyJointValues(e){this.robot?.setJointValues(e)}}class hf extends Qs{static async create(){const e=new hf;return await e._initAsync(),e}constructor(){super(),this.name="SEM",this.userData.keep=!0}update(e){}applyPose(e){if(!e)return;const t={t:performance.now()*.001,x:e.x,y:e.y,rz:e.rz};this.pushTransformSnapshot(t)}async _initAsync(){const i=new Jt(1.1044,.7484,.537,10,1,1),s=new Ne(65535),a=new Ne(16711680),o=[],l=-1.1044/2,c=1.1044/2,d=l+(c-l)*(2/3);for(let b=0;b<i.attributes.position.count;b++){const p=new I;p.fromBufferAttribute(i.attributes.position,b);const g=p.x>=d?a:s;o.push(g.r,g.g,g.b)}i.setAttribute("color",new ke(o,3));const h=new jt({vertexColors:!0,transparent:!0,opacity:.65,depthWrite:!1,side:Si}),u=new Ee(i,h);u.position.set(0,0,.2685),u.userData.keep=!0,u.renderOrder=1;const f=new Fc(i),m=new Ks(f,new zn({color:16777215}));m.renderOrder=2,m.userData.keep=!0,u.add(m),this.add(u)}}class uf extends Qs{static async create(){const e=new uf;return await e._initAsync(),e}constructor(){super(),this.name="SEC",this.userData.keep=!0}update(e){}applyPose(e){if(!e)return;const t={t:performance.now()*.001,x:e.x,y:e.y,rz:e.rz};this.pushTransformSnapshot(t)}async _initAsync(){const i=new Jt(1.1044,.7484,.537,10,1,1),s=new Ne(65535),a=new Ne(16711680),o=[],l=-1.1044/2,c=1.1044/2,d=l+(c-l)*(2/3);for(let b=0;b<i.attributes.position.count;b++){const p=new I;p.fromBufferAttribute(i.attributes.position,b);const g=p.x>=d?a:s;o.push(g.r,g.g,g.b)}i.setAttribute("color",new ke(o,3));const h=new jt({vertexColors:!0,transparent:!0,opacity:.65,depthWrite:!1,side:Si}),u=new Ee(i,h);u.position.set(0,0,.2685),u.userData.keep=!0,u.renderOrder=1;const f=new Fc(i),m=new Ks(f,new zn({color:16777215}));m.renderOrder=2,m.userData.keep=!0,u.add(m),this.add(u)}}class Ec extends Qs{static async create(){const e=new Ec;return await e._initAsync(),e}constructor(){super(),this.name="FallbackRobot",this.userData.keep=!0}update(e){}applyPose(e){if(!e)return;const t={t:performance.now()*.001,x:e.x,y:e.y,rz:e.rz};this.pushTransformSnapshot(t)}async _initAsync(){const i=new Jt(1.1044,.7484,.537,10,1,1),s=new Ne(65535),a=new Ne(16711680),o=[],l=-1.1044/2,c=1.1044/2,d=l+(c-l)*(2/3);for(let b=0;b<i.attributes.position.count;b++){const p=new I;p.fromBufferAttribute(i.attributes.position,b);const g=p.x>=d?a:s;o.push(g.r,g.g,g.b)}i.setAttribute("color",new ke(o,3));const h=new jt({vertexColors:!0,transparent:!0,opacity:.65,depthWrite:!1,side:Si}),u=new Ee(i,h);u.position.set(0,0,.2685),u.userData.keep=!0,u.renderOrder=1;const f=new Fc(i),m=new Ks(f,new zn({color:16777215}));m.renderOrder=2,m.userData.keep=!0,u.add(m),this.add(u)}}class ff extends Qs{static async create(){const e=new ff;return await e._initAsync(),e}constructor(){super(),this.name="GAIA",this.userData.keep=!0}async _initAsync(){const e=new Ar,t=new Oo,n=Hn(As.GAIA.modelUrl);t.setDecoderPath(Hn("/draco/")),e.setDRACOLoader(t);try{const s=(await e.loadAsync(n)).scene;s.renderOrder=mn.ROBOT;const a=new Vt;a.add(s),a.traverse(o=>{if(o.userData.keep=!0,!(o instanceof Ee))return;const l=c=>{const d=new Fn;return"color"in c&&c.color instanceof Ne&&d.color.copy(c.color),"map"in c&&c.map instanceof Ut&&(d.map=c.map),"transparent"in c&&(d.transparent=c.transparent),"opacity"in c&&(d.opacity=c.opacity),"side"in c&&(d.side=c.side),d};Array.isArray(o.material)?o.material=o.material.map(l):o.material=l(o.material)}),this.alignToGroundZUp(s),a.rotation.z=Math.PI,this.add(a)}catch(i){i instanceof Error?console.error("GAIA Load Failed:",i.message):console.error("GAIA Load Failed:",i)}finally{t.dispose()}}update(e){this.position.set(Number(e.x),Number(e.y),0),this.rotation.z=bt.degToRad(Number(e.rz))}applyPose(e){if(!e)return;const t={t:performance.now()*.001,x:e.x,y:e.y,rz:e.rz};this.pushTransformSnapshot(t)}}class pf extends Qs{static async create(){const e=new pf;return await e._initAsync(),e}constructor(){super(),this.name="QD",this.userData.keep=!0}async _initAsync(){const e=new Ar,t=new Oo,n=Hn(As.QD.modelUrl);t.setDecoderPath(Hn("/draco/")),e.setDRACOLoader(t);try{const s=(await e.loadAsync(n)).scene;s.renderOrder=mn.ROBOT;const a=new Vt;a.add(s),a.traverse(o=>{o.userData.keep=!0}),this.alignToGroundZUp(s),this.add(a)}catch(i){i instanceof Error?console.error("QD Load Failed:",i.message):console.error("QD Load Failed:",i)}finally{t.dispose()}}update(e){this.position.set(Number(e.x),Number(e.y),0),this.rotation.z=bt.degToRad(Number(e.rz))}applyPose(e){if(!e)return;const t={t:performance.now()*.001,x:e.x,y:e.y,rz:e.rz};this.pushTransformSnapshot(t)}}const Zm={rby1a:{name:"RBY1-A",urdfPath:"/rby1a/rby1a.urdf"},rby1m:{name:"RBY1-M",urdfPath:"/rby1m/rby1m.urdf"},rby1ub:{name:"RBY1-UB",urdfPath:"/rby1ub/rby1ub.urdf"},rby2c:{name:"RBY2-C",urdfPath:"/rby2c/rby2c.urdf"}};class mf extends Qs{robot;variant;static async create(e="rby1m"){const t=new mf(e);return await t._initAsync(),t}constructor(e){super(),this.variant=e,this.jointBuf=new lf,this.name=Zm[e].name,this.userData.keep=!0}async _initAsync(){const e=Zm[this.variant],t=Hn(e.urdfPath);await new Promise(n=>{const i=new zc,s=new sf(i);let a=null,o=!1;const l=()=>{o||(o=!0,n())};s.loadMeshCb=sv,i.onLoad=()=>{if(!o){if(!a){l();return}a.userData.keep=!0,a.traverse(c=>{c.userData.keep=!0}),this.robot=a,this.alignToGroundZUp(a),this.add(a),l()}},i.onError=c=>{o||(console.warn(`[RBY] Load failed: ${c}`),l())},s.load(t,c=>{o||(a=c)},void 0,c=>{o||(c instanceof Error?console.error(`RBY Load Failed (${this.variant}):`,c.message):console.error(`RBY Load Failed (${this.variant}):`,c),l())})})}update(e){this.position.set(Number(e.x),Number(e.y),0),this.rotation.z=bt.degToRad(Number(e.rz))}applyPose(e){if(!e)return;const t={t:performance.now()*.001,x:e.x,y:e.y,rz:e.rz};this.pushTransformSnapshot(t)}applyJointValues(e){this.robot?.setJointValues(e)}}const Ym=["#0087fc","#f77468","#f37a32","#dc8932","#ca9232","#bb9832","#ae9d31","#9fa131","#8ea631","#77ab31","#50b131","#32b25c","#33b07a","#34af8c","#35ae99","#36ada4","#36acae","#37aab9","#38a9c5","#39a7d5","#3ba3ec","#6e9bf4","#9591f4","#b287f4","#cc7af4","#e866f4","#f560e4","#f565cc","#f66ab7","#f66da2"];class DC{editor;mainRobot=null;rbq;s100;robotMap;previousUpdateTime;availableColors;constructor(e){this.editor=e,this.s100=null,this.rbq=null,this.robotMap=new Map,this.previousUpdateTime=Date.now(),this.availableColors=[...Ym]}registerEventListeners(){this.editor.eventHandler.eventBus.on("ui:initial-view-set-up",this.handleSetUpInitialView)}deregisterEventListeners(){this.editor.eventHandler.eventBus.off("ui:initial-view-set-up",this.handleSetUpInitialView)}addLabel(e){const t=document.createElement("div");t.className="nodeLabel",t.textContent=e.name,t.style.color="white",t.style.backgroundColor="transparent",t.style.position="absolute",t.style.fontSize="6.5px",t.style.zIndex="-999";const n=new Hs(t);n.userData.keep=!0,n.userData.labelType="robot",n.name="label",n.center.set(0,-.5),e.add(n)}count(){return this.robotMap.size}dispose(){this.rbq=null,this.s100=null,this.mainRobot=null}async loadMainRobot(e){if(this.mainRobot||!this.editor.scene)return;let t=null;switch(e){case"S100":case"S100-A":case"S100-A-3D":case"S100-B":case"S100-B-3D":t=await cf.create(),this.s100=t;break;case"RBQ":t=await df.create(),this.rbq=t;break;case"SEM":t=await hf.create();break;case"SEC":t=await uf.create();break;case"D400":case"D400_NEW":case"DD-SEC_EE":t=await Ec.create();break;case"QD":t=await ff.create();break;case"rby1a":case"rby1m":case"rby1ub":case"rby2c":t=await mf.create(e);break;case"QD-RBY":t=await pf.create();break;default:t=await Ec.create();break}t&&(this.mainRobot=t,this.editor.scene.add(this.mainRobot),this.robotMap.set("mainRobot",this.mainRobot),this.editor.eventHandler.eventBus.emit("robot-manager:main-robot-loaded"))}update=(e,t)=>{e.visible?(e.position.set(t.x,t.y,e.position.z),e.rotation.z=t.rz*Math.PI/180):(e.position.set(t.x,t.y,0),e.rotation.z=t.rz,e.visible=!0)};updateAll(e){this.mainRobot?.tick(e)}addAxesHelper(e){const t=new Da(1e3);t.userData.keep=!0,e.add(t)}cloneEdgeLine(e,t){const n=e.getObjectByName("edgeLine"),i=t.getObjectByName("edgeLine");n&&i&&(i.material=n.material.clone())}cloneRobot(e){const t=e.clone();t.name="robot";const n=e.material.clone();return n.color=new Ne(this.getUniqueColor()),t.material=n,t}getUniqueColor(){return this.availableColors.length===0&&(this.availableColors=[...Ym]),this.availableColors.splice(0,1)[0]}handleSetUpInitialView=e=>{if(!this.mainRobot)return;const t={x:Number(e.x),y:Number(e.y),z:0},n=Number(e.rz)*Math.PI/180;this.mainRobot.position.copy(t),this.mainRobot.rotation.z=n}}class LC{_selected=null;_selectableObjects=[];_selectableLinks=[];_selectableZones=[];_selectableZoneVertices=[];_selectedObjects=[];_selectedLinks=[];_focusedLinkId=null;_selectedZones=[];_focusedZoneId=null;_selectedZoneVertex=null;getSelected(){return this._selected}setSelected(e){this._selected=e}getSelectableObjects(){return this._selectableObjects}setSelectableObjects(e){this._selectableObjects=e}registerSelectable(e){this._selectableObjects.push(e)}getSelectableLinks(){return this._selectableLinks}registerSelectableLink(e){this._selectableLinks.push(e)}getSelectableZones(){return this._selectableZones}registerSelectableZone(e){this._selectableZones.push(e)}getSelectableZoneVertices(){return this._selectableZoneVertices}registerSelectableZoneVertex(e){this._selectableZoneVertices.push(e)}unregisterSelectableZoneVertex(e){const t=this._selectableZoneVertices.indexOf(e);t>-1&&this._selectableZoneVertices.splice(t,1),this._selectedZoneVertex===e&&(this._selectedZoneVertex=null)}unregisterSelectableZone(e){const t=this._selectableZones.indexOf(e);t>-1&&this._selectableZones.splice(t,1),this._selectedZones=this._selectedZones.filter(n=>n!==e),this.syncFocusedZoneId()}unregisterSelectableLink(e){const t=this._selectableLinks.indexOf(e);t>-1&&this._selectableLinks.splice(t,1),this._selectedLinks=this._selectedLinks.filter(n=>n!==e),this.syncFocusedLinkId()}unregisterSelectable(e){const t=this._selectableObjects.indexOf(e);t>-1&&this._selectableObjects.splice(t,1);const n=this._selectedObjects.indexOf(e);n>-1&&this._selectedObjects.splice(n,1)}replaceSelectable(e,t){const n=this._selectableObjects.indexOf(e);n>-1&&(this._selectableObjects[n]=t)}replaceSelected(e,t){this._selectedObjects=this._selectedObjects.map(n=>n===e?t:n),this._selected===e&&(this._selected=t)}isSelectable(e){return this._selectableObjects.includes(e)}getSelectedObjects(){return this._selectedObjects}setSelectedObjects(e){this._selectedObjects=e}getSelectedLinks(){return this._selectedLinks}setSelectedLinks(e){this._selectedLinks=e,this.syncFocusedLinkId()}getFocusedLinkId(){return this._focusedLinkId}setFocusedLinkId(e){if(e===null){this._focusedLinkId=null;return}this._focusedLinkId=this._selectedLinks.some(t=>String(t.userData.linkId)===e)?e:this._selectedLinks[0]?String(this._selectedLinks[0].userData.linkId):null}getSelectedZones(){return this._selectedZones}setSelectedZones(e){this._selectedZones=e,this.syncFocusedZoneId()}getFocusedZoneId(){return this._focusedZoneId}setFocusedZoneId(e){if(e===null){this._focusedZoneId=null;return}this._focusedZoneId=this._selectedZones.some(t=>String(t.userData.zoneId)===e)?e:this._selectedZones[0]?String(this._selectedZones[0].userData.zoneId):null}getSelectedZoneVertex(){return this._selectedZoneVertex}setSelectedZoneVertex(e){this._selectedZoneVertex=e}clearLinkSelection(){this._selectedLinks=[],this._focusedLinkId=null}clearZoneSelection(){this._selectedZones=[],this._focusedZoneId=null}clearZoneVertexSelection(){this._selectedZoneVertex=null}clearSelection(){this._selected=null,this._selectedObjects=[],this._selectedLinks=[],this._focusedLinkId=null,this._selectedZones=[],this._focusedZoneId=null,this._selectedZoneVertex=null}reset(){this.clearSelection(),this._selectableObjects=[],this._selectableLinks=[],this._selectableZones=[],this._selectableZoneVertices=[]}syncFocusedLinkId(){if(this._selectedLinks.length===0){this._focusedLinkId=null;return}this._focusedLinkId&&this._selectedLinks.some(e=>String(e.userData.linkId)===this._focusedLinkId)||(this._focusedLinkId=String(this._selectedLinks[0].userData.linkId))}syncFocusedZoneId(){if(this._selectedZones.length===0){this._focusedZoneId=null;return}this._focusedZoneId&&this._selectedZones.some(e=>String(e.userData.zoneId)===this._focusedZoneId)||(this._focusedZoneId=String(this._selectedZones[0].userData.zoneId))}}class IC{editor;_raycaster;_invMat=new Ie;mouse=new me;selectionRect=new Ws;constructor(e){this.editor=e,this._raycaster=new tf,this._raycaster.params.Points.threshold=.5}get pointsThreshold(){return this._raycaster.params.Points.threshold}set pointsThreshold(e){e<=0||(this._raycaster.params.Points.threshold=e)}dispose(){this.deregisterEvents()}deregisterEvents(){const e=this.editor.eventHandler.eventBus;e.off("viewport:intersections-detected",this.handleIntersectionsDetected),e.off("selector:box-intersections-detected",this.handleBoxIntersectionsDetected),e.off("editor:object-removed",this.handleObjectRemoved),e.off("ui:selection-reset-requested",this.handleSelectionReset),e.off("ui:node-selected",this.handleNodeSelectedFromUI),e.off("eraser:radius-changed",this.handleEraserRadiusChanged)}getSelectionBoxIntersects(e,t,n){this.selectionRect.min=new me(Math.min(t.x,n.x),Math.min(t.y,n.y)),this.selectionRect.max=new me(Math.max(t.x,n.x),Math.max(t.y,n.y));const i=[],s=this.editor.selectionManager.getSelectableObjects(),a=s.length;for(let l=0;l<a;l++){const c=s[l],d=this.toScreenPosition(e,c),h=new me(d.x,d.y);this.selectionRect.containsPoint(h)&&i.push(c)}return this.getSortedIntersects(i)}getPointerPlaneIntersection(e,t){return this.mouse.set(e.x*2-1,-(e.y*2)+1),this._raycaster.setFromCamera(this.mouse,t),this.computeGlobalPlaneIntersection(this._raycaster)}getPointerObjectIntersections(e,t){return this.mouse.set(e.x*2-1,-(e.y*2)+1),this._raycaster.setFromCamera(this.mouse,t),this.computeObjectIntersects(this._raycaster)}getPointerZoneDraftVertexIntersection(e,t){this.mouse.set(e.x*2-1,-(e.y*2)+1),this._raycaster.setFromCamera(this.mouse,t);const n=this._raycaster.intersectObjects(this.editor.selectionManager.getSelectableZoneVertices(),!0);return this.resolveZoneDraftVertexHit(n)}getPointerOctreeIntersections(e,t){return this.mouse.set(e.x*2-1,-(e.y*2)+1),this._raycaster.setFromCamera(this.mouse,t),this.computeOctreePointIntersections(this._raycaster,t)}getPointerQuadTreeIntersections(e,t){return this.mouse.set(e.x*2-1,-(e.y*2)+1),this._raycaster.setFromCamera(this.mouse,t),this.computeQuadtreePointIntersections(this._raycaster,t)}getPointerMapBrushIntersections(e,t){this.mouse.set(e.x*2-1,-(e.y*2)+1),this._raycaster.setFromCamera(this.mouse,t);const n=this.computeGlobalPlaneIntersection(this._raycaster);return n.length?this.computeQuadtreeXYBrushIntersections(n[0].point,this._raycaster.params.Points.threshold??1,t):[]}getPointerNearestPointIntersection(e,t){return this.mouse.set(e.x*2-1,-(e.y*2)+1),this._raycaster.setFromCamera(this.mouse,t),this.computeNearestPointIntersect(this._raycaster,t)}registerEventListeners(){const e=this.editor.eventHandler.eventBus;e.on("viewport:intersections-detected",this.handleIntersectionsDetected),e.on("selector:box-intersections-detected",this.handleBoxIntersectionsDetected),e.on("editor:object-removed",this.handleObjectRemoved),e.on("ui:selection-reset-requested",this.handleSelectionReset),e.on("ui:node-selected",this.handleNodeSelectedFromUI),e.on("eraser:radius-changed",this.handleEraserRadiusChanged)}accumulateOctreeIntersections(e,t,n,i,s){if(e.intersectsBox(t.boundary))if(t.divided)for(const a of t.children)this.accumulateOctreeIntersections(e,a,n,i,s);else for(const{position:a,index:o}of t.points){const l=e.distanceToPoint(a);if(l<=n){const c=i.position.distanceTo(a);s.push({point:a.clone(),index:o,distance:l,cameraDist:c})}}}computeGlobalPlaneIntersection(e){return e.intersectObject(this.editor.globalPlane)}computeNearestPointIntersect(e,t){const n=e.ray,i=this.editor.pointsManager.pointsOctree;return this.findNearestOctreeIntersection(n,i,e.params.Points.threshold,t)}computeObjectIntersects(e){const t=[...this.editor.selectionManager.getSelectableZoneVertices(),...this.editor.selectionManager.getSelectableObjects(),...this.editor.selectionManager.getSelectableLinks().filter(n=>n.visible),...this.editor.selectionManager.getSelectableZones()];return e.intersectObjects(t,!0)}computeOctreePointIntersections(e,t){const n=e.ray,i=[],s=this.editor.pointsManager.pointsOctree;return this.accumulateOctreeIntersections(n,s,e.params.Points.threshold,t,i),i}findNearestOctreeIntersection(e,t,n,i){if(!e.intersectsBox(t.boundary))return null;let s=null;if(t.divided)for(const a of t.children){const o=this.findNearestOctreeIntersection(e,a,n,i);o!==null&&(s===null||o.cameraDist<s.cameraDist)&&(s=o)}else for(const{position:a,index:o}of t.points){const l=e.distanceToPoint(a);if(l<=n){const c=i.position.distanceTo(a);(s===null||c<s.cameraDist)&&(s={point:a.clone(),index:o,distance:l,cameraDist:c})}}return s}getSortedIntersects(e){return e.sort((t,n)=>{const i=t.position.x-n.position.x;return i!==0?i:n.position.y-t.position.y}),e}handleBoxIntersectionsDetected=e=>{const{intersections:t,action:n}=e;this.clearLinkSelection(),this.clearZoneSelection(),this.select(null),this.multiSelect(t,n)};handleIntersectionsDetected=e=>{const{action:t,intent:n,intersections:i}=e,s=this.resolveSelectionHit(i);if(!s){if(n==="add"||n==="remove")return;this.clearZoneVertexSelection(),this.clearLinkSelection(),this.clearZoneSelection(),this.select(null);return}if(s.kind==="zone-draft-vertex"){this.clearLinkSelection(),this.clearZoneSelection(),this.select(null),this.selectZoneDraftVertex(s.vertex,s.vertexIndex);return}if(s.kind==="links"){this.clearZoneVertexSelection(),this.clearZoneSelection(),this.editor.selectionManager.setSelectedLinks(s.arrows),this.editor.eventHandler.eventBus.emit("selector:link-selected",{linkIds:s.linkIds}),this.select(null);return}if(s.kind==="zones"){this.clearZoneVertexSelection(),this.clearLinkSelection(),this.editor.selectionManager.setSelectedZones(s.zones),this.select(null),this.editor.eventHandler.eventBus.emit("selector:zone-selected",{zoneIds:s.zoneIds});return}this.clearZoneVertexSelection(),this.clearLinkSelection(),this.clearZoneSelection(),this.select(s.object,t,n)};handleNodesCopied=e=>{this.select(null),this.multiSelect(e,"inspect")};handleObjectRemoved=()=>{this.clearZoneVertexSelection(),this.clearLinkSelection(),this.clearZoneSelection(),this.select(null)};multiSelect=(e,t)=>{const n=this.editor.selectionManager,i=[...n.getSelectedObjects()],s=e[e.length-1]??null;n.setSelected(s),n.setSelectedObjects(e),this.editor.eventHandler.eventBus.emit("selector:object-selected",{object:s,prevSelected:i,selectedObjects:[...e],action:t})};select=(e,t,n="replace")=>{const i=this.editor.selectionManager,s=i.getSelectedObjects();if(n==="replace"&&e!==null&&s.length===1&&s[0]===e)return;const o=e?n==="add"?[...s.filter(d=>d!==e),e]:n==="remove"?s.filter(d=>d!==e):[e]:[];if(n==="remove"&&e!==null&&s.length===o.length){const d=i.getSelected();this.editor.eventHandler.eventBus.emit("selector:object-selected",{object:d,prevSelected:[...s],selectedObjects:[...s],action:t});return}const l=o[o.length-1]??null;i.setSelected(l);const c={object:l,prevSelected:[...s],selectedObjects:[...o],action:t};this.editor.eventHandler.eventBus.emit("selector:object-selected",c),i.setSelectedObjects(o)};toScreenPosition(e,t){const n=e.getBoundingClientRect(),i=new I;return t.updateMatrixWorld(),i.setFromMatrixPosition(t.matrixWorld),i.project(this.editor.camera),{x:(i.x+1)/2*n.width+n.left,y:(-i.y+1)/2*n.height+n.top}}computeQuadtreePointIntersections(e,t){const n=[],i=this.editor.pointsManager.pointsQuadTree;if(!i)return n;const s=e.params.Points.threshold??1;return this.accumulateQuadtreeIntersections(e.ray,i,s,t,n),n}computeQuadtreeXYBrushIntersections(e,t,n){const i=[],s=this.editor.pointsManager.pointsQuadTree;if(!s)return i;const a=new Ws(new me(e.x-t,e.y-t),new me(e.x+t,e.y+t));return this.accumulateQuadtreeXYBrushIntersections(e,t,a,s,n,i),i}_visualizeRay(e,t,n,i=30,s=65535){const a=new G_(t,e,i,s,.3,.3);n.add(a)}accumulateQuadtreeIntersections(e,t,n,i,s){const a=t.boundary.clone().expandByScalar(n),o=new Yt(new I(a.min.x,a.min.y,-n),new I(a.max.x,a.max.y,n));if(e.intersectsBox(o))if(t.divided)for(const l of t.children)this.accumulateQuadtreeIntersections(e,l,n,i,s);else for(const{position:l,index:c}of t.points){const d=e.distanceToPoint(l);if(d<=n){const h=i.position.distanceTo(l);s.push({point:l.clone(),index:c,distance:d,cameraDist:h})}}}accumulateQuadtreeXYBrushIntersections(e,t,n,i,s,a){if(!i.boundary.intersectsBox(n))return;const o=t*t;if(i.divided)for(const l of i.children)this.accumulateQuadtreeXYBrushIntersections(e,t,n,l,s,a);else for(const{position:l,index:c}of i.points){const d=l.x-e.x,h=l.y-e.y,u=d*d+h*h;if(u<=o){const f=Math.sqrt(u),m=s.position.distanceTo(l);a.push({point:l.clone(),index:c,distance:f,cameraDist:m})}}}handleSelectionReset=()=>{this.clearZoneVertexSelection(),this.clearLinkSelection(),this.clearZoneSelection(),this.select(null)};handleNodeSelectedFromUI=({nodeId:e,intent:t})=>{const n=this.editor.scene.getObjectByProperty("uuid",e);if(!n)return;const i=n;this.clearZoneVertexSelection(),this.clearLinkSelection(),this.clearZoneSelection(),this.select(i,"select",t)};handleEraserRadiusChanged=e=>{this._raycaster.params.Points.threshold=e};clearLinkSelection(){this.editor.selectionManager.clearLinkSelection(),this.editor.eventHandler.eventBus.emit("selector:link-selected",{linkIds:[]})}clearZoneSelection(){this.editor.selectionManager.clearZoneSelection(),this.editor.eventHandler.eventBus.emit("selector:zone-selected",{zoneIds:[]})}clearZoneVertexSelection(){this.editor.selectionManager.clearZoneVertexSelection(),this.editor.eventHandler.eventBus.emit("selector:zone-draft-vertex-selected",{vertex:null,vertexIndex:null})}selectZoneDraftVertex(e,t){this.editor.selectionManager.setSelectedZoneVertex(e),this.editor.eventHandler.eventBus.emit("selector:zone-draft-vertex-selected",{vertex:e,vertexIndex:t})}resolveSelectionHit(e){const t=this.resolveZoneDraftVertexHit(e);if(t)return{kind:"zone-draft-vertex",vertex:t.mesh,vertexIndex:t.vertexIndex};for(let s=0;s<e.length;s++){const a=e[s].object;if(this.editor.selectionManager.isSelectable(a))return{kind:"node",object:a}}const n=this.resolveLinkHits(e);if(n.length>0)return{kind:"links",arrows:n,linkIds:n.map(s=>String(s.userData.linkId))};const i=this.resolveZoneHits(e);return i.length>0?{kind:"zones",zones:i,zoneIds:i.map(s=>String(s.userData.zoneId))}:null}resolveLinkHits(e){const t=new Map;for(let n=0;n<e.length;n++){const i=this.resolveLinkHit(e[n].object);if(!i)continue;const s=String(i.userData.linkId);t.has(s)||t.set(s,i)}return[...t.values()]}resolveLinkHit(e){const t=e.userData.objectType,n=e.userData.arrowOwner,i=e.userData.linkId??n?.userData.linkId;return(t==="topology-link-hit-area"||t==="topology-link-part")&&n&&n.visible&&i?n:null}resolveZoneHits(e){const t=new Map;for(let n=0;n<e.length;n++){const i=this.resolveZoneHit(e[n].object);if(!i)continue;const s=String(i.userData.zoneId);t.has(s)||t.set(s,i)}return[...t.values()]}resolveZoneHit(e){const t=e.userData.objectType,n=e.userData.zoneId;return t==="topology-zone-hit-area"&&n?e:null}resolveZoneDraftVertexHit(e){for(let t=0;t<e.length;t++){const n=e[t].object;if(!this.editor.selectionManager.getSelectableZoneVertices().includes(n))continue;const i=n.userData.vertexIndex;if(typeof i=="number")return{mesh:n,vertexIndex:i}}return null}}/*! *****************************************************************************
|
|
4407
4407
|
Copyright (c) Microsoft Corporation.
|
|
4408
4408
|
|
|
4409
4409
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -4739,7 +4739,7 @@ PERFORMANCE OF THIS SOFTWARE.
|
|
|
4739
4739
|
|
|
4740
4740
|
#endif
|
|
4741
4741
|
|
|
4742
|
-
}`};class nP extends Ia{constructor(){super();const e=tP;this.uniforms=Ca.clone(e.uniforms),this.material=new f_({name:e.name,uniforms:this.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader}),this.fsQuad=new bf(this.material),this._outputColorSpace=null,this._toneMapping=null}render(e,t,n){this.uniforms.tDiffuse.value=n.texture,this.uniforms.toneMappingExposure.value=e.toneMappingExposure,(this._outputColorSpace!==e.outputColorSpace||this._toneMapping!==e.toneMapping)&&(this._outputColorSpace=e.outputColorSpace,this._toneMapping=e.toneMapping,this.material.defines={},ft.getTransfer(this._outputColorSpace)===Ht&&(this.material.defines.SRGB_TRANSFER=""),this._toneMapping===Jg?this.material.defines.LINEAR_TONE_MAPPING="":this._toneMapping===eb?this.material.defines.REINHARD_TONE_MAPPING="":this._toneMapping===tb?this.material.defines.CINEON_TONE_MAPPING="":this._toneMapping===nb?this.material.defines.ACES_FILMIC_TONE_MAPPING="":this._toneMapping===sb?this.material.defines.AGX_TONE_MAPPING="":this._toneMapping===rb?this.material.defines.NEUTRAL_TONE_MAPPING="":this._toneMapping===ib&&(this.material.defines.CUSTOM_TONE_MAPPING=""),this.material.needsUpdate=!0),this.renderToScreen===!0?(e.setRenderTarget(null),this.fsQuad.render(e)):(e.setRenderTarget(t),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),this.fsQuad.render(e))}dispose(){this.material.dispose(),this.fsQuad.dispose()}}class iP extends Ia{constructor(e,t,n=null,i=null,s=null){super(),this.scene=e,this.camera=t,this.overrideMaterial=n,this.clearColor=i,this.clearAlpha=s,this.clear=!0,this.clearDepth=!1,this.needsSwap=!1,this._oldClearColor=new Ne}render(e,t,n){const i=e.autoClear;e.autoClear=!1;let s,a;this.overrideMaterial!==null&&(a=this.scene.overrideMaterial,this.scene.overrideMaterial=this.overrideMaterial),this.clearColor!==null&&(e.getClearColor(this._oldClearColor),e.setClearColor(this.clearColor,e.getClearAlpha())),this.clearAlpha!==null&&(s=e.getClearAlpha(),e.setClearAlpha(this.clearAlpha)),this.clearDepth==!0&&e.clearDepth(),e.setRenderTarget(this.renderToScreen?null:n),this.clear===!0&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),e.render(this.scene,this.camera),this.clearColor!==null&&e.setClearColor(this._oldClearColor),this.clearAlpha!==null&&e.setClearAlpha(s),this.overrideMaterial!==null&&(this.scene.overrideMaterial=a),e.autoClear=i}}var mo=function(){var r=0,e=document.createElement("div");e.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",e.addEventListener("click",function(d){d.preventDefault(),n(++r%e.children.length)},!1);function t(d){return e.appendChild(d.dom),d}function n(d){for(var h=0;h<e.children.length;h++)e.children[h].style.display=h===d?"block":"none";r=d}var i=(performance||Date).now(),s=i,a=0,o=t(new mo.Panel("FPS","#0ff","#002")),l=t(new mo.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var c=t(new mo.Panel("MB","#f08","#201"));return n(0),{REVISION:16,dom:e,addPanel:t,showPanel:n,begin:function(){i=(performance||Date).now()},end:function(){a++;var d=(performance||Date).now();if(l.update(d-i,200),d>=s+1e3&&(o.update(a*1e3/(d-s),100),s=d,a=0,c)){var h=performance.memory;c.update(h.usedJSHeapSize/1048576,h.jsHeapSizeLimit/1048576)}return d},update:function(){i=this.end()},domElement:e,setMode:n}};mo.Panel=function(r,e,t){var n=1/0,i=0,s=Math.round,a=s(window.devicePixelRatio||1),o=80*a,l=48*a,c=3*a,d=2*a,h=3*a,u=15*a,f=74*a,m=30*a,b=document.createElement("canvas");b.width=o,b.height=l,b.style.cssText="width:80px;height:48px";var p=b.getContext("2d");return p.font="bold "+9*a+"px Helvetica,Arial,sans-serif",p.textBaseline="top",p.fillStyle=t,p.fillRect(0,0,o,l),p.fillStyle=e,p.fillText(r,c,d),p.fillRect(h,u,f,m),p.fillStyle=t,p.globalAlpha=.9,p.fillRect(h,u,f,m),{dom:b,update:function(g,y){n=Math.min(n,g),i=Math.max(i,g),p.fillStyle=t,p.globalAlpha=1,p.fillRect(0,0,o,u),p.fillStyle=e,p.fillText(s(g)+" "+r+" ("+s(n)+"-"+s(i)+")",c,d),p.drawImage(b,h+a,u,f-a,m,h,u,f-a,m),p.fillRect(h+f-a,u,a,m),p.fillStyle=t,p.globalAlpha=.9,p.fillRect(h+f-a,u,a,s((1-g/y)*m))}}};const Qm=16,Jm=.85,sP=.9;class rP{domElement;orbit;constructor({domElement:e,orbit:t}){this.domElement=e,this.orbit=t}attach(){this.domElement.addEventListener("wheel",this.handleWheel,{passive:!1,capture:!0})}detach(){this.domElement.removeEventListener("wheel",this.handleWheel,!0)}handleWheel=e=>{if(e.target!==this.domElement||!this.orbit.enabled||!this.isTrackpadWheelEvent(e)||e.ctrlKey)return;e.preventDefault(),e.stopImmediatePropagation();const{deltaX:t,deltaY:n}=this.normalizeWheelDelta(e);if(e.shiftKey){if(!this.orbit.enableRotate)return;this.rotateFromTrackpad(t,n);return}this.panFromTrackpad(t,n)};isTrackpadWheelEvent=e=>e.deltaMode!==WheelEvent.DOM_DELTA_PIXEL?!1:Math.abs(e.deltaX)>0;normalizeWheelDelta=e=>{if(e.deltaMode===WheelEvent.DOM_DELTA_LINE)return{deltaX:e.deltaX*Qm,deltaY:e.deltaY*Qm};if(e.deltaMode===WheelEvent.DOM_DELTA_PAGE){const t=this.domElement.clientHeight||window.innerHeight;return{deltaX:e.deltaX*t,deltaY:e.deltaY*t}}return{deltaX:e.deltaX,deltaY:e.deltaY}};panFromTrackpad=(e,t)=>{const n=this.orbit;n._pan(-e*Jm,-t*Jm),n.update()};rotateFromTrackpad=(e,t)=>{const n=2*Math.PI/this.domElement.clientHeight*this.orbit.rotateSpeed*sP,i=this.orbit;i._rotateLeft(-e*n),i._rotateUp(-t*n),i.update()}}const aP=200,oP=3,lP=4,cP=20,dP=6,eg=1,hP=.15,Ja=1e-6,tg=[1,3,6,12,20,40],Zl=["text-7xl","text-5xl","text-4xl","text-base","text-sm","text-xs","hidden"];class uP{constructor(e){this.editor=e}_renderCSS2D;container;scene;sceneHelpers;camera;renderer;css2DRenderer;effectComposer;selectedNodeOutlinePass;activeNodeOutlinePass;robotPos=new I;robotQuat=new Lt;lookOffset=new I;robotForward=new I;PRIMARY_MOUSE_BUTTON=0;tmpView=new I;onDownPosition=new me;onMovePosition=new me;onUpPosition=new me;onDownPx=new me;onUpPx=new me;startPoint=new me;endPoint=new me;fwd=new I;right=new I;up=new I;delta=new I;focusBox=new Yt;focusCenter=new I;focusSphere=new vn;focusDirection=new I;activePointId=null;pointerDownTime=0;isBoxSelectGestureActive=!1;pointerSelectionIntent="replace";control;arcball;orbit;trackpadOrbitController;transformControls;boxSelectHelper;labels;clock;grid;stats=null;resizeObserver=null;pendingResize=!1;resizeWidth;resizeHeight;interactionTimer;pointerAction="inspect";zoneDraftState="idle";zoneDraftEditingZoneId=null;transformDragStart=null;currentCameraMode="perspective";lastPerspectiveCameraState=null;getCameraState(){return!this.camera||!this.orbit?null:{position:{x:this.camera.position.x,y:this.camera.position.y,z:this.camera.position.z},target:{x:this.orbit.target.x,y:this.orbit.target.y,z:this.orbit.target.z}}}setCameraState(e){!this.camera||!this.orbit||(this.camera.position.set(e.position.x,e.position.y,e.position.z),this.orbit.target.set(e.target.x,e.target.y,e.target.z),this.orbit.update(),this.emitCameraChanged())}emitCameraChanged(){const e=this.getCameraState();e&&this.editor.eventHandler.eventBus.emit("viewport:camera-changed",e)}get renderCSS2D(){return this._renderCSS2D}set renderCSS2D(e){this._renderCSS2D=e}initialize(){this._renderCSS2D=!1,this.scene=this.editor.scene,this.sceneHelpers=this.editor.sceneHelpers,this.camera=this.editor.camera,this.labels=[],this.clock=new Qu;const e=this.editor.canvas;if(!e)throw new Error("[Viewport] Canvas is not ready");const t=ZA(e,"Viewport");if(this.renderer=new TE({antialias:!0,canvas:e,alpha:!0}),this.container=t,window.location.hostname==="localhost"){const a=new mo;a.dom.style.position="absolute",a.dom.style.top="",a.dom.style.bottom="50px",a.dom.style.left="30px",this.container.appendChild(a.dom),this.stats=a}e.addEventListener("pointerdown",this.onPointerDown),e.addEventListener("pointermove",this.onPointerHover),e.addEventListener("pointerleave",this.onPointerLeave),YA(this.renderer),this.renderer.localClippingEnabled=!0,this.renderer.setSize(t.clientWidth,t.clientHeight),this.renderer.setAnimationLoop(this.animate),this.resizeObserver=JA(t,(a,o)=>{this.resizeWidth=a,this.resizeHeight=o,this.pendingResize=!0}),e.tabIndex=0,e.style.outline="none",this.camera instanceof gn&&(this.camera.aspect=e.clientWidth/e.clientHeight,this.camera.updateProjectionMatrix()),this.css2DRenderer=$A(t);const n=new iP(this.scene,this.camera);this.effectComposer=new eP(this.renderer),this.selectedNodeOutlinePass=new ws(new me(e.clientWidth,e.clientHeight),this.scene,this.camera,[]),this.selectedNodeOutlinePass.visibleEdgeColor.setHex(16734751),this.selectedNodeOutlinePass.hiddenEdgeColor.setHex(12069376),this.selectedNodeOutlinePass.edgeStrength=3,this.selectedNodeOutlinePass.edgeThickness=1,this.activeNodeOutlinePass=new ws(new me(e.clientWidth,e.clientHeight),this.scene,this.camera,[]),this.activeNodeOutlinePass.visibleEdgeColor.setHex(16765952),this.activeNodeOutlinePass.hiddenEdgeColor.setHex(13146624),this.activeNodeOutlinePass.edgeStrength=4,this.activeNodeOutlinePass.edgeThickness=1,this.effectComposer.addPass(n),this.effectComposer.addPass(this.selectedNodeOutlinePass),this.effectComposer.addPass(this.activeNodeOutlinePass),this.effectComposer.addPass(new nP),this.control="orbit",this.orbit=new DA(this.editor.camera,this.renderer.domElement),this.orbit.mouseButtons={LEFT:-1,MIDDLE:xr.PAN,RIGHT:-1},this.orbit.touches={ONE:Gs.PAN,TWO:Gs.ROTATE};const i=navigator.maxTouchPoints>0||window.matchMedia("(pointer: coarse)").matches;this.orbit.panSpeed=i?1.5:1,this.orbit.minDistance=3,this.orbit.maxDistance=150,this.orbit.enableRotate=!0,this.orbit.maxPolarAngle=Math.PI/2,this.orbit.zoomToCursor=!0,this.editor.initialCameraState&&(this.orbit.target.set(this.editor.initialCameraState.target.x,this.editor.initialCameraState.target.y,this.editor.initialCameraState.target.z),this.orbit.update()),this.trackpadOrbitController=new rP({domElement:this.renderer.domElement,orbit:this.orbit}),this.trackpadOrbitController.attach(),this.orbit.addEventListener("change",this.handleOrbitChange),this.transformControls=new RE(this.camera,this.renderer.domElement),this.transformControls.addEventListener("dragging-changed",this.handleTransformControlDraggingChanged),this.transformControls.addEventListener("objectChange",this.handleTransformControlsObjectChange),this.transformControls.addEventListener("object-changed",this.handleTransformControlsObjectChange);const s=this.transformControls.getHelper();this.sceneHelpers.add(s),this.boxSelectHelper=document.createElement("div"),this.boxSelectHelper.style.position="absolute",this.boxSelectHelper.style.border="1px dashed #ffffff",this.boxSelectHelper.style.background="rgba(255, 255, 255, 0.1)",this.boxSelectHelper.style.pointerEvents="none",document.body.appendChild(this.boxSelectHelper),this.grid=new qA({size1:1,size2:5,fineColor:4473924,coarseColor:9079434,xAxisColor:16717636,yAxisColor:65382,distance:500}),this.grid.renderOrder=20,this.grid.userData.keep=!0,this.scene.add(this.grid),this.render(),this.editor.eventHandler.eventBus.emit("viewport:initialized")}animate=e=>{this.applyPendingResize();const t=e*.001-hP;this.editor.robotManager.updateAll(t),this.control==="follow"&&this.alignCameraToRobotView(),this.render(),this.stats&&this.stats.update()};registerEventListeners(){const e=this.editor.eventHandler.eventBus;e.on("editor:camera-reset",this.handleCameraReset),e.on("zone:draft-updated",this.handleZoneDraftUpdated),e.on("selector:object-selected",this.handleObjectSelected),e.on("selector:link-selected",this.handleLinkSelected),e.on("selector:zone-selected",this.handleZoneSelected),e.on("selector:zone-focused",this.handleZoneFocused),e.on("selector:zone-draft-vertex-selected",this.handleZoneDraftVertexSelected),e.on("points-manager:mappoints-updated",this.handleMapPointsUpdated),e.on("editor:object-removed",this.handleObjectRemoved),e.on("ui:grid-visibility-set-requested",this.handleSetGridVisibility),e.on("ui:control-change-requested",this.handleControlSet),e.on("ui:tfc-axis-y-enable-requested",this.handleEnableAxisY),e.on("ui:localization-mode-toggle-requested",this.handleLocalizationModeToggled),e.on("ui:label-visibility-set-requested",this.handleLabelVisibilitySet),e.on("node-manager:label-added",this.handleLabelAdded),e.on("node-manager:label-removed",this.handleLabelRemoved),e.on("ui:pointer-action-set-requested",this.handlePointerActionSet),e.on("ui:initial-view-set-up",this.handleSetUpInitialView),e.on("editor:initialized",this.handleEditorInitialized),e.on("ui:transformControls-set-mode-requested",this.handleTransformcontrolsSetModeRequested),e.on("ui:camera-move-requested",this.handleCameraMoveRequested),e.on("ui:camera-mode-set-requested",this.handleCameraModeSetRequested),e.on("ui:camera-state-set-requested",this.handleCameraStateSetRequested)}deregisterEventListeners(){const e=this.editor.eventHandler.eventBus;e.off("editor:camera-reset",this.handleCameraReset),e.off("zone:draft-updated",this.handleZoneDraftUpdated),e.off("selector:object-selected",this.handleObjectSelected),e.off("selector:link-selected",this.handleLinkSelected),e.off("selector:zone-selected",this.handleZoneSelected),e.off("selector:zone-focused",this.handleZoneFocused),e.off("selector:zone-draft-vertex-selected",this.handleZoneDraftVertexSelected),e.off("points-manager:mappoints-updated",this.handleMapPointsUpdated),e.off("editor:object-removed",this.handleObjectRemoved),e.off("ui:grid-visibility-set-requested",this.handleSetGridVisibility),e.off("ui:control-change-requested",this.handleControlSet),e.off("ui:tfc-axis-y-enable-requested",this.handleEnableAxisY),e.off("ui:localization-mode-toggle-requested",this.handleLocalizationModeToggled),e.off("ui:label-visibility-set-requested",this.handleLabelVisibilitySet),e.off("node-manager:label-added",this.handleLabelAdded),e.off("node-manager:label-removed",this.handleLabelRemoved),e.off("ui:pointer-action-set-requested",this.handlePointerActionSet),e.off("ui:initial-view-set-up",this.handleSetUpInitialView),e.off("editor:initialized",this.handleEditorInitialized),e.off("ui:transformControls-set-mode-requested",this.handleTransformcontrolsSetModeRequested),e.off("ui:camera-move-requested",this.handleCameraMoveRequested),e.off("ui:camera-mode-set-requested",this.handleCameraModeSetRequested),e.off("ui:camera-state-set-requested",this.handleCameraStateSetRequested)}dispose(){this.renderer&&(this.renderer.setAnimationLoop(null),this.selectedNodeOutlinePass?.dispose(),this.activeNodeOutlinePass?.dispose(),this.effectComposer?.dispose(),this.grid&&(this.scene.remove(this.grid),this.grid.geometry.dispose(),this.grid.material.dispose()),this.renderer.dispose()),this.orbit&&(this.orbit.removeEventListener("change",this.handleOrbitChange),this.orbit.dispose()),this.transformControls&&(this.transformControls.removeEventListener("dragging-changed",this.handleTransformControlDraggingChanged),this.transformControls.removeEventListener("objectChange",this.handleTransformControlsObjectChange),this.transformControls.removeEventListener("object-changed",this.handleTransformControlsObjectChange),this.sceneHelpers?.remove(this.transformControls.getHelper()),this.transformControls.dispose()),QA(this.css2DRenderer),this.renderer?.domElement&&(this.renderer.domElement.removeEventListener("pointerdown",this.onPointerDown),this.renderer.domElement.removeEventListener("pointermove",this.onPointerHover),this.renderer.domElement.removeEventListener("pointerleave",this.onPointerLeave)),this.trackpadOrbitController?.detach(),this.boxSelectHelper?.parentNode&&this.boxSelectHelper.parentNode.removeChild(this.boxSelectHelper),this.stats&&this.stats.dom.remove(),this.resizeObserver&&this.resizeObserver.disconnect(),this.resizeObserver=null,this.deregisterEventListeners()}handleSetUpInitialView=e=>{if(this.editor.robotManager.mainRobot){const t=new I(Number(e.x),Number(e.y),0);this.orbit.target.copy(t),this.orbit.update()}};handleLabelAdded=e=>{this.labels.push(e)};handleLabelRemoved=e=>{this.removeLabel(e)};handleLabelVisibilitySet=e=>{this.renderCSS2D=e,this.css2DRenderer.domElement.style.display=this.renderCSS2D?"":"none";const t=this.editor.selectionManager.getSelectableObjects();for(let n=0;n<t.length;n++)t[n].traverse(s=>{s instanceof Hs&&(s.visible=e)})};handleLocalizationModeToggled=e=>{const t=this.editor.previewHelper;if(!t){this.transformControls.detach(),this.orbit.update();return}e?(t.visible=!0,this.transformControls.setMode("rotate"),this.transformControls.showX=!1,this.transformControls.showY=!1,this.transformControls.showZ=!0,this.transformControls.attach(t)):(t.visible=!1,this.transformControls.setMode("translate"),this.transformControls.showX=!0,this.transformControls.showY=!0,this.transformControls.showZ=!1,this.transformControls.detach()),this.orbit.update()};updateEraserIndicator=e=>{this.onMovePosition.fromArray(this.getNormalizedPos(e.clientX,e.clientY));const t=this.editor.selector.getPointerPlaneIntersection(this.onMovePosition,this.editor.camera);if(!t.length){this.editor.eraser.hideIndicator();return}this.editor.eraser.updateIndicator(t[0].point),this.render()};render=()=>{this.effectComposer.render(),this.renderCSS2D&&this.css2DRenderer.render(this.editor.scene,this.editor.viewportCamera),this.renderer.autoClear=!1,this.sceneHelpers.visible&&this.renderer.render(this.sceneHelpers,this.editor.viewportCamera),this.renderer.autoClear=!0};applyPendingResize=()=>{if(!this.pendingResize)return;this.pendingResize=!1,e1({camera:this.editor.viewportCamera,renderer:this.renderer,css2DRenderer:this.css2DRenderer,canvas:this.editor.canvas,width:this.resizeWidth,height:this.resizeHeight})&&(this.effectComposer.setSize(this.resizeWidth,this.resizeHeight),this.selectedNodeOutlinePass.setSize(this.resizeWidth,this.resizeHeight),this.activeNodeOutlinePass.setSize(this.resizeWidth,this.resizeHeight))};depthToBucket(e){for(let t=0;t<tg.length;t++)if(e<tg[t])return t;return Zl.length-1}resizeLabels=()=>{const{camera:e,labels:t,tmpView:n}=this;e.updateMatrixWorld();const i=e.matrixWorldInverse;for(const s of t){s.worldPosition||(s.worldPosition=new I,s.obj.getWorldPosition(s.worldPosition)),n.copy(s.worldPosition).applyMatrix4(i);const a=Math.abs(n.z),o=this.depthToBucket(a);if(o!==s.bucket){const l=s.obj.element;s.bucket!==null?l.classList.replace(Zl[s.bucket],Zl[o]):l.classList.add(Zl[o]),s.bucket=o}}};alignCameraToRobotView(){this.editor.robotManager.mainRobot&&(this.setCameraPosition(),this.setCameraOrientation())}getRobotWorldPose(){const e=this.editor.robotManager.mainRobot;return e.getWorldPosition(this.robotPos),e.getWorldQuaternion(this.robotQuat),{pos:this.robotPos,quat:this.robotQuat}}computeShoulderOffset(e){return this.lookOffset.set(-4,0,2).applyQuaternion(e)}setCameraPosition(){const{pos:e,quat:t}=this.getRobotWorldPose(),n=this.computeShoulderOffset(t);this.camera.position.copy(e).add(n)}setCameraOrientation(){const{pos:e,quat:t}=this.getRobotWorldPose(),n=this.robotForward.set(1,0,0).applyQuaternion(t);this.camera.lookAt(e.clone().add(n.multiplyScalar(10)))}getNormalizedPos(e,t){const n=this.renderer.domElement.getBoundingClientRect();return[(e-n.left)/n.width,(t-n.top)/n.height]}onPointerDown=e=>{this.pointerDownTime=performance.now(),e.preventDefault(),e.target===this.renderer.domElement&&(this.renderer.domElement.setPointerCapture(e.pointerId),this.activePointId=e.pointerId,this.onDownPosition.fromArray(this.getNormalizedPos(e.clientX,e.clientY)),this.onDownPx.set(e.clientX,e.clientY),this.isBoxSelectGestureActive=!1,this.pointerSelectionIntent=this.resolveSelectionIntent(e),e.pointerType==="mouse"&&e.button===this.PRIMARY_MOUSE_BUTTON&&this.canStartBoxSelect()&&(this.isBoxSelectGestureActive=!0,this.startPoint.set(e.clientX,e.clientY),this.endPoint.copy(this.startPoint),Object.assign(this.boxSelectHelper.style,{left:`${this.startPoint.x}px`,top:`${this.startPoint.y}px`,width:"0px",height:"0px",display:"block"})),this.renderer.domElement.addEventListener("pointermove",this.onPointerMove,{passive:!1}),this.renderer.domElement.addEventListener("pointerup",this.onPointerUp),this.renderer.domElement.addEventListener("pointercancel",this.onPointerUp))};onPointerMove=e=>{if(e.pointerId!==this.activePointId)return;e.preventDefault(),this.onMovePosition.fromArray(this.getNormalizedPos(e.clientX,e.clientY));const t=this.editor.selector.getPointerPlaneIntersection(this.onMovePosition,this.editor.camera);if(t.length){if(this.pointerAction==="zoneDraft"){const n=t[0].point.clone();n.z=0,this.editor.eventHandler.eventBus.emit("viewport:zone-point-preview-updated",{point:n})}if(e.pointerType==="mouse"&&e.buttons===1&&this.isBoxSelectGestureActive){this.endPoint.set(e.clientX,e.clientY);const n=Math.min(this.startPoint.x,this.endPoint.x),i=Math.min(this.startPoint.y,this.endPoint.y),s=Math.abs(this.endPoint.x-this.startPoint.x),a=Math.abs(this.endPoint.y-this.startPoint.y);Object.assign(this.boxSelectHelper.style,{left:`${n}px`,top:`${i}px`,width:`${s}px`,height:`${a}px`})}}};onPointerHover=e=>{if(this.activePointId!==null||e.target!==this.renderer.domElement)return;if(this.pointerAction==="erase"){this.updateEraserIndicator(e);return}const t=this.pointerAction==="zoneDraft"&&this.zoneDraftState==="drawing",n=this.zoneDraftState==="closed";if(!t&&!n)return;const i=this.getNormalizedPos(e.clientX,e.clientY);if(this.onMovePosition.fromArray(i),n){const o=this.editor.selector.getPointerZoneDraftVertexIntersection(this.onMovePosition,this.editor.camera);this.editor.eventHandler.eventBus.emit("viewport:zone-draft-vertex-hovered",{vertexIndex:o?.vertexIndex??null});return}const s=this.editor.selector.getPointerPlaneIntersection(this.onMovePosition,this.editor.camera);if(!s.length)return;const a=s[0].point.clone();a.z=0,this.editor.eventHandler.eventBus.emit("viewport:zone-point-preview-updated",{point:a})};onPointerLeave=e=>{this.activePointId===null&&e.target===this.renderer.domElement&&(this.editor.eraser.hideIndicator(),this.zoneDraftState==="closed"&&this.editor.eventHandler.eventBus.emit("viewport:zone-draft-vertex-hovered",{vertexIndex:null}),this.pointerAction==="zoneDraft"&&this.editor.eventHandler.eventBus.emit("viewport:pointer-leave",void 0))};finishPointer=()=>{this.renderer.domElement.removeEventListener("pointermove",this.onPointerMove),this.renderer.domElement.removeEventListener("pointerup",this.onPointerUp),this.renderer.domElement.removeEventListener("pointercancel",this.onPointerUp),this.activePointId!==null&&(this.renderer.domElement.releasePointerCapture(this.activePointId),this.activePointId=null),this.isBoxSelectGestureActive=!1,this.pointerSelectionIntent="replace",this.boxSelectHelper.style.display="none",this.pointerAction!=="erase"&&this.editor.eraser.hideIndicator()};onPointerUp=e=>{if(e.pointerId!==this.activePointId)return;this.onUpPosition.fromArray(this.getNormalizedPos(e.clientX,e.clientY)),this.onUpPx.set(e.clientX,e.clientY);const t=e.pointerType==="mouse"&&e.button===this.PRIMARY_MOUSE_BUTTON,n=e.pointerType==="touch";(t||n)&&this.handlePrimaryPointerAction(),this.finishPointer()};handlePrimaryPointerAction=()=>{const e=performance.now()-this.pointerDownTime,t=this.onDownPx.distanceToSquared(this.onUpPx),n=Math.pow(oP*devicePixelRatio,2);if(e<aP&&t<=n)switch(this.pointerAction){case"inspect":this.handleInspectAndSelect(this.pointerAction);break;case"select":this.handleInspectAndSelect(this.pointerAction);break;case"locatePreview":this.updatePreviewOnPointer();break;case"erase":this.handleErase();break;case"zoneDraft":{const s=this.editor.selector.getPointerPlaneIntersection(this.onUpPosition,this.editor.camera);if(s.length){const a=s[0].point.clone();a.z=0,this.editor.eventHandler.eventBus.emit("viewport:zone-point-place-requested",{point:a})}break}default:this.pointerAction}else this.isBoxSelectGestureActive&&this.handleBoxSelect();this.render()};handleErase=()=>{const e=this.editor.selector.getPointerMapBrushIntersections(this.onUpPosition,this.editor.camera);this.editor.eventHandler.eventBus.emit("eraser:intersections-detected",e)};updatePreviewOnPointer=()=>{const e=this.editor.previewHelper;if(!e)return;const t=this.editor.selector.getPointerPlaneIntersection(this.onDownPosition,this.editor.camera);t.length&&(e.updatePosition(t[0].point),e.position.z=0,this.transformControls.attach(e))};handleInspectAndSelect=e=>{const t=this.editor.selector.getPointerObjectIntersections(this.onUpPosition,this.editor.camera);this.editor.eventHandler.eventBus.emit("viewport:intersections-detected",{action:e,intent:this.pointerSelectionIntent,intersections:t})};resolveSelectionIntent=e=>e.metaKey||e.ctrlKey?"remove":e.shiftKey?"add":"replace";handleCameraReset=()=>{const e=this.renderer.domElement;this.camera instanceof gn&&(this.camera.aspect=e.clientWidth/e.clientHeight,this.camera.updateProjectionMatrix(),this.orbit.target.set(0,0,0),this.emitCameraChanged())};handleCameraModeSetRequested=e=>{if(!(!this.camera||!this.orbit)){if(this.control="orbit",this.orbit.enabled=!0,e==="topView"){this.currentCameraMode!=="topView"&&(this.lastPerspectiveCameraState=this.getCameraState());const t=this.orbit.target.clone(),n=bt.clamp(this.camera.position.distanceTo(t),this.orbit.minDistance+.1,this.orbit.maxDistance-.1);this.camera.up.set(0,1,0),this.camera.position.set(t.x,t.y,t.z+n),this.orbit.enableRotate=!1,this.orbit.update(),this.currentCameraMode="topView",this.emitCameraChanged(),this.render();return}if(this.camera.up.set(0,0,1),this.orbit.enableRotate=!0,this.currentCameraMode==="topView")if(this.lastPerspectiveCameraState)this.camera.position.set(this.lastPerspectiveCameraState.position.x,this.lastPerspectiveCameraState.position.y,this.lastPerspectiveCameraState.position.z),this.orbit.target.set(this.lastPerspectiveCameraState.target.x,this.lastPerspectiveCameraState.target.y,this.lastPerspectiveCameraState.target.z);else{const t=this.orbit.target,n=bt.clamp(this.camera.position.distanceTo(t),this.orbit.minDistance+.1,this.orbit.maxDistance-.1);this.camera.position.set(t.x-n*.75,t.y,t.z+n)}this.orbit.update(),this.currentCameraMode="perspective",this.emitCameraChanged(),this.render()}};handleZoneDraftUpdated=e=>{this.zoneDraftState=e.state,this.zoneDraftEditingZoneId=e.editingZoneId,e.editingZoneId!==null&&this.transformControls.object?.userData.topologyObjectType==="zone"&&this.transformControls.detach(),e.state!=="closed"&&this.editor.eventHandler.eventBus.emit("viewport:zone-draft-vertex-hovered",{vertexIndex:null})};handleBoxSelect=()=>{this.boxSelectHelper.style.display="none";const e=this.editor.selector.getSelectionBoxIntersects(this.renderer.domElement,this.startPoint,this.endPoint);e.length&&this.editor.eventHandler.eventBus.emit("selector:box-intersections-detected",{intersections:e,action:this.pointerAction==="select"?"select":"inspect"})};canStartBoxSelect=()=>{const e=this.editor.selectionManager.getSelectedZoneVertex();return(this.pointerAction==="select"||this.pointerAction==="inspect")&&!this.transformControls.dragging&&e===null};handleTransformControlsObjectChange=()=>{if(this.transformControls.object){if(this.transformControls.object.userData.topologyObjectType==="zone")return;if(this.transformControls.object.userData.objectType==="topology-zone-draft-vertex"){const t=this.transformControls.object.userData.vertexIndex;typeof t=="number"&&this.editor.eventHandler.eventBus.emit("viewport:zone-draft-vertex-moved",{vertexIndex:t,point:this.transformControls.object.position.clone()});return}const e=bt.radToDeg(this.transformControls.object.rotation.z);this.editor.eventHandler.eventBus.emit("node-manager:selection-transform-changed",{x:this.transformControls.object.position.x.toString().slice(0,6),y:this.transformControls.object.position.y.toString().slice(0,6),z:this.transformControls.object.position.z.toString().slice(0,6),rz:e.toString().slice(0,6)})}else this.editor.eventHandler.eventBus.emit("node-manager:selection-transform-changed",null)};handleObjectSelected=e=>{const{object:t,selectedObjects:n,action:i}=e;this.transformControls.detach(),this.selectedNodeOutlinePass.selectedObjects=n.length>1?n.slice(0,-1):[],this.activeNodeOutlinePass.selectedObjects=t!==null?[t]:[],t!==null&&i==="select"&&this.transformControls.attach(t)};handleLinkSelected=()=>{this.transformControls.detach()};handleZoneSelected=()=>{this.transformControls.detach(),this.attachFocusedZoneTransform()};handleZoneFocused=()=>{this.pointerAction!=="select"||this.zoneDraftEditingZoneId!==null||(this.transformControls.detach(),this.attachFocusedZoneTransform())};attachFocusedZoneTransform(){if(this.pointerAction!=="select"||this.zoneDraftEditingZoneId!==null)return!1;const e=this.editor.selectionManager.getFocusedZoneId(),n=this.editor.selectionManager.getSelectedZones().find(i=>String(i.userData.zoneId)===e)?.userData.zoneOwner;return n?(this.transformControls.attach(n),this.transformControls.setMode("translate"),this.transformControls.showX=!0,this.transformControls.showY=!0,this.transformControls.showZ=!1,!0):!1}handleZoneDraftVertexSelected=e=>{if(!e.vertex||e.vertexIndex===null){this.transformControls.detach();return}this.transformControls.attach(e.vertex),this.transformControls.setMode("translate"),this.transformControls.showX=!0,this.transformControls.showY=!0,this.transformControls.showZ=!1};handleMapPointsUpdated=()=>{this.transformControls.detach(),this.render()};handleObjectRemoved=e=>{e.label&&(this.removeLabel(e.label),this.transformControls.detach())};removeLabel(e){const t=this.labels.findIndex(n=>n.obj===e);t>-1&&this.labels.splice(t,1)}handleSetGridVisibility=e=>{this.grid&&(this.grid.visible=e)};setClearColor=e=>{if(e==="transparent"||e==="inherit"){this.renderer.setClearColor(0,0);return}this.renderer.setClearColor(e)};setGridColors=(e,t)=>{this.grid?.setColors(e,t)};setGridAxisColors=(e,t)=>{this.grid?.setAxisColors(e,t)};handleControlSet=e=>{e==="orbit"?this.activateOrbitMode():e==="follow"&&this.activateFollowMode()};activateOrbitMode(){if(!this.editor.robotManager.mainRobot)return;this.orbit.enabled=!0;const{pos:e}=this.getRobotWorldPose();this.orbit.target.copy(e);const t=this.editor.robotManager.mainRobot,n=new vn;new Yt().setFromObject(t).getBoundingSphere(n);const i=n.radius||1,s=this.camera.position.clone().sub(this.orbit.target).normalize(),a=bt.clamp(i*15,this.orbit.minDistance+.1,this.orbit.maxDistance-.1);this.camera.position.copy(this.orbit.target).addScaledVector(s,a),this.orbit.update(),this.control="orbit",this.emitCameraChanged()}activateFollowMode(){this.orbit.enabled=!1,this.control="follow"}handleEnableAxisY=e=>{};handleOrbitChange=()=>{this.emitCameraChanged(),this.renderCSS2D&&clearTimeout(this.interactionTimer)};handlePointerActionSet=e=>{this.pointerAction=e,this.pointerAction==="inspect"&&this.transformControls.detach(),this.pointerAction!=="erase"&&this.editor.eraser.hideIndicator()};handleTransformControlDraggingChanged=e=>{this.orbit.enabled=!e.value,e.value&&(this.isBoxSelectGestureActive=!1);const t=this.transformControls.object,n=t?this.editor.selectionManager.isSelectable(t):!1,i=t?.userData.topologyObjectType==="zone"?String(t.userData.zoneId):null,s=i!==null&&i===this.editor.selectionManager.getFocusedZoneId();if(e.value){if(!t||!n&&!s){this.transformDragStart=null;return}this.transformDragStart={object:t,position:t.position.clone(),rotation:t.rotation.clone()};return}const a=this.transformDragStart;if(this.transformDragStart=null,!a||!t||a.object!==t)return;const o=a.position.distanceTo(t.position)>Ja,l=Math.abs(a.rotation.x-t.rotation.x)>Ja||Math.abs(a.rotation.y-t.rotation.y)>Ja||Math.abs(a.rotation.z-t.rotation.z)>Ja;if(!(!o&&!l)){if(s&&i){const c=t.position.clone().sub(a.position);this.editor.eventHandler.eventBus.emit("viewport:zone-translation-committed",{zoneId:i,delta:{x:c.x,y:c.y}});return}this.editor.eventHandler.eventBus.emit("topology:changed",{source:"node-updated"})}};handleEditorInitialized=()=>{this.initialize()};handleTransformcontrolsSetModeRequested=e=>{if(!this.transformControls||this.attachFocusedZoneTransform())return;if(this.transformControls.object?.userData.topologyObjectType==="zone"){this.transformControls.setMode("translate"),this.transformControls.showX=!0,this.transformControls.showY=!0,this.transformControls.showZ=!1;return}const t=this.editor.selectionManager.getSelected()??this.editor.selectionManager.getSelectedZoneVertex();t&&this.transformControls.attach(t),this.transformControls.setMode(e),e==="rotate"?(this.transformControls.showX=!1,this.transformControls.showY=!1,this.transformControls.showZ=!0):(this.transformControls.showX=!0,this.transformControls.showY=!0,this.transformControls.showZ=!1)};handleCameraMoveRequested=e=>{const t=this.camera,n=this.orbit,i=t.position.distanceTo(n.target),s=Math.min(Math.max(i*.03,.1),5),a=1;switch(t.getWorldDirection(this.fwd).normalize(),this.right.copy(this.fwd).cross(t.up).normalize(),this.up.copy(this.right).cross(this.fwd).normalize(),this.delta.set(0,0,0),e){case"up":this.delta.copy(this.up).multiplyScalar(s);break;case"down":this.delta.copy(this.up).multiplyScalar(-s);break;case"left":this.delta.copy(this.right).multiplyScalar(-s);break;case"right":this.delta.copy(this.right).multiplyScalar(s);break;case"zoomin":this.delta.copy(this.fwd).multiplyScalar(a),t.position.add(this.delta),n.update(),this.emitCameraChanged();return;case"zoomout":this.delta.copy(this.fwd).multiplyScalar(-a),t.position.add(this.delta),n.update(),this.emitCameraChanged();return;case"center":{const o=t.position.z,l=.001;n.target.set(0,0,0),t.position.set(l,l,o),n.update(),this.emitCameraChanged();return}case"focus":this.focusCameraOnActiveNode();return}t.position.add(this.delta),n.target.add(this.delta),n.update(),this.emitCameraChanged()};handleCameraStateSetRequested=e=>{this.setCameraState(e)};focusCameraOnActiveNode=()=>{const e=this.editor.selectionManager.getSelected();if(!e)return;this.focusBox.setFromObject(e),this.focusBox.isEmpty()?(this.focusCenter.copy(e.position),this.focusSphere.center.copy(this.focusCenter),this.focusSphere.radius=eg):(this.focusBox.getCenter(this.focusCenter),this.focusBox.getBoundingSphere(this.focusSphere));const t=Math.max(this.focusSphere.radius,eg),n=bt.clamp(t*dP,lP,cP);this.focusDirection.copy(this.camera.position).sub(this.orbit.target),this.focusDirection.lengthSq()<Ja?this.camera.getWorldDirection(this.focusDirection).multiplyScalar(-1):this.focusDirection.normalize(),this.orbit.target.copy(this.focusCenter),this.camera.position.copy(this.focusCenter).addScaledVector(this.focusDirection,n),this.orbit.update(),this.emitCameraChanged()}}class fP{nodeManager;eventHandler;robotManager;selectionManager;selector;eraser;pathDrawer;trajectoryDrawer;pointsManager;tileMap;viewport;initialized=!1;scene;sceneHelpers;camera;viewportCamera;robotType=null;initialCameraState=null;previewHelper;globalPlane;canvas=null;constructor(){this.selectionManager=new LC,this.eventHandler=new _1(this),this.nodeManager=new xC(this),this.robotManager=new DC(this),this.selector=new IC(this),this.eraser=new x1(this),this.pathDrawer=new TC(this),this.trajectoryDrawer=new WC(this),this.pointsManager=new AC(this),this.tileMap=new GC(this),this.viewport=new uP(this)}getEraserRadius(){return this.selector?this.selector.pointsThreshold:.5}async initialize(e){this.canvas=e.canvas,this.robotType=e.robotType,this.initialCameraState=e.initialCameraState??null,Pt.DEFAULT_UP=new I(0,0,1),this.scene=new uu,this.sceneHelpers=new uu,this.camera=Ta.clone(),this.initialCameraState&&this.camera.position.set(this.initialCameraState.position.x,this.initialCameraState.position.y,this.initialCameraState.position.z),this.viewportCamera=this.camera;const t=new $s(1e4,1e4),n=new jt({visible:!1}),i=new Ee(t,n);i.name="globalPlane",i.userData.keep=!0,this.globalPlane=i,this.scene.add(this.globalPlane);const s=new Sp(16777215,2105376,.5);s.userData.keep=!0,this.scene.add(s);const a=new Hc(16777215,1);a.position.set(0,0,100),a.userData.keep=!0,this.scene.add(a),this.sceneHelpers.add(new Sp(16777215,8947848,2)),this.selectionManager.reset(),this.eventHandler.registerEventListeners(),this.viewport.registerEventListeners(),this.eventHandler.registerCanvasEventListeners(),this.selector.registerEventListeners(),this.pointsManager.registerEventListeners(),this.tileMap.registerEventListeners(),this.eraser.registerEventListeners(),this.nodeManager.registerEventListeners(),this.robotManager.registerEventListeners(),this.initialized=!0,this.eventHandler.eventBus.emit("editor:initialized",e)}addOrigin(e){const t=new Pa(.1),n=new jt({color:16711680}),i=new Ee(t,n);i.name="origin";const s=new Da(e);i.add(s),this.scene.add(i)}clear(e={clearMap:!0,clearTopo:!0}){e.clearMap&&this.pointsManager.clearMapPoints(),e.clearTopo&&this.nodeManager.clearTopo()}resetCamera(){this.camera.copy(Ta),this.eventHandler.eventBus.emit("editor:camera-reset")}dispose(){if(this.initialized){for(this.eventHandler.dispose(),this.eraser.dispose(),this.pathDrawer.dispose(),this.trajectoryDrawer.dispose(),this.robotManager.dispose(),this.selector.dispose(),this.pointsManager.dispose(),this.nodeManager.dispose(),this.tileMap.dispose(),this.viewport.dispose(),this.scene.traverse(e=>{e instanceof Ee&&(e.geometry&&e.geometry.dispose(),e.material&&Array.isArray(e.material)&&e.material.forEach(t=>{t.dispose()}))});this.scene.children.length>0;)this.scene.remove(this.scene.children[0]);this.robotType=null,this.initialCameraState=null,this.initialized=!1}}getObjectBySlamId(e){let t=null;return this.scene.traverse(n=>{n.userData.id===e&&(t=n)}),t}removeObject(e){if(e.parent===null)return;const t=e.children.find(i=>i instanceof Hs),n=this.selectionManager.isSelectable(e);e.parent.remove(e),n&&(this.nodeManager.removeAllLinksRelatedTo(e),this.nodeManager.removeAllArrowsRelatedTo(e),this.selectionManager.unregisterSelectable(e),this.eventHandler.eventBus.emit("topology:nodes-updated",this.selectionManager.getSelectableObjects())),e.clear(),this.eventHandler.eventBus.emit("editor:object-removed",{object:e,label:t})}setupPreviewHelper(e){this.previewHelper?.parent&&this.previewHelper.parent.remove(this.previewHelper);let t;e==="QD-RBY"?t=new XC:e==="rby1a"||e==="rby1m"||e==="rby1ub"||e==="rby2c"?t=new ZC(e):e==="GAIA"||e==="QD"?t=new qC:t=new jC,this.previewHelper=t,this.scene.add(this.previewHelper)}}const ah=r=>typeof r=="number"&&Number.isFinite(r),ng=r=>{if(!r||typeof r!="object")return!1;const e=r;return ah(e.x)&&ah(e.y)&&ah(e.z)},pP=r=>{if(!r)return null;try{const e=JSON.parse(r);if(!e||typeof e!="object")return null;const t=e;return!ng(t.position)||!ng(t.target)?null:{position:t.position,target:t.target}}catch{return null}},mP=r=>{if(!r)return null;try{return pP(localStorage.getItem(r))}catch{return null}},gP=(r,e)=>{if(r)try{localStorage.setItem(r,JSON.stringify(e))}catch{}},bP=({className:r})=>v("div",{className:$t("absolute top-0 left-0 z-50 flex h-full w-full items-center justify-center p-1.5 text-5xl text-white",r),children:v(Wv,{size:"3rem"})}),{useCallback:vP,useMemo:Yl,useReducer:yP,useState:Gi}=await At("react"),xP={state:"idle",editingZoneId:null,selectedVertexIndex:null,name:"",type:"NO_ENTRY",pointCount:0,points:[]},Ac={editor:!1,viewport:!1,nodeManager:!1,robot:!1,map:!1,topo:!1};function Mv(r,e){switch(e.type){case"RESET":return Ac;case"SET":return r[e.key]===e.value?r:{...r,[e.key]:e.value};case"REPLACE":return e.ready}}function $N(){const[r,e]=yP(Mv,Ac),[t,n]=Gi([]),[i,s]=Gi(null),[a,o]=Gi([]),[l,c]=Gi(null),[d,h]=Gi([]),[u,f]=Gi(null),[m,b]=Gi([]),[p,g]=Gi([]),[y,x]=Gi([]),[w,P]=Gi(null),[T,A]=Gi(xP),M=vP(O=>{e({type:"REPLACE",ready:O})},[]),_=Yl(()=>t[t.length-1]??null,[t]),S=Yl(()=>{if(a.length===0)return[];const O=new Set(a);return p.filter(H=>O.has(H.id))},[p,a]),R=Yl(()=>S.length===0||!l?null:S.find(O=>O.id===l)??null,[l,S]),k=Yl(()=>({onReadyChange:M,onSelectedObjectsChange:n,onSelectedNodeTransformChange:s,onSelectedLinksChange:o,onFocusedLinkChange:c,onSelectedZonesChange:h,onFocusedZoneChange:f,onNodesChange:b,onLinksChange:g,onZonesChange:x,onMapBoundsChange:P,onZoneDraftChange:A}),[M]);return{ready:r,selectedObjects:t,selectedNodeTransform:i,selectedNode:_,selectedLinkIds:a,focusedLinkId:l,selectedLinks:S,focusedLink:R,selectedZoneIds:d,focusedZoneId:u,nodes:m,links:p,zones:y,mapBounds:w,zoneDraft:T,worldStudioStateProps:k}}const{forwardRef:_P,useCallback:Ti,useEffect:qt,useImperativeHandle:wP,useMemo:SP,useReducer:MP,useRef:Kl,useState:ig}=await At("react"),sg={light:{background:"#f4f4f5",fine:5395026,coarse:5921370,xAxis:16717636,yAxis:65382},dark:{background:"#333333",fine:6052956,coarse:9079434,xAxis:16717636,yAxis:65382}},TP=r=>r.map(e=>({id:String(e.userData?.id??""),uuid:e.uuid,name:e.name,type:e.userData.type?.toLowerCase()||"unknown",features:Array.isArray(e.userData.features)?e.userData.features.filter(t=>typeof t=="string"):[],safetyField:typeof e.userData.safetyField=="number"?e.userData.safetyField:0,x:e.position.x,y:e.position.y,z:e.position.z})),EP=_P(({className:r,cameraPositionKey:e,pointsData:t,parsedPointCloudData:n,topoData:i,mapCloudUpdatedAt:s,topologyUpdatedAt:a,robot:o,globalPath:l,localPath:c,trajectory:d,lidarPoints:h,lidar3DPoints:u,mappingPoints:f,robotPose:m,selectedTool:b,showGrid:p,showNodeLabels:g,nodeRenderMode:y="default",showLidar:x,showLidar3D:w,showMapBoundary:P,mapPointHeightClip:T,lidarPointSize:A,mapPointSize:M,viewportCameraMode:_,mappingKeyFrame:S,onReadyChange:R,onSelectedObjectsChange:k,onSelectedNodeTransformChange:O,onSelectedLinksChange:H,onFocusedLinkChange:q,onSelectedZonesChange:G,onFocusedZoneChange:K,onNodesChange:V,onLinksChange:Z,onZonesChange:le,onMapBoundsChange:se,onEraserHistoryInvalidated:ge,onEraserSelectionChange:de,onZoneDraftChange:X},ee)=>{const{theme:ie}=Ea(),Y=Kl(null),ue=Kl(null),oe=Kl(o??null),[be,Ce]=ig(null),[je,Fe]=MP(Mv,Ac),j=Kl(null),[Ke,Ue]=ig("none"),Te=SP(()=>je.editor&&je.viewport&&je.nodeManager,[je]),Se=Ti((te,re)=>{if(je[te]===re)return;const De={...je,[te]:re};Fe({type:"SET",key:te,value:re}),R?.(De)},[je,R]),et=Ti(()=>{Fe({type:"RESET"}),R?.(Ac)},[R]),Be=Ti(te=>{V?.(TP(te))},[V]),N=Ti(()=>{const te=Y.current?.nodeManager.getTopologyLinks()??[];Z?.(te)},[Z]),E=Ti(()=>{const te=Y.current?.nodeManager.getTopologyZones()??[];le?.(te)},[le]),W=Ti(te=>{if(k?.(te.selectedObjects),!!O){if(!te.object){O(null);return}O({x:te.object.position.x,y:te.object.position.y,z:te.object.position.z,rz:bt.radToDeg(te.object.rotation.z)})}},[O,k]),ae=Ti(te=>{if(!te){O?.(null);return}const re=Number(te.x),De=Number(te.y),Ye=Number(te.z),xe=Number(te.rz);if([re,De,Ye,xe].some(Le=>Number.isNaN(Le))){O?.(null);return}O?.({x:re,y:De,z:Ye,rz:xe})},[O]),ve=Ti(te=>{se?.(te.mapBounds),Se("map",!0)},[se,Se]),ce=Ti(te=>{H?.(te.linkIds)},[H]),Oe=Ti(te=>{G?.(te.zoneIds)},[G]),Pe=Ti(te=>{q?.(te.linkId)},[q]),Ve=Ti(te=>{K?.(te.zoneId)},[K]);return wP(ee,()=>({emit:(te,re)=>{Y.current?.eventHandler.eventBus.emit(te,re)},getCamera:()=>{const te=Y.current;return te?.viewportCamera??te?.camera??null},getCanvas:()=>Y.current?.canvas??null,getEraserRadius:()=>Y.current?.getEraserRadius()??.5,getMapPointsData:()=>Y.current?.pointsManager?.mapPointsData??[],getPreviewTransform:()=>{const te=Y.current?.previewHelper;return te?{x:te.position.x.toString(),y:te.position.y.toString(),z:te.position.z.toString(),rz:(te.rotation.z*(180/Math.PI)).toString()}:null},getTopologyData:()=>{const te=Y.current?.selectionManager.getSelectableObjects()??[],re=Y.current?.nodeManager.getTopologyLinks()??[],De=Y.current?.nodeManager.getTopologyZones()??[],Ye=te.map(xe=>({id:typeof xe.userData.id=="string"?xe.userData.id:xe.uuid,name:xe.name,context:typeof xe.userData.context=="string"?xe.userData.context:"",pose:{x:xe.position.x,y:xe.position.y,z:xe.position.z,rx:bt.radToDeg(xe.rotation.x),ry:bt.radToDeg(xe.rotation.y),rz:bt.radToDeg(xe.rotation.z)},size:{x:0,y:0,z:0},type:typeof xe.userData.type=="string"?xe.userData.type:"GOAL",safetyField:typeof xe.userData.safetyField=="number"?xe.userData.safetyField:0,features:Array.isArray(xe.userData.features)?xe.userData.features.filter(ct=>typeof ct=="string"):[]}));return{format_version:EE,nodes:Ye,links:re,zones:De}},getTopologyZones:()=>Y.current?.nodeManager.getTopologyZones()??[],hidePreviewHelper:()=>{const te=Y.current;te&&(te.setupPreviewHelper(null),te.previewHelper.visible=!1)},moveCamera:te=>{Y.current?.eventHandler.eventBus.emit("ui:camera-move-requested",te)},startZoneDraft:te=>{Y.current?.eventHandler.eventBus.emit("ui:zone-draft-start-requested",te)},cancelZoneDraft:()=>{Y.current?.eventHandler.eventBus.emit("ui:zone-draft-cancel-requested",void 0)},clearZoneDraft:()=>{Y.current?.eventHandler.eventBus.emit("ui:zone-draft-clear-requested",void 0)},undoZoneDraft:()=>{Y.current?.eventHandler.eventBus.emit("ui:zone-draft-undo-requested",void 0)},closeZoneDraft:()=>{Y.current?.eventHandler.eventBus.emit("ui:zone-draft-close-requested",void 0)},reopenZoneDraft:()=>{Y.current?.eventHandler.eventBus.emit("ui:zone-draft-reopen-requested",void 0)},commitZoneDraft:()=>{Y.current?.eventHandler.eventBus.emit("ui:zone-draft-commit-requested",void 0)},startZoneEdit:te=>{Y.current?.eventHandler.eventBus.emit("ui:zone-edit-start-requested",{zoneId:te})},focusActiveTopologyZone:te=>{Y.current?.nodeManager.focusActiveTopologyZone(te)},updateZoneDraftMeta:te=>{Y.current?.eventHandler.eventBus.emit("ui:zone-draft-meta-updated",te)},deleteTopologyZone:te=>{Y.current?.nodeManager.deleteTopologyZone(te)},onTopologyChanged:te=>{const re=Y.current?.eventHandler.eventBus;return re?(re.on("topology:changed",te),()=>{re.off("topology:changed",te)}):()=>{}}}),[]),qt(()=>{Y.current||(Y.current=new fP);const re=Y.current.eventHandler.eventBus,De=()=>Se("editor",!0),Ye=()=>Se("viewport",!0),xe=()=>Se("nodeManager",!0),Le=Q=>{gP(e,Q)},ct=Q=>{X?.(Q),Ue(Q.state==="drawing"?"zoneDraft":"none")},rt=Q=>{de?.(Q.selectedCount)},Rt=()=>{ge?.()};return re.on("editor:initialized",De),re.on("viewport:initialized",Ye),re.on("node-manager:ready",xe),re.on("viewport:camera-changed",Le),re.on("points-manager:mappoints-updated",ve),re.on("selector:object-selected",W),re.on("node-manager:selection-transform-changed",ae),re.on("selector:link-selected",ce),re.on("selector:link-focused",Pe),re.on("selector:zone-selected",Oe),re.on("selector:zone-focused",Ve),re.on("topology:nodes-updated",Be),re.on("node-manager:topo-updated",N),re.on("node-manager:topo-updated",E),re.on("eraser:history-invalidated",Rt),re.on("eraser:selection-changed",rt),re.on("zone:draft-updated",ct),()=>{re.off("editor:initialized",De),re.off("viewport:initialized",Ye),re.off("node-manager:ready",xe),re.off("viewport:camera-changed",Le),re.off("points-manager:mappoints-updated",ve),re.off("selector:object-selected",W),re.off("node-manager:selection-transform-changed",ae),re.off("selector:link-selected",ce),re.off("selector:link-focused",Pe),re.off("selector:zone-selected",Oe),re.off("selector:zone-focused",Ve),re.off("topology:nodes-updated",Be),re.off("node-manager:topo-updated",N),re.off("node-manager:topo-updated",E),re.off("eraser:history-invalidated",Rt),re.off("eraser:selection-changed",rt),re.off("zone:draft-updated",ct)}},[ve,W,ae,Pe,Ve,ce,Oe,q,K,ge,de,X,e,Se,N,Be,E]),qt(()=>{const te=Y.current;te&&(oe.current=o??null,te.robotType=o??null)},[o]),qt(()=>{const te=Y.current;if(te){if(!be){ue.current=null;return}if(!(!be.isConnected||!be.parentElement)&&ue.current!==be)return ue.current=be,te.initialize({robotType:oe.current,canvas:be,initialCameraState:mP(e)}),()=>{te.dispose(),ue.current=null,et()}}},[e,be,et]),qt(()=>{const te=Y.current;!Te||!te||t&&te.eventHandler.eventBus.emit("ui:map-points-update-requested",t)},[t,s,Te]),qt(()=>{const te=Y.current;!Te||!te||(n?te.eventHandler.eventBus.emit("ui:typed-map-points-update-requested",n):t||te.clear({clearMap:!0,clearTopo:!1}))},[n,t,Te]),qt(()=>{const te=Y.current;!Te||!te||te.pathDrawer.updateGlobalPath(l??[])},[l,Te]),qt(()=>{const te=Y.current;!Te||!te||te.pathDrawer.updateLocalPath(c??[])},[c,Te]),qt(()=>{const te=Y.current;!Te||!te||te.trajectoryDrawer.updateTrajectory(d??[])},[d,Te]),qt(()=>{const te=Y.current;!Te||!te||te.eventHandler.eventBus.emit("ui:topo-update-requested",{topoData:i})},[i,a,Te]),qt(()=>{const te=Y.current;!Te||!te||te.eventHandler.eventBus.emit("ui:grid-visibility-set-requested",p)},[p,Te]),qt(()=>{const te=Y.current;!Te||!te||!_||te.eventHandler.eventBus.emit("ui:camera-mode-set-requested",_)},[Te,_]),qt(()=>{const te=Y.current?.viewport;if(!Te||!te)return;const{background:re,fine:De,coarse:Ye,xAxis:xe,yAxis:Le}=sg[ie]??sg.dark;te.setGridColors(De,Ye),te.setGridAxisColors(xe,Le)},[ie,Te]),qt(()=>{const te=Y.current;!Te||!te||!o||(te.robotManager.loadMainRobot(o),te.setupPreviewHelper(o))},[o,Te]),qt(()=>{const te=Y.current;!Te||!te||!h||te.eventHandler.eventBus.emit("lidar:updated",{lidarPoints:h})},[h,Te]),qt(()=>{const te=Y.current;!Te||!te||!u||te.eventHandler.eventBus.emit("lidar3d:updated",{lidarPoints:u})},[u,Te]),qt(()=>{const te=Y.current;if(!Te||!te||!m)return;const re=te.robotManager.mainRobot;re&&re.applyPose({x:Number(m.x??0),y:Number(m.y??0),rz:Number(m.rz??0)})},[m,Te]),qt(()=>{const te=Y.current;if(!Te||!te)return;const re=te.eventHandler.eventBus;if(re.emit("ui:localization-mode-toggle-requested",!1),Ke==="zoneDraft"){re.emit("ui:pointer-action-set-requested","zoneDraft");return}switch(b){case"select":re.emit("ui:pointer-action-set-requested","inspect");break;case"target":re.emit("ui:localization-mode-toggle-requested",!0),re.emit("ui:pointer-action-set-requested","locatePreview");break;case"move":re.emit("ui:pointer-action-set-requested","select"),re.emit("ui:transformControls-set-mode-requested","translate");break;case"rotate":re.emit("ui:pointer-action-set-requested","select"),re.emit("ui:transformControls-set-mode-requested","rotate");break;case"scale":re.emit("ui:pointer-action-set-requested","select"),re.emit("ui:transformControls-set-mode-requested","scale");break}},[b,Te,Ke]),qt(()=>{const te=Y.current;!Te||!te||te.eventHandler.eventBus.emit("ui:label-visibility-set-requested",g)},[g,Te]),qt(()=>{const te=Y.current;!Te||!te||te.eventHandler.eventBus.emit("ui:node-render-mode-set-requested",y)},[y,Te]),qt(()=>{const te=Y.current;!Te||!te||te.eventHandler.eventBus.emit("ui:lidar-toggled",x)},[x,Te]),qt(()=>{const te=Y.current;!Te||!te||te.eventHandler.eventBus.emit("ui:lidar3d-toggled",!!w)},[w,Te]),qt(()=>{const te=Y.current;!Te||!te||te.eventHandler.eventBus.emit("ui:map-boundary-visibility-set-requested",!!P)},[P,Te]),qt(()=>{const te=Y.current;!Te||!te||te.eventHandler.eventBus.emit("ui:map-points-height-clip-set-requested",T??null)},[Te,T]),qt(()=>{const te=Y.current;!Te||!te||typeof M!="number"||te.eventHandler.eventBus.emit("ui:map-point-size-set-requested",M)},[Te,M]),qt(()=>{const te=Y.current;!Te||!te||typeof A!="number"||te.eventHandler.eventBus.emit("ui:lidar-point-size-set-requested",A)},[A,Te]),qt(()=>{const te=Y.current;!Te||!te||!f||te.eventHandler.eventBus.emit("ui:mapping-data-received",f)},[f,Te]),qt(()=>{const te=Y.current;if(!Te||!te||!S||S.data.length===0)return;const re=j.current;re&&re.chunkNum===S.chunkNum&&re.chunkId===S.chunkId&&re.data===S.data||(j.current=S,te.eventHandler.eventBus.emit("ui:mapping-keyframe-received",S))},[S,Te]),C("div",{className:$t("WorldStudio","bg-bg-raised relative h-full w-full",r),children:[v("canvas",{ref:Ce,className:"h-full w-full"}),!Te&&v(bP,{})]})});EP.displayName="WorldStudio";const rg=r=>{switch(r.toLowerCase()){case"good":return"text-fg-success";case"busy":case"pause":return"text-fg-caution";case"fail":case"error":case"not ready":return"text-fg-danger";case"move":return"text-fg-information";case"none":return"text-fg-subtler";default:return"text-fg-subtler"}},AP=r=>{switch(r.toLowerCase()){case"near":return"text-fg-danger";case"far":return"text-fg-caution";case"vir":return"text-fg-information";default:return"text-fg-subtler"}},CP=(r,e)=>{switch(r.toLowerCase()){case"good":return e("move.amr.rightPanel.hud.status.good");case"busy":return e("move.amr.rightPanel.hud.status.busy");case"pause":return e("move.amr.rightPanel.hud.status.pause");case"fail":return e("move.amr.rightPanel.hud.status.fail");case"error":return e("move.amr.rightPanel.hud.status.error");case"not ready":return e("move.amr.rightPanel.hud.status.notReady");case"move":return e("move.amr.rightPanel.hud.status.move");case"success":return e("move.amr.rightPanel.hud.status.success");case"none":return e("move.amr.rightPanel.hud.status.none");default:return r}},{memo:PP}=await At("react"),RP=({localizationStatus:r="none",autoMove:e="none",obsState:t="none",poseX:n=0,poseY:i=0,poseZ:s=0,poseYaw:a=0,speed:o=0,velocityX:l=0,velocityY:c=0,velocityWz:d=0,roll:h=0,pitch:u=0,imuYaw:f=0,angularVelocity:m=0,inlierError:b=0,inlierRatio:p=0})=>{const{t:g}=tn();return C($,{className:"pointer-events-none absolute top-4 left-4 z-10 gap-2.5",children:[C(we,{className:"items-start gap-4",children:[C($,{className:"gap-0.5",children:[v("p",{className:"typo-body-2xs-semibold text-fg-subtler",children:g("move.amr.rightPanel.hud.localization")}),C(we,{className:"items-center gap-1 py-0.5",children:[v(ba,{className:`h-2.5 w-2.5 ${rg(r)}`}),v("span",{className:"typo-compact-2xs-semibold text-fg-default",children:CP(r,g)}),v("span",{className:"typo-compact-2xs-medium text-fg-subtler ml-2",children:g("move.amr.rightPanel.hud.inlierError")}),v("span",{className:"typo-compact-2xs-semibold text-fg-default",children:b.toFixed(3)}),v("span",{className:"typo-compact-2xs-medium text-fg-subtler ml-1",children:g("move.amr.rightPanel.hud.inlierRatio")}),v("span",{className:"typo-compact-2xs-semibold text-fg-default",children:p.toFixed(2)})]})]}),C($,{className:"gap-0.5",children:[v("p",{className:"typo-body-2xs-semibold text-fg-subtler",children:g("move.amr.rightPanel.hud.autoMove")}),C(we,{className:"items-center gap-1 py-0.5",children:[v(Wg,{className:`h-2.5 w-2.5 ${rg(e)}`}),v("span",{className:"typo-compact-2xs-semibold text-fg-default",children:e})]})]}),C($,{className:"gap-0.5",children:[v("p",{className:"typo-body-2xs-semibold text-fg-subtler",children:g("move.amr.rightPanel.hud.obstacleDetect")}),C(we,{className:"items-center gap-1 py-0.5",children:[v(jv,{className:`h-2.5 w-2.5 ${AP(t)}`}),v("span",{className:"typo-compact-2xs-semibold text-fg-default",children:t})]})]})]}),C($,{className:"gap-0.5",children:[v("p",{className:"typo-body-2xs-semibold text-fg-subtler",children:g("move.amr.rightPanel.hud.robotTransform")}),C($,{className:"gap-2",children:[C(we,{className:"items-center gap-3",children:[C($,{children:[v("p",{className:"typo-compact-2xs-medium text-fg-danger",children:"X"}),v("p",{className:"typo-compact-2xs-semibold text-fg-default",children:n.toFixed(3)})]}),C($,{children:[v("p",{className:"typo-compact-2xs-medium text-fg-success",children:"Y"}),v("p",{className:"typo-compact-2xs-semibold text-fg-default",children:i.toFixed(3)})]}),C($,{children:[v("p",{className:"typo-compact-2xs-medium text-fg-information",children:"Z"}),v("p",{className:"typo-compact-2xs-semibold text-fg-default",children:s.toFixed(3)})]}),C($,{children:[v("p",{className:"typo-compact-2xs-medium text-fg-information",children:"RZ"}),v("p",{className:"typo-compact-2xs-semibold text-fg-default",children:a.toFixed(3)})]}),C($,{children:[v("p",{className:"typo-compact-2xs-medium text-fg-subtle",children:g("move.amr.rightPanel.hud.speed")}),C("p",{className:"typo-compact-2xs-semibold text-fg-default",children:[o.toFixed(2)," m/s"]})]})]}),C(we,{className:"items-center gap-3",children:[C($,{children:[v("p",{className:"typo-compact-2xs-medium text-fg-subtle",children:"VX"}),v("p",{className:"typo-compact-2xs-semibold text-fg-default",children:l.toFixed(3)})]}),C($,{children:[v("p",{className:"typo-compact-2xs-medium text-fg-subtle",children:"VY"}),v("p",{className:"typo-compact-2xs-semibold text-fg-default",children:c.toFixed(3)})]}),C($,{children:[v("p",{className:"typo-compact-2xs-medium text-fg-subtle",children:"WZ"}),v("p",{className:"typo-compact-2xs-semibold text-fg-default",children:d.toFixed(3)})]})]})]})]}),C($,{className:"gap-0.5",children:[v("p",{className:"typo-body-2xs-semibold text-fg-subtler",children:g("move.amr.rightPanel.hud.imuSensor")}),C(we,{className:"items-center gap-3",children:[C($,{children:[v("p",{className:"typo-compact-2xs-medium text-fg-subtle",children:"Roll"}),C("p",{className:"typo-compact-2xs-semibold text-fg-default",children:[h>0?"+":"",h.toFixed(2),"°"]})]}),C($,{children:[v("p",{className:"typo-compact-2xs-medium text-fg-subtle",children:"Pitch"}),C("p",{className:"typo-compact-2xs-semibold text-fg-default",children:[u>0?"+":"",u.toFixed(2),"°"]})]}),C($,{children:[v("p",{className:"typo-compact-2xs-medium text-fg-subtle",children:"Yaw"}),C("p",{className:"typo-compact-2xs-semibold text-fg-default",children:[f>0?"+":"",f.toFixed(2),"°"]})]}),C($,{children:[v("p",{className:"typo-compact-2xs-medium text-fg-subtle uppercase",children:"ω"}),C("p",{className:"typo-compact-2xs-semibold text-fg-default",children:[m.toFixed(2)," deg/s"]})]})]})]})]})},QN=PP(RP),{useEffect:NP,useMemo:oh,useRef:DP,useState:eo}=await At("react"),JN=({open:r,close:e,onOpenChange:t,currentMap:n,onLoadMap:i,mapList:s})=>{const{t:a}=tn(),[o,l]=eo(1),[c,d]=eo(null),[h,u]=eo(""),[f,m]=eo(!1),[b,p]=eo(!1),g=DP(null),y=()=>{e?.(),t?.(!1)},x=O=>O>=1024*1024?`${(O/(1024*1024)).toFixed(1)} MB`:O>=1024?`${(O/1024).toFixed(1)} KB`:`${O} B`,w=oh(()=>(s?.list??[]).map((O,H)=>{const q=[...O.cloudInfo,...O.topoInfo].reduce((G,K)=>G+K.fileSize,0);return{id:`${H+1}`,name:O.mapName,modifiedDate:O.updatedAt,size:x(q)}}),[s?.list]),P=oh(()=>w.filter(O=>O.name.toLowerCase().includes(h.toLowerCase())),[w,h]),T=16,A=Math.max(1,Math.ceil(P.length/T)),M=Math.min(o,A),_=(M-1)*T,S=oh(()=>P.slice(_,_+T),[P,_,T]),R=O=>{const H=Math.max(1,Math.min(A,O));l(H)},k=()=>{if(!c)return;const O=w.find(H=>H.id===c);O&&(i(O.name),y())};return NP(()=>{if(!r){m(!1),p(!1);return}const O=g.current;if(!O)return;const H=O.querySelector('[data-slot="scroll-area-viewport"]');if(!H)return;const q=()=>{const G=H.scrollHeight>H.clientHeight+1,K=H.scrollTop+H.clientHeight>=H.scrollHeight-1,V=H.scrollTop>1;m(G&&V),p(G&&!K)};return q(),H.addEventListener("scroll",q),window.addEventListener("resize",q),()=>{H.removeEventListener("scroll",q),window.removeEventListener("resize",q)}},[S,r]),r?C($,{className:"fixed inset-0 z-50 items-center justify-center p-4",children:[v("button",{type:"button","aria-label":a("move.amr.rightPanel.map.loadDialog.closeBackdrop"),className:"bg-bg-dim absolute inset-0",onClick:y}),C($,{className:"bg-bg-overlay relative h-[560px] w-full max-w-4xl overflow-hidden rounded-lg p-4",children:[v($,{className:"shrink-0 gap-0.5 p-1",children:C(we,{className:"items-start justify-between",children:[v(we,{className:"items-center gap-2 pb-2",children:C($,{className:"gap-0.5",children:[v("p",{className:"typo-compact-lg-semibold text-fg-default",children:a("move.amr.rightPanel.map.loadDialog.title")}),v("p",{className:"typo-compact-xs-normal text-fg-subtler",children:a("move.amr.rightPanel.map.loadDialog.description")})]})}),v(Kn,{variant:"transparent",size:"2xs",icon:v(Ao,{}),className:"text-fg-subtle",onClick:y})]})}),C($,{className:"min-h-0 flex-1 gap-2",children:[v(we,{className:"bg-alt-1 items-center justify-between rounded-md px-2.5 py-2 [[data-theme='light']_&]:bg-white",children:C(we,{className:"items-center gap-1",children:[v("p",{className:"typo-compact-xs-semibold text-fg-success",children:a("move.amr.rightPanel.map.loadDialog.currentMap")}),v("p",{className:"typo-compact-xs-semibold text-fg-default",children:n||"-"})]})}),v($,{className:"shrink-0 gap-3",children:v(Rn,{type:"search",value:h,placeholder:a("move.amr.rightPanel.map.loadDialog.searchPlaceholder"),prefixIcon:v(Xv,{className:"text-fg-subtler"}),onChange:O=>{u(O.target.value),l(1)},className:"w-full"})}),C($,{ref:g,className:"relative min-h-0 flex-1 overflow-hidden",children:[f&&v("div",{className:"from-bg-overlay pointer-events-none absolute inset-x-0 top-0 z-10 h-4 bg-gradient-to-b to-transparent"}),v(Zv,{className:"h-full min-h-0 w-full overflow-hidden",viewportClassName:"h-full w-full",children:v("div",{className:"grid grid-cols-2 gap-2 pr-2",children:S.length>0?S.map(O=>{const H=c===O.id,q=O.name===n;return v("button",{type:"button",onClick:()=>d(O.id),className:`rounded-md border px-3 py-2.5 text-left transition-colors ${H?"border-fg-brand bg-fill-brand-subtlest":q?"border-fg-success bg-fill-success-subtlest":"bg-fill-inverse-subtle hover:bg-fill-inverse-subtler border-subtle [[data-theme='light']_&]:bg-white"}`,children:C(we,{className:"items-start",children:[C($,{className:"min-w-0 flex-1 justify-between gap-2",children:[v("p",{className:"typo-compact-sm-semibold text-fg-default truncate",children:O.name}),C($,{className:"gap-0.5",children:[C(we,{className:"gap-1",children:[C("p",{className:"typo-compact-xs-normal text-fg-subtler",children:[a("move.amr.rightPanel.map.loadDialog.modified"),":"]}),v("p",{className:"typo-compact-xs-normal text-fg-default",children:O.modifiedDate})]}),C(we,{className:"gap-1",children:[C("p",{className:"typo-compact-xs-normal text-fg-subtler",children:[a("move.amr.rightPanel.map.loadDialog.size"),":"]}),v("p",{className:"typo-compact-xs-normal text-fg-default",children:O.size})]})]})]}),H&&v(qv,{className:"text-fg-brand size-4"}),!H&&q&&v("p",{className:"typo-compact-2xs-semibold text-fg-success uppercase",children:a("move.amr.rightPanel.map.loadDialog.current")})]})},O.id)}):C($,{className:"col-span-2 items-center justify-center py-10",children:[v("p",{className:"typo-compact-sm-normal text-fg-subtler",children:a("move.amr.rightPanel.map.loadDialog.noMapsFound")}),v("p",{className:"typo-compact-2xs-normal text-fg-subtler",children:a("move.amr.rightPanel.map.loadDialog.tryDifferentSearch")})]})})}),b&&v("div",{className:"from-bg-overlay pointer-events-none absolute inset-x-0 bottom-0 h-4 bg-gradient-to-t to-transparent"})]})]}),C($,{className:"shrink-0 gap-3",children:[v(we,{className:"justify-center",children:v(Yv,{currPage:M,listSize:T,pageSize:5,totalCount:P.length,handlePageChange:R})}),C(we,{className:"items-center justify-end gap-2",children:[v(nt,{variant:"outlined",onClick:y,children:a("move.amr.rightPanel.common.cancel")}),v(nt,{variant:"brand",disabled:!c,onClick:k,children:a("move.amr.rightPanel.map.loadDialog.loadSelectedMap")})]})]})]})]}):null},{memo:LP}=await At("react"),IP=({mapName:r,onMapNameClick:e})=>{const t=!r,{theme:n}=Ea();return v("div",{onClick:()=>{e&&e()},className:`shadow-down-xs ${n==="light"?"bg-default":"bg-alt-1"} hover:bg-alt-2 absolute top-4 left-1/2 z-10 -translate-x-1/2 cursor-pointer rounded-md border px-4 py-2 backdrop-blur-sm transition-all duration-200 hover:scale-105 ${t?"border-default border-dashed":"border-default"}`,children:C("div",{className:"flex items-center gap-1 px-0.5",children:[v(Ry,{className:`h-4 w-4 ${t?"text-fg-subtle":"text-fg-default"}`}),v("span",{className:"text-fg-default typo-compact-xs-semibold",children:r}),t&&v("span",{className:"text-fg-subtle typo-compact-xs-medium",children:"Empty"})]})})},e2=LP(IP),{memo:kP}=await At("react"),OP=[{id:"select",icon:Wg,label:"Select",labelKey:"move.amr.leftToolBar.select",shortcut:"V"},{id:"target",icon:Cy,label:"Cursor",labelKey:"move.amr.leftToolBar.cursor",shortcut:"T"}],FP=[{id:"move",icon:Kv,label:"Move",labelKey:"move.amr.leftToolBar.move",shortcut:"G"},{id:"rotate",icon:jg,label:"Rotate",labelKey:"move.amr.leftToolBar.rotate",shortcut:"R"},{id:"scale",icon:$v,label:"Scale",labelKey:"move.amr.leftToolBar.scale",shortcut:"S"}],UP=[OP,FP],BP=({selectedTool:r,onToolChange:e,hasSelectedZone:t=!1,toolGroups:n,className:i})=>{const{theme:s}=Ea(),{t:a}=tn(),o=s==="light"?"bg-default":"bg-alt-1",l=n??UP;return v($,{className:$t("gap-2",i),children:l.map((c,d)=>v("div",{className:"overflow-visible rounded-lg bg-transparent",children:c.map(h=>{const u=r===h.id,f=t&&(h.id==="rotate"||h.id==="scale"),m=h.labelKey?a(h.labelKey):h.label,b=h.ariaLabelKey?a(h.ariaLabelKey):h.ariaLabel??m,p=h.shortcut?`${m} (${h.shortcut})`:m;return C("div",{className:"group relative",children:[v(Kn,{variant:"transparent",size:"xs2",onClick:()=>e(h.id),disabled:f,className:$t(o,"shadow-down-xs relative rounded-sm",!f&&"hover:!text-fg-default !text-fg-default",!f&&s==="light"?"hover:!bg-white":!f&&"hover:!bg-bg-alt-1"),icon:C(hi,{children:[u?v("span",{className:"bg-fill-subtler pointer-events-none absolute inset-1 rounded-md"}):null,v(h.icon,{className:$t("relative z-10 h-4 w-4",f?"!text-fg-disabled":"!text-fg-default")})]}),"aria-label":b}),v("p",{className:`typo-compact-xs2-normal ${o} text-fg-default border-border-subtle pointer-events-none invisible absolute top-1/2 left-full z-30 ml-2 -translate-y-1/2 rounded border px-2 py-1.5 whitespace-nowrap shadow-md group-hover:visible`,children:p})]},h.id)})},d))})},t2=kP(BP),{memo:zP}=await At("react"),lh={fullscreen:"right-2",menuExpanded:"right-33",menuCollapsed:"right-12"},HP=({isLive:r,pointCount:e,latency:t,fps:n,nodeCount:i,linkCount:s,onToggleRobotControl:a,onToggleCameraStreams:o,onToggleObstacleMap:l,showCameraStreams:c,showObstacleMap:d,showDebugPanel:h,onToggleDebugPanel:u,showRobotControlBtn:f,isFullscreen:m=!1,isMenuExpanded:b=!1})=>{const{theme:p}=Ea(),{t:g}=tn(),y=!f,x=m?lh.fullscreen:b?lh.menuExpanded:lh.menuCollapsed;return C("div",{className:"pointer-events-none absolute bottom-0 z-50 flex h-10 w-full items-center justify-between bg-transparent px-4 text-xs",children:[C("div",{className:"flex items-center gap-3",children:[C("div",{className:"flex items-center gap-1",children:[v("div",{className:`h-2 w-2 rounded-full ${r?"animate-pulse bg-green-500":"bg-gray-600"}`}),v("span",{className:"text-fg-default typo-compact-2xs-semibold",children:g(r?"move.amr.rightPanel.bottomBar.liveStream":"move.amr.rightPanel.bottomBar.offline")})]}),C("div",{className:"flex items-center gap-1",children:[C("span",{className:"text-fg-subtler typo-compact-2xs-normal",children:[g("move.amr.rightPanel.bottomBar.points"),":"]}),v("span",{className:"typo-compact-2xs-semibold text-fg-default",children:e.toLocaleString()})]}),C("div",{className:"flex items-center gap-1",children:[C("span",{className:"text-fg-subtler typo-compact-2xs-normal",children:[g("move.amr.rightPanel.bottomBar.nodes"),":"]}),v("span",{className:"typo-compact-2xs-semibold text-fg-default",children:i})]}),C("div",{className:"flex items-center gap-1",children:[C("span",{className:"text-fg-subtler typo-compact-2xs-normal",children:[g("move.amr.rightPanel.bottomBar.links"),":"]}),v("span",{className:"typo-compact-2xs-semibold text-fg-default",children:s})]})]}),C("div",{className:$t("pointer-events-auto absolute flex items-center gap-1.5",x),children:[v(nt,{size:"2xs",variant:"inverse",leadingIcon:v(Sh,{}),onClick:o,className:$t(!c&&(p==="light"?"bg-white hover:!bg-white":"bg-alt-1 hover:!bg-alt-2"),"shadow-down-xs gap-2"),children:g("move.amr.rightPanel.bottomBar.camera")}),v(nt,{size:"2xs",variant:"inverse",leadingIcon:v(Xg,{}),onClick:l,className:$t(!d&&(p==="light"?"bg-white hover:!bg-white":"bg-alt-1 hover:!bg-alt-2"),"shadow-down-xs gap-2"),children:g("move.amr.rightPanel.bottomBar.obstacleMap")}),v(nt,{size:"2xs",variant:"inverse",leadingIcon:v(Qv,{}),onClick:a,className:$t(!y&&(p==="light"?"bg-white hover:!bg-white":"bg-alt-1 hover:!bg-alt-2"),"shadow-down-xs gap-2"),children:g("move.amr.rightPanel.bottomBar.controlPanel")}),v(nt,{size:"2xs",variant:"inverse",leadingIcon:v(Jv,{}),onClick:u,className:$t(!h&&(p==="light"?"bg-white hover:!bg-white":"bg-alt-1 hover:!bg-alt-2"),"shadow-down-xs gap-2"),children:g("move.amr.rightPanel.menu.debug")})]})]})},n2=zP(HP),{useEffect:GP,useRef:VP,useState:bi}=await At("react"),WP=["button","point","manual"],ag={KeyW:"forward",KeyA:"left",KeyS:"backward",KeyD:"right",KeyQ:"rotateLeft",KeyE:"rotateRight"},og=r=>{if(!(r instanceof HTMLElement))return!1;const e=r.tagName.toLowerCase();return r.isContentEditable||e==="input"||e==="textarea"||e==="select"},i2=({robotPose:r,handleButtonJog:e,onClose:t,onMoveTarget:n,onMoveLinear:i,linearSpeed:s,setLinearSpeed:a,rotationSpeed:o,setRotationSpeed:l,className:c})=>{const{t:d}=tn(),[h,u]=bi("button"),f=VP(null),[m,b]=bi("0.5"),[p,g]=bi("0.5"),[y,x]=bi("45"),[w,P]=bi("45"),[T,A]=bi("0.0"),[M,_]=bi("0.0"),[S,R]=bi("0.0"),[k,O]=bi("0.0"),[H,q]=bi("x"),[G,K]=bi("1.0"),[V,Z]=bi("0.5"),[le,se]=bi(80),ge=()=>{n({goalPose:{x:Number.parseFloat(T)||0,y:Number.parseFloat(M)||0,rz:Number.parseFloat(k)||0},method:"pp",preset:1})},de=()=>{const X=Number.parseFloat(G)||0,ee=Number.parseFloat(V)||0;i({axis:H,target:X,speed:ee})};return GP(()=>{if(typeof window>"u")return;const X=()=>{f.current!==null&&(f.current=null,e("stop"))},ee=Y=>{if(h!=="button"||Y.repeat||og(Y.target))return;const ue=ag[Y.code];ue&&(Y.preventDefault(),f.current!==ue&&(f.current=ue,e(ue)))},ie=Y=>{if(h!=="button"||og(Y.target))return;const ue=ag[Y.code];!ue||f.current!==ue||(Y.preventDefault(),X())};return window.addEventListener("keydown",ee),window.addEventListener("keyup",ie),window.addEventListener("blur",X),()=>{window.removeEventListener("keydown",ee),window.removeEventListener("keyup",ie),window.removeEventListener("blur",X),X()}},[h,e]),C($,{className:$t("border-subtle shadow-down-lg pointer-events-auto w-[39.375rem] overflow-hidden rounded-lg border",c),style:{backgroundColor:`color-mix(in srgb, var(--color-bg-alt-1) ${Math.max(0,Math.min(100,le))}%, transparent)`},children:[C(we,{className:"border-subtle items-center justify-between gap-4 border-b px-3",children:[v(Zg,{className:"min-h-0 flex-1",variant:"line",value:h,onValueChange:X=>{WP.includes(X)&&u(X)},children:C(qg,{children:[v(vr,{value:"button",children:d("move.amr.rightPanel.controlPanel.tab.button")}),v(vr,{value:"point",children:d("move.amr.rightPanel.controlPanel.tab.point")}),v(vr,{value:"manual",children:d("move.amr.rightPanel.controlPanel.tab.linear")})]})}),C(we,{className:"h-8 shrink-0 items-center gap-2",children:[v("p",{className:"typo-compact-xs2-normal text-fg-subtle",children:d("move.amr.rightPanel.controlPanel.transparency")}),C("p",{className:"typo-compact-xs2-semibold text-fg-default w-8 text-right",children:[le,"%"]}),v(Rc,{value:[le],min:0,max:100,step:1,onValueChange:X=>{const ee=X[0];se(ee)},className:"w-24"}),v(Kn,{icon:v(Ao,{}),variant:"transparent",size:"2xs",onClick:t})]})]}),C($,{className:"p-3 pb-3.5",children:[h==="button"&&C($,{className:"gap-2",children:[v("p",{className:"typo-compact-xs2-normal text-fg-information",children:d("move.amr.rightPanel.controlPanel.button.description")}),C(we,{className:"items-end gap-4",children:[C($,{className:"min-w-0 flex-1 gap-2.5",children:[C(we,{className:"items-start gap-3",children:[C("p",{className:"typo-compact-xs2-medium text-fg-subtler shrink-0",children:[d("move.amr.rightPanel.controlPanel.linearMotion.line1"),v("br",{}),d("move.amr.rightPanel.controlPanel.linearMotion.line2")]}),C("div",{className:"grid flex-1 grid-cols-3 gap-1",children:[C($,{className:"min-w-0 gap-1.5",children:[v("p",{className:"typo-compact-xs-semibold text-fg-default truncate",children:d("move.amr.rightPanel.controlPanel.speedMs")}),v(Rn,{size:"xs2",type:"number",value:s,className:"!w-full",onChange:X=>{a(Number.parseFloat(X.target.value)||0)}})]}),C($,{className:"min-w-0 gap-1.5",children:[v("p",{className:"typo-compact-xs-semibold text-fg-default truncate",children:d("move.amr.rightPanel.controlPanel.accelMs2")}),v(Rn,{size:"xs2",type:"number",value:m,className:"!w-full",disabled:!0,onChange:X=>{b(X.target.value)}})]}),C($,{className:"min-w-0 gap-1.5",children:[v("p",{className:"typo-compact-xs-semibold text-fg-default truncate",children:d("move.amr.rightPanel.controlPanel.decelMs2")}),v(Rn,{size:"xs2",type:"number",value:p,className:"!w-full",disabled:!0,onChange:X=>{g(X.target.value)}})]})]})]}),C(we,{className:"items-start gap-3",children:[C("p",{className:"typo-compact-xs2-medium text-fg-subtler shrink-0",children:[d("move.amr.rightPanel.controlPanel.angularMotion.line1"),v("br",{}),d("move.amr.rightPanel.controlPanel.angularMotion.line2")]}),C("div",{className:"grid flex-1 grid-cols-3 gap-1",children:[C($,{className:"min-w-0 gap-1.5",children:[v("p",{className:"typo-compact-xs-semibold text-fg-default truncate",children:d("move.amr.rightPanel.controlPanel.speedDegS")}),v(Rn,{size:"xs2",type:"number",value:o,className:"!w-full",onChange:X=>{l(Number.parseFloat(X.target.value)||0)}})]}),C($,{className:"min-w-0 gap-1.5",children:[v("p",{className:"typo-compact-xs-semibold text-fg-default truncate",children:d("move.amr.rightPanel.controlPanel.accelDegS2")}),v(Rn,{size:"xs2",type:"number",value:y,className:"!w-full",disabled:!0,onChange:X=>{x(X.target.value)}})]}),C($,{className:"min-w-0 gap-1.5",children:[v("p",{className:"typo-compact-xs-semibold text-fg-default truncate",children:d("move.amr.rightPanel.controlPanel.decelDegS2")}),v(Rn,{size:"xs2",type:"number",value:w,className:"!w-full",disabled:!0,onChange:X=>{P(X.target.value)}})]})]})]})]}),C($,{className:"w-[8.25rem] shrink-0 items-center gap-1.5",children:[C("div",{className:"grid grid-cols-[2.5rem_2.5rem_2.5rem] grid-rows-2 gap-1.5",children:[v("div",{className:"size-10"}),v(Kn,{variant:"soft",icon:v(Hg,{}),className:"border-subtle size-10 border-t",onMouseDown:()=>e("forward"),onMouseUp:()=>e("stop"),onMouseLeave:()=>e("stop")}),v("div",{className:"size-10"}),v(Kn,{variant:"soft",icon:v(Gg,{}),className:"border-subtle size-10 border-t",onMouseDown:()=>e("left"),onMouseUp:()=>e("stop"),onMouseLeave:()=>e("stop")}),v(Kn,{variant:"soft",icon:v(Vg,{}),className:"border-subtle size-10 border-t",onMouseDown:()=>e("backward"),onMouseUp:()=>e("stop"),onMouseLeave:()=>e("stop")}),v(Kn,{variant:"soft",icon:v(Pu,{}),className:"border-subtle size-10 border-t",onMouseDown:()=>e("right"),onMouseUp:()=>e("stop"),onMouseLeave:()=>e("stop")})]}),C("div",{className:"grid w-full grid-cols-2 gap-1.5",children:[v(nt,{leadingIcon:v(ey,{}),size:"xs",variant:"soft",className:"typo-compact-xs-semibold h-7 w-full",onMouseDown:()=>e("rotateLeft"),onMouseUp:()=>e("stop"),onMouseLeave:()=>e("stop"),children:d("move.amr.rightPanel.controlPanel.left")}),v(nt,{leadingIcon:v(ty,{}),size:"xs",variant:"soft",className:"typo-compact-xs-semibold h-7 w-full",onMouseDown:()=>e("rotateRight"),onMouseUp:()=>e("stop"),onMouseLeave:()=>e("stop"),children:d("move.amr.rightPanel.controlPanel.right")})]})]})]})]}),h==="point"&&C($,{className:"justify-between gap-2",children:[v("p",{className:"typo-compact-xs2-normal text-fg-information",children:d("move.amr.rightPanel.controlPanel.point.description")}),C($,{className:"gap-3",children:[C("div",{className:"grid grid-cols-4 gap-2",children:[C($,{className:"min-w-0 gap-1.5",children:[C(we,{className:"gap-1",children:[v("p",{className:"typo-compact-xs-medium text-fg-danger",children:"X"}),v("p",{className:"typo-compact-xs-medium text-fg-subtle",children:"(m)"})]}),v(Rn,{size:"xs2",type:"number",className:"!w-full",value:T,onChange:X=>{A(X.target.value)}})]}),C($,{className:"min-w-0 gap-1.5",children:[C(we,{className:"gap-1",children:[v("p",{className:"typo-compact-xs-medium text-fg-success",children:"Y"}),v("p",{className:"typo-compact-xs-medium text-fg-subtle",children:"(m)"})]}),v(Rn,{size:"xs2",type:"number",className:"!w-full",value:M,onChange:X=>{_(X.target.value)}})]}),C($,{className:"min-w-0 gap-1.5",children:[C(we,{className:"gap-1",children:[v("p",{className:"typo-compact-xs-medium text-fg-brand",children:"Z"}),v("p",{className:"typo-compact-xs-medium text-fg-subtle",children:"(m)"})]}),v(Rn,{size:"xs2",type:"number",className:"!w-full",value:S,onChange:X=>{R(X.target.value)}})]}),C($,{className:"min-w-0 gap-1.5",children:[C(we,{className:"gap-1",children:[v("p",{className:"typo-compact-xs-medium text-fg-debug",children:"Theta"}),v("p",{className:"typo-compact-xs-medium text-fg-subtle",children:"(°)"})]}),v(Rn,{size:"xs2",type:"number",className:"!w-full",value:k,onChange:X=>{O(X.target.value)}})]})]}),C(we,{className:"items-center justify-between gap-3",children:[C(we,{className:"min-w-0 items-center gap-0.5",children:[v(Cu,{className:"text-fg-subtle size-3.5 shrink-0"}),v("p",{className:"typo-compact-xs2-normal text-fg-subtle min-w-0 truncate",children:d("move.amr.rightPanel.controlPanel.currentPose",{x:r.x.toFixed(2),y:r.y.toFixed(2),yaw:r.yaw.toFixed(1)})})]}),v(nt,{size:"xs2",variant:"brand",className:"h-8 w-32 !px-3",onClick:ge,children:d("move.amr.rightPanel.controlPanel.moveToPoint")})]})]})]}),h==="manual"&&C($,{className:"justify-between gap-2",children:[v("p",{className:"typo-compact-xs2-normal text-fg-information",children:d("move.amr.rightPanel.controlPanel.linear.description")}),C($,{className:"gap-3",children:[C("div",{className:"grid grid-cols-3 gap-2",children:[C($,{className:"min-w-0 gap-1.5",children:[v("p",{className:"typo-compact-xs-semibold text-fg-default",children:d("move.amr.rightPanel.controlPanel.axis")}),C("div",{className:"grid grid-cols-2 gap-1.5",children:[v(nt,{variant:H==="x"?"brand":"soft",size:"xs2",className:"h-8 w-full !px-3",onClick:()=>{q("x")},children:"X"}),v(nt,{variant:H==="y"?"brand":"soft",size:"xs2",className:"h-8 w-full !px-3",onClick:()=>{q("y")},children:"Y"})]})]}),C($,{className:"min-w-0 gap-1.5",children:[v("p",{className:"typo-compact-xs-semibold text-fg-default",children:d("move.amr.rightPanel.controlPanel.targetM")}),v(Rn,{size:"xs2",type:"number",className:"!w-full",value:G,onChange:X=>{K(X.target.value)}})]}),C($,{className:"min-w-0 gap-1.5",children:[v("p",{className:"typo-compact-xs-semibold text-fg-default",children:d("move.amr.rightPanel.controlPanel.speedMs")}),v(Rn,{size:"xs2",type:"number",className:"!w-full",value:V,onChange:X=>{Z(X.target.value)}})]})]}),v(we,{className:"justify-end",children:v(nt,{size:"xs2",variant:"brand",className:"h-8 w-32 !px-3",onClick:de,children:d("move.amr.rightPanel.controlPanel.executeMove")})})]})]})]})]})},{memo:jP}=await At("react"),XP=(r,e)=>{switch(r){case"left":return`translate(calc(-100% - ${e}px), -50%)`;case"top":return`translate(-50%, calc(-100% - ${e}px))`;case"bottom":return`translate(-50%, ${e}px)`;case"right":default:return`translate(${e}px, -50%)`}},lg=r=>typeof r!="number"||Number.isNaN(r)?"-":r.toFixed(3),qP=r=>typeof r!="number"||Number.isNaN(r)?"-":`${(r*180/Math.PI).toFixed(3)}°`,ZP=({visible:r=!0,x:e,y:t,currentX:n,currentY:i,currentRz:s,placement:a="right",offset:o=65,nodeName:l,onEdit:c,onDelete:d,onMove:h,className:u=""})=>r?C($,{className:`pointer-events-none absolute z-30 max-w-[calc(100vw-32px)] min-w-[220px] rounded-md bg-[#2b2b2f]/65 px-4 py-3 ${u}`,style:{left:e,top:t,transform:XP(a,o)},children:[C(we,{className:"items-center justify-between gap-3",children:[C(we,{className:"min-w-0 items-center",children:[v("p",{className:"typo-compact-sm2-semibold text-fg-subtler mr-3",children:"Name"}),v("span",{className:"typo-compact-sm-semibold text-fg-default truncate",children:l})]}),c&&v(Kn,{className:"pointer-events-auto",variant:"transparent",size:"2xs","aria-label":"Edit node",icon:v(Ru,{}),onClick:c})]}),C(we,{className:"flex flex-wrap gap-x-7",children:[C("p",{className:"whitespace-nowrap",children:[v("span",{className:"text-fg-danger typo-compact-sm2-semibold mr-3",children:"X"}),v("span",{className:"typo-compact-sm-semibold text-fg-default",children:lg(n)})]}),C("p",{className:"whitespace-nowrap",children:[v("span",{className:"text-fg-success typo-compact-sm2-semibold mr-3",children:"Y"}),v("span",{className:"typo-compact-sm-semibold text-fg-default",children:lg(i)})]}),C("p",{className:"whitespace-nowrap",children:[v("span",{className:"typo-compact-sm2-semibold text-fg-information mr-3",children:"RZ"}),v("span",{className:"typo-compact-sm-semibold text-fg-default",children:qP(s)})]})]}),(d||h)&&C(we,{className:"pointer-events-auto mt-3 gap-2",children:[d&&v(nt,{variant:"danger",size:"sm",onClick:d,children:"Delete"}),h&&v(nt,{variant:"soft",size:"sm",onClick:h,children:"Move To Node"})]})]}):null,s2=jP(ZP),{memo:YP}=await At("react"),KP=(r,e)=>{switch(r){case"left":return`translate(calc(-100% - ${e}px), -50%)`;case"top":return`translate(-50%, calc(-100% - ${e}px))`;case"bottom":return`translate(-50%, ${e}px)`;case"right":default:return`translate(${e}px, -50%)`}},$P=r=>typeof r!="number"||Number.isNaN(r)?"-":r.toFixed(2),QP=({visible:r=!0,x:e,y:t,items:n,activeItemId:i,onSelectItem:s,onEdit:a,onDelete:o,placement:l="right",offset:c=65,className:d=""})=>{if(!r||n.length===0)return null;const h=n.find(u=>u.id===i)??n[0]??null;return h?C($,{className:`pointer-events-none absolute z-30 max-w-[calc(100vw-32px)] min-w-[260px] rounded-md bg-[#2b2b2f]/65 px-4 py-3 ${d}`,style:{left:e,top:t,transform:KP(l,c)},children:[n.length>1&&v(we,{className:"pointer-events-auto mb-2 gap-1.5",children:n.map((u,f)=>{const m=u.id===h.id;return v("button",{type:"button",className:`typo-compact-xs-semibold rounded-md px-2 py-1 transition-colors ${m?"bg-fill-brand text-fg-white":"bg-fill-control-surface text-fg-default hover:bg-fill-subtle"}`,onClick:()=>{s?.(u.id)},children:`Link ${f+1}`},u.id)})}),C(we,{className:"items-center justify-between gap-3",children:[C(we,{className:"min-w-0 items-center",children:[v("p",{className:"typo-compact-sm2-semibold text-fg-subtler mr-3",children:"Link"}),v("span",{className:"typo-compact-sm-semibold text-fg-default truncate",children:h.title})]}),a&&v(Kn,{className:"pointer-events-auto",variant:"transparent",size:"2xs","aria-label":"Edit link",icon:v(Ru,{}),onClick:a})]}),C(we,{className:"flex flex-wrap gap-x-7",children:[C("p",{className:"whitespace-nowrap",children:[v("span",{className:"typo-compact-sm2-semibold text-fg-warning mr-3",children:"DIR"}),v("span",{className:"typo-compact-sm-semibold text-fg-default",children:h.dir})]}),C("p",{className:"whitespace-nowrap",children:[v("span",{className:"typo-compact-sm2-semibold text-fg-brand mr-3",children:"METHOD"}),v("span",{className:"typo-compact-sm-semibold text-fg-default",children:h.method})]}),C("p",{className:"whitespace-nowrap",children:[v("span",{className:"typo-compact-sm2-semibold text-fg-success mr-3",children:"SPEED"}),v("span",{className:"typo-compact-sm-semibold text-fg-default",children:$P(h.speed)})]})]}),o&&v(we,{className:"pointer-events-auto mt-3 gap-2",children:v(nt,{variant:"danger",size:"sm",onClick:o,children:"Delete"})})]}):null},r2=YP(QP),{memo:JP}=await At("react"),eR=(r,e)=>{switch(r){case"left":return`translate(calc(-100% - ${e}px), -50%)`;case"top":return`translate(-50%, calc(-100% - ${e}px))`;case"bottom":return`translate(-50%, ${e}px)`;case"right":default:return`translate(${e}px, -50%)`}},tR=({visible:r=!0,x:e,y:t,items:n,activeItemId:i,onSelectItem:s,onEdit:a,onDelete:o,placement:l="right",offset:c=65,className:d=""})=>{if(!r||n.length===0)return null;const h=n.find(u=>u.id===i)??n[0]??null;return h?C($,{className:`pointer-events-none absolute z-30 max-w-[calc(100vw-32px)] min-w-[260px] rounded-md bg-[#2b2b2f]/65 px-4 py-3 ${d}`,style:{left:e,top:t,transform:eR(l,c)},children:[n.length>1&&v(we,{className:"pointer-events-auto mb-2 gap-1.5",children:n.map((u,f)=>{const m=u.id===h.id;return v("button",{type:"button",className:`typo-compact-xs-semibold rounded-md px-2 py-1 transition-colors ${m?"bg-fill-brand text-fg-white":"bg-fill-control-surface text-fg-default hover:bg-fill-subtle"}`,onClick:()=>{s?.(u.id)},children:`Zone ${f+1}`},u.id)})}),C(we,{className:"items-center justify-between gap-3",children:[C(we,{className:"min-w-0 items-center",children:[v("p",{className:"typo-compact-sm2-semibold text-fg-subtler mr-3",children:"Zone"}),v("span",{className:"typo-compact-sm-semibold text-fg-default truncate",children:h.title})]}),a&&v(Kn,{className:"pointer-events-auto",variant:"transparent",size:"2xs","aria-label":"Edit zone",icon:v(Ru,{}),onClick:a})]}),C(we,{className:"flex flex-wrap gap-x-7",children:[C("p",{className:"whitespace-nowrap",children:[v("span",{className:"typo-compact-sm2-semibold text-fg-warning mr-3",children:"TYPE"}),v("span",{className:"typo-compact-sm-semibold text-fg-default",children:h.type})]}),C("p",{className:"whitespace-nowrap",children:[v("span",{className:"typo-compact-sm2-semibold text-fg-brand mr-3",children:"POINTS"}),v("span",{className:"typo-compact-sm-semibold text-fg-default",children:h.pointCount})]})]}),o&&v(we,{className:"pointer-events-auto mt-3 gap-2",children:v(nt,{variant:"danger",size:"sm",onClick:o,children:"Delete"})})]}):null},a2=JP(tR),{memo:nR,useCallback:ch,useEffect:cg,useRef:dr,useState:$l}=await At("react"),Ql={width:630,height:320},Jl={width:420,height:180},dg=24,hg=(r,e,t)=>Math.min(Math.max(r,e),t),iR=({cameras:r,onClose:e,onQualityChange:t})=>{const{t:n}=tn(),[i,s]=$l({x:0,y:0}),[a,o]=$l(Ql),[l,c]=$l(null),[d,h]=$l(80),u=dr(null),f=dr({x:0,y:0}),m=dr(Ql),b=dr(!1),p=dr(!1),g=dr({mouseX:0,mouseY:0,panelX:0,panelY:0}),y=dr({mouseX:0,mouseY:0,panelX:0,panelY:0,width:Ql.width,height:Ql.height}),x=r.find(A=>A.id===l&&A.status==="live"&&A.streamUrl),w=ch(A=>{A.preventDefault(),!p.current&&(b.current=!0,document.body.style.cursor="grabbing",g.current={mouseX:A.clientX,mouseY:A.clientY,panelX:f.current.x,panelY:f.current.y})},[]),P=ch(A=>{A.preventDefault(),A.stopPropagation();const M=u.current?.getBoundingClientRect();p.current=!0,document.body.style.cursor="se-resize",document.body.style.userSelect="none",y.current={mouseX:A.clientX,mouseY:A.clientY,panelX:f.current.x,panelY:f.current.y,width:M?.width??m.current.width,height:M?.height??m.current.height}},[]),T=ch(A=>{c(A)},[]);return cg(()=>{const A=_=>{if(b.current){const S=g.current.panelX+(_.clientX-g.current.mouseX),R=g.current.panelY+(_.clientY-g.current.mouseY);f.current={x:S,y:R},u.current&&(u.current.style.transform=`translate(${S}px, ${R}px)`)}if(p.current){const S=hg(y.current.width+(_.clientX-y.current.mouseX),Jl.width,Math.max(Jl.width,window.innerWidth-dg)),R=hg(y.current.height+(_.clientY-y.current.mouseY),Jl.height,Math.max(Jl.height,window.innerHeight-dg)),k={width:S,height:R},O={x:y.current.panelX+(S-y.current.width),y:y.current.panelY+(R-y.current.height)};m.current=k,f.current=O,o(k),s(O)}},M=()=>{const _=b.current,S=p.current;_&&(b.current=!1,document.body.style.cursor="",s({...f.current})),S&&(p.current=!1,document.body.style.cursor="",document.body.style.userSelect="")};return window.addEventListener("mousemove",A),window.addEventListener("mouseup",M),()=>{window.removeEventListener("mousemove",A),window.removeEventListener("mouseup",M),document.body.style.cursor="",document.body.style.userSelect=""}},[]),cg(()=>{l&&!r.some(A=>A.id===l)&&c(null)},[r,l]),C("div",{className:"pointer-events-auto",children:[v(ny,{className:"bg-overlay border-subtle [&_[data-slot='dialog-close']]:text-fg-subtle [&_[data-slot='dialog-header']>h2]:text-fg-default [&_[data-slot='dialog-header']>h2]:typo-title-01-bold block !max-w-[70vw] overflow-hidden rounded-lg border-1 !border-solid p-0 shadow-[0px_0px_2px_0px_rgba(9,9,11,0.20)] [&_[data-slot='dialog-close']]:top-3 [&_[data-slot='dialog-close']]:right-3 [&_[data-slot='dialog-header']]:gap-0.5 [&_[data-slot='dialog-header']]:pt-3 [&_[data-slot='dialog-header']]:pr-16 [&_[data-slot='dialog-header']]:pb-2 [&_[data-slot='dialog-header']]:pl-4 [&_[data-slot='dialog-header']]:text-left",open:!!x,onOpenChange:A=>{A||c(null)},header:{title:x?.name??n("move.amr.rightPanel.cameraPanel.title")},children:x&&v("div",{className:"!bg-alt-2 flex h-full flex-col justify-between",children:v("div",{className:"bg-base-black h-[calc(var(--vh,1vh)*70)] overflow-hidden",children:v(_f,{className:"bg-base-black h-full w-full overflow-hidden [&_video]:object-cover",url:x.streamUrl??"",label:x.name,lebelPosition:"top-left",initStatus:!0,disconnectedMessage:n("move.amr.rightPanel.cameraPanel.disconnected"),loadingMessage:n("move.amr.rightPanel.cameraPanel.connecting")})})})}),C("div",{ref:u,className:"border-subtle shadow-down-lg relative flex flex-col overflow-hidden rounded-lg border",style:{backgroundColor:`color-mix(in srgb, var(--color-bg-alt-1) ${Math.max(0,Math.min(100,d))}%, transparent)`,transform:`translate(${i.x}px, ${i.y}px)`,width:a.width,height:a.height},children:[C("div",{className:"border-subtle flex shrink-0 cursor-grab items-center justify-start gap-0.5 border-b py-1 pr-2 pl-3 select-none",onMouseDown:w,children:[C("div",{className:"typo-compact-xs2-semibold flex flex-1 items-center justify-start gap-1",children:[v("span",{className:"text-fg-default",children:n("move.amr.rightPanel.cameraPanel.title")}),v("span",{className:"text-fg-brand",children:r.length})]}),C("div",{className:"flex h-8 shrink-0 cursor-default items-center gap-2",onMouseDown:A=>{A.stopPropagation()},onPointerDown:A=>{A.stopPropagation()},children:[v("p",{className:"typo-compact-xs2-normal text-fg-subtle",children:n("move.amr.rightPanel.controlPanel.transparency")}),C("p",{className:"typo-compact-xs2-semibold text-fg-default w-8 text-right",children:[d,"%"]}),v(Rc,{value:[d],min:0,max:100,step:1,onValueChange:A=>{h(A[0])},className:"w-24"})]}),v(Kn,{icon:v(Ao,{}),variant:"transparent",size:"2xs",onClick:e})]}),r.length===0?v("div",{className:"min-h-0 flex-1 px-3 pt-2 pb-3.5",children:v(go,{className:"h-full rounded-md [&_[data-slot='empty-view-section']]:h-full",type:"icon",icon:v(Sh,{className:"text-fg-subtlest size-5"}),message:n("move.amr.rightPanel.cameraPanel.empty")})}):v("div",{className:"[&::-webkit-scrollbar-thumb]:bg-border-subtle min-h-0 flex-1 overflow-x-auto overflow-y-hidden px-3 pt-2 pb-4.5 [scrollbar-color:var(--color-border-subtle)_transparent] [scrollbar-width:thin] [&::-webkit-scrollbar]:h-1.5 [&::-webkit-scrollbar]:w-1.5 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-track]:bg-transparent",children:v("div",{className:"flex h-full w-max min-w-full items-start gap-2",children:r.map(A=>C("div",{className:"inline-flex h-full shrink-0 flex-col gap-1.5",children:[C("div",{className:"flex items-center gap-1 px-0.5",children:[v("div",{className:"flex size-3 items-center justify-center",children:v(yi,{color:A.status==="live"?"green":"red"})}),v("span",{className:"text-fg-default typo-compact-xs2-semibold pr-2",children:A.name}),v("div",{onClick:M=>M.stopPropagation(),children:v(ca,{className:"min-w-20",size:"xs2",value:A.quality,handleChange:M=>{typeof M=="string"&&t?.(A.camId,M)},children:A.qualityOptions.map(M=>v(Pi,{value:M,children:M},M))})}),v("span",{className:"text-fg-subtler typo-compact-xs-normal ml-auto",children:A.resolution})]}),A.status==="live"&&A.streamUrl?v("div",{className:"bg-base-black border-subtle h-52 w-96 cursor-pointer overflow-hidden rounded-md border",onClick:M=>{M.stopPropagation(),T(A.id)},children:v(_f,{className:"bg-base-black h-full w-full overflow-hidden [&_video]:object-cover",url:A.streamUrl??"",label:A.name,lebelPosition:"top-left",initStatus:!0,disconnectedMessage:n("move.amr.rightPanel.cameraPanel.disconnected"),loadingMessage:n("move.amr.rightPanel.cameraPanel.connecting")})}):C("div",{className:"outline-border-subtle flex h-52 w-96 flex-col items-center justify-center gap-1 rounded-md outline outline-1 outline-offset-[-1px]",children:[v(Sh,{className:"text-fg-subtlest size-5"}),v("span",{className:"text-fg-subtler typo-compact-xs-normal",children:n("move.amr.rightPanel.cameraPanel.disconnected")})]})]},A.id))})}),v("div",{"aria-label":"Resize camera streams panel",className:"absolute right-0 bottom-0 z-10 flex size-5 cursor-se-resize items-end justify-end p-1",role:"separator",onMouseDown:P,children:v("span",{className:"border-fg-subtlest block size-2.5 border-r-2 border-b-2 opacity-70"})})]})]})},o2=nR(iR),{memo:sR,useEffect:to,useMemo:ug,useRef:dh,useState:ec}=await At("react"),rR=["static","dynamic","virtual","collision"],aR={static:[148,163,184,160],dynamic:[59,130,246,190],virtual:[168,85,247,180],collision:[239,68,68,210]},oR=320,hh=.5,uh=4,fg=.25,Cc=(r,e,t)=>Math.max(e,Math.min(t,r)),pg=(r,e,t)=>{if(e<=1)return{x:0,y:0};const n=Math.max(0,(r.canvasWidth*e-r.canvasWidth)/2),i=Math.max(0,(r.canvasHeight*e-r.canvasHeight)/2);return{x:Cc(t.x,-n,n),y:Cc(t.y,-i,i)}},mg=(r,e)=>(r%e+e)%e,lR=(()=>{const r=new ArrayBuffer(4),e=new Uint32Array(r),t=new Uint8Array(r);return e[0]=168496141,t[0]===13})(),cR=(r,e,t,n)=>lR?n<<24|t<<16|e<<8|r:r<<24|e<<16|t<<8|n,dR=(r,e)=>{const t=Math.max(r,1),n=Math.max(e,1),i=Math.max(t,n),s=Math.max(1,Math.floor(oR/i)),a=t*s,o=n*s;return{safeWidth:t,safeHeight:n,scale:s,canvasWidth:a,canvasHeight:o,centerX:a/2,centerY:o/2}},gg=(r,e)=>{r.width!==e.canvasWidth&&(r.width=e.canvasWidth),r.height!==e.canvasHeight&&(r.height=e.canvasHeight)},hR=(r,e,t)=>{r.clearRect(0,0,e.canvasWidth,e.canvasHeight),r.fillStyle="#0f172a",r.fillRect(0,0,e.canvasWidth,e.canvasHeight),r.fillStyle="rgba(255,255,255,0.72)",r.font="500 14px sans-serif",r.textAlign="center",r.textBaseline="middle",r.fillText(t,e.canvasWidth/2,e.canvasHeight/2)},uR=(r,e,t,n)=>{r.clearRect(0,0,e.canvasWidth,e.canvasHeight),r.fillStyle="#0f172a",r.fillRect(0,0,e.canvasWidth,e.canvasHeight),r.save(),r.strokeStyle="rgba(255,255,255,0.06)",r.lineWidth=1;const s=e.scale*t*8,a=mg(e.centerX+n.x,s),o=mg(e.centerY+n.y,s);for(let l=a;l<=e.canvasWidth;l+=s)r.beginPath(),r.moveTo(l+.5,0),r.lineTo(l+.5,e.canvasHeight),r.stroke();for(let l=o;l<=e.canvasHeight;l+=s)r.beginPath(),r.moveTo(0,l+.5),r.lineTo(e.canvasWidth,l+.5),r.stroke();r.restore()},fR=async(r,e,t,n)=>{try{const i=await createImageBitmap(new Blob([new Uint8Array(r)],{type:"image/png"})),s=document.createElement("canvas");s.width=e,s.height=t;const a=s.getContext("2d");if(!a)return i.close(),null;a.imageSmoothingEnabled=!1,a.drawImage(i,0,0,e,t),i.close();const[o,l,c,d]=n,h=a.getImageData(0,0,e,t),u=h.data,f=cR(o,l,c,d),m=new Uint32Array(u.buffer);for(let b=0;b<m.length;b+=1){if(!(u[b*4]>0)){m[b]=0;continue}m[b]=f}return a.putImageData(h,0,0),s}catch{return null}},pR=(r,e,t,n,i)=>{const s=t.canvasWidth*n,a=t.canvasHeight*n,o=t.centerX-s/2+i.x,l=t.centerY-a/2+i.y;r.drawImage(e,o,l,s,a)},mR=(r,e,t,n,i,s)=>{if(!(t>0))return;const a=n.scale*i,o=d=>n.centerX+s.x+d/t*a,l=d=>n.centerY+s.y-d/t*a,c=(d,h,u,f,m,b)=>{const p=o(d),g=o(h),y=l(f),x=l(u);r.fillStyle=m,r.strokeStyle=b,r.lineWidth=1,r.fillRect(p,y,g-p,x-y),r.strokeRect(p,y,g-p,x-y)};c(e.obsBoxMinX-e.stopMarginX-e.slowMarginX,e.obsBoxMaxX+e.stopMarginX+e.slowMarginX,e.obsBoxMinY-e.stopMarginY-e.slowMarginY,e.obsBoxMaxY+e.stopMarginY+e.slowMarginY,"rgba(245, 158, 11, 0.12)","rgba(245, 158, 11, 0.7)"),c(e.obsBoxMinX-e.stopMarginX,e.obsBoxMaxX+e.stopMarginX,e.obsBoxMinY-e.stopMarginY,e.obsBoxMaxY+e.stopMarginY,"rgba(239, 68, 68, 0.14)","rgba(239, 68, 68, 0.85)"),c(e.obsBoxMinX,e.obsBoxMaxX,e.obsBoxMinY,e.obsBoxMaxY,"rgba(34, 197, 94, 0.16)","rgba(34, 197, 94, 0.9)")},gR=(r,e,t,n,i,s)=>{if(!(t>0))return;const a=n.scale*i,o=x=>n.centerX+s.x+x/t*a,l=x=>n.centerY+s.y-x/t*a,c=o(e.obsBoxMinX),d=o(e.obsBoxMaxX),h=l(e.obsBoxMaxY),u=l(e.obsBoxMinY),f=d-c,m=u-h,b=(c+d)/2,p=(h+u)/2,g=Math.max(f*1.1,14),y=Math.max(Math.min(f,m)*.7,10);r.save(),r.lineWidth=1,r.strokeStyle="rgba(59,130,246,0.95)",r.fillStyle="rgba(59,130,246,0.95)",r.beginPath(),r.moveTo(b,p),r.lineTo(b+g,p),r.stroke(),r.beginPath(),r.moveTo(b+g,p),r.lineTo(b+g-5,p-2.5),r.lineTo(b+g-5,p+2.5),r.closePath(),r.fill(),r.strokeStyle="rgba(34,197,94,0.95)",r.fillStyle="rgba(34,197,94,0.95)",r.beginPath(),r.moveTo(b,p),r.lineTo(b,p-y),r.stroke(),r.beginPath(),r.moveTo(b,p-y),r.lineTo(b-2.5,p-y+5),r.lineTo(b+2.5,p-y+5),r.closePath(),r.fill(),r.restore()},bR=(r,e)=>{r.save(),r.strokeStyle="rgba(255,255,255,0.14)",r.lineWidth=1,r.strokeRect(.5,.5,e.canvasWidth-1,e.canvasHeight-1),r.translate(.5,.5),r.strokeStyle="rgba(255,255,255,0.18)",r.beginPath(),r.moveTo(e.canvasWidth/2,0),r.lineTo(e.canvasWidth/2,e.canvasHeight),r.moveTo(0,e.canvasHeight/2),r.lineTo(e.canvasWidth,e.canvasHeight/2),r.stroke(),r.restore()},vR=({layers:r,width:e,height:t,gridSize:n,safety:i,loading:s=!1,onClose:a,className:o})=>{const{t:l}=tn(),c=dh(null),d=dh(null),h=dh(null),[u,f]=ec(1),[m,b]=ec(80),[p,g]=ec({x:0,y:0}),[y,x]=ec([]),w=r.length,P=ug(()=>r.map(k=>k.name).join(", "),[r]),T=ug(()=>dR(e,t),[t,e]),A=e>0&&t>0?`${e} x ${t}`:"-",M=n>0?l("move.amr.obstacleMap.gridSizePerPixel",{value:n.toFixed(3)}):"-",_=`${Math.round(u*100)}%`,S=u>1,R=s?l("move.amr.obstacleMap.status.waitingForStream"):e>0&&t>0?w>0?l("move.amr.obstacleMap.status.live"):l("move.amr.obstacleMap.status.noActiveLayers"):l("move.amr.obstacleMap.status.idle");return to(()=>{g(k=>pg(T,u,k))},[T,u]),to(()=>{let k=!1;if(e<=0||t<=0||r.length===0){x([]);return}const O=rR.map(H=>({layerName:H,layer:r.find(q=>q.name===H)})).filter(H=>!!H.layer&&H.layer.data.length>0);return(async()=>{const H=await Promise.all(O.map(async({layerName:q,layer:G})=>{const K=await fR(G.data,e,t,aR[q]);return{layerName:q,tintedLayerCanvas:K}}));k||x(H.filter(q=>q.tintedLayerCanvas!==null))})(),()=>{k=!0}},[t,r,e]),to(()=>{const k=c.current,O=d.current;k&&gg(k,T),O&&gg(O,T)},[T]),to(()=>{const k=c.current;if(!k)return;const O=k.getContext("2d");if(!O)return;O.imageSmoothingEnabled=!1;const H=document.createElement("canvas");H.width=T.canvasWidth,H.height=T.canvasHeight;const q=H.getContext("2d");if(q){if(q.imageSmoothingEnabled=!1,e<=0||t<=0){hR(q,T,l("move.amr.obstacleMap.waitingForData")),O.clearRect(0,0,T.canvasWidth,T.canvasHeight),O.drawImage(H,0,0);return}uR(q,T,u,p);for(const{tintedLayerCanvas:G}of y)pR(q,G,T,u,p);O.clearRect(0,0,T.canvasWidth,T.canvasHeight),O.drawImage(H,0,0)}},[y,t,T,p,l,e,u]),to(()=>{const k=d.current;if(!k)return;const O=k.getContext("2d");O&&(O.imageSmoothingEnabled=!1,O.clearRect(0,0,T.canvasWidth,T.canvasHeight),!(e<=0||t<=0)&&(mR(O,i,n,T,u,p),gR(O,i,n,T,u,p),bR(O,T)))},[n,t,e,i,T,p,u]),C($,{className:$t("border-subtle shadow-down-lg pointer-events-auto w-[25rem] overflow-hidden rounded-lg border",o),style:{backgroundColor:`color-mix(in srgb, var(--color-bg-alt-1) ${Math.max(0,Math.min(100,m))}%, transparent)`},children:[C(we,{className:"border-subtle items-center justify-between gap-4 border-b px-3 py-2.5",children:[C(we,{className:"min-w-0 items-center gap-2",children:[v("div",{className:"bg-fill-information-subtle flex size-8 shrink-0 items-center justify-center rounded-md",children:v(Xg,{className:"text-fg-information size-4"})}),C($,{className:"min-w-0 gap-0.5",children:[v("p",{className:"typo-compact-xs-semibold text-fg-default truncate",children:l("move.amr.obstacleMap.title")}),v("p",{className:"typo-compact-xs2-normal text-fg-subtle truncate",children:l("move.amr.obstacleMap.description")})]})]}),C(we,{className:"h-8 shrink-0 items-center gap-2",children:[v("p",{className:"typo-compact-xs2-normal text-fg-subtle",children:l("move.amr.rightPanel.controlPanel.transparency")}),C("p",{className:"typo-compact-xs2-semibold text-fg-default w-8 text-right",children:[m,"%"]}),v(Rc,{value:[m],min:0,max:100,step:1,onValueChange:k=>{b(k[0])},className:"w-24"}),v(Kn,{icon:v(Ao,{}),variant:"transparent",size:"2xs",onClick:a})]})]}),C($,{className:"gap-3 p-3",children:[C("div",{className:$t("bg-bg-default border-subtle relative aspect-square overflow-hidden rounded-md border",S?"cursor-grab touch-none active:cursor-grabbing":"cursor-default"),onPointerDown:k=>{!S||k.target instanceof Element&&k.target.closest("button")||(h.current={pointerId:k.pointerId,startX:k.clientX,startY:k.clientY,startPanX:p.x,startPanY:p.y},k.currentTarget.setPointerCapture(k.pointerId))},onPointerMove:k=>{const O=h.current;!O||O.pointerId!==k.pointerId||g(pg(T,u,{x:O.startPanX+k.clientX-O.startX,y:O.startPanY+k.clientY-O.startY}))},onPointerUp:k=>{h.current?.pointerId===k.pointerId&&(h.current=null,k.currentTarget.releasePointerCapture(k.pointerId))},onPointerCancel:k=>{h.current?.pointerId===k.pointerId&&(h.current=null,k.currentTarget.releasePointerCapture(k.pointerId))},children:[C(we,{className:"absolute top-3 right-3 z-10 gap-1.5 rounded-md bg-black/45 p-1 backdrop-blur-sm",children:[v(Kn,{icon:v(jg,{}),variant:"transparent",size:"2xs",disabled:u===1&&p.x===0&&p.y===0,onClick:()=>{f(1),g({x:0,y:0})}}),v(Kn,{icon:v(iy,{}),variant:"transparent",size:"2xs",disabled:u<=hh,onClick:()=>{f(k=>{const O=Cc(k-fg,hh,uh);return O<=1&&g({x:0,y:0}),O})}}),v(nt,{size:"2xs",variant:"soft",disabled:!0,className:"min-w-14 justify-center",children:_}),v(Kn,{icon:v(sy,{}),variant:"transparent",size:"2xs",disabled:u>=uh,onClick:()=>{f(k=>Cc(k+fg,hh,uh))}})]}),v("canvas",{ref:c,className:"absolute inset-0 h-full w-full [image-rendering:pixelated]"}),v("canvas",{ref:d,className:"pointer-events-none absolute inset-0 h-full w-full [image-rendering:pixelated]"}),v("div",{className:"absolute inset-x-3 bottom-3",children:C(we,{className:"justify-between rounded-md bg-black/45 px-2.5 py-2 backdrop-blur-sm",children:[C($,{className:"gap-0.5",children:[v("p",{className:"typo-compact-xs2-normal text-white/70",children:l("move.amr.obstacleMap.statusLabel")}),v("p",{className:"typo-compact-xs2-semibold text-white",children:R})]}),C($,{className:"items-end gap-0.5",children:[v("p",{className:"typo-compact-xs2-normal text-white/70",children:l("move.amr.obstacleMap.gridLabel")}),v("p",{className:"typo-compact-xs2-semibold text-white",children:A})]})]})})]}),C(we,{className:"flex-wrap gap-2",children:[v(nt,{size:"2xs",variant:"soft",disabled:!0,children:M}),v(nt,{size:"2xs",variant:"soft",disabled:!0,children:l("move.amr.obstacleMap.layerCount",{count:w})}),P?v(nt,{size:"2xs",variant:"soft",disabled:!0,children:P}):null]})]})]})},l2=sR(vR),{useEffect:no,useMemo:fh,useRef:bg,useState:es}=await At("react"),yR=[{key:"measMismatch",labelKey:"move.amr.rightPanel.pdu.safety.measMismatch",robotStateKey:"sfMeasMismatch"},{key:"overSpeed",labelKey:"move.amr.rightPanel.pdu.safety.overSpeed",robotStateKey:"sfOverSpeed"},{key:"obstacle",labelKey:"move.amr.rightPanel.pdu.safety.obstacle",robotStateKey:"sfObsDetect"},{key:"fieldMismatch",labelKey:"move.amr.rightPanel.pdu.safety.fieldMismatch",robotStateKey:"sfFieldMismatch"},{key:"interlock",labelKey:"move.amr.rightPanel.pdu.safety.interlock",robotStateKey:"sfInterlock"},{key:"bumper",labelKey:"move.amr.rightPanel.pdu.safety.bumper",robotStateKey:"sfBumperDetect"}],xR=[{key:"running",label:"Running",bit:0,normalWhenActive:!0},{key:"mode",label:"Mode",bit:1},{key:"jam",label:"Jam",bit:2},{key:"current",label:"Current",bit:3},{key:"big",label:"Big",bit:4},{key:"input",label:"Input",bit:5},{key:"position",label:"Position",bit:6},{key:"collision",label:"Collision",bit:7}],_R=r=>typeof r=="boolean"?Number(r):r??0,vg=(r,e)=>(r&1<<e)!==0,yg=(r,e)=>typeof r!="number"||!Number.isFinite(r)?"-":`${r}${e}`,Tv=r=>{if(r?.length)return r.filter(e=>Number.isInteger(e.pin)&&e.pin>=0).map(e=>({pin:e.pin,value:!!e.value,rawValue:e.rawValue})).sort((e,t)=>e.pin-t.pin)},wR=r=>{const e=Tv(r.bits);if(e)return{...r,bits:e}},xg=(r,e)=>{if(!r)return"";if(typeof r=="string")return r;const t=e.toLowerCase().split(/[-_]/)[0],n=r[t];return typeof n=="string"&&n.length>0?n:typeof r.en=="string"&&r.en.length>0?r.en:Object.values(r).find(i=>typeof i=="string"&&i.length>0)??""},SR=r=>{const e=[],t=[{key:"mcu0-din",label:"MCU0 DIN",mcu:0,kind:"din",bits:r?.mcu0Din},{key:"mcu1-din",label:"MCU1 DIN",mcu:1,kind:"din",bits:r?.mcu1Din},{key:"mcu0-dio",label:"MCU0 DIO",mcu:0,kind:"dio",bits:r?.mcu0Dio},{key:"mcu1-dio",label:"MCU1 DIO",mcu:1,kind:"dio",bits:r?.mcu1Dio}];for(const n of t){const i=Tv(n.bits);i&&e.push({key:n.key,label:n.label,mcu:n.mcu,kind:n.kind,bits:i})}return e},tc=(r,e,t)=>r.find(n=>n.mcu===e&&n.kind===t),_g=r=>r?.map(e=>e.value),Ev=r=>r?`0x${r.reduce((t,n)=>n.value?t|1<<n.pin:t,0).toString(16).toUpperCase().padStart(2,"0")}`:"-",nc=r=>r?r.map(e=>({...e})):void 0,wg=r=>r?.map(e=>e.pin).join(",")??"",Sg=({label:r,onClick:e})=>v(nt,{variant:"outlined",className:"!typo-compact-xs-normal text-fg-subtle",size:"2xs",onClick:e,children:r}),Av=({pin:r,active:e,disabled:t=!1,onClick:n})=>{const i=$t("flex h-8 min-w-0 flex-col items-center justify-center rounded border border-transparent text-center text-white shadow-[inset_0_0_0_1px_rgba(255,255,255,0.12),0_1px_2px_rgba(0,0,0,0.35)]",e?"bg-[#12833B]":"bg-[#E5252A]",n&&!t?"hover:brightness-110":"cursor-default");return n?v("button",{type:"button",className:i,disabled:t,onClick:n,children:v("span",{className:"typo-compact-2xs-semibold leading-none",children:r})}):v("div",{className:i,children:v("span",{className:"typo-compact-2xs-semibold leading-none",children:r})})},MR=({label:r,bits:e})=>C($,{className:"gap-1",children:[C("div",{className:"flex items-center justify-between gap-2",children:[v("span",{className:"typo-compact-xs-normal text-fg-subtle",children:r}),v("span",{className:"typo-compact-xs-semibold text-fg-subtle font-mono",children:Ev(e)})]}),e?v("div",{className:"grid w-full gap-1",style:{gridTemplateColumns:`repeat(${e.length}, minmax(0, 1fr))`},children:e.map(t=>v(Av,{pin:t.pin,active:t.value},t.pin))}):v("span",{className:"typo-compact-xs-normal text-fg-subtler",children:"-"})]}),TR=({label:r,bits:e,disabled:t,onToggle:n})=>C($,{className:"gap-1",children:[C("div",{className:"flex items-center justify-between gap-2",children:[v("span",{className:"typo-compact-xs-normal text-fg-subtle",children:r}),v("span",{className:"typo-compact-xs-semibold text-fg-subtle font-mono",children:Ev(e)})]}),e?v("div",{className:"grid w-full gap-1",style:{gridTemplateColumns:`repeat(${e.length}, minmax(0, 1fr))`},children:e.map((i,s)=>v(Av,{pin:i.pin,active:i.value,disabled:t,onClick:()=>n(s)},i.pin))}):v("span",{className:"typo-compact-xs-normal text-fg-subtler",children:"-"})]}),c2=({amrStatus:r,setMotorLocked:e,onSystemStatusChange:t,onClearSafetyRecovery:n,onLidarFieldSave:i,onOssdDetectChange:s,safetyIo:a,safetyIoLoading:o=!1,onSetSafetyIo:l,onMotorConnectSuccess:c,onLidarSaveSuccess:d,onMotorConnectError:h,onLidarSaveError:u,onSafetyIoSetError:f})=>{const{currentLanguage:m,t:b}=tn(),p=r?.motor??[],g=p.length>0,y=g&&p.every(xe=>!!xe.status),x=g?!y:!1,w=!!r?.robotState?.emo,P=r?.chargeState?.charge??"",T=r?.chargeState?.dockId??"",A=r?.chargeState?.dockResult??"",M=!!r?.chargeState?.dock,_=P.trim()==="charging",S=!!r?.robotState?.sfOperationalStop,R=r?.robotState?.lidarField??null,k=bg(null);no(()=>{k.current===null&&R!=null&&(k.current=R)},[R]);const[O,H]=es(""),[q,G]=es(!1),[K,V]=es(null);no(()=>{V(null)},[R]);const Z=q?O:String(K??k.current??R??0),le=!!r?.robotState?.detectMode,[se,ge]=es(null);no(()=>{ge(null)},[le]);const[de,X]=es(null),[ee,ie]=es(!1),[Y,ue]=es(!1),oe=de??x;no(()=>{X(null)},[x]);const be=fh(()=>a?.rows?.length?a.rows.map(wR).filter(xe=>!!xe):SR(a),[a]),Ce=fh(()=>({mcu0Din:tc(be,0,"din")?.bits,mcu1Din:tc(be,1,"din")?.bits,mcu0Dio:tc(be,0,"dio")?.bits,mcu1Dio:tc(be,1,"dio")?.bits}),[be]),je=fh(()=>be.filter(xe=>xe.kind==="dio"&&(xe.mcu===0||xe.mcu===1)),[be]),Fe=be.length>0,[j,Ke]=es({}),[Ue,Te]=es(!1),[Se,et]=es(!1),Be=`${wg(Ce.mcu0Dio)}|${wg(Ce.mcu1Dio)}`,N=bg(null);no(()=>{!Ce.mcu0Dio||!Ce.mcu1Dio||N.current!==Be&&(N.current=Be,Ke({mcu0Din:nc(Ce.mcu0Dio),mcu1Din:nc(Ce.mcu1Dio)}),Te(!1))},[Be,Ce.mcu0Dio,Ce.mcu1Dio]);const E=j.mcu0Din,W=j.mcu1Din,ae=!!l&&!!Ce.mcu0Dio&&!!Ce.mcu1Dio&&!!E&&!!W,ve=ae&&Ue,ce=!ae||o||Se,Oe=(xe,Le)=>{if(ce||!E||!W)return;const ct=nc(E),rt=nc(W);!ct||!rt||(xe===0?ct[Le]={...ct[Le],value:!ct[Le].value}:rt[Le]={...rt[Le],value:!rt[Le].value},Ke({mcu0Din:ct,mcu1Din:rt}),Te(!0))},Pe=xe=>{if(xe===0)return E;if(xe===1)return W},Ve=xe=>xg(xe.label,m),te=async()=>{if(!(!l||!E||!W||!ve)){et(!0);try{await l({mcu0Din:_g(E)??[],mcu1Din:_g(W)??[]}),Te(!1)}catch{f?.()}finally{et(!1)}}},re=async()=>{if(e){ie(!0);try{await e(!1),X(!1),t?.({motorLock:!1}),c?.()}catch{h?.()}finally{ie(!1)}}},De=()=>{G(!1),H("")},Ye=async()=>{const xe=Number(O);if(Number.isNaN(xe))G(!1);else{V(xe),G(!1);try{await i?.(xe),d?.()}catch{V(null),u?.()}}};return C("div",{className:"h-full min-h-0",children:[v("div",{className:"border-subtler border-b p-3",children:C("div",{className:"flex items-center justify-between",children:[v("span",{className:"typo-compact-sm2-semibold text-fg-default",children:b("move.amr.rightPanel.pdu.emergencyStop")}),C("div",{className:"flex items-center gap-2",children:[v(yi,{color:w?"red":"green"}),v("span",{className:"typo-compact-xs-semibold text-fg-default",children:b(w?"move.amr.rightPanel.common.triggered":"move.amr.rightPanel.common.normal")})]})]})}),C($,{className:"border-subtler gap-1.5 border-b p-3",children:[C("button",{type:"button",className:"flex w-full items-center justify-between gap-2 text-left","aria-expanded":Y,onClick:()=>ue(xe=>!xe),children:[v("span",{className:"flex min-w-0 items-center",children:v("span",{className:"typo-compact-sm2-semibold text-fg-default truncate",children:b("move.amr.rightPanel.pdu.motorStatus")})}),C("div",{className:"flex shrink-0 items-center gap-2",children:[v(yi,{color:oe?"red":"green"}),v("span",{className:"typo-compact-xs-semibold text-fg-default",children:b(oe?"move.amr.rightPanel.common.disconnected":"move.amr.rightPanel.common.connected")}),Y?v(ry,{className:"text-fg-subtle size-3.5 shrink-0"}):v(ay,{className:"text-fg-subtle size-3.5 shrink-0"})]})]}),C("div",{className:"flex items-center justify-between",children:[v("span",{className:"typo-compact-xs2-normal text-fg-subtler",children:b("move.amr.rightPanel.pdu.motor")}),v(wr,{checked:!oe,disabled:!oe||ee,onCheckedChange:xe=>{xe&&re()}})]}),Y&&v($,{className:"gap-2 pt-1",children:p.length===0?v("span",{className:"typo-compact-xs-normal text-fg-disabled",children:"No motor data"}):p.map((xe,Le)=>{const ct=_R(xe.status),rt=vg(ct,0),Rt=!!xe.connection;return C($,{className:"border-subtle bg-alt-1 gap-2 rounded border p-2",children:[C("div",{className:"flex items-center justify-between",children:[C("span",{className:"typo-compact-sm2-semibold text-fg-default",children:["Motor ",Le+1]}),C("div",{className:"flex items-center gap-2",children:[v(yi,{color:Rt?"green":"red"}),v("span",{className:"typo-compact-xs-semibold text-fg-default",children:Rt?"Connected":"Disconnected"})]})]}),C($,{className:"bg-raised gap-2 rounded p-2",children:[C("div",{className:"flex items-center justify-between",children:[v("span",{className:"typo-compact-xs-normal text-fg-subtler",children:"Running"}),C("div",{className:"flex items-center gap-2",children:[v(yi,{color:rt?"green":"red"}),v("span",{className:"typo-compact-xs-semibold text-fg-default",children:rt?"On":"Off"})]})]}),C("div",{className:"flex items-center justify-between",children:[v("span",{className:"typo-compact-xs-normal text-fg-subtler",children:"Temperature"}),v("span",{className:"typo-compact-xs-semibold text-fg-default font-mono",children:yg(xe.temp,"°C")})]}),C("div",{className:"flex items-center justify-between",children:[v("span",{className:"typo-compact-xs-normal text-fg-subtler",children:"Current"}),v("span",{className:"typo-compact-xs-semibold text-fg-default font-mono",children:yg(xe.current,"A")})]})]}),C($,{className:"gap-1",children:[v("span",{className:"typo-compact-xs-normal text-fg-subtler",children:"Status Flags"}),v("div",{className:"grid grid-cols-2 gap-1.5",children:xR.map(Q=>{const Ge=vg(ct,Q.bit),ye=Ge?Q.normalWhenActive?"green":"red":"gray";return C("div",{className:"bg-fill-disabled flex items-center justify-between gap-2 rounded px-2 py-1",children:[v("span",{className:"typo-compact-2xs-normal text-fg-subtle truncate",children:Q.label}),v(oy,{type:"soft",color:ye,children:Ge?"On":"Off"})]},Q.key)})})]})]},Le)})})]}),C("div",{className:"border-subtler flex flex-col gap-1.5 border-b p-3",children:[v("span",{className:"typo-compact-sm2-semibold text-fg-default",children:b("move.amr.rightPanel.pdu.chargeContact")}),C("div",{className:"space-y-2",children:[C("div",{className:"flex items-center justify-between",children:[v("span",{className:"typo-compact-xs-normal text-fg-subtler",children:b("move.amr.rightPanel.pdu.charge")}),C("div",{className:"flex items-center gap-2",children:[v(yi,{color:_?"green":"red"}),v("span",{className:"typo-compact-xs-semibold text-fg-default font-mono",children:b(_?"move.amr.rightPanel.common.true":"move.amr.rightPanel.common.false")})]})]}),C("div",{className:"flex items-center justify-between",children:[v("span",{className:"typo-compact-xs-normal text-fg-subtler",children:b("move.amr.rightPanel.pdu.dock")}),C("div",{className:"flex items-center gap-2",children:[v(yi,{color:M?"green":"red"}),v("span",{className:"typo-compact-xs-semibold text-fg-default font-mono",children:b(M?"move.amr.rightPanel.common.true":"move.amr.rightPanel.common.false")})]})]}),C("div",{className:"flex items-center justify-between",children:[v("span",{className:"typo-compact-xs-normal text-fg-subtler",children:b("move.amr.rightPanel.pdu.dockResult")}),v("span",{className:"typo-compact-xs-normal text-fg-subtle font-mono",children:A||"-"})]}),C("div",{className:"flex items-center justify-between",children:[v("span",{className:"typo-compact-xs-normal text-fg-subtler",children:b("move.amr.rightPanel.pdu.dockId")}),v("span",{className:"typo-compact-xs-normal text-fg-subtle font-mono",children:T||"-"})]})]})]}),C($,{className:"border-subtler gap-1.5 border-b p-3",children:[v("span",{className:"typo-compact-sm2-semibold text-fg-default",children:b("move.amr.rightPanel.pdu.safetyRecovery")}),v("div",{className:"space-y-2",children:yR.map(({key:xe,labelKey:Le,robotStateKey:ct})=>{const rt=!!r?.robotState?.[ct];return C("div",{className:"flex items-center justify-between",children:[v("span",{className:"typo-compact-xs2-normal text-fg-subtler",children:b(Le)}),C("div",{className:"flex items-center gap-3",children:[C("div",{className:"flex items-center gap-2",children:[v(yi,{color:rt?"red":"green"}),v("span",{className:"typo-compact-xs-semibold text-fg-default w-7 text-right",children:b(rt?"move.amr.rightPanel.common.trig":"move.amr.rightPanel.common.none")})]}),v(Sg,{label:b("move.amr.rightPanel.common.clear"),onClick:()=>n?.(xe)})]})]},Le)})})]}),C($,{className:"border-subtler gap-1.5 border-b p-3",children:[v("span",{className:"typo-compact-sm2-semibold text-fg-default",children:b("move.amr.rightPanel.pdu.opMode")}),v("div",{className:"space-y-2",children:C("div",{className:"flex items-center justify-between",children:[v("span",{className:"typo-compact-xs2-normal text-fg-subtler",children:b("move.amr.rightPanel.pdu.opModeRestoration")}),C("div",{className:"flex items-center gap-2",children:[v(yi,{color:S?"red":"green"}),v("span",{className:"typo-compact-xs-semibold text-fg-default w-7 text-right",children:b(S?"move.amr.rightPanel.common.trig":"move.amr.rightPanel.common.none")}),v(Sg,{label:b("move.amr.rightPanel.common.clear"),onClick:()=>n?.("operationStop")})]})]})})]}),Fe&&C($,{className:"border-subtler gap-3 border-b p-3",children:[C("div",{className:"flex items-center justify-between gap-2",children:[v("span",{className:"typo-compact-sm2-semibold text-fg-default",children:"Safety I/O"}),o&&v("span",{className:"typo-compact-2xs-normal text-fg-subtle",children:b("move.amr.rightPanel.pdu.safetyIo.pending")})]}),C($,{className:"gap-2",children:[v("div",{className:"flex items-center justify-between gap-2",children:v("span",{className:"typo-compact-xs-semibold text-fg-default",children:b("move.amr.rightPanel.pdu.safetyIo.read")})}),v($,{className:"gap-2",children:be.map(xe=>v(MR,{label:xg(xe.label,m),bits:xe.bits},xe.key))})]}),je.length>0&&C($,{className:"gap-2",children:[C("div",{className:"flex items-center justify-between gap-2",children:[v("span",{className:"typo-compact-xs-semibold text-fg-default",children:b("move.amr.rightPanel.pdu.safetyIo.outputControl")}),v("div",{className:"flex items-center gap-1",children:v(nt,{variant:"brand",size:"2xs",disabled:!ve||ce,onClick:te,children:b("move.amr.rightPanel.pdu.safetyIo.apply")})})]}),v($,{className:"gap-2",children:je.map(xe=>v(TR,{label:Ve(xe),bits:Pe(xe.mcu),disabled:ce,onToggle:Le=>{(xe.mcu===0||xe.mcu===1)&&Oe(xe.mcu,Le)}},`${xe.key}-control`))})]})]}),C($,{className:"border-subtler gap-1.5 border-b p-3",children:[C("div",{className:"flex items-center justify-between",children:[v("span",{className:"typo-compact-sm2-semibold text-fg-default",children:b("move.amr.rightPanel.pdu.lidarField")}),q&&C("div",{className:"flex items-center gap-1",children:[v(nt,{variant:"outlined",size:"2xs",onClick:De,children:b("move.amr.rightPanel.common.reset")}),v(nt,{variant:"brand",size:"2xs",onClick:Ye,children:b("move.amr.rightPanel.common.save")})]})]}),v(Nn,{className:"w-full",type:"number",size:"sm",value:Z,handleChange:xe=>{H(xe!==void 0?String(xe):""),G(!0)}})]}),C($,{className:"border-subtler gap-1.5 border-b p-3",children:[v("span",{className:"typo-compact-sm2-semibold text-fg-default",children:"OSSD"}),C("div",{className:"flex items-center justify-between",children:[v("span",{className:"typo-compact-xs2-normal text-fg-subtler",children:b("move.amr.rightPanel.pdu.detect")}),v(wr,{checked:se??le,onCheckedChange:xe=>{const Le=se??le;ge(xe),s?.(xe)?.catch(()=>ge(Le))}})]})]})]})},{useMemo:ER}=await At("react"),AR=({className:r,currentNode:e,targetNode:t,moveStatus:n})=>{const{t:i}=tn(),s=ER(()=>n==="move"||n==="vir"||n==="moving",[n]);return C("div",{className:$t("AMRNodeFromTo","relative pl-7",r),children:[C($,{className:$t("gap-2","[&>div]:gap-0.5","[&>div>span]:text-fg-subtle [&>div>span]:typo-compact-2xs-medium","[&>div>div]:text-fg-default [&>div>div]:typo-compact-sm-semibold"),children:[C($,{children:[v("span",{children:i("move.amr.rightPanel.task.currentNode")}),v("div",{className:"text-fg-subtle truncate",children:e||"-"})]}),C($,{children:[v("span",{children:i("move.amr.rightPanel.task.targetNode")}),v("div",{className:"text-fg-subtle truncate",children:t||"-"})]})]}),v(CR,{className:"w-7",isMoving:s,children:v("span",{className:"moving-dot"})})]})},CR=Nc("div",{target:"e184amb70"})(`position:absolute;top:50%;transform:translateY(-50%);left:0;z-index:1;height:85%;&::before,&::after{content:"";position:absolute;left:50%;width:1px;height:50%;transform:translateX(-50%);}&::before{top:0;background:linear-gradient(
|
|
4742
|
+
}`};class nP extends Ia{constructor(){super();const e=tP;this.uniforms=Ca.clone(e.uniforms),this.material=new f_({name:e.name,uniforms:this.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader}),this.fsQuad=new bf(this.material),this._outputColorSpace=null,this._toneMapping=null}render(e,t,n){this.uniforms.tDiffuse.value=n.texture,this.uniforms.toneMappingExposure.value=e.toneMappingExposure,(this._outputColorSpace!==e.outputColorSpace||this._toneMapping!==e.toneMapping)&&(this._outputColorSpace=e.outputColorSpace,this._toneMapping=e.toneMapping,this.material.defines={},ft.getTransfer(this._outputColorSpace)===Ht&&(this.material.defines.SRGB_TRANSFER=""),this._toneMapping===Jg?this.material.defines.LINEAR_TONE_MAPPING="":this._toneMapping===eb?this.material.defines.REINHARD_TONE_MAPPING="":this._toneMapping===tb?this.material.defines.CINEON_TONE_MAPPING="":this._toneMapping===nb?this.material.defines.ACES_FILMIC_TONE_MAPPING="":this._toneMapping===sb?this.material.defines.AGX_TONE_MAPPING="":this._toneMapping===rb?this.material.defines.NEUTRAL_TONE_MAPPING="":this._toneMapping===ib&&(this.material.defines.CUSTOM_TONE_MAPPING=""),this.material.needsUpdate=!0),this.renderToScreen===!0?(e.setRenderTarget(null),this.fsQuad.render(e)):(e.setRenderTarget(t),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),this.fsQuad.render(e))}dispose(){this.material.dispose(),this.fsQuad.dispose()}}class iP extends Ia{constructor(e,t,n=null,i=null,s=null){super(),this.scene=e,this.camera=t,this.overrideMaterial=n,this.clearColor=i,this.clearAlpha=s,this.clear=!0,this.clearDepth=!1,this.needsSwap=!1,this._oldClearColor=new Ne}render(e,t,n){const i=e.autoClear;e.autoClear=!1;let s,a;this.overrideMaterial!==null&&(a=this.scene.overrideMaterial,this.scene.overrideMaterial=this.overrideMaterial),this.clearColor!==null&&(e.getClearColor(this._oldClearColor),e.setClearColor(this.clearColor,e.getClearAlpha())),this.clearAlpha!==null&&(s=e.getClearAlpha(),e.setClearAlpha(this.clearAlpha)),this.clearDepth==!0&&e.clearDepth(),e.setRenderTarget(this.renderToScreen?null:n),this.clear===!0&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),e.render(this.scene,this.camera),this.clearColor!==null&&e.setClearColor(this._oldClearColor),this.clearAlpha!==null&&e.setClearAlpha(s),this.overrideMaterial!==null&&(this.scene.overrideMaterial=a),e.autoClear=i}}var mo=function(){var r=0,e=document.createElement("div");e.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",e.addEventListener("click",function(d){d.preventDefault(),n(++r%e.children.length)},!1);function t(d){return e.appendChild(d.dom),d}function n(d){for(var h=0;h<e.children.length;h++)e.children[h].style.display=h===d?"block":"none";r=d}var i=(performance||Date).now(),s=i,a=0,o=t(new mo.Panel("FPS","#0ff","#002")),l=t(new mo.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var c=t(new mo.Panel("MB","#f08","#201"));return n(0),{REVISION:16,dom:e,addPanel:t,showPanel:n,begin:function(){i=(performance||Date).now()},end:function(){a++;var d=(performance||Date).now();if(l.update(d-i,200),d>=s+1e3&&(o.update(a*1e3/(d-s),100),s=d,a=0,c)){var h=performance.memory;c.update(h.usedJSHeapSize/1048576,h.jsHeapSizeLimit/1048576)}return d},update:function(){i=this.end()},domElement:e,setMode:n}};mo.Panel=function(r,e,t){var n=1/0,i=0,s=Math.round,a=s(window.devicePixelRatio||1),o=80*a,l=48*a,c=3*a,d=2*a,h=3*a,u=15*a,f=74*a,m=30*a,b=document.createElement("canvas");b.width=o,b.height=l,b.style.cssText="width:80px;height:48px";var p=b.getContext("2d");return p.font="bold "+9*a+"px Helvetica,Arial,sans-serif",p.textBaseline="top",p.fillStyle=t,p.fillRect(0,0,o,l),p.fillStyle=e,p.fillText(r,c,d),p.fillRect(h,u,f,m),p.fillStyle=t,p.globalAlpha=.9,p.fillRect(h,u,f,m),{dom:b,update:function(g,y){n=Math.min(n,g),i=Math.max(i,g),p.fillStyle=t,p.globalAlpha=1,p.fillRect(0,0,o,u),p.fillStyle=e,p.fillText(s(g)+" "+r+" ("+s(n)+"-"+s(i)+")",c,d),p.drawImage(b,h+a,u,f-a,m,h,u,f-a,m),p.fillRect(h+f-a,u,a,m),p.fillStyle=t,p.globalAlpha=.9,p.fillRect(h+f-a,u,a,s((1-g/y)*m))}}};const Qm=16,Jm=.85,sP=.9;class rP{domElement;orbit;constructor({domElement:e,orbit:t}){this.domElement=e,this.orbit=t}attach(){this.domElement.addEventListener("wheel",this.handleWheel,{passive:!1,capture:!0})}detach(){this.domElement.removeEventListener("wheel",this.handleWheel,!0)}handleWheel=e=>{if(e.target!==this.domElement||!this.orbit.enabled||!this.isTrackpadWheelEvent(e)||e.ctrlKey)return;e.preventDefault(),e.stopImmediatePropagation();const{deltaX:t,deltaY:n}=this.normalizeWheelDelta(e);if(e.shiftKey){if(!this.orbit.enableRotate)return;this.rotateFromTrackpad(t,n);return}this.panFromTrackpad(t,n)};isTrackpadWheelEvent=e=>e.deltaMode!==WheelEvent.DOM_DELTA_PIXEL?!1:Math.abs(e.deltaX)>0;normalizeWheelDelta=e=>{if(e.deltaMode===WheelEvent.DOM_DELTA_LINE)return{deltaX:e.deltaX*Qm,deltaY:e.deltaY*Qm};if(e.deltaMode===WheelEvent.DOM_DELTA_PAGE){const t=this.domElement.clientHeight||window.innerHeight;return{deltaX:e.deltaX*t,deltaY:e.deltaY*t}}return{deltaX:e.deltaX,deltaY:e.deltaY}};panFromTrackpad=(e,t)=>{const n=this.orbit;n._pan(-e*Jm,-t*Jm),n.update()};rotateFromTrackpad=(e,t)=>{const n=2*Math.PI/this.domElement.clientHeight*this.orbit.rotateSpeed*sP,i=this.orbit;i._rotateLeft(-e*n),i._rotateUp(-t*n),i.update()}}const aP=200,oP=3,lP=4,cP=20,dP=6,eg=1,hP=.15,Ja=1e-6,tg=[1,3,6,12,20,40],Zl=["text-7xl","text-5xl","text-4xl","text-base","text-sm","text-xs","hidden"];class uP{constructor(e){this.editor=e}_renderCSS2D;container;scene;sceneHelpers;camera;renderer;css2DRenderer;effectComposer;selectedNodeOutlinePass;activeNodeOutlinePass;robotPos=new I;robotQuat=new Lt;lookOffset=new I;robotForward=new I;PRIMARY_MOUSE_BUTTON=0;tmpView=new I;onDownPosition=new me;onMovePosition=new me;onUpPosition=new me;onDownPx=new me;onUpPx=new me;startPoint=new me;endPoint=new me;fwd=new I;right=new I;up=new I;delta=new I;focusBox=new Yt;focusCenter=new I;focusSphere=new vn;focusDirection=new I;activePointId=null;pointerDownTime=0;isBoxSelectGestureActive=!1;pointerSelectionIntent="replace";control;arcball;orbit;trackpadOrbitController;transformControls;boxSelectHelper;labels;clock;grid;stats=null;resizeObserver=null;pendingResize=!1;resizeWidth;resizeHeight;interactionTimer;pointerAction="inspect";zoneDraftState="idle";zoneDraftEditingZoneId=null;transformDragStart=null;currentCameraMode="perspective";lastPerspectiveCameraState=null;getCameraState(){return!this.camera||!this.orbit?null:{position:{x:this.camera.position.x,y:this.camera.position.y,z:this.camera.position.z},target:{x:this.orbit.target.x,y:this.orbit.target.y,z:this.orbit.target.z}}}setCameraState(e){!this.camera||!this.orbit||(this.camera.position.set(e.position.x,e.position.y,e.position.z),this.orbit.target.set(e.target.x,e.target.y,e.target.z),this.orbit.update(),this.emitCameraChanged())}emitCameraChanged(){const e=this.getCameraState();e&&this.editor.eventHandler.eventBus.emit("viewport:camera-changed",e)}get renderCSS2D(){return this._renderCSS2D}set renderCSS2D(e){this._renderCSS2D=e}initialize(){this._renderCSS2D=!1,this.scene=this.editor.scene,this.sceneHelpers=this.editor.sceneHelpers,this.camera=this.editor.camera,this.labels=[],this.clock=new Qu;const e=this.editor.canvas;if(!e)throw new Error("[Viewport] Canvas is not ready");const t=ZA(e,"Viewport");if(this.renderer=new TE({antialias:!0,canvas:e,alpha:!0}),this.container=t,window.location.hostname==="localhost"){const a=new mo;a.dom.style.position="absolute",a.dom.style.top="",a.dom.style.bottom="50px",a.dom.style.left="30px",this.container.appendChild(a.dom),this.stats=a}e.addEventListener("pointerdown",this.onPointerDown),e.addEventListener("pointermove",this.onPointerHover),e.addEventListener("pointerleave",this.onPointerLeave),YA(this.renderer),this.renderer.localClippingEnabled=!0,this.renderer.setSize(t.clientWidth,t.clientHeight),this.renderer.setAnimationLoop(this.animate),this.resizeObserver=JA(t,(a,o)=>{this.resizeWidth=a,this.resizeHeight=o,this.pendingResize=!0}),e.tabIndex=0,e.style.outline="none",this.camera instanceof gn&&(this.camera.aspect=e.clientWidth/e.clientHeight,this.camera.updateProjectionMatrix()),this.css2DRenderer=$A(t);const n=new iP(this.scene,this.camera);this.effectComposer=new eP(this.renderer),this.selectedNodeOutlinePass=new ws(new me(e.clientWidth,e.clientHeight),this.scene,this.camera,[]),this.selectedNodeOutlinePass.visibleEdgeColor.setHex(16734751),this.selectedNodeOutlinePass.hiddenEdgeColor.setHex(12069376),this.selectedNodeOutlinePass.edgeStrength=3,this.selectedNodeOutlinePass.edgeThickness=1,this.activeNodeOutlinePass=new ws(new me(e.clientWidth,e.clientHeight),this.scene,this.camera,[]),this.activeNodeOutlinePass.visibleEdgeColor.setHex(16765952),this.activeNodeOutlinePass.hiddenEdgeColor.setHex(13146624),this.activeNodeOutlinePass.edgeStrength=4,this.activeNodeOutlinePass.edgeThickness=1,this.effectComposer.addPass(n),this.effectComposer.addPass(this.selectedNodeOutlinePass),this.effectComposer.addPass(this.activeNodeOutlinePass),this.effectComposer.addPass(new nP),this.control="orbit",this.orbit=new DA(this.editor.camera,this.renderer.domElement),this.orbit.mouseButtons={LEFT:-1,MIDDLE:xr.PAN,RIGHT:-1},this.orbit.touches={ONE:Gs.PAN,TWO:Gs.ROTATE};const i=navigator.maxTouchPoints>0||window.matchMedia("(pointer: coarse)").matches;this.orbit.panSpeed=i?1.5:1,this.orbit.minDistance=3,this.orbit.maxDistance=150,this.orbit.enableRotate=!0,this.orbit.maxPolarAngle=Math.PI/2,this.orbit.zoomToCursor=!0,this.editor.initialCameraState&&(this.orbit.target.set(this.editor.initialCameraState.target.x,this.editor.initialCameraState.target.y,this.editor.initialCameraState.target.z),this.orbit.update()),this.trackpadOrbitController=new rP({domElement:this.renderer.domElement,orbit:this.orbit}),this.trackpadOrbitController.attach(),this.orbit.addEventListener("change",this.handleOrbitChange),this.transformControls=new RE(this.camera,this.renderer.domElement),this.transformControls.addEventListener("dragging-changed",this.handleTransformControlDraggingChanged),this.transformControls.addEventListener("objectChange",this.handleTransformControlsObjectChange),this.transformControls.addEventListener("object-changed",this.handleTransformControlsObjectChange);const s=this.transformControls.getHelper();this.sceneHelpers.add(s),this.boxSelectHelper=document.createElement("div"),this.boxSelectHelper.style.position="absolute",this.boxSelectHelper.style.border="1px dashed #ffffff",this.boxSelectHelper.style.background="rgba(255, 255, 255, 0.1)",this.boxSelectHelper.style.pointerEvents="none",document.body.appendChild(this.boxSelectHelper),this.grid=new qA({size1:1,size2:5,fineColor:4473924,coarseColor:9079434,xAxisColor:16717636,yAxisColor:65382,distance:500}),this.grid.renderOrder=20,this.grid.userData.keep=!0,this.scene.add(this.grid),this.render(),this.editor.eventHandler.eventBus.emit("viewport:initialized")}animate=e=>{this.applyPendingResize();const t=e*.001-hP;this.editor.robotManager.updateAll(t),this.control==="follow"&&this.alignCameraToRobotView(),this.render(),this.stats&&this.stats.update()};registerEventListeners(){const e=this.editor.eventHandler.eventBus;e.on("editor:camera-reset",this.handleCameraReset),e.on("zone:draft-updated",this.handleZoneDraftUpdated),e.on("selector:object-selected",this.handleObjectSelected),e.on("selector:link-selected",this.handleLinkSelected),e.on("selector:zone-selected",this.handleZoneSelected),e.on("selector:zone-focused",this.handleZoneFocused),e.on("selector:zone-draft-vertex-selected",this.handleZoneDraftVertexSelected),e.on("points-manager:mappoints-updated",this.handleMapPointsUpdated),e.on("editor:object-removed",this.handleObjectRemoved),e.on("ui:grid-visibility-set-requested",this.handleSetGridVisibility),e.on("ui:control-change-requested",this.handleControlSet),e.on("ui:tfc-axis-y-enable-requested",this.handleEnableAxisY),e.on("ui:localization-mode-toggle-requested",this.handleLocalizationModeToggled),e.on("ui:label-visibility-set-requested",this.handleLabelVisibilitySet),e.on("node-manager:label-added",this.handleLabelAdded),e.on("node-manager:label-removed",this.handleLabelRemoved),e.on("ui:pointer-action-set-requested",this.handlePointerActionSet),e.on("ui:initial-view-set-up",this.handleSetUpInitialView),e.on("editor:initialized",this.handleEditorInitialized),e.on("ui:transformControls-set-mode-requested",this.handleTransformcontrolsSetModeRequested),e.on("ui:camera-move-requested",this.handleCameraMoveRequested),e.on("ui:camera-mode-set-requested",this.handleCameraModeSetRequested),e.on("ui:camera-state-set-requested",this.handleCameraStateSetRequested)}deregisterEventListeners(){const e=this.editor.eventHandler.eventBus;e.off("editor:camera-reset",this.handleCameraReset),e.off("zone:draft-updated",this.handleZoneDraftUpdated),e.off("selector:object-selected",this.handleObjectSelected),e.off("selector:link-selected",this.handleLinkSelected),e.off("selector:zone-selected",this.handleZoneSelected),e.off("selector:zone-focused",this.handleZoneFocused),e.off("selector:zone-draft-vertex-selected",this.handleZoneDraftVertexSelected),e.off("points-manager:mappoints-updated",this.handleMapPointsUpdated),e.off("editor:object-removed",this.handleObjectRemoved),e.off("ui:grid-visibility-set-requested",this.handleSetGridVisibility),e.off("ui:control-change-requested",this.handleControlSet),e.off("ui:tfc-axis-y-enable-requested",this.handleEnableAxisY),e.off("ui:localization-mode-toggle-requested",this.handleLocalizationModeToggled),e.off("ui:label-visibility-set-requested",this.handleLabelVisibilitySet),e.off("node-manager:label-added",this.handleLabelAdded),e.off("node-manager:label-removed",this.handleLabelRemoved),e.off("ui:pointer-action-set-requested",this.handlePointerActionSet),e.off("ui:initial-view-set-up",this.handleSetUpInitialView),e.off("editor:initialized",this.handleEditorInitialized),e.off("ui:transformControls-set-mode-requested",this.handleTransformcontrolsSetModeRequested),e.off("ui:camera-move-requested",this.handleCameraMoveRequested),e.off("ui:camera-mode-set-requested",this.handleCameraModeSetRequested),e.off("ui:camera-state-set-requested",this.handleCameraStateSetRequested)}dispose(){this.renderer&&(this.renderer.setAnimationLoop(null),this.selectedNodeOutlinePass?.dispose(),this.activeNodeOutlinePass?.dispose(),this.effectComposer?.dispose(),this.grid&&(this.scene.remove(this.grid),this.grid.geometry.dispose(),this.grid.material.dispose()),this.renderer.dispose()),this.orbit&&(this.orbit.removeEventListener("change",this.handleOrbitChange),this.orbit.dispose()),this.transformControls&&(this.transformControls.removeEventListener("dragging-changed",this.handleTransformControlDraggingChanged),this.transformControls.removeEventListener("objectChange",this.handleTransformControlsObjectChange),this.transformControls.removeEventListener("object-changed",this.handleTransformControlsObjectChange),this.sceneHelpers?.remove(this.transformControls.getHelper()),this.transformControls.dispose()),QA(this.css2DRenderer),this.renderer?.domElement&&(this.renderer.domElement.removeEventListener("pointerdown",this.onPointerDown),this.renderer.domElement.removeEventListener("pointermove",this.onPointerHover),this.renderer.domElement.removeEventListener("pointerleave",this.onPointerLeave)),this.trackpadOrbitController?.detach(),this.boxSelectHelper?.parentNode&&this.boxSelectHelper.parentNode.removeChild(this.boxSelectHelper),this.stats&&this.stats.dom.remove(),this.resizeObserver&&this.resizeObserver.disconnect(),this.resizeObserver=null,this.deregisterEventListeners()}handleSetUpInitialView=e=>{if(this.editor.robotManager.mainRobot){const t=new I(Number(e.x),Number(e.y),0);this.orbit.target.copy(t),this.orbit.update()}};handleLabelAdded=e=>{this.labels.push(e)};handleLabelRemoved=e=>{this.removeLabel(e)};handleLabelVisibilitySet=e=>{this.renderCSS2D=e,this.css2DRenderer.domElement.style.display=this.renderCSS2D?"":"none";const t=this.editor.selectionManager.getSelectableObjects();for(let n=0;n<t.length;n++)t[n].traverse(s=>{s instanceof Hs&&(s.visible=e)})};handleLocalizationModeToggled=e=>{const t=this.editor.previewHelper;if(!t){this.transformControls.detach(),this.orbit.update();return}e?(t.visible=!0,this.transformControls.setMode("rotate"),this.transformControls.showX=!1,this.transformControls.showY=!1,this.transformControls.showZ=!0,this.transformControls.attach(t)):(t.visible=!1,this.transformControls.setMode("translate"),this.transformControls.showX=!0,this.transformControls.showY=!0,this.transformControls.showZ=!1,this.transformControls.detach()),this.orbit.update()};updateEraserIndicator=e=>{this.onMovePosition.fromArray(this.getNormalizedPos(e.clientX,e.clientY));const t=this.editor.selector.getPointerPlaneIntersection(this.onMovePosition,this.editor.camera);if(!t.length){this.editor.eraser.hideIndicator();return}this.editor.eraser.updateIndicator(t[0].point),this.render()};render=()=>{this.effectComposer.render(),this.renderCSS2D&&this.css2DRenderer.render(this.editor.scene,this.editor.viewportCamera),this.renderer.autoClear=!1,this.sceneHelpers.visible&&this.renderer.render(this.sceneHelpers,this.editor.viewportCamera),this.renderer.autoClear=!0};applyPendingResize=()=>{if(!this.pendingResize)return;this.pendingResize=!1,e1({camera:this.editor.viewportCamera,renderer:this.renderer,css2DRenderer:this.css2DRenderer,canvas:this.editor.canvas,width:this.resizeWidth,height:this.resizeHeight})&&(this.effectComposer.setSize(this.resizeWidth,this.resizeHeight),this.selectedNodeOutlinePass.setSize(this.resizeWidth,this.resizeHeight),this.activeNodeOutlinePass.setSize(this.resizeWidth,this.resizeHeight))};depthToBucket(e){for(let t=0;t<tg.length;t++)if(e<tg[t])return t;return Zl.length-1}resizeLabels=()=>{const{camera:e,labels:t,tmpView:n}=this;e.updateMatrixWorld();const i=e.matrixWorldInverse;for(const s of t){s.worldPosition||(s.worldPosition=new I,s.obj.getWorldPosition(s.worldPosition)),n.copy(s.worldPosition).applyMatrix4(i);const a=Math.abs(n.z),o=this.depthToBucket(a);if(o!==s.bucket){const l=s.obj.element;s.bucket!==null?l.classList.replace(Zl[s.bucket],Zl[o]):l.classList.add(Zl[o]),s.bucket=o}}};alignCameraToRobotView(){this.editor.robotManager.mainRobot&&(this.setCameraPosition(),this.setCameraOrientation())}getRobotWorldPose(){const e=this.editor.robotManager.mainRobot;return e.getWorldPosition(this.robotPos),e.getWorldQuaternion(this.robotQuat),{pos:this.robotPos,quat:this.robotQuat}}computeShoulderOffset(e){return this.lookOffset.set(-4,0,2).applyQuaternion(e)}setCameraPosition(){const{pos:e,quat:t}=this.getRobotWorldPose(),n=this.computeShoulderOffset(t);this.camera.position.copy(e).add(n)}setCameraOrientation(){const{pos:e,quat:t}=this.getRobotWorldPose(),n=this.robotForward.set(1,0,0).applyQuaternion(t);this.camera.lookAt(e.clone().add(n.multiplyScalar(10)))}getNormalizedPos(e,t){const n=this.renderer.domElement.getBoundingClientRect();return[(e-n.left)/n.width,(t-n.top)/n.height]}onPointerDown=e=>{this.pointerDownTime=performance.now(),e.preventDefault(),e.target===this.renderer.domElement&&(this.renderer.domElement.setPointerCapture(e.pointerId),this.activePointId=e.pointerId,this.onDownPosition.fromArray(this.getNormalizedPos(e.clientX,e.clientY)),this.onDownPx.set(e.clientX,e.clientY),this.isBoxSelectGestureActive=!1,this.pointerSelectionIntent=this.resolveSelectionIntent(e),e.pointerType==="mouse"&&e.button===this.PRIMARY_MOUSE_BUTTON&&this.canStartBoxSelect()&&(this.isBoxSelectGestureActive=!0,this.startPoint.set(e.clientX,e.clientY),this.endPoint.copy(this.startPoint),Object.assign(this.boxSelectHelper.style,{left:`${this.startPoint.x}px`,top:`${this.startPoint.y}px`,width:"0px",height:"0px",display:"block"})),this.renderer.domElement.addEventListener("pointermove",this.onPointerMove,{passive:!1}),this.renderer.domElement.addEventListener("pointerup",this.onPointerUp),this.renderer.domElement.addEventListener("pointercancel",this.onPointerUp))};onPointerMove=e=>{if(e.pointerId!==this.activePointId)return;e.preventDefault(),this.onMovePosition.fromArray(this.getNormalizedPos(e.clientX,e.clientY));const t=this.editor.selector.getPointerPlaneIntersection(this.onMovePosition,this.editor.camera);if(t.length){if(this.pointerAction==="zoneDraft"){const n=t[0].point.clone();n.z=0,this.editor.eventHandler.eventBus.emit("viewport:zone-point-preview-updated",{point:n})}if(e.pointerType==="mouse"&&e.buttons===1&&this.isBoxSelectGestureActive){this.endPoint.set(e.clientX,e.clientY);const n=Math.min(this.startPoint.x,this.endPoint.x),i=Math.min(this.startPoint.y,this.endPoint.y),s=Math.abs(this.endPoint.x-this.startPoint.x),a=Math.abs(this.endPoint.y-this.startPoint.y);Object.assign(this.boxSelectHelper.style,{left:`${n}px`,top:`${i}px`,width:`${s}px`,height:`${a}px`})}}};onPointerHover=e=>{if(this.activePointId!==null||e.target!==this.renderer.domElement)return;if(this.pointerAction==="erase"){this.updateEraserIndicator(e);return}const t=this.pointerAction==="zoneDraft"&&this.zoneDraftState==="drawing",n=this.zoneDraftState==="closed";if(!t&&!n)return;const i=this.getNormalizedPos(e.clientX,e.clientY);if(this.onMovePosition.fromArray(i),n){const o=this.editor.selector.getPointerZoneDraftVertexIntersection(this.onMovePosition,this.editor.camera);this.editor.eventHandler.eventBus.emit("viewport:zone-draft-vertex-hovered",{vertexIndex:o?.vertexIndex??null});return}const s=this.editor.selector.getPointerPlaneIntersection(this.onMovePosition,this.editor.camera);if(!s.length)return;const a=s[0].point.clone();a.z=0,this.editor.eventHandler.eventBus.emit("viewport:zone-point-preview-updated",{point:a})};onPointerLeave=e=>{this.activePointId===null&&e.target===this.renderer.domElement&&(this.editor.eraser.hideIndicator(),this.zoneDraftState==="closed"&&this.editor.eventHandler.eventBus.emit("viewport:zone-draft-vertex-hovered",{vertexIndex:null}),this.pointerAction==="zoneDraft"&&this.editor.eventHandler.eventBus.emit("viewport:pointer-leave",void 0))};finishPointer=()=>{this.renderer.domElement.removeEventListener("pointermove",this.onPointerMove),this.renderer.domElement.removeEventListener("pointerup",this.onPointerUp),this.renderer.domElement.removeEventListener("pointercancel",this.onPointerUp),this.activePointId!==null&&(this.renderer.domElement.releasePointerCapture(this.activePointId),this.activePointId=null),this.isBoxSelectGestureActive=!1,this.pointerSelectionIntent="replace",this.boxSelectHelper.style.display="none",this.pointerAction!=="erase"&&this.editor.eraser.hideIndicator()};onPointerUp=e=>{if(e.pointerId!==this.activePointId)return;this.onUpPosition.fromArray(this.getNormalizedPos(e.clientX,e.clientY)),this.onUpPx.set(e.clientX,e.clientY);const t=e.pointerType==="mouse"&&e.button===this.PRIMARY_MOUSE_BUTTON,n=e.pointerType==="touch";(t||n)&&this.handlePrimaryPointerAction(),this.finishPointer()};handlePrimaryPointerAction=()=>{const e=performance.now()-this.pointerDownTime,t=this.onDownPx.distanceToSquared(this.onUpPx),n=Math.pow(oP*devicePixelRatio,2);if(e<aP&&t<=n)switch(this.pointerAction){case"inspect":this.handleInspectAndSelect(this.pointerAction);break;case"select":this.handleInspectAndSelect(this.pointerAction);break;case"locatePreview":this.updatePreviewOnPointer();break;case"erase":this.handleErase();break;case"zoneDraft":{const s=this.editor.selector.getPointerPlaneIntersection(this.onUpPosition,this.editor.camera);if(s.length){const a=s[0].point.clone();a.z=0,this.editor.eventHandler.eventBus.emit("viewport:zone-point-place-requested",{point:a})}break}default:this.pointerAction}else this.isBoxSelectGestureActive&&this.handleBoxSelect();this.render()};handleErase=()=>{const e=this.editor.selector.getPointerMapBrushIntersections(this.onUpPosition,this.editor.camera);this.editor.eventHandler.eventBus.emit("eraser:intersections-detected",e)};updatePreviewOnPointer=()=>{const e=this.editor.previewHelper;if(!e)return;const t=this.editor.selector.getPointerPlaneIntersection(this.onDownPosition,this.editor.camera);t.length&&(e.updatePosition(t[0].point),e.position.z=0,this.transformControls.attach(e))};handleInspectAndSelect=e=>{const t=this.editor.selector.getPointerObjectIntersections(this.onUpPosition,this.editor.camera);this.editor.eventHandler.eventBus.emit("viewport:intersections-detected",{action:e,intent:this.pointerSelectionIntent,intersections:t})};resolveSelectionIntent=e=>e.metaKey||e.ctrlKey?"remove":e.shiftKey?"add":"replace";handleCameraReset=()=>{const e=this.renderer.domElement;this.camera instanceof gn&&(this.camera.aspect=e.clientWidth/e.clientHeight,this.camera.updateProjectionMatrix(),this.orbit.target.set(0,0,0),this.emitCameraChanged())};handleCameraModeSetRequested=e=>{if(!(!this.camera||!this.orbit)){if(this.control="orbit",this.orbit.enabled=!0,e==="topView"){this.currentCameraMode!=="topView"&&(this.lastPerspectiveCameraState=this.getCameraState());const t=this.orbit.target.clone(),n=bt.clamp(this.camera.position.distanceTo(t),this.orbit.minDistance+.1,this.orbit.maxDistance-.1);this.camera.up.set(0,1,0),this.camera.position.set(t.x,t.y,t.z+n),this.orbit.enableRotate=!1,this.orbit.update(),this.currentCameraMode="topView",this.emitCameraChanged(),this.render();return}if(this.camera.up.set(0,0,1),this.orbit.enableRotate=!0,this.currentCameraMode==="topView")if(this.lastPerspectiveCameraState)this.camera.position.set(this.lastPerspectiveCameraState.position.x,this.lastPerspectiveCameraState.position.y,this.lastPerspectiveCameraState.position.z),this.orbit.target.set(this.lastPerspectiveCameraState.target.x,this.lastPerspectiveCameraState.target.y,this.lastPerspectiveCameraState.target.z);else{const t=this.orbit.target,n=bt.clamp(this.camera.position.distanceTo(t),this.orbit.minDistance+.1,this.orbit.maxDistance-.1);this.camera.position.set(t.x-n*.75,t.y,t.z+n)}this.orbit.update(),this.currentCameraMode="perspective",this.emitCameraChanged(),this.render()}};handleZoneDraftUpdated=e=>{this.zoneDraftState=e.state,this.zoneDraftEditingZoneId=e.editingZoneId,e.editingZoneId!==null&&this.transformControls.object?.userData.topologyObjectType==="zone"&&this.transformControls.detach(),e.state!=="closed"&&this.editor.eventHandler.eventBus.emit("viewport:zone-draft-vertex-hovered",{vertexIndex:null})};handleBoxSelect=()=>{this.boxSelectHelper.style.display="none";const e=this.editor.selector.getSelectionBoxIntersects(this.renderer.domElement,this.startPoint,this.endPoint);e.length&&this.editor.eventHandler.eventBus.emit("selector:box-intersections-detected",{intersections:e,action:this.pointerAction==="select"?"select":"inspect"})};canStartBoxSelect=()=>{const e=this.editor.selectionManager.getSelectedZoneVertex();return(this.pointerAction==="select"||this.pointerAction==="inspect")&&!this.transformControls.dragging&&e===null};handleTransformControlsObjectChange=()=>{if(this.transformControls.object){if(this.transformControls.object.userData.topologyObjectType==="zone")return;if(this.transformControls.object.userData.objectType==="topology-zone-draft-vertex"){const t=this.transformControls.object.userData.vertexIndex;typeof t=="number"&&this.editor.eventHandler.eventBus.emit("viewport:zone-draft-vertex-moved",{vertexIndex:t,point:this.transformControls.object.position.clone()});return}const e=bt.radToDeg(this.transformControls.object.rotation.z);this.editor.eventHandler.eventBus.emit("node-manager:selection-transform-changed",{x:this.transformControls.object.position.x.toString().slice(0,6),y:this.transformControls.object.position.y.toString().slice(0,6),z:this.transformControls.object.position.z.toString().slice(0,6),rz:e.toString().slice(0,6)})}else this.editor.eventHandler.eventBus.emit("node-manager:selection-transform-changed",null)};handleObjectSelected=e=>{const{object:t,selectedObjects:n,action:i}=e;this.transformControls.detach(),this.selectedNodeOutlinePass.selectedObjects=n.length>1?n.slice(0,-1):[],this.activeNodeOutlinePass.selectedObjects=t!==null?[t]:[],t!==null&&i==="select"&&this.transformControls.attach(t)};handleLinkSelected=()=>{this.transformControls.detach()};handleZoneSelected=()=>{this.transformControls.detach(),this.attachFocusedZoneTransform()};handleZoneFocused=()=>{this.pointerAction!=="select"||this.zoneDraftEditingZoneId!==null||(this.transformControls.detach(),this.attachFocusedZoneTransform())};attachFocusedZoneTransform(){if(this.pointerAction!=="select"||this.zoneDraftEditingZoneId!==null)return!1;const e=this.editor.selectionManager.getFocusedZoneId(),n=this.editor.selectionManager.getSelectedZones().find(i=>String(i.userData.zoneId)===e)?.userData.zoneOwner;return n?(this.transformControls.attach(n),this.transformControls.setMode("translate"),this.transformControls.showX=!0,this.transformControls.showY=!0,this.transformControls.showZ=!1,!0):!1}handleZoneDraftVertexSelected=e=>{if(!e.vertex||e.vertexIndex===null){this.transformControls.detach();return}this.transformControls.attach(e.vertex),this.transformControls.setMode("translate"),this.transformControls.showX=!0,this.transformControls.showY=!0,this.transformControls.showZ=!1};handleMapPointsUpdated=()=>{this.transformControls.detach(),this.render()};handleObjectRemoved=e=>{e.label&&(this.removeLabel(e.label),this.transformControls.detach())};removeLabel(e){const t=this.labels.findIndex(n=>n.obj===e);t>-1&&this.labels.splice(t,1)}handleSetGridVisibility=e=>{this.grid&&(this.grid.visible=e)};setClearColor=e=>{if(e==="transparent"||e==="inherit"){this.renderer.setClearColor(0,0);return}this.renderer.setClearColor(e)};setGridColors=(e,t)=>{this.grid?.setColors(e,t)};setGridAxisColors=(e,t)=>{this.grid?.setAxisColors(e,t)};handleControlSet=e=>{e==="orbit"?this.activateOrbitMode():e==="follow"&&this.activateFollowMode()};activateOrbitMode(){if(!this.editor.robotManager.mainRobot)return;this.orbit.enabled=!0;const{pos:e}=this.getRobotWorldPose();this.orbit.target.copy(e);const t=this.editor.robotManager.mainRobot,n=new vn;new Yt().setFromObject(t).getBoundingSphere(n);const i=n.radius||1,s=this.camera.position.clone().sub(this.orbit.target).normalize(),a=bt.clamp(i*15,this.orbit.minDistance+.1,this.orbit.maxDistance-.1);this.camera.position.copy(this.orbit.target).addScaledVector(s,a),this.orbit.update(),this.control="orbit",this.emitCameraChanged()}activateFollowMode(){this.orbit.enabled=!1,this.control="follow"}handleEnableAxisY=e=>{};handleOrbitChange=()=>{this.emitCameraChanged(),this.renderCSS2D&&clearTimeout(this.interactionTimer)};handlePointerActionSet=e=>{this.pointerAction=e,this.pointerAction==="inspect"&&this.transformControls.detach(),this.pointerAction!=="erase"&&this.editor.eraser.hideIndicator()};handleTransformControlDraggingChanged=e=>{this.orbit.enabled=!e.value,e.value&&(this.isBoxSelectGestureActive=!1);const t=this.transformControls.object,n=t?this.editor.selectionManager.isSelectable(t):!1,i=t?.userData.topologyObjectType==="zone"?String(t.userData.zoneId):null,s=i!==null&&i===this.editor.selectionManager.getFocusedZoneId();if(e.value){if(!t||!n&&!s){this.transformDragStart=null;return}this.transformDragStart={object:t,position:t.position.clone(),rotation:t.rotation.clone()};return}const a=this.transformDragStart;if(this.transformDragStart=null,!a||!t||a.object!==t)return;const o=a.position.distanceTo(t.position)>Ja,l=Math.abs(a.rotation.x-t.rotation.x)>Ja||Math.abs(a.rotation.y-t.rotation.y)>Ja||Math.abs(a.rotation.z-t.rotation.z)>Ja;if(!(!o&&!l)){if(s&&i){const c=t.position.clone().sub(a.position);this.editor.eventHandler.eventBus.emit("viewport:zone-translation-committed",{zoneId:i,delta:{x:c.x,y:c.y}});return}this.editor.eventHandler.eventBus.emit("topology:changed",{source:"node-updated"})}};handleEditorInitialized=()=>{this.initialize()};handleTransformcontrolsSetModeRequested=e=>{if(!this.transformControls||this.attachFocusedZoneTransform())return;if(this.transformControls.object?.userData.topologyObjectType==="zone"){this.transformControls.setMode("translate"),this.transformControls.showX=!0,this.transformControls.showY=!0,this.transformControls.showZ=!1;return}const t=this.editor.selectionManager.getSelected()??this.editor.selectionManager.getSelectedZoneVertex();t&&this.transformControls.attach(t),this.transformControls.setMode(e),e==="rotate"?(this.transformControls.showX=!1,this.transformControls.showY=!1,this.transformControls.showZ=!0):(this.transformControls.showX=!0,this.transformControls.showY=!0,this.transformControls.showZ=!1)};handleCameraMoveRequested=e=>{const t=this.camera,n=this.orbit,i=t.position.distanceTo(n.target),s=Math.min(Math.max(i*.03,.1),5),a=1;switch(t.getWorldDirection(this.fwd).normalize(),this.right.copy(this.fwd).cross(t.up).normalize(),this.up.copy(this.right).cross(this.fwd).normalize(),this.delta.set(0,0,0),e){case"up":this.delta.copy(this.up).multiplyScalar(s);break;case"down":this.delta.copy(this.up).multiplyScalar(-s);break;case"left":this.delta.copy(this.right).multiplyScalar(-s);break;case"right":this.delta.copy(this.right).multiplyScalar(s);break;case"zoomin":this.delta.copy(this.fwd).multiplyScalar(a),t.position.add(this.delta),n.update(),this.emitCameraChanged();return;case"zoomout":this.delta.copy(this.fwd).multiplyScalar(-a),t.position.add(this.delta),n.update(),this.emitCameraChanged();return;case"center":{const o=t.position.z,l=.001;n.target.set(0,0,0),t.position.set(l,l,o),n.update(),this.emitCameraChanged();return}case"focus":this.focusCameraOnActiveNode();return}t.position.add(this.delta),n.target.add(this.delta),n.update(),this.emitCameraChanged()};handleCameraStateSetRequested=e=>{this.setCameraState(e)};focusCameraOnActiveNode=()=>{const e=this.editor.selectionManager.getSelected();if(!e)return;this.focusBox.setFromObject(e),this.focusBox.isEmpty()?(this.focusCenter.copy(e.position),this.focusSphere.center.copy(this.focusCenter),this.focusSphere.radius=eg):(this.focusBox.getCenter(this.focusCenter),this.focusBox.getBoundingSphere(this.focusSphere));const t=Math.max(this.focusSphere.radius,eg),n=bt.clamp(t*dP,lP,cP);this.focusDirection.copy(this.camera.position).sub(this.orbit.target),this.focusDirection.lengthSq()<Ja?this.camera.getWorldDirection(this.focusDirection).multiplyScalar(-1):this.focusDirection.normalize(),this.orbit.target.copy(this.focusCenter),this.camera.position.copy(this.focusCenter).addScaledVector(this.focusDirection,n),this.orbit.update(),this.emitCameraChanged()}}class fP{nodeManager;eventHandler;robotManager;selectionManager;selector;eraser;pathDrawer;trajectoryDrawer;pointsManager;tileMap;viewport;initialized=!1;scene;sceneHelpers;camera;viewportCamera;robotType=null;initialCameraState=null;previewHelper;globalPlane;canvas=null;constructor(){this.selectionManager=new LC,this.eventHandler=new _1(this),this.nodeManager=new xC(this),this.robotManager=new DC(this),this.selector=new IC(this),this.eraser=new x1(this),this.pathDrawer=new TC(this),this.trajectoryDrawer=new WC(this),this.pointsManager=new AC(this),this.tileMap=new GC(this),this.viewport=new uP(this)}getEraserRadius(){return this.selector?this.selector.pointsThreshold:.5}async initialize(e){this.canvas=e.canvas,this.robotType=e.robotType,this.initialCameraState=e.initialCameraState??null,Pt.DEFAULT_UP=new I(0,0,1),this.scene=new uu,this.sceneHelpers=new uu,this.camera=Ta.clone(),this.initialCameraState&&this.camera.position.set(this.initialCameraState.position.x,this.initialCameraState.position.y,this.initialCameraState.position.z),this.viewportCamera=this.camera;const t=new $s(1e4,1e4),n=new jt({visible:!1}),i=new Ee(t,n);i.name="globalPlane",i.userData.keep=!0,this.globalPlane=i,this.scene.add(this.globalPlane);const s=new Sp(16777215,2105376,.5);s.userData.keep=!0,this.scene.add(s);const a=new Hc(16777215,1);a.position.set(0,0,100),a.userData.keep=!0,this.scene.add(a),this.sceneHelpers.add(new Sp(16777215,8947848,2)),this.selectionManager.reset(),this.eventHandler.registerEventListeners(),this.viewport.registerEventListeners(),this.eventHandler.registerCanvasEventListeners(),this.selector.registerEventListeners(),this.pointsManager.registerEventListeners(),this.tileMap.registerEventListeners(),this.eraser.registerEventListeners(),this.nodeManager.registerEventListeners(),this.robotManager.registerEventListeners(),this.initialized=!0,this.eventHandler.eventBus.emit("editor:initialized",e)}addOrigin(e){const t=new Pa(.1),n=new jt({color:16711680}),i=new Ee(t,n);i.name="origin";const s=new Da(e);i.add(s),this.scene.add(i)}clear(e={clearMap:!0,clearTopo:!0}){e.clearMap&&this.pointsManager.clearMapPoints(),e.clearTopo&&this.nodeManager.clearTopo()}resetCamera(){this.camera.copy(Ta),this.eventHandler.eventBus.emit("editor:camera-reset")}resetMappingRecovery(){this.pointsManager.resetMappingRecovery()}dispose(){if(this.initialized){for(this.eventHandler.dispose(),this.eraser.dispose(),this.pathDrawer.dispose(),this.trajectoryDrawer.dispose(),this.robotManager.dispose(),this.selector.dispose(),this.pointsManager.dispose(),this.nodeManager.dispose(),this.tileMap.dispose(),this.viewport.dispose(),this.scene.traverse(e=>{e instanceof Ee&&(e.geometry&&e.geometry.dispose(),e.material&&Array.isArray(e.material)&&e.material.forEach(t=>{t.dispose()}))});this.scene.children.length>0;)this.scene.remove(this.scene.children[0]);this.robotType=null,this.initialCameraState=null,this.initialized=!1}}getObjectBySlamId(e){let t=null;return this.scene.traverse(n=>{n.userData.id===e&&(t=n)}),t}removeObject(e){if(e.parent===null)return;const t=e.children.find(i=>i instanceof Hs),n=this.selectionManager.isSelectable(e);e.parent.remove(e),n&&(this.nodeManager.removeAllLinksRelatedTo(e),this.nodeManager.removeAllArrowsRelatedTo(e),this.selectionManager.unregisterSelectable(e),this.eventHandler.eventBus.emit("topology:nodes-updated",this.selectionManager.getSelectableObjects())),e.clear(),this.eventHandler.eventBus.emit("editor:object-removed",{object:e,label:t})}setupPreviewHelper(e){this.previewHelper?.parent&&this.previewHelper.parent.remove(this.previewHelper);let t;e==="QD-RBY"?t=new XC:e==="rby1a"||e==="rby1m"||e==="rby1ub"||e==="rby2c"?t=new ZC(e):e==="GAIA"||e==="QD"?t=new qC:t=new jC,this.previewHelper=t,this.scene.add(this.previewHelper)}}const ah=r=>typeof r=="number"&&Number.isFinite(r),ng=r=>{if(!r||typeof r!="object")return!1;const e=r;return ah(e.x)&&ah(e.y)&&ah(e.z)},pP=r=>{if(!r)return null;try{const e=JSON.parse(r);if(!e||typeof e!="object")return null;const t=e;return!ng(t.position)||!ng(t.target)?null:{position:t.position,target:t.target}}catch{return null}},mP=r=>{if(!r)return null;try{return pP(localStorage.getItem(r))}catch{return null}},gP=(r,e)=>{if(r)try{localStorage.setItem(r,JSON.stringify(e))}catch{}},bP=({className:r})=>v("div",{className:$t("absolute top-0 left-0 z-50 flex h-full w-full items-center justify-center p-1.5 text-5xl text-white",r),children:v(Wv,{size:"3rem"})}),{useCallback:vP,useMemo:Yl,useReducer:yP,useState:Gi}=await At("react"),xP={state:"idle",editingZoneId:null,selectedVertexIndex:null,name:"",type:"NO_ENTRY",pointCount:0,points:[]},Ac={editor:!1,viewport:!1,nodeManager:!1,robot:!1,map:!1,topo:!1};function Mv(r,e){switch(e.type){case"RESET":return Ac;case"SET":return r[e.key]===e.value?r:{...r,[e.key]:e.value};case"REPLACE":return e.ready}}function $N(){const[r,e]=yP(Mv,Ac),[t,n]=Gi([]),[i,s]=Gi(null),[a,o]=Gi([]),[l,c]=Gi(null),[d,h]=Gi([]),[u,f]=Gi(null),[m,b]=Gi([]),[p,g]=Gi([]),[y,x]=Gi([]),[w,P]=Gi(null),[T,A]=Gi(xP),M=vP(O=>{e({type:"REPLACE",ready:O})},[]),_=Yl(()=>t[t.length-1]??null,[t]),S=Yl(()=>{if(a.length===0)return[];const O=new Set(a);return p.filter(H=>O.has(H.id))},[p,a]),R=Yl(()=>S.length===0||!l?null:S.find(O=>O.id===l)??null,[l,S]),k=Yl(()=>({onReadyChange:M,onSelectedObjectsChange:n,onSelectedNodeTransformChange:s,onSelectedLinksChange:o,onFocusedLinkChange:c,onSelectedZonesChange:h,onFocusedZoneChange:f,onNodesChange:b,onLinksChange:g,onZonesChange:x,onMapBoundsChange:P,onZoneDraftChange:A}),[M]);return{ready:r,selectedObjects:t,selectedNodeTransform:i,selectedNode:_,selectedLinkIds:a,focusedLinkId:l,selectedLinks:S,focusedLink:R,selectedZoneIds:d,focusedZoneId:u,nodes:m,links:p,zones:y,mapBounds:w,zoneDraft:T,worldStudioStateProps:k}}const{forwardRef:_P,useCallback:Ti,useEffect:qt,useImperativeHandle:wP,useMemo:SP,useReducer:MP,useRef:Kl,useState:ig}=await At("react"),sg={light:{background:"#f4f4f5",fine:5395026,coarse:5921370,xAxis:16717636,yAxis:65382},dark:{background:"#333333",fine:6052956,coarse:9079434,xAxis:16717636,yAxis:65382}},TP=r=>r.map(e=>({id:String(e.userData?.id??""),uuid:e.uuid,name:e.name,type:e.userData.type?.toLowerCase()||"unknown",features:Array.isArray(e.userData.features)?e.userData.features.filter(t=>typeof t=="string"):[],safetyField:typeof e.userData.safetyField=="number"?e.userData.safetyField:0,x:e.position.x,y:e.position.y,z:e.position.z})),EP=_P(({className:r,cameraPositionKey:e,pointsData:t,parsedPointCloudData:n,topoData:i,mapCloudUpdatedAt:s,topologyUpdatedAt:a,robot:o,globalPath:l,localPath:c,trajectory:d,lidarPoints:h,lidar3DPoints:u,mappingPoints:f,robotPose:m,selectedTool:b,showGrid:p,showNodeLabels:g,nodeRenderMode:y="default",showLidar:x,showLidar3D:w,showMapBoundary:P,mapPointHeightClip:T,lidarPointSize:A,mapPointSize:M,viewportCameraMode:_,mappingKeyFrame:S,onReadyChange:R,onSelectedObjectsChange:k,onSelectedNodeTransformChange:O,onSelectedLinksChange:H,onFocusedLinkChange:q,onSelectedZonesChange:G,onFocusedZoneChange:K,onNodesChange:V,onLinksChange:Y,onZonesChange:le,onMapBoundsChange:se,onEraserHistoryInvalidated:ge,onEraserSelectionChange:de,onZoneDraftChange:X},ee)=>{const{theme:ie}=Ea(),Z=Kl(null),ue=Kl(null),oe=Kl(o??null),[be,Ce]=ig(null),[je,Fe]=MP(Mv,Ac),j=Kl(null),[Ke,Ue]=ig("none"),Te=SP(()=>je.editor&&je.viewport&&je.nodeManager,[je]),Se=Ti((te,re)=>{if(je[te]===re)return;const De={...je,[te]:re};Fe({type:"SET",key:te,value:re}),R?.(De)},[je,R]),et=Ti(()=>{Fe({type:"RESET"}),R?.(Ac)},[R]),Be=Ti(te=>{V?.(TP(te))},[V]),N=Ti(()=>{const te=Z.current?.nodeManager.getTopologyLinks()??[];Y?.(te)},[Y]),E=Ti(()=>{const te=Z.current?.nodeManager.getTopologyZones()??[];le?.(te)},[le]),W=Ti(te=>{if(k?.(te.selectedObjects),!!O){if(!te.object){O(null);return}O({x:te.object.position.x,y:te.object.position.y,z:te.object.position.z,rz:bt.radToDeg(te.object.rotation.z)})}},[O,k]),ae=Ti(te=>{if(!te){O?.(null);return}const re=Number(te.x),De=Number(te.y),Ye=Number(te.z),xe=Number(te.rz);if([re,De,Ye,xe].some(Le=>Number.isNaN(Le))){O?.(null);return}O?.({x:re,y:De,z:Ye,rz:xe})},[O]),ve=Ti(te=>{se?.(te.mapBounds),Se("map",!0)},[se,Se]),ce=Ti(te=>{H?.(te.linkIds)},[H]),Oe=Ti(te=>{G?.(te.zoneIds)},[G]),Pe=Ti(te=>{q?.(te.linkId)},[q]),Ve=Ti(te=>{K?.(te.zoneId)},[K]);return wP(ee,()=>({emit:(te,re)=>{Z.current?.eventHandler.eventBus.emit(te,re)},getCamera:()=>{const te=Z.current;return te?.viewportCamera??te?.camera??null},getCanvas:()=>Z.current?.canvas??null,getEraserRadius:()=>Z.current?.getEraserRadius()??.5,getMapPointsData:()=>Z.current?.pointsManager?.mapPointsData??[],resetMappingRecovery:()=>{j.current=null,Z.current?.resetMappingRecovery()},getPreviewTransform:()=>{const te=Z.current?.previewHelper;return te?{x:te.position.x.toString(),y:te.position.y.toString(),z:te.position.z.toString(),rz:(te.rotation.z*(180/Math.PI)).toString()}:null},getTopologyData:()=>{const te=Z.current?.selectionManager.getSelectableObjects()??[],re=Z.current?.nodeManager.getTopologyLinks()??[],De=Z.current?.nodeManager.getTopologyZones()??[],Ye=te.map(xe=>({id:typeof xe.userData.id=="string"?xe.userData.id:xe.uuid,name:xe.name,context:typeof xe.userData.context=="string"?xe.userData.context:"",pose:{x:xe.position.x,y:xe.position.y,z:xe.position.z,rx:bt.radToDeg(xe.rotation.x),ry:bt.radToDeg(xe.rotation.y),rz:bt.radToDeg(xe.rotation.z)},size:{x:0,y:0,z:0},type:typeof xe.userData.type=="string"?xe.userData.type:"GOAL",safetyField:typeof xe.userData.safetyField=="number"?xe.userData.safetyField:0,features:Array.isArray(xe.userData.features)?xe.userData.features.filter(ct=>typeof ct=="string"):[]}));return{format_version:EE,nodes:Ye,links:re,zones:De}},getTopologyZones:()=>Z.current?.nodeManager.getTopologyZones()??[],hidePreviewHelper:()=>{const te=Z.current;te&&(te.setupPreviewHelper(null),te.previewHelper.visible=!1)},moveCamera:te=>{Z.current?.eventHandler.eventBus.emit("ui:camera-move-requested",te)},startZoneDraft:te=>{Z.current?.eventHandler.eventBus.emit("ui:zone-draft-start-requested",te)},cancelZoneDraft:()=>{Z.current?.eventHandler.eventBus.emit("ui:zone-draft-cancel-requested",void 0)},clearZoneDraft:()=>{Z.current?.eventHandler.eventBus.emit("ui:zone-draft-clear-requested",void 0)},undoZoneDraft:()=>{Z.current?.eventHandler.eventBus.emit("ui:zone-draft-undo-requested",void 0)},closeZoneDraft:()=>{Z.current?.eventHandler.eventBus.emit("ui:zone-draft-close-requested",void 0)},reopenZoneDraft:()=>{Z.current?.eventHandler.eventBus.emit("ui:zone-draft-reopen-requested",void 0)},commitZoneDraft:()=>{Z.current?.eventHandler.eventBus.emit("ui:zone-draft-commit-requested",void 0)},startZoneEdit:te=>{Z.current?.eventHandler.eventBus.emit("ui:zone-edit-start-requested",{zoneId:te})},focusActiveTopologyZone:te=>{Z.current?.nodeManager.focusActiveTopologyZone(te)},updateZoneDraftMeta:te=>{Z.current?.eventHandler.eventBus.emit("ui:zone-draft-meta-updated",te)},deleteTopologyZone:te=>{Z.current?.nodeManager.deleteTopologyZone(te)},onTopologyChanged:te=>{const re=Z.current?.eventHandler.eventBus;return re?(re.on("topology:changed",te),()=>{re.off("topology:changed",te)}):()=>{}}}),[]),qt(()=>{Z.current||(Z.current=new fP);const re=Z.current.eventHandler.eventBus,De=()=>Se("editor",!0),Ye=()=>Se("viewport",!0),xe=()=>Se("nodeManager",!0),Le=Q=>{gP(e,Q)},ct=Q=>{X?.(Q),Ue(Q.state==="drawing"?"zoneDraft":"none")},rt=Q=>{de?.(Q.selectedCount)},Rt=()=>{ge?.()};return re.on("editor:initialized",De),re.on("viewport:initialized",Ye),re.on("node-manager:ready",xe),re.on("viewport:camera-changed",Le),re.on("points-manager:mappoints-updated",ve),re.on("selector:object-selected",W),re.on("node-manager:selection-transform-changed",ae),re.on("selector:link-selected",ce),re.on("selector:link-focused",Pe),re.on("selector:zone-selected",Oe),re.on("selector:zone-focused",Ve),re.on("topology:nodes-updated",Be),re.on("node-manager:topo-updated",N),re.on("node-manager:topo-updated",E),re.on("eraser:history-invalidated",Rt),re.on("eraser:selection-changed",rt),re.on("zone:draft-updated",ct),()=>{re.off("editor:initialized",De),re.off("viewport:initialized",Ye),re.off("node-manager:ready",xe),re.off("viewport:camera-changed",Le),re.off("points-manager:mappoints-updated",ve),re.off("selector:object-selected",W),re.off("node-manager:selection-transform-changed",ae),re.off("selector:link-selected",ce),re.off("selector:link-focused",Pe),re.off("selector:zone-selected",Oe),re.off("selector:zone-focused",Ve),re.off("topology:nodes-updated",Be),re.off("node-manager:topo-updated",N),re.off("node-manager:topo-updated",E),re.off("eraser:history-invalidated",Rt),re.off("eraser:selection-changed",rt),re.off("zone:draft-updated",ct)}},[ve,W,ae,Pe,Ve,ce,Oe,q,K,ge,de,X,e,Se,N,Be,E]),qt(()=>{const te=Z.current;te&&(oe.current=o??null,te.robotType=o??null)},[o]),qt(()=>{const te=Z.current;if(te){if(!be){ue.current=null;return}if(!(!be.isConnected||!be.parentElement)&&ue.current!==be)return ue.current=be,te.initialize({robotType:oe.current,canvas:be,initialCameraState:mP(e)}),()=>{te.dispose(),ue.current=null,et()}}},[e,be,et]),qt(()=>{const te=Z.current;!Te||!te||t&&te.eventHandler.eventBus.emit("ui:map-points-update-requested",t)},[t,s,Te]),qt(()=>{const te=Z.current;!Te||!te||(n?te.eventHandler.eventBus.emit("ui:typed-map-points-update-requested",n):t||te.clear({clearMap:!0,clearTopo:!1}))},[n,t,Te]),qt(()=>{const te=Z.current;!Te||!te||te.pathDrawer.updateGlobalPath(l??[])},[l,Te]),qt(()=>{const te=Z.current;!Te||!te||te.pathDrawer.updateLocalPath(c??[])},[c,Te]),qt(()=>{const te=Z.current;!Te||!te||te.trajectoryDrawer.updateTrajectory(d??[])},[d,Te]),qt(()=>{const te=Z.current;!Te||!te||te.eventHandler.eventBus.emit("ui:topo-update-requested",{topoData:i})},[i,a,Te]),qt(()=>{const te=Z.current;!Te||!te||te.eventHandler.eventBus.emit("ui:grid-visibility-set-requested",p)},[p,Te]),qt(()=>{const te=Z.current;!Te||!te||!_||te.eventHandler.eventBus.emit("ui:camera-mode-set-requested",_)},[Te,_]),qt(()=>{const te=Z.current?.viewport;if(!Te||!te)return;const{background:re,fine:De,coarse:Ye,xAxis:xe,yAxis:Le}=sg[ie]??sg.dark;te.setGridColors(De,Ye),te.setGridAxisColors(xe,Le)},[ie,Te]),qt(()=>{const te=Z.current;!Te||!te||!o||(te.robotManager.loadMainRobot(o),te.setupPreviewHelper(o))},[o,Te]),qt(()=>{const te=Z.current;!Te||!te||!h||te.eventHandler.eventBus.emit("lidar:updated",{lidarPoints:h})},[h,Te]),qt(()=>{const te=Z.current;!Te||!te||!u||te.eventHandler.eventBus.emit("lidar3d:updated",{lidarPoints:u})},[u,Te]),qt(()=>{const te=Z.current;if(!Te||!te||!m)return;const re=te.robotManager.mainRobot;re&&re.applyPose({x:Number(m.x??0),y:Number(m.y??0),rz:Number(m.rz??0)})},[m,Te]),qt(()=>{const te=Z.current;if(!Te||!te)return;const re=te.eventHandler.eventBus;if(re.emit("ui:localization-mode-toggle-requested",!1),Ke==="zoneDraft"){re.emit("ui:pointer-action-set-requested","zoneDraft");return}switch(b){case"select":re.emit("ui:pointer-action-set-requested","inspect");break;case"target":re.emit("ui:localization-mode-toggle-requested",!0),re.emit("ui:pointer-action-set-requested","locatePreview");break;case"move":re.emit("ui:pointer-action-set-requested","select"),re.emit("ui:transformControls-set-mode-requested","translate");break;case"rotate":re.emit("ui:pointer-action-set-requested","select"),re.emit("ui:transformControls-set-mode-requested","rotate");break;case"scale":re.emit("ui:pointer-action-set-requested","select"),re.emit("ui:transformControls-set-mode-requested","scale");break}},[b,Te,Ke]),qt(()=>{const te=Z.current;!Te||!te||te.eventHandler.eventBus.emit("ui:label-visibility-set-requested",g)},[g,Te]),qt(()=>{const te=Z.current;!Te||!te||te.eventHandler.eventBus.emit("ui:node-render-mode-set-requested",y)},[y,Te]),qt(()=>{const te=Z.current;!Te||!te||te.eventHandler.eventBus.emit("ui:lidar-toggled",x)},[x,Te]),qt(()=>{const te=Z.current;!Te||!te||te.eventHandler.eventBus.emit("ui:lidar3d-toggled",!!w)},[w,Te]),qt(()=>{const te=Z.current;!Te||!te||te.eventHandler.eventBus.emit("ui:map-boundary-visibility-set-requested",!!P)},[P,Te]),qt(()=>{const te=Z.current;!Te||!te||te.eventHandler.eventBus.emit("ui:map-points-height-clip-set-requested",T??null)},[Te,T]),qt(()=>{const te=Z.current;!Te||!te||typeof M!="number"||te.eventHandler.eventBus.emit("ui:map-point-size-set-requested",M)},[Te,M]),qt(()=>{const te=Z.current;!Te||!te||typeof A!="number"||te.eventHandler.eventBus.emit("ui:lidar-point-size-set-requested",A)},[A,Te]),qt(()=>{const te=Z.current;!Te||!te||!f||te.eventHandler.eventBus.emit("ui:mapping-data-received",f)},[f,Te]),qt(()=>{const te=Z.current;if(!Te||!te||!S||S.data.length===0)return;const re=j.current;re&&re.chunkNum===S.chunkNum&&re.chunkId===S.chunkId&&re.data===S.data||(j.current=S,te.eventHandler.eventBus.emit("ui:mapping-keyframe-received",S))},[S,Te]),C("div",{className:$t("WorldStudio","bg-bg-raised relative h-full w-full",r),children:[v("canvas",{ref:Ce,className:"h-full w-full"}),!Te&&v(bP,{})]})});EP.displayName="WorldStudio";const rg=r=>{switch(r.toLowerCase()){case"good":return"text-fg-success";case"busy":case"pause":return"text-fg-caution";case"fail":case"error":case"not ready":return"text-fg-danger";case"move":return"text-fg-information";case"none":return"text-fg-subtler";default:return"text-fg-subtler"}},AP=r=>{switch(r.toLowerCase()){case"near":return"text-fg-danger";case"far":return"text-fg-caution";case"vir":return"text-fg-information";default:return"text-fg-subtler"}},CP=(r,e)=>{switch(r.toLowerCase()){case"good":return e("move.amr.rightPanel.hud.status.good");case"busy":return e("move.amr.rightPanel.hud.status.busy");case"pause":return e("move.amr.rightPanel.hud.status.pause");case"fail":return e("move.amr.rightPanel.hud.status.fail");case"error":return e("move.amr.rightPanel.hud.status.error");case"not ready":return e("move.amr.rightPanel.hud.status.notReady");case"move":return e("move.amr.rightPanel.hud.status.move");case"success":return e("move.amr.rightPanel.hud.status.success");case"none":return e("move.amr.rightPanel.hud.status.none");default:return r}},{memo:PP}=await At("react"),RP=({localizationStatus:r="none",autoMove:e="none",obsState:t="none",poseX:n=0,poseY:i=0,poseZ:s=0,poseYaw:a=0,speed:o=0,velocityX:l=0,velocityY:c=0,velocityWz:d=0,roll:h=0,pitch:u=0,imuYaw:f=0,angularVelocity:m=0,inlierError:b=0,inlierRatio:p=0})=>{const{t:g}=tn();return C($,{className:"pointer-events-none absolute top-4 left-4 z-10 gap-2.5",children:[C(we,{className:"items-start gap-4",children:[C($,{className:"gap-0.5",children:[v("p",{className:"typo-body-2xs-semibold text-fg-subtler",children:g("move.amr.rightPanel.hud.localization")}),C(we,{className:"items-center gap-1 py-0.5",children:[v(ba,{className:`h-2.5 w-2.5 ${rg(r)}`}),v("span",{className:"typo-compact-2xs-semibold text-fg-default",children:CP(r,g)}),v("span",{className:"typo-compact-2xs-medium text-fg-subtler ml-2",children:g("move.amr.rightPanel.hud.inlierError")}),v("span",{className:"typo-compact-2xs-semibold text-fg-default",children:b.toFixed(3)}),v("span",{className:"typo-compact-2xs-medium text-fg-subtler ml-1",children:g("move.amr.rightPanel.hud.inlierRatio")}),v("span",{className:"typo-compact-2xs-semibold text-fg-default",children:p.toFixed(2)})]})]}),C($,{className:"gap-0.5",children:[v("p",{className:"typo-body-2xs-semibold text-fg-subtler",children:g("move.amr.rightPanel.hud.autoMove")}),C(we,{className:"items-center gap-1 py-0.5",children:[v(Wg,{className:`h-2.5 w-2.5 ${rg(e)}`}),v("span",{className:"typo-compact-2xs-semibold text-fg-default",children:e})]})]}),C($,{className:"gap-0.5",children:[v("p",{className:"typo-body-2xs-semibold text-fg-subtler",children:g("move.amr.rightPanel.hud.obstacleDetect")}),C(we,{className:"items-center gap-1 py-0.5",children:[v(jv,{className:`h-2.5 w-2.5 ${AP(t)}`}),v("span",{className:"typo-compact-2xs-semibold text-fg-default",children:t})]})]})]}),C($,{className:"gap-0.5",children:[v("p",{className:"typo-body-2xs-semibold text-fg-subtler",children:g("move.amr.rightPanel.hud.robotTransform")}),C($,{className:"gap-2",children:[C(we,{className:"items-center gap-3",children:[C($,{children:[v("p",{className:"typo-compact-2xs-medium text-fg-danger",children:"X"}),v("p",{className:"typo-compact-2xs-semibold text-fg-default",children:n.toFixed(3)})]}),C($,{children:[v("p",{className:"typo-compact-2xs-medium text-fg-success",children:"Y"}),v("p",{className:"typo-compact-2xs-semibold text-fg-default",children:i.toFixed(3)})]}),C($,{children:[v("p",{className:"typo-compact-2xs-medium text-fg-information",children:"Z"}),v("p",{className:"typo-compact-2xs-semibold text-fg-default",children:s.toFixed(3)})]}),C($,{children:[v("p",{className:"typo-compact-2xs-medium text-fg-information",children:"RZ"}),v("p",{className:"typo-compact-2xs-semibold text-fg-default",children:a.toFixed(3)})]}),C($,{children:[v("p",{className:"typo-compact-2xs-medium text-fg-subtle",children:g("move.amr.rightPanel.hud.speed")}),C("p",{className:"typo-compact-2xs-semibold text-fg-default",children:[o.toFixed(2)," m/s"]})]})]}),C(we,{className:"items-center gap-3",children:[C($,{children:[v("p",{className:"typo-compact-2xs-medium text-fg-subtle",children:"VX"}),v("p",{className:"typo-compact-2xs-semibold text-fg-default",children:l.toFixed(3)})]}),C($,{children:[v("p",{className:"typo-compact-2xs-medium text-fg-subtle",children:"VY"}),v("p",{className:"typo-compact-2xs-semibold text-fg-default",children:c.toFixed(3)})]}),C($,{children:[v("p",{className:"typo-compact-2xs-medium text-fg-subtle",children:"WZ"}),v("p",{className:"typo-compact-2xs-semibold text-fg-default",children:d.toFixed(3)})]})]})]})]}),C($,{className:"gap-0.5",children:[v("p",{className:"typo-body-2xs-semibold text-fg-subtler",children:g("move.amr.rightPanel.hud.imuSensor")}),C(we,{className:"items-center gap-3",children:[C($,{children:[v("p",{className:"typo-compact-2xs-medium text-fg-subtle",children:"Roll"}),C("p",{className:"typo-compact-2xs-semibold text-fg-default",children:[h>0?"+":"",h.toFixed(2),"°"]})]}),C($,{children:[v("p",{className:"typo-compact-2xs-medium text-fg-subtle",children:"Pitch"}),C("p",{className:"typo-compact-2xs-semibold text-fg-default",children:[u>0?"+":"",u.toFixed(2),"°"]})]}),C($,{children:[v("p",{className:"typo-compact-2xs-medium text-fg-subtle",children:"Yaw"}),C("p",{className:"typo-compact-2xs-semibold text-fg-default",children:[f>0?"+":"",f.toFixed(2),"°"]})]}),C($,{children:[v("p",{className:"typo-compact-2xs-medium text-fg-subtle uppercase",children:"ω"}),C("p",{className:"typo-compact-2xs-semibold text-fg-default",children:[m.toFixed(2)," deg/s"]})]})]})]})]})},QN=PP(RP),{useEffect:NP,useMemo:oh,useRef:DP,useState:eo}=await At("react"),JN=({open:r,close:e,onOpenChange:t,currentMap:n,onLoadMap:i,mapList:s})=>{const{t:a}=tn(),[o,l]=eo(1),[c,d]=eo(null),[h,u]=eo(""),[f,m]=eo(!1),[b,p]=eo(!1),g=DP(null),y=()=>{e?.(),t?.(!1)},x=O=>O>=1024*1024?`${(O/(1024*1024)).toFixed(1)} MB`:O>=1024?`${(O/1024).toFixed(1)} KB`:`${O} B`,w=oh(()=>(s?.list??[]).map((O,H)=>{const q=[...O.cloudInfo,...O.topoInfo].reduce((G,K)=>G+K.fileSize,0);return{id:`${H+1}`,name:O.mapName,modifiedDate:O.updatedAt,size:x(q)}}),[s?.list]),P=oh(()=>w.filter(O=>O.name.toLowerCase().includes(h.toLowerCase())),[w,h]),T=16,A=Math.max(1,Math.ceil(P.length/T)),M=Math.min(o,A),_=(M-1)*T,S=oh(()=>P.slice(_,_+T),[P,_,T]),R=O=>{const H=Math.max(1,Math.min(A,O));l(H)},k=()=>{if(!c)return;const O=w.find(H=>H.id===c);O&&(i(O.name),y())};return NP(()=>{if(!r){m(!1),p(!1);return}const O=g.current;if(!O)return;const H=O.querySelector('[data-slot="scroll-area-viewport"]');if(!H)return;const q=()=>{const G=H.scrollHeight>H.clientHeight+1,K=H.scrollTop+H.clientHeight>=H.scrollHeight-1,V=H.scrollTop>1;m(G&&V),p(G&&!K)};return q(),H.addEventListener("scroll",q),window.addEventListener("resize",q),()=>{H.removeEventListener("scroll",q),window.removeEventListener("resize",q)}},[S,r]),r?C($,{className:"fixed inset-0 z-50 items-center justify-center p-4",children:[v("button",{type:"button","aria-label":a("move.amr.rightPanel.map.loadDialog.closeBackdrop"),className:"bg-bg-dim absolute inset-0",onClick:y}),C($,{className:"bg-bg-overlay relative h-[560px] w-full max-w-4xl overflow-hidden rounded-lg p-4",children:[v($,{className:"shrink-0 gap-0.5 p-1",children:C(we,{className:"items-start justify-between",children:[v(we,{className:"items-center gap-2 pb-2",children:C($,{className:"gap-0.5",children:[v("p",{className:"typo-compact-lg-semibold text-fg-default",children:a("move.amr.rightPanel.map.loadDialog.title")}),v("p",{className:"typo-compact-xs-normal text-fg-subtler",children:a("move.amr.rightPanel.map.loadDialog.description")})]})}),v(Kn,{variant:"transparent",size:"2xs",icon:v(Ao,{}),className:"text-fg-subtle",onClick:y})]})}),C($,{className:"min-h-0 flex-1 gap-2",children:[v(we,{className:"bg-alt-1 items-center justify-between rounded-md px-2.5 py-2 [[data-theme='light']_&]:bg-white",children:C(we,{className:"items-center gap-1",children:[v("p",{className:"typo-compact-xs-semibold text-fg-success",children:a("move.amr.rightPanel.map.loadDialog.currentMap")}),v("p",{className:"typo-compact-xs-semibold text-fg-default",children:n||"-"})]})}),v($,{className:"shrink-0 gap-3",children:v(Rn,{type:"search",value:h,placeholder:a("move.amr.rightPanel.map.loadDialog.searchPlaceholder"),prefixIcon:v(Xv,{className:"text-fg-subtler"}),onChange:O=>{u(O.target.value),l(1)},className:"w-full"})}),C($,{ref:g,className:"relative min-h-0 flex-1 overflow-hidden",children:[f&&v("div",{className:"from-bg-overlay pointer-events-none absolute inset-x-0 top-0 z-10 h-4 bg-gradient-to-b to-transparent"}),v(Zv,{className:"h-full min-h-0 w-full overflow-hidden",viewportClassName:"h-full w-full",children:v("div",{className:"grid grid-cols-2 gap-2 pr-2",children:S.length>0?S.map(O=>{const H=c===O.id,q=O.name===n;return v("button",{type:"button",onClick:()=>d(O.id),className:`rounded-md border px-3 py-2.5 text-left transition-colors ${H?"border-fg-brand bg-fill-brand-subtlest":q?"border-fg-success bg-fill-success-subtlest":"bg-fill-inverse-subtle hover:bg-fill-inverse-subtler border-subtle [[data-theme='light']_&]:bg-white"}`,children:C(we,{className:"items-start",children:[C($,{className:"min-w-0 flex-1 justify-between gap-2",children:[v("p",{className:"typo-compact-sm-semibold text-fg-default truncate",children:O.name}),C($,{className:"gap-0.5",children:[C(we,{className:"gap-1",children:[C("p",{className:"typo-compact-xs-normal text-fg-subtler",children:[a("move.amr.rightPanel.map.loadDialog.modified"),":"]}),v("p",{className:"typo-compact-xs-normal text-fg-default",children:O.modifiedDate})]}),C(we,{className:"gap-1",children:[C("p",{className:"typo-compact-xs-normal text-fg-subtler",children:[a("move.amr.rightPanel.map.loadDialog.size"),":"]}),v("p",{className:"typo-compact-xs-normal text-fg-default",children:O.size})]})]})]}),H&&v(qv,{className:"text-fg-brand size-4"}),!H&&q&&v("p",{className:"typo-compact-2xs-semibold text-fg-success uppercase",children:a("move.amr.rightPanel.map.loadDialog.current")})]})},O.id)}):C($,{className:"col-span-2 items-center justify-center py-10",children:[v("p",{className:"typo-compact-sm-normal text-fg-subtler",children:a("move.amr.rightPanel.map.loadDialog.noMapsFound")}),v("p",{className:"typo-compact-2xs-normal text-fg-subtler",children:a("move.amr.rightPanel.map.loadDialog.tryDifferentSearch")})]})})}),b&&v("div",{className:"from-bg-overlay pointer-events-none absolute inset-x-0 bottom-0 h-4 bg-gradient-to-t to-transparent"})]})]}),C($,{className:"shrink-0 gap-3",children:[v(we,{className:"justify-center",children:v(Yv,{currPage:M,listSize:T,pageSize:5,totalCount:P.length,handlePageChange:R})}),C(we,{className:"items-center justify-end gap-2",children:[v(nt,{variant:"outlined",onClick:y,children:a("move.amr.rightPanel.common.cancel")}),v(nt,{variant:"brand",disabled:!c,onClick:k,children:a("move.amr.rightPanel.map.loadDialog.loadSelectedMap")})]})]})]})]}):null},{memo:LP}=await At("react"),IP=({mapName:r,onMapNameClick:e})=>{const t=!r,{theme:n}=Ea();return v("div",{onClick:()=>{e&&e()},className:`shadow-down-xs ${n==="light"?"bg-default":"bg-alt-1"} hover:bg-alt-2 absolute top-4 left-1/2 z-10 -translate-x-1/2 cursor-pointer rounded-md border px-4 py-2 backdrop-blur-sm transition-all duration-200 hover:scale-105 ${t?"border-default border-dashed":"border-default"}`,children:C("div",{className:"flex items-center gap-1 px-0.5",children:[v(Ry,{className:`h-4 w-4 ${t?"text-fg-subtle":"text-fg-default"}`}),v("span",{className:"text-fg-default typo-compact-xs-semibold",children:r}),t&&v("span",{className:"text-fg-subtle typo-compact-xs-medium",children:"Empty"})]})})},e2=LP(IP),{memo:kP}=await At("react"),OP=[{id:"select",icon:Wg,label:"Select",labelKey:"move.amr.leftToolBar.select",shortcut:"V"},{id:"target",icon:Cy,label:"Cursor",labelKey:"move.amr.leftToolBar.cursor",shortcut:"T"}],FP=[{id:"move",icon:Kv,label:"Move",labelKey:"move.amr.leftToolBar.move",shortcut:"G"},{id:"rotate",icon:jg,label:"Rotate",labelKey:"move.amr.leftToolBar.rotate",shortcut:"R"},{id:"scale",icon:$v,label:"Scale",labelKey:"move.amr.leftToolBar.scale",shortcut:"S"}],UP=[OP,FP],BP=({selectedTool:r,onToolChange:e,hasSelectedZone:t=!1,toolGroups:n,className:i})=>{const{theme:s}=Ea(),{t:a}=tn(),o=s==="light"?"bg-default":"bg-alt-1",l=n??UP;return v($,{className:$t("gap-2",i),children:l.map((c,d)=>v("div",{className:"overflow-visible rounded-lg bg-transparent",children:c.map(h=>{const u=r===h.id,f=t&&(h.id==="rotate"||h.id==="scale"),m=h.labelKey?a(h.labelKey):h.label,b=h.ariaLabelKey?a(h.ariaLabelKey):h.ariaLabel??m,p=h.shortcut?`${m} (${h.shortcut})`:m;return C("div",{className:"group relative",children:[v(Kn,{variant:"transparent",size:"xs2",onClick:()=>e(h.id),disabled:f,className:$t(o,"shadow-down-xs relative rounded-sm",!f&&"hover:!text-fg-default !text-fg-default",!f&&s==="light"?"hover:!bg-white":!f&&"hover:!bg-bg-alt-1"),icon:C(hi,{children:[u?v("span",{className:"bg-fill-subtler pointer-events-none absolute inset-1 rounded-md"}):null,v(h.icon,{className:$t("relative z-10 h-4 w-4",f?"!text-fg-disabled":"!text-fg-default")})]}),"aria-label":b}),v("p",{className:`typo-compact-xs2-normal ${o} text-fg-default border-border-subtle pointer-events-none invisible absolute top-1/2 left-full z-30 ml-2 -translate-y-1/2 rounded border px-2 py-1.5 whitespace-nowrap shadow-md group-hover:visible`,children:p})]},h.id)})},d))})},t2=kP(BP),{memo:zP}=await At("react"),lh={fullscreen:"right-2",menuExpanded:"right-33",menuCollapsed:"right-12"},HP=({isLive:r,pointCount:e,latency:t,fps:n,nodeCount:i,linkCount:s,onToggleRobotControl:a,onToggleCameraStreams:o,onToggleObstacleMap:l,showCameraStreams:c,showObstacleMap:d,showDebugPanel:h,onToggleDebugPanel:u,showRobotControlBtn:f,isFullscreen:m=!1,isMenuExpanded:b=!1})=>{const{theme:p}=Ea(),{t:g}=tn(),y=!f,x=m?lh.fullscreen:b?lh.menuExpanded:lh.menuCollapsed;return C("div",{className:"pointer-events-none absolute bottom-0 z-50 flex h-10 w-full items-center justify-between bg-transparent px-4 text-xs",children:[C("div",{className:"flex items-center gap-3",children:[C("div",{className:"flex items-center gap-1",children:[v("div",{className:`h-2 w-2 rounded-full ${r?"animate-pulse bg-green-500":"bg-gray-600"}`}),v("span",{className:"text-fg-default typo-compact-2xs-semibold",children:g(r?"move.amr.rightPanel.bottomBar.liveStream":"move.amr.rightPanel.bottomBar.offline")})]}),C("div",{className:"flex items-center gap-1",children:[C("span",{className:"text-fg-subtler typo-compact-2xs-normal",children:[g("move.amr.rightPanel.bottomBar.points"),":"]}),v("span",{className:"typo-compact-2xs-semibold text-fg-default",children:e.toLocaleString()})]}),C("div",{className:"flex items-center gap-1",children:[C("span",{className:"text-fg-subtler typo-compact-2xs-normal",children:[g("move.amr.rightPanel.bottomBar.nodes"),":"]}),v("span",{className:"typo-compact-2xs-semibold text-fg-default",children:i})]}),C("div",{className:"flex items-center gap-1",children:[C("span",{className:"text-fg-subtler typo-compact-2xs-normal",children:[g("move.amr.rightPanel.bottomBar.links"),":"]}),v("span",{className:"typo-compact-2xs-semibold text-fg-default",children:s})]})]}),C("div",{className:$t("pointer-events-auto absolute flex items-center gap-1.5",x),children:[v(nt,{size:"2xs",variant:"inverse",leadingIcon:v(Sh,{}),onClick:o,className:$t(!c&&(p==="light"?"bg-white hover:!bg-white":"bg-alt-1 hover:!bg-alt-2"),"shadow-down-xs gap-2"),children:g("move.amr.rightPanel.bottomBar.camera")}),v(nt,{size:"2xs",variant:"inverse",leadingIcon:v(Xg,{}),onClick:l,className:$t(!d&&(p==="light"?"bg-white hover:!bg-white":"bg-alt-1 hover:!bg-alt-2"),"shadow-down-xs gap-2"),children:g("move.amr.rightPanel.bottomBar.obstacleMap")}),v(nt,{size:"2xs",variant:"inverse",leadingIcon:v(Qv,{}),onClick:a,className:$t(!y&&(p==="light"?"bg-white hover:!bg-white":"bg-alt-1 hover:!bg-alt-2"),"shadow-down-xs gap-2"),children:g("move.amr.rightPanel.bottomBar.controlPanel")}),v(nt,{size:"2xs",variant:"inverse",leadingIcon:v(Jv,{}),onClick:u,className:$t(!h&&(p==="light"?"bg-white hover:!bg-white":"bg-alt-1 hover:!bg-alt-2"),"shadow-down-xs gap-2"),children:g("move.amr.rightPanel.menu.debug")})]})]})},n2=zP(HP),{useEffect:GP,useRef:VP,useState:bi}=await At("react"),WP=["button","point","manual"],ag={KeyW:"forward",KeyA:"left",KeyS:"backward",KeyD:"right",KeyQ:"rotateLeft",KeyE:"rotateRight"},og=r=>{if(!(r instanceof HTMLElement))return!1;const e=r.tagName.toLowerCase();return r.isContentEditable||e==="input"||e==="textarea"||e==="select"},i2=({robotPose:r,handleButtonJog:e,onClose:t,onMoveTarget:n,onMoveLinear:i,linearSpeed:s,setLinearSpeed:a,rotationSpeed:o,setRotationSpeed:l,className:c})=>{const{t:d}=tn(),[h,u]=bi("button"),f=VP(null),[m,b]=bi("0.5"),[p,g]=bi("0.5"),[y,x]=bi("45"),[w,P]=bi("45"),[T,A]=bi("0.0"),[M,_]=bi("0.0"),[S,R]=bi("0.0"),[k,O]=bi("0.0"),[H,q]=bi("x"),[G,K]=bi("1.0"),[V,Y]=bi("0.5"),[le,se]=bi(80),ge=()=>{n({goalPose:{x:Number.parseFloat(T)||0,y:Number.parseFloat(M)||0,rz:Number.parseFloat(k)||0},method:"pp",preset:1})},de=()=>{const X=Number.parseFloat(G)||0,ee=Number.parseFloat(V)||0;i({axis:H,target:X,speed:ee})};return GP(()=>{if(typeof window>"u")return;const X=()=>{f.current!==null&&(f.current=null,e("stop"))},ee=Z=>{if(h!=="button"||Z.repeat||og(Z.target))return;const ue=ag[Z.code];ue&&(Z.preventDefault(),f.current!==ue&&(f.current=ue,e(ue)))},ie=Z=>{if(h!=="button"||og(Z.target))return;const ue=ag[Z.code];!ue||f.current!==ue||(Z.preventDefault(),X())};return window.addEventListener("keydown",ee),window.addEventListener("keyup",ie),window.addEventListener("blur",X),()=>{window.removeEventListener("keydown",ee),window.removeEventListener("keyup",ie),window.removeEventListener("blur",X),X()}},[h,e]),C($,{className:$t("border-subtle shadow-down-lg pointer-events-auto w-[39.375rem] overflow-hidden rounded-lg border",c),style:{backgroundColor:`color-mix(in srgb, var(--color-bg-alt-1) ${Math.max(0,Math.min(100,le))}%, transparent)`},children:[C(we,{className:"border-subtle items-center justify-between gap-4 border-b px-3",children:[v(Zg,{className:"min-h-0 flex-1",variant:"line",value:h,onValueChange:X=>{WP.includes(X)&&u(X)},children:C(qg,{children:[v(vr,{value:"button",children:d("move.amr.rightPanel.controlPanel.tab.button")}),v(vr,{value:"point",children:d("move.amr.rightPanel.controlPanel.tab.point")}),v(vr,{value:"manual",children:d("move.amr.rightPanel.controlPanel.tab.linear")})]})}),C(we,{className:"h-8 shrink-0 items-center gap-2",children:[v("p",{className:"typo-compact-xs2-normal text-fg-subtle",children:d("move.amr.rightPanel.controlPanel.transparency")}),C("p",{className:"typo-compact-xs2-semibold text-fg-default w-8 text-right",children:[le,"%"]}),v(Rc,{value:[le],min:0,max:100,step:1,onValueChange:X=>{const ee=X[0];se(ee)},className:"w-24"}),v(Kn,{icon:v(Ao,{}),variant:"transparent",size:"2xs",onClick:t})]})]}),C($,{className:"p-3 pb-3.5",children:[h==="button"&&C($,{className:"gap-2",children:[v("p",{className:"typo-compact-xs2-normal text-fg-information",children:d("move.amr.rightPanel.controlPanel.button.description")}),C(we,{className:"items-end gap-4",children:[C($,{className:"min-w-0 flex-1 gap-2.5",children:[C(we,{className:"items-start gap-3",children:[C("p",{className:"typo-compact-xs2-medium text-fg-subtler shrink-0",children:[d("move.amr.rightPanel.controlPanel.linearMotion.line1"),v("br",{}),d("move.amr.rightPanel.controlPanel.linearMotion.line2")]}),C("div",{className:"grid flex-1 grid-cols-3 gap-1",children:[C($,{className:"min-w-0 gap-1.5",children:[v("p",{className:"typo-compact-xs-semibold text-fg-default truncate",children:d("move.amr.rightPanel.controlPanel.speedMs")}),v(Rn,{size:"xs2",type:"number",value:s,className:"!w-full",onChange:X=>{a(Number.parseFloat(X.target.value)||0)}})]}),C($,{className:"min-w-0 gap-1.5",children:[v("p",{className:"typo-compact-xs-semibold text-fg-default truncate",children:d("move.amr.rightPanel.controlPanel.accelMs2")}),v(Rn,{size:"xs2",type:"number",value:m,className:"!w-full",disabled:!0,onChange:X=>{b(X.target.value)}})]}),C($,{className:"min-w-0 gap-1.5",children:[v("p",{className:"typo-compact-xs-semibold text-fg-default truncate",children:d("move.amr.rightPanel.controlPanel.decelMs2")}),v(Rn,{size:"xs2",type:"number",value:p,className:"!w-full",disabled:!0,onChange:X=>{g(X.target.value)}})]})]})]}),C(we,{className:"items-start gap-3",children:[C("p",{className:"typo-compact-xs2-medium text-fg-subtler shrink-0",children:[d("move.amr.rightPanel.controlPanel.angularMotion.line1"),v("br",{}),d("move.amr.rightPanel.controlPanel.angularMotion.line2")]}),C("div",{className:"grid flex-1 grid-cols-3 gap-1",children:[C($,{className:"min-w-0 gap-1.5",children:[v("p",{className:"typo-compact-xs-semibold text-fg-default truncate",children:d("move.amr.rightPanel.controlPanel.speedDegS")}),v(Rn,{size:"xs2",type:"number",value:o,className:"!w-full",onChange:X=>{l(Number.parseFloat(X.target.value)||0)}})]}),C($,{className:"min-w-0 gap-1.5",children:[v("p",{className:"typo-compact-xs-semibold text-fg-default truncate",children:d("move.amr.rightPanel.controlPanel.accelDegS2")}),v(Rn,{size:"xs2",type:"number",value:y,className:"!w-full",disabled:!0,onChange:X=>{x(X.target.value)}})]}),C($,{className:"min-w-0 gap-1.5",children:[v("p",{className:"typo-compact-xs-semibold text-fg-default truncate",children:d("move.amr.rightPanel.controlPanel.decelDegS2")}),v(Rn,{size:"xs2",type:"number",value:w,className:"!w-full",disabled:!0,onChange:X=>{P(X.target.value)}})]})]})]})]}),C($,{className:"w-[8.25rem] shrink-0 items-center gap-1.5",children:[C("div",{className:"grid grid-cols-[2.5rem_2.5rem_2.5rem] grid-rows-2 gap-1.5",children:[v("div",{className:"size-10"}),v(Kn,{variant:"soft",icon:v(Hg,{}),className:"border-subtle size-10 border-t",onMouseDown:()=>e("forward"),onMouseUp:()=>e("stop"),onMouseLeave:()=>e("stop")}),v("div",{className:"size-10"}),v(Kn,{variant:"soft",icon:v(Gg,{}),className:"border-subtle size-10 border-t",onMouseDown:()=>e("left"),onMouseUp:()=>e("stop"),onMouseLeave:()=>e("stop")}),v(Kn,{variant:"soft",icon:v(Vg,{}),className:"border-subtle size-10 border-t",onMouseDown:()=>e("backward"),onMouseUp:()=>e("stop"),onMouseLeave:()=>e("stop")}),v(Kn,{variant:"soft",icon:v(Pu,{}),className:"border-subtle size-10 border-t",onMouseDown:()=>e("right"),onMouseUp:()=>e("stop"),onMouseLeave:()=>e("stop")})]}),C("div",{className:"grid w-full grid-cols-2 gap-1.5",children:[v(nt,{leadingIcon:v(ey,{}),size:"xs",variant:"soft",className:"typo-compact-xs-semibold h-7 w-full",onMouseDown:()=>e("rotateLeft"),onMouseUp:()=>e("stop"),onMouseLeave:()=>e("stop"),children:d("move.amr.rightPanel.controlPanel.left")}),v(nt,{leadingIcon:v(ty,{}),size:"xs",variant:"soft",className:"typo-compact-xs-semibold h-7 w-full",onMouseDown:()=>e("rotateRight"),onMouseUp:()=>e("stop"),onMouseLeave:()=>e("stop"),children:d("move.amr.rightPanel.controlPanel.right")})]})]})]})]}),h==="point"&&C($,{className:"justify-between gap-2",children:[v("p",{className:"typo-compact-xs2-normal text-fg-information",children:d("move.amr.rightPanel.controlPanel.point.description")}),C($,{className:"gap-3",children:[C("div",{className:"grid grid-cols-4 gap-2",children:[C($,{className:"min-w-0 gap-1.5",children:[C(we,{className:"gap-1",children:[v("p",{className:"typo-compact-xs-medium text-fg-danger",children:"X"}),v("p",{className:"typo-compact-xs-medium text-fg-subtle",children:"(m)"})]}),v(Rn,{size:"xs2",type:"number",className:"!w-full",value:T,onChange:X=>{A(X.target.value)}})]}),C($,{className:"min-w-0 gap-1.5",children:[C(we,{className:"gap-1",children:[v("p",{className:"typo-compact-xs-medium text-fg-success",children:"Y"}),v("p",{className:"typo-compact-xs-medium text-fg-subtle",children:"(m)"})]}),v(Rn,{size:"xs2",type:"number",className:"!w-full",value:M,onChange:X=>{_(X.target.value)}})]}),C($,{className:"min-w-0 gap-1.5",children:[C(we,{className:"gap-1",children:[v("p",{className:"typo-compact-xs-medium text-fg-brand",children:"Z"}),v("p",{className:"typo-compact-xs-medium text-fg-subtle",children:"(m)"})]}),v(Rn,{size:"xs2",type:"number",className:"!w-full",value:S,onChange:X=>{R(X.target.value)}})]}),C($,{className:"min-w-0 gap-1.5",children:[C(we,{className:"gap-1",children:[v("p",{className:"typo-compact-xs-medium text-fg-debug",children:"Theta"}),v("p",{className:"typo-compact-xs-medium text-fg-subtle",children:"(°)"})]}),v(Rn,{size:"xs2",type:"number",className:"!w-full",value:k,onChange:X=>{O(X.target.value)}})]})]}),C(we,{className:"items-center justify-between gap-3",children:[C(we,{className:"min-w-0 items-center gap-0.5",children:[v(Cu,{className:"text-fg-subtle size-3.5 shrink-0"}),v("p",{className:"typo-compact-xs2-normal text-fg-subtle min-w-0 truncate",children:d("move.amr.rightPanel.controlPanel.currentPose",{x:r.x.toFixed(2),y:r.y.toFixed(2),yaw:r.yaw.toFixed(1)})})]}),v(nt,{size:"xs2",variant:"brand",className:"h-8 w-32 !px-3",onClick:ge,children:d("move.amr.rightPanel.controlPanel.moveToPoint")})]})]})]}),h==="manual"&&C($,{className:"justify-between gap-2",children:[v("p",{className:"typo-compact-xs2-normal text-fg-information",children:d("move.amr.rightPanel.controlPanel.linear.description")}),C($,{className:"gap-3",children:[C("div",{className:"grid grid-cols-3 gap-2",children:[C($,{className:"min-w-0 gap-1.5",children:[v("p",{className:"typo-compact-xs-semibold text-fg-default",children:d("move.amr.rightPanel.controlPanel.axis")}),C("div",{className:"grid grid-cols-2 gap-1.5",children:[v(nt,{variant:H==="x"?"brand":"soft",size:"xs2",className:"h-8 w-full !px-3",onClick:()=>{q("x")},children:"X"}),v(nt,{variant:H==="y"?"brand":"soft",size:"xs2",className:"h-8 w-full !px-3",onClick:()=>{q("y")},children:"Y"})]})]}),C($,{className:"min-w-0 gap-1.5",children:[v("p",{className:"typo-compact-xs-semibold text-fg-default",children:d("move.amr.rightPanel.controlPanel.targetM")}),v(Rn,{size:"xs2",type:"number",className:"!w-full",value:G,onChange:X=>{K(X.target.value)}})]}),C($,{className:"min-w-0 gap-1.5",children:[v("p",{className:"typo-compact-xs-semibold text-fg-default",children:d("move.amr.rightPanel.controlPanel.speedMs")}),v(Rn,{size:"xs2",type:"number",className:"!w-full",value:V,onChange:X=>{Y(X.target.value)}})]})]}),v(we,{className:"justify-end",children:v(nt,{size:"xs2",variant:"brand",className:"h-8 w-32 !px-3",onClick:de,children:d("move.amr.rightPanel.controlPanel.executeMove")})})]})]})]})]})},{memo:jP}=await At("react"),XP=(r,e)=>{switch(r){case"left":return`translate(calc(-100% - ${e}px), -50%)`;case"top":return`translate(-50%, calc(-100% - ${e}px))`;case"bottom":return`translate(-50%, ${e}px)`;case"right":default:return`translate(${e}px, -50%)`}},lg=r=>typeof r!="number"||Number.isNaN(r)?"-":r.toFixed(3),qP=r=>typeof r!="number"||Number.isNaN(r)?"-":`${(r*180/Math.PI).toFixed(3)}°`,ZP=({visible:r=!0,x:e,y:t,currentX:n,currentY:i,currentRz:s,placement:a="right",offset:o=65,nodeName:l,onEdit:c,onDelete:d,onMove:h,className:u=""})=>r?C($,{className:`pointer-events-none absolute z-30 max-w-[calc(100vw-32px)] min-w-[220px] rounded-md bg-[#2b2b2f]/65 px-4 py-3 ${u}`,style:{left:e,top:t,transform:XP(a,o)},children:[C(we,{className:"items-center justify-between gap-3",children:[C(we,{className:"min-w-0 items-center",children:[v("p",{className:"typo-compact-sm2-semibold text-fg-subtler mr-3",children:"Name"}),v("span",{className:"typo-compact-sm-semibold text-fg-default truncate",children:l})]}),c&&v(Kn,{className:"pointer-events-auto",variant:"transparent",size:"2xs","aria-label":"Edit node",icon:v(Ru,{}),onClick:c})]}),C(we,{className:"flex flex-wrap gap-x-7",children:[C("p",{className:"whitespace-nowrap",children:[v("span",{className:"text-fg-danger typo-compact-sm2-semibold mr-3",children:"X"}),v("span",{className:"typo-compact-sm-semibold text-fg-default",children:lg(n)})]}),C("p",{className:"whitespace-nowrap",children:[v("span",{className:"text-fg-success typo-compact-sm2-semibold mr-3",children:"Y"}),v("span",{className:"typo-compact-sm-semibold text-fg-default",children:lg(i)})]}),C("p",{className:"whitespace-nowrap",children:[v("span",{className:"typo-compact-sm2-semibold text-fg-information mr-3",children:"RZ"}),v("span",{className:"typo-compact-sm-semibold text-fg-default",children:qP(s)})]})]}),(d||h)&&C(we,{className:"pointer-events-auto mt-3 gap-2",children:[d&&v(nt,{variant:"danger",size:"sm",onClick:d,children:"Delete"}),h&&v(nt,{variant:"soft",size:"sm",onClick:h,children:"Move To Node"})]})]}):null,s2=jP(ZP),{memo:YP}=await At("react"),KP=(r,e)=>{switch(r){case"left":return`translate(calc(-100% - ${e}px), -50%)`;case"top":return`translate(-50%, calc(-100% - ${e}px))`;case"bottom":return`translate(-50%, ${e}px)`;case"right":default:return`translate(${e}px, -50%)`}},$P=r=>typeof r!="number"||Number.isNaN(r)?"-":r.toFixed(2),QP=({visible:r=!0,x:e,y:t,items:n,activeItemId:i,onSelectItem:s,onEdit:a,onDelete:o,placement:l="right",offset:c=65,className:d=""})=>{if(!r||n.length===0)return null;const h=n.find(u=>u.id===i)??n[0]??null;return h?C($,{className:`pointer-events-none absolute z-30 max-w-[calc(100vw-32px)] min-w-[260px] rounded-md bg-[#2b2b2f]/65 px-4 py-3 ${d}`,style:{left:e,top:t,transform:KP(l,c)},children:[n.length>1&&v(we,{className:"pointer-events-auto mb-2 gap-1.5",children:n.map((u,f)=>{const m=u.id===h.id;return v("button",{type:"button",className:`typo-compact-xs-semibold rounded-md px-2 py-1 transition-colors ${m?"bg-fill-brand text-fg-white":"bg-fill-control-surface text-fg-default hover:bg-fill-subtle"}`,onClick:()=>{s?.(u.id)},children:`Link ${f+1}`},u.id)})}),C(we,{className:"items-center justify-between gap-3",children:[C(we,{className:"min-w-0 items-center",children:[v("p",{className:"typo-compact-sm2-semibold text-fg-subtler mr-3",children:"Link"}),v("span",{className:"typo-compact-sm-semibold text-fg-default truncate",children:h.title})]}),a&&v(Kn,{className:"pointer-events-auto",variant:"transparent",size:"2xs","aria-label":"Edit link",icon:v(Ru,{}),onClick:a})]}),C(we,{className:"flex flex-wrap gap-x-7",children:[C("p",{className:"whitespace-nowrap",children:[v("span",{className:"typo-compact-sm2-semibold text-fg-warning mr-3",children:"DIR"}),v("span",{className:"typo-compact-sm-semibold text-fg-default",children:h.dir})]}),C("p",{className:"whitespace-nowrap",children:[v("span",{className:"typo-compact-sm2-semibold text-fg-brand mr-3",children:"METHOD"}),v("span",{className:"typo-compact-sm-semibold text-fg-default",children:h.method})]}),C("p",{className:"whitespace-nowrap",children:[v("span",{className:"typo-compact-sm2-semibold text-fg-success mr-3",children:"SPEED"}),v("span",{className:"typo-compact-sm-semibold text-fg-default",children:$P(h.speed)})]})]}),o&&v(we,{className:"pointer-events-auto mt-3 gap-2",children:v(nt,{variant:"danger",size:"sm",onClick:o,children:"Delete"})})]}):null},r2=YP(QP),{memo:JP}=await At("react"),eR=(r,e)=>{switch(r){case"left":return`translate(calc(-100% - ${e}px), -50%)`;case"top":return`translate(-50%, calc(-100% - ${e}px))`;case"bottom":return`translate(-50%, ${e}px)`;case"right":default:return`translate(${e}px, -50%)`}},tR=({visible:r=!0,x:e,y:t,items:n,activeItemId:i,onSelectItem:s,onEdit:a,onDelete:o,placement:l="right",offset:c=65,className:d=""})=>{if(!r||n.length===0)return null;const h=n.find(u=>u.id===i)??n[0]??null;return h?C($,{className:`pointer-events-none absolute z-30 max-w-[calc(100vw-32px)] min-w-[260px] rounded-md bg-[#2b2b2f]/65 px-4 py-3 ${d}`,style:{left:e,top:t,transform:eR(l,c)},children:[n.length>1&&v(we,{className:"pointer-events-auto mb-2 gap-1.5",children:n.map((u,f)=>{const m=u.id===h.id;return v("button",{type:"button",className:`typo-compact-xs-semibold rounded-md px-2 py-1 transition-colors ${m?"bg-fill-brand text-fg-white":"bg-fill-control-surface text-fg-default hover:bg-fill-subtle"}`,onClick:()=>{s?.(u.id)},children:`Zone ${f+1}`},u.id)})}),C(we,{className:"items-center justify-between gap-3",children:[C(we,{className:"min-w-0 items-center",children:[v("p",{className:"typo-compact-sm2-semibold text-fg-subtler mr-3",children:"Zone"}),v("span",{className:"typo-compact-sm-semibold text-fg-default truncate",children:h.title})]}),a&&v(Kn,{className:"pointer-events-auto",variant:"transparent",size:"2xs","aria-label":"Edit zone",icon:v(Ru,{}),onClick:a})]}),C(we,{className:"flex flex-wrap gap-x-7",children:[C("p",{className:"whitespace-nowrap",children:[v("span",{className:"typo-compact-sm2-semibold text-fg-warning mr-3",children:"TYPE"}),v("span",{className:"typo-compact-sm-semibold text-fg-default",children:h.type})]}),C("p",{className:"whitespace-nowrap",children:[v("span",{className:"typo-compact-sm2-semibold text-fg-brand mr-3",children:"POINTS"}),v("span",{className:"typo-compact-sm-semibold text-fg-default",children:h.pointCount})]})]}),o&&v(we,{className:"pointer-events-auto mt-3 gap-2",children:v(nt,{variant:"danger",size:"sm",onClick:o,children:"Delete"})})]}):null},a2=JP(tR),{memo:nR,useCallback:ch,useEffect:cg,useRef:dr,useState:$l}=await At("react"),Ql={width:630,height:320},Jl={width:420,height:180},dg=24,hg=(r,e,t)=>Math.min(Math.max(r,e),t),iR=({cameras:r,onClose:e,onQualityChange:t})=>{const{t:n}=tn(),[i,s]=$l({x:0,y:0}),[a,o]=$l(Ql),[l,c]=$l(null),[d,h]=$l(80),u=dr(null),f=dr({x:0,y:0}),m=dr(Ql),b=dr(!1),p=dr(!1),g=dr({mouseX:0,mouseY:0,panelX:0,panelY:0}),y=dr({mouseX:0,mouseY:0,panelX:0,panelY:0,width:Ql.width,height:Ql.height}),x=r.find(A=>A.id===l&&A.status==="live"&&A.streamUrl),w=ch(A=>{A.preventDefault(),!p.current&&(b.current=!0,document.body.style.cursor="grabbing",g.current={mouseX:A.clientX,mouseY:A.clientY,panelX:f.current.x,panelY:f.current.y})},[]),P=ch(A=>{A.preventDefault(),A.stopPropagation();const M=u.current?.getBoundingClientRect();p.current=!0,document.body.style.cursor="se-resize",document.body.style.userSelect="none",y.current={mouseX:A.clientX,mouseY:A.clientY,panelX:f.current.x,panelY:f.current.y,width:M?.width??m.current.width,height:M?.height??m.current.height}},[]),T=ch(A=>{c(A)},[]);return cg(()=>{const A=_=>{if(b.current){const S=g.current.panelX+(_.clientX-g.current.mouseX),R=g.current.panelY+(_.clientY-g.current.mouseY);f.current={x:S,y:R},u.current&&(u.current.style.transform=`translate(${S}px, ${R}px)`)}if(p.current){const S=hg(y.current.width+(_.clientX-y.current.mouseX),Jl.width,Math.max(Jl.width,window.innerWidth-dg)),R=hg(y.current.height+(_.clientY-y.current.mouseY),Jl.height,Math.max(Jl.height,window.innerHeight-dg)),k={width:S,height:R},O={x:y.current.panelX+(S-y.current.width),y:y.current.panelY+(R-y.current.height)};m.current=k,f.current=O,o(k),s(O)}},M=()=>{const _=b.current,S=p.current;_&&(b.current=!1,document.body.style.cursor="",s({...f.current})),S&&(p.current=!1,document.body.style.cursor="",document.body.style.userSelect="")};return window.addEventListener("mousemove",A),window.addEventListener("mouseup",M),()=>{window.removeEventListener("mousemove",A),window.removeEventListener("mouseup",M),document.body.style.cursor="",document.body.style.userSelect=""}},[]),cg(()=>{l&&!r.some(A=>A.id===l)&&c(null)},[r,l]),C("div",{className:"pointer-events-auto",children:[v(ny,{className:"bg-overlay border-subtle [&_[data-slot='dialog-close']]:text-fg-subtle [&_[data-slot='dialog-header']>h2]:text-fg-default [&_[data-slot='dialog-header']>h2]:typo-title-01-bold block !max-w-[70vw] overflow-hidden rounded-lg border-1 !border-solid p-0 shadow-[0px_0px_2px_0px_rgba(9,9,11,0.20)] [&_[data-slot='dialog-close']]:top-3 [&_[data-slot='dialog-close']]:right-3 [&_[data-slot='dialog-header']]:gap-0.5 [&_[data-slot='dialog-header']]:pt-3 [&_[data-slot='dialog-header']]:pr-16 [&_[data-slot='dialog-header']]:pb-2 [&_[data-slot='dialog-header']]:pl-4 [&_[data-slot='dialog-header']]:text-left",open:!!x,onOpenChange:A=>{A||c(null)},header:{title:x?.name??n("move.amr.rightPanel.cameraPanel.title")},children:x&&v("div",{className:"!bg-alt-2 flex h-full flex-col justify-between",children:v("div",{className:"bg-base-black h-[calc(var(--vh,1vh)*70)] overflow-hidden",children:v(_f,{className:"bg-base-black h-full w-full overflow-hidden [&_video]:object-cover",url:x.streamUrl??"",label:x.name,lebelPosition:"top-left",initStatus:!0,disconnectedMessage:n("move.amr.rightPanel.cameraPanel.disconnected"),loadingMessage:n("move.amr.rightPanel.cameraPanel.connecting")})})})}),C("div",{ref:u,className:"border-subtle shadow-down-lg relative flex flex-col overflow-hidden rounded-lg border",style:{backgroundColor:`color-mix(in srgb, var(--color-bg-alt-1) ${Math.max(0,Math.min(100,d))}%, transparent)`,transform:`translate(${i.x}px, ${i.y}px)`,width:a.width,height:a.height},children:[C("div",{className:"border-subtle flex shrink-0 cursor-grab items-center justify-start gap-0.5 border-b py-1 pr-2 pl-3 select-none",onMouseDown:w,children:[C("div",{className:"typo-compact-xs2-semibold flex flex-1 items-center justify-start gap-1",children:[v("span",{className:"text-fg-default",children:n("move.amr.rightPanel.cameraPanel.title")}),v("span",{className:"text-fg-brand",children:r.length})]}),C("div",{className:"flex h-8 shrink-0 cursor-default items-center gap-2",onMouseDown:A=>{A.stopPropagation()},onPointerDown:A=>{A.stopPropagation()},children:[v("p",{className:"typo-compact-xs2-normal text-fg-subtle",children:n("move.amr.rightPanel.controlPanel.transparency")}),C("p",{className:"typo-compact-xs2-semibold text-fg-default w-8 text-right",children:[d,"%"]}),v(Rc,{value:[d],min:0,max:100,step:1,onValueChange:A=>{h(A[0])},className:"w-24"})]}),v(Kn,{icon:v(Ao,{}),variant:"transparent",size:"2xs",onClick:e})]}),r.length===0?v("div",{className:"min-h-0 flex-1 px-3 pt-2 pb-3.5",children:v(go,{className:"h-full rounded-md [&_[data-slot='empty-view-section']]:h-full",type:"icon",icon:v(Sh,{className:"text-fg-subtlest size-5"}),message:n("move.amr.rightPanel.cameraPanel.empty")})}):v("div",{className:"[&::-webkit-scrollbar-thumb]:bg-border-subtle min-h-0 flex-1 overflow-x-auto overflow-y-hidden px-3 pt-2 pb-4.5 [scrollbar-color:var(--color-border-subtle)_transparent] [scrollbar-width:thin] [&::-webkit-scrollbar]:h-1.5 [&::-webkit-scrollbar]:w-1.5 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-track]:bg-transparent",children:v("div",{className:"flex h-full w-max min-w-full items-start gap-2",children:r.map(A=>C("div",{className:"inline-flex h-full shrink-0 flex-col gap-1.5",children:[C("div",{className:"flex items-center gap-1 px-0.5",children:[v("div",{className:"flex size-3 items-center justify-center",children:v(yi,{color:A.status==="live"?"green":"red"})}),v("span",{className:"text-fg-default typo-compact-xs2-semibold pr-2",children:A.name}),v("div",{onClick:M=>M.stopPropagation(),children:v(ca,{className:"min-w-20",size:"xs2",value:A.quality,handleChange:M=>{typeof M=="string"&&t?.(A.camId,M)},children:A.qualityOptions.map(M=>v(Pi,{value:M,children:M},M))})}),v("span",{className:"text-fg-subtler typo-compact-xs-normal ml-auto",children:A.resolution})]}),A.status==="live"&&A.streamUrl?v("div",{className:"bg-base-black border-subtle h-52 w-96 cursor-pointer overflow-hidden rounded-md border",onClick:M=>{M.stopPropagation(),T(A.id)},children:v(_f,{className:"bg-base-black h-full w-full overflow-hidden [&_video]:object-cover",url:A.streamUrl??"",label:A.name,lebelPosition:"top-left",initStatus:!0,disconnectedMessage:n("move.amr.rightPanel.cameraPanel.disconnected"),loadingMessage:n("move.amr.rightPanel.cameraPanel.connecting")})}):C("div",{className:"outline-border-subtle flex h-52 w-96 flex-col items-center justify-center gap-1 rounded-md outline outline-1 outline-offset-[-1px]",children:[v(Sh,{className:"text-fg-subtlest size-5"}),v("span",{className:"text-fg-subtler typo-compact-xs-normal",children:n("move.amr.rightPanel.cameraPanel.disconnected")})]})]},A.id))})}),v("div",{"aria-label":"Resize camera streams panel",className:"absolute right-0 bottom-0 z-10 flex size-5 cursor-se-resize items-end justify-end p-1",role:"separator",onMouseDown:P,children:v("span",{className:"border-fg-subtlest block size-2.5 border-r-2 border-b-2 opacity-70"})})]})]})},o2=nR(iR),{memo:sR,useEffect:to,useMemo:ug,useRef:dh,useState:ec}=await At("react"),rR=["static","dynamic","virtual","collision"],aR={static:[148,163,184,160],dynamic:[59,130,246,190],virtual:[168,85,247,180],collision:[239,68,68,210]},oR=320,hh=.5,uh=4,fg=.25,Cc=(r,e,t)=>Math.max(e,Math.min(t,r)),pg=(r,e,t)=>{if(e<=1)return{x:0,y:0};const n=Math.max(0,(r.canvasWidth*e-r.canvasWidth)/2),i=Math.max(0,(r.canvasHeight*e-r.canvasHeight)/2);return{x:Cc(t.x,-n,n),y:Cc(t.y,-i,i)}},mg=(r,e)=>(r%e+e)%e,lR=(()=>{const r=new ArrayBuffer(4),e=new Uint32Array(r),t=new Uint8Array(r);return e[0]=168496141,t[0]===13})(),cR=(r,e,t,n)=>lR?n<<24|t<<16|e<<8|r:r<<24|e<<16|t<<8|n,dR=(r,e)=>{const t=Math.max(r,1),n=Math.max(e,1),i=Math.max(t,n),s=Math.max(1,Math.floor(oR/i)),a=t*s,o=n*s;return{safeWidth:t,safeHeight:n,scale:s,canvasWidth:a,canvasHeight:o,centerX:a/2,centerY:o/2}},gg=(r,e)=>{r.width!==e.canvasWidth&&(r.width=e.canvasWidth),r.height!==e.canvasHeight&&(r.height=e.canvasHeight)},hR=(r,e,t)=>{r.clearRect(0,0,e.canvasWidth,e.canvasHeight),r.fillStyle="#0f172a",r.fillRect(0,0,e.canvasWidth,e.canvasHeight),r.fillStyle="rgba(255,255,255,0.72)",r.font="500 14px sans-serif",r.textAlign="center",r.textBaseline="middle",r.fillText(t,e.canvasWidth/2,e.canvasHeight/2)},uR=(r,e,t,n)=>{r.clearRect(0,0,e.canvasWidth,e.canvasHeight),r.fillStyle="#0f172a",r.fillRect(0,0,e.canvasWidth,e.canvasHeight),r.save(),r.strokeStyle="rgba(255,255,255,0.06)",r.lineWidth=1;const s=e.scale*t*8,a=mg(e.centerX+n.x,s),o=mg(e.centerY+n.y,s);for(let l=a;l<=e.canvasWidth;l+=s)r.beginPath(),r.moveTo(l+.5,0),r.lineTo(l+.5,e.canvasHeight),r.stroke();for(let l=o;l<=e.canvasHeight;l+=s)r.beginPath(),r.moveTo(0,l+.5),r.lineTo(e.canvasWidth,l+.5),r.stroke();r.restore()},fR=async(r,e,t,n)=>{try{const i=await createImageBitmap(new Blob([new Uint8Array(r)],{type:"image/png"})),s=document.createElement("canvas");s.width=e,s.height=t;const a=s.getContext("2d");if(!a)return i.close(),null;a.imageSmoothingEnabled=!1,a.drawImage(i,0,0,e,t),i.close();const[o,l,c,d]=n,h=a.getImageData(0,0,e,t),u=h.data,f=cR(o,l,c,d),m=new Uint32Array(u.buffer);for(let b=0;b<m.length;b+=1){if(!(u[b*4]>0)){m[b]=0;continue}m[b]=f}return a.putImageData(h,0,0),s}catch{return null}},pR=(r,e,t,n,i)=>{const s=t.canvasWidth*n,a=t.canvasHeight*n,o=t.centerX-s/2+i.x,l=t.centerY-a/2+i.y;r.drawImage(e,o,l,s,a)},mR=(r,e,t,n,i,s)=>{if(!(t>0))return;const a=n.scale*i,o=d=>n.centerX+s.x+d/t*a,l=d=>n.centerY+s.y-d/t*a,c=(d,h,u,f,m,b)=>{const p=o(d),g=o(h),y=l(f),x=l(u);r.fillStyle=m,r.strokeStyle=b,r.lineWidth=1,r.fillRect(p,y,g-p,x-y),r.strokeRect(p,y,g-p,x-y)};c(e.obsBoxMinX-e.stopMarginX-e.slowMarginX,e.obsBoxMaxX+e.stopMarginX+e.slowMarginX,e.obsBoxMinY-e.stopMarginY-e.slowMarginY,e.obsBoxMaxY+e.stopMarginY+e.slowMarginY,"rgba(245, 158, 11, 0.12)","rgba(245, 158, 11, 0.7)"),c(e.obsBoxMinX-e.stopMarginX,e.obsBoxMaxX+e.stopMarginX,e.obsBoxMinY-e.stopMarginY,e.obsBoxMaxY+e.stopMarginY,"rgba(239, 68, 68, 0.14)","rgba(239, 68, 68, 0.85)"),c(e.obsBoxMinX,e.obsBoxMaxX,e.obsBoxMinY,e.obsBoxMaxY,"rgba(34, 197, 94, 0.16)","rgba(34, 197, 94, 0.9)")},gR=(r,e,t,n,i,s)=>{if(!(t>0))return;const a=n.scale*i,o=x=>n.centerX+s.x+x/t*a,l=x=>n.centerY+s.y-x/t*a,c=o(e.obsBoxMinX),d=o(e.obsBoxMaxX),h=l(e.obsBoxMaxY),u=l(e.obsBoxMinY),f=d-c,m=u-h,b=(c+d)/2,p=(h+u)/2,g=Math.max(f*1.1,14),y=Math.max(Math.min(f,m)*.7,10);r.save(),r.lineWidth=1,r.strokeStyle="rgba(59,130,246,0.95)",r.fillStyle="rgba(59,130,246,0.95)",r.beginPath(),r.moveTo(b,p),r.lineTo(b+g,p),r.stroke(),r.beginPath(),r.moveTo(b+g,p),r.lineTo(b+g-5,p-2.5),r.lineTo(b+g-5,p+2.5),r.closePath(),r.fill(),r.strokeStyle="rgba(34,197,94,0.95)",r.fillStyle="rgba(34,197,94,0.95)",r.beginPath(),r.moveTo(b,p),r.lineTo(b,p-y),r.stroke(),r.beginPath(),r.moveTo(b,p-y),r.lineTo(b-2.5,p-y+5),r.lineTo(b+2.5,p-y+5),r.closePath(),r.fill(),r.restore()},bR=(r,e)=>{r.save(),r.strokeStyle="rgba(255,255,255,0.14)",r.lineWidth=1,r.strokeRect(.5,.5,e.canvasWidth-1,e.canvasHeight-1),r.translate(.5,.5),r.strokeStyle="rgba(255,255,255,0.18)",r.beginPath(),r.moveTo(e.canvasWidth/2,0),r.lineTo(e.canvasWidth/2,e.canvasHeight),r.moveTo(0,e.canvasHeight/2),r.lineTo(e.canvasWidth,e.canvasHeight/2),r.stroke(),r.restore()},vR=({layers:r,width:e,height:t,gridSize:n,safety:i,loading:s=!1,onClose:a,className:o})=>{const{t:l}=tn(),c=dh(null),d=dh(null),h=dh(null),[u,f]=ec(1),[m,b]=ec(80),[p,g]=ec({x:0,y:0}),[y,x]=ec([]),w=r.length,P=ug(()=>r.map(k=>k.name).join(", "),[r]),T=ug(()=>dR(e,t),[t,e]),A=e>0&&t>0?`${e} x ${t}`:"-",M=n>0?l("move.amr.obstacleMap.gridSizePerPixel",{value:n.toFixed(3)}):"-",_=`${Math.round(u*100)}%`,S=u>1,R=s?l("move.amr.obstacleMap.status.waitingForStream"):e>0&&t>0?w>0?l("move.amr.obstacleMap.status.live"):l("move.amr.obstacleMap.status.noActiveLayers"):l("move.amr.obstacleMap.status.idle");return to(()=>{g(k=>pg(T,u,k))},[T,u]),to(()=>{let k=!1;if(e<=0||t<=0||r.length===0){x([]);return}const O=rR.map(H=>({layerName:H,layer:r.find(q=>q.name===H)})).filter(H=>!!H.layer&&H.layer.data.length>0);return(async()=>{const H=await Promise.all(O.map(async({layerName:q,layer:G})=>{const K=await fR(G.data,e,t,aR[q]);return{layerName:q,tintedLayerCanvas:K}}));k||x(H.filter(q=>q.tintedLayerCanvas!==null))})(),()=>{k=!0}},[t,r,e]),to(()=>{const k=c.current,O=d.current;k&&gg(k,T),O&&gg(O,T)},[T]),to(()=>{const k=c.current;if(!k)return;const O=k.getContext("2d");if(!O)return;O.imageSmoothingEnabled=!1;const H=document.createElement("canvas");H.width=T.canvasWidth,H.height=T.canvasHeight;const q=H.getContext("2d");if(q){if(q.imageSmoothingEnabled=!1,e<=0||t<=0){hR(q,T,l("move.amr.obstacleMap.waitingForData")),O.clearRect(0,0,T.canvasWidth,T.canvasHeight),O.drawImage(H,0,0);return}uR(q,T,u,p);for(const{tintedLayerCanvas:G}of y)pR(q,G,T,u,p);O.clearRect(0,0,T.canvasWidth,T.canvasHeight),O.drawImage(H,0,0)}},[y,t,T,p,l,e,u]),to(()=>{const k=d.current;if(!k)return;const O=k.getContext("2d");O&&(O.imageSmoothingEnabled=!1,O.clearRect(0,0,T.canvasWidth,T.canvasHeight),!(e<=0||t<=0)&&(mR(O,i,n,T,u,p),gR(O,i,n,T,u,p),bR(O,T)))},[n,t,e,i,T,p,u]),C($,{className:$t("border-subtle shadow-down-lg pointer-events-auto w-[25rem] overflow-hidden rounded-lg border",o),style:{backgroundColor:`color-mix(in srgb, var(--color-bg-alt-1) ${Math.max(0,Math.min(100,m))}%, transparent)`},children:[C(we,{className:"border-subtle items-center justify-between gap-4 border-b px-3 py-2.5",children:[C(we,{className:"min-w-0 items-center gap-2",children:[v("div",{className:"bg-fill-information-subtle flex size-8 shrink-0 items-center justify-center rounded-md",children:v(Xg,{className:"text-fg-information size-4"})}),C($,{className:"min-w-0 gap-0.5",children:[v("p",{className:"typo-compact-xs-semibold text-fg-default truncate",children:l("move.amr.obstacleMap.title")}),v("p",{className:"typo-compact-xs2-normal text-fg-subtle truncate",children:l("move.amr.obstacleMap.description")})]})]}),C(we,{className:"h-8 shrink-0 items-center gap-2",children:[v("p",{className:"typo-compact-xs2-normal text-fg-subtle",children:l("move.amr.rightPanel.controlPanel.transparency")}),C("p",{className:"typo-compact-xs2-semibold text-fg-default w-8 text-right",children:[m,"%"]}),v(Rc,{value:[m],min:0,max:100,step:1,onValueChange:k=>{b(k[0])},className:"w-24"}),v(Kn,{icon:v(Ao,{}),variant:"transparent",size:"2xs",onClick:a})]})]}),C($,{className:"gap-3 p-3",children:[C("div",{className:$t("bg-bg-default border-subtle relative aspect-square overflow-hidden rounded-md border",S?"cursor-grab touch-none active:cursor-grabbing":"cursor-default"),onPointerDown:k=>{!S||k.target instanceof Element&&k.target.closest("button")||(h.current={pointerId:k.pointerId,startX:k.clientX,startY:k.clientY,startPanX:p.x,startPanY:p.y},k.currentTarget.setPointerCapture(k.pointerId))},onPointerMove:k=>{const O=h.current;!O||O.pointerId!==k.pointerId||g(pg(T,u,{x:O.startPanX+k.clientX-O.startX,y:O.startPanY+k.clientY-O.startY}))},onPointerUp:k=>{h.current?.pointerId===k.pointerId&&(h.current=null,k.currentTarget.releasePointerCapture(k.pointerId))},onPointerCancel:k=>{h.current?.pointerId===k.pointerId&&(h.current=null,k.currentTarget.releasePointerCapture(k.pointerId))},children:[C(we,{className:"absolute top-3 right-3 z-10 gap-1.5 rounded-md bg-black/45 p-1 backdrop-blur-sm",children:[v(Kn,{icon:v(jg,{}),variant:"transparent",size:"2xs",disabled:u===1&&p.x===0&&p.y===0,onClick:()=>{f(1),g({x:0,y:0})}}),v(Kn,{icon:v(iy,{}),variant:"transparent",size:"2xs",disabled:u<=hh,onClick:()=>{f(k=>{const O=Cc(k-fg,hh,uh);return O<=1&&g({x:0,y:0}),O})}}),v(nt,{size:"2xs",variant:"soft",disabled:!0,className:"min-w-14 justify-center",children:_}),v(Kn,{icon:v(sy,{}),variant:"transparent",size:"2xs",disabled:u>=uh,onClick:()=>{f(k=>Cc(k+fg,hh,uh))}})]}),v("canvas",{ref:c,className:"absolute inset-0 h-full w-full [image-rendering:pixelated]"}),v("canvas",{ref:d,className:"pointer-events-none absolute inset-0 h-full w-full [image-rendering:pixelated]"}),v("div",{className:"absolute inset-x-3 bottom-3",children:C(we,{className:"justify-between rounded-md bg-black/45 px-2.5 py-2 backdrop-blur-sm",children:[C($,{className:"gap-0.5",children:[v("p",{className:"typo-compact-xs2-normal text-white/70",children:l("move.amr.obstacleMap.statusLabel")}),v("p",{className:"typo-compact-xs2-semibold text-white",children:R})]}),C($,{className:"items-end gap-0.5",children:[v("p",{className:"typo-compact-xs2-normal text-white/70",children:l("move.amr.obstacleMap.gridLabel")}),v("p",{className:"typo-compact-xs2-semibold text-white",children:A})]})]})})]}),C(we,{className:"flex-wrap gap-2",children:[v(nt,{size:"2xs",variant:"soft",disabled:!0,children:M}),v(nt,{size:"2xs",variant:"soft",disabled:!0,children:l("move.amr.obstacleMap.layerCount",{count:w})}),P?v(nt,{size:"2xs",variant:"soft",disabled:!0,children:P}):null]})]})]})},l2=sR(vR),{useEffect:no,useMemo:fh,useRef:bg,useState:es}=await At("react"),yR=[{key:"measMismatch",labelKey:"move.amr.rightPanel.pdu.safety.measMismatch",robotStateKey:"sfMeasMismatch"},{key:"overSpeed",labelKey:"move.amr.rightPanel.pdu.safety.overSpeed",robotStateKey:"sfOverSpeed"},{key:"obstacle",labelKey:"move.amr.rightPanel.pdu.safety.obstacle",robotStateKey:"sfObsDetect"},{key:"fieldMismatch",labelKey:"move.amr.rightPanel.pdu.safety.fieldMismatch",robotStateKey:"sfFieldMismatch"},{key:"interlock",labelKey:"move.amr.rightPanel.pdu.safety.interlock",robotStateKey:"sfInterlock"},{key:"bumper",labelKey:"move.amr.rightPanel.pdu.safety.bumper",robotStateKey:"sfBumperDetect"}],xR=[{key:"running",label:"Running",bit:0,normalWhenActive:!0},{key:"mode",label:"Mode",bit:1},{key:"jam",label:"Jam",bit:2},{key:"current",label:"Current",bit:3},{key:"big",label:"Big",bit:4},{key:"input",label:"Input",bit:5},{key:"position",label:"Position",bit:6},{key:"collision",label:"Collision",bit:7}],_R=r=>typeof r=="boolean"?Number(r):r??0,vg=(r,e)=>(r&1<<e)!==0,yg=(r,e)=>typeof r!="number"||!Number.isFinite(r)?"-":`${r}${e}`,Tv=r=>{if(r?.length)return r.filter(e=>Number.isInteger(e.pin)&&e.pin>=0).map(e=>({pin:e.pin,value:!!e.value,rawValue:e.rawValue})).sort((e,t)=>e.pin-t.pin)},wR=r=>{const e=Tv(r.bits);if(e)return{...r,bits:e}},xg=(r,e)=>{if(!r)return"";if(typeof r=="string")return r;const t=e.toLowerCase().split(/[-_]/)[0],n=r[t];return typeof n=="string"&&n.length>0?n:typeof r.en=="string"&&r.en.length>0?r.en:Object.values(r).find(i=>typeof i=="string"&&i.length>0)??""},SR=r=>{const e=[],t=[{key:"mcu0-din",label:"MCU0 DIN",mcu:0,kind:"din",bits:r?.mcu0Din},{key:"mcu1-din",label:"MCU1 DIN",mcu:1,kind:"din",bits:r?.mcu1Din},{key:"mcu0-dio",label:"MCU0 DIO",mcu:0,kind:"dio",bits:r?.mcu0Dio},{key:"mcu1-dio",label:"MCU1 DIO",mcu:1,kind:"dio",bits:r?.mcu1Dio}];for(const n of t){const i=Tv(n.bits);i&&e.push({key:n.key,label:n.label,mcu:n.mcu,kind:n.kind,bits:i})}return e},tc=(r,e,t)=>r.find(n=>n.mcu===e&&n.kind===t),_g=r=>r?.map(e=>e.value),Ev=r=>r?`0x${r.reduce((t,n)=>n.value?t|1<<n.pin:t,0).toString(16).toUpperCase().padStart(2,"0")}`:"-",nc=r=>r?r.map(e=>({...e})):void 0,wg=r=>r?.map(e=>e.pin).join(",")??"",Sg=({label:r,onClick:e})=>v(nt,{variant:"outlined",className:"!typo-compact-xs-normal text-fg-subtle",size:"2xs",onClick:e,children:r}),Av=({pin:r,active:e,disabled:t=!1,onClick:n})=>{const i=$t("flex h-8 min-w-0 flex-col items-center justify-center rounded border border-transparent text-center text-white shadow-[inset_0_0_0_1px_rgba(255,255,255,0.12),0_1px_2px_rgba(0,0,0,0.35)]",e?"bg-[#12833B]":"bg-[#E5252A]",n&&!t?"hover:brightness-110":"cursor-default");return n?v("button",{type:"button",className:i,disabled:t,onClick:n,children:v("span",{className:"typo-compact-2xs-semibold leading-none",children:r})}):v("div",{className:i,children:v("span",{className:"typo-compact-2xs-semibold leading-none",children:r})})},MR=({label:r,bits:e})=>C($,{className:"gap-1",children:[C("div",{className:"flex items-center justify-between gap-2",children:[v("span",{className:"typo-compact-xs-normal text-fg-subtle",children:r}),v("span",{className:"typo-compact-xs-semibold text-fg-subtle font-mono",children:Ev(e)})]}),e?v("div",{className:"grid w-full gap-1",style:{gridTemplateColumns:`repeat(${e.length}, minmax(0, 1fr))`},children:e.map(t=>v(Av,{pin:t.pin,active:t.value},t.pin))}):v("span",{className:"typo-compact-xs-normal text-fg-subtler",children:"-"})]}),TR=({label:r,bits:e,disabled:t,onToggle:n})=>C($,{className:"gap-1",children:[C("div",{className:"flex items-center justify-between gap-2",children:[v("span",{className:"typo-compact-xs-normal text-fg-subtle",children:r}),v("span",{className:"typo-compact-xs-semibold text-fg-subtle font-mono",children:Ev(e)})]}),e?v("div",{className:"grid w-full gap-1",style:{gridTemplateColumns:`repeat(${e.length}, minmax(0, 1fr))`},children:e.map((i,s)=>v(Av,{pin:i.pin,active:i.value,disabled:t,onClick:()=>n(s)},i.pin))}):v("span",{className:"typo-compact-xs-normal text-fg-subtler",children:"-"})]}),c2=({amrStatus:r,setMotorLocked:e,onSystemStatusChange:t,onClearSafetyRecovery:n,onLidarFieldSave:i,onOssdDetectChange:s,safetyIo:a,safetyIoLoading:o=!1,onSetSafetyIo:l,onMotorConnectSuccess:c,onLidarSaveSuccess:d,onMotorConnectError:h,onLidarSaveError:u,onSafetyIoSetError:f})=>{const{currentLanguage:m,t:b}=tn(),p=r?.motor??[],g=p.length>0,y=g&&p.every(xe=>!!xe.status),x=g?!y:!1,w=!!r?.robotState?.emo,P=r?.chargeState?.charge??"",T=r?.chargeState?.dockId??"",A=r?.chargeState?.dockResult??"",M=!!r?.chargeState?.dock,_=P.trim()==="charging",S=!!r?.robotState?.sfOperationalStop,R=r?.robotState?.lidarField??null,k=bg(null);no(()=>{k.current===null&&R!=null&&(k.current=R)},[R]);const[O,H]=es(""),[q,G]=es(!1),[K,V]=es(null);no(()=>{V(null)},[R]);const Y=q?O:String(K??k.current??R??0),le=!!r?.robotState?.detectMode,[se,ge]=es(null);no(()=>{ge(null)},[le]);const[de,X]=es(null),[ee,ie]=es(!1),[Z,ue]=es(!1),oe=de??x;no(()=>{X(null)},[x]);const be=fh(()=>a?.rows?.length?a.rows.map(wR).filter(xe=>!!xe):SR(a),[a]),Ce=fh(()=>({mcu0Din:tc(be,0,"din")?.bits,mcu1Din:tc(be,1,"din")?.bits,mcu0Dio:tc(be,0,"dio")?.bits,mcu1Dio:tc(be,1,"dio")?.bits}),[be]),je=fh(()=>be.filter(xe=>xe.kind==="dio"&&(xe.mcu===0||xe.mcu===1)),[be]),Fe=be.length>0,[j,Ke]=es({}),[Ue,Te]=es(!1),[Se,et]=es(!1),Be=`${wg(Ce.mcu0Dio)}|${wg(Ce.mcu1Dio)}`,N=bg(null);no(()=>{!Ce.mcu0Dio||!Ce.mcu1Dio||N.current!==Be&&(N.current=Be,Ke({mcu0Din:nc(Ce.mcu0Dio),mcu1Din:nc(Ce.mcu1Dio)}),Te(!1))},[Be,Ce.mcu0Dio,Ce.mcu1Dio]);const E=j.mcu0Din,W=j.mcu1Din,ae=!!l&&!!Ce.mcu0Dio&&!!Ce.mcu1Dio&&!!E&&!!W,ve=ae&&Ue,ce=!ae||o||Se,Oe=(xe,Le)=>{if(ce||!E||!W)return;const ct=nc(E),rt=nc(W);!ct||!rt||(xe===0?ct[Le]={...ct[Le],value:!ct[Le].value}:rt[Le]={...rt[Le],value:!rt[Le].value},Ke({mcu0Din:ct,mcu1Din:rt}),Te(!0))},Pe=xe=>{if(xe===0)return E;if(xe===1)return W},Ve=xe=>xg(xe.label,m),te=async()=>{if(!(!l||!E||!W||!ve)){et(!0);try{await l({mcu0Din:_g(E)??[],mcu1Din:_g(W)??[]}),Te(!1)}catch{f?.()}finally{et(!1)}}},re=async()=>{if(e){ie(!0);try{await e(!1),X(!1),t?.({motorLock:!1}),c?.()}catch{h?.()}finally{ie(!1)}}},De=()=>{G(!1),H("")},Ye=async()=>{const xe=Number(O);if(Number.isNaN(xe))G(!1);else{V(xe),G(!1);try{await i?.(xe),d?.()}catch{V(null),u?.()}}};return C("div",{className:"h-full min-h-0",children:[v("div",{className:"border-subtler border-b p-3",children:C("div",{className:"flex items-center justify-between",children:[v("span",{className:"typo-compact-sm2-semibold text-fg-default",children:b("move.amr.rightPanel.pdu.emergencyStop")}),C("div",{className:"flex items-center gap-2",children:[v(yi,{color:w?"red":"green"}),v("span",{className:"typo-compact-xs-semibold text-fg-default",children:b(w?"move.amr.rightPanel.common.triggered":"move.amr.rightPanel.common.normal")})]})]})}),C($,{className:"border-subtler gap-1.5 border-b p-3",children:[C("button",{type:"button",className:"flex w-full items-center justify-between gap-2 text-left","aria-expanded":Z,onClick:()=>ue(xe=>!xe),children:[v("span",{className:"flex min-w-0 items-center",children:v("span",{className:"typo-compact-sm2-semibold text-fg-default truncate",children:b("move.amr.rightPanel.pdu.motorStatus")})}),C("div",{className:"flex shrink-0 items-center gap-2",children:[v(yi,{color:oe?"red":"green"}),v("span",{className:"typo-compact-xs-semibold text-fg-default",children:b(oe?"move.amr.rightPanel.common.disconnected":"move.amr.rightPanel.common.connected")}),Z?v(ry,{className:"text-fg-subtle size-3.5 shrink-0"}):v(ay,{className:"text-fg-subtle size-3.5 shrink-0"})]})]}),C("div",{className:"flex items-center justify-between",children:[v("span",{className:"typo-compact-xs2-normal text-fg-subtler",children:b("move.amr.rightPanel.pdu.motor")}),v(wr,{checked:!oe,disabled:!oe||ee,onCheckedChange:xe=>{xe&&re()}})]}),Z&&v($,{className:"gap-2 pt-1",children:p.length===0?v("span",{className:"typo-compact-xs-normal text-fg-disabled",children:"No motor data"}):p.map((xe,Le)=>{const ct=_R(xe.status),rt=vg(ct,0),Rt=!!xe.connection;return C($,{className:"border-subtle bg-alt-1 gap-2 rounded border p-2",children:[C("div",{className:"flex items-center justify-between",children:[C("span",{className:"typo-compact-sm2-semibold text-fg-default",children:["Motor ",Le+1]}),C("div",{className:"flex items-center gap-2",children:[v(yi,{color:Rt?"green":"red"}),v("span",{className:"typo-compact-xs-semibold text-fg-default",children:Rt?"Connected":"Disconnected"})]})]}),C($,{className:"bg-raised gap-2 rounded p-2",children:[C("div",{className:"flex items-center justify-between",children:[v("span",{className:"typo-compact-xs-normal text-fg-subtler",children:"Running"}),C("div",{className:"flex items-center gap-2",children:[v(yi,{color:rt?"green":"red"}),v("span",{className:"typo-compact-xs-semibold text-fg-default",children:rt?"On":"Off"})]})]}),C("div",{className:"flex items-center justify-between",children:[v("span",{className:"typo-compact-xs-normal text-fg-subtler",children:"Temperature"}),v("span",{className:"typo-compact-xs-semibold text-fg-default font-mono",children:yg(xe.temp,"°C")})]}),C("div",{className:"flex items-center justify-between",children:[v("span",{className:"typo-compact-xs-normal text-fg-subtler",children:"Current"}),v("span",{className:"typo-compact-xs-semibold text-fg-default font-mono",children:yg(xe.current,"A")})]})]}),C($,{className:"gap-1",children:[v("span",{className:"typo-compact-xs-normal text-fg-subtler",children:"Status Flags"}),v("div",{className:"grid grid-cols-2 gap-1.5",children:xR.map(Q=>{const Ge=vg(ct,Q.bit),ye=Ge?Q.normalWhenActive?"green":"red":"gray";return C("div",{className:"bg-fill-disabled flex items-center justify-between gap-2 rounded px-2 py-1",children:[v("span",{className:"typo-compact-2xs-normal text-fg-subtle truncate",children:Q.label}),v(oy,{type:"soft",color:ye,children:Ge?"On":"Off"})]},Q.key)})})]})]},Le)})})]}),C("div",{className:"border-subtler flex flex-col gap-1.5 border-b p-3",children:[v("span",{className:"typo-compact-sm2-semibold text-fg-default",children:b("move.amr.rightPanel.pdu.chargeContact")}),C("div",{className:"space-y-2",children:[C("div",{className:"flex items-center justify-between",children:[v("span",{className:"typo-compact-xs-normal text-fg-subtler",children:b("move.amr.rightPanel.pdu.charge")}),C("div",{className:"flex items-center gap-2",children:[v(yi,{color:_?"green":"red"}),v("span",{className:"typo-compact-xs-semibold text-fg-default font-mono",children:b(_?"move.amr.rightPanel.common.true":"move.amr.rightPanel.common.false")})]})]}),C("div",{className:"flex items-center justify-between",children:[v("span",{className:"typo-compact-xs-normal text-fg-subtler",children:b("move.amr.rightPanel.pdu.dock")}),C("div",{className:"flex items-center gap-2",children:[v(yi,{color:M?"green":"red"}),v("span",{className:"typo-compact-xs-semibold text-fg-default font-mono",children:b(M?"move.amr.rightPanel.common.true":"move.amr.rightPanel.common.false")})]})]}),C("div",{className:"flex items-center justify-between",children:[v("span",{className:"typo-compact-xs-normal text-fg-subtler",children:b("move.amr.rightPanel.pdu.dockResult")}),v("span",{className:"typo-compact-xs-normal text-fg-subtle font-mono",children:A||"-"})]}),C("div",{className:"flex items-center justify-between",children:[v("span",{className:"typo-compact-xs-normal text-fg-subtler",children:b("move.amr.rightPanel.pdu.dockId")}),v("span",{className:"typo-compact-xs-normal text-fg-subtle font-mono",children:T||"-"})]})]})]}),C($,{className:"border-subtler gap-1.5 border-b p-3",children:[v("span",{className:"typo-compact-sm2-semibold text-fg-default",children:b("move.amr.rightPanel.pdu.safetyRecovery")}),v("div",{className:"space-y-2",children:yR.map(({key:xe,labelKey:Le,robotStateKey:ct})=>{const rt=!!r?.robotState?.[ct];return C("div",{className:"flex items-center justify-between",children:[v("span",{className:"typo-compact-xs2-normal text-fg-subtler",children:b(Le)}),C("div",{className:"flex items-center gap-3",children:[C("div",{className:"flex items-center gap-2",children:[v(yi,{color:rt?"red":"green"}),v("span",{className:"typo-compact-xs-semibold text-fg-default w-7 text-right",children:b(rt?"move.amr.rightPanel.common.trig":"move.amr.rightPanel.common.none")})]}),v(Sg,{label:b("move.amr.rightPanel.common.clear"),onClick:()=>n?.(xe)})]})]},Le)})})]}),C($,{className:"border-subtler gap-1.5 border-b p-3",children:[v("span",{className:"typo-compact-sm2-semibold text-fg-default",children:b("move.amr.rightPanel.pdu.opMode")}),v("div",{className:"space-y-2",children:C("div",{className:"flex items-center justify-between",children:[v("span",{className:"typo-compact-xs2-normal text-fg-subtler",children:b("move.amr.rightPanel.pdu.opModeRestoration")}),C("div",{className:"flex items-center gap-2",children:[v(yi,{color:S?"red":"green"}),v("span",{className:"typo-compact-xs-semibold text-fg-default w-7 text-right",children:b(S?"move.amr.rightPanel.common.trig":"move.amr.rightPanel.common.none")}),v(Sg,{label:b("move.amr.rightPanel.common.clear"),onClick:()=>n?.("operationStop")})]})]})})]}),Fe&&C($,{className:"border-subtler gap-3 border-b p-3",children:[C("div",{className:"flex items-center justify-between gap-2",children:[v("span",{className:"typo-compact-sm2-semibold text-fg-default",children:"Safety I/O"}),o&&v("span",{className:"typo-compact-2xs-normal text-fg-subtle",children:b("move.amr.rightPanel.pdu.safetyIo.pending")})]}),C($,{className:"gap-2",children:[v("div",{className:"flex items-center justify-between gap-2",children:v("span",{className:"typo-compact-xs-semibold text-fg-default",children:b("move.amr.rightPanel.pdu.safetyIo.read")})}),v($,{className:"gap-2",children:be.map(xe=>v(MR,{label:xg(xe.label,m),bits:xe.bits},xe.key))})]}),je.length>0&&C($,{className:"gap-2",children:[C("div",{className:"flex items-center justify-between gap-2",children:[v("span",{className:"typo-compact-xs-semibold text-fg-default",children:b("move.amr.rightPanel.pdu.safetyIo.outputControl")}),v("div",{className:"flex items-center gap-1",children:v(nt,{variant:"brand",size:"2xs",disabled:!ve||ce,onClick:te,children:b("move.amr.rightPanel.pdu.safetyIo.apply")})})]}),v($,{className:"gap-2",children:je.map(xe=>v(TR,{label:Ve(xe),bits:Pe(xe.mcu),disabled:ce,onToggle:Le=>{(xe.mcu===0||xe.mcu===1)&&Oe(xe.mcu,Le)}},`${xe.key}-control`))})]})]}),C($,{className:"border-subtler gap-1.5 border-b p-3",children:[C("div",{className:"flex items-center justify-between",children:[v("span",{className:"typo-compact-sm2-semibold text-fg-default",children:b("move.amr.rightPanel.pdu.lidarField")}),q&&C("div",{className:"flex items-center gap-1",children:[v(nt,{variant:"outlined",size:"2xs",onClick:De,children:b("move.amr.rightPanel.common.reset")}),v(nt,{variant:"brand",size:"2xs",onClick:Ye,children:b("move.amr.rightPanel.common.save")})]})]}),v(Nn,{className:"w-full",type:"number",size:"sm",value:Y,handleChange:xe=>{H(xe!==void 0?String(xe):""),G(!0)}})]}),C($,{className:"border-subtler gap-1.5 border-b p-3",children:[v("span",{className:"typo-compact-sm2-semibold text-fg-default",children:"OSSD"}),C("div",{className:"flex items-center justify-between",children:[v("span",{className:"typo-compact-xs2-normal text-fg-subtler",children:b("move.amr.rightPanel.pdu.detect")}),v(wr,{checked:se??le,onCheckedChange:xe=>{const Le=se??le;ge(xe),s?.(xe)?.catch(()=>ge(Le))}})]})]})]})},{useMemo:ER}=await At("react"),AR=({className:r,currentNode:e,targetNode:t,moveStatus:n})=>{const{t:i}=tn(),s=ER(()=>n==="move"||n==="vir"||n==="moving",[n]);return C("div",{className:$t("AMRNodeFromTo","relative pl-7",r),children:[C($,{className:$t("gap-2","[&>div]:gap-0.5","[&>div>span]:text-fg-subtle [&>div>span]:typo-compact-2xs-medium","[&>div>div]:text-fg-default [&>div>div]:typo-compact-sm-semibold"),children:[C($,{children:[v("span",{children:i("move.amr.rightPanel.task.currentNode")}),v("div",{className:"text-fg-subtle truncate",children:e||"-"})]}),C($,{children:[v("span",{children:i("move.amr.rightPanel.task.targetNode")}),v("div",{className:"text-fg-subtle truncate",children:t||"-"})]})]}),v(CR,{className:"w-7",isMoving:s,children:v("span",{className:"moving-dot"})})]})},CR=Nc("div",{target:"e184amb70"})(`position:absolute;top:50%;transform:translateY(-50%);left:0;z-index:1;height:85%;&::before,&::after{content:"";position:absolute;left:50%;width:1px;height:50%;transform:translateX(-50%);}&::before{top:0;background:linear-gradient(
|
|
4743
4743
|
180deg,
|
|
4744
4744
|
color-mix(in srgb, var(--color-fg-default) 2%, transparent) 0%,
|
|
4745
4745
|
color-mix(in srgb, var(--color-fg-default) 16%, transparent) 35%,
|
|
@@ -4749,6 +4749,6 @@ PERFORMANCE OF THIS SOFTWARE.
|
|
|
4749
4749
|
color-mix(in srgb, var(--color-fg-default) 58%, transparent) 0%,
|
|
4750
4750
|
color-mix(in srgb, var(--color-fg-default) 16%, transparent) 65%,
|
|
4751
4751
|
color-mix(in srgb, var(--color-fg-default) 2%, transparent) 100%
|
|
4752
|
-
);}.moving-dot{position:absolute;left:50%;top:0.5rem;width:0.5rem;height:0.5rem;transform:translateX(-50%);border-radius:9999px;background:var(--color-fg-default);box-shadow:0 0 0.625rem color-mix(in srgb, var(--color-fg-default) 95%, transparent),0 0 1.25rem color-mix(in srgb, var(--color-fg-information) 70%, transparent);animation:`,r=>r.isMoving?"drop-down 4s ease-in-out infinite, sparkle 0.65s ease-in-out infinite":"none",";}@keyframes drop-down{0%{top:0.25rem;opacity:0.2;}5%{opacity:1;}90%{opacity:0.9;}100%{top:calc(100% - 0.75rem);opacity:0.1;}}@keyframes sparkle{0%{filter:brightness(0.9);}50%{filter:brightness(1.35);}100%{filter:brightness(0.9);}}"),Cv=({className:r,items:e,latestIndex:t=0,latestIndexes:n,compact:i=!1,showResult:s=!i})=>{const{t:a}=tn();return e.length?v(PR,{className:$t("gap-2",r),children:e.map((o,l)=>{const c=n?n.includes(l):l===t,d=l===0,h=l===e.length-1;return C("div",{className:"relative flex items-start gap-3 rounded-md px-2 py-1.5",children:[v(RR,{isFirst:d,isLast:h,children:v(NR,{isLatest:c})}),C($,{className:"min-w-0 flex-1 gap-0.5",children:[C("div",{className:"flex min-h-5 items-center justify-between gap-1.5",children:[v("span",{className:$t("typo-compact-xs2-semibold truncate font-mono",c?"text-fg-information":"text-fg-default"),children:o.message||"-"}),c?v("span",{className:"bg-fill-information typo-compact-2xs-semibold text-fg-inverse rounded-lg px-1.5 py-0.5",children:a("move.amr.rightPanel.history.latest")}):null]}),!i&&C(hi,{children:[C("div",{className:"flex items-center justify-between gap-2",children:[v("span",{className:"typo-compact-2xs-medium text-fg-subtler",children:a("move.amr.rightPanel.history.time")}),v("span",{className:"typo-compact-xs-normal text-fg-subtle truncate",children:ly(o.createdAt,"YYYY-MM-DD HH:mm:ss")})]}),C("div",{className:"flex items-center justify-between gap-2",children:[v("span",{className:"typo-compact-2xs-medium text-fg-subtler",children:a("move.amr.rightPanel.history.command")}),v("span",{className:"typo-compact-xs-normal text-fg-subtle truncate",children:o.command||"-"})]})]}),s&&C("div",{className:"flex items-center justify-between gap-2",children:[v("span",{className:"typo-compact-2xs-medium text-fg-subtler",children:a("move.amr.rightPanel.history.result")}),v("span",{className:$t("typo-compact-xs-normal",{"text-fg-success":o.result==="success","text-fg-danger":o.result==="fail","text-fg-information":o.result==="start","text-fg-disabled":o.result==="cancel","text-fg-subtle":o.result!=="success"&&o.result!=="fail"&&o.result!=="start"&&o.result!=="cancel"}),children:o.result||"-"})]})]})]},`${o.createdAt}-${o.command}-${l}`)})}):v("div",{className:r,children:v("span",{className:"typo-compact-xs2-normal text-fg-subtle",children:a("move.amr.rightPanel.history.noHistory")})})},PR=Nc($,{target:"edynay22"})({name:"bjn8wh",styles:"position:relative"}),RR=Nc("div",{target:"edynay21"})('position:relative;width:0.875rem;min-width:0.875rem;align-self:stretch;&::before{content:"";position:absolute;left:50%;transform:translateX(-50%);width:1px;background:rgba(148, 163, 184, 0.45);top:',r=>r.isFirst?"0.75rem":"-0.625rem",";",r=>r.isLast?`height: ${r.isFirst?"0":"1.375rem"}; bottom: unset;`:"bottom: -0.625rem;",";}"),NR=Nc("span",{target:"edynay20"})("position:absolute;top:0.5rem;left:50%;width:0.5rem;height:0.5rem;transform:translateX(-50%);border-radius:9999px;background:",r=>r.isLatest?"rgb(59 130 246)":"rgb(107 114 128)",";box-shadow:",r=>r.isLatest?"0 0 0.5rem rgba(59, 130, 246, 0.9), 0 0 1rem rgba(59, 130, 246, 0.55)":"none",";animation:",r=>r.isLatest?"latest-pulse 1.2s ease-in-out infinite":"none",";@keyframes latest-pulse{0%{opacity:0.45;transform:translateX(-50%) scale(0.8);}50%{opacity:1;transform:translateX(-50%) scale(1);}100%{opacity:0.5;transform:translateX(-50%) scale(0.85);}}"),{useEffect:DR,useMemo:Mg,useState:LR}=await At("react"),IR=[{createdAt:"2026-03-19T10:12:41Z",message:"Move Goal: NODE_A-12",command:"goal",result:"success"},{createdAt:"2026-03-19T10:11:03Z",message:"Move Linear: 0.8m",command:"xLinear",result:"start"},{createdAt:"2026-03-19T10:09:36Z",message:"Move Rotate: 90.0deg",command:"rotate",result:"cancel"},{createdAt:"2026-03-19T10:08:02Z",message:"Move Target: 12.5, 4.1, 0.0",command:"target",result:"fail"}],kR=r=>r.toUpperCase().replace("_"," "),Tg=r=>{if(!r)return"-";const e=new Date(r);if(Number.isNaN(e.getTime()))return r;const t=n=>String(n).padStart(2,"0");return`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())} ${t(e.getHours())}:${t(e.getMinutes())}:${t(e.getSeconds())}`},OR=(r,e)=>{const t=new Date(r).getTime(),n=new Date(e).getTime();return Number.isNaN(t)||Number.isNaN(n)||n<t?0:Math.floor((n-t)/1e3)},Eg=r=>{if(!r)return null;const e=new Date(r).getTime();return Number.isNaN(e)?null:e},FR=r=>{const e=Math.max(0,Math.floor(r)),t=Math.floor(e/3600),n=Math.floor(e%3600/60),i=e%60;return t>0?`${t}h ${n}m ${i}s`:`${n}m ${i}s`},UR=r=>{if(r.command==="goal")return`Move Goal: ${r.goalId||r.goalName}`;if(r.command==="rotate")return`Move Rotate: ${r.target?.toFixed(1)??0}deg`;if(r.command==="target"){const e=r.goalPose;return e?`Move Target: ${e.x?.toFixed(3)??0}, ${e.y?.toFixed(3)??0}, ${e.z?.toFixed(3)??0}`:r.message||"Move Target: -"}return r.command==="circular"?`Move Circular: ${r.target?.toFixed(1)??0}deg`:`Move Linear: ${r.target?.toFixed(1)??0}m`},BR=r=>{if(!r?.items?.length)return;const e=r.items[0],t=r.items;return{status:e.status||"",createdAt:e.createdAt||"",updatedAt:e.updateAt||"",goalNode:e.goalName||e.goalId||"",currentNode:e.goalName||e.goalId||"",estimatedDuration:0,actualDuration:OR(e.createdAt,e.updateAt),previousNodes:t.map(n=>({createdAt:n.createdAt,message:UR(n),command:n.command,result:n.result}))}},d2=({logData:r,moveStatus:e})=>{const{t}=tn(),[n,i]=LR(()=>Date.now()),s=BR(r),a=s?.status??"",o=a?kR(a):t("move.amr.rightPanel.task.idle"),l=s?.previousNodes??[],c=l.length?l:IR,d=e?.goalNode?.name||e?.goalNode?.id||s?.goalNode||"N/A",h=e?.curNode?.name||e?.curNode?.id||s?.currentNode||"N/A",u=a==="in_progress"||a==="move"||a==="vir";DR(()=>{if(!u)return;const b=window.setInterval(()=>{i(Date.now())},1e3);return()=>{window.clearInterval(b)}},[u]);const f=Mg(()=>{const b=Eg(s?.createdAt),p=Eg(s?.updatedAt);if(b!==null){if(u)return Math.max(0,Math.floor((n-b)/1e3));if(p!==null&&p>=b)return Math.floor((p-b)/1e3)}return typeof s?.actualDuration=="number"&&s.actualDuration>=0?Math.floor(s.actualDuration):0},[u,n,s?.actualDuration,s?.createdAt,s?.updatedAt]),m=Mg(()=>FR(f),[f]);return C($,{className:"h-full min-h-0",children:[C($,{className:"border-subtler gap-1.5 border-b p-3",children:[C("div",{className:"flex items-center justify-between",children:[v("div",{className:"typo-compact-xs-normal text-fg-subtler",children:t("move.amr.rightPanel.task.status")}),C("div",{className:"flex flex-row items-center gap-2",children:[v(yi,{color:a!==""?"blue":"gray",className:a!==""?"animate-pulse":void 0}),v("div",{className:"typo-compact-xs-semibold text-fg-default",children:o})]})]}),C("div",{className:"flex items-center justify-between",children:[v("div",{className:"typo-compact-xs-normal text-fg-subtler",children:t("move.amr.rightPanel.common.created")}),v("div",{className:"typo-compact-xs-normal text-fg-subtle",children:Tg(s?.createdAt)})]}),C("div",{className:"flex items-center justify-between",children:[v("div",{className:"typo-compact-xs-normal text-fg-subtler",children:t("move.amr.rightPanel.task.lastUpdated")}),v("div",{className:"typo-compact-xs-normal text-fg-subtle",children:Tg(s?.updatedAt)})]})]}),v("div",{className:"border-subtler border-b p-3",children:C($,{className:"bg-raised space-y-2 rounded p-2",children:[v(AR,{currentNode:h,targetNode:d,moveStatus:a}),v("div",{className:"border-subtler border-b"}),C(we,{className:"justify-between",children:[v("span",{className:"typo-compact-xs-normal text-fg-subtler",children:t("move.amr.rightPanel.task.duration")}),v("span",{className:"typo-compact-xs-normal text-fg-default",children:m})]})]})}),C($,{className:"border-subtler min-h-0 gap-1.5 border-b p-3",children:[C(we,{className:"space-x-1.5",children:[v("span",{className:"typo-compact-sm2-semibold text-fg-default",children:t("move.amr.rightPanel.task.pathHistory")}),v("span",{className:"typo-compact-sm2-normal text-fg-subtle",children:c.length})]}),v(Cv,{items:c,className:"min-h-0 flex-1 overflow-y-auto"})]})]})},{useEffect:io,useRef:ea,useState:ph}=await At("react"),Ag=[{key:"docking",label:"move.amr.rightPanel.dock.step.docking"},{key:"checkCharge",label:"move.amr.rightPanel.dock.step.checkCharge"},{key:"complete",label:"move.amr.rightPanel.dock.step.complete"}],h2=({amrStatus:r,isPaused:e,onDock:t=()=>{},onUndock:n=()=>{},onStop:i=()=>{},onPause:s=()=>{},onResume:a=()=>{},maxRetryCount:o,onOpenRetrySettings:l=()=>{},dockDisabled:c=!1,rejectMessage:d})=>{const{t:h}=tn(),[u,f]=ph(!1),[m,b]=ph(!1),[p,g]=ph(new Set),y=ea(!1),x=ea(!1),w=ea(!1),P=ea(""),T=ea(!1),A=ea(!1),M=r?.chargeState?.charge??"none",_=r?.chargeState?.dockResult??"",S=r?.chargeState?.dock??!1,R=M.toLowerCase(),k=_.toLowerCase(),O=k==="move",H=k==="fail",q=R!=="none"&&M!=="",G=R==="charging",K=R==="battery_on",V=u||O||K,Z=!V&&S,le=h(V?"move.amr.rightPanel.dock.status.move":Z?"move.amr.rightPanel.dock.status.dock":"move.amr.rightPanel.dock.status.undocked"),se=V?"blue":Z?"green":"red",ge=O&&!K&&!G,de=[...u&&!O?["pointDock"]:[],...ge?["docking"]:[],...K?["checkCharge"]:[],...G?["complete"]:[]],X=Ag.map(Fe=>({message:h(Fe.label),result:p.has(Fe.key)?"success":void 0})),ee=de.map(Fe=>Ag.findIndex(j=>j.key===Fe)).filter(Fe=>Fe>=0);io(()=>{const Fe=y.current;y.current=G,!(!G||Fe||T.current)&&(f(!1),g(j=>{const Ke=new Set(j);return Ke.add("pointDock"),Ke.add("docking"),Ke.add("checkCharge"),Ke.add("complete"),Ke}))},[G]),io(()=>{const Fe=x.current;x.current=K,!(!K||Fe||T.current)&&g(j=>{const Ke=new Set(j);return Ke.add("pointDock"),Ke.add("docking"),Ke})},[K]),io(()=>{const Fe=w.current;w.current=O,!(!O||Fe||T.current)&&g(j=>{const Ke=new Set(j);return Ke.add("pointDock"),Ke})},[O]),io(()=>{const Fe=P.current;P.current=k,!(k!=="fail"||Fe==="fail")&&(f(!1),g(new Set))},[k]);const ie=()=>{P.current="",g(new Set),f(!1),b(!1),T.current=!1,A.current=!1};io(()=>{if(m){if(O){A.current=!0;return}A.current&&(A.current=!1,b(!1),T.current=!1)}},[m,O]);const Y=()=>{ie(),f(!0),t()},ue=()=>{ie(),i()},oe=()=>{s()},be=()=>{a()},Ce=()=>{ie(),b(!0),T.current=!0,n()},je=()=>C($,{className:"gap-2",children:[C("div",{className:"grid grid-cols-2 gap-2",children:[v(nt,{variant:"successSoft",onClick:Y,disabled:c,children:h("move.amr.rightPanel.dock.action.dock")}),v(nt,{variant:"dangerSoft",onClick:Ce,disabled:c,children:h("move.amr.rightPanel.dock.action.undock")})]}),V&&C($,{className:"gap-1.5",children:[v("p",{className:"typo-compact-xs-semibold text-fg-default",children:h("move.amr.rightPanel.dock.operation.motion")}),C("div",{className:"grid grid-cols-2 gap-2",children:[v(nt,{variant:"dangerSoft",leadingIcon:v(zg,{className:"size-3"}),disabled:m,onClick:ue,children:h("move.amr.rightPanel.common.stop")}),e?v(nt,{variant:"soft",leadingIcon:v(dy,{className:"size-3"}),disabled:m,onClick:be,children:h("move.amr.rightPanel.dock.action.resume")}):v(nt,{variant:"soft",leadingIcon:v(hy,{className:"size-3"}),disabled:m,onClick:oe,children:h("move.amr.rightPanel.dock.action.pause")})]})]})]});return C(hi,{children:[C($,{className:"border-subtler gap-2.5 border-b p-3",children:[v("p",{className:"typo-compact-sm2-semibold text-fg-default",children:h("move.amr.rightPanel.dock.operation.title")}),C($,{className:"gap-2 rounded",children:[C("div",{className:"bg-fill-disabled grid grid-cols-2 gap-x-3 rounded-md px-3 py-3",children:[C($,{className:"gap-0.5",children:[v("p",{className:"typo-compact-2xs-normal text-fg-subtler",children:h("move.amr.rightPanel.dock.operation.dock")}),C(we,{className:"items-center gap-1.5",children:[v(yi,{color:se,className:V||Z?"animate-pulse":void 0}),v("p",{className:"typo-compact-xs2-medium text-fg-default",children:le})]})]}),C($,{className:"gap-0.5",children:[v("p",{className:"typo-compact-2xs-normal text-fg-subtler",children:h("move.amr.rightPanel.dock.operation.charge")}),v("p",{className:"typo-compact-xs2-medium text-fg-default uppercase",children:q?M:h("move.amr.rightPanel.common.none")})]})]}),je(),C(we,{className:"items-start gap-1",children:[v("div",{className:"flex size-4 shrink-0 items-center justify-center",children:v(Cu,{className:"text-fg-subtlest size-3"})}),v("p",{className:"typo-compact-xs-normal text-fg-subtler flex-1",children:h("move.amr.rightPanel.dock.operation.description")})]})]})]}),C($,{className:"border-subtler gap-2 border-b p-3",children:[v("p",{className:"typo-compact-sm2-semibold text-fg-default",children:h("move.amr.rightPanel.dock.status.title")}),v(Cv,{items:X,latestIndexes:m?[]:ee,compact:!0})]}),C($,{className:"border-subtler gap-2 border-b p-2.5",children:[C(we,{className:"items-center justify-between self-stretch",children:[C(we,{className:"flex-1 items-center gap-1.5",children:[v("p",{className:"typo-compact-sm2-semibold text-fg-default",children:h("move.amr.rightPanel.dock.retryCount")}),H&&v("span",{className:"typo-compact-2xs-semibold bg-fill-danger text-fg-inverse rounded-lg px-1.5 py-0.5",children:h("move.amr.rightPanel.common.fail")})]}),C("button",{type:"button",className:"hover:bg-fill-hovered flex h-5 items-center gap-0.5 rounded-sm px-1.5",onClick:l,children:[v(Yg,{className:"text-fg-default size-3"}),v("span",{className:"text-fg-default text-[10px] leading-3 font-semibold",children:h("move.amr.rightPanel.common.settings")})]})]}),d&&C(we,{className:"border-danger bg-fill-danger-subtlest mt-1 items-start gap-2 rounded-md border px-3 py-2.5",children:[v(cy,{className:"text-fg-danger mt-0.5 size-4 shrink-0"}),v("p",{className:"typo-compact-xs-semibold text-fg-danger",children:d})]}),v("div",{className:"bg-fill-control-surface-disabled outline-border-disabled inline-flex h-9 w-full items-center overflow-hidden rounded-md px-2.5 outline outline-1 outline-offset-[-1px]",children:o!==void 0?v("p",{className:"text-fg-default text-sm leading-5",children:o}):v("p",{className:"text-fg-subtler text-sm leading-5",children:"—"})})]})]})},{useEffect:zR,useState:mh}=await At("react"),{createPortal:HR}=await At("react-dom"),GR=r=>{const e=Math.floor(r/3600).toString().padStart(2,"0"),t=Math.floor(r%3600/60).toString().padStart(2,"0"),n=Math.floor(r%60).toString().padStart(2,"0");return`${e}:${t}:${n}`},u2=({onOpenChange:r,open:e,close:t,onSaveMapping:n,completedKeyframeCount:i=0,totalKeyframePoints:s=0,durationSeconds:a=0,existingMapNames:o=[]})=>{const{t:l}=tn(),[c,d]=mh(""),[h,u]=mh(!1),[f,m]=mh(""),b=async()=>{const y=c.trim();if(!y){m(l("move.amr.rightPanel.map.saveDialog.error.required"));return}if(i<=0){m(l("move.amr.rightPanel.map.mapping.keyframeRequired"));return}if(y.length<3){m(l("move.amr.rightPanel.map.saveDialog.error.minLength"));return}if(!/^[a-zA-Z0-9가-힣_-]+$/.test(y)){m(l("move.amr.rightPanel.map.saveDialog.error.invalidChars"));return}if(o.includes(y)){m(l("move.amr.rightPanel.map.saveDialog.error.duplicateName",{name:y}));return}u(!0),m("");try{const x=await n(y);if(x.ok){d(""),p();return}"reason"in x&&x.reason==="load-failed"?m(l("move.amr.rightPanel.map.saveDialog.error.loadFailed")):m(l("move.amr.rightPanel.map.saveDialog.error.saveFailed"))}catch{m(l("move.amr.rightPanel.map.saveDialog.error.saveError"))}finally{u(!1)}},p=()=>{h||(d(""),m(""),t?.(),r?.(!1))};if(zR(()=>{e||(d(""),m(""),u(!1))},[e]),!e)return null;const g=C($,{className:"fixed inset-0 z-50 items-center justify-center p-4",children:[v("button",{type:"button","aria-label":l("move.amr.rightPanel.map.saveDialog.closeBackdrop"),className:"bg-bg-dim absolute inset-0",onClick:p}),C($,{className:"bg-bg-overlay relative w-full max-w-xl overflow-hidden rounded-lg p-4",children:[v($,{className:"shrink-0 gap-0.5 p-1",children:C(we,{className:"items-start justify-between",children:[C($,{className:"gap-0.5",children:[v("p",{className:"typo-compact-lg-semibold text-fg-default",children:l("move.amr.rightPanel.map.saveDialog.title")}),v("p",{className:"typo-compact-xs-normal text-fg-subtler",children:l("move.amr.rightPanel.map.saveDialog.description")})]}),v(Kn,{variant:"transparent",size:"2xs",icon:v(Ao,{}),className:"text-fg-subtle",onClick:p,disabled:h})]})}),C($,{className:"gap-3 p-1 pt-3",children:[C($,{className:"gap-1.5",children:[v("p",{className:"typo-compact-xs-semibold text-fg-default",children:l("move.amr.rightPanel.map.info.mapName")}),v(Rn,{type:"text",value:c,placeholder:l("move.amr.rightPanel.map.saveDialog.placeholder"),disabled:h,autoFocus:!0,className:"w-full",onChange:y=>{d(y.target.value),m("")},onKeyDown:y=>{y.key==="Enter"&&!h&&b()}}),v("p",{className:"typo-compact-2xs-normal text-fg-subtler",children:l("move.amr.rightPanel.map.saveDialog.nameRule")})]}),f&&v(we,{className:"bg-bg-danger-tertiary outline-border-danger rounded-md p-2.5 outline outline-1 outline-offset-[-1px]",children:v("p",{className:"typo-compact-xs-normal text-fg-danger",children:f})}),C($,{className:"bg-bg-alt-1 gap-1 rounded-md p-2.5",children:[C(we,{className:"items-center justify-between",children:[v("p",{className:"typo-compact-2xs-normal text-fg-subtler",children:l("move.amr.rightPanel.map.mapping.keyframesReceived")}),v("p",{className:"typo-compact-2xs-semibold text-fg-information",children:i.toLocaleString()})]}),C(we,{className:"items-center justify-between",children:[v("p",{className:"typo-compact-2xs-normal text-fg-subtler",children:l("move.amr.rightPanel.map.mapping.keyframePoints")}),v("p",{className:"typo-compact-2xs-semibold text-fg-default",children:l("move.amr.rightPanel.map.mapping.points",{count:s.toLocaleString()})})]}),C(we,{className:"items-center justify-between",children:[v("p",{className:"typo-compact-2xs-normal text-fg-subtler",children:l("move.amr.rightPanel.task.duration")}),v("p",{className:"typo-compact-2xs-semibold text-fg-default",children:GR(a)})]})]})]}),C(we,{className:"shrink-0 items-center justify-end gap-2 p-1 pt-3",children:[v(nt,{variant:"outlined",onClick:p,disabled:h,children:l("move.amr.rightPanel.common.cancel")}),v(nt,{variant:"brand",onClick:b,disabled:h||!c.trim()||i<=0,children:l(h?"move.amr.rightPanel.common.saving":"move.amr.rightPanel.map.saveDialog.saveMap")})]})]})]});return typeof window>"u"?g:HR(g,document.body)},{useEffect:VR}=await At("react"),f2=({isEraserEnabled:r=!1,onEraserToggle:e=()=>{},eraserRadius:t=1,setEraserRadius:n=()=>{},eraseSelectedAreaDisabled:i=!1,onEraseSelectedArea:s=()=>{},onReleaseSelectedPoints:a=()=>{},onSaveChanges:o=()=>{}})=>{const{t:l}=tn();return VR(()=>()=>{e(!1)},[e]),C($,{className:"h-full justify-between overflow-y-auto",children:[C($,{children:[C($,{className:"gap-0.5 px-3 pt-3",children:[C(we,{className:"justify-between",children:[v("p",{className:"typo-compact-sm2-semibold text-fg-default",children:l("move.amr.rightPanel.map.erasing.eraseMode")}),v(wr,{size:"default",checked:r,onCheckedChange:()=>e(!r)})]}),C("p",{className:"typo-compact-xs-normal text-fg-subtler",children:[l("move.amr.rightPanel.map.erasing.descriptionLine1"),v("br",{}),l("move.amr.rightPanel.map.erasing.descriptionLine2")]})]}),C($,{className:"gap-2 p-3",children:[C(we,{className:"justify-between",children:[v("p",{className:"typo-compact-xs2-normal text-fg-default",children:l("move.amr.rightPanel.map.erasing.eraserRadius")}),C("p",{className:"typo-compact-xs2-normal text-fg-default",children:[t.toFixed(1)," m"]})]}),v(Rc,{min:0,max:5,step:.1,value:[t],onValueChange:c=>n(c[0]),disabled:!r})]}),C($,{className:"border-border-subtler gap-2 border-b-[1px] px-3 pb-3",children:[v(nt,{size:"xs2",variant:"soft",leadingIcon:v(uy,{className:"size-3.5"}),disabled:!r||i,onClick:s,children:l("move.amr.rightPanel.map.erasing.eraseSelectedArea")}),v(nt,{size:"xs2",variant:"soft",leadingIcon:v(fy,{className:"size-3.5"}),disabled:!r,onClick:a,children:l("move.amr.rightPanel.map.erasing.releaseSelectedPoints")})]})]}),v($,{className:"p-3",children:v(nt,{variant:"brand",size:"sm",onClick:o,disabled:!r,children:l("move.amr.rightPanel.common.saveChanges")})})]})},{useCallback:Cg,useRef:WR}=await At("react"),Pv={bidirectional:!0,mode:"sequential",properties:{dir:"FORWARD",method:"PP",speed:0,avoidRange:0,safetyField:0,slowMarginX:0,slowMarginY:0,stopMarginX:0,stopMarginY:0}},p2=()=>{const r=WR(Pv),e=Cg(n=>{r.current=n},[]),t=Cg(n=>{const{bidirectional:i,mode:s,properties:a}=r.current;n(i,s,a)},[]);return{setLinkCreationSettings:e,createLinks:t}},Bo=({children:r,cancelLabel:e,saveLabel:t,onCancel:n,onSave:i,cancelDisabled:s=!1,saveDisabled:a=!1})=>C($,{className:"border-subtler sticky bottom-0 z-1 gap-2 border-t p-3",children:[r,C("div",{className:"grid grid-cols-2 gap-2",children:[v(nt,{variant:"outlined",className:"h-9",disabled:s,onClick:n,children:e}),v(nt,{variant:"brand",className:"h-9",disabled:a,onClick:i,children:t})]})]}),{useEffect:ic,useMemo:ta,useState:Ei}=await At("react"),zt=Pv.properties,Tu=["PP","HPP","TNG","SIDE"],Pg=r=>Tu.includes(r),Bs=(r,e,t,n)=>{if(!r||r.trim()==="")return n;const i=Number(r);return Number.isNaN(i)?n:Math.min(t,Math.max(e,i))},vi=r=>r.toFixed(2),jR=({selectedObjects:r,focusedLinkId:e,linkVisibilityFilter:t,nodes:n,visibleSelectedLinks:i,onFocusedLinkChange:s,onLinkVisibilityFilterChange:a,onToolChange:o,onCreateLinks:l,onLinkCreationSettingsChange:c,onUpdateLink:d,onDeleteLink:h,onDeleteLinksBetweenSelected:u,onCancelTopologyChanges:f,onSaveTopologyChanges:m})=>{const{confirmDialog:b}=Co({confirmComponent:Po}),{t:p}=tn(),[g,y]=Ei("sequential"),[x,w]=Ei("bidirectional"),[P,T]=Ei(zt.dir),[A,M]=Ei(zt.method),[_,S]=Ei(String(zt.speed)),[R,k]=Ei(String(zt.avoidRange)),[O,H]=Ei(String(zt.safetyField)),[q,G]=Ei(vi(zt.slowMarginX)),[K,V]=Ei(vi(zt.slowMarginY)),[Z,le]=Ei(vi(zt.stopMarginX)),[se,ge]=Ei(vi(zt.stopMarginY)),[de,X]=Ei(!1);ic(()=>{o?.("select")},[o]);const ee=ta(()=>r.map(W=>{const ae=n.find(ve=>ve.uuid===W.uuid);return{id:W.uuid,name:ae?.name||W.name||W.uuid,mesh:W}}),[n,r]),ie=ta(()=>i.map(W=>{const ae=n.find(ce=>ce.id===W.from),ve=n.find(ce=>ce.id===W.to);return{...W,fromName:ae?.name??W.from,toName:ve?.name??W.to}}),[n,i]),Y=i.length>0,ue=i.length,oe=ta(()=>e?i.find(W=>W.id===e)??null:null,[e,i]),be=W=>{W!=="all"&&W!=="forward"&&W!=="reverse"||a({...t,dir:W})},Ce=W=>{W!=="all"&&!Pg(W)||a({...t,method:W})},je=ta(()=>ie.find(W=>W.id===oe?.id)??null,[oe?.id,ie]);ic(()=>{if(!Y){T(zt.dir),M(zt.method),S(String(zt.speed)),k(String(zt.avoidRange)),H(String(zt.safetyField)),G(vi(zt.slowMarginX)),V(vi(zt.slowMarginY)),le(vi(zt.stopMarginX)),ge(vi(zt.stopMarginY)),X(!1);return}},[Y]),ic(()=>{oe&&(T(oe.dir),M(oe.method),S(String(oe.speed)),k(String(oe.avoidRange)),H(String(oe.safetyField)),G(vi(oe.slowMarginX??zt.slowMarginX)),V(vi(oe.slowMarginY??zt.slowMarginY)),le(vi(oe.stopMarginX??zt.stopMarginX)),ge(vi(oe.stopMarginY??zt.stopMarginY)),X(!1))},[oe]);const Fe=ta(()=>{const W=ee.length;if(W<2)return p("move.amr.rightPanel.topology.link.selectAtLeastTwo");if(W===2){const[ce,Oe]=ee,Pe=x==="bidirectional"?" ↔ ":" → ";return p("move.amr.rightPanel.topology.link.willCreateNamed",{from:ce.name,connector:Pe,to:Oe.name})}const ae=g==="sequential"?W-1:W*(W-1)/2,ve=x==="bidirectional"?ae*2:ae;return p("move.amr.rightPanel.topology.link.willCreateCount",{count:ve})},[g,x,ee,p]),j=ta(()=>({dir:P,method:A,speed:Bs(_,-1,1,zt.speed),avoidRange:Bs(R,-1,1.2,zt.avoidRange),safetyField:Bs(O,-1,Number.MAX_SAFE_INTEGER,zt.safetyField),slowMarginX:Bs(q,-1,1,zt.slowMarginX),slowMarginY:Bs(K,-1,1,zt.slowMarginY),stopMarginX:Bs(Z,-1,1,zt.stopMarginX),stopMarginY:Bs(se,-1,1,zt.stopMarginY)}),[R,P,A,O,q,K,_,Z,se]),Ke=W=>{ee.length<2||l?.(W,g,j)},Ue=()=>{oe&&d?.(oe.id,j)},Te=()=>{oe&&h?.(oe.id)},Se=W=>ae=>{if(X(!0),Number(ae)<0){W("-1");return}W(ae)},et=W=>ae=>{X(!0),W(ae)},Be=W=>ae=>{W(vi(Bs(ae,-1,1,0)))},N=ee.length>=2,E=Y?"edit":"add";return ic(()=>{E==="add"&&c?.({bidirectional:x==="bidirectional",mode:g,properties:j})},[g,x,j,E,c]),C($,{className:"h-full min-h-0 overflow-hidden",children:[C($,{className:"min-h-0 flex-1 overflow-x-hidden overflow-y-auto",children:[C(we,{className:"border-subtler gap-1.5 border-b p-3",children:[v(Pu,{className:"text-fg-default"}),C($,{className:"gap-0.5",children:[v("p",{className:"compact-sm-semibold text-fg-default",children:E==="edit"?`${ue} link${ue>1?"s":""} selected`:p("move.amr.rightPanel.topology.link.nodeSelectedCount",{count:ee.length})}),v("p",{className:"typo-compact-xs-normal text-fg-subtle",children:E==="edit"?ue>1?"Select one link from the list below to edit.":"Review and update the selected link.":p("move.amr.rightPanel.topology.link.selectAtLeastTwoShort")})]})]}),E==="edit"&&C($,{className:"border-subtler gap-1.5 border-b p-3",children:[v("p",{className:"typo-compact-xs-semibold text-fg-default",children:"Link Filter"}),C("div",{className:"grid grid-cols-2 gap-2",children:[C($,{className:"gap-1",children:[v("p",{className:"typo-compact-xs-normal text-fg-subtler",children:"Direction"}),C(ca,{size:"sm",value:t.dir,handleChange:be,children:[v(Pi,{value:"all",children:"All"}),v(Pi,{value:"forward",children:"Forward"}),v(Pi,{value:"reverse",children:"Reverse"})]})]}),C($,{className:"gap-1",children:[v("p",{className:"typo-compact-xs-normal text-fg-subtler",children:"Method"}),C(ca,{size:"sm",value:t.method,handleChange:Ce,children:[v(Pi,{value:"all",children:"All"}),Tu.map(W=>v(Pi,{value:W,children:W},W))]})]})]})]}),E==="add"&&C(hi,{children:[C($,{className:"border-subtler gap-2 border-b p-3",children:[v("p",{className:"typo-compact-sm2-semibold text-fg-default",children:p("move.amr.rightPanel.topology.link.creationMode")}),C("div",{className:"grid grid-cols-2 gap-2",children:[C(ii,{name:"topology-link-mode-sequential",className:"w-full",checkValue:"sequential",value:g,disabled:ee.length<3,onChange:W=>{W.target.checked&&y("sequential")},children:[p("move.amr.rightPanel.topology.link.sequential"),v("br",{}),"(1→2→3)"]}),C(ii,{name:"topology-link-mode-complete",className:"w-full",checkValue:"complete",value:g,disabled:ee.length<3,onChange:W=>{W.target.checked&&y("complete")},children:[p("move.amr.rightPanel.topology.link.complete"),v("br",{}),"(all↔all)"]})]}),v("p",{className:"typo-compact-xs-normal text-fg-subtler",children:p("move.amr.rightPanel.topology.link.modeAvailable")})]}),C($,{className:"border-border-subtler gap-2 border-b p-3",children:[v("p",{className:"typo-compact-sm2-semibold text-fg-default",children:p("move.amr.rightPanel.topology.link.direction")}),C("div",{className:"grid grid-cols-2 gap-2",children:[v(ii,{name:"topology-link-direction-bidirectional",className:"w-full",checkValue:"bidirectional",value:x,disabled:!N,onChange:W=>{W.target.checked&&w("bidirectional")},children:p("move.amr.rightPanel.topology.link.bidirectional")}),v(ii,{name:"topology-link-direction-unidirectional",className:"w-full",checkValue:"unidirectional",value:x,disabled:!N,onChange:W=>{W.target.checked&&w("unidirectional")},children:p("move.amr.rightPanel.topology.link.unidirectional")})]}),v("p",{className:"typo-compact-xs-normal text-fg-subtler",children:p("move.amr.rightPanel.topology.link.configureDirection")})]})]}),E==="edit"&&C($,{className:"border-subtler gap-3 border-b p-3",children:[C($,{className:"gap-1",children:[v("p",{className:"typo-compact-sm2-semibold text-fg-default",children:"Selected Links"}),v("p",{className:"typo-compact-xs-normal text-fg-subtler",children:ue>1?"Choose one link to load its properties into the editor.":"The selected link is ready to edit."})]}),v($,{className:"border-border-subtle max-h-40 gap-1 overflow-y-auto rounded-md border p-1.5",children:ie.map((W,ae)=>C(we,{className:`items-center justify-between rounded-md border px-2 py-1.5 transition-colors ${W.id===oe?.id?"border-border-default bg-fill-subtler":"bg-fill-control-surface hover:border-border-subtle border-transparent"}`,onClick:()=>{s(W.id)},children:[v("p",{className:"typo-compact-xs-semibold text-fg-default truncate",children:`${ae+1}. ${W.fromName} -> ${W.toName}`}),v("p",{className:"typo-compact-xs-normal text-fg-subtler shrink-0",children:`${W.method} / ${W.dir}`})]},W.id))})]}),C($,{className:`border-subtler gap-2 border-b p-3 ${E==="add"&&!N?"opacity-50":""}`,children:[v("p",{className:"typo-compact-sm2-semibold text-fg-default",children:p("move.amr.rightPanel.topology.link.properties")}),C($,{className:"gap-2",children:[v("p",{className:"typo-compact-xs-semibold text-fg-default",children:p("move.amr.rightPanel.topology.link.dir")}),C("div",{className:"grid grid-cols-2 gap-2",children:[v(ii,{name:"topology-link-dir-forward",className:"w-full",checkValue:"FORWARD",value:P,disabled:E==="add"?!N:!oe,onChange:W=>{W.target.checked&&(X(!0),T("FORWARD"))},children:"FORWARD"}),v(ii,{name:"topology-link-dir-reverse",className:"w-full",checkValue:"REVERSE",value:P,disabled:E==="add"?!N:!oe,onChange:W=>{W.target.checked&&(X(!0),T("REVERSE"))},children:"REVERSE"})]})]}),C($,{className:"gap-2",children:[v("p",{className:"typo-compact-xs-semibold text-fg-default",children:p("move.amr.rightPanel.topology.link.method")}),v(ca,{size:"sm",value:A,disabled:E==="add"?!N:!oe,handleChange:W=>{Pg(W)&&(X(!0),M(W))},children:Tu.map(W=>v(Pi,{value:W,children:W},W))})]}),C("div",{className:"grid grid-cols-2 gap-2",children:[C($,{className:"gap-1",children:[C(we,{className:"typo-compact-xs-medium gap-1",children:[v("p",{className:"text-fg-default",children:p("move.amr.rightPanel.common.speed")}),v("p",{className:"text-fg-subtle",children:"(max 1.0)"})]}),v(Nn,{className:"w-full",value:_,step:.1,increaseStep:Number(_)<0?1:.1,min:-1,max:1,disabled:E==="add"?!N:!oe,handleChange:Se(S)})]}),C($,{className:"gap-1",children:[C(we,{className:"typo-compact-xs-medium gap-1",children:[v("p",{className:"text-fg-default",children:p("move.amr.rightPanel.topology.link.avoidRange")}),v("p",{className:"text-fg-subtle",children:"(max 1.2)"})]}),v(Nn,{className:"w-full",value:R,step:.1,increaseStep:Number(R)<0?1:.1,min:-1,max:1.2,disabled:E==="add"?!N:!oe,handleChange:Se(k)})]})]}),C($,{className:"gap-1",children:[v("p",{className:"typo-compact-xs-semibold text-fg-default",children:p("move.amr.rightPanel.topology.link.safetyField")}),v(Nn,{className:"w-full",value:O,step:1,min:-1,disabled:E==="add"?!N:!oe,handleChange:W=>{X(!0),H(W)}})]}),C($,{className:"gap-2",children:[C(we,{className:"typo-compact-xs-medium gap-1",children:[v("p",{className:"text-fg-default",children:"Slow Margin"}),v("p",{className:"text-fg-subtle",children:"(max 1.0)"})]}),C("div",{className:"grid grid-cols-2 gap-2",children:[C($,{className:"gap-1",children:[v("p",{className:"typo-compact-xs-normal text-fg-subtler",children:"X"}),v(Nn,{className:"w-full",value:q,step:.01,fixedDigit:2,increaseStep:Number(q)<0?1:.01,decreaseStep:Number(q)<=0?1:.01,min:-1,max:1,disabled:E==="add"?!N:!oe,handleChange:et(G),onBlur:()=>{Be(G)(q)}})]}),C($,{className:"gap-1",children:[v("p",{className:"typo-compact-xs-normal text-fg-subtler",children:"Y"}),v(Nn,{className:"w-full",value:K,step:.01,fixedDigit:2,increaseStep:Number(K)<0?1:.01,decreaseStep:Number(K)<=0?1:.01,min:-1,max:1,disabled:E==="add"?!N:!oe,handleChange:et(V),onBlur:()=>{Be(V)(K)}})]})]})]}),C($,{className:"gap-2",children:[C(we,{className:"typo-compact-xs-medium gap-1",children:[v("p",{className:"text-fg-default",children:"Stop Margin"}),v("p",{className:"text-fg-subtle",children:"(max 1.0)"})]}),C("div",{className:"grid grid-cols-2 gap-2",children:[C($,{className:"gap-1",children:[v("p",{className:"typo-compact-xs-normal text-fg-subtler",children:"X"}),v(Nn,{className:"w-full",value:Z,step:.01,fixedDigit:2,increaseStep:Number(Z)<0?1:.01,decreaseStep:Number(Z)<=0?1:.01,min:-1,max:1,disabled:E==="add"?!N:!oe,handleChange:et(le),onBlur:()=>{Be(le)(Z)}})]}),C($,{className:"gap-1",children:[v("p",{className:"typo-compact-xs-normal text-fg-subtler",children:"Y"}),v(Nn,{className:"w-full",value:se,step:.01,fixedDigit:2,increaseStep:Number(se)<0?1:.01,decreaseStep:Number(se)<=0?1:.01,min:-1,max:1,disabled:E==="add"?!N:!oe,handleChange:et(ge),onBlur:()=>{Be(ge)(se)}})]})]})]})]})]}),v(Bo,{cancelLabel:p("move.amr.rightPanel.common.cancel"),saveLabel:p("move.amr.rightPanel.common.save"),onCancel:async()=>{await b({title:p("move.amr.rightPanel.common.cancel"),content:p("move.amr.rightPanel.topology.dialog.discardContent"),buttonText:{yes:p("move.amr.rightPanel.common.discard"),no:p("move.amr.rightPanel.common.keepEditing")}})&&f?.()},onSave:m,children:C($,{className:"border-subtler border-b p-3",children:[v("p",{className:"typo-compact-xs-normal text-fg-subtle text-center",children:E==="edit"?je?`${je.fromName} -> ${je.toName} is selected for editing.`:"Select a link from the list above to edit.":Fe}),v("p",{className:"typo-compact-xs-normal text-fg-subtler pt-1 text-center",children:E==="edit"?oe?`dir ${j.dir} / method ${j.method} / speed ${j.speed.toFixed(1)} / avoid ${j.avoidRange.toFixed(1)}`:"":p("move.amr.rightPanel.topology.link.previewProperties",{dir:j.dir,method:j.method,speed:j.speed.toFixed(1),avoid:j.avoidRange.toFixed(1)})}),v($,{className:"gap-2 pt-3",children:E==="edit"?C(hi,{children:[v(nt,{variant:"soft",className:"text-fg-default py-2",disabled:!oe||!de,onClick:Ue,children:"Update selected link"}),v(nt,{variant:"dangerSoft",onClick:Te,disabled:!oe,leadingIcon:v(Mh,{}),children:"Delete selected link"})]}):C(hi,{children:[v(nt,{variant:"soft",className:"text-fg-default py-2",disabled:ee.length<2,onClick:()=>{Ke(x==="bidirectional")},children:p("move.amr.rightPanel.topology.link.linkSelected")}),v(nt,{variant:"dangerSoft",onClick:u,disabled:ee.length<2,leadingIcon:v(Mh,{}),children:p("move.amr.rightPanel.topology.link.deleteLinks")})]})})]})})]})},XR=({selectedTool:r="select",onToolChange:e,selectedNodeType:t="goal",onSelectNodeType:n,selectedNodePlacementType:i="cursor",onSelectNodePlacementType:s,onAddNodeAtRobot:a,onAddNodeAtCursor:o,onSaveTopologyChanges:l,onCancelTopologyChanges:c,showRobotPlacement:d=!0})=>{const{confirmDialog:h}=Co({confirmComponent:Po}),{t:u}=tn(),f=r==="target";return C($,{className:"h-full min-h-0 gap-0",children:[C($,{className:"min-h-0 flex-1 overflow-y-auto",children:[C($,{className:"border-subtler gap-0.5 border-b p-3",children:[v("p",{className:"typo-compact-sm2-semibold text-fg-default",children:u("move.amr.rightPanel.topology.add.title")}),v("p",{className:"typo-compact-xs-normal text-fg-subtler",children:u("move.amr.rightPanel.topology.add.description")})]}),C($,{className:"border-subtler gap-2 border-b p-3",children:[v("p",{className:"typo-compact-sm2-semibold text-fg-default",children:u("move.amr.rightPanel.topology.add.selectNodeType")}),C("div",{className:"grid grid-cols-3 gap-2",children:[v(ii,{className:"w-full",name:"topology-node-type-goal",checkValue:"goal",value:t,onChange:m=>{m.target.checked&&n?.("goal")},children:u("move.amr.rightPanel.topology.nodeType.goal")}),v(ii,{className:"w-full",name:"topology-node-type-route",checkValue:"route",value:t,onChange:m=>{m.target.checked&&n?.("route")},children:u("move.amr.rightPanel.topology.nodeType.route")}),v(ii,{className:"w-full",name:"topology-node-type-align",checkValue:"align",value:t,onChange:m=>{m.target.checked&&n?.("align")},children:u("move.amr.rightPanel.topology.nodeType.align")})]})]}),C($,{className:"border-subtler gap-2 border-b p-3",children:[v("p",{className:"typo-compact-sm2-semibold text-fg-default",children:u("move.amr.rightPanel.topology.add.selectPlacement")}),C(we,{className:"items-center justify-between gap-2 py-1",children:[C($,{className:"gap-0.5",children:[v("p",{className:"typo-compact-sm2-semibold text-fg-default",children:"Cursor Preview"}),v("p",{className:"typo-compact-2xs-normal text-fg-subtler",children:"Enable cursor placement mode before adding at cursor position."})]}),v(wr,{checked:f,onCheckedChange:m=>{if(m){e?.("target");return}r==="target"&&e?.("select")}})]}),C($,{className:"gap-2",children:[v(ii,{className:"w-full",name:"topology-node-placement-cursor",checkValue:"cursor",value:i,onChange:m=>{m.target.checked&&s?.("cursor")},children:u("move.amr.rightPanel.topology.add.atCursorPosition")}),d&&v(ii,{className:"w-full",name:"topology-node-placement-robot",checkValue:"robot",value:i,onChange:m=>{m.target.checked&&s?.("robot")},children:u("move.amr.rightPanel.topology.add.atRobotPosition")})]})]})]}),v(Bo,{cancelLabel:u("move.amr.rightPanel.common.cancel"),saveLabel:u("move.amr.rightPanel.common.save"),onCancel:async()=>{await h({title:u("move.amr.rightPanel.common.cancel"),content:u("move.amr.rightPanel.topology.dialog.discardContent"),buttonText:{yes:u("move.amr.rightPanel.common.discard"),no:u("move.amr.rightPanel.common.keepEditing")}})&&c?.()},onSave:l,children:C(nt,{variant:"soft",className:"text-fg-default",onClick:()=>{if(i==="robot"){a?.();return}if(r!=="target"){py.openToast({type:"basic",variant:"warning",title:"Cursor Preview Disabled",content:"Turn on cursor placement mode before adding a node at cursor position.",position:"top-right"});return}o?.()},children:[u("move.amr.rightPanel.topology.add.addNode")," (N)"]})})]})},{useEffect:gh,useMemo:Rg,useRef:bh,useState:bs}=await At("react"),vh=["INIT","CHARGING","AUTO_DOOR","ARUCO","APRIL","V_MARKER","TAPE","PRECISION","SCAN_MATCH"],Ai=r=>Number(r.toFixed(3)),Rv=-1,Nv=31,qR=r=>{const e=r.trim();if(!/^-?\d+$/.test(e))return null;const t=Number(e);return Number.isInteger(t)?Math.min(Nv,Math.max(Rv,t)):null},ZR=r=>{const e=r.toLowerCase().replace("init","goal");return e==="route"||e==="align"?e:"goal"},YR=({selectedObjects:r=[],selectedNodeTransform:e=null,nodes:t=[],robotPose:n=null,onUpdateNode:i,onChangeNodeType:s,onTransformSelectedNodes:a,onDeleteSelectedNodes:o,onCancelTopologyChanges:l,onSaveTopologyChanges:c})=>{const{confirmDialog:d}=Co({confirmComponent:Po}),{t:h}=tn(),[u,f]=bs(""),[m,b]=bs([]),[p,g]=bs("0"),[y,x]=bs("0.0"),[w,P]=bs("0.0"),[T,A]=bs("0.0"),[M,_]=bs("0.0"),[S,R]=bs(!1),[k,O]=bs("1"),H=bh({altKey:!1,metaKey:!1,ctrlKey:!1}),q=bh(null),G=bh(!1);gh(()=>{const N=W=>{H.current={altKey:W.altKey,metaKey:W.metaKey,ctrlKey:W.ctrlKey}},E=()=>{H.current={altKey:!1,metaKey:!1,ctrlKey:!1},q.current=null};return window.addEventListener("keydown",N),window.addEventListener("keyup",N),window.addEventListener("blur",E),()=>{window.removeEventListener("keydown",N),window.removeEventListener("keyup",N),window.removeEventListener("blur",E)}},[]);const K=Rg(()=>r.map(N=>{const E=t.find(W=>W.uuid===N.uuid);return{uuid:N.uuid,externalId:String(N.userData?.id??""),name:N.name,type:ZR(E?.type||N.userData?.type||"goal"),features:Array.isArray(N.userData?.features)?N.userData.features.filter(W=>typeof W=="string"&&vh.includes(W)):[],safetyField:typeof N.userData?.safetyField=="number"?N.userData.safetyField:E?.safetyField??0,x:N.position.x,y:N.position.y,z:N.position.z,rz:Ai(N.rotation.z*180/Math.PI)}}),[t,r]),V=K[K.length-1],Z=K.length===1,le=Rg(()=>{if(!n)return null;const N=Number(n.x),E=Number(n.y),W=Number(n.rz);return[N,E,W].some(ae=>Number.isNaN(ae))?null:{x:Ai(N),y:Ai(E),rz:Ai(W)}},[n]);gh(()=>{f(V?.name??""),b(V?.features??[]),g(String(V?.safetyField??0))},[V?.uuid,V?.name,V?.features,V?.safetyField]),gh(()=>{let N=null;e?N={x:e.x,y:e.y,z:e.z,rz:e.rz}:V&&(N={x:V.x,y:V.y,z:V.z,rz:V.rz}),x(String(Ai(N?.x??0))),P(String(Ai(N?.y??0))),A(String(Ai(N?.z??0))),_(String(Ai(N?.rz??0)))},[V,V?.uuid,V?.x,V?.y,V?.z,V?.rz,e]);const se=(N,E)=>{i?.(N,E)},ge=N=>N.filter(E=>typeof E=="string"&&vh.includes(E)),de=(N,E)=>{N==="x"&&x(E),N==="y"&&P(E),N==="z"&&A(E)},X=(N,E)=>{if(N==="x"||N==="y"||N==="z"){de(N,E);return}_(E)},ee=N=>{const E=r[r.length-1];return E?N==="x"?E.position.x:N==="y"?E.position.y:N==="z"?E.position.z:Ai(E.rotation.z*180/Math.PI):0},ie=(N=H.current)=>N.altKey?"delta":N.metaKey||N.ctrlKey?"absolute":"single",Y=()=>q.current??ie(),ue=(N,E)=>{q.current=ie({altKey:E?.altKey,metaKey:E?.metaKey,ctrlKey:E?.ctrlKey})},oe=()=>{q.current=null},be=N=>{G.current=N.metaKey||N.ctrlKey},Ce=(N,E,W)=>{const ae=W?N.features.includes(E)?N.features:[...N.features,E]:N.features.filter(ve=>ve!==E);se(N.uuid,{features:ae})},je=(N,E)=>{if(!V||!Array.isArray(E))return;const W=ge(E),ae=W.includes(N),ve=G.current;if(G.current=!1,b(W),ve){for(const ce of K)Ce(ce,N,ae);return}se(V.uuid,{features:W})},Fe=(N,E,W)=>{if(!V)return;const ae=W?Y():ie(),ve=Number(E);if(Number.isNaN(ve))return;const ce=Ai(ve),Oe=String(ce);if(N==="x"||N==="y"||N==="z"?de(N,Oe):_(Oe),ae==="delta"){const Pe=Ai(W?(W==="up"?1:-1)*(Number(k)||1):ce-ee(N));a?.(N,Pe,"delta");return}if(ae==="absolute"){a?.(N,ce,"absolute");return}if(N==="x"||N==="y"||N==="z"){se(V.uuid,{[N]:ce});return}se(V.uuid,{rz:ce})},j=(N,E,W)=>{if(W){Fe(N,E,W);return}X(N,E)},Ke=(N,E)=>{Fe(N,E)},Ue=(N,E)=>{if(!V)return;const W=E?Y():ie(),ae=qR(N);if(ae===null)return;const ve=String(ae);if(g(ve),W==="absolute"){for(const ce of K)se(ce.uuid,{safetyField:ae});return}se(V.uuid,{safetyField:ae})},Te=N=>{V&&/^-?\d*$/.test(N)&&g(N)},Se=(N,E)=>{if(E){Ue(N,E);return}Te(N)},et=N=>{Ue(N)},Be=()=>{!Z||!le||(x(String(le.x)),P(String(le.y)),_(String(le.rz)),se(V.uuid,le))};return C($,{className:"h-full min-h-0 overflow-hidden",children:[C($,{className:"min-h-0 flex-1 overflow-x-hidden overflow-y-auto",children:[C($,{className:"border-subtler gap-3 border-b p-3",children:[C(we,{className:"items-center justify-between gap-2",children:[v("p",{className:"typo-compact-sm2-semibold text-fg-default",children:h("move.amr.rightPanel.topology.edit.nodeProperties")}),K.length>1&&C("p",{className:"typo-compact-2xs-semibold text-fg-subtler",children:[K.length," selected"]})]}),C($,{className:"gap-1.5",children:[v("p",{className:"typo-compact-xs-semibold text-fg-default",children:h("move.amr.rightPanel.topology.edit.nodeId")}),C(we,{className:"items-center gap-1.5",children:[v("p",{className:"typo-compact-xs-normal text-fg-subtler flex-1",children:V?.externalId??""}),V?.externalId&&v("button",{className:"text-fg-subtler hover:text-fg-default shrink-0",onClick:()=>{gy({text:V.externalId??""})},children:v(my,{className:"size-3.5"})})]})]}),C($,{className:"gap-1.5",children:[v("p",{className:"typo-compact-xs-semibold text-fg-default",children:h("move.amr.rightPanel.topology.edit.name")}),v(Rn,{className:"w-full",type:"text",value:u,onChange:N=>{if(!V)return;const E=N.target.value;f(E),se(V.uuid,{name:E})}})]}),C($,{className:"gap-1",children:[v("p",{className:"typo-compact-xs-semibold text-fg-default",children:h("move.amr.rightPanel.topology.edit.nodeType")}),C(ca,{size:"sm",value:V?.type??"goal",disabled:!Z,handleChange:N=>{!V||!Z||N!==V.type&&(N==="goal"||N==="route"||N==="align")&&s?.(V.uuid,N)},children:[v(Pi,{value:"goal",children:h("move.amr.rightPanel.topology.nodeType.goal")}),v(Pi,{value:"route",children:h("move.amr.rightPanel.topology.nodeType.route")}),v(Pi,{value:"align",children:h("move.amr.rightPanel.topology.nodeType.align")})]}),v("p",{className:"typo-compact-2xs-normal text-fg-subtler",children:h(Z?"move.amr.rightPanel.topology.edit.nodeTypeUnavailable":"move.amr.rightPanel.topology.edit.nodeTypeSingleSelect")})]}),C($,{className:"gap-1.5",children:[C(we,{className:"items-center gap-1",children:[v("p",{className:"typo-compact-xs-semibold text-fg-default",children:h("move.amr.rightPanel.topology.link.safetyField")}),v("p",{className:"text-fg-subtle typo-compact-2xs-normal",children:"(-1 ~ 31)"})]}),v(Nn,{className:"w-full",value:p,step:1,min:Rv,max:Nv,handleChange:(N,E,W)=>{Se(N,W?.type)},handleEnter:N=>{et(N)},onButtonPointerDown:ue,onButtonPointerUp:oe})]})]}),v("div",{className:"border-subtler border-b",children:v(wf,{title:v("p",{className:"typo-compact-sm2-semibold text-fg-default",children:h("move.amr.rightPanel.topology.edit.features")}),children:v("div",{className:"grid grid-cols-2 gap-x-2 gap-y-2",children:vh.map(N=>v(by,{className:"[&_[data-slot=checkbox-surface]]:border-border-default [&_[data-slot=checkbox-surface]]:bg-fill-control-surface [&_[data-slot=checkbox-surface]]:shadow-none",name:`topology-feature-${V?.uuid??""}`,checkValue:N,value:m,onClick:be,handleChange:E=>{je(N,E)},children:v("span",{className:"typo-compact-xs-normal text-fg-default",children:N})},N))})})}),v("div",{className:"border-subtler border-b",children:C(wf,{initialOpen:!0,title:C(we,{className:"w-full items-center justify-between",children:[v("p",{className:"typo-compact-sm2-semibold text-fg-default",children:h("move.amr.rightPanel.topology.edit.transform")}),C(we,{className:"text-fg-default items-center gap-0.5",children:[v(nt,{variant:"transparent",size:"2xs",leadingIcon:v(Yg,{}),onClick:N=>{N.preventDefault(),N.stopPropagation(),R(E=>!E)},children:h("move.amr.rightPanel.topology.edit.stepSize")}),v("div",{className:`overflow-hidden transition-all duration-200 ease-out ${S?"w-32 opacity-100":"pointer-events-none w-0 opacity-0"}`,children:v(Nn,{className:"h-8 w-32",value:k,step:.1,handleChange:N=>{O(N)}})})]})]}),children:[C($,{className:"gap-2 pt-1",children:[C($,{className:"gap-1",children:[C(we,{className:"typo-compact-xs-medium gap-1",children:[v("p",{className:"text-fg-danger",children:"X"}),v("p",{className:"text-fg-subtle",children:"(m)"})]}),v(Nn,{className:"w-full",value:y,step:Number(k)||1,handleChange:(N,E,W)=>{j("x",N,W?.type)},handleEnter:N=>{Ke("x",N)},onButtonPointerDown:ue,onButtonPointerUp:oe})]}),C($,{className:"gap-1",children:[C(we,{className:"typo-compact-xs-medium gap-1",children:[v("p",{className:"text-fg-success",children:"Y"}),v("p",{className:"text-fg-subtle",children:"(m)"})]}),v(Nn,{className:"w-full",value:w,step:Number(k)||1,handleChange:(N,E,W)=>{j("y",N,W?.type)},handleEnter:N=>{Ke("y",N)},onButtonPointerDown:ue,onButtonPointerUp:oe})]}),C($,{className:"gap-1",children:[C(we,{className:"typo-compact-xs-medium gap-1",children:[v("p",{className:"text-fg-brand",children:"Z"}),v("p",{className:"text-fg-subtle",children:"(m)"})]}),v(Nn,{className:"w-full",value:T,step:Number(k)||1,handleChange:(N,E,W)=>{j("z",N,W?.type)},handleEnter:N=>{Ke("z",N)},onButtonPointerDown:ue,onButtonPointerUp:oe})]})]}),C($,{className:"gap-1",children:[C(we,{className:"typo-compact-xs-medium gap-1",children:[v("p",{className:"text-fg-information",children:"RZ"}),v("p",{className:"text-fg-subtle",children:"(°)"})]}),v(Nn,{className:"w-full",value:M,step:Number(k)||1,min:0,max:360,handleChange:(N,E,W)=>{j("rz",N,W?.type)},handleEnter:N=>{Ke("rz",N)},onButtonPointerDown:ue,onButtonPointerUp:oe}),Z&&le&&v(we,{className:"mt-2 justify-center",children:v(nt,{variant:"transparent",size:"sm",leadingIcon:v(ba,{}),onClick:Be,children:"Match Robot Pose"})})]})]})})]}),v(Bo,{cancelLabel:h("move.amr.rightPanel.common.cancel"),saveLabel:h("move.amr.rightPanel.common.saveChanges"),onCancel:async()=>{await d({title:h("move.amr.rightPanel.common.cancel"),content:h("move.amr.rightPanel.topology.dialog.discardContent"),buttonText:{yes:h("move.amr.rightPanel.common.discard"),no:h("move.amr.rightPanel.common.keepEditing")}})&&l?.()},onSave:c,children:C("button",{className:"typo-compact-sm-normal text-fg-danger hover:bg-fill-subtle flex items-center justify-center gap-1 rounded-md py-2 transition-colors",onClick:o,children:[v(Mh,{className:"size-4"}),h("move.amr.rightPanel.common.delete")]})})]})},{useEffect:KR,useMemo:$R,useRef:QR,useState:sc}=await At("react"),JR=r=>{const e=r.toLowerCase();return e==="goal"?v(xy,{className:"text-fg-warning"}):e==="route"?v(Kg,{className:"text-fg-brand"}):v(_y,{className:"text-fg-success"})},eN=({nodes:r=[],selectedObjects:e=[],selectedNodeTransform:t=null,robotPose:n=null,onNodeSelected:i,selectedTool:s="select",onToolChange:a,selectedNodeType:o="goal",onSelectNodeType:l,selectedNodePlacementType:c="cursor",onSelectNodePlacementType:d,onAddNodeAtRobot:h,onAddNodeAtCursor:u,onUpdateNode:f,onChangeNodeType:m,onTransformSelectedNodes:b,onDeleteSelectedNodes:p,onSaveTopologyChanges:g,onCancelTopologyChanges:y,showRobotPlacement:x=!0})=>{const{t:w}=tn(),P=QR(null),[T,A]=sc(""),[M,_]=sc("all"),[S,R]=sc(!1),[k,O]=sc(!1),H=e.length>0,q=$R(()=>{const V=T.trim().toLowerCase(),Z=V?r.filter(le=>(le.name||le.id).toLowerCase().includes(V)):r;return{all:Z,goal:Z.filter(le=>le.type.toLowerCase()==="goal"),route:Z.filter(le=>le.type.toLowerCase()==="route"),align:Z.filter(le=>le.type.toLowerCase()==="align")}},[r,T]),G=q[M];KR(()=>{const V=P.current;if(!V)return;const Z=()=>{const{scrollTop:le,clientHeight:se,scrollHeight:ge}=V;R(le>4),O(le+se<ge-4)};return Z(),V.addEventListener("scroll",Z),()=>{V.removeEventListener("scroll",Z)}},[G]);const K=V=>V.length===0?v(go,{className:"h-full w-full flex-1 [&_[data-slot='empty-view-section']]:h-full",type:"icon",icon:v(vy,{}),message:w("move.amr.rightPanel.topology.nodes.empty")}):V.map(Z=>C($,{children:[C(we,{className:"hover:bg-fill-subtle cursor-pointer items-center justify-between rounded-md px-1.5 py-1.5 transition-colors",onClick:le=>{const se=le.metaKey||le.ctrlKey?"remove":le.shiftKey?"add":"replace";i?.(Z.uuid,se)},children:[C(we,{className:"min-w-0 flex-1 items-center gap-2",children:[JR(Z.type),C(we,{className:"min-w-0 flex-1 items-center justify-between gap-2",children:[v("p",{className:"typo-compact-xs-normal text-fg-default truncate",children:Z.name?Z.name:`${Z.id}(ID)`}),C(we,{className:"mr-2 shrink-0 items-center gap-1.5",children:[v("p",{className:"typo-compact-2xs-semibold text-fg-subtler uppercase",children:Z.type}),v(ts,{type:"vertical",thickness:"thick",className:"text-fg-subtler h-4"}),C("p",{className:"typo-compact-2xs-normal text-fg-subtler",children:[Z.x.toFixed(1),", ",Z.y.toFixed(1),", ",Z.z.toFixed(1)]})]})]})]}),v(yy,{className:"text-fg-default"})]}),v(ts,{className:"text-fg-subtler"})]},Z.uuid));return C($,{className:"h-full min-h-0 gap-0",children:[C($,{className:"border-subtler h-[25%] min-h-[16rem] gap-2 border-b p-3",children:[v(Rn,{size:"sm",className:"w-full",value:T,type:"search",placeholder:w("move.amr.rightPanel.topology.nodes.searchByName"),onChange:V=>{A(V.target.value)}}),C(Zg,{className:"min-h-0 w-full flex-1",variant:"line",value:M,onValueChange:V=>{(V==="all"||V==="goal"||V==="route"||V==="align")&&_(V)},children:[C(we,{className:"items-center justify-between gap-2",children:[C(qg,{children:[v(vr,{value:"all",children:w("move.amr.rightPanel.topology.nodeType.all")}),v(vr,{value:"goal",children:w("move.amr.rightPanel.topology.nodeType.goal")}),v(vr,{value:"route",children:w("move.amr.rightPanel.topology.nodeType.route")}),v(vr,{value:"align",children:w("move.amr.rightPanel.topology.nodeType.align")})]}),C("p",{className:"typo-compact-2xs-semibold text-fg-subtler shrink-0 px-2",children:[G.length," / ",r.length]})]}),C("div",{className:"border-border-subtle bg-fill-disabled relative min-h-0 flex-1 overflow-hidden rounded-md border",children:[G.length>4&&S&&v("div",{className:"from-bg-alt-1 pointer-events-none absolute top-0 right-0 left-0 z-[1] h-3 rounded-t-md bg-gradient-to-b to-transparent"}),C("div",{ref:P,className:"h-full min-h-0 overflow-y-auto px-1 py-0.5",children:[v(Xo,{value:"all",className:"h-full",children:v($,{className:"h-full min-h-0 gap-1",children:K(q.all)})}),v(Xo,{value:"goal",className:"h-full",children:v($,{className:"h-full min-h-0 gap-1",children:K(q.goal)})}),v(Xo,{value:"route",className:"h-full",children:v($,{className:"h-full min-h-0 gap-1",children:K(q.route)})}),v(Xo,{value:"align",className:"h-full",children:v($,{className:"h-full min-h-0 gap-1",children:K(q.align)})})]}),G.length>4&&k&&v("div",{className:"from-bg-alt-1 pointer-events-none absolute right-0 bottom-0 left-0 z-[1] h-6 rounded-b-md bg-gradient-to-t to-transparent"})]})]})]}),v($,{className:"min-h-0 flex-1",children:H?v(YR,{selectedObjects:e,selectedNodeTransform:t,nodes:r,robotPose:n,onUpdateNode:f,onChangeNodeType:m,onTransformSelectedNodes:b,onDeleteSelectedNodes:p,onCancelTopologyChanges:y,onSaveTopologyChanges:g}):v(XR,{selectedTool:s,onToolChange:a,selectedNodeType:o,onSelectNodeType:l,selectedNodePlacementType:c,onSelectNodePlacementType:d,onAddNodeAtRobot:h,onAddNodeAtCursor:u,onSaveTopologyChanges:g,onCancelTopologyChanges:y,showRobotPlacement:x})})]})},rc=({label:r,value:e})=>C("div",{className:"flex items-center justify-between gap-2",children:[v("span",{className:"typo-compact-xs-normal text-fg-subtle",children:r}),v("span",{className:"typo-compact-xs-semibold text-fg-default",children:e})]}),tN=r=>{if(!r)return"-";const e=new Date(r);return Number.isNaN(e.getTime())?r:r.slice(0,19).replace("T"," ")},nN=({nodeCount:r=0,linkCount:e,zoneCount:t=0,createdAt:n,downloadDisabled:i=!1,downloadHelpText:s,onDownloadTopology:a,onCancelTopologyChanges:o,onSaveTopologyChanges:l})=>{const{t:c}=tn();return C($,{className:"h-full min-h-0",children:[C($,{className:"min-h-0 flex-1 gap-4 p-3",children:[C($,{className:"gap-2",children:[v("p",{className:"typo-compact-sm-bold text-fg-default",children:c("move.amr.rightPanel.topology.overview.title")}),v("p",{className:"typo-compact-xs-normal text-fg-subtle",children:c("move.amr.rightPanel.topology.overview.description")})]}),C($,{className:"border-subtler bg-fill-control-surface gap-3 rounded-lg border p-3",children:[v("p",{className:"typo-compact-xs-semibold text-fg-default",children:c("move.amr.rightPanel.topology.overview.summaryTitle")}),C($,{className:"gap-2",children:[v(rc,{label:c("move.amr.rightPanel.topology.overview.createdAt"),value:tN(n)}),v(rc,{label:c("move.amr.rightPanel.topology.overview.nodes"),value:r}),v(rc,{label:c("move.amr.rightPanel.topology.overview.links"),value:e??"-"}),v(rc,{label:c("move.amr.rightPanel.topology.overview.zones"),value:t})]})]}),C($,{className:"border-subtler bg-fill-control-surface gap-2 rounded-lg border p-3",children:[v("p",{className:"typo-compact-xs-semibold text-fg-default",children:c("move.amr.rightPanel.topology.overview.fileTitle")}),v("p",{className:"typo-compact-xs-normal text-fg-subtle",children:c("move.amr.rightPanel.topology.overview.fileDescription")}),s&&v("p",{className:"typo-compact-xs-normal text-fg-warning",children:s})]})]}),v(Bo,{cancelLabel:c("move.amr.rightPanel.common.cancel"),saveLabel:c("move.amr.rightPanel.common.save"),onCancel:o,onSave:l,children:v(nt,{variant:"soft",className:"h-9",disabled:i,leadingIcon:v(wy,{}),onClick:a,children:c("move.amr.rightPanel.topology.overview.download")})})]})},{useMemo:ac}=await At("react"),iN=["NO_ENTRY","IGNORE_LIDAR_2D","IGNORE_LIDAR_3D"],sN=({draft:r={state:"idle",editingZoneId:null,selectedVertexIndex:null,name:"",type:"NO_ENTRY",pointCount:0,points:[]},selectedZoneIds:e,focusedZoneId:t,onFocusedZoneChange:n,onDraftStart:i,onDraftCancel:s,onDraftClear:a,onDraftUndo:o,onDraftClose:l,onDraftReopen:c,onDraftCommit:d,onDraftMetaChange:h,zones:u,onEditZone:f,onDeleteZone:m,hasUnsavedTopologyChanges:b=!1,isTopologySaving:p=!1,onSaveTopologyChanges:g,onCancelTopologyChanges:y})=>{const{t:x}=tn(),{confirmDialog:w}=Co({confirmComponent:Po}),P=ac(()=>{if(e.length===0)return[];const be=new Set(e);return u.filter(Ce=>be.has(Ce.id))},[e,u]),T=ac(()=>r.editingZoneId?u.find(be=>be.id===r.editingZoneId)??null:t?P.find(be=>be.id===t)??null:P[0]??null,[r.editingZoneId,t,P,u]),A=ac(()=>r.editingZoneId?u.find(be=>be.id===r.editingZoneId)??null:null,[r.editingZoneId,u]),M=e.length>1,_=ac(()=>M?"multi-select":r.editingZoneId||P.length>0?"edit":"create",[r.editingZoneId,M,P.length]),S=A??T,R=r.state==="idle",k=r.state==="closed",O=r.editingZoneId!==null,H=r.state!=="idle",q=H,G=R&&T!==null,K=r.points.length>0&&!k,V=r.points.length>0&&!k,Z=r.points.length>=3&&!k,le=k,se=b&&!H&&!p,ge=!H&&S===null,de=H?r.name:S?.name??"",X=H?r.type:S?.type??"",ee=x(O?"move.amr.rightPanel.topology.zone.updateZone":"move.amr.rightPanel.topology.zone.createZone");x(O?"move.amr.rightPanel.topology.zone.discardEditContent":"move.amr.rightPanel.topology.zone.discardDraftContent");const ie=x(G?"move.amr.rightPanel.topology.zone.createNewZone":"move.amr.rightPanel.topology.zone.startDrawing"),Y=H,ue=_==="create"&&R,oe=_==="multi-select"?x("move.amr.rightPanel.topology.zone.selectedCount",{count:e.length}):_==="edit"?r.editingZoneId?x("move.amr.rightPanel.topology.zone.editingZone"):x("move.amr.rightPanel.topology.zone.oneSelected"):x("move.amr.rightPanel.topology.zone.createZone");return C($,{className:"h-full min-h-0",children:[C($,{className:"min-h-0 flex-1 gap-3 overflow-y-auto p-3",children:[v(we,{className:"border-subtler gap-1.5 border-b pb-3",children:v($,{className:"gap-0.5",children:v("p",{className:"compact-sm-semibold text-fg-default",children:oe})})}),P.length>0&&!r.editingZoneId&&C(hi,{children:[C($,{className:"gap-2",children:[v("p",{className:"typo-compact-sm2-semibold text-fg-default",children:x("move.amr.rightPanel.topology.zone.selectedZones")}),v($,{className:"border-border-subtle max-h-40 gap-1 overflow-y-auto rounded-md border p-1.5",children:P.map((be,Ce)=>{const je=be.id===T?.id;return C(we,{className:`items-center justify-between rounded-md border px-2 py-1.5 transition-colors ${je?"border-border-default bg-fill-subtler":"border-transparent bg-fill-control-surface hover:border-border-subtle"}`,onClick:()=>{n(be.id)},children:[v("p",{className:"typo-compact-xs-semibold text-fg-default truncate",children:`${Ce+1}. ${be.name||be.id}`}),v("p",{className:"typo-compact-xs-normal text-fg-subtler shrink-0",children:x("move.amr.rightPanel.topology.zone.pointCount",{type:be.type,count:be.polygon.length})})]},be.id)})})]}),v(ts,{})]}),C($,{className:$t("gap-2",ge&&"opacity-50"),children:[v("p",{className:"typo-compact-sm2-semibold text-fg-default",children:x("move.amr.rightPanel.topology.zone.details")}),C($,{className:"gap-1",children:[v("p",{className:"typo-compact-xs-semibold text-fg-default",children:x("move.amr.rightPanel.topology.zone.name")}),q?v(Rn,{className:"w-full",size:"sm",placeholder:x("move.amr.rightPanel.topology.zone.namePlaceholder"),value:de,onChange:be=>{h?.({name:be.target.value})}}):v("div",{className:"border-border-subtle bg-fill-control-surface rounded-md border px-3 py-2",children:v("p",{className:"typo-compact-xs-normal text-fg-default",children:de||"-"})})]}),C($,{className:"gap-1",children:[v("p",{className:"typo-compact-xs-semibold text-fg-default",children:x("move.amr.rightPanel.topology.zone.type")}),q?v("div",{className:"grid grid-cols-1 gap-2",children:iN.map(be=>v(ii,{className:"w-full",name:`topology-zone-type-${be.toLowerCase()}`,checkValue:be,value:X,onChange:Ce=>{Ce.target.checked&&h?.({type:be})},children:be},be))}):v("div",{className:"border-border-subtle bg-fill-control-surface rounded-md border px-3 py-2",children:v("p",{className:"typo-compact-xs-normal text-fg-default",children:X||"-"})})]})]}),v(ts,{})]}),C(Bo,{cancelLabel:x("move.amr.rightPanel.common.discard"),saveLabel:x(p?"move.amr.rightPanel.common.saving":"move.amr.rightPanel.common.saveChanges"),cancelDisabled:!se,saveDisabled:!se,onCancel:async()=>{await w({title:x("move.amr.rightPanel.common.discard"),content:x("move.amr.rightPanel.topology.dialog.discardContent"),buttonText:{yes:x("move.amr.rightPanel.common.discard"),no:x("move.amr.rightPanel.common.keepEditing")}})&&y?.()},onSave:()=>{g?.()},children:[ue&&v(nt,{variant:"soft",className:"text-fg-default py-2",onClick:()=>{i?.({name:r.name,type:r.type})},children:ie}),R&&G&&C(hi,{children:[v(nt,{variant:"soft",className:"text-fg-default py-2",onClick:()=>{f?.(T.id)},children:x("move.amr.rightPanel.topology.zone.editZone")}),v(nt,{variant:"dangerSoft",className:"py-2",onClick:async()=>{await w({title:x("move.amr.rightPanel.topology.zone.deleteZone"),content:x("move.amr.rightPanel.topology.zone.deleteContent"),buttonText:{yes:x("move.amr.rightPanel.common.delete"),no:x("move.amr.rightPanel.topology.zone.keep")}})&&m?.(T.id)},children:x("move.amr.rightPanel.topology.zone.deleteZone")})]}),Y&&C(hi,{children:[C("div",{className:"grid grid-cols-2 gap-2",children:[v(nt,{variant:"outlined",disabled:!K,onClick:o,children:x("move.amr.rightPanel.topology.zone.undoLastPoint")}),v(nt,{variant:"outlined",disabled:!V,onClick:a,children:x("move.amr.rightPanel.topology.zone.clearPoints")})]}),!k&&v(nt,{variant:"dangerSoft",disabled:!Z,onClick:l,children:x("move.amr.rightPanel.topology.zone.closeZone")}),k&&C(hi,{children:[v(nt,{variant:"soft",className:"text-fg-default py-2",onClick:c,children:x(O?"move.amr.rightPanel.topology.zone.reopenZone":"move.amr.rightPanel.topology.zone.reopen")}),v(nt,{variant:"brand",className:"py-2",disabled:!le,onClick:d,children:ee})]})]})]})]})},{memo:rN,useCallback:yh,useEffect:aN,useState:oN}=await At("react"),xh="topology_tab",_h=r=>r==="overview"||r==="node"||r==="link"||r==="zone",lN=[{labelKey:"move.amr.rightPanel.topology.tab.overview",value:"overview"},{labelKey:"move.amr.rightPanel.topology.tab.node",value:"node"},{labelKey:"move.amr.rightPanel.topology.tab.link",value:"link"},{labelKey:"move.amr.rightPanel.topology.tab.zone",value:"zone"}],cN=({className:r,overviewTabProps:e,nodeTabProps:t,linkTabProps:n,zoneTabProps:i})=>{const{theme:s}=Ea(),{t:a}=tn(),{confirmDialog:o}=Co({confirmComponent:Po}),[l,c]=qy(),[d,h]=oN(()=>{const p=l.get(xh)??"";return _h(p)?p:"overview"}),u=i?.draft?.state==="drawing"||i?.draft?.state==="closed",f=yh(async()=>await o({title:"Leave Zone",content:"Leaving the Zone tab will discard the current zone draft. Continue?",buttonText:{yes:"Leave",no:a("move.amr.rightPanel.common.cancel")}})?(i?.onDraftCancel?.(),!0):!1,[o,a,i]),m=yh(async()=>{await o({title:a("move.amr.rightPanel.common.cancel"),content:a("move.amr.rightPanel.topology.dialog.discardContent"),buttonText:{yes:a("move.amr.rightPanel.common.discard"),no:a("move.amr.rightPanel.common.keepEditing")}})&&t?.onCancelTopologyChanges?.()},[o,t,a]),b=yh(async p=>{if(d===p||d==="zone"&&p!=="zone"&&u&&!await f())return;h(p);const g=new URLSearchParams(l);g.set(xh,p),c(g,{replace:!0})},[f,u,l,c,d]);return aN(()=>{const p=l.get(xh)??"",g=_h(p)?p:"overview";h(y=>y!==g?g:y)},[l]),v("div",{className:$t("TopologyControl","h-full",r),children:v("div",{className:"flex h-full min-h-0 gap-0",children:C("div",{className:"flex h-full min-h-0 flex-1 flex-col overflow-x-hidden",children:[v("div",{className:$t("sticky top-0 left-0 z-2",s==="light"?"bg-default":"bg-alt-1"),children:v(Sy,{tabItems:lN.map(p=>({key:p.value,label:a(p.labelKey)})),activeKey:d,handleChange:async p=>{_h(p)&&await b(p)},size:"xs",tabBtnClassName:"typo-compact-xs-bold light:bg-white light:[&.active]:bg-fill-navy! light:[&.active]:text-white!"})}),C($,{className:"min-h-0 flex-1 overflow-y-auto",children:[d==="overview"&&v(nN,{...e,nodeCount:t?.nodes?.length??0,linkCount:n?.links?.length??0,zoneCount:i?.zones?.length??0,onCancelTopologyChanges:m,onSaveTopologyChanges:t?.onSaveTopologyChanges}),d==="node"&&v(eN,{...t}),d==="link"&&v(jR,{...n}),d==="zone"&&v(sN,{...i})]})]})})})},m2=rN(cN),dN=await At("react"),hN={APRILTAG:"AprilTag",ARUCO:"ArUco"},uN={x:"text-fg-danger",y:"text-fg-success",z:"text-fg-brand",rx:"text-fg-danger",ry:"text-fg-success",rz:"text-fg-brand"},na=({label:r,value:e})=>C(we,{className:"items-baseline gap-1",children:[v("span",{className:`typo-compact-xs-semibold ${uN[r]??"text-fg-subtler"}`,children:r}),v("span",{className:"typo-compact-xs-normal text-fg-default font-mono",children:e})]}),fN=({detection:r,isSelected:e,onSelect:t})=>{const n=hN[r.type]??r.type,i=r.confidence!=null?Math.round(r.confidence*100):null,s=r.confidence!=null&&r.confidence>=.85,a=[r.distM!=null?r.distM.toFixed(2)+" m":"—",...(r.camIds?.length?r.camIds:[r.camId]).map(o=>`cam ${o}`)];return v("button",{type:"button",onClick:()=>t(String(r.markerId)),className:$t("w-full rounded-md border text-left transition-all",e?"border-fg-brand bg-fill-brand-subtlest":"bg-fill-disabled hover:bg-fill-subtlest border-transparent"),children:C($,{className:"gap-1 px-3 py-2.5",children:[C(we,{className:"items-center justify-between",children:[C(we,{className:"items-center gap-2",children:[C("span",{className:["typo-compact-lg-semibold",e?"text-fg-brand":"text-fg-default"].join(" "),children:["#",r.markerId]}),v("span",{className:["typo-compact-2xs-semibold rounded-full px-2 py-0.5",e?"bg-fg-brand text-white":"bg-fill-disabled text-fg-subtle"].join(" "),children:n})]}),i!=null&&C("span",{className:["typo-compact-sm-semibold",s?"text-fg-success":"text-fg-caution"].join(" "),children:[i,"%"]})]}),v(we,{className:"items-center gap-1.5",children:a.map((o,l)=>C(dN.Fragment,{children:[l>0&&v("span",{className:"text-fg-subtler",children:"·"}),v("span",{className:"typo-compact-xs-normal text-fg-subtle",children:o})]},o))}),r.pose?C($,{className:"gap-0.5",children:[C(we,{className:"items-center gap-3",children:[v(na,{label:"x",value:r.pose.x.toFixed(3)}),v(na,{label:"y",value:r.pose.y.toFixed(3)}),r.pose.z!=null&&v(na,{label:"z",value:r.pose.z.toFixed(3)})]}),C(we,{className:"items-center gap-3",children:[r.pose.rx!=null&&v(na,{label:"rx",value:`${r.pose.rx.toFixed(1)}°`}),r.pose.ry!=null&&v(na,{label:"ry",value:`${r.pose.ry.toFixed(1)}°`}),v(na,{label:"rz",value:`${r.pose.rz.toFixed(1)}°`})]})]}):v(go,{type:"icon",icon:v(ba,{}),message:"No pose data",className:"py-1"})]})})},{useEffect:pN,useMemo:mN,useState:so}=await At("react"),gN=[{label:"0.04m",value:"0.04"},{label:"0.1m",value:"0.10"},{label:"0.15m",value:"0.15"}],bN=(r,e)=>(r.confidence??0)!==(e.confidence??0)?(r.confidence??0)>(e.confidence??0):r.distM!=null&&e.distM!=null?r.distM<e.distM:r.distM!=null?!0:e.distM!=null?!1:r.camId<e.camId,vN=r=>{const e=new Map,t=new Map;return r.forEach(n=>{const i=t.get(n.markerId)??new Set;i.add(n.camId),n.camIds?.forEach(a=>i.add(a)),t.set(n.markerId,i);const s=e.get(n.markerId);(!s||bN(n,s))&&e.set(n.markerId,n)}),Array.from(e.values()).map(n=>({...n,camIds:Array.from(t.get(n.markerId)??[n.camId]).filter(i=>Number.isFinite(i)).sort((i,s)=>i-s)}))},g2=({mode:r="register",isScanning:e=!1,detections:t=[],onRegisterMarker:n,isRegisterPending:i=!1,lastRegisteredMarkerId:s,registeredMarkers:a=[],capturedPose:o=null,onCapturePose:l,onTeachTarget:c})=>{const{t:d}=tn(),[h,u]=so(""),f=mN(()=>vN(t),[t]);pN(()=>{s!=null&&u("")},[s]);const[m,b]=so("WALL"),[p,g]=so("0.10"),[y,x]=so(null),[w,P]=so(""),T=f.find(H=>String(H.markerId)===h)??null,A=H=>{u(H)},M=()=>{T&&n?.({camId:T.camId,markerId:T.markerId,type:T.type,mount:m,markerSizeM:Number(p)})},_=()=>{!y||!w||(c?.({markerNodeId:y.nodeId,markerId:y.markerId,nodeName:w}),P(""))},S=f.length>0,R=f.map(H=>H.distM).filter(H=>Number.isFinite(H)).sort((H,q)=>H-q)[0],k=R!=null?`${R.toFixed(2)}m`:"-",O=v($,{className:"border-subtler gap-2 border-b p-3",children:C($,{className:"bg-fill-disabled gap-1 rounded-md p-3",children:[C(we,{className:"items-center justify-between gap-3",children:[C(we,{className:"items-center gap-1",children:[v(ba,{className:"text-fg-subtle size-4"}),v("p",{className:"typo-compact-xs2-normal text-fg-subtle",children:d("move.amr.rightPanel.marker.markerStatus")})]}),C(we,{className:"items-center gap-1.5",children:[v(yi,{color:S?"green":"gray"}),v("p",{className:"typo-compact-sm-semibold text-fg-default uppercase",children:S?d("move.amr.rightPanel.marker.foundCount",{count:f.length}):d("move.amr.rightPanel.marker.notFound")})]})]}),C(we,{className:"items-center justify-between gap-3",children:[C(we,{className:"items-center gap-1",children:[v(Kg,{className:"text-fg-subtle size-4"}),v("p",{className:"typo-compact-xs2-normal text-fg-subtle",children:d("move.title.distance")})]}),v("p",{className:"typo-compact-sm-semibold text-fg-default",children:k})]})]})});return r==="register"?C($,{className:"h-full gap-0",children:[O,C($,{className:"flex-1 gap-0 overflow-y-auto",children:[f.length===0?v("div",{className:"p-3 pb-0",children:v(go,{type:"icon",icon:v(Sf,{}),message:d("move.amr.rightPanel.marker.notFound"),className:"bg-fill-disabled rounded-md"})}):v($,{className:"gap-2 p-3 pb-0",children:f.map(H=>v(fN,{detection:H,isSelected:h===String(H.markerId),onSelect:A},H.markerId))}),C($,{className:"gap-3 p-3",children:[C($,{className:"gap-1",children:[v("p",{className:"typo-compact-xs-semibold text-fg-default",children:d("move.amr.rightPanel.marker.markerId")}),v("div",{className:"bg-fill-disabled border-border-subtler flex h-8 items-center rounded-md border px-3",children:v("p",{className:`typo-compact-sm-normal ${T?"text-fg-default":"text-fg-subtler"}`,children:T?`#${T.markerId}`:"—"})})]}),C($,{className:"gap-1",children:[v("p",{className:"typo-compact-xs-semibold text-fg-default",children:d("move.amr.rightPanel.marker.markerType")}),v("div",{className:"bg-fill-disabled border-border-subtler flex h-8 items-center rounded-md border px-3",children:v("p",{className:`typo-compact-sm-normal ${T?"text-fg-default":"text-fg-subtler"}`,children:T?T.type==="ARUCO"?"ArUco":"AprilTag":"—"})})]}),C($,{className:"gap-2",children:[C($,{className:"gap-1",children:[v("p",{className:"typo-compact-xs-semibold text-fg-default",children:d("move.amr.rightPanel.marker.markerSize")}),v(we,{className:"items-center",children:v(Nn,{className:"flex-1",size:"sm",value:p,step:.05,digit:2,fixedDigit:2,min:"0.01",max:"1.00",handleChange:H=>g(H)})})]}),v(we,{className:"gap-2",children:gN.map(H=>v(ii,{className:"flex-1",value:p,checkValue:H.value,unCheckValue:H.value,handleChange:q=>g(q),size:"sm",children:H.label},H.value))})]}),C($,{className:"gap-1",children:[v("p",{className:"typo-compact-xs-semibold text-fg-default",children:d("move.amr.rightPanel.marker.mount")}),C(we,{className:"gap-2",children:[v(ii,{className:"w-full",value:m,checkValue:"WALL",unCheckValue:"WALL",handleChange:H=>b(H),size:"sm",children:d("move.amr.rightPanel.marker.mount.wall")}),v(ii,{className:"w-full",value:m,checkValue:"FLOOR",unCheckValue:"FLOOR",handleChange:H=>b(H),size:"sm",children:d("move.amr.rightPanel.marker.mount.floor")})]})]})]})]}),v("div",{className:"p-3",children:v(nt,{variant:"brand",className:"h-9 w-full",onClick:M,disabled:!T||i,children:T?d("move.amr.rightPanel.marker.registerId",{id:T.markerId}):d("move.amr.rightPanel.marker.registerMarker")})})]}):C($,{className:"h-full gap-0",children:[O,C($,{className:"flex-1 gap-3 overflow-y-auto p-3",children:[C($,{className:"gap-1",children:[v("p",{className:"typo-compact-xs-semibold text-fg-default",children:d("move.amr.rightPanel.marker.targetMarker")}),v(ca,{size:"sm",value:y?String(y.markerId):"",handleChange:H=>{const q=a.find(G=>String(G.markerId)===H);x(q??null)},disabled:a.length===0,children:a.length===0?v(Pi,{value:"",children:d("move.amr.rightPanel.marker.noRegisteredMarkers")}):a.map(H=>C(Pi,{value:String(H.markerId),children:["id ",H.markerId," · ",H.type," · ",H.mount]},H.markerId))})]}),y?.precisionTarget&&(()=>{const H=y.precisionTarget,q=H.context.match(/dock_offset=([^;]+)/)?.[1]?.split(",")??[];return v($,{className:"gap-2",children:v("div",{className:"bg-fill-disabled rounded-md px-3 py-2.5",children:C($,{className:"gap-2",children:[H.nodeName&&v("p",{className:"typo-compact-sm-semibold text-fg-default",children:H.nodeName}),q.length>0&&C($,{className:"gap-0.5",children:[v("p",{className:"typo-compact-2xs-normal text-fg-subtler",children:d("move.amr.rightPanel.marker.dockOffset")}),v("div",{className:"grid grid-cols-3 gap-x-2 gap-y-0.5",children:["x","y","z","rx","ry","rz"].map((G,K)=>C(we,{className:"items-baseline gap-1",children:[v("span",{className:"typo-compact-xs-semibold text-fg-subtle w-4",children:G}),v("span",{className:"typo-compact-xs-normal text-fg-default truncate font-mono",children:q[K]?Number(q[K]).toFixed(3):"—"})]},G))})]})]})})})})(),C($,{className:"gap-1",children:[v("p",{className:"typo-compact-xs-semibold text-fg-default",children:d("move.amr.rightPanel.marker.capturedPose")}),o?v("div",{className:"bg-fill-disabled rounded-md px-3 py-2.5",children:v(we,{className:"items-center gap-3",children:[{label:"x",value:o.x.toFixed(3),color:"text-fg-danger"},{label:"y",value:o.y.toFixed(3),color:"text-fg-success"},{label:"θ",value:`${o.rz.toFixed(1)}°`,color:"text-fg-brand"}].map(({label:H,value:q,color:G})=>C(we,{className:"items-baseline gap-1",children:[v("span",{className:`typo-compact-xs-semibold ${G}`,children:H}),v("span",{className:"typo-compact-xs-normal text-fg-default font-mono",children:q})]},H))})}):v("div",{className:"bg-fill-disabled rounded-md px-3 py-2",children:v(go,{type:"icon",icon:v(Sf,{}),message:d("move.amr.rightPanel.marker.moveRobotThenCapture"),className:"py-1"})}),v(nt,{size:"xs2",variant:"soft",leadingIcon:v(ba,{}),onClick:l,disabled:!y,children:d("move.amr.rightPanel.marker.captureCurrentPose")})]}),C($,{className:"gap-1",children:[v("p",{className:"typo-compact-xs-semibold text-fg-default",children:d("move.amr.rightPanel.marker.targetName")}),v(Rn,{className:"w-full",size:"sm",placeholder:d("move.amr.rightPanel.marker.targetNamePlaceholder"),value:w,onChange:H=>P(H.target.value)})]})]}),v("div",{className:"p-3",children:v(nt,{variant:"brand",className:"h-9 w-full",onClick:_,disabled:!y||!w||!o,children:d("move.amr.rightPanel.marker.saveTarget")})})]})},{useEffect:yN}=await At("react"),xN={KeyV:"select",KeyT:"target",KeyG:"move",KeyR:"rotate",KeyS:"scale"},Ng=r=>{if(!(r instanceof HTMLElement))return!1;if(r.isContentEditable)return!0;const e=r.tagName.toLowerCase();if(e==="textarea"||e==="select")return!0;if(e==="input"){const n=r.type.toLowerCase();return n===""||n==="text"||n==="search"||n==="email"||n==="password"||n==="number"||n==="tel"||n==="url"}return!!r.closest("textarea, select, [contenteditable='true'], input:not([type]), input[type='text'], input[type='search'], input[type='email'], input[type='password'], input[type='number'], input[type='tel'], input[type='url']")},b2=({enabled:r=!0,tools:e,topology:t,selection:n,camera:i,link:s,zone:a})=>{const{enabled:o=!0,selectedTool:l,onToolChange:c,hasSelectedNode:d=!0,hasSelectedZone:h=!1}=e,u=t?.enabled??!0,f=!!t,m=t?.selectedNodePlacementType,b=t?.onAddNodeAtRobot,p=t?.onAddNodeAtCursor,g=n?.enabled??!0,y=!!n,x=n?.hasSelectedNodes??!1,w=n?.hasSelectedLinks??!1,P=n?.hasSelectedZones??!1,T=n?.onDeleteSelectedNodes,A=n?.onDeleteSelectedLinks,M=n?.onDeleteSelectedZones,_=i?.enabled??!0,S=!!i,R=i?.hasSelectedNode??!1,k=i?.onFocusSelectedNode,O=s?.enabled??!0,H=!!s,q=s?.selectedNodeCount??0,G=s?.onCreateLinks,K=a?.enabled??!0,V=!!a,Z=a?.state,le=a?.pointCount??0,se=a?.onCloseDraft;yN(()=>{if(!r)return;const ge=(oe,be)=>{o&&(l==="disabled"&&be!=="select"&&be!=="target"||h&&(be==="rotate"||be==="scale")||l!==be&&(oe.preventDefault(),c(be)))},de=oe=>{if(!(!f||!u)){if(m==="robot"){oe.preventDefault(),b?.();return}l==="target"&&(oe.preventDefault(),p?.())}},X=oe=>{if(!(!y||!g)){if(x){oe.preventDefault(),T?.();return}if(w){oe.preventDefault(),A?.();return}P&&(oe.preventDefault(),M?.())}},ee=oe=>{!S||!_||!R||(oe.preventDefault(),k?.())},ie=oe=>{!H||!O||q<2||(oe.preventDefault(),G?.())},Y=oe=>{!V||!K||Z!=="drawing"||le<3||(oe.preventDefault(),se?.())},ue=oe=>{if(!(Ng(oe.target)||Ng(document.activeElement))&&!oe.repeat&&!(oe.metaKey||oe.ctrlKey||oe.altKey||oe.shiftKey))switch(oe.code){case"Escape":Y(oe);return;case"KeyN":de(oe);return;case"Delete":case"Backspace":X(oe);return;case"KeyF":ee(oe);return;case"KeyL":ie(oe);return;case"KeyV":case"KeyT":case"KeyG":case"KeyR":case"KeyS":{const be=xN[oe.code];if(!be)return;ge(oe,be);return}default:return}};return window.addEventListener("keydown",ue),()=>{window.removeEventListener("keydown",ue)}},[r,_,S,R,H,y,w,d,h,x,P,f,V,p,b,A,T,M,k,G,se,c,m,q,l,g,o,u,O,Z,K,le])},{useState:_N,useCallback:wN}=await At("react"),v2=()=>{const[r,e]=_N("select"),t=wN(n=>{e(n)},[]);return{selectedTool:r,onToolChange:t}},{useEffect:Dg,useRef:Lg,useState:SN}=await At("react"),Ig=.5,MN=520;function y2({anchorObject:r,anchorWorldPosition:e,worldStudioRef:t,viewportHostRef:n,horizontalPlacementBoundary:i=MN}){const[s,a]=SN(null),o=Lg(null),l=Lg(null);return Dg(()=>{const c=()=>{const m=n.current,b=t.current?.getCanvas();o.current=m?.getBoundingClientRect()??null,l.current=b?.getBoundingClientRect()??null};c();const d=n.current,h=t.current?.getCanvas(),u=new ResizeObserver(()=>{c()});d&&u.observe(d),h&&u.observe(h);const f=()=>{c()};return window.addEventListener("resize",f),window.addEventListener("scroll",f,!0),document.addEventListener("fullscreenchange",f),()=>{u.disconnect(),window.removeEventListener("resize",f),window.removeEventListener("scroll",f,!0),document.removeEventListener("fullscreenchange",f)}},[n,t]),Dg(()=>{if(!r&&!e){a(null);return}let c=0;const d=new I,h=new I,u=()=>{const f=t.current?.getCanvas(),m=t.current?.getCamera(),b=n.current;if(!f||!m||!b){a(A=>A===null?A:null),c=requestAnimationFrame(u);return}if(m.updateMatrixWorld(),r)r.updateMatrixWorld(),r.getWorldPosition(h);else if(e)h.copy(e);else{a(A=>A===null?A:null),c=requestAnimationFrame(u);return}d.copy(h).project(m);const p=o.current,g=l.current;if(!p||!g){a(A=>A===null?A:null),c=requestAnimationFrame(u);return}const y=(d.x+1)/2*g.width,x=(-d.y+1)/2*g.height,w=y+g.left-p.left,P=x+g.top-p.top,T=Number.isFinite(w)&&Number.isFinite(P)&&d.z>=-1&&d.z<=1&&w>=0&&w<=p.width&&P>=0&&P<=p.height;a(A=>{if(!T)return A===null?A:null;const M={x:w,y:P,placement:w>p.width-i?"left":"right"};return A&&Math.abs(A.x-M.x)<Ig&&Math.abs(A.y-M.y)<Ig&&A.placement===M.placement?A:M}),c=requestAnimationFrame(u)};return u(),()=>{cancelAnimationFrame(c)}},[r,e,i,n,t]),s}const{useEffect:TN,useMemo:ia,useRef:EN,useState:ci}=await At("react"),x2=(r,e=!1)=>{const{t}=tn(),[n,i]=ci(!0),[s,a]=ci(!1),[o,l]=ci(!1),[c,d]=ci(!1),[h,u]=ci(!1),[f,m]=ci(!0),[b,p]=ci(!0),[g,y]=ci(!1),[x,w]=ci(_u),[P,T]=ci(Kb),[A,M]=ci(!1),[_,S]=ci(0),[R,k]=ci(0),[O,H]=ci("topView"),q=EN(!1);TN(()=>{!r||q.current||(S(r.minZ),k(r.maxZ))},[r]);const G=ia(()=>[{id:"lidarPoints",label:t(e?"move.amr.rightPanel.capability.lidar2d":"move.amr.viewportControls.visibility.lidarPoints"),description:t("move.amr.viewportControls.visibility.lidarPointsDescription"),checked:f,onCheckedChange:m},...e?[{id:"lidar3DPoints",label:t("move.amr.rightPanel.capability.lidar3d"),description:t("move.amr.viewportControls.visibility.lidarPointsDescription"),checked:b,onCheckedChange:p}]:[],{id:"simpleNodes",label:t("move.amr.viewportControls.visibility.simpleNodes"),description:t("move.amr.viewportControls.visibility.simpleNodesDescription"),checked:h,onCheckedChange:u},{id:"nodeLabels",label:t("move.amr.viewportControls.visibility.nodeLabels"),description:t("move.amr.viewportControls.visibility.nodeLabelsDescription"),checked:c,onCheckedChange:d},{id:"grid",label:t("move.amr.viewportControls.visibility.grid"),description:t("move.amr.viewportControls.visibility.gridDescription"),checked:n,onCheckedChange:i},{id:"mapBoundary",label:t("move.amr.viewportControls.visibility.mapBoundary"),description:t("move.amr.viewportControls.visibility.mapBoundaryDescription"),checked:g,onCheckedChange:y}],[n,f,b,e,g,c,h,t]),K=ia(()=>({label:t("move.amr.viewportControls.camera.projection"),description:t("move.amr.viewportControls.camera.projectionDescription"),value:O,items:[{label:t("move.amr.viewportControls.camera.topView"),value:"topView",description:t("move.amr.viewportControls.camera.topViewDescription")},{label:t("move.amr.viewportControls.camera.perspective"),value:"perspective",description:t("move.amr.viewportControls.camera.perspectiveDescription")}],onChange:ge=>{H(ge)}}),[t,O]),V=ia(()=>({sectionLabel:t("move.amr.viewportControls.section.manualCamera"),label:t("move.amr.viewportControls.camera.move"),description:t("move.amr.viewportControls.camera.moveDescription")}),[t]),Z=ia(()=>[{id:"mapPointSize",label:`${t("move.amr.rightPanel.map.info.pointCloud")} ${t("settings.tool.title.size")}`,value:P,min:.01,max:.3,step:.01,digit:2,onChange:T},{id:"lidarPointSize",label:t("move.amr.viewportControls.rendering.lidarPointSize"),description:t("move.amr.viewportControls.rendering.lidarPointSizeDescription"),value:x,min:.01,max:.5,step:.01,digit:2,onChange:w}],[x,P,t]),le=ia(()=>({enabled:A,minZ:_,maxZ:R,bounds:r?{minZ:r.minZ,maxZ:r.maxZ}:void 0,onEnabledChange:M,onMinZChange:ge=>{q.current=!0,S(ge)},onMaxZChange:ge=>{q.current=!0,k(ge)},onReset:()=>{q.current=!1,r&&(S(r.minZ),k(r.maxZ)),M(!1)}}),[A,r,R,_]),se=ia(()=>A?{minZ:_,maxZ:R}:null,[A,R,_]);return{showGrid:n,setShowGrid:i,showJoysticks:s,setShowJoysticks:a,showViewControls:o,setShowViewControls:l,showNodeLabels:c,setShowNodeLabels:d,showSimpleNodes:h,setShowSimpleNodes:u,showLidar:f,setShowLidar:m,showLidar3D:b,setShowLidar3D:p,showMapBoundary:g,setShowMapBoundary:y,lidarPointSize:x,setLidarPointSize:w,mapPointSize:P,setMapPointSize:T,viewportCameraMode:O,visibilityItems:G,cameraModeControl:K,cameraMoveControl:V,renderingSettingItems:Z,mapPointHeightClip:se,pointCloudHeightClipControl:le}},{useMemo:AN}=await At("react"),_2=({loading:r,isDefaultData:e,mapCloud:t,topology:n,nodes:i,links:s})=>AN(()=>{const a=!r&&!e,o=t?.rowCount??t?.data?.length??0,l=i?.length??n?.nodes?.length??0,c=s?.length??n?.links?.length??0;return{isLive:a,pointCount:o,latency:0,fps:0,nodeCount:l,linkCount:c}},[e,r,t?.data?.length,t?.rowCount,s?.length,i?.length,n?.links?.length,n?.nodes?.length]),{useCallback:wh}=await At("react"),w2=()=>{const r=wh((n,i,s)=>{const a=new Blob([i],{type:s?.mimeType}),o=window.URL.createObjectURL(a),l=document.createElement("a");l.href=o,l.download=n,l.click(),window.URL.revokeObjectURL(o)},[]),e=wh((n,i)=>{const s=JSON.stringify(i,null,2)??"";r(n,s,{mimeType:"application/json"})},[r]),t=wh((n,i)=>{const s=i.map(a=>a.map(o=>o??"").join(",")).join(`
|
|
4752
|
+
);}.moving-dot{position:absolute;left:50%;top:0.5rem;width:0.5rem;height:0.5rem;transform:translateX(-50%);border-radius:9999px;background:var(--color-fg-default);box-shadow:0 0 0.625rem color-mix(in srgb, var(--color-fg-default) 95%, transparent),0 0 1.25rem color-mix(in srgb, var(--color-fg-information) 70%, transparent);animation:`,r=>r.isMoving?"drop-down 4s ease-in-out infinite, sparkle 0.65s ease-in-out infinite":"none",";}@keyframes drop-down{0%{top:0.25rem;opacity:0.2;}5%{opacity:1;}90%{opacity:0.9;}100%{top:calc(100% - 0.75rem);opacity:0.1;}}@keyframes sparkle{0%{filter:brightness(0.9);}50%{filter:brightness(1.35);}100%{filter:brightness(0.9);}}"),Cv=({className:r,items:e,latestIndex:t=0,latestIndexes:n,compact:i=!1,showResult:s=!i})=>{const{t:a}=tn();return e.length?v(PR,{className:$t("gap-2",r),children:e.map((o,l)=>{const c=n?n.includes(l):l===t,d=l===0,h=l===e.length-1;return C("div",{className:"relative flex items-start gap-3 rounded-md px-2 py-1.5",children:[v(RR,{isFirst:d,isLast:h,children:v(NR,{isLatest:c})}),C($,{className:"min-w-0 flex-1 gap-0.5",children:[C("div",{className:"flex min-h-5 items-center justify-between gap-1.5",children:[v("span",{className:$t("typo-compact-xs2-semibold truncate font-mono",c?"text-fg-information":"text-fg-default"),children:o.message||"-"}),c?v("span",{className:"bg-fill-information typo-compact-2xs-semibold text-fg-inverse rounded-lg px-1.5 py-0.5",children:a("move.amr.rightPanel.history.latest")}):null]}),!i&&C(hi,{children:[C("div",{className:"flex items-center justify-between gap-2",children:[v("span",{className:"typo-compact-2xs-medium text-fg-subtler",children:a("move.amr.rightPanel.history.time")}),v("span",{className:"typo-compact-xs-normal text-fg-subtle truncate",children:ly(o.createdAt,"YYYY-MM-DD HH:mm:ss")})]}),C("div",{className:"flex items-center justify-between gap-2",children:[v("span",{className:"typo-compact-2xs-medium text-fg-subtler",children:a("move.amr.rightPanel.history.command")}),v("span",{className:"typo-compact-xs-normal text-fg-subtle truncate",children:o.command||"-"})]})]}),s&&C("div",{className:"flex items-center justify-between gap-2",children:[v("span",{className:"typo-compact-2xs-medium text-fg-subtler",children:a("move.amr.rightPanel.history.result")}),v("span",{className:$t("typo-compact-xs-normal",{"text-fg-success":o.result==="success","text-fg-danger":o.result==="fail","text-fg-information":o.result==="start","text-fg-disabled":o.result==="cancel","text-fg-subtle":o.result!=="success"&&o.result!=="fail"&&o.result!=="start"&&o.result!=="cancel"}),children:o.result||"-"})]})]})]},`${o.createdAt}-${o.command}-${l}`)})}):v("div",{className:r,children:v("span",{className:"typo-compact-xs2-normal text-fg-subtle",children:a("move.amr.rightPanel.history.noHistory")})})},PR=Nc($,{target:"edynay22"})({name:"bjn8wh",styles:"position:relative"}),RR=Nc("div",{target:"edynay21"})('position:relative;width:0.875rem;min-width:0.875rem;align-self:stretch;&::before{content:"";position:absolute;left:50%;transform:translateX(-50%);width:1px;background:rgba(148, 163, 184, 0.45);top:',r=>r.isFirst?"0.75rem":"-0.625rem",";",r=>r.isLast?`height: ${r.isFirst?"0":"1.375rem"}; bottom: unset;`:"bottom: -0.625rem;",";}"),NR=Nc("span",{target:"edynay20"})("position:absolute;top:0.5rem;left:50%;width:0.5rem;height:0.5rem;transform:translateX(-50%);border-radius:9999px;background:",r=>r.isLatest?"rgb(59 130 246)":"rgb(107 114 128)",";box-shadow:",r=>r.isLatest?"0 0 0.5rem rgba(59, 130, 246, 0.9), 0 0 1rem rgba(59, 130, 246, 0.55)":"none",";animation:",r=>r.isLatest?"latest-pulse 1.2s ease-in-out infinite":"none",";@keyframes latest-pulse{0%{opacity:0.45;transform:translateX(-50%) scale(0.8);}50%{opacity:1;transform:translateX(-50%) scale(1);}100%{opacity:0.5;transform:translateX(-50%) scale(0.85);}}"),{useEffect:DR,useMemo:Mg,useState:LR}=await At("react"),IR=[{createdAt:"2026-03-19T10:12:41Z",message:"Move Goal: NODE_A-12",command:"goal",result:"success"},{createdAt:"2026-03-19T10:11:03Z",message:"Move Linear: 0.8m",command:"xLinear",result:"start"},{createdAt:"2026-03-19T10:09:36Z",message:"Move Rotate: 90.0deg",command:"rotate",result:"cancel"},{createdAt:"2026-03-19T10:08:02Z",message:"Move Target: 12.5, 4.1, 0.0",command:"target",result:"fail"}],kR=r=>r.toUpperCase().replace("_"," "),Tg=r=>{if(!r)return"-";const e=new Date(r);if(Number.isNaN(e.getTime()))return r;const t=n=>String(n).padStart(2,"0");return`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())} ${t(e.getHours())}:${t(e.getMinutes())}:${t(e.getSeconds())}`},OR=(r,e)=>{const t=new Date(r).getTime(),n=new Date(e).getTime();return Number.isNaN(t)||Number.isNaN(n)||n<t?0:Math.floor((n-t)/1e3)},Eg=r=>{if(!r)return null;const e=new Date(r).getTime();return Number.isNaN(e)?null:e},FR=r=>{const e=Math.max(0,Math.floor(r)),t=Math.floor(e/3600),n=Math.floor(e%3600/60),i=e%60;return t>0?`${t}h ${n}m ${i}s`:`${n}m ${i}s`},UR=r=>{if(r.command==="goal")return`Move Goal: ${r.goalId||r.goalName}`;if(r.command==="rotate")return`Move Rotate: ${r.target?.toFixed(1)??0}deg`;if(r.command==="target"){const e=r.goalPose;return e?`Move Target: ${e.x?.toFixed(3)??0}, ${e.y?.toFixed(3)??0}, ${e.z?.toFixed(3)??0}`:r.message||"Move Target: -"}return r.command==="circular"?`Move Circular: ${r.target?.toFixed(1)??0}deg`:`Move Linear: ${r.target?.toFixed(1)??0}m`},BR=r=>{if(!r?.items?.length)return;const e=r.items[0],t=r.items;return{status:e.status||"",createdAt:e.createdAt||"",updatedAt:e.updateAt||"",goalNode:e.goalName||e.goalId||"",currentNode:e.goalName||e.goalId||"",estimatedDuration:0,actualDuration:OR(e.createdAt,e.updateAt),previousNodes:t.map(n=>({createdAt:n.createdAt,message:UR(n),command:n.command,result:n.result}))}},d2=({logData:r,moveStatus:e})=>{const{t}=tn(),[n,i]=LR(()=>Date.now()),s=BR(r),a=s?.status??"",o=a?kR(a):t("move.amr.rightPanel.task.idle"),l=s?.previousNodes??[],c=l.length?l:IR,d=e?.goalNode?.name||e?.goalNode?.id||s?.goalNode||"N/A",h=e?.curNode?.name||e?.curNode?.id||s?.currentNode||"N/A",u=a==="in_progress"||a==="move"||a==="vir";DR(()=>{if(!u)return;const b=window.setInterval(()=>{i(Date.now())},1e3);return()=>{window.clearInterval(b)}},[u]);const f=Mg(()=>{const b=Eg(s?.createdAt),p=Eg(s?.updatedAt);if(b!==null){if(u)return Math.max(0,Math.floor((n-b)/1e3));if(p!==null&&p>=b)return Math.floor((p-b)/1e3)}return typeof s?.actualDuration=="number"&&s.actualDuration>=0?Math.floor(s.actualDuration):0},[u,n,s?.actualDuration,s?.createdAt,s?.updatedAt]),m=Mg(()=>FR(f),[f]);return C($,{className:"h-full min-h-0",children:[C($,{className:"border-subtler gap-1.5 border-b p-3",children:[C("div",{className:"flex items-center justify-between",children:[v("div",{className:"typo-compact-xs-normal text-fg-subtler",children:t("move.amr.rightPanel.task.status")}),C("div",{className:"flex flex-row items-center gap-2",children:[v(yi,{color:a!==""?"blue":"gray",className:a!==""?"animate-pulse":void 0}),v("div",{className:"typo-compact-xs-semibold text-fg-default",children:o})]})]}),C("div",{className:"flex items-center justify-between",children:[v("div",{className:"typo-compact-xs-normal text-fg-subtler",children:t("move.amr.rightPanel.common.created")}),v("div",{className:"typo-compact-xs-normal text-fg-subtle",children:Tg(s?.createdAt)})]}),C("div",{className:"flex items-center justify-between",children:[v("div",{className:"typo-compact-xs-normal text-fg-subtler",children:t("move.amr.rightPanel.task.lastUpdated")}),v("div",{className:"typo-compact-xs-normal text-fg-subtle",children:Tg(s?.updatedAt)})]})]}),v("div",{className:"border-subtler border-b p-3",children:C($,{className:"bg-raised space-y-2 rounded p-2",children:[v(AR,{currentNode:h,targetNode:d,moveStatus:a}),v("div",{className:"border-subtler border-b"}),C(we,{className:"justify-between",children:[v("span",{className:"typo-compact-xs-normal text-fg-subtler",children:t("move.amr.rightPanel.task.duration")}),v("span",{className:"typo-compact-xs-normal text-fg-default",children:m})]})]})}),C($,{className:"border-subtler min-h-0 gap-1.5 border-b p-3",children:[C(we,{className:"space-x-1.5",children:[v("span",{className:"typo-compact-sm2-semibold text-fg-default",children:t("move.amr.rightPanel.task.pathHistory")}),v("span",{className:"typo-compact-sm2-normal text-fg-subtle",children:c.length})]}),v(Cv,{items:c,className:"min-h-0 flex-1 overflow-y-auto"})]})]})},{useEffect:io,useRef:ea,useState:ph}=await At("react"),Ag=[{key:"docking",label:"move.amr.rightPanel.dock.step.docking"},{key:"checkCharge",label:"move.amr.rightPanel.dock.step.checkCharge"},{key:"complete",label:"move.amr.rightPanel.dock.step.complete"}],h2=({amrStatus:r,isPaused:e,onDock:t=()=>{},onUndock:n=()=>{},onStop:i=()=>{},onPause:s=()=>{},onResume:a=()=>{},maxRetryCount:o,onOpenRetrySettings:l=()=>{},dockDisabled:c=!1,rejectMessage:d})=>{const{t:h}=tn(),[u,f]=ph(!1),[m,b]=ph(!1),[p,g]=ph(new Set),y=ea(!1),x=ea(!1),w=ea(!1),P=ea(""),T=ea(!1),A=ea(!1),M=r?.chargeState?.charge??"none",_=r?.chargeState?.dockResult??"",S=r?.chargeState?.dock??!1,R=M.toLowerCase(),k=_.toLowerCase(),O=k==="move",H=k==="fail",q=R!=="none"&&M!=="",G=R==="charging",K=R==="battery_on",V=u||O||K,Y=!V&&S,le=h(V?"move.amr.rightPanel.dock.status.move":Y?"move.amr.rightPanel.dock.status.dock":"move.amr.rightPanel.dock.status.undocked"),se=V?"blue":Y?"green":"red",ge=O&&!K&&!G,de=[...u&&!O?["pointDock"]:[],...ge?["docking"]:[],...K?["checkCharge"]:[],...G?["complete"]:[]],X=Ag.map(Fe=>({message:h(Fe.label),result:p.has(Fe.key)?"success":void 0})),ee=de.map(Fe=>Ag.findIndex(j=>j.key===Fe)).filter(Fe=>Fe>=0);io(()=>{const Fe=y.current;y.current=G,!(!G||Fe||T.current)&&(f(!1),g(j=>{const Ke=new Set(j);return Ke.add("pointDock"),Ke.add("docking"),Ke.add("checkCharge"),Ke.add("complete"),Ke}))},[G]),io(()=>{const Fe=x.current;x.current=K,!(!K||Fe||T.current)&&g(j=>{const Ke=new Set(j);return Ke.add("pointDock"),Ke.add("docking"),Ke})},[K]),io(()=>{const Fe=w.current;w.current=O,!(!O||Fe||T.current)&&g(j=>{const Ke=new Set(j);return Ke.add("pointDock"),Ke})},[O]),io(()=>{const Fe=P.current;P.current=k,!(k!=="fail"||Fe==="fail")&&(f(!1),g(new Set))},[k]);const ie=()=>{P.current="",g(new Set),f(!1),b(!1),T.current=!1,A.current=!1};io(()=>{if(m){if(O){A.current=!0;return}A.current&&(A.current=!1,b(!1),T.current=!1)}},[m,O]);const Z=()=>{ie(),f(!0),t()},ue=()=>{ie(),i()},oe=()=>{s()},be=()=>{a()},Ce=()=>{ie(),b(!0),T.current=!0,n()},je=()=>C($,{className:"gap-2",children:[C("div",{className:"grid grid-cols-2 gap-2",children:[v(nt,{variant:"successSoft",onClick:Z,disabled:c,children:h("move.amr.rightPanel.dock.action.dock")}),v(nt,{variant:"dangerSoft",onClick:Ce,disabled:c,children:h("move.amr.rightPanel.dock.action.undock")})]}),V&&C($,{className:"gap-1.5",children:[v("p",{className:"typo-compact-xs-semibold text-fg-default",children:h("move.amr.rightPanel.dock.operation.motion")}),C("div",{className:"grid grid-cols-2 gap-2",children:[v(nt,{variant:"dangerSoft",leadingIcon:v(zg,{className:"size-3"}),disabled:m,onClick:ue,children:h("move.amr.rightPanel.common.stop")}),e?v(nt,{variant:"soft",leadingIcon:v(dy,{className:"size-3"}),disabled:m,onClick:be,children:h("move.amr.rightPanel.dock.action.resume")}):v(nt,{variant:"soft",leadingIcon:v(hy,{className:"size-3"}),disabled:m,onClick:oe,children:h("move.amr.rightPanel.dock.action.pause")})]})]})]});return C(hi,{children:[C($,{className:"border-subtler gap-2.5 border-b p-3",children:[v("p",{className:"typo-compact-sm2-semibold text-fg-default",children:h("move.amr.rightPanel.dock.operation.title")}),C($,{className:"gap-2 rounded",children:[C("div",{className:"bg-fill-disabled grid grid-cols-2 gap-x-3 rounded-md px-3 py-3",children:[C($,{className:"gap-0.5",children:[v("p",{className:"typo-compact-2xs-normal text-fg-subtler",children:h("move.amr.rightPanel.dock.operation.dock")}),C(we,{className:"items-center gap-1.5",children:[v(yi,{color:se,className:V||Y?"animate-pulse":void 0}),v("p",{className:"typo-compact-xs2-medium text-fg-default",children:le})]})]}),C($,{className:"gap-0.5",children:[v("p",{className:"typo-compact-2xs-normal text-fg-subtler",children:h("move.amr.rightPanel.dock.operation.charge")}),v("p",{className:"typo-compact-xs2-medium text-fg-default uppercase",children:q?M:h("move.amr.rightPanel.common.none")})]})]}),je(),C(we,{className:"items-start gap-1",children:[v("div",{className:"flex size-4 shrink-0 items-center justify-center",children:v(Cu,{className:"text-fg-subtlest size-3"})}),v("p",{className:"typo-compact-xs-normal text-fg-subtler flex-1",children:h("move.amr.rightPanel.dock.operation.description")})]})]})]}),C($,{className:"border-subtler gap-2 border-b p-3",children:[v("p",{className:"typo-compact-sm2-semibold text-fg-default",children:h("move.amr.rightPanel.dock.status.title")}),v(Cv,{items:X,latestIndexes:m?[]:ee,compact:!0})]}),C($,{className:"border-subtler gap-2 border-b p-2.5",children:[C(we,{className:"items-center justify-between self-stretch",children:[C(we,{className:"flex-1 items-center gap-1.5",children:[v("p",{className:"typo-compact-sm2-semibold text-fg-default",children:h("move.amr.rightPanel.dock.retryCount")}),H&&v("span",{className:"typo-compact-2xs-semibold bg-fill-danger text-fg-inverse rounded-lg px-1.5 py-0.5",children:h("move.amr.rightPanel.common.fail")})]}),C("button",{type:"button",className:"hover:bg-fill-hovered flex h-5 items-center gap-0.5 rounded-sm px-1.5",onClick:l,children:[v(Yg,{className:"text-fg-default size-3"}),v("span",{className:"text-fg-default text-[10px] leading-3 font-semibold",children:h("move.amr.rightPanel.common.settings")})]})]}),d&&C(we,{className:"border-danger bg-fill-danger-subtlest mt-1 items-start gap-2 rounded-md border px-3 py-2.5",children:[v(cy,{className:"text-fg-danger mt-0.5 size-4 shrink-0"}),v("p",{className:"typo-compact-xs-semibold text-fg-danger",children:d})]}),v("div",{className:"bg-fill-control-surface-disabled outline-border-disabled inline-flex h-9 w-full items-center overflow-hidden rounded-md px-2.5 outline outline-1 outline-offset-[-1px]",children:o!==void 0?v("p",{className:"text-fg-default text-sm leading-5",children:o}):v("p",{className:"text-fg-subtler text-sm leading-5",children:"—"})})]})]})},{useEffect:zR,useState:mh}=await At("react"),{createPortal:HR}=await At("react-dom"),GR=r=>{const e=Math.floor(r/3600).toString().padStart(2,"0"),t=Math.floor(r%3600/60).toString().padStart(2,"0"),n=Math.floor(r%60).toString().padStart(2,"0");return`${e}:${t}:${n}`},u2=({onOpenChange:r,open:e,close:t,onSaveMapping:n,completedKeyframeCount:i=0,totalKeyframePoints:s=0,durationSeconds:a=0,existingMapNames:o=[]})=>{const{t:l}=tn(),[c,d]=mh(""),[h,u]=mh(!1),[f,m]=mh(""),b=async()=>{const y=c.trim();if(!y){m(l("move.amr.rightPanel.map.saveDialog.error.required"));return}if(i<=0){m(l("move.amr.rightPanel.map.mapping.keyframeRequired"));return}if(y.length<3){m(l("move.amr.rightPanel.map.saveDialog.error.minLength"));return}if(!/^[a-zA-Z0-9가-힣_-]+$/.test(y)){m(l("move.amr.rightPanel.map.saveDialog.error.invalidChars"));return}if(o.includes(y)){m(l("move.amr.rightPanel.map.saveDialog.error.duplicateName",{name:y}));return}u(!0),m("");try{const x=await n(y);if(x.ok){d(""),p();return}"reason"in x&&x.reason==="load-failed"?m(l("move.amr.rightPanel.map.saveDialog.error.loadFailed")):m(l("move.amr.rightPanel.map.saveDialog.error.saveFailed"))}catch{m(l("move.amr.rightPanel.map.saveDialog.error.saveError"))}finally{u(!1)}},p=()=>{h||(d(""),m(""),t?.(),r?.(!1))};if(zR(()=>{e||(d(""),m(""),u(!1))},[e]),!e)return null;const g=C($,{className:"fixed inset-0 z-50 items-center justify-center p-4",children:[v("button",{type:"button","aria-label":l("move.amr.rightPanel.map.saveDialog.closeBackdrop"),className:"bg-bg-dim absolute inset-0",onClick:p}),C($,{className:"bg-bg-overlay relative w-full max-w-xl overflow-hidden rounded-lg p-4",children:[v($,{className:"shrink-0 gap-0.5 p-1",children:C(we,{className:"items-start justify-between",children:[C($,{className:"gap-0.5",children:[v("p",{className:"typo-compact-lg-semibold text-fg-default",children:l("move.amr.rightPanel.map.saveDialog.title")}),v("p",{className:"typo-compact-xs-normal text-fg-subtler",children:l("move.amr.rightPanel.map.saveDialog.description")})]}),v(Kn,{variant:"transparent",size:"2xs",icon:v(Ao,{}),className:"text-fg-subtle",onClick:p,disabled:h})]})}),C($,{className:"gap-3 p-1 pt-3",children:[C($,{className:"gap-1.5",children:[v("p",{className:"typo-compact-xs-semibold text-fg-default",children:l("move.amr.rightPanel.map.info.mapName")}),v(Rn,{type:"text",value:c,placeholder:l("move.amr.rightPanel.map.saveDialog.placeholder"),disabled:h,autoFocus:!0,className:"w-full",onChange:y=>{d(y.target.value),m("")},onKeyDown:y=>{y.key==="Enter"&&!h&&b()}}),v("p",{className:"typo-compact-2xs-normal text-fg-subtler",children:l("move.amr.rightPanel.map.saveDialog.nameRule")})]}),f&&v(we,{className:"bg-bg-danger-tertiary outline-border-danger rounded-md p-2.5 outline outline-1 outline-offset-[-1px]",children:v("p",{className:"typo-compact-xs-normal text-fg-danger",children:f})}),C($,{className:"bg-bg-alt-1 gap-1 rounded-md p-2.5",children:[C(we,{className:"items-center justify-between",children:[v("p",{className:"typo-compact-2xs-normal text-fg-subtler",children:l("move.amr.rightPanel.map.mapping.keyframesReceived")}),v("p",{className:"typo-compact-2xs-semibold text-fg-information",children:i.toLocaleString()})]}),C(we,{className:"items-center justify-between",children:[v("p",{className:"typo-compact-2xs-normal text-fg-subtler",children:l("move.amr.rightPanel.map.mapping.keyframePoints")}),v("p",{className:"typo-compact-2xs-semibold text-fg-default",children:l("move.amr.rightPanel.map.mapping.points",{count:s.toLocaleString()})})]}),C(we,{className:"items-center justify-between",children:[v("p",{className:"typo-compact-2xs-normal text-fg-subtler",children:l("move.amr.rightPanel.task.duration")}),v("p",{className:"typo-compact-2xs-semibold text-fg-default",children:GR(a)})]})]})]}),C(we,{className:"shrink-0 items-center justify-end gap-2 p-1 pt-3",children:[v(nt,{variant:"outlined",onClick:p,disabled:h,children:l("move.amr.rightPanel.common.cancel")}),v(nt,{variant:"brand",onClick:b,disabled:h||!c.trim()||i<=0,children:l(h?"move.amr.rightPanel.common.saving":"move.amr.rightPanel.map.saveDialog.saveMap")})]})]})]});return typeof window>"u"?g:HR(g,document.body)},{useEffect:VR}=await At("react"),f2=({isEraserEnabled:r=!1,onEraserToggle:e=()=>{},eraserRadius:t=1,setEraserRadius:n=()=>{},eraseSelectedAreaDisabled:i=!1,onEraseSelectedArea:s=()=>{},onReleaseSelectedPoints:a=()=>{},onSaveChanges:o=()=>{}})=>{const{t:l}=tn();return VR(()=>()=>{e(!1)},[e]),C($,{className:"h-full justify-between overflow-y-auto",children:[C($,{children:[C($,{className:"gap-0.5 px-3 pt-3",children:[C(we,{className:"justify-between",children:[v("p",{className:"typo-compact-sm2-semibold text-fg-default",children:l("move.amr.rightPanel.map.erasing.eraseMode")}),v(wr,{size:"default",checked:r,onCheckedChange:()=>e(!r)})]}),C("p",{className:"typo-compact-xs-normal text-fg-subtler",children:[l("move.amr.rightPanel.map.erasing.descriptionLine1"),v("br",{}),l("move.amr.rightPanel.map.erasing.descriptionLine2")]})]}),C($,{className:"gap-2 p-3",children:[C(we,{className:"justify-between",children:[v("p",{className:"typo-compact-xs2-normal text-fg-default",children:l("move.amr.rightPanel.map.erasing.eraserRadius")}),C("p",{className:"typo-compact-xs2-normal text-fg-default",children:[t.toFixed(1)," m"]})]}),v(Rc,{min:0,max:5,step:.1,value:[t],onValueChange:c=>n(c[0]),disabled:!r})]}),C($,{className:"border-border-subtler gap-2 border-b-[1px] px-3 pb-3",children:[v(nt,{size:"xs2",variant:"soft",leadingIcon:v(uy,{className:"size-3.5"}),disabled:!r||i,onClick:s,children:l("move.amr.rightPanel.map.erasing.eraseSelectedArea")}),v(nt,{size:"xs2",variant:"soft",leadingIcon:v(fy,{className:"size-3.5"}),disabled:!r,onClick:a,children:l("move.amr.rightPanel.map.erasing.releaseSelectedPoints")})]})]}),v($,{className:"p-3",children:v(nt,{variant:"brand",size:"sm",onClick:o,disabled:!r,children:l("move.amr.rightPanel.common.saveChanges")})})]})},{useCallback:Cg,useRef:WR}=await At("react"),Pv={bidirectional:!0,mode:"sequential",properties:{dir:"FORWARD",method:"PP",speed:0,avoidRange:0,safetyField:0,slowMarginX:0,slowMarginY:0,stopMarginX:0,stopMarginY:0}},p2=()=>{const r=WR(Pv),e=Cg(n=>{r.current=n},[]),t=Cg(n=>{const{bidirectional:i,mode:s,properties:a}=r.current;n(i,s,a)},[]);return{setLinkCreationSettings:e,createLinks:t}},Bo=({children:r,cancelLabel:e,saveLabel:t,onCancel:n,onSave:i,cancelDisabled:s=!1,saveDisabled:a=!1})=>C($,{className:"border-subtler sticky bottom-0 z-1 gap-2 border-t p-3",children:[r,C("div",{className:"grid grid-cols-2 gap-2",children:[v(nt,{variant:"outlined",className:"h-9",disabled:s,onClick:n,children:e}),v(nt,{variant:"brand",className:"h-9",disabled:a,onClick:i,children:t})]})]}),{useEffect:ic,useMemo:ta,useState:Ei}=await At("react"),zt=Pv.properties,Tu=["PP","HPP","TNG","SIDE"],Pg=r=>Tu.includes(r),Bs=(r,e,t,n)=>{if(!r||r.trim()==="")return n;const i=Number(r);return Number.isNaN(i)?n:Math.min(t,Math.max(e,i))},vi=r=>r.toFixed(2),jR=({selectedObjects:r,focusedLinkId:e,linkVisibilityFilter:t,nodes:n,visibleSelectedLinks:i,onFocusedLinkChange:s,onLinkVisibilityFilterChange:a,onToolChange:o,onCreateLinks:l,onLinkCreationSettingsChange:c,onUpdateLink:d,onDeleteLink:h,onDeleteLinksBetweenSelected:u,onCancelTopologyChanges:f,onSaveTopologyChanges:m})=>{const{confirmDialog:b}=Co({confirmComponent:Po}),{t:p}=tn(),[g,y]=Ei("sequential"),[x,w]=Ei("bidirectional"),[P,T]=Ei(zt.dir),[A,M]=Ei(zt.method),[_,S]=Ei(String(zt.speed)),[R,k]=Ei(String(zt.avoidRange)),[O,H]=Ei(String(zt.safetyField)),[q,G]=Ei(vi(zt.slowMarginX)),[K,V]=Ei(vi(zt.slowMarginY)),[Y,le]=Ei(vi(zt.stopMarginX)),[se,ge]=Ei(vi(zt.stopMarginY)),[de,X]=Ei(!1);ic(()=>{o?.("select")},[o]);const ee=ta(()=>r.map(W=>{const ae=n.find(ve=>ve.uuid===W.uuid);return{id:W.uuid,name:ae?.name||W.name||W.uuid,mesh:W}}),[n,r]),ie=ta(()=>i.map(W=>{const ae=n.find(ce=>ce.id===W.from),ve=n.find(ce=>ce.id===W.to);return{...W,fromName:ae?.name??W.from,toName:ve?.name??W.to}}),[n,i]),Z=i.length>0,ue=i.length,oe=ta(()=>e?i.find(W=>W.id===e)??null:null,[e,i]),be=W=>{W!=="all"&&W!=="forward"&&W!=="reverse"||a({...t,dir:W})},Ce=W=>{W!=="all"&&!Pg(W)||a({...t,method:W})},je=ta(()=>ie.find(W=>W.id===oe?.id)??null,[oe?.id,ie]);ic(()=>{if(!Z){T(zt.dir),M(zt.method),S(String(zt.speed)),k(String(zt.avoidRange)),H(String(zt.safetyField)),G(vi(zt.slowMarginX)),V(vi(zt.slowMarginY)),le(vi(zt.stopMarginX)),ge(vi(zt.stopMarginY)),X(!1);return}},[Z]),ic(()=>{oe&&(T(oe.dir),M(oe.method),S(String(oe.speed)),k(String(oe.avoidRange)),H(String(oe.safetyField)),G(vi(oe.slowMarginX??zt.slowMarginX)),V(vi(oe.slowMarginY??zt.slowMarginY)),le(vi(oe.stopMarginX??zt.stopMarginX)),ge(vi(oe.stopMarginY??zt.stopMarginY)),X(!1))},[oe]);const Fe=ta(()=>{const W=ee.length;if(W<2)return p("move.amr.rightPanel.topology.link.selectAtLeastTwo");if(W===2){const[ce,Oe]=ee,Pe=x==="bidirectional"?" ↔ ":" → ";return p("move.amr.rightPanel.topology.link.willCreateNamed",{from:ce.name,connector:Pe,to:Oe.name})}const ae=g==="sequential"?W-1:W*(W-1)/2,ve=x==="bidirectional"?ae*2:ae;return p("move.amr.rightPanel.topology.link.willCreateCount",{count:ve})},[g,x,ee,p]),j=ta(()=>({dir:P,method:A,speed:Bs(_,-1,1,zt.speed),avoidRange:Bs(R,-1,1.2,zt.avoidRange),safetyField:Bs(O,-1,Number.MAX_SAFE_INTEGER,zt.safetyField),slowMarginX:Bs(q,-1,1,zt.slowMarginX),slowMarginY:Bs(K,-1,1,zt.slowMarginY),stopMarginX:Bs(Y,-1,1,zt.stopMarginX),stopMarginY:Bs(se,-1,1,zt.stopMarginY)}),[R,P,A,O,q,K,_,Y,se]),Ke=W=>{ee.length<2||l?.(W,g,j)},Ue=()=>{oe&&d?.(oe.id,j)},Te=()=>{oe&&h?.(oe.id)},Se=W=>ae=>{if(X(!0),Number(ae)<0){W("-1");return}W(ae)},et=W=>ae=>{X(!0),W(ae)},Be=W=>ae=>{W(vi(Bs(ae,-1,1,0)))},N=ee.length>=2,E=Z?"edit":"add";return ic(()=>{E==="add"&&c?.({bidirectional:x==="bidirectional",mode:g,properties:j})},[g,x,j,E,c]),C($,{className:"h-full min-h-0 overflow-hidden",children:[C($,{className:"min-h-0 flex-1 overflow-x-hidden overflow-y-auto",children:[C(we,{className:"border-subtler gap-1.5 border-b p-3",children:[v(Pu,{className:"text-fg-default"}),C($,{className:"gap-0.5",children:[v("p",{className:"compact-sm-semibold text-fg-default",children:E==="edit"?`${ue} link${ue>1?"s":""} selected`:p("move.amr.rightPanel.topology.link.nodeSelectedCount",{count:ee.length})}),v("p",{className:"typo-compact-xs-normal text-fg-subtle",children:E==="edit"?ue>1?"Select one link from the list below to edit.":"Review and update the selected link.":p("move.amr.rightPanel.topology.link.selectAtLeastTwoShort")})]})]}),E==="edit"&&C($,{className:"border-subtler gap-1.5 border-b p-3",children:[v("p",{className:"typo-compact-xs-semibold text-fg-default",children:"Link Filter"}),C("div",{className:"grid grid-cols-2 gap-2",children:[C($,{className:"gap-1",children:[v("p",{className:"typo-compact-xs-normal text-fg-subtler",children:"Direction"}),C(ca,{size:"sm",value:t.dir,handleChange:be,children:[v(Pi,{value:"all",children:"All"}),v(Pi,{value:"forward",children:"Forward"}),v(Pi,{value:"reverse",children:"Reverse"})]})]}),C($,{className:"gap-1",children:[v("p",{className:"typo-compact-xs-normal text-fg-subtler",children:"Method"}),C(ca,{size:"sm",value:t.method,handleChange:Ce,children:[v(Pi,{value:"all",children:"All"}),Tu.map(W=>v(Pi,{value:W,children:W},W))]})]})]})]}),E==="add"&&C(hi,{children:[C($,{className:"border-subtler gap-2 border-b p-3",children:[v("p",{className:"typo-compact-sm2-semibold text-fg-default",children:p("move.amr.rightPanel.topology.link.creationMode")}),C("div",{className:"grid grid-cols-2 gap-2",children:[C(ii,{name:"topology-link-mode-sequential",className:"w-full",checkValue:"sequential",value:g,disabled:ee.length<3,onChange:W=>{W.target.checked&&y("sequential")},children:[p("move.amr.rightPanel.topology.link.sequential"),v("br",{}),"(1→2→3)"]}),C(ii,{name:"topology-link-mode-complete",className:"w-full",checkValue:"complete",value:g,disabled:ee.length<3,onChange:W=>{W.target.checked&&y("complete")},children:[p("move.amr.rightPanel.topology.link.complete"),v("br",{}),"(all↔all)"]})]}),v("p",{className:"typo-compact-xs-normal text-fg-subtler",children:p("move.amr.rightPanel.topology.link.modeAvailable")})]}),C($,{className:"border-border-subtler gap-2 border-b p-3",children:[v("p",{className:"typo-compact-sm2-semibold text-fg-default",children:p("move.amr.rightPanel.topology.link.direction")}),C("div",{className:"grid grid-cols-2 gap-2",children:[v(ii,{name:"topology-link-direction-bidirectional",className:"w-full",checkValue:"bidirectional",value:x,disabled:!N,onChange:W=>{W.target.checked&&w("bidirectional")},children:p("move.amr.rightPanel.topology.link.bidirectional")}),v(ii,{name:"topology-link-direction-unidirectional",className:"w-full",checkValue:"unidirectional",value:x,disabled:!N,onChange:W=>{W.target.checked&&w("unidirectional")},children:p("move.amr.rightPanel.topology.link.unidirectional")})]}),v("p",{className:"typo-compact-xs-normal text-fg-subtler",children:p("move.amr.rightPanel.topology.link.configureDirection")})]})]}),E==="edit"&&C($,{className:"border-subtler gap-3 border-b p-3",children:[C($,{className:"gap-1",children:[v("p",{className:"typo-compact-sm2-semibold text-fg-default",children:"Selected Links"}),v("p",{className:"typo-compact-xs-normal text-fg-subtler",children:ue>1?"Choose one link to load its properties into the editor.":"The selected link is ready to edit."})]}),v($,{className:"border-border-subtle max-h-40 gap-1 overflow-y-auto rounded-md border p-1.5",children:ie.map((W,ae)=>C(we,{className:`items-center justify-between rounded-md border px-2 py-1.5 transition-colors ${W.id===oe?.id?"border-border-default bg-fill-subtler":"bg-fill-control-surface hover:border-border-subtle border-transparent"}`,onClick:()=>{s(W.id)},children:[v("p",{className:"typo-compact-xs-semibold text-fg-default truncate",children:`${ae+1}. ${W.fromName} -> ${W.toName}`}),v("p",{className:"typo-compact-xs-normal text-fg-subtler shrink-0",children:`${W.method} / ${W.dir}`})]},W.id))})]}),C($,{className:`border-subtler gap-2 border-b p-3 ${E==="add"&&!N?"opacity-50":""}`,children:[v("p",{className:"typo-compact-sm2-semibold text-fg-default",children:p("move.amr.rightPanel.topology.link.properties")}),C($,{className:"gap-2",children:[v("p",{className:"typo-compact-xs-semibold text-fg-default",children:p("move.amr.rightPanel.topology.link.dir")}),C("div",{className:"grid grid-cols-2 gap-2",children:[v(ii,{name:"topology-link-dir-forward",className:"w-full",checkValue:"FORWARD",value:P,disabled:E==="add"?!N:!oe,onChange:W=>{W.target.checked&&(X(!0),T("FORWARD"))},children:"FORWARD"}),v(ii,{name:"topology-link-dir-reverse",className:"w-full",checkValue:"REVERSE",value:P,disabled:E==="add"?!N:!oe,onChange:W=>{W.target.checked&&(X(!0),T("REVERSE"))},children:"REVERSE"})]})]}),C($,{className:"gap-2",children:[v("p",{className:"typo-compact-xs-semibold text-fg-default",children:p("move.amr.rightPanel.topology.link.method")}),v(ca,{size:"sm",value:A,disabled:E==="add"?!N:!oe,handleChange:W=>{Pg(W)&&(X(!0),M(W))},children:Tu.map(W=>v(Pi,{value:W,children:W},W))})]}),C("div",{className:"grid grid-cols-2 gap-2",children:[C($,{className:"gap-1",children:[C(we,{className:"typo-compact-xs-medium gap-1",children:[v("p",{className:"text-fg-default",children:p("move.amr.rightPanel.common.speed")}),v("p",{className:"text-fg-subtle",children:"(max 1.0)"})]}),v(Nn,{className:"w-full",value:_,step:.1,increaseStep:Number(_)<0?1:.1,min:-1,max:1,disabled:E==="add"?!N:!oe,handleChange:Se(S)})]}),C($,{className:"gap-1",children:[C(we,{className:"typo-compact-xs-medium gap-1",children:[v("p",{className:"text-fg-default",children:p("move.amr.rightPanel.topology.link.avoidRange")}),v("p",{className:"text-fg-subtle",children:"(max 1.2)"})]}),v(Nn,{className:"w-full",value:R,step:.1,increaseStep:Number(R)<0?1:.1,min:-1,max:1.2,disabled:E==="add"?!N:!oe,handleChange:Se(k)})]})]}),C($,{className:"gap-1",children:[v("p",{className:"typo-compact-xs-semibold text-fg-default",children:p("move.amr.rightPanel.topology.link.safetyField")}),v(Nn,{className:"w-full",value:O,step:1,min:-1,disabled:E==="add"?!N:!oe,handleChange:W=>{X(!0),H(W)}})]}),C($,{className:"gap-2",children:[C(we,{className:"typo-compact-xs-medium gap-1",children:[v("p",{className:"text-fg-default",children:"Slow Margin"}),v("p",{className:"text-fg-subtle",children:"(max 1.0)"})]}),C("div",{className:"grid grid-cols-2 gap-2",children:[C($,{className:"gap-1",children:[v("p",{className:"typo-compact-xs-normal text-fg-subtler",children:"X"}),v(Nn,{className:"w-full",value:q,step:.01,fixedDigit:2,increaseStep:Number(q)<0?1:.01,decreaseStep:Number(q)<=0?1:.01,min:-1,max:1,disabled:E==="add"?!N:!oe,handleChange:et(G),onBlur:()=>{Be(G)(q)}})]}),C($,{className:"gap-1",children:[v("p",{className:"typo-compact-xs-normal text-fg-subtler",children:"Y"}),v(Nn,{className:"w-full",value:K,step:.01,fixedDigit:2,increaseStep:Number(K)<0?1:.01,decreaseStep:Number(K)<=0?1:.01,min:-1,max:1,disabled:E==="add"?!N:!oe,handleChange:et(V),onBlur:()=>{Be(V)(K)}})]})]})]}),C($,{className:"gap-2",children:[C(we,{className:"typo-compact-xs-medium gap-1",children:[v("p",{className:"text-fg-default",children:"Stop Margin"}),v("p",{className:"text-fg-subtle",children:"(max 1.0)"})]}),C("div",{className:"grid grid-cols-2 gap-2",children:[C($,{className:"gap-1",children:[v("p",{className:"typo-compact-xs-normal text-fg-subtler",children:"X"}),v(Nn,{className:"w-full",value:Y,step:.01,fixedDigit:2,increaseStep:Number(Y)<0?1:.01,decreaseStep:Number(Y)<=0?1:.01,min:-1,max:1,disabled:E==="add"?!N:!oe,handleChange:et(le),onBlur:()=>{Be(le)(Y)}})]}),C($,{className:"gap-1",children:[v("p",{className:"typo-compact-xs-normal text-fg-subtler",children:"Y"}),v(Nn,{className:"w-full",value:se,step:.01,fixedDigit:2,increaseStep:Number(se)<0?1:.01,decreaseStep:Number(se)<=0?1:.01,min:-1,max:1,disabled:E==="add"?!N:!oe,handleChange:et(ge),onBlur:()=>{Be(ge)(se)}})]})]})]})]})]}),v(Bo,{cancelLabel:p("move.amr.rightPanel.common.cancel"),saveLabel:p("move.amr.rightPanel.common.save"),onCancel:async()=>{await b({title:p("move.amr.rightPanel.common.cancel"),content:p("move.amr.rightPanel.topology.dialog.discardContent"),buttonText:{yes:p("move.amr.rightPanel.common.discard"),no:p("move.amr.rightPanel.common.keepEditing")}})&&f?.()},onSave:m,children:C($,{className:"border-subtler border-b p-3",children:[v("p",{className:"typo-compact-xs-normal text-fg-subtle text-center",children:E==="edit"?je?`${je.fromName} -> ${je.toName} is selected for editing.`:"Select a link from the list above to edit.":Fe}),v("p",{className:"typo-compact-xs-normal text-fg-subtler pt-1 text-center",children:E==="edit"?oe?`dir ${j.dir} / method ${j.method} / speed ${j.speed.toFixed(1)} / avoid ${j.avoidRange.toFixed(1)}`:"":p("move.amr.rightPanel.topology.link.previewProperties",{dir:j.dir,method:j.method,speed:j.speed.toFixed(1),avoid:j.avoidRange.toFixed(1)})}),v($,{className:"gap-2 pt-3",children:E==="edit"?C(hi,{children:[v(nt,{variant:"soft",className:"text-fg-default py-2",disabled:!oe||!de,onClick:Ue,children:"Update selected link"}),v(nt,{variant:"dangerSoft",onClick:Te,disabled:!oe,leadingIcon:v(Mh,{}),children:"Delete selected link"})]}):C(hi,{children:[v(nt,{variant:"soft",className:"text-fg-default py-2",disabled:ee.length<2,onClick:()=>{Ke(x==="bidirectional")},children:p("move.amr.rightPanel.topology.link.linkSelected")}),v(nt,{variant:"dangerSoft",onClick:u,disabled:ee.length<2,leadingIcon:v(Mh,{}),children:p("move.amr.rightPanel.topology.link.deleteLinks")})]})})]})})]})},XR=({selectedTool:r="select",onToolChange:e,selectedNodeType:t="goal",onSelectNodeType:n,selectedNodePlacementType:i="cursor",onSelectNodePlacementType:s,onAddNodeAtRobot:a,onAddNodeAtCursor:o,onSaveTopologyChanges:l,onCancelTopologyChanges:c,showRobotPlacement:d=!0})=>{const{confirmDialog:h}=Co({confirmComponent:Po}),{t:u}=tn(),f=r==="target";return C($,{className:"h-full min-h-0 gap-0",children:[C($,{className:"min-h-0 flex-1 overflow-y-auto",children:[C($,{className:"border-subtler gap-0.5 border-b p-3",children:[v("p",{className:"typo-compact-sm2-semibold text-fg-default",children:u("move.amr.rightPanel.topology.add.title")}),v("p",{className:"typo-compact-xs-normal text-fg-subtler",children:u("move.amr.rightPanel.topology.add.description")})]}),C($,{className:"border-subtler gap-2 border-b p-3",children:[v("p",{className:"typo-compact-sm2-semibold text-fg-default",children:u("move.amr.rightPanel.topology.add.selectNodeType")}),C("div",{className:"grid grid-cols-3 gap-2",children:[v(ii,{className:"w-full",name:"topology-node-type-goal",checkValue:"goal",value:t,onChange:m=>{m.target.checked&&n?.("goal")},children:u("move.amr.rightPanel.topology.nodeType.goal")}),v(ii,{className:"w-full",name:"topology-node-type-route",checkValue:"route",value:t,onChange:m=>{m.target.checked&&n?.("route")},children:u("move.amr.rightPanel.topology.nodeType.route")}),v(ii,{className:"w-full",name:"topology-node-type-align",checkValue:"align",value:t,onChange:m=>{m.target.checked&&n?.("align")},children:u("move.amr.rightPanel.topology.nodeType.align")})]})]}),C($,{className:"border-subtler gap-2 border-b p-3",children:[v("p",{className:"typo-compact-sm2-semibold text-fg-default",children:u("move.amr.rightPanel.topology.add.selectPlacement")}),C(we,{className:"items-center justify-between gap-2 py-1",children:[C($,{className:"gap-0.5",children:[v("p",{className:"typo-compact-sm2-semibold text-fg-default",children:"Cursor Preview"}),v("p",{className:"typo-compact-2xs-normal text-fg-subtler",children:"Enable cursor placement mode before adding at cursor position."})]}),v(wr,{checked:f,onCheckedChange:m=>{if(m){e?.("target");return}r==="target"&&e?.("select")}})]}),C($,{className:"gap-2",children:[v(ii,{className:"w-full",name:"topology-node-placement-cursor",checkValue:"cursor",value:i,onChange:m=>{m.target.checked&&s?.("cursor")},children:u("move.amr.rightPanel.topology.add.atCursorPosition")}),d&&v(ii,{className:"w-full",name:"topology-node-placement-robot",checkValue:"robot",value:i,onChange:m=>{m.target.checked&&s?.("robot")},children:u("move.amr.rightPanel.topology.add.atRobotPosition")})]})]})]}),v(Bo,{cancelLabel:u("move.amr.rightPanel.common.cancel"),saveLabel:u("move.amr.rightPanel.common.save"),onCancel:async()=>{await h({title:u("move.amr.rightPanel.common.cancel"),content:u("move.amr.rightPanel.topology.dialog.discardContent"),buttonText:{yes:u("move.amr.rightPanel.common.discard"),no:u("move.amr.rightPanel.common.keepEditing")}})&&c?.()},onSave:l,children:C(nt,{variant:"soft",className:"text-fg-default",onClick:()=>{if(i==="robot"){a?.();return}if(r!=="target"){py.openToast({type:"basic",variant:"warning",title:"Cursor Preview Disabled",content:"Turn on cursor placement mode before adding a node at cursor position.",position:"top-right"});return}o?.()},children:[u("move.amr.rightPanel.topology.add.addNode")," (N)"]})})]})},{useEffect:gh,useMemo:Rg,useRef:bh,useState:bs}=await At("react"),vh=["INIT","CHARGING","AUTO_DOOR","ARUCO","APRIL","V_MARKER","TAPE","PRECISION","SCAN_MATCH"],Ai=r=>Number(r.toFixed(3)),Rv=-1,Nv=31,qR=r=>{const e=r.trim();if(!/^-?\d+$/.test(e))return null;const t=Number(e);return Number.isInteger(t)?Math.min(Nv,Math.max(Rv,t)):null},ZR=r=>{const e=r.toLowerCase().replace("init","goal");return e==="route"||e==="align"?e:"goal"},YR=({selectedObjects:r=[],selectedNodeTransform:e=null,nodes:t=[],robotPose:n=null,onUpdateNode:i,onChangeNodeType:s,onTransformSelectedNodes:a,onDeleteSelectedNodes:o,onCancelTopologyChanges:l,onSaveTopologyChanges:c})=>{const{confirmDialog:d}=Co({confirmComponent:Po}),{t:h}=tn(),[u,f]=bs(""),[m,b]=bs([]),[p,g]=bs("0"),[y,x]=bs("0.0"),[w,P]=bs("0.0"),[T,A]=bs("0.0"),[M,_]=bs("0.0"),[S,R]=bs(!1),[k,O]=bs("1"),H=bh({altKey:!1,metaKey:!1,ctrlKey:!1}),q=bh(null),G=bh(!1);gh(()=>{const N=W=>{H.current={altKey:W.altKey,metaKey:W.metaKey,ctrlKey:W.ctrlKey}},E=()=>{H.current={altKey:!1,metaKey:!1,ctrlKey:!1},q.current=null};return window.addEventListener("keydown",N),window.addEventListener("keyup",N),window.addEventListener("blur",E),()=>{window.removeEventListener("keydown",N),window.removeEventListener("keyup",N),window.removeEventListener("blur",E)}},[]);const K=Rg(()=>r.map(N=>{const E=t.find(W=>W.uuid===N.uuid);return{uuid:N.uuid,externalId:String(N.userData?.id??""),name:N.name,type:ZR(E?.type||N.userData?.type||"goal"),features:Array.isArray(N.userData?.features)?N.userData.features.filter(W=>typeof W=="string"&&vh.includes(W)):[],safetyField:typeof N.userData?.safetyField=="number"?N.userData.safetyField:E?.safetyField??0,x:N.position.x,y:N.position.y,z:N.position.z,rz:Ai(N.rotation.z*180/Math.PI)}}),[t,r]),V=K[K.length-1],Y=K.length===1,le=Rg(()=>{if(!n)return null;const N=Number(n.x),E=Number(n.y),W=Number(n.rz);return[N,E,W].some(ae=>Number.isNaN(ae))?null:{x:Ai(N),y:Ai(E),rz:Ai(W)}},[n]);gh(()=>{f(V?.name??""),b(V?.features??[]),g(String(V?.safetyField??0))},[V?.uuid,V?.name,V?.features,V?.safetyField]),gh(()=>{let N=null;e?N={x:e.x,y:e.y,z:e.z,rz:e.rz}:V&&(N={x:V.x,y:V.y,z:V.z,rz:V.rz}),x(String(Ai(N?.x??0))),P(String(Ai(N?.y??0))),A(String(Ai(N?.z??0))),_(String(Ai(N?.rz??0)))},[V,V?.uuid,V?.x,V?.y,V?.z,V?.rz,e]);const se=(N,E)=>{i?.(N,E)},ge=N=>N.filter(E=>typeof E=="string"&&vh.includes(E)),de=(N,E)=>{N==="x"&&x(E),N==="y"&&P(E),N==="z"&&A(E)},X=(N,E)=>{if(N==="x"||N==="y"||N==="z"){de(N,E);return}_(E)},ee=N=>{const E=r[r.length-1];return E?N==="x"?E.position.x:N==="y"?E.position.y:N==="z"?E.position.z:Ai(E.rotation.z*180/Math.PI):0},ie=(N=H.current)=>N.altKey?"delta":N.metaKey||N.ctrlKey?"absolute":"single",Z=()=>q.current??ie(),ue=(N,E)=>{q.current=ie({altKey:E?.altKey,metaKey:E?.metaKey,ctrlKey:E?.ctrlKey})},oe=()=>{q.current=null},be=N=>{G.current=N.metaKey||N.ctrlKey},Ce=(N,E,W)=>{const ae=W?N.features.includes(E)?N.features:[...N.features,E]:N.features.filter(ve=>ve!==E);se(N.uuid,{features:ae})},je=(N,E)=>{if(!V||!Array.isArray(E))return;const W=ge(E),ae=W.includes(N),ve=G.current;if(G.current=!1,b(W),ve){for(const ce of K)Ce(ce,N,ae);return}se(V.uuid,{features:W})},Fe=(N,E,W)=>{if(!V)return;const ae=W?Z():ie(),ve=Number(E);if(Number.isNaN(ve))return;const ce=Ai(ve),Oe=String(ce);if(N==="x"||N==="y"||N==="z"?de(N,Oe):_(Oe),ae==="delta"){const Pe=Ai(W?(W==="up"?1:-1)*(Number(k)||1):ce-ee(N));a?.(N,Pe,"delta");return}if(ae==="absolute"){a?.(N,ce,"absolute");return}if(N==="x"||N==="y"||N==="z"){se(V.uuid,{[N]:ce});return}se(V.uuid,{rz:ce})},j=(N,E,W)=>{if(W){Fe(N,E,W);return}X(N,E)},Ke=(N,E)=>{Fe(N,E)},Ue=(N,E)=>{if(!V)return;const W=E?Z():ie(),ae=qR(N);if(ae===null)return;const ve=String(ae);if(g(ve),W==="absolute"){for(const ce of K)se(ce.uuid,{safetyField:ae});return}se(V.uuid,{safetyField:ae})},Te=N=>{V&&/^-?\d*$/.test(N)&&g(N)},Se=(N,E)=>{if(E){Ue(N,E);return}Te(N)},et=N=>{Ue(N)},Be=()=>{!Y||!le||(x(String(le.x)),P(String(le.y)),_(String(le.rz)),se(V.uuid,le))};return C($,{className:"h-full min-h-0 overflow-hidden",children:[C($,{className:"min-h-0 flex-1 overflow-x-hidden overflow-y-auto",children:[C($,{className:"border-subtler gap-3 border-b p-3",children:[C(we,{className:"items-center justify-between gap-2",children:[v("p",{className:"typo-compact-sm2-semibold text-fg-default",children:h("move.amr.rightPanel.topology.edit.nodeProperties")}),K.length>1&&C("p",{className:"typo-compact-2xs-semibold text-fg-subtler",children:[K.length," selected"]})]}),C($,{className:"gap-1.5",children:[v("p",{className:"typo-compact-xs-semibold text-fg-default",children:h("move.amr.rightPanel.topology.edit.nodeId")}),C(we,{className:"items-center gap-1.5",children:[v("p",{className:"typo-compact-xs-normal text-fg-subtler flex-1",children:V?.externalId??""}),V?.externalId&&v("button",{className:"text-fg-subtler hover:text-fg-default shrink-0",onClick:()=>{gy({text:V.externalId??""})},children:v(my,{className:"size-3.5"})})]})]}),C($,{className:"gap-1.5",children:[v("p",{className:"typo-compact-xs-semibold text-fg-default",children:h("move.amr.rightPanel.topology.edit.name")}),v(Rn,{className:"w-full",type:"text",value:u,onChange:N=>{if(!V)return;const E=N.target.value;f(E),se(V.uuid,{name:E})}})]}),C($,{className:"gap-1",children:[v("p",{className:"typo-compact-xs-semibold text-fg-default",children:h("move.amr.rightPanel.topology.edit.nodeType")}),C(ca,{size:"sm",value:V?.type??"goal",disabled:!Y,handleChange:N=>{!V||!Y||N!==V.type&&(N==="goal"||N==="route"||N==="align")&&s?.(V.uuid,N)},children:[v(Pi,{value:"goal",children:h("move.amr.rightPanel.topology.nodeType.goal")}),v(Pi,{value:"route",children:h("move.amr.rightPanel.topology.nodeType.route")}),v(Pi,{value:"align",children:h("move.amr.rightPanel.topology.nodeType.align")})]}),v("p",{className:"typo-compact-2xs-normal text-fg-subtler",children:h(Y?"move.amr.rightPanel.topology.edit.nodeTypeUnavailable":"move.amr.rightPanel.topology.edit.nodeTypeSingleSelect")})]}),C($,{className:"gap-1.5",children:[C(we,{className:"items-center gap-1",children:[v("p",{className:"typo-compact-xs-semibold text-fg-default",children:h("move.amr.rightPanel.topology.link.safetyField")}),v("p",{className:"text-fg-subtle typo-compact-2xs-normal",children:"(-1 ~ 31)"})]}),v(Nn,{className:"w-full",value:p,step:1,min:Rv,max:Nv,handleChange:(N,E,W)=>{Se(N,W?.type)},handleEnter:N=>{et(N)},onButtonPointerDown:ue,onButtonPointerUp:oe})]})]}),v("div",{className:"border-subtler border-b",children:v(wf,{title:v("p",{className:"typo-compact-sm2-semibold text-fg-default",children:h("move.amr.rightPanel.topology.edit.features")}),children:v("div",{className:"grid grid-cols-2 gap-x-2 gap-y-2",children:vh.map(N=>v(by,{className:"[&_[data-slot=checkbox-surface]]:border-border-default [&_[data-slot=checkbox-surface]]:bg-fill-control-surface [&_[data-slot=checkbox-surface]]:shadow-none",name:`topology-feature-${V?.uuid??""}`,checkValue:N,value:m,onClick:be,handleChange:E=>{je(N,E)},children:v("span",{className:"typo-compact-xs-normal text-fg-default",children:N})},N))})})}),v("div",{className:"border-subtler border-b",children:C(wf,{initialOpen:!0,title:C(we,{className:"w-full items-center justify-between",children:[v("p",{className:"typo-compact-sm2-semibold text-fg-default",children:h("move.amr.rightPanel.topology.edit.transform")}),C(we,{className:"text-fg-default items-center gap-0.5",children:[v(nt,{variant:"transparent",size:"2xs",leadingIcon:v(Yg,{}),onClick:N=>{N.preventDefault(),N.stopPropagation(),R(E=>!E)},children:h("move.amr.rightPanel.topology.edit.stepSize")}),v("div",{className:`overflow-hidden transition-all duration-200 ease-out ${S?"w-32 opacity-100":"pointer-events-none w-0 opacity-0"}`,children:v(Nn,{className:"h-8 w-32",value:k,step:.1,handleChange:N=>{O(N)}})})]})]}),children:[C($,{className:"gap-2 pt-1",children:[C($,{className:"gap-1",children:[C(we,{className:"typo-compact-xs-medium gap-1",children:[v("p",{className:"text-fg-danger",children:"X"}),v("p",{className:"text-fg-subtle",children:"(m)"})]}),v(Nn,{className:"w-full",value:y,step:Number(k)||1,handleChange:(N,E,W)=>{j("x",N,W?.type)},handleEnter:N=>{Ke("x",N)},onButtonPointerDown:ue,onButtonPointerUp:oe})]}),C($,{className:"gap-1",children:[C(we,{className:"typo-compact-xs-medium gap-1",children:[v("p",{className:"text-fg-success",children:"Y"}),v("p",{className:"text-fg-subtle",children:"(m)"})]}),v(Nn,{className:"w-full",value:w,step:Number(k)||1,handleChange:(N,E,W)=>{j("y",N,W?.type)},handleEnter:N=>{Ke("y",N)},onButtonPointerDown:ue,onButtonPointerUp:oe})]}),C($,{className:"gap-1",children:[C(we,{className:"typo-compact-xs-medium gap-1",children:[v("p",{className:"text-fg-brand",children:"Z"}),v("p",{className:"text-fg-subtle",children:"(m)"})]}),v(Nn,{className:"w-full",value:T,step:Number(k)||1,handleChange:(N,E,W)=>{j("z",N,W?.type)},handleEnter:N=>{Ke("z",N)},onButtonPointerDown:ue,onButtonPointerUp:oe})]})]}),C($,{className:"gap-1",children:[C(we,{className:"typo-compact-xs-medium gap-1",children:[v("p",{className:"text-fg-information",children:"RZ"}),v("p",{className:"text-fg-subtle",children:"(°)"})]}),v(Nn,{className:"w-full",value:M,step:Number(k)||1,min:0,max:360,handleChange:(N,E,W)=>{j("rz",N,W?.type)},handleEnter:N=>{Ke("rz",N)},onButtonPointerDown:ue,onButtonPointerUp:oe}),Y&&le&&v(we,{className:"mt-2 justify-center",children:v(nt,{variant:"transparent",size:"sm",leadingIcon:v(ba,{}),onClick:Be,children:"Match Robot Pose"})})]})]})})]}),v(Bo,{cancelLabel:h("move.amr.rightPanel.common.cancel"),saveLabel:h("move.amr.rightPanel.common.saveChanges"),onCancel:async()=>{await d({title:h("move.amr.rightPanel.common.cancel"),content:h("move.amr.rightPanel.topology.dialog.discardContent"),buttonText:{yes:h("move.amr.rightPanel.common.discard"),no:h("move.amr.rightPanel.common.keepEditing")}})&&l?.()},onSave:c,children:C("button",{className:"typo-compact-sm-normal text-fg-danger hover:bg-fill-subtle flex items-center justify-center gap-1 rounded-md py-2 transition-colors",onClick:o,children:[v(Mh,{className:"size-4"}),h("move.amr.rightPanel.common.delete")]})})]})},{useEffect:KR,useMemo:$R,useRef:QR,useState:sc}=await At("react"),JR=r=>{const e=r.toLowerCase();return e==="goal"?v(xy,{className:"text-fg-warning"}):e==="route"?v(Kg,{className:"text-fg-brand"}):v(_y,{className:"text-fg-success"})},eN=({nodes:r=[],selectedObjects:e=[],selectedNodeTransform:t=null,robotPose:n=null,onNodeSelected:i,selectedTool:s="select",onToolChange:a,selectedNodeType:o="goal",onSelectNodeType:l,selectedNodePlacementType:c="cursor",onSelectNodePlacementType:d,onAddNodeAtRobot:h,onAddNodeAtCursor:u,onUpdateNode:f,onChangeNodeType:m,onTransformSelectedNodes:b,onDeleteSelectedNodes:p,onSaveTopologyChanges:g,onCancelTopologyChanges:y,showRobotPlacement:x=!0})=>{const{t:w}=tn(),P=QR(null),[T,A]=sc(""),[M,_]=sc("all"),[S,R]=sc(!1),[k,O]=sc(!1),H=e.length>0,q=$R(()=>{const V=T.trim().toLowerCase(),Y=V?r.filter(le=>(le.name||le.id).toLowerCase().includes(V)):r;return{all:Y,goal:Y.filter(le=>le.type.toLowerCase()==="goal"),route:Y.filter(le=>le.type.toLowerCase()==="route"),align:Y.filter(le=>le.type.toLowerCase()==="align")}},[r,T]),G=q[M];KR(()=>{const V=P.current;if(!V)return;const Y=()=>{const{scrollTop:le,clientHeight:se,scrollHeight:ge}=V;R(le>4),O(le+se<ge-4)};return Y(),V.addEventListener("scroll",Y),()=>{V.removeEventListener("scroll",Y)}},[G]);const K=V=>V.length===0?v(go,{className:"h-full w-full flex-1 [&_[data-slot='empty-view-section']]:h-full",type:"icon",icon:v(vy,{}),message:w("move.amr.rightPanel.topology.nodes.empty")}):V.map(Y=>C($,{children:[C(we,{className:"hover:bg-fill-subtle cursor-pointer items-center justify-between rounded-md px-1.5 py-1.5 transition-colors",onClick:le=>{const se=le.metaKey||le.ctrlKey?"remove":le.shiftKey?"add":"replace";i?.(Y.uuid,se)},children:[C(we,{className:"min-w-0 flex-1 items-center gap-2",children:[JR(Y.type),C(we,{className:"min-w-0 flex-1 items-center justify-between gap-2",children:[v("p",{className:"typo-compact-xs-normal text-fg-default truncate",children:Y.name?Y.name:`${Y.id}(ID)`}),C(we,{className:"mr-2 shrink-0 items-center gap-1.5",children:[v("p",{className:"typo-compact-2xs-semibold text-fg-subtler uppercase",children:Y.type}),v(ts,{type:"vertical",thickness:"thick",className:"text-fg-subtler h-4"}),C("p",{className:"typo-compact-2xs-normal text-fg-subtler",children:[Y.x.toFixed(1),", ",Y.y.toFixed(1),", ",Y.z.toFixed(1)]})]})]})]}),v(yy,{className:"text-fg-default"})]}),v(ts,{className:"text-fg-subtler"})]},Y.uuid));return C($,{className:"h-full min-h-0 gap-0",children:[C($,{className:"border-subtler h-[25%] min-h-[16rem] gap-2 border-b p-3",children:[v(Rn,{size:"sm",className:"w-full",value:T,type:"search",placeholder:w("move.amr.rightPanel.topology.nodes.searchByName"),onChange:V=>{A(V.target.value)}}),C(Zg,{className:"min-h-0 w-full flex-1",variant:"line",value:M,onValueChange:V=>{(V==="all"||V==="goal"||V==="route"||V==="align")&&_(V)},children:[C(we,{className:"items-center justify-between gap-2",children:[C(qg,{children:[v(vr,{value:"all",children:w("move.amr.rightPanel.topology.nodeType.all")}),v(vr,{value:"goal",children:w("move.amr.rightPanel.topology.nodeType.goal")}),v(vr,{value:"route",children:w("move.amr.rightPanel.topology.nodeType.route")}),v(vr,{value:"align",children:w("move.amr.rightPanel.topology.nodeType.align")})]}),C("p",{className:"typo-compact-2xs-semibold text-fg-subtler shrink-0 px-2",children:[G.length," / ",r.length]})]}),C("div",{className:"border-border-subtle bg-fill-disabled relative min-h-0 flex-1 overflow-hidden rounded-md border",children:[G.length>4&&S&&v("div",{className:"from-bg-alt-1 pointer-events-none absolute top-0 right-0 left-0 z-[1] h-3 rounded-t-md bg-gradient-to-b to-transparent"}),C("div",{ref:P,className:"h-full min-h-0 overflow-y-auto px-1 py-0.5",children:[v(Xo,{value:"all",className:"h-full",children:v($,{className:"h-full min-h-0 gap-1",children:K(q.all)})}),v(Xo,{value:"goal",className:"h-full",children:v($,{className:"h-full min-h-0 gap-1",children:K(q.goal)})}),v(Xo,{value:"route",className:"h-full",children:v($,{className:"h-full min-h-0 gap-1",children:K(q.route)})}),v(Xo,{value:"align",className:"h-full",children:v($,{className:"h-full min-h-0 gap-1",children:K(q.align)})})]}),G.length>4&&k&&v("div",{className:"from-bg-alt-1 pointer-events-none absolute right-0 bottom-0 left-0 z-[1] h-6 rounded-b-md bg-gradient-to-t to-transparent"})]})]})]}),v($,{className:"min-h-0 flex-1",children:H?v(YR,{selectedObjects:e,selectedNodeTransform:t,nodes:r,robotPose:n,onUpdateNode:f,onChangeNodeType:m,onTransformSelectedNodes:b,onDeleteSelectedNodes:p,onCancelTopologyChanges:y,onSaveTopologyChanges:g}):v(XR,{selectedTool:s,onToolChange:a,selectedNodeType:o,onSelectNodeType:l,selectedNodePlacementType:c,onSelectNodePlacementType:d,onAddNodeAtRobot:h,onAddNodeAtCursor:u,onSaveTopologyChanges:g,onCancelTopologyChanges:y,showRobotPlacement:x})})]})},rc=({label:r,value:e})=>C("div",{className:"flex items-center justify-between gap-2",children:[v("span",{className:"typo-compact-xs-normal text-fg-subtle",children:r}),v("span",{className:"typo-compact-xs-semibold text-fg-default",children:e})]}),tN=r=>{if(!r)return"-";const e=new Date(r);return Number.isNaN(e.getTime())?r:r.slice(0,19).replace("T"," ")},nN=({nodeCount:r=0,linkCount:e,zoneCount:t=0,createdAt:n,downloadDisabled:i=!1,downloadHelpText:s,onDownloadTopology:a,onCancelTopologyChanges:o,onSaveTopologyChanges:l})=>{const{t:c}=tn();return C($,{className:"h-full min-h-0",children:[C($,{className:"min-h-0 flex-1 gap-4 p-3",children:[C($,{className:"gap-2",children:[v("p",{className:"typo-compact-sm-bold text-fg-default",children:c("move.amr.rightPanel.topology.overview.title")}),v("p",{className:"typo-compact-xs-normal text-fg-subtle",children:c("move.amr.rightPanel.topology.overview.description")})]}),C($,{className:"border-subtler bg-fill-control-surface gap-3 rounded-lg border p-3",children:[v("p",{className:"typo-compact-xs-semibold text-fg-default",children:c("move.amr.rightPanel.topology.overview.summaryTitle")}),C($,{className:"gap-2",children:[v(rc,{label:c("move.amr.rightPanel.topology.overview.createdAt"),value:tN(n)}),v(rc,{label:c("move.amr.rightPanel.topology.overview.nodes"),value:r}),v(rc,{label:c("move.amr.rightPanel.topology.overview.links"),value:e??"-"}),v(rc,{label:c("move.amr.rightPanel.topology.overview.zones"),value:t})]})]}),C($,{className:"border-subtler bg-fill-control-surface gap-2 rounded-lg border p-3",children:[v("p",{className:"typo-compact-xs-semibold text-fg-default",children:c("move.amr.rightPanel.topology.overview.fileTitle")}),v("p",{className:"typo-compact-xs-normal text-fg-subtle",children:c("move.amr.rightPanel.topology.overview.fileDescription")}),s&&v("p",{className:"typo-compact-xs-normal text-fg-warning",children:s})]})]}),v(Bo,{cancelLabel:c("move.amr.rightPanel.common.cancel"),saveLabel:c("move.amr.rightPanel.common.save"),onCancel:o,onSave:l,children:v(nt,{variant:"soft",className:"h-9",disabled:i,leadingIcon:v(wy,{}),onClick:a,children:c("move.amr.rightPanel.topology.overview.download")})})]})},{useMemo:ac}=await At("react"),iN=["NO_ENTRY","IGNORE_LIDAR_2D","IGNORE_LIDAR_3D"],sN=({draft:r={state:"idle",editingZoneId:null,selectedVertexIndex:null,name:"",type:"NO_ENTRY",pointCount:0,points:[]},selectedZoneIds:e,focusedZoneId:t,onFocusedZoneChange:n,onDraftStart:i,onDraftCancel:s,onDraftClear:a,onDraftUndo:o,onDraftClose:l,onDraftReopen:c,onDraftCommit:d,onDraftMetaChange:h,zones:u,onEditZone:f,onDeleteZone:m,hasUnsavedTopologyChanges:b=!1,isTopologySaving:p=!1,onSaveTopologyChanges:g,onCancelTopologyChanges:y})=>{const{t:x}=tn(),{confirmDialog:w}=Co({confirmComponent:Po}),P=ac(()=>{if(e.length===0)return[];const be=new Set(e);return u.filter(Ce=>be.has(Ce.id))},[e,u]),T=ac(()=>r.editingZoneId?u.find(be=>be.id===r.editingZoneId)??null:t?P.find(be=>be.id===t)??null:P[0]??null,[r.editingZoneId,t,P,u]),A=ac(()=>r.editingZoneId?u.find(be=>be.id===r.editingZoneId)??null:null,[r.editingZoneId,u]),M=e.length>1,_=ac(()=>M?"multi-select":r.editingZoneId||P.length>0?"edit":"create",[r.editingZoneId,M,P.length]),S=A??T,R=r.state==="idle",k=r.state==="closed",O=r.editingZoneId!==null,H=r.state!=="idle",q=H,G=R&&T!==null,K=r.points.length>0&&!k,V=r.points.length>0&&!k,Y=r.points.length>=3&&!k,le=k,se=b&&!H&&!p,ge=!H&&S===null,de=H?r.name:S?.name??"",X=H?r.type:S?.type??"",ee=x(O?"move.amr.rightPanel.topology.zone.updateZone":"move.amr.rightPanel.topology.zone.createZone");x(O?"move.amr.rightPanel.topology.zone.discardEditContent":"move.amr.rightPanel.topology.zone.discardDraftContent");const ie=x(G?"move.amr.rightPanel.topology.zone.createNewZone":"move.amr.rightPanel.topology.zone.startDrawing"),Z=H,ue=_==="create"&&R,oe=_==="multi-select"?x("move.amr.rightPanel.topology.zone.selectedCount",{count:e.length}):_==="edit"?r.editingZoneId?x("move.amr.rightPanel.topology.zone.editingZone"):x("move.amr.rightPanel.topology.zone.oneSelected"):x("move.amr.rightPanel.topology.zone.createZone");return C($,{className:"h-full min-h-0",children:[C($,{className:"min-h-0 flex-1 gap-3 overflow-y-auto p-3",children:[v(we,{className:"border-subtler gap-1.5 border-b pb-3",children:v($,{className:"gap-0.5",children:v("p",{className:"compact-sm-semibold text-fg-default",children:oe})})}),P.length>0&&!r.editingZoneId&&C(hi,{children:[C($,{className:"gap-2",children:[v("p",{className:"typo-compact-sm2-semibold text-fg-default",children:x("move.amr.rightPanel.topology.zone.selectedZones")}),v($,{className:"border-border-subtle max-h-40 gap-1 overflow-y-auto rounded-md border p-1.5",children:P.map((be,Ce)=>{const je=be.id===T?.id;return C(we,{className:`items-center justify-between rounded-md border px-2 py-1.5 transition-colors ${je?"border-border-default bg-fill-subtler":"border-transparent bg-fill-control-surface hover:border-border-subtle"}`,onClick:()=>{n(be.id)},children:[v("p",{className:"typo-compact-xs-semibold text-fg-default truncate",children:`${Ce+1}. ${be.name||be.id}`}),v("p",{className:"typo-compact-xs-normal text-fg-subtler shrink-0",children:x("move.amr.rightPanel.topology.zone.pointCount",{type:be.type,count:be.polygon.length})})]},be.id)})})]}),v(ts,{})]}),C($,{className:$t("gap-2",ge&&"opacity-50"),children:[v("p",{className:"typo-compact-sm2-semibold text-fg-default",children:x("move.amr.rightPanel.topology.zone.details")}),C($,{className:"gap-1",children:[v("p",{className:"typo-compact-xs-semibold text-fg-default",children:x("move.amr.rightPanel.topology.zone.name")}),q?v(Rn,{className:"w-full",size:"sm",placeholder:x("move.amr.rightPanel.topology.zone.namePlaceholder"),value:de,onChange:be=>{h?.({name:be.target.value})}}):v("div",{className:"border-border-subtle bg-fill-control-surface rounded-md border px-3 py-2",children:v("p",{className:"typo-compact-xs-normal text-fg-default",children:de||"-"})})]}),C($,{className:"gap-1",children:[v("p",{className:"typo-compact-xs-semibold text-fg-default",children:x("move.amr.rightPanel.topology.zone.type")}),q?v("div",{className:"grid grid-cols-1 gap-2",children:iN.map(be=>v(ii,{className:"w-full",name:`topology-zone-type-${be.toLowerCase()}`,checkValue:be,value:X,onChange:Ce=>{Ce.target.checked&&h?.({type:be})},children:be},be))}):v("div",{className:"border-border-subtle bg-fill-control-surface rounded-md border px-3 py-2",children:v("p",{className:"typo-compact-xs-normal text-fg-default",children:X||"-"})})]})]}),v(ts,{})]}),C(Bo,{cancelLabel:x("move.amr.rightPanel.common.discard"),saveLabel:x(p?"move.amr.rightPanel.common.saving":"move.amr.rightPanel.common.saveChanges"),cancelDisabled:!se,saveDisabled:!se,onCancel:async()=>{await w({title:x("move.amr.rightPanel.common.discard"),content:x("move.amr.rightPanel.topology.dialog.discardContent"),buttonText:{yes:x("move.amr.rightPanel.common.discard"),no:x("move.amr.rightPanel.common.keepEditing")}})&&y?.()},onSave:()=>{g?.()},children:[ue&&v(nt,{variant:"soft",className:"text-fg-default py-2",onClick:()=>{i?.({name:r.name,type:r.type})},children:ie}),R&&G&&C(hi,{children:[v(nt,{variant:"soft",className:"text-fg-default py-2",onClick:()=>{f?.(T.id)},children:x("move.amr.rightPanel.topology.zone.editZone")}),v(nt,{variant:"dangerSoft",className:"py-2",onClick:async()=>{await w({title:x("move.amr.rightPanel.topology.zone.deleteZone"),content:x("move.amr.rightPanel.topology.zone.deleteContent"),buttonText:{yes:x("move.amr.rightPanel.common.delete"),no:x("move.amr.rightPanel.topology.zone.keep")}})&&m?.(T.id)},children:x("move.amr.rightPanel.topology.zone.deleteZone")})]}),Z&&C(hi,{children:[C("div",{className:"grid grid-cols-2 gap-2",children:[v(nt,{variant:"outlined",disabled:!K,onClick:o,children:x("move.amr.rightPanel.topology.zone.undoLastPoint")}),v(nt,{variant:"outlined",disabled:!V,onClick:a,children:x("move.amr.rightPanel.topology.zone.clearPoints")})]}),!k&&v(nt,{variant:"dangerSoft",disabled:!Y,onClick:l,children:x("move.amr.rightPanel.topology.zone.closeZone")}),k&&C(hi,{children:[v(nt,{variant:"soft",className:"text-fg-default py-2",onClick:c,children:x(O?"move.amr.rightPanel.topology.zone.reopenZone":"move.amr.rightPanel.topology.zone.reopen")}),v(nt,{variant:"brand",className:"py-2",disabled:!le,onClick:d,children:ee})]})]})]})]})},{memo:rN,useCallback:yh,useEffect:aN,useState:oN}=await At("react"),xh="topology_tab",_h=r=>r==="overview"||r==="node"||r==="link"||r==="zone",lN=[{labelKey:"move.amr.rightPanel.topology.tab.overview",value:"overview"},{labelKey:"move.amr.rightPanel.topology.tab.node",value:"node"},{labelKey:"move.amr.rightPanel.topology.tab.link",value:"link"},{labelKey:"move.amr.rightPanel.topology.tab.zone",value:"zone"}],cN=({className:r,overviewTabProps:e,nodeTabProps:t,linkTabProps:n,zoneTabProps:i})=>{const{theme:s}=Ea(),{t:a}=tn(),{confirmDialog:o}=Co({confirmComponent:Po}),[l,c]=qy(),[d,h]=oN(()=>{const p=l.get(xh)??"";return _h(p)?p:"overview"}),u=i?.draft?.state==="drawing"||i?.draft?.state==="closed",f=yh(async()=>await o({title:"Leave Zone",content:"Leaving the Zone tab will discard the current zone draft. Continue?",buttonText:{yes:"Leave",no:a("move.amr.rightPanel.common.cancel")}})?(i?.onDraftCancel?.(),!0):!1,[o,a,i]),m=yh(async()=>{await o({title:a("move.amr.rightPanel.common.cancel"),content:a("move.amr.rightPanel.topology.dialog.discardContent"),buttonText:{yes:a("move.amr.rightPanel.common.discard"),no:a("move.amr.rightPanel.common.keepEditing")}})&&t?.onCancelTopologyChanges?.()},[o,t,a]),b=yh(async p=>{if(d===p||d==="zone"&&p!=="zone"&&u&&!await f())return;h(p);const g=new URLSearchParams(l);g.set(xh,p),c(g,{replace:!0})},[f,u,l,c,d]);return aN(()=>{const p=l.get(xh)??"",g=_h(p)?p:"overview";h(y=>y!==g?g:y)},[l]),v("div",{className:$t("TopologyControl","h-full",r),children:v("div",{className:"flex h-full min-h-0 gap-0",children:C("div",{className:"flex h-full min-h-0 flex-1 flex-col overflow-x-hidden",children:[v("div",{className:$t("sticky top-0 left-0 z-2",s==="light"?"bg-default":"bg-alt-1"),children:v(Sy,{tabItems:lN.map(p=>({key:p.value,label:a(p.labelKey)})),activeKey:d,handleChange:async p=>{_h(p)&&await b(p)},size:"xs",tabBtnClassName:"typo-compact-xs-bold light:bg-white light:[&.active]:bg-fill-navy! light:[&.active]:text-white!"})}),C($,{className:"min-h-0 flex-1 overflow-y-auto",children:[d==="overview"&&v(nN,{...e,nodeCount:t?.nodes?.length??0,linkCount:n?.links?.length??0,zoneCount:i?.zones?.length??0,onCancelTopologyChanges:m,onSaveTopologyChanges:t?.onSaveTopologyChanges}),d==="node"&&v(eN,{...t}),d==="link"&&v(jR,{...n}),d==="zone"&&v(sN,{...i})]})]})})})},m2=rN(cN),dN=await At("react"),hN={APRILTAG:"AprilTag",ARUCO:"ArUco"},uN={x:"text-fg-danger",y:"text-fg-success",z:"text-fg-brand",rx:"text-fg-danger",ry:"text-fg-success",rz:"text-fg-brand"},na=({label:r,value:e})=>C(we,{className:"items-baseline gap-1",children:[v("span",{className:`typo-compact-xs-semibold ${uN[r]??"text-fg-subtler"}`,children:r}),v("span",{className:"typo-compact-xs-normal text-fg-default font-mono",children:e})]}),fN=({detection:r,isSelected:e,onSelect:t})=>{const n=hN[r.type]??r.type,i=r.confidence!=null?Math.round(r.confidence*100):null,s=r.confidence!=null&&r.confidence>=.85,a=[r.distM!=null?r.distM.toFixed(2)+" m":"—",...(r.camIds?.length?r.camIds:[r.camId]).map(o=>`cam ${o}`)];return v("button",{type:"button",onClick:()=>t(String(r.markerId)),className:$t("w-full rounded-md border text-left transition-all",e?"border-fg-brand bg-fill-brand-subtlest":"bg-fill-disabled hover:bg-fill-subtlest border-transparent"),children:C($,{className:"gap-1 px-3 py-2.5",children:[C(we,{className:"items-center justify-between",children:[C(we,{className:"items-center gap-2",children:[C("span",{className:["typo-compact-lg-semibold",e?"text-fg-brand":"text-fg-default"].join(" "),children:["#",r.markerId]}),v("span",{className:["typo-compact-2xs-semibold rounded-full px-2 py-0.5",e?"bg-fg-brand text-white":"bg-fill-disabled text-fg-subtle"].join(" "),children:n})]}),i!=null&&C("span",{className:["typo-compact-sm-semibold",s?"text-fg-success":"text-fg-caution"].join(" "),children:[i,"%"]})]}),v(we,{className:"items-center gap-1.5",children:a.map((o,l)=>C(dN.Fragment,{children:[l>0&&v("span",{className:"text-fg-subtler",children:"·"}),v("span",{className:"typo-compact-xs-normal text-fg-subtle",children:o})]},o))}),r.pose?C($,{className:"gap-0.5",children:[C(we,{className:"items-center gap-3",children:[v(na,{label:"x",value:r.pose.x.toFixed(3)}),v(na,{label:"y",value:r.pose.y.toFixed(3)}),r.pose.z!=null&&v(na,{label:"z",value:r.pose.z.toFixed(3)})]}),C(we,{className:"items-center gap-3",children:[r.pose.rx!=null&&v(na,{label:"rx",value:`${r.pose.rx.toFixed(1)}°`}),r.pose.ry!=null&&v(na,{label:"ry",value:`${r.pose.ry.toFixed(1)}°`}),v(na,{label:"rz",value:`${r.pose.rz.toFixed(1)}°`})]})]}):v(go,{type:"icon",icon:v(ba,{}),message:"No pose data",className:"py-1"})]})})},{useEffect:pN,useMemo:mN,useState:so}=await At("react"),gN=[{label:"0.04m",value:"0.04"},{label:"0.1m",value:"0.10"},{label:"0.15m",value:"0.15"}],bN=(r,e)=>(r.confidence??0)!==(e.confidence??0)?(r.confidence??0)>(e.confidence??0):r.distM!=null&&e.distM!=null?r.distM<e.distM:r.distM!=null?!0:e.distM!=null?!1:r.camId<e.camId,vN=r=>{const e=new Map,t=new Map;return r.forEach(n=>{const i=t.get(n.markerId)??new Set;i.add(n.camId),n.camIds?.forEach(a=>i.add(a)),t.set(n.markerId,i);const s=e.get(n.markerId);(!s||bN(n,s))&&e.set(n.markerId,n)}),Array.from(e.values()).map(n=>({...n,camIds:Array.from(t.get(n.markerId)??[n.camId]).filter(i=>Number.isFinite(i)).sort((i,s)=>i-s)}))},g2=({mode:r="register",isScanning:e=!1,detections:t=[],onRegisterMarker:n,isRegisterPending:i=!1,lastRegisteredMarkerId:s,registeredMarkers:a=[],capturedPose:o=null,onCapturePose:l,onTeachTarget:c})=>{const{t:d}=tn(),[h,u]=so(""),f=mN(()=>vN(t),[t]);pN(()=>{s!=null&&u("")},[s]);const[m,b]=so("WALL"),[p,g]=so("0.10"),[y,x]=so(null),[w,P]=so(""),T=f.find(H=>String(H.markerId)===h)??null,A=H=>{u(H)},M=()=>{T&&n?.({camId:T.camId,markerId:T.markerId,type:T.type,mount:m,markerSizeM:Number(p)})},_=()=>{!y||!w||(c?.({markerNodeId:y.nodeId,markerId:y.markerId,nodeName:w}),P(""))},S=f.length>0,R=f.map(H=>H.distM).filter(H=>Number.isFinite(H)).sort((H,q)=>H-q)[0],k=R!=null?`${R.toFixed(2)}m`:"-",O=v($,{className:"border-subtler gap-2 border-b p-3",children:C($,{className:"bg-fill-disabled gap-1 rounded-md p-3",children:[C(we,{className:"items-center justify-between gap-3",children:[C(we,{className:"items-center gap-1",children:[v(ba,{className:"text-fg-subtle size-4"}),v("p",{className:"typo-compact-xs2-normal text-fg-subtle",children:d("move.amr.rightPanel.marker.markerStatus")})]}),C(we,{className:"items-center gap-1.5",children:[v(yi,{color:S?"green":"gray"}),v("p",{className:"typo-compact-sm-semibold text-fg-default uppercase",children:S?d("move.amr.rightPanel.marker.foundCount",{count:f.length}):d("move.amr.rightPanel.marker.notFound")})]})]}),C(we,{className:"items-center justify-between gap-3",children:[C(we,{className:"items-center gap-1",children:[v(Kg,{className:"text-fg-subtle size-4"}),v("p",{className:"typo-compact-xs2-normal text-fg-subtle",children:d("move.title.distance")})]}),v("p",{className:"typo-compact-sm-semibold text-fg-default",children:k})]})]})});return r==="register"?C($,{className:"h-full gap-0",children:[O,C($,{className:"flex-1 gap-0 overflow-y-auto",children:[f.length===0?v("div",{className:"p-3 pb-0",children:v(go,{type:"icon",icon:v(Sf,{}),message:d("move.amr.rightPanel.marker.notFound"),className:"bg-fill-disabled rounded-md"})}):v($,{className:"gap-2 p-3 pb-0",children:f.map(H=>v(fN,{detection:H,isSelected:h===String(H.markerId),onSelect:A},H.markerId))}),C($,{className:"gap-3 p-3",children:[C($,{className:"gap-1",children:[v("p",{className:"typo-compact-xs-semibold text-fg-default",children:d("move.amr.rightPanel.marker.markerId")}),v("div",{className:"bg-fill-disabled border-border-subtler flex h-8 items-center rounded-md border px-3",children:v("p",{className:`typo-compact-sm-normal ${T?"text-fg-default":"text-fg-subtler"}`,children:T?`#${T.markerId}`:"—"})})]}),C($,{className:"gap-1",children:[v("p",{className:"typo-compact-xs-semibold text-fg-default",children:d("move.amr.rightPanel.marker.markerType")}),v("div",{className:"bg-fill-disabled border-border-subtler flex h-8 items-center rounded-md border px-3",children:v("p",{className:`typo-compact-sm-normal ${T?"text-fg-default":"text-fg-subtler"}`,children:T?T.type==="ARUCO"?"ArUco":"AprilTag":"—"})})]}),C($,{className:"gap-2",children:[C($,{className:"gap-1",children:[v("p",{className:"typo-compact-xs-semibold text-fg-default",children:d("move.amr.rightPanel.marker.markerSize")}),v(we,{className:"items-center",children:v(Nn,{className:"flex-1",size:"sm",value:p,step:.05,digit:2,fixedDigit:2,min:"0.01",max:"1.00",handleChange:H=>g(H)})})]}),v(we,{className:"gap-2",children:gN.map(H=>v(ii,{className:"flex-1",value:p,checkValue:H.value,unCheckValue:H.value,handleChange:q=>g(q),size:"sm",children:H.label},H.value))})]}),C($,{className:"gap-1",children:[v("p",{className:"typo-compact-xs-semibold text-fg-default",children:d("move.amr.rightPanel.marker.mount")}),C(we,{className:"gap-2",children:[v(ii,{className:"w-full",value:m,checkValue:"WALL",unCheckValue:"WALL",handleChange:H=>b(H),size:"sm",children:d("move.amr.rightPanel.marker.mount.wall")}),v(ii,{className:"w-full",value:m,checkValue:"FLOOR",unCheckValue:"FLOOR",handleChange:H=>b(H),size:"sm",children:d("move.amr.rightPanel.marker.mount.floor")})]})]})]})]}),v("div",{className:"p-3",children:v(nt,{variant:"brand",className:"h-9 w-full",onClick:M,disabled:!T||i,children:T?d("move.amr.rightPanel.marker.registerId",{id:T.markerId}):d("move.amr.rightPanel.marker.registerMarker")})})]}):C($,{className:"h-full gap-0",children:[O,C($,{className:"flex-1 gap-3 overflow-y-auto p-3",children:[C($,{className:"gap-1",children:[v("p",{className:"typo-compact-xs-semibold text-fg-default",children:d("move.amr.rightPanel.marker.targetMarker")}),v(ca,{size:"sm",value:y?String(y.markerId):"",handleChange:H=>{const q=a.find(G=>String(G.markerId)===H);x(q??null)},disabled:a.length===0,children:a.length===0?v(Pi,{value:"",children:d("move.amr.rightPanel.marker.noRegisteredMarkers")}):a.map(H=>C(Pi,{value:String(H.markerId),children:["id ",H.markerId," · ",H.type," · ",H.mount]},H.markerId))})]}),y?.precisionTarget&&(()=>{const H=y.precisionTarget,q=H.context.match(/dock_offset=([^;]+)/)?.[1]?.split(",")??[];return v($,{className:"gap-2",children:v("div",{className:"bg-fill-disabled rounded-md px-3 py-2.5",children:C($,{className:"gap-2",children:[H.nodeName&&v("p",{className:"typo-compact-sm-semibold text-fg-default",children:H.nodeName}),q.length>0&&C($,{className:"gap-0.5",children:[v("p",{className:"typo-compact-2xs-normal text-fg-subtler",children:d("move.amr.rightPanel.marker.dockOffset")}),v("div",{className:"grid grid-cols-3 gap-x-2 gap-y-0.5",children:["x","y","z","rx","ry","rz"].map((G,K)=>C(we,{className:"items-baseline gap-1",children:[v("span",{className:"typo-compact-xs-semibold text-fg-subtle w-4",children:G}),v("span",{className:"typo-compact-xs-normal text-fg-default truncate font-mono",children:q[K]?Number(q[K]).toFixed(3):"—"})]},G))})]})]})})})})(),C($,{className:"gap-1",children:[v("p",{className:"typo-compact-xs-semibold text-fg-default",children:d("move.amr.rightPanel.marker.capturedPose")}),o?v("div",{className:"bg-fill-disabled rounded-md px-3 py-2.5",children:v(we,{className:"items-center gap-3",children:[{label:"x",value:o.x.toFixed(3),color:"text-fg-danger"},{label:"y",value:o.y.toFixed(3),color:"text-fg-success"},{label:"θ",value:`${o.rz.toFixed(1)}°`,color:"text-fg-brand"}].map(({label:H,value:q,color:G})=>C(we,{className:"items-baseline gap-1",children:[v("span",{className:`typo-compact-xs-semibold ${G}`,children:H}),v("span",{className:"typo-compact-xs-normal text-fg-default font-mono",children:q})]},H))})}):v("div",{className:"bg-fill-disabled rounded-md px-3 py-2",children:v(go,{type:"icon",icon:v(Sf,{}),message:d("move.amr.rightPanel.marker.moveRobotThenCapture"),className:"py-1"})}),v(nt,{size:"xs2",variant:"soft",leadingIcon:v(ba,{}),onClick:l,disabled:!y,children:d("move.amr.rightPanel.marker.captureCurrentPose")})]}),C($,{className:"gap-1",children:[v("p",{className:"typo-compact-xs-semibold text-fg-default",children:d("move.amr.rightPanel.marker.targetName")}),v(Rn,{className:"w-full",size:"sm",placeholder:d("move.amr.rightPanel.marker.targetNamePlaceholder"),value:w,onChange:H=>P(H.target.value)})]})]}),v("div",{className:"p-3",children:v(nt,{variant:"brand",className:"h-9 w-full",onClick:_,disabled:!y||!w||!o,children:d("move.amr.rightPanel.marker.saveTarget")})})]})},{useEffect:yN}=await At("react"),xN={KeyV:"select",KeyT:"target",KeyG:"move",KeyR:"rotate",KeyS:"scale"},Ng=r=>{if(!(r instanceof HTMLElement))return!1;if(r.isContentEditable)return!0;const e=r.tagName.toLowerCase();if(e==="textarea"||e==="select")return!0;if(e==="input"){const n=r.type.toLowerCase();return n===""||n==="text"||n==="search"||n==="email"||n==="password"||n==="number"||n==="tel"||n==="url"}return!!r.closest("textarea, select, [contenteditable='true'], input:not([type]), input[type='text'], input[type='search'], input[type='email'], input[type='password'], input[type='number'], input[type='tel'], input[type='url']")},b2=({enabled:r=!0,tools:e,topology:t,selection:n,camera:i,link:s,zone:a})=>{const{enabled:o=!0,selectedTool:l,onToolChange:c,hasSelectedNode:d=!0,hasSelectedZone:h=!1}=e,u=t?.enabled??!0,f=!!t,m=t?.selectedNodePlacementType,b=t?.onAddNodeAtRobot,p=t?.onAddNodeAtCursor,g=n?.enabled??!0,y=!!n,x=n?.hasSelectedNodes??!1,w=n?.hasSelectedLinks??!1,P=n?.hasSelectedZones??!1,T=n?.onDeleteSelectedNodes,A=n?.onDeleteSelectedLinks,M=n?.onDeleteSelectedZones,_=i?.enabled??!0,S=!!i,R=i?.hasSelectedNode??!1,k=i?.onFocusSelectedNode,O=s?.enabled??!0,H=!!s,q=s?.selectedNodeCount??0,G=s?.onCreateLinks,K=a?.enabled??!0,V=!!a,Y=a?.state,le=a?.pointCount??0,se=a?.onCloseDraft;yN(()=>{if(!r)return;const ge=(oe,be)=>{o&&(l==="disabled"&&be!=="select"&&be!=="target"||h&&(be==="rotate"||be==="scale")||l!==be&&(oe.preventDefault(),c(be)))},de=oe=>{if(!(!f||!u)){if(m==="robot"){oe.preventDefault(),b?.();return}l==="target"&&(oe.preventDefault(),p?.())}},X=oe=>{if(!(!y||!g)){if(x){oe.preventDefault(),T?.();return}if(w){oe.preventDefault(),A?.();return}P&&(oe.preventDefault(),M?.())}},ee=oe=>{!S||!_||!R||(oe.preventDefault(),k?.())},ie=oe=>{!H||!O||q<2||(oe.preventDefault(),G?.())},Z=oe=>{!V||!K||Y!=="drawing"||le<3||(oe.preventDefault(),se?.())},ue=oe=>{if(!(Ng(oe.target)||Ng(document.activeElement))&&!oe.repeat&&!(oe.metaKey||oe.ctrlKey||oe.altKey||oe.shiftKey))switch(oe.code){case"Escape":Z(oe);return;case"KeyN":de(oe);return;case"Delete":case"Backspace":X(oe);return;case"KeyF":ee(oe);return;case"KeyL":ie(oe);return;case"KeyV":case"KeyT":case"KeyG":case"KeyR":case"KeyS":{const be=xN[oe.code];if(!be)return;ge(oe,be);return}default:return}};return window.addEventListener("keydown",ue),()=>{window.removeEventListener("keydown",ue)}},[r,_,S,R,H,y,w,d,h,x,P,f,V,p,b,A,T,M,k,G,se,c,m,q,l,g,o,u,O,Y,K,le])},{useState:_N,useCallback:wN}=await At("react"),v2=()=>{const[r,e]=_N("select"),t=wN(n=>{e(n)},[]);return{selectedTool:r,onToolChange:t}},{useEffect:Dg,useRef:Lg,useState:SN}=await At("react"),Ig=.5,MN=520;function y2({anchorObject:r,anchorWorldPosition:e,worldStudioRef:t,viewportHostRef:n,horizontalPlacementBoundary:i=MN}){const[s,a]=SN(null),o=Lg(null),l=Lg(null);return Dg(()=>{const c=()=>{const m=n.current,b=t.current?.getCanvas();o.current=m?.getBoundingClientRect()??null,l.current=b?.getBoundingClientRect()??null};c();const d=n.current,h=t.current?.getCanvas(),u=new ResizeObserver(()=>{c()});d&&u.observe(d),h&&u.observe(h);const f=()=>{c()};return window.addEventListener("resize",f),window.addEventListener("scroll",f,!0),document.addEventListener("fullscreenchange",f),()=>{u.disconnect(),window.removeEventListener("resize",f),window.removeEventListener("scroll",f,!0),document.removeEventListener("fullscreenchange",f)}},[n,t]),Dg(()=>{if(!r&&!e){a(null);return}let c=0;const d=new I,h=new I,u=()=>{const f=t.current?.getCanvas(),m=t.current?.getCamera(),b=n.current;if(!f||!m||!b){a(A=>A===null?A:null),c=requestAnimationFrame(u);return}if(m.updateMatrixWorld(),r)r.updateMatrixWorld(),r.getWorldPosition(h);else if(e)h.copy(e);else{a(A=>A===null?A:null),c=requestAnimationFrame(u);return}d.copy(h).project(m);const p=o.current,g=l.current;if(!p||!g){a(A=>A===null?A:null),c=requestAnimationFrame(u);return}const y=(d.x+1)/2*g.width,x=(-d.y+1)/2*g.height,w=y+g.left-p.left,P=x+g.top-p.top,T=Number.isFinite(w)&&Number.isFinite(P)&&d.z>=-1&&d.z<=1&&w>=0&&w<=p.width&&P>=0&&P<=p.height;a(A=>{if(!T)return A===null?A:null;const M={x:w,y:P,placement:w>p.width-i?"left":"right"};return A&&Math.abs(A.x-M.x)<Ig&&Math.abs(A.y-M.y)<Ig&&A.placement===M.placement?A:M}),c=requestAnimationFrame(u)};return u(),()=>{cancelAnimationFrame(c)}},[r,e,i,n,t]),s}const{useEffect:TN,useMemo:ia,useRef:EN,useState:ci}=await At("react"),x2=(r,e=!1)=>{const{t}=tn(),[n,i]=ci(!0),[s,a]=ci(!1),[o,l]=ci(!1),[c,d]=ci(!1),[h,u]=ci(!1),[f,m]=ci(!0),[b,p]=ci(!0),[g,y]=ci(!1),[x,w]=ci(_u),[P,T]=ci(Kb),[A,M]=ci(!1),[_,S]=ci(0),[R,k]=ci(0),[O,H]=ci("topView"),q=EN(!1);TN(()=>{!r||q.current||(S(r.minZ),k(r.maxZ))},[r]);const G=ia(()=>[{id:"lidarPoints",label:t(e?"move.amr.rightPanel.capability.lidar2d":"move.amr.viewportControls.visibility.lidarPoints"),description:t("move.amr.viewportControls.visibility.lidarPointsDescription"),checked:f,onCheckedChange:m},...e?[{id:"lidar3DPoints",label:t("move.amr.rightPanel.capability.lidar3d"),description:t("move.amr.viewportControls.visibility.lidarPointsDescription"),checked:b,onCheckedChange:p}]:[],{id:"simpleNodes",label:t("move.amr.viewportControls.visibility.simpleNodes"),description:t("move.amr.viewportControls.visibility.simpleNodesDescription"),checked:h,onCheckedChange:u},{id:"nodeLabels",label:t("move.amr.viewportControls.visibility.nodeLabels"),description:t("move.amr.viewportControls.visibility.nodeLabelsDescription"),checked:c,onCheckedChange:d},{id:"grid",label:t("move.amr.viewportControls.visibility.grid"),description:t("move.amr.viewportControls.visibility.gridDescription"),checked:n,onCheckedChange:i},{id:"mapBoundary",label:t("move.amr.viewportControls.visibility.mapBoundary"),description:t("move.amr.viewportControls.visibility.mapBoundaryDescription"),checked:g,onCheckedChange:y}],[n,f,b,e,g,c,h,t]),K=ia(()=>({label:t("move.amr.viewportControls.camera.projection"),description:t("move.amr.viewportControls.camera.projectionDescription"),value:O,items:[{label:t("move.amr.viewportControls.camera.topView"),value:"topView",description:t("move.amr.viewportControls.camera.topViewDescription")},{label:t("move.amr.viewportControls.camera.perspective"),value:"perspective",description:t("move.amr.viewportControls.camera.perspectiveDescription")}],onChange:ge=>{H(ge)}}),[t,O]),V=ia(()=>({sectionLabel:t("move.amr.viewportControls.section.manualCamera"),label:t("move.amr.viewportControls.camera.move"),description:t("move.amr.viewportControls.camera.moveDescription")}),[t]),Y=ia(()=>[{id:"mapPointSize",label:`${t("move.amr.rightPanel.map.info.pointCloud")} ${t("settings.tool.title.size")}`,value:P,min:.01,max:.3,step:.01,digit:2,onChange:T},{id:"lidarPointSize",label:t("move.amr.viewportControls.rendering.lidarPointSize"),description:t("move.amr.viewportControls.rendering.lidarPointSizeDescription"),value:x,min:.01,max:.5,step:.01,digit:2,onChange:w}],[x,P,t]),le=ia(()=>({enabled:A,minZ:_,maxZ:R,bounds:r?{minZ:r.minZ,maxZ:r.maxZ}:void 0,onEnabledChange:M,onMinZChange:ge=>{q.current=!0,S(ge)},onMaxZChange:ge=>{q.current=!0,k(ge)},onReset:()=>{q.current=!1,r&&(S(r.minZ),k(r.maxZ)),M(!1)}}),[A,r,R,_]),se=ia(()=>A?{minZ:_,maxZ:R}:null,[A,R,_]);return{showGrid:n,setShowGrid:i,showJoysticks:s,setShowJoysticks:a,showViewControls:o,setShowViewControls:l,showNodeLabels:c,setShowNodeLabels:d,showSimpleNodes:h,setShowSimpleNodes:u,showLidar:f,setShowLidar:m,showLidar3D:b,setShowLidar3D:p,showMapBoundary:g,setShowMapBoundary:y,lidarPointSize:x,setLidarPointSize:w,mapPointSize:P,setMapPointSize:T,viewportCameraMode:O,visibilityItems:G,cameraModeControl:K,cameraMoveControl:V,renderingSettingItems:Y,mapPointHeightClip:se,pointCloudHeightClipControl:le}},{useMemo:AN}=await At("react"),_2=({loading:r,isDefaultData:e,mapCloud:t,topology:n,nodes:i,links:s})=>AN(()=>{const a=!r&&!e,o=t?.rowCount??t?.data?.length??0,l=i?.length??n?.nodes?.length??0,c=s?.length??n?.links?.length??0;return{isLive:a,pointCount:o,latency:0,fps:0,nodeCount:l,linkCount:c}},[e,r,t?.data?.length,t?.rowCount,s?.length,i?.length,n?.links?.length,n?.nodes?.length]),{useCallback:wh}=await At("react"),w2=()=>{const r=wh((n,i,s)=>{const a=new Blob([i],{type:s?.mimeType}),o=window.URL.createObjectURL(a),l=document.createElement("a");l.href=o,l.download=n,l.click(),window.URL.revokeObjectURL(o)},[]),e=wh((n,i)=>{const s=JSON.stringify(i,null,2)??"";r(n,s,{mimeType:"application/json"})},[r]),t=wh((n,i)=>{const s=i.map(a=>a.map(o=>o??"").join(",")).join(`
|
|
4753
4753
|
`);r(n,s,{mimeType:"text/csv;charset=utf-8;"})},[r]);return{downloadFile:r,downloadJsonFile:e,downloadCsvFile:t}},Dv=`const d=e=>Math.min(1,Math.max(0,e)),a=e=>e<=.04045?e/12.92:((e+.055)/1.055)**2.4,L=e=>{const t=d(Math.sqrt(e/255));return{r:d(.13572138+t*(4.6153926+t*(-42.66032258+t*(132.13108234+t*(-152.94239396+t*59.28637943))))),g:d(.09140261+t*(2.19418839+t*(4.84296658+t*(-14.18503333+t*(4.27729857+t*2.82956604))))),b:d(.1066733+t*(12.64194608+t*(-60.58204836+t*(110.36276771+t*(-89.90310912+t*27.34824973)))))}},x=e=>{switch(e){case 2:return 20;case 3:return 28;case 7:case 8:return 30;default:return null}},A=e=>{const t=new DataView(e);if(t.byteLength<227||t.getUint32(0,!1)!==1279349574)throw new Error("Invalid LAS buffer.");const r=t.getUint32(96,!0),h=t.getUint8(104)&63,g=t.getUint16(105,!0),w=t.getUint32(107,!0),o=w>0&&h<=5?w:Number(t.getBigUint64(247,!0));if(!Number.isSafeInteger(o)||g<20||r+o*g>t.byteLength)throw new Error("Invalid LAS point data.");const p=[t.getFloat64(131,!0),t.getFloat64(139,!0),t.getFloat64(147,!0)],b=[t.getFloat64(155,!0),t.getFloat64(163,!0),t.getFloat64(171,!0)],l=new Float32Array(o*3),U=new Float32Array(o),f=new Float32Array(o*3),i=x(h),u=i===null?void 0:new Float32Array(o*3);let C=!1;for(let c=0;c<o;c+=1){const s=r+c*g,n=c*3;l[n]=t.getInt32(s,!0)*p[0]+b[0],l[n+1]=t.getInt32(s+4,!0)*p[1]+b[1],l[n+2]=t.getInt32(s+8,!0)*p[2]+b[2];const F=t.getUint16(s+12,!0);U[c]=F,C||=F>0;const y=L(F);f[n]=a(y.r),f[n+1]=a(y.g),f[n+2]=a(y.b),u&&i!==null&&i+6<=g&&(u[n]=a(t.getUint16(s+i,!0)/65535),u[n+1]=a(t.getUint16(s+i+2,!0)/65535),u[n+2]=a(t.getUint16(s+i+4,!0)/65535))}return{pointCount:o,positions:l,colors:u,intensities:C?U:void 0,intensityColors:f,bounds:{minX:t.getFloat64(187,!0),minY:t.getFloat64(203,!0),minZ:t.getFloat64(219,!0),maxX:t.getFloat64(179,!0),maxY:t.getFloat64(195,!0),maxZ:t.getFloat64(211,!0)}}},m=self;m.onmessage=e=>{try{const t=A(e.data.buffer),r=[t.positions.buffer];t.intensityColors&&r.push(t.intensityColors.buffer),t.colors&&r.push(t.colors.buffer),t.intensities&&r.push(t.intensities.buffer),m.postMessage({id:e.data.id,type:"success",data:t},r)}catch(t){m.postMessage({id:e.data.id,type:"error",message:t instanceof Error?t.message:"Unknown LAS error."})}};
|
|
4754
|
-
`,kg=typeof self<"u"&&self.Blob&&new Blob(["URL.revokeObjectURL(import.meta.url);",Dv],{type:"text/javascript;charset=utf-8"});function CN(r){let e;try{if(e=kg&&(self.URL||self.webkitURL).createObjectURL(kg),!e)throw"";const t=new Worker(e,{type:"module",name:r?.name});return t.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(e)}),t}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(Dv),{type:"module",name:r?.name})}}const{useEffect:PN,useRef:RN,useState:NN}=await At("react"),Og={data:null,error:null,loading:!1},S2=r=>{const[e,t]=NN(Og),n=RN(0);return PN(()=>{if(!r){n.current+=1,t(Og);return}const i=n.current+1;n.current=i,t({data:null,error:null,loading:!0});let s;try{s=new CN}catch(o){t({data:null,error:o instanceof Error?o:new Error("Failed to create LAS parser worker."),loading:!1});return}s.onmessage=o=>{n.current===o.data.id&&(t(o.data.type==="success"?{data:o.data.data,error:null,loading:!1}:{data:null,error:new Error(o.data.message),loading:!1}),s.terminate())},s.onerror=o=>{n.current===i&&t({data:null,error:new Error(o.message),loading:!1}),s.terminate()};const a=r.slice(0);return s.postMessage({id:i,buffer:a},[a]),()=>s.terminate()},[r]),e};export{YA as $,Lf as A,fi as B,Ne as C,ln as D,hn as E,Si as F,Vt as G,To as H,Hs as I,zc as J,sv as K,fo as L,Ii as M,GN as N,Pt as O,ns as P,Lt as Q,yi as R,wn as S,xi as T,sf as U,I as V,Sp as W,Hc as X,JA as Y,uu as Z,TE as _,zN as a,
|
|
4754
|
+
`,kg=typeof self<"u"&&self.Blob&&new Blob(["URL.revokeObjectURL(import.meta.url);",Dv],{type:"text/javascript;charset=utf-8"});function CN(r){let e;try{if(e=kg&&(self.URL||self.webkitURL).createObjectURL(kg),!e)throw"";const t=new Worker(e,{type:"module",name:r?.name});return t.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(e)}),t}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(Dv),{type:"module",name:r?.name})}}const{useEffect:PN,useRef:RN,useState:NN}=await At("react"),Og={data:null,error:null,loading:!1},S2=r=>{const[e,t]=NN(Og),n=RN(0);return PN(()=>{if(!r){n.current+=1,t(Og);return}const i=n.current+1;n.current=i,t({data:null,error:null,loading:!0});let s;try{s=new CN}catch(o){t({data:null,error:o instanceof Error?o:new Error("Failed to create LAS parser worker."),loading:!1});return}s.onmessage=o=>{n.current===o.data.id&&(t(o.data.type==="success"?{data:o.data.data,error:null,loading:!1}:{data:null,error:new Error(o.data.message),loading:!1}),s.terminate())},s.onerror=o=>{n.current===i&&t({data:null,error:new Error(o.message),loading:!1}),s.terminate()};const a=r.slice(0);return s.postMessage({id:i,buffer:a},[a]),()=>s.terminate()},[r]),e};export{YA as $,Lf as A,fi as B,Ne as C,ln as D,hn as E,Si as F,Vt as G,To as H,Hs as I,zc as J,sv as K,fo as L,Ii as M,GN as N,Pt as O,ns as P,Lt as Q,yi as R,wn as S,xi as T,sf as U,I as V,Sp as W,Hc as X,JA as Y,uu as Z,TE as _,zN as a,rg as a$,ex as a0,ZA as a1,$A as a2,gn as a3,qA as a4,DA as a5,e1 as a6,QA as a7,Pa as a8,jN as a9,AR as aA,FP as aB,t2 as aC,p2 as aD,y2 as aE,S2 as aF,w2 as aG,v2 as aH,x2 as aI,b2 as aJ,_2 as aK,JN as aL,QN as aM,e2 as aN,o2 as aO,l2 as aP,i2 as aQ,n2 as aR,m2 as aS,r2 as aT,a2 as aU,s2 as aV,UN as aW,Cy as aX,FN as aY,Wy as aZ,YN as a_,w0 as aa,VN as ab,t1 as ac,Lb as ad,Jt as ae,Fn as af,pi as ag,Ys as ah,gt as ai,ke as aj,wi as ak,mr as al,Pn as am,Bc as an,Qb as ao,AA as ap,Jb as aq,ZN as ar,Yd as as,qy as at,KN as au,ON as av,EE as aw,$N as ax,EP as ay,qN as az,me as b,AP as b0,u2 as b1,b1 as b2,Ta as b3,OP as b4,UP as b5,Pv as b6,h2 as b7,XN as b8,fP as b9,x1 as ba,f2 as bb,_1 as bc,g2 as bd,gs as be,xC as bf,TC as bg,c2 as bh,DC as bi,IC as bj,d2 as bk,Bo as bl,jR as bm,XR as bn,YR as bo,eN as bp,nN as bq,sN as br,WC as bs,uP as bt,tf as c,jt as d,HN as e,rn as f,Ee as g,bt as h,Yt as i,Ie as j,H_ as k,BN as l,yr as m,Aa as n,Ks as o,Ab as p,qn as q,sa as r,vn as s,WN as t,Oc as u,ht as v,xt as w,zn as x,RE as y,js as z};
|